feat: handover拆批时校验批次号是否可用
This commit is contained in:
parent
45e02eae5f
commit
f689b7609c
|
@ -738,19 +738,26 @@ def handover_submit(handover:Handover, user: User, now: Union[datetime.datetime,
|
|||
|
||||
recive_mgroup = handover.recive_mgroup
|
||||
recive_dept = handover.recive_dept
|
||||
batches = []
|
||||
|
||||
new_batch = handover.new_batch
|
||||
if new_batch and mtype != Handover.H_MERGE:
|
||||
raise ParseError("只有合并时才能提供新批次号")
|
||||
|
||||
batches = []
|
||||
mids = []
|
||||
exclude_batchst_ids = []
|
||||
if mtype == Handover.H_MERGE:
|
||||
if new_batch:
|
||||
batches = [new_batch]
|
||||
else:
|
||||
raise ParseError("合并批次时请提供新批次号")
|
||||
|
||||
new_target = None
|
||||
exclude_batchst_ids = []
|
||||
mids = []
|
||||
target_b, _ = BatchSt.g_create(batch=new_batch, handover=handover, material_start=material)
|
||||
exclude_batchst_ids.append(target_b.id)
|
||||
elif mtype == Handover.H_DIV:
|
||||
if handover.wm is None:
|
||||
raise ParseError('拆批请选择车间库存')
|
||||
batches_to_limit = BatchLog.batches_to(batch=handover.wm.batch)
|
||||
source_b, _ = BatchSt.g_create(batch=handover.wm.batch)
|
||||
for item in handoverb_list:
|
||||
wmId, xcount, handover_or_b = item
|
||||
if xcount <= 0:
|
||||
|
@ -761,19 +768,16 @@ def handover_submit(handover:Handover, user: User, now: Union[datetime.datetime,
|
|||
# 合并为新批
|
||||
if mtype == Handover.H_MERGE:
|
||||
source, _ = BatchSt.g_create(batch=wm_from.batch, exclude_batchst_ids=exclude_batchst_ids)
|
||||
batch = new_batch
|
||||
if new_target is None:
|
||||
new_target, _ = BatchSt.g_create(batch=batch, handover=handover, material_start=material)
|
||||
exclude_batchst_ids.append(new_target.id)
|
||||
BatchLog.g_create(source=source, target=new_target, handover=handover, relation_type="merge")
|
||||
BatchLog.g_create(source=source, target=target_b, handover=handover, relation_type="merge")
|
||||
elif mtype == Handover.H_DIV:
|
||||
if handover.wm is None:
|
||||
raise ParseError('拆批请选择车间库存')
|
||||
source, _ = BatchSt.g_create(batch=handover.wm.batch, exclude_batchst_ids=exclude_batchst_ids)
|
||||
batch = handover_or_b.batch
|
||||
if batch in batches_to_limit:
|
||||
raise ParseError(f'{batch} 不在可拆批次中')
|
||||
else:
|
||||
batches_to_limit.append(batch)
|
||||
target, _ = BatchSt.g_create(batch=batch, handover=handover, material_start=material)
|
||||
exclude_batchst_ids.append(target.id)
|
||||
BatchLog.g_create(source=source, target=target, handover=handover, relation_type="split")
|
||||
BatchLog.g_create(source=source_b, target=target, handover=handover, relation_type="split")
|
||||
else:
|
||||
batch = wm_from.batch
|
||||
batches.append(batch)
|
||||
|
|
Loading…
Reference in New Issue