fix: 个到个的拆分bug5
This commit is contained in:
parent
6fa9c9182b
commit
c8cde0a436
|
|
@ -33,7 +33,7 @@ from apps.wpmw.models import Wpr
|
||||||
from apps.qm.models import Qct, Ftest, TestItem
|
from apps.qm.models import Qct, Ftest, TestItem
|
||||||
from apps.enm.models import EnStat
|
from apps.enm.models import EnStat
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from apps.utils.tools import convert_ordereddict
|
from apps.utils.tools import convert_ordereddict, update_dict
|
||||||
from django.db.models import Count
|
from django.db.models import Count
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -574,6 +574,8 @@ class MlogbInViewSet(CreateModelMixin, UpdateModelMixin, DestroyModelMixin, Cust
|
||||||
"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,
|
||||||
|
"qct": qct
|
||||||
}
|
}
|
||||||
if mtype == Process.PRO_DIV and material_in.tracking == Material.MA_TRACKING_SINGLE:
|
if mtype == Process.PRO_DIV and material_in.tracking == Material.MA_TRACKING_SINGLE:
|
||||||
pass
|
pass
|
||||||
|
|
@ -583,11 +585,8 @@ class MlogbInViewSet(CreateModelMixin, UpdateModelMixin, DestroyModelMixin, Cust
|
||||||
if mtype == Process.PRO_NORMAL: # 正常 支持批到批, 个到个
|
if mtype == Process.PRO_NORMAL: # 正常 支持批到批, 个到个
|
||||||
d_count_real = mlogbin.count_use
|
d_count_real = mlogbin.count_use
|
||||||
d_count_ok = mlogbin.count_use
|
d_count_ok = mlogbin.count_use
|
||||||
mlogbout, _ = Mlogb.objects.get_or_create(**m_dict, defaults=
|
mlogbout, _ = Mlogb.objects.get_or_create(mlogb_from=mlogbin, defaults=
|
||||||
{"batch_ofrom": wm_in.batch_ofrom, "material_ofrom": wm_in.material_ofrom, "count_real": d_count_real, "count_ok": d_count_ok,
|
update_dict(m_dict, {"count_real": d_count_real, "count_ok": d_count_ok}))
|
||||||
"qct": qct, "mlogb_from": mlogbin})
|
|
||||||
if mlogbout.mlogb_from != mlogbin:
|
|
||||||
raise ParseError("生成产出出错1")
|
|
||||||
if material_in.tracking == Material.MA_TRACKING_SINGLE and material_out.tracking == Material.MA_TRACKING_SINGLE:
|
if material_in.tracking == Material.MA_TRACKING_SINGLE and material_out.tracking == Material.MA_TRACKING_SINGLE:
|
||||||
for mlogbwin in Mlogbw.objects.filter(mlogb=mlogbin).order_by("number"):
|
for mlogbwin in Mlogbw.objects.filter(mlogb=mlogbin).order_by("number"):
|
||||||
Mlogbw.objects.get_or_create(wpr=wpr, mlogb=mlogbout, defaults={"number": wpr.number, "mlogbw_from": mlogbwin})
|
Mlogbw.objects.get_or_create(wpr=wpr, mlogb=mlogbout, defaults={"number": wpr.number, "mlogbw_from": mlogbwin})
|
||||||
|
|
@ -596,52 +595,30 @@ class MlogbInViewSet(CreateModelMixin, UpdateModelMixin, DestroyModelMixin, Cust
|
||||||
if material_in.tracking == Material.MA_TRACKING_SINGLE and material_out.tracking == Material.MA_TRACKING_BATCH:
|
if material_in.tracking == Material.MA_TRACKING_SINGLE and material_out.tracking == Material.MA_TRACKING_BATCH:
|
||||||
for mlogbwin in Mlogbw.objects.filter(mlogb=mlogbin).order_by("number"):
|
for mlogbwin in Mlogbw.objects.filter(mlogb=mlogbin).order_by("number"):
|
||||||
m_dict["batch"] = mlogbwin.number
|
m_dict["batch"] = mlogbwin.number
|
||||||
mlogbout, _ = Mlogb.objects.get_or_create(**m_dict, defaults=
|
Mlogb.objects.get_or_create(mlogbw_from=mlogbwin, defaults=update_dict(m_dict, {"count_real": div_number, "count_ok": div_number}))
|
||||||
{"batch_ofrom": wm_in.batch_ofrom, "material_ofrom": wm_in.material_ofrom,
|
|
||||||
"count_real": div_number, "count_ok": div_number, "qct": qct, "mlogbw_from": mlogbwin})
|
|
||||||
if mlogbout.mlogbw_from != mlogbwin:
|
|
||||||
raise ParseError("生成产出出错2")
|
|
||||||
elif material_in.tracking == Material.MA_TRACKING_SINGLE and material_out.tracking == Material.MA_TRACKING_SINGLE:
|
elif material_in.tracking == Material.MA_TRACKING_SINGLE and material_out.tracking == Material.MA_TRACKING_SINGLE:
|
||||||
|
mlogbout, _ = Mlogb.objects.get_or_create(mlogb_from=mlogbin, defaults=update_dict(m_dict, {"count_real": d_count_real*div_number, "count_ok": d_count_ok*div_number}))
|
||||||
for mlogbwin in Mlogbw.objects.filter(mlogb=mlogbin).order_by("number"):
|
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, "mlogbw_from": mlogbwin})
|
|
||||||
if mlogbout.mlogbw_from != mlogbwin:
|
|
||||||
raise ParseError("生成产出出错2-2")
|
|
||||||
wpr_ = mlogbwin.wpr
|
wpr_ = mlogbwin.wpr
|
||||||
for i in range(div_number):
|
for i in range(div_number):
|
||||||
Mlogbw.objects.get_or_create(mlogb=mlogbout, number=f'{wpr_.number}-{i+1}', defaults={"mlogbw_from": mlogbwin})
|
Mlogbw.objects.get_or_create(mlogb=mlogbout, number=f'{wpr_.number}-{i+1}', defaults={"mlogbw_from": mlogbwin})
|
||||||
elif material_in.tracking == Material.MA_TRACKING_BATCH and material_out.tracking == Material.MA_TRACKING_BATCH:
|
elif material_in.tracking == Material.MA_TRACKING_BATCH and material_out.tracking == Material.MA_TRACKING_BATCH:
|
||||||
d_count_real = mlogbin.count_use * div_number
|
d_count_real = mlogbin.count_use * div_number
|
||||||
d_count_ok = d_count_real
|
d_count_ok = d_count_real
|
||||||
mlogbout, _ = Mlogb.objects.get_or_create(**m_dict, defaults=
|
Mlogb.objects.get_or_create(mlogb_from=mlogbin, defaults=update_dict(m_dict,{"count_real": d_count_real, "count_ok": d_count_ok}))
|
||||||
{"batch_ofrom": wm_in.batch_ofrom, "material_ofrom": wm_in.material_ofrom,
|
|
||||||
"count_real": d_count_real, "count_ok": d_count_ok, "qct": qct, "mlogb_from": mlogbin})
|
|
||||||
if mlogbout.mlogb_from != mlogbin:
|
|
||||||
raise ParseError("生成产出出错2-2")
|
|
||||||
elif mtype == Process.PRO_MERGE: # 支持批到批
|
elif mtype == Process.PRO_MERGE: # 支持批到批
|
||||||
xcount = math.floor( mlogbin.count_use / route.div_number)
|
xcount = math.floor( mlogbin.count_use / route.div_number)
|
||||||
d_count_real = xcount
|
d_count_real = xcount
|
||||||
d_count_ok = xcount
|
d_count_ok = xcount
|
||||||
mlogbout, _ = Mlogb.objects.get_or_create(**m_dict, defaults=
|
Mlogb.objects.get_or_create(mlogb_from=mlogbin, defaults=update_dict(m_dict, {"count_real": d_count_real, "count_ok": d_count_ok}))
|
||||||
{"batch_ofrom": wm_in.batch_ofrom, "material_ofrom": wm_in.material_ofrom,
|
|
||||||
"count_real": d_count_real, "count_ok": d_count_ok, "qct": qct, "mlogb_from": mlogbin})
|
|
||||||
if mlogbout.mlogb_from != mlogbin:
|
|
||||||
raise ParseError("生成产出出错3")
|
|
||||||
elif is_fix:# 支持批到批,个到个
|
elif is_fix:# 支持批到批,个到个
|
||||||
d_count_real = mlogbin.count_use
|
d_count_real = mlogbin.count_use
|
||||||
d_count_ok = mlogbin.count_use
|
d_count_ok = mlogbin.count_use
|
||||||
mlogbout, _ = Mlogb.objects.get_or_create(**m_dict, defaults=
|
Mlogb.objects.get_or_create(mlogb_from=mlogbin, defaults=update_dict(m_dict,{"count_real": d_count_real, "count_ok": d_count_ok}))
|
||||||
{"batch_ofrom": wm_in.batch_ofrom, "material_ofrom": wm_in.material_ofrom,
|
|
||||||
"count_real": d_count_real, "count_ok": d_count_ok, "qct": qct, "mlogb_from": mlogbin})
|
|
||||||
if mlogbout.mlogb_from != mlogbin:
|
|
||||||
raise ParseError("生成产出出错4")
|
|
||||||
if material_in.tracking == Material.MA_TRACKING_SINGLE and material_out.tracking == Material.MA_TRACKING_SINGLE:
|
if material_in.tracking == Material.MA_TRACKING_SINGLE and material_out.tracking == Material.MA_TRACKING_SINGLE:
|
||||||
for mlogbwin in Mlogbw.objects.filter(mlogb=mlogbin).order_by("number"):
|
for mlogbwin in Mlogbw.objects.filter(mlogb=mlogbin).order_by("number"):
|
||||||
bw, _ = Mlogbw.objects.get_or_create(wpr=wpr, mlogb=mlogbout, defaults={"number": wpr.number, "mlogbw_from": mlogbwin})
|
wpr = mlogbwin.wpr
|
||||||
if bw.mlogbw_from != mlogbwin:
|
Mlogbw.objects.get_or_create(wpr=wpr, mlogb=mlogbout, defaults={"number": wpr.number, "mlogbw_from": mlogbwin})
|
||||||
raise ParseError("生成产出出错5")
|
|
||||||
else:
|
else:
|
||||||
raise ParseError("不支持生成产出物料!")
|
raise ParseError("不支持生成产出物料!")
|
||||||
|
|
||||||
|
|
@ -735,9 +712,7 @@ class MlogbwViewSet(CustomModelViewSet):
|
||||||
elif mlogb_qs.exists() and material_out.tracking == Material.MA_TRACKING_SINGLE:
|
elif mlogb_qs.exists() and material_out.tracking == Material.MA_TRACKING_SINGLE:
|
||||||
for mlogb in mlogb_qs:
|
for mlogb in mlogb_qs:
|
||||||
if route.process.mtype == Process.PRO_NORMAL:
|
if route.process.mtype == Process.PRO_NORMAL:
|
||||||
bw, _ = Mlogbw.objects.get_or_create(mlogb=mlogb, wpr=ins.wpr, defaults={"number": ins.number, "mlogbw_from": ins})
|
Mlogbw.objects.get_or_create(mlogb=mlogb, wpr=ins.wpr, defaults={"number": ins.number, "mlogbw_from": ins})
|
||||||
if bw.mlogbw_from != ins:
|
|
||||||
raise ParseError("生成产出出错7")
|
|
||||||
elif route.process.mtype == Process.PRO_DIV:
|
elif route.process.mtype == Process.PRO_DIV:
|
||||||
for i in range(route.div_number):
|
for i in range(route.div_number):
|
||||||
Mlogbw.objects.get_or_create(mlogb=mlogb, number=f'{ins.number}-{i+1}', defaults={"mlogbw_from": ins})
|
Mlogbw.objects.get_or_create(mlogb=mlogb, number=f'{ins.number}-{i+1}', defaults={"mlogbw_from": ins})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue