get_step info bug

This commit is contained in:
曹前明 2022-06-29 14:53:25 +08:00
parent 464f1930fc
commit 4dc8918f80
2 changed files with 8 additions and 9 deletions

View File

@ -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]

View File

@ -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)