feat: 修改mlog_submit和mlog_revert以支持日志多个工艺步骤
This commit is contained in:
parent
1d840e7c9d
commit
4b2bcc6d29
|
@ -190,7 +190,7 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
||||||
exclude_batchst_ids.append(target.id)
|
exclude_batchst_ids.append(target.id)
|
||||||
BatchLog.g_create(source=source, target=target, mlog=mlog)
|
BatchLog.g_create(source=source, target=target, mlog=mlog)
|
||||||
|
|
||||||
if material_in or is_fix: # 需要进行车间库存管理
|
# 消耗物料处理
|
||||||
m_ins_list = []
|
m_ins_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():
|
||||||
|
@ -205,6 +205,8 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
||||||
m_ins_list = [(material_in, mlog.batch, mlog.count_use, None, 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, defect, mlog_or_b = mi
|
mi_ma, mi_batch, mi_count, defect, mlog_or_b = mi
|
||||||
|
if mi_ma is None:
|
||||||
|
continue
|
||||||
if mi_count <= 0:
|
if mi_count <= 0:
|
||||||
raise ParseError('存在非正数!')
|
raise ParseError('存在非正数!')
|
||||||
# 需要判断领用数是否合理
|
# 需要判断领用数是否合理
|
||||||
|
@ -261,7 +263,6 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
||||||
raise ParseError("加工前不良的物料暂不支持单件追踪")
|
raise ParseError("加工前不良的物料暂不支持单件追踪")
|
||||||
|
|
||||||
|
|
||||||
if material_out or is_fix: # 需要入车间库存
|
|
||||||
mlogb_out_qs = Mlogb.objects.filter(mlog=mlog, material_out__isnull=False)
|
mlogb_out_qs = Mlogb.objects.filter(mlog=mlog, material_out__isnull=False)
|
||||||
stored_notok = need_store_notok
|
stored_notok = need_store_notok
|
||||||
stored_mgroup = need_store_notok
|
stored_mgroup = need_store_notok
|
||||||
|
@ -304,6 +305,8 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
||||||
# 一次填写的暂时不处理不合格品
|
# 一次填写的暂时不处理不合格品
|
||||||
for mo in m_outs_list:
|
for mo in m_outs_list:
|
||||||
mo_ma, mo_batch, mo_count, mo_count_eweight, notok_sign_or_defect, mlog_or_b = mo
|
mo_ma, mo_batch, mo_count, mo_count_eweight, notok_sign_or_defect, mlog_or_b = mo
|
||||||
|
if mo_ma is None:
|
||||||
|
continue
|
||||||
if mo_count < 0:
|
if mo_count < 0:
|
||||||
raise ParseError('存在负数!')
|
raise ParseError('存在负数!')
|
||||||
elif mo_count == 0:
|
elif mo_count == 0:
|
||||||
|
@ -411,7 +414,6 @@ def mlog_revert(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
||||||
if is_fix:
|
if is_fix:
|
||||||
can_matoutIds = process.get_canout_mat_ids()
|
can_matoutIds = process.get_canout_mat_ids()
|
||||||
# 先回退产物
|
# 先回退产物
|
||||||
if material_out or is_fix: # 产物退回
|
|
||||||
# 有多个产物的情况
|
# 有多个产物的情况
|
||||||
# 需要考虑不合格品退回的情况
|
# 需要考虑不合格品退回的情况
|
||||||
mlogb_out_qs = Mlogb.objects.filter(mlog=mlog, material_out__isnull=False)
|
mlogb_out_qs = Mlogb.objects.filter(mlog=mlog, material_out__isnull=False)
|
||||||
|
@ -456,6 +458,8 @@ def mlog_revert(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
||||||
|
|
||||||
for mo in m_outs_list:
|
for mo in m_outs_list:
|
||||||
mo_ma, mo_batch, mo_count, _, notok_sign_or_defect, mlog_or_b = mo
|
mo_ma, mo_batch, mo_count, _, notok_sign_or_defect, mlog_or_b = mo
|
||||||
|
if mo_ma is None:
|
||||||
|
continue
|
||||||
if mo_count < 0:
|
if mo_count < 0:
|
||||||
raise ParseError('存在负数!')
|
raise ParseError('存在负数!')
|
||||||
elif mo_count == 0:
|
elif mo_count == 0:
|
||||||
|
@ -509,7 +513,6 @@ def mlog_revert(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
||||||
Wpr.change_or_new(wpr=item.wpr, old_wm=wm)
|
Wpr.change_or_new(wpr=item.wpr, old_wm=wm)
|
||||||
|
|
||||||
# 再生成消耗
|
# 再生成消耗
|
||||||
if material_in or is_fix: # 领用数退回
|
|
||||||
m_ins_list = []
|
m_ins_list = []
|
||||||
m_ins_bl_list = []
|
m_ins_bl_list = []
|
||||||
into_wm_mgroup = process.into_wm_mgroup
|
into_wm_mgroup = process.into_wm_mgroup
|
||||||
|
@ -527,6 +530,8 @@ def mlog_revert(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
||||||
m_ins_list = [(material_in, mlog.batch, mlog.count_use, mlog.wm_in, mlog)]
|
m_ins_list = [(material_in, mlog.batch, mlog.count_use, mlog.wm_in, mlog)]
|
||||||
for mi in m_ins_list:
|
for mi in m_ins_list:
|
||||||
mi_ma, mi_batch, mi_count, defect_or, mlog_or_b = mi
|
mi_ma, mi_batch, mi_count, defect_or, mlog_or_b = mi
|
||||||
|
if mi_ma is None:
|
||||||
|
continue
|
||||||
if mi_count <= 0:
|
if mi_count <= 0:
|
||||||
raise ParseError('存在非正数!')
|
raise ParseError('存在非正数!')
|
||||||
if isinstance(mlog_or_b, Mlogb) and mlog_or_b.wm_in:
|
if isinstance(mlog_or_b, Mlogb) and mlog_or_b.wm_in:
|
||||||
|
|
Loading…
Reference in New Issue