feat: 加工前不良的日志提交和撤回
This commit is contained in:
parent
91add9ec1d
commit
40b012b962
|
@ -208,7 +208,12 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
||||||
if material_in: # 需要进行车间库存管理
|
if material_in: # 需要进行车间库存管理
|
||||||
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():
|
||||||
m_ins_list = [(mi.material_in, mi.batch, mi.count_use, mi.wm_in) for mi in m_ins.all()]
|
m_ins_list = []
|
||||||
|
m_ins_bl_list = []
|
||||||
|
for mi in m_ins.all():
|
||||||
|
m_ins_list.append((mi.material_in, mi.batch, mi.count_use, mi.wm_in))
|
||||||
|
if mi.count_n_jgqbl > 0:
|
||||||
|
m_ins_bl_list.append((mi.material_in, mi.batch, mi.count_n_jgqbl))
|
||||||
else:
|
else:
|
||||||
m_ins_list = [(material_in, mlog.batch, mlog.count_use, mlog.wm_in)]
|
m_ins_list = [(material_in, mlog.batch, mlog.count_use, mlog.wm_in)]
|
||||||
for mi in m_ins_list:
|
for mi in m_ins_list:
|
||||||
|
@ -239,6 +244,20 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
||||||
wm.count = wm.count - mi_count
|
wm.count = wm.count - mi_count
|
||||||
wm.update_by = user
|
wm.update_by = user
|
||||||
wm.save()
|
wm.save()
|
||||||
|
# 针对加工前不良的暂时额外处理
|
||||||
|
for item in m_ins_bl_list:
|
||||||
|
material, batch, count_n_jgqbl = item
|
||||||
|
if count_n_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 + item.count_n_jgqbl
|
||||||
|
if is_create:
|
||||||
|
wm.create_by = user
|
||||||
|
else:
|
||||||
|
wm.update_by = user
|
||||||
|
wm.save()
|
||||||
|
|
||||||
|
|
||||||
if material_out: # 需要入车间库存
|
if material_out: # 需要入车间库存
|
||||||
into_wm_mgroup = material_out.process.into_wm_mgroup if material_out.process else False
|
into_wm_mgroup = material_out.process.into_wm_mgroup if material_out.process else False
|
||||||
need_store_notok = material_out.process.store_notok if material_out.process else False
|
need_store_notok = material_out.process.store_notok if material_out.process else False
|
||||||
|
@ -302,7 +321,12 @@ def mlog_revert(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
||||||
into_wm_mgroup = material_in.process.into_wm_mgroup if material_in.process else False
|
into_wm_mgroup = material_in.process.into_wm_mgroup if material_in.process else False
|
||||||
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():
|
||||||
m_ins_list = [(mi.material_in, mi.batch, mi.count_use, mi.wm_in) for mi in m_ins.all()]
|
m_ins_list = []
|
||||||
|
m_ins_bl_list = []
|
||||||
|
for mi in m_ins.all():
|
||||||
|
m_ins_list.append((mi.material_in, mi.batch, mi.count_use, mi.wm_in))
|
||||||
|
if mi.count_n_jgqbl > 0:
|
||||||
|
m_ins_bl_list.append((mi.material_in, mi.batch, mi.count_n_jgqbl))
|
||||||
else:
|
else:
|
||||||
m_ins_list = [(material_in, mlog.batch, mlog.count_use, mlog.wm_in)]
|
m_ins_list = [(material_in, mlog.batch, mlog.count_use, mlog.wm_in)]
|
||||||
for mi in m_ins_list:
|
for mi in m_ins_list:
|
||||||
|
@ -324,6 +348,21 @@ def mlog_revert(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
||||||
wm.count = wm.count + mi_count
|
wm.count = wm.count + mi_count
|
||||||
wm.update_by = user
|
wm.update_by = user
|
||||||
wm.save()
|
wm.save()
|
||||||
|
# 针对加工前不良的暂时额外处理
|
||||||
|
for item in m_ins_bl_list:
|
||||||
|
material, batch, count_n_jgqbl = item
|
||||||
|
if count_n_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 - item.count_n_jgqbl
|
||||||
|
if wm.count < 0:
|
||||||
|
raise ParseError('加工前不良数量大于库存量')
|
||||||
|
if is_create:
|
||||||
|
wm.create_by = user
|
||||||
|
else:
|
||||||
|
wm.update_by = user
|
||||||
|
wm.save()
|
||||||
|
|
||||||
if material_out: # 产物退回
|
if material_out: # 产物退回
|
||||||
# 有多个产物的情况
|
# 有多个产物的情况
|
||||||
# 需要考虑不合格品退回的情况
|
# 需要考虑不合格品退回的情况
|
||||||
|
|
Loading…
Reference in New Issue