feat: 批次号追加number
This commit is contained in:
parent
166ae8b12c
commit
9ad0cf6498
|
|
@ -457,17 +457,18 @@ class MlogbInViewSet(CreateModelMixin, UpdateModelMixin, DestroyModelMixin, Cust
|
||||||
query_dict = {"material_out__isnull": False, "mlog": ins.mlog, "mtask": ins.mtask}
|
query_dict = {"material_out__isnull": False, "mlog": ins.mlog, "mtask": ins.mtask}
|
||||||
route = ins.mtask.route
|
route = ins.mtask.route
|
||||||
if route.batch_bind:
|
if route.batch_bind:
|
||||||
query_dict["batch"] = ins.batch
|
query_dict["batch__contains"] = ins.batch
|
||||||
Mlogb.objects.filter(**query_dict).delete()
|
Mlogb.objects.filter(**query_dict).delete()
|
||||||
instance.delete()
|
instance.delete()
|
||||||
|
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
def perform_create(self, serializer):
|
def perform_create(self, serializer):
|
||||||
ins: Mlogb = serializer.save()
|
ins: Mlogb = serializer.save()
|
||||||
|
mlog: Mlog = ins.mlog
|
||||||
# 创建输出
|
# 创建输出
|
||||||
if ins.mtask and ins.material_in:
|
if ins.mtask and ins.material_in:
|
||||||
material_out = ins.mlog.material_out
|
material_out = mlog.material_out
|
||||||
route = ins.mlog.route
|
route = mlog.route
|
||||||
if material_out is None:
|
if material_out is None:
|
||||||
raise ParseError('产物不可为空')
|
raise ParseError('产物不可为空')
|
||||||
m_dict = {
|
m_dict = {
|
||||||
|
|
@ -477,6 +478,12 @@ class MlogbInViewSet(CreateModelMixin, UpdateModelMixin, DestroyModelMixin, Cust
|
||||||
}
|
}
|
||||||
if route.batch_bind: # 批次绑定
|
if route.batch_bind: # 批次绑定
|
||||||
m_dict['batch'] = ins.batch
|
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)
|
Mlogb.objects.get_or_create(**m_dict, defaults=m_dict)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue