From 8cc9c46a950eb95853210e3730e9292a87cb45b4 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Mon, 8 Sep 2025 14:29:19 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=B7=A5=E8=89=BA=E6=AD=A5=E9=AA=A4?= =?UTF-8?q?=E4=B8=AD=E8=BE=85=E6=96=99=E4=BD=BF=E7=94=A8=E7=9A=84=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/wpm/views.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/apps/wpm/views.py b/apps/wpm/views.py index 1d033d4b..27d4bfe6 100644 --- a/apps/wpm/views.py +++ b/apps/wpm/views.py @@ -10,7 +10,7 @@ from django.db.models import Sum from django.utils import timezone from apps.system.models import User -from apps.mtm.models import Material, Process, Route, Mgroup, RoutePack +from apps.mtm.models import Material, Process, Route, Mgroup, RoutePack, RouteMat from apps.utils.viewsets import CustomGenericViewSet, CustomModelViewSet from apps.utils.mixins import CustomListModelMixin, BulkCreateModelMixin, ComplexQueryMixin @@ -702,13 +702,15 @@ class MlogbInViewSet(CreateModelMixin, UpdateModelMixin, DestroyModelMixin, Cust material_out:Material = material_in if is_fix else route.material_out if material_out is None: raise ParseError('产物不可为空') + if route and route.material_in != material_in: + raise ParseError('工艺步骤输入与实际输入不符') # 如果是主要输入物料且是主批次,才需生成输出 - if is_fix is False and route and route.material_in != material_in or mlogbin.parent is not None: - # 如果次批且是结合工序,需要触发产生输出 - if mtype and mtype == Process.PRO_DIV: + if mlogbin_parent is not None: + if mtype and mtype == Process.PRO_MERGE: pass else: return + wm_in: WMaterial = mlogbin.wm_in @@ -803,7 +805,9 @@ class MlogbInViewSet(CreateModelMixin, UpdateModelMixin, DestroyModelMixin, Cust count_pn_jgqbl_sum = Mlogb.objects.filter(Q(id=mlogbin_parent.id)|Q(parent=mlogbin_parent), material_in=mlogbin.material_in).aggregate(Sum('count_pn_jgqbl'))['count_pn_jgqbl__sum'] or 0 xcount = math.floor( (count_use_sum-count_pn_jgqbl_sum) / div_number) else: - raise ParseError("暂不支持主次物料不一致") + # 获取可用的辅料 + if not RouteMat.objects.filter(material=mlogbin.material_in, route=route).exists(): + raise ParseError("工艺步骤中不存在该辅料") # 使用主批作为后续引用 mlogbin = mlogbin_parent else: