diff --git a/hb_server/apps/mtm/views.py b/hb_server/apps/mtm/views.py index c5932e5..7ab01d0 100644 --- a/hb_server/apps/mtm/views.py +++ b/hb_server/apps/mtm/views.py @@ -166,7 +166,7 @@ class UsedStepViewSet(OptimizationMixin, CreateModelMixin, DestroyModelMixin, Li 'put':'subproduction_update', 'delete':'subproduction_update'} queryset = UsedStep.objects.all() filterset_fields = ['subproduction', 'step'] - ordering = ['step__sort', '-step__create_time'] + ordering = ['step__number', 'step__create_time'] def get_serializer_class(self): if self.action =='create': diff --git a/hb_server/apps/wpm/services.py b/hb_server/apps/wpm/services.py index 55ad079..1587c55 100644 --- a/hb_server/apps/wpm/services.py +++ b/hb_server/apps/wpm/services.py @@ -2,6 +2,7 @@ from django.utils import timezone from typing import List from django.db.models.expressions import F +from apps.mtm.serializers import UsedStepListSerializer from apps.pm.models import ProductionPlan, SubProductionPlan, SubProductionProgress from apps.mtm.models import Material, Step, SubprodctionMaterial, UsedStep 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') + if nowstep is None: + try: + nowstep = used_steps[0].step + except: + pass for index, i in enumerate(used_steps): if i.step == nowstep: try: 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: - return nowstep, False, True + return nowstep, i.need_test, i.reuse_form raise ParseError('获取步骤信息失败') # steps_list = subproduction_plan.steps diff --git a/hb_server/apps/wpm/views.py b/hb_server/apps/wpm/views.py index a532c26..a72ae13 100644 --- a/hb_server/apps/wpm/views.py +++ b/hb_server/apps/wpm/views.py @@ -36,7 +36,7 @@ from apps.wpm.services import WpmService from django.utils import timezone from rest_framework import status from django.db.models import Count, Q - +from rest_framework.exceptions import ParseError from utils.tools import ranstr @@ -717,6 +717,7 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd else: wp.act_state = WProduct.WPR_ACT_STATE_DOWAIT if needTest: #子工序若需要检验 + print(needTest, reuseForm) wp.act_state = WProduct.WPR_ACT_STATE_TOTEST last_test = wp.last_wp_test if last_test and reuseForm: