From 4dc8918f809644c7eb177cf32814c37481349dc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E5=89=8D=E6=98=8E?= <909355014@qq.com> Date: Wed, 29 Jun 2022 14:53:25 +0800 Subject: [PATCH] get_step info bug --- hb_server/apps/wpm/services.py | 13 ++++++------- hb_server/apps/wpm/views.py | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/hb_server/apps/wpm/services.py b/hb_server/apps/wpm/services.py index fddb01a..55ad079 100644 --- a/hb_server/apps/wpm/services.py +++ b/hb_server/apps/wpm/services.py @@ -13,20 +13,19 @@ from rest_framework.exceptions import ParseError class WpmService(object): @classmethod - def get_step_info(cls, subproduction_plan:SubProductionPlan, nowstep:Step, get_next=True): + def get_step_info(cls, subproduction_plan:SubProductionPlan, nowstep:Step): """ - 获取本步骤或下一步骤的信息 + 返回下一步骤, 当前步骤是否需要检验, 当前步骤是否需要复用表 """ used_steps = UsedStep.objects.filter(subproduction=subproduction_plan.subproduction).order_by('step__number') for index, i in enumerate(used_steps): - if i.step == nowstep and get_next: + if i.step == nowstep: try: used_step = used_steps[index+1] - return used_step.step, used_step.need_test, used_step.reuse_form + return used_step.step, i.need_test, i.reuise_form except: - return nowstep, i.need_test, i.reuse_form - elif i.step == nowstep and get_next == False: - return nowstep, i.need_test, i.reuse_form + return nowstep, False, True + raise ParseError('获取步骤信息失败') # steps_list = subproduction_plan.steps # stepIds = [i['id'] for i in steps_list] diff --git a/hb_server/apps/wpm/views.py b/hb_server/apps/wpm/views.py index e5a4d0c..a532c26 100644 --- a/hb_server/apps/wpm/views.py +++ b/hb_server/apps/wpm/views.py @@ -213,8 +213,8 @@ class WProductViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet): elif wproduct.act_state == WProduct.WPR_ACT_STATE_TOCOMBTEST: savedict['type'] = TestRecord.TEST_COMB elif wproduct.act_state == WProduct.WPR_ACT_STATE_TOTEST: - step, need_test, _ = WpmService.get_step_info(wproduct.subproduction_plan, wproduct.pre_step, get_next=False) - if need_test and wproduct.step != step: + _, need_test, _ = WpmService.get_step_info(wproduct.subproduction_plan, wproduct.pre_step) + if need_test and wproduct.step != wproduct.pre_step: savedict['is_midtesting'] = True # if UsedStep.objects.filter(subproduction=wproduct.subproduction_plan.subproduction).first().need_test: tr = TestRecord.objects.create(**savedict)