feat: mlogb_submit支持加工前不良
This commit is contained in:
parent
2a9bd7ef6a
commit
925bc2027c
|
@ -167,15 +167,16 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
|||
m_ins_bl_list = []
|
||||
m_ins = Mlogb.objects.filter(mlog=mlog, material_in__isnull=False)
|
||||
if m_ins.exists():
|
||||
for mi in m_ins.all():
|
||||
m_ins_list.append((mi.material_in, mi.batch, mi.count_use, mi))
|
||||
if mi.count_pn_jgqbl > 0:
|
||||
raise ParseError("暂不支持加工前不良")
|
||||
m_ins_bl_list.append((mi.material_in, mi.batch, mi.count_pn_jgqbl, mi))
|
||||
m_ins_list = [(mi.material_in, mi.batch if mi.batch else mi.batch, mi.count_use-mi.count_pn_jgqbl, None, mi) for mi in m_ins.all()]
|
||||
for item in m_ins:
|
||||
mbd_qs = MlogbDefect.objects.filter(mlogb=item)
|
||||
for itemx in mbd_qs:
|
||||
if itemx.defect:
|
||||
m_ins_bl_list.append((item.material_in, item.batch, itemx.count, itemx.defect, item))
|
||||
else:
|
||||
m_ins_list = [(material_in, mlog.batch, mlog.count_use, mlog)]
|
||||
m_ins_list = [(material_in, mlog.batch, mlog.count_use, None, mlog)]
|
||||
for mi in m_ins_list:
|
||||
mi_ma, mi_batch, mi_count, mlog_or_b = mi
|
||||
mi_ma, mi_batch, mi_count, defect, mlog_or_b = mi
|
||||
# 需要判断领用数是否合理
|
||||
# 优先使用工段库存
|
||||
if isinstance(mlog_or_b, Mlogb) and mlog_or_b.wm_in:
|
||||
|
@ -185,7 +186,6 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
|||
if not wm_qs.exists():
|
||||
wm_qs = WMaterial.objects.filter(batch=mi_batch, material=mi_ma,
|
||||
belong_dept=belong_dept, mgroup=None, state=WMaterial.WM_OK)
|
||||
|
||||
count_x = wm_qs.count()
|
||||
if count_x == 1:
|
||||
wm = wm_qs.first()
|
||||
|
@ -214,11 +214,11 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
|||
|
||||
# 针对加工前不良的暂时额外处理
|
||||
for item in m_ins_bl_list:
|
||||
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
|
||||
material, batch, count, defect, mi_ = item
|
||||
if count> 0:
|
||||
lookup = {'batch': batch, 'material': material, 'mgroup': mgroup, 'defect': defect, 'state': WMaterial.WM_NOTOK}
|
||||
wm, is_create = WMaterial.objects.get_or_create(**lookup, defaults={"belong_dept": belong_dept})
|
||||
wm.count = wm.count + count
|
||||
if is_create:
|
||||
wm.create_by = user
|
||||
wm.batch_ofrom = mi_.batch_ofrom
|
||||
|
@ -242,8 +242,8 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
|||
for item in mlogb_out_qs:
|
||||
mbd_qs = MlogbDefect.objects.filter(mlogb=item)
|
||||
if item.qct is not None or mbd_qs.exists():
|
||||
if item.material_out.tracking == Material.MA_TRACKING_SINGLE:
|
||||
Mlogbw.cal_count_notok(item)
|
||||
# if item.material_out.tracking == Material.MA_TRACKING_SINGLE:
|
||||
# Mlogbw.cal_count_notok(item)
|
||||
for itemx in MlogbDefect.objects.filter(mlogb=item):
|
||||
m_outs_list.append((item.material_out, item.batch, itemx.count, 0, itemx.defect, item))
|
||||
# # 获取所有主要的不合格项/先暂时保留
|
||||
|
@ -376,8 +376,8 @@ def mlog_revert(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
|||
for item in mlogb_out_qs:
|
||||
mbd_qs = MlogbDefect.objects.filter(mlogb=item)
|
||||
if item.qct is not None or mbd_qs.exists():
|
||||
if item.material_out.tracking == Material.MA_TRACKING_SINGLE:
|
||||
Mlogbw.cal_count_notok(item)
|
||||
# if item.material_out.tracking == Material.MA_TRACKING_SINGLE:
|
||||
# Mlogbw.cal_count_notok(item)
|
||||
for itemx in MlogbDefect.objects.filter(mlogb=item):
|
||||
m_outs_list.append((item.material_out, item.batch, itemx.count, 0, itemx.defect, item))
|
||||
# if item.material_out.tracking == Material.MA_TRACKING_SINGLE:
|
||||
|
|
Loading…
Reference in New Issue