From 4518344fa6164b974fcc9c5b78fcbf48a62c8235 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Thu, 14 Nov 2024 13:04:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20do=5Fout=20=E9=A2=86=E6=96=99=E6=97=B6?= =?UTF-8?q?=E7=9A=84material=5Fofrom?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/inm/services.py | 27 +++++++++------------------ apps/wpm/services.py | 22 ++++++++++++++-------- 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/apps/inm/services.py b/apps/inm/services.py index e86cc06d..49f6f965 100644 --- a/apps/inm/services.py +++ b/apps/inm/services.py @@ -68,25 +68,16 @@ def do_out(item: MIOItem): mb.save() # 领到车间库存(或工段) - ddict = { - "batch": xbatch, - "material": xmaterial, - "count": xcount, - "create_by": do_user, - "belong_dept": belong_dept, - "mgroup": mgroup, - "state": WMaterial.WM_OK, - } wm, new_create = WMaterial.objects.get_or_create(batch=xbatch, material=xmaterial, belong_dept=belong_dept, mgroup=mgroup, - state=WMaterial.WM_OK, - defaults=ddict) - if not new_create: - wm.count = wm.count + item.count - wm.update_by = do_user - wm.batch_ofrom = mb.batch_ofrom if mb else None - wm.material_ofrom = mb.material_ofrom if mb else None - wm.save() + state=WMaterial.WM_OK) + if new_create: + wm.create_by = do_user + wm.batch_ofrom = mb.batch if mb else None + wm.material_ofrom = mb.material if mb else None + wm.count = wm.count + item.count + wm.update_by = do_user + wm.save() def do_in(item: MIOItem): @@ -154,7 +145,7 @@ def do_in(item: MIOItem): defaults={ "count": 0, "batch_ofrom": wm.batch_ofrom, - "material_ofrom": xmaterial, + "material_ofrom": wm.material_ofrom, "production_dept": production_dept } ) diff --git a/apps/wpm/services.py b/apps/wpm/services.py index 3a701669..d24fde94 100644 --- a/apps/wpm/services.py +++ b/apps/wpm/services.py @@ -137,7 +137,7 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]): for mi in m_ins.all(): m_ins_list.append((mi.material_in, mi.batch, mi.count_use, mi.wm_in)) if mi.count_pn_jgqbl > 0: - m_ins_bl_list.append((mi.material_in, mi.batch, mi.count_pn_jgqbl)) + m_ins_bl_list.append((mi.material_in, mi.batch, mi.count_pn_jgqbl, mi)) else: m_ins_list = [(material_in, mlog.batch, mlog.count_use, mlog.wm_in)] for mi in m_ins_list: @@ -170,15 +170,16 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]): wm.save() # 针对加工前不良的暂时额外处理 for item in m_ins_bl_list: - material, batch, count_pn_jgqbl = item + material, batch, count_pn_jgqbl, mi_ = item if count_pn_jgqbl> 0: lookup = {'batch': batch, 'material': material, 'mgroup': mgroup, 'notok_sign': 'jgqbl', 'state': WMaterial.WM_NOTOK} wm, is_create = WMaterial.objects.get_or_create(**lookup, defaults={**lookup, "belong_dept": belong_dept}) wm.count = wm.count + count_pn_jgqbl if is_create: wm.create_by = user - else: - wm.update_by = user + wm.batch_ofrom = mi_.batch_ofrom + wm.material_ofrom = mi_.material_ofrom + wm.update_by = user wm.save() @@ -218,6 +219,7 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]): if supplier is not None: wm.supplier = supplier if is_create2: + wm.create_by = user if isinstance(mlog_or_b, Mlog) and mlog_or_b.wm_in: wm.batch_ofrom = mlog_or_b.wm_in.batch_ofrom wm.material_ofrom = mlog_or_b.wm_in.material_ofrom @@ -512,7 +514,8 @@ def handover_submit(handover: Handover, user: User, now: Union[datetime.datetime state=WMaterial.WM_OK, defaults={ "batch_ofrom": wm_from.batch_ofrom, - "material_ofrom": wm_from.material_ofrom + "material_ofrom": wm_from.material_ofrom, + "create_by": user } ) elif handover.type == Handover.H_REPAIR: @@ -527,7 +530,8 @@ def handover_submit(handover: Handover, user: User, now: Union[datetime.datetime state=WMaterial.WM_REPAIR, defaults={ "batch_ofrom": wm_from.batch_ofrom, - "material_ofrom": wm_from.material_ofrom + "material_ofrom": wm_from.material_ofrom, + "create_by": user } ) else: @@ -542,7 +546,8 @@ def handover_submit(handover: Handover, user: User, now: Union[datetime.datetime defaults={ "count_xtest": 0, "batch_ofrom": wm_from.batch_ofrom, - "material_ofrom": wm_from.material_ofrom + "material_ofrom": wm_from.material_ofrom, + "create_by": user }, ) elif handover.type == Handover.H_SCRAP: @@ -556,7 +561,8 @@ def handover_submit(handover: Handover, user: User, now: Union[datetime.datetime state=WMaterial.WM_SCRAP, defaults={ "batch_ofrom": wm_from.batch_ofrom, - "material_ofrom": wm_from.material_ofrom + "material_ofrom": wm_from.material_ofrom, + "create_by": user } ) else: