From f59cb2cbc2cc48e7904627d067415f3e80d1c9ac Mon Sep 17 00:00:00 2001 From: caoqianming Date: Mon, 10 Mar 2025 17:58:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=AA=E6=8B=86=E6=89=B92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/wpm/views.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/apps/wpm/views.py b/apps/wpm/views.py index ed67b8c1..78438892 100644 --- a/apps/wpm/views.py +++ b/apps/wpm/views.py @@ -712,18 +712,26 @@ class MlogbwViewSet(CustomModelViewSet): mlogbin = ins.mlogb wm_in = mlogbin.wm_in mlog = mlogbin.mlog + div_number = route.div_number m_dict = { "mtask": mlogbin.mtask, "mlog": mlog, "material_out": material_out, + "batch_ofrom": wm_in.batch_ofrom, + "material_ofrom": wm_in.material_ofrom, + "count_real": div_number, + "count_ok": div_number, "qct": mlog.qct } - div_number = route.div_number - mlogbout, _ = Mlogb.objects.get_or_create(**m_dict, defaults= - {"batch_ofrom": wm_in.batch_ofrom, "material_ofrom": wm_in.material_ofrom, "count_real": div_number, "count_ok": div_number, "qct": mlog.qct}) + if ins.mlogb_to: + mlogbout = ins.mlogb_to + else: + mlogbout = Mlogb.objects.create(**m_dict) + ins.mlogb_to = mlogbout + ins.save(update_fields=["mlogb_to"]) if material_out.tracking == Material.MA_TRACKING_SINGLE: for i in range(div_number): Mlogbw.objects.get_or_create(mlogb=mlogbout, defaults=f'{ins.number}-{i+1}') - Mlogbw.cal_count_notok(mlogb_to) + Mlogbw.cal_count_notok(mlogbout) elif mlogb_to and material_out.tracking == Material.MA_TRACKING_SINGLE: if route.process.mtype == Process.PRO_NORMAL: Mlogbw.objects.get_or_create(mlogb=mlogb_to, wpr=ins.wpr, defaults={"number": ins.number})