This commit is contained in:
zty 2024-09-25 16:04:03 +08:00
commit 7517da3e92
2 changed files with 24 additions and 0 deletions

View File

@ -319,5 +319,18 @@ class PmService:
mtask.submit_time = now
mtask.submit_user = user
mtask.save()
utask = mtask.utask
PmService.utask_submit(utask)
else:
raise ParseError('该任务状态不可提交')
@classmethod
def utask_submit(cls, utask: Utask):
"""
生产大任务提交
"""
if utask.state == Utask.UTASK_WORKING and Mtask.objects.filter(utask=utask).exclude(state=Mtask.MTASK_SUBMIT).count() == 0:
utask.state = Utask.UTASK_SUBMIT
utask.save()
else:
raise ParseError('该任务状态不可提交')

View File

@ -36,6 +36,17 @@ class UtaskViewSet(CustomModelViewSet):
raise ParseError('该任务状态不可删除')
return super().perform_destroy(instance)
@action(methods=['post'], detail=True, perms_map={'post': 'utask.submit'}, serializer_class=Serializer)
@transaction.atomic
def submit(self, request, *args, **kwargs):
"""提交任务
提交任务
"""
obj = self.get_object()
PmService.utask_submit(obj)
return Response()
@action(methods=['post'], detail=True, perms_map={'post': 'utask.toggle'}, serializer_class=Serializer)
@transaction.atomic
def toggle(self, request, *args, **kwargs):