From 94a218c09a2b34d06798d5e8b641f7bc5b168426 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Mon, 8 Sep 2025 11:18:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=AC=A1=E6=89=B9=E8=A7=A6=E5=8F=91?= =?UTF-8?q?=E8=BE=93=E5=87=BA=E4=BA=A7=E7=94=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/wpm/views.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/apps/wpm/views.py b/apps/wpm/views.py index ce0aec04..1d033d4b 100644 --- a/apps/wpm/views.py +++ b/apps/wpm/views.py @@ -686,6 +686,7 @@ class MlogbInViewSet(CreateModelMixin, UpdateModelMixin, DestroyModelMixin, Cust @classmethod def p_create_after(cls, mlogbin:Mlogb): + mlogbin_parent:Mlogb = mlogbin.parent mlog:Mlog = mlogbin.mlog mgroup:Mgroup = mlog.mgroup route:Route = mlogbin.route @@ -703,7 +704,11 @@ class MlogbInViewSet(CreateModelMixin, UpdateModelMixin, DestroyModelMixin, Cust raise ParseError('产物不可为空') # 如果是主要输入物料且是主批次,才需生成输出 if is_fix is False and route and route.material_in != material_in or mlogbin.parent is not None: - return + # 如果次批且是结合工序,需要触发产生输出 + if mtype and mtype == Process.PRO_DIV: + pass + else: + return wm_in: WMaterial = mlogbin.wm_in @@ -790,7 +795,19 @@ class MlogbInViewSet(CreateModelMixin, UpdateModelMixin, DestroyModelMixin, Cust mlogbout.save(update_fields=["count_json_from"]) elif mtype == Process.PRO_MERGE: # 支持批到批,批到个 div_number = route.div_number - xcount = math.floor( (mlogbin.count_use-mlogbin.count_pn_jgqbl) / div_number) + if mlogbin_parent is not None: + # 说明是次批 + if mlogbin.material_in == mlogbin_parent.material_in: + # 如果主次物料一致,则进行处理 + count_use_sum = Mlogb.objects.filter(Q(id=mlogbin_parent.id)|Q(parent=mlogbin_parent), material_in=mlogbin.material_in).aggregate(Sum('count_use'))['count_use__sum'] or 0 + 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("暂不支持主次物料不一致") + # 使用主批作为后续引用 + mlogbin = mlogbin_parent + else: + xcount = math.floor( (mlogbin.count_use-mlogbin.count_pn_jgqbl) / div_number) d_count_real = xcount d_count_ok = xcount number_to_batch = process.number_to_batch