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 rest_framework.decorators import action
|
||||
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)
|
||||
wm_in: WMaterial = mlogbin.wm_in
|
||||
d_count_real = 0
|
||||
d_count_ok = 0
|
||||
if route:
|
||||
mlogbout, is_create = Mlogb.objects.get_or_create(**m_dict, defaults=
|
||||
{"batch_ofrom": wm_in.batch_ofrom, "material_ofrom": wm_in.material_ofrom})
|
||||
if is_create and route:
|
||||
d_count_real = 0
|
||||
d_count_ok = 0
|
||||
if route.process.mtype == Process.PRO_NORMAL:
|
||||
d_count_real = mlogbin.count_use
|
||||
d_count_ok = mlogbin.count_use
|
||||
elif route.process.mtype == Process.PRO_DIV:
|
||||
d_count_real = mlogbin.count_use*route.div_number
|
||||
d_count_ok = mlogbin.count_use*route.div_number
|
||||
xcount = mlogbin.count_use * route.div_number
|
||||
d_count_real = xcount
|
||||
d_count_ok = xcount
|
||||
elif route.process.mtype == Process.PRO_MERGE:
|
||||
d_count_real = 1
|
||||
d_count_ok = 1
|
||||
mlogbout, _ = Mlogb.objects.get_or_create(**m_dict, defaults=
|
||||
{"batch_ofrom": wm_in.batch_ofrom, "material_ofrom": wm_in.material_ofrom,
|
||||
"count_real": d_count_real, "count_ok": d_count_ok})
|
||||
xcount = math.ceil( mlogbin.count_use / route.div_number)
|
||||
d_count_real = xcount
|
||||
d_count_ok = xcount
|
||||
mlogbout.count_real = d_count_real
|
||||
mlogbout.count_ok = d_count_ok
|
||||
mlogbout.save()
|
||||
mlogbin.mlogb_to = mlogbout
|
||||
mlogbin.save()
|
||||
if material_in.tracking == Material.MA_TRACKING_SINGLE:
|
||||
|
|
Loading…
Reference in New Issue