From 76a48d46eec49b6ed86a93f1a63f4f8700d75510 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Mon, 28 Apr 2025 11:28:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=AA=E5=88=B0=E6=89=B9=E6=97=B6?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=8B=A5=E6=98=AF=E4=B8=80=E4=B8=AA=E8=BF=98?= =?UTF-8?q?=E6=98=AF=E6=B2=BF=E7=94=A8=E5=8E=9F=E6=9C=89=E6=89=B9=E5=8F=B7?= 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 3c17d181..ab2b8546 100644 --- a/apps/wpm/views.py +++ b/apps/wpm/views.py @@ -614,9 +614,15 @@ class MlogbInViewSet(CreateModelMixin, UpdateModelMixin, DestroyModelMixin, Cust elif mtype == Process.PRO_DIV: # 切分 支持批到批,个到个, 个到批 div_number = route.div_number if material_in.tracking == Material.MA_TRACKING_SINGLE and material_out.tracking == Material.MA_TRACKING_BATCH: - for mlogbwin in Mlogbw.objects.filter(mlogb=mlogbin).order_by("number"): - m_dict["batch"] = mlogbwin.number - Mlogb.objects.get_or_create(mlogbw_from=mlogbwin, defaults=update_dict(m_dict, {"count_real": div_number, "count_ok": div_number})) + if Mlogbw.objects.filter(mlogb=mlogbin).count() == 1: + mlogbwin = Mlogbw.objects.filter(mlogb=mlogbin).first() + mlogbout, _ = Mlogb.objects.get_or_create(mlogbw_from=mlogbwin, mlogb_from=mlogbin, defaults=update_dict(m_dict,{"count_real": div_number, "count_ok": div_number})) + mlogbout.count_json_from = mlogbin.count_json_from + mlogbout.save(update_fields=["count_json_from"]) + else: + for mlogbwin in Mlogbw.objects.filter(mlogb=mlogbin).order_by("number"): + m_dict["batch"] = mlogbwin.number + Mlogb.objects.get_or_create(mlogbw_from=mlogbwin, defaults=update_dict(m_dict, {"count_real": div_number, "count_ok": div_number})) elif material_in.tracking == Material.MA_TRACKING_SINGLE and material_out.tracking == Material.MA_TRACKING_SINGLE: d_count_real = mlogbin.count_use * div_number d_count_ok = d_count_real