feat: 批次号追加number

This commit is contained in:
caoqianming 2024-07-31 14:27:15 +08:00
parent 166ae8b12c
commit 9ad0cf6498
1 changed files with 10 additions and 3 deletions

View File

@ -457,17 +457,18 @@ class MlogbInViewSet(CreateModelMixin, UpdateModelMixin, DestroyModelMixin, Cust
query_dict = {"material_out__isnull": False, "mlog": ins.mlog, "mtask": ins.mtask}
route = ins.mtask.route
if route.batch_bind:
query_dict["batch"] = ins.batch
query_dict["batch__contains"] = ins.batch
Mlogb.objects.filter(**query_dict).delete()
instance.delete()
@transaction.atomic
def perform_create(self, serializer):
ins: Mlogb = serializer.save()
mlog: Mlog = ins.mlog
# 创建输出
if ins.mtask and ins.material_in:
material_out = ins.mlog.material_out
route = ins.mlog.route
material_out = mlog.material_out
route = mlog.route
if material_out is None:
raise ParseError('产物不可为空')
m_dict = {
@ -477,6 +478,12 @@ class MlogbInViewSet(CreateModelMixin, UpdateModelMixin, DestroyModelMixin, Cust
}
if route.batch_bind: # 批次绑定
m_dict['batch'] = ins.batch
else:
new_batch = ins.batch
number = mlog.equipment.number if mlog.equipment else ''
if number:
new_batch = f'{number}{new_batch}'
m_dict['batch'] = new_batch
Mlogb.objects.get_or_create(**m_dict, defaults=m_dict)