feat: 次批触发输出产生

This commit is contained in:
caoqianming 2025-09-08 11:18:09 +08:00
parent 10d4a64c3a
commit 94a218c09a
1 changed files with 19 additions and 2 deletions

View File

@ -686,6 +686,7 @@ class MlogbInViewSet(CreateModelMixin, UpdateModelMixin, DestroyModelMixin, Cust
@classmethod
def p_create_after(cls, mlogbin:Mlogb):
mlogbin_parent:Mlogb = mlogbin.parent
mlog:Mlog = mlogbin.mlog
mgroup:Mgroup = mlog.mgroup
route:Route = mlogbin.route
@ -703,7 +704,11 @@ class MlogbInViewSet(CreateModelMixin, UpdateModelMixin, DestroyModelMixin, Cust
raise ParseError('产物不可为空')
# 如果是主要输入物料且是主批次,才需生成输出
if is_fix is False and route and route.material_in != material_in or mlogbin.parent is not None:
return
# 如果次批且是结合工序,需要触发产生输出
if mtype and mtype == Process.PRO_DIV:
pass
else:
return
wm_in: WMaterial = mlogbin.wm_in
@ -790,7 +795,19 @@ class MlogbInViewSet(CreateModelMixin, UpdateModelMixin, DestroyModelMixin, Cust
mlogbout.save(update_fields=["count_json_from"])
elif mtype == Process.PRO_MERGE: # 支持批到批,批到个
div_number = route.div_number
xcount = math.floor( (mlogbin.count_use-mlogbin.count_pn_jgqbl) / 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)
d_count_real = xcount
d_count_ok = xcount
number_to_batch = process.number_to_batch