diff --git a/hb_server/apps/qm/views.py b/hb_server/apps/qm/views.py index 717cd5b..247e6d6 100644 --- a/hb_server/apps/qm/views.py +++ b/hb_server/apps/qm/views.py @@ -77,6 +77,7 @@ class TestRecordViewSet(ListModelMixin, UpdateModelMixin, RetrieveModelMixin, De obj = self.get_object() if obj.is_submited: raise exceptions.APIException('该记录已提交不可删除') + WpmServies.add_wproduct_flow_log(obj.wproduct, 'test_delete') return super().destroy(request, *args, **kwargs) @action(methods=['post'], detail=True, perms_map={'post':'*'}, serializer_class=TestRecordUpdateSerializer) @@ -89,7 +90,7 @@ class TestRecordViewSet(ListModelMixin, UpdateModelMixin, RetrieveModelMixin, De with transaction.atomic(): obj.is_submited=True obj.save() - WpmServies.update_wproduct_by_test(obj, request.user) + WpmServies.update_wproduct_by_test(obj, request.user) # 这里已经做了日志记录和进度计算 return Response() # def create(self, request, *args, **kwargs): diff --git a/hb_server/apps/wpm/services.py b/hb_server/apps/wpm/services.py index a4ef8aa..bd68bb7 100644 --- a/hb_server/apps/wpm/services.py +++ b/hb_server/apps/wpm/services.py @@ -73,10 +73,6 @@ class WpmServies(object): participant_type=State.PARTICIPANT_TYPE_PERSONAL, intervene_type=0, participant=user) - - - # 更新子计划相关进度 - cls.update_subproduction_progress_main(sp=wproduct.subproduction_plan) else:# 如果不合格 wproduct.act_state = WProduct.WPR_ACT_STATE_NOTOK # 需要走不合格品审理的工单 @@ -95,11 +91,15 @@ class WpmServies(object): intervene_type=0, participant=user) - wproduct.update_by = user wproduct.update_time = timezone.now() wproduct.test = None wproduct.save() + # 添加日志 + cls.add_wproduct_flow_log(wproduct, 'test_ok' if is_testok else 'test_notok') + # 更新子计划相关进度 + cls.update_subproduction_progress_main(sp=wproduct.subproduction_plan) + @classmethod def update_subproduction_progress_main(cls, sp:SubProductionPlan): diff --git a/hb_server/apps/wpm/signals.py b/hb_server/apps/wpm/signals.py index de92df1..91a4dcf 100644 --- a/hb_server/apps/wpm/signals.py +++ b/hb_server/apps/wpm/signals.py @@ -35,6 +35,7 @@ def handleTicket(sender, instance, created, **kwargs): wproduct.ticket = instance wproduct.save() WpmServies.add_wproduct_flow_log(wproduct, 'ticket_create') + # 检验员 if not ticket_data.get('tester', None): ticket_data['tester'] = test_record.create_by.id @@ -68,11 +69,7 @@ def handleTicket(sender, instance, created, **kwargs): wt.save() wp.ticket = None # 解除当前工单 wp.act_state = WProduct.WPR_ACT_STATE_DOWAIT - wp.save() - WpmServies.add_wproduct_flow_log(wp, 'ticket_finish') - # 更新子计划合格进度 - WpmServies.update_subproduction_progress_main(sp=sp) - + wp.save() else: raise exceptions.APIException('返回步骤点错误') @@ -82,5 +79,9 @@ def handleTicket(sender, instance, created, **kwargs): wt.save() wp.ticket = None # 解除当前工单 wp.save() - WpmServies.add_wproduct_flow_log(wp, 'ticket_finish') + + # 添加日志 + WpmServies.add_wproduct_flow_log(wp, 'ticket_finish') + # 更新子计划合格进度 + WpmServies.update_subproduction_progress_main(sp=wp.subproduction_plan)