feat: mlogbin自动创建mlogbout数量2
This commit is contained in:
parent
b454972943
commit
afb3b23486
|
|
@ -1,3 +1,5 @@
|
||||||
|
import math
|
||||||
|
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from rest_framework.decorators import action
|
from rest_framework.decorators import action
|
||||||
from rest_framework.exceptions import ParseError
|
from rest_framework.exceptions import ParseError
|
||||||
|
|
@ -496,21 +498,25 @@ class MlogbInViewSet(CreateModelMixin, UpdateModelMixin, DestroyModelMixin, Cust
|
||||||
}
|
}
|
||||||
m_dict['batch'] = generate_new_batch(mlogbin.batch, mlog)
|
m_dict['batch'] = generate_new_batch(mlogbin.batch, mlog)
|
||||||
wm_in: WMaterial = mlogbin.wm_in
|
wm_in: WMaterial = mlogbin.wm_in
|
||||||
d_count_real = 0
|
mlogbout, is_create = Mlogb.objects.get_or_create(**m_dict, defaults=
|
||||||
d_count_ok = 0
|
{"batch_ofrom": wm_in.batch_ofrom, "material_ofrom": wm_in.material_ofrom})
|
||||||
if route:
|
if is_create and route:
|
||||||
|
d_count_real = 0
|
||||||
|
d_count_ok = 0
|
||||||
if route.process.mtype == Process.PRO_NORMAL:
|
if route.process.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
|
||||||
elif route.process.mtype == Process.PRO_DIV:
|
elif route.process.mtype == Process.PRO_DIV:
|
||||||
d_count_real = mlogbin.count_use*route.div_number
|
xcount = mlogbin.count_use * route.div_number
|
||||||
d_count_ok = mlogbin.count_use*route.div_number
|
d_count_real = xcount
|
||||||
|
d_count_ok = xcount
|
||||||
elif route.process.mtype == Process.PRO_MERGE:
|
elif route.process.mtype == Process.PRO_MERGE:
|
||||||
d_count_real = 1
|
xcount = math.ceil( mlogbin.count_use / route.div_number)
|
||||||
d_count_ok = 1
|
d_count_real = xcount
|
||||||
mlogbout, _ = Mlogb.objects.get_or_create(**m_dict, defaults=
|
d_count_ok = xcount
|
||||||
{"batch_ofrom": wm_in.batch_ofrom, "material_ofrom": wm_in.material_ofrom,
|
mlogbout.count_real = d_count_real
|
||||||
"count_real": d_count_real, "count_ok": d_count_ok})
|
mlogbout.count_ok = d_count_ok
|
||||||
|
mlogbout.save()
|
||||||
mlogbin.mlogb_to = mlogbout
|
mlogbin.mlogb_to = mlogbout
|
||||||
mlogbin.save()
|
mlogbin.save()
|
||||||
if material_in.tracking == Material.MA_TRACKING_SINGLE:
|
if material_in.tracking == Material.MA_TRACKING_SINGLE:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue