检验流转bug

This commit is contained in:
曹前明 2022-06-29 18:07:19 +08:00
parent 4dc8918f80
commit 3a31196f15
3 changed files with 11 additions and 4 deletions

View File

@ -166,7 +166,7 @@ class UsedStepViewSet(OptimizationMixin, CreateModelMixin, DestroyModelMixin, Li
'put':'subproduction_update', 'delete':'subproduction_update'} 'put':'subproduction_update', 'delete':'subproduction_update'}
queryset = UsedStep.objects.all() queryset = UsedStep.objects.all()
filterset_fields = ['subproduction', 'step'] filterset_fields = ['subproduction', 'step']
ordering = ['step__sort', '-step__create_time'] ordering = ['step__number', 'step__create_time']
def get_serializer_class(self): def get_serializer_class(self):
if self.action =='create': if self.action =='create':

View File

@ -2,6 +2,7 @@ from django.utils import timezone
from typing import List from typing import List
from django.db.models.expressions import F from django.db.models.expressions import F
from apps.mtm.serializers import UsedStepListSerializer
from apps.pm.models import ProductionPlan, SubProductionPlan, SubProductionProgress from apps.pm.models import ProductionPlan, SubProductionPlan, SubProductionProgress
from apps.mtm.models import Material, Step, SubprodctionMaterial, UsedStep from apps.mtm.models import Material, Step, SubprodctionMaterial, UsedStep
from apps.qm.models import TestRecord from apps.qm.models import TestRecord
@ -18,13 +19,18 @@ class WpmService(object):
返回下一步骤 当前步骤是否需要检验 当前步骤是否需要复用表 返回下一步骤 当前步骤是否需要检验 当前步骤是否需要复用表
""" """
used_steps = UsedStep.objects.filter(subproduction=subproduction_plan.subproduction).order_by('step__number') used_steps = UsedStep.objects.filter(subproduction=subproduction_plan.subproduction).order_by('step__number')
if nowstep is None:
try:
nowstep = used_steps[0].step
except:
pass
for index, i in enumerate(used_steps): for index, i in enumerate(used_steps):
if i.step == nowstep: if i.step == nowstep:
try: try:
used_step = used_steps[index+1] used_step = used_steps[index+1]
return used_step.step, i.need_test, i.reuise_form return used_step.step, i.need_test, i.reuse_form
except: except:
return nowstep, False, True return nowstep, i.need_test, i.reuse_form
raise ParseError('获取步骤信息失败') raise ParseError('获取步骤信息失败')
# steps_list = subproduction_plan.steps # steps_list = subproduction_plan.steps

View File

@ -36,7 +36,7 @@ from apps.wpm.services import WpmService
from django.utils import timezone from django.utils import timezone
from rest_framework import status from rest_framework import status
from django.db.models import Count, Q from django.db.models import Count, Q
from rest_framework.exceptions import ParseError
from utils.tools import ranstr from utils.tools import ranstr
@ -717,6 +717,7 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd
else: else:
wp.act_state = WProduct.WPR_ACT_STATE_DOWAIT wp.act_state = WProduct.WPR_ACT_STATE_DOWAIT
if needTest: #子工序若需要检验 if needTest: #子工序若需要检验
print(needTest, reuseForm)
wp.act_state = WProduct.WPR_ACT_STATE_TOTEST wp.act_state = WProduct.WPR_ACT_STATE_TOTEST
last_test = wp.last_wp_test last_test = wp.last_wp_test
if last_test and reuseForm: if last_test and reuseForm: