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_bl_list = []
|
||||||
m_ins = Mlogb.objects.filter(mlog=mlog, material_in__isnull=False)
|
m_ins = Mlogb.objects.filter(mlog=mlog, material_in__isnull=False)
|
||||||
if m_ins.exists():
|
if m_ins.exists():
|
||||||
for mi in m_ins.all():
|
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()]
|
||||||
m_ins_list.append((mi.material_in, mi.batch, mi.count_use, mi))
|
for item in m_ins:
|
||||||
if mi.count_pn_jgqbl > 0:
|
mbd_qs = MlogbDefect.objects.filter(mlogb=item)
|
||||||
raise ParseError("暂不支持加工前不良")
|
for itemx in mbd_qs:
|
||||||
m_ins_bl_list.append((mi.material_in, mi.batch, mi.count_pn_jgqbl, mi))
|
if itemx.defect:
|
||||||
|
m_ins_bl_list.append((item.material_in, item.batch, itemx.count, itemx.defect, item))
|
||||||
else:
|
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:
|
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:
|
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():
|
if not wm_qs.exists():
|
||||||
wm_qs = WMaterial.objects.filter(batch=mi_batch, material=mi_ma,
|
wm_qs = WMaterial.objects.filter(batch=mi_batch, material=mi_ma,
|
||||||
belong_dept=belong_dept, mgroup=None, state=WMaterial.WM_OK)
|
belong_dept=belong_dept, mgroup=None, state=WMaterial.WM_OK)
|
||||||
|
|
||||||
count_x = wm_qs.count()
|
count_x = wm_qs.count()
|
||||||
if count_x == 1:
|
if count_x == 1:
|
||||||
wm = wm_qs.first()
|
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:
|
for item in m_ins_bl_list:
|
||||||
material, batch, count_pn_jgqbl, mi_ = item
|
material, batch, count, defect, mi_ = item
|
||||||
if count_pn_jgqbl> 0:
|
if count> 0:
|
||||||
lookup = {'batch': batch, 'material': material, 'mgroup': mgroup, 'notok_sign': 'jgqbl', 'state': WMaterial.WM_NOTOK}
|
lookup = {'batch': batch, 'material': material, 'mgroup': mgroup, 'defect': defect, 'state': WMaterial.WM_NOTOK}
|
||||||
wm, is_create = WMaterial.objects.get_or_create(**lookup, defaults={**lookup, "belong_dept": belong_dept})
|
wm, is_create = WMaterial.objects.get_or_create(**lookup, defaults={"belong_dept": belong_dept})
|
||||||
wm.count = wm.count + count_pn_jgqbl
|
wm.count = wm.count + count
|
||||||
if is_create:
|
if is_create:
|
||||||
wm.create_by = user
|
wm.create_by = user
|
||||||
wm.batch_ofrom = mi_.batch_ofrom
|
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:
|
for item in mlogb_out_qs:
|
||||||
mbd_qs = MlogbDefect.objects.filter(mlogb=item)
|
mbd_qs = MlogbDefect.objects.filter(mlogb=item)
|
||||||
if item.qct is not None or mbd_qs.exists():
|
if item.qct is not None or mbd_qs.exists():
|
||||||
if item.material_out.tracking == Material.MA_TRACKING_SINGLE:
|
# if item.material_out.tracking == Material.MA_TRACKING_SINGLE:
|
||||||
Mlogbw.cal_count_notok(item)
|
# Mlogbw.cal_count_notok(item)
|
||||||
for itemx in MlogbDefect.objects.filter(mlogb=item):
|
for itemx in MlogbDefect.objects.filter(mlogb=item):
|
||||||
m_outs_list.append((item.material_out, item.batch, itemx.count, 0, itemx.defect, 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:
|
for item in mlogb_out_qs:
|
||||||
mbd_qs = MlogbDefect.objects.filter(mlogb=item)
|
mbd_qs = MlogbDefect.objects.filter(mlogb=item)
|
||||||
if item.qct is not None or mbd_qs.exists():
|
if item.qct is not None or mbd_qs.exists():
|
||||||
if item.material_out.tracking == Material.MA_TRACKING_SINGLE:
|
# if item.material_out.tracking == Material.MA_TRACKING_SINGLE:
|
||||||
Mlogbw.cal_count_notok(item)
|
# Mlogbw.cal_count_notok(item)
|
||||||
for itemx in MlogbDefect.objects.filter(mlogb=item):
|
for itemx in MlogbDefect.objects.filter(mlogb=item):
|
||||||
m_outs_list.append((item.material_out, item.batch, itemx.count, 0, itemx.defect, 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:
|
# if item.material_out.tracking == Material.MA_TRACKING_SINGLE:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue