From f0b24da22f3f972439d5e82fc3572636643a8e8d Mon Sep 17 00:00:00 2001 From: caoqianming Date: Tue, 26 Aug 2025 10:35:21 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20number=5Fto=5Fbatch=20=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E7=BB=93=E5=90=88=E5=B7=A5=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/wpm/views.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/wpm/views.py b/apps/wpm/views.py index 559b9227..17a18828 100644 --- a/apps/wpm/views.py +++ b/apps/wpm/views.py @@ -758,9 +758,11 @@ class MlogbInViewSet(CreateModelMixin, UpdateModelMixin, DestroyModelMixin, Cust xcount = math.floor( (mlogbin.count_use-mlogbin.count_pn_jgqbl) / div_number) d_count_real = xcount d_count_ok = xcount - mlogbout, _ = Mlogb.objects.get_or_create(mlogb_from=mlogbin, defaults=update_dict(m_dict, {"count_real": d_count_real, "count_ok": d_count_ok, "count_ok_full": d_count_ok})) - mlogbout.count_json_from = mlogbin.count_json_from - mlogbout.save(update_fields=["count_json_from"]) + number_to_batch = process.number_to_batch + if not number_to_batch: + mlogbout, _ = Mlogb.objects.get_or_create(mlogb_from=mlogbin, defaults=update_dict(m_dict, {"count_real": d_count_real, "count_ok": d_count_ok, "count_ok_full": d_count_ok})) + mlogbout.count_json_from = mlogbin.count_json_from + mlogbout.save(update_fields=["count_json_from"]) wpr_number_rule = process.wpr_number_rule if material_out.tracking == Material.MA_TRACKING_SINGLE: number = mlogbin.batch @@ -769,6 +771,8 @@ class MlogbInViewSet(CreateModelMixin, UpdateModelMixin, DestroyModelMixin, Cust if d_count_real == 1: if wpr_number_rule: number = MlogbInViewSet.gen_number_with_rule(wpr_number_rule, material_out) + if number_to_batch: + mlogbout, _ = Mlogb.objects.get_or_create(mlogb_from=mlogbin, defaults=update_dict(m_dict, {"count_real": 1, "count_ok": 1, "count_ok_full": 1, "batch": number})) Mlogbw.objects.get_or_create(number=number, mlogb=mlogbout) else: if wpr_number_rule: @@ -778,6 +782,8 @@ class MlogbInViewSet(CreateModelMixin, UpdateModelMixin, DestroyModelMixin, Cust numberx = number_list[i] else: numberx = f'{number}-{i+1}' + if number_to_batch: + mlogbout, _ = Mlogb.objects.get_or_create(mlogb_from=mlogbin, defaults=update_dict(m_dict, {"count_real": 1, "count_ok": 1, "count_ok_full": 1, "batch": numberx})) Mlogbw.objects.get_or_create(number=numberx, mlogb=mlogbout) else: raise ParseError("不支持生成产出物料!")