feat: 次批触发输出产生
This commit is contained in:
parent
10d4a64c3a
commit
94a218c09a
|
@ -686,6 +686,7 @@ class MlogbInViewSet(CreateModelMixin, UpdateModelMixin, DestroyModelMixin, Cust
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def p_create_after(cls, mlogbin:Mlogb):
|
def p_create_after(cls, mlogbin:Mlogb):
|
||||||
|
mlogbin_parent:Mlogb = mlogbin.parent
|
||||||
mlog:Mlog = mlogbin.mlog
|
mlog:Mlog = mlogbin.mlog
|
||||||
mgroup:Mgroup = mlog.mgroup
|
mgroup:Mgroup = mlog.mgroup
|
||||||
route:Route = mlogbin.route
|
route:Route = mlogbin.route
|
||||||
|
@ -703,6 +704,10 @@ class MlogbInViewSet(CreateModelMixin, UpdateModelMixin, DestroyModelMixin, Cust
|
||||||
raise ParseError('产物不可为空')
|
raise ParseError('产物不可为空')
|
||||||
# 如果是主要输入物料且是主批次,才需生成输出
|
# 如果是主要输入物料且是主批次,才需生成输出
|
||||||
if is_fix is False and route and route.material_in != material_in or mlogbin.parent is not None:
|
if is_fix is False and route and route.material_in != material_in or mlogbin.parent is not None:
|
||||||
|
# 如果次批且是结合工序,需要触发产生输出
|
||||||
|
if mtype and mtype == Process.PRO_DIV:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
wm_in: WMaterial = mlogbin.wm_in
|
wm_in: WMaterial = mlogbin.wm_in
|
||||||
|
@ -790,6 +795,18 @@ class MlogbInViewSet(CreateModelMixin, UpdateModelMixin, DestroyModelMixin, Cust
|
||||||
mlogbout.save(update_fields=["count_json_from"])
|
mlogbout.save(update_fields=["count_json_from"])
|
||||||
elif mtype == Process.PRO_MERGE: # 支持批到批,批到个
|
elif mtype == Process.PRO_MERGE: # 支持批到批,批到个
|
||||||
div_number = route.div_number
|
div_number = route.div_number
|
||||||
|
if mlogbin_parent is not None:
|
||||||
|
# 说明是次批
|
||||||
|
if mlogbin.material_in == mlogbin_parent.material_in:
|
||||||
|
# 如果主次物料一致,则进行处理
|
||||||
|
count_use_sum = Mlogb.objects.filter(Q(id=mlogbin_parent.id)|Q(parent=mlogbin_parent), material_in=mlogbin.material_in).aggregate(Sum('count_use'))['count_use__sum'] or 0
|
||||||
|
count_pn_jgqbl_sum = Mlogb.objects.filter(Q(id=mlogbin_parent.id)|Q(parent=mlogbin_parent), material_in=mlogbin.material_in).aggregate(Sum('count_pn_jgqbl'))['count_pn_jgqbl__sum'] or 0
|
||||||
|
xcount = math.floor( (count_use_sum-count_pn_jgqbl_sum) / div_number)
|
||||||
|
else:
|
||||||
|
raise ParseError("暂不支持主次物料不一致")
|
||||||
|
# 使用主批作为后续引用
|
||||||
|
mlogbin = mlogbin_parent
|
||||||
|
else:
|
||||||
xcount = math.floor( (mlogbin.count_use-mlogbin.count_pn_jgqbl) / div_number)
|
xcount = math.floor( (mlogbin.count_use-mlogbin.count_pn_jgqbl) / div_number)
|
||||||
d_count_real = xcount
|
d_count_real = xcount
|
||||||
d_count_ok = xcount
|
d_count_ok = xcount
|
||||||
|
|
Loading…
Reference in New Issue