feat: 个拆批2

This commit is contained in:
caoqianming 2025-03-10 17:58:09 +08:00
parent 75ec24702c
commit f59cb2cbc2
1 changed files with 12 additions and 4 deletions

View File

@ -712,18 +712,26 @@ class MlogbwViewSet(CustomModelViewSet):
mlogbin = ins.mlogb mlogbin = ins.mlogb
wm_in = mlogbin.wm_in wm_in = mlogbin.wm_in
mlog = mlogbin.mlog mlog = mlogbin.mlog
div_number = route.div_number
m_dict = { m_dict = {
"mtask": mlogbin.mtask, "mtask": mlogbin.mtask,
"mlog": mlog, "mlog": mlog,
"material_out": material_out, "material_out": material_out,
"batch_ofrom": wm_in.batch_ofrom,
"material_ofrom": wm_in.material_ofrom,
"count_real": div_number,
"count_ok": div_number, "qct": mlog.qct
} }
div_number = route.div_number if ins.mlogb_to:
mlogbout, _ = Mlogb.objects.get_or_create(**m_dict, defaults= mlogbout = ins.mlogb_to
{"batch_ofrom": wm_in.batch_ofrom, "material_ofrom": wm_in.material_ofrom, "count_real": div_number, "count_ok": div_number, "qct": mlog.qct}) else:
mlogbout = Mlogb.objects.create(**m_dict)
ins.mlogb_to = mlogbout
ins.save(update_fields=["mlogb_to"])
if material_out.tracking == Material.MA_TRACKING_SINGLE: if material_out.tracking == Material.MA_TRACKING_SINGLE:
for i in range(div_number): for i in range(div_number):
Mlogbw.objects.get_or_create(mlogb=mlogbout, defaults=f'{ins.number}-{i+1}') Mlogbw.objects.get_or_create(mlogb=mlogbout, defaults=f'{ins.number}-{i+1}')
Mlogbw.cal_count_notok(mlogb_to) Mlogbw.cal_count_notok(mlogbout)
elif mlogb_to and material_out.tracking == Material.MA_TRACKING_SINGLE: elif mlogb_to and material_out.tracking == Material.MA_TRACKING_SINGLE:
if route.process.mtype == Process.PRO_NORMAL: if route.process.mtype == Process.PRO_NORMAL:
Mlogbw.objects.get_or_create(mlogb=mlogb_to, wpr=ins.wpr, defaults={"number": ins.number}) Mlogbw.objects.get_or_create(mlogb=mlogb_to, wpr=ins.wpr, defaults={"number": ins.number})