feat: 生成产出出错2的bug
This commit is contained in:
parent
378648436f
commit
8d67c06e63
|
@ -561,6 +561,7 @@ class MlogbInViewSet(CreateModelMixin, UpdateModelMixin, DestroyModelMixin, Cust
|
|||
qs.delete()
|
||||
if ftestIds:
|
||||
Ftest.objects.filter(id__in=ftestIds).delete()
|
||||
Mlogb.objects.filter(id__in=Mlogbw.objects.filter(mlogb=ins).values_list("mlogb_to__id", flat=True)).delete()
|
||||
ins.delete()
|
||||
|
||||
@transaction.atomic
|
||||
|
@ -580,12 +581,6 @@ class MlogbInViewSet(CreateModelMixin, UpdateModelMixin, DestroyModelMixin, Cust
|
|||
# 如果是主要输入物料且是主批次,才需生成输出
|
||||
if route and route.material_in != material_in or mlogbin.parent is not None:
|
||||
return
|
||||
m_dict = {
|
||||
"mtask": mlogbin.mtask,
|
||||
"mlog": mlog,
|
||||
"material_out": material_out,
|
||||
}
|
||||
m_dict['batch'] = generate_new_batch(mlogbin.batch, mlog)
|
||||
|
||||
wm_in: WMaterial = mlogbin.wm_in
|
||||
|
||||
|
@ -598,6 +593,16 @@ class MlogbInViewSet(CreateModelMixin, UpdateModelMixin, DestroyModelMixin, Cust
|
|||
mlog.qct = Qct.get(material_out, "process")
|
||||
mlog.save(update_fields = ["qct"])
|
||||
|
||||
m_dict = {
|
||||
"mtask": mlogbin.mtask,
|
||||
"mlog": mlog,
|
||||
"material_out": material_out,
|
||||
}
|
||||
if mtype == Process.PRO_DIV and material_in.tracking == Material.MA_TRACKING_SINGLE:
|
||||
pass
|
||||
else:
|
||||
m_dict['batch'] = generate_new_batch(mlogbin.batch, mlog)
|
||||
|
||||
if mtype == Process.PRO_NORMAL:
|
||||
d_count_real = mlogbin.count_use
|
||||
d_count_ok = mlogbin.count_use
|
||||
|
@ -610,14 +615,26 @@ class MlogbInViewSet(CreateModelMixin, UpdateModelMixin, DestroyModelMixin, Cust
|
|||
raise ParseError("生成产出出错1")
|
||||
elif mtype == Process.PRO_DIV:
|
||||
div_number = route.div_number
|
||||
for mlogbwin in Mlogbw.objects.filter(mlogb=mlogbin).order_by("number"):
|
||||
if material_in.tracking == Material.MA_TRACKING_SINGLE:
|
||||
for mlogbwin in Mlogbw.objects.filter(mlogb=mlogbin).order_by("number"):
|
||||
m_dict["batch"] = mlogbwin.number
|
||||
mlogbout, _ = Mlogb.objects.get_or_create(**m_dict, defaults=
|
||||
{"batch_ofrom": wm_in.batch_ofrom, "material_ofrom": wm_in.material_ofrom, "count_real": div_number, "count_ok": div_number, "qct": qct})
|
||||
if mlogbwin.mlogb_to is None:
|
||||
mlogbwin.mlogb_to = mlogbout
|
||||
mlogbwin.save(update_fields = ["mlogb_to"])
|
||||
elif mlogbwin.mlogb_to != mlogbout:
|
||||
raise ParseError("生成产出出错2")
|
||||
elif material_out.tracking == Material.MA_TRACKING_BATCH:
|
||||
d_count_real = mlogbin.count_use * div_number
|
||||
d_count_ok = d_count_real
|
||||
mlogbout, _ = Mlogb.objects.get_or_create(**m_dict, defaults=
|
||||
{"batch_ofrom": wm_in.batch_ofrom, "material_ofrom": wm_in.material_ofrom, "count_real": div_number, "count_ok": div_number, "qct": qct})
|
||||
if mlogbwin.mlogb_to is None:
|
||||
mlogbwin.mlogb_to = mlogbout
|
||||
mlogbwin.save(update_fields = ["mlogb_to"])
|
||||
elif mlogbwin.mlogb_to != mlogbout:
|
||||
raise ParseError("生成产出出错2")
|
||||
{"batch_ofrom": wm_in.batch_ofrom, "material_ofrom": wm_in.material_ofrom, "count_real": d_count_real, "count_ok": d_count_ok, "qct": qct})
|
||||
if mlogbin.mlogb_to is None:
|
||||
mlogbin.mlogb_to = mlogbout
|
||||
mlogbin.save(update_fields = ["mlogb_to"])
|
||||
elif mlogbin.mlogb_to != mlogbout:
|
||||
raise ParseError("生成产出出错2-2")
|
||||
elif mtype == Process.PRO_MERGE:
|
||||
xcount = math.floor( mlogbin.count_use / route.div_number)
|
||||
d_count_real = xcount
|
||||
|
|
Loading…
Reference in New Issue