feat: 针对加工前不良的处理2
This commit is contained in:
parent
330d44e2a3
commit
456f05a83e
|
|
@ -380,8 +380,7 @@ class Mlogb(BaseModel):
|
||||||
mqs = MlogbDefect.get_defect_qs_from_mlogb(self, ftype="in")
|
mqs = MlogbDefect.get_defect_qs_from_mlogb(self, ftype="in")
|
||||||
count_pn_jgqbl = mqs.aggregate(total=Sum("count"))["total"] or 0
|
count_pn_jgqbl = mqs.aggregate(total=Sum("count"))["total"] or 0
|
||||||
self.count_pn_jgqbl = count_pn_jgqbl
|
self.count_pn_jgqbl = count_pn_jgqbl
|
||||||
self.count_real = self.count_use - self.count_pn_jgqbl
|
self.save(update_fields=["count_pn_jgqbl"])
|
||||||
self.save(update_fields=["count_pn_jgqbl", "count_real"])
|
|
||||||
mlog = self.mlog
|
mlog = self.mlog
|
||||||
if mlog:
|
if mlog:
|
||||||
count_pn_jgqbl = MlogbDefect.get_defect_qs_from_mlog(mlog, ftype="in").aggregate(total=Sum("count"))["total"] or 0
|
count_pn_jgqbl = MlogbDefect.get_defect_qs_from_mlog(mlog, ftype="in").aggregate(total=Sum("count"))["total"] or 0
|
||||||
|
|
|
||||||
|
|
@ -156,18 +156,21 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
||||||
raise ParseError('不可提交未来的日志')
|
raise ParseError('不可提交未来的日志')
|
||||||
|
|
||||||
mgroup = mlog.mgroup
|
mgroup = mlog.mgroup
|
||||||
|
process = mgroup.process
|
||||||
|
into_wm_mgroup = process.into_wm_mgroup
|
||||||
|
need_store_notok = process.store_notok
|
||||||
belong_dept = mgroup.belong_dept
|
belong_dept = mgroup.belong_dept
|
||||||
material_out: Material = mlog.material_out
|
material_out: Material = mlog.material_out
|
||||||
material_in: Material = mlog.material_in
|
material_in: Material = mlog.material_in
|
||||||
supplier = mlog.supplier # 外协
|
supplier = mlog.supplier # 外协
|
||||||
is_fix = mlog.is_fix
|
is_fix = mlog.is_fix
|
||||||
m_ins_list = []
|
m_ins_list = []
|
||||||
|
m_ins_bl_list = []
|
||||||
if material_in or is_fix: # 需要进行车间库存管理
|
if material_in or is_fix: # 需要进行车间库存管理
|
||||||
m_ins_list = []
|
m_ins_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():
|
||||||
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 = [(mi.material_in, mi.batch if mi.batch else mi.batch, mi.count_use, None, mi) for mi in m_ins.all()]
|
||||||
for item in m_ins:
|
for item in m_ins:
|
||||||
mbd_qs = MlogbDefect.get_defect_qs_from_mlogb(item)
|
mbd_qs = MlogbDefect.get_defect_qs_from_mlogb(item)
|
||||||
for itemx in mbd_qs:
|
for itemx in mbd_qs:
|
||||||
|
|
@ -213,6 +216,7 @@ def mlog_submit(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 need_store_notok:
|
||||||
for item in m_ins_bl_list:
|
for item in m_ins_bl_list:
|
||||||
material, batch, count, defect, mi_ = item
|
material, batch, count, defect, mi_ = item
|
||||||
if count> 0:
|
if count> 0:
|
||||||
|
|
@ -230,9 +234,6 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
||||||
|
|
||||||
|
|
||||||
if material_out or is_fix: # 需要入车间库存
|
if material_out or is_fix: # 需要入车间库存
|
||||||
process = mgroup.process
|
|
||||||
into_wm_mgroup = process.into_wm_mgroup
|
|
||||||
need_store_notok = process.store_notok
|
|
||||||
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
|
||||||
|
|
@ -464,7 +465,7 @@ def mlog_revert(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
||||||
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():
|
for mi in m_ins.all():
|
||||||
m_ins_list.append((mi.material_in, mi.batch, mi.count_use-mi.count_pn_jgqbl, None, mi))
|
m_ins_list.append((mi.material_in, mi.batch, mi.count_use, None, mi))
|
||||||
for item in m_ins:
|
for item in m_ins:
|
||||||
mbd_qs = MlogbDefect.get_defect_qs_from_mlogb(item)
|
mbd_qs = MlogbDefect.get_defect_qs_from_mlogb(item)
|
||||||
for itemx in mbd_qs:
|
for itemx in mbd_qs:
|
||||||
|
|
@ -502,6 +503,7 @@ def mlog_revert(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
||||||
item.save()
|
item.save()
|
||||||
|
|
||||||
# 针对加工前不良的暂时额外处理
|
# 针对加工前不良的暂时额外处理
|
||||||
|
if stored_notok:
|
||||||
for item in m_ins_bl_list:
|
for item in m_ins_bl_list:
|
||||||
material, batch, count, defect, mi_ = item
|
material, batch, count, defect, mi_ = item
|
||||||
if count> 0:
|
if count> 0:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue