feat: 合批时的物料校验
This commit is contained in:
parent
0ddc6692ac
commit
4e7757f64d
|
@ -953,12 +953,18 @@ class HandoverSerializer(CustomModelSerializer):
|
||||||
if attrs["type"] == Handover.H_CHANGE:
|
if attrs["type"] == Handover.H_CHANGE:
|
||||||
if "material_changed" not in attrs:
|
if "material_changed" not in attrs:
|
||||||
raise ParseError("必须指定改版后的物料")
|
raise ParseError("必须指定改版后的物料")
|
||||||
|
|
||||||
if mtype == Handover.H_MERGE:
|
if mtype == Handover.H_MERGE:
|
||||||
new_wm = attrs.get("new_wm", None)
|
new_state = None
|
||||||
|
new_wm:WMaterial = attrs.get("new_wm", None)
|
||||||
if new_wm:
|
if new_wm:
|
||||||
attrs['new_batch'] = new_wm.batch
|
attrs['new_batch'] = new_wm.batch
|
||||||
|
new_state = new_wm.state
|
||||||
|
new_defect = new_wm.defect
|
||||||
if not attrs.get("new_batch", None):
|
if not attrs.get("new_batch", None):
|
||||||
raise ParseError("必须指定合并后的批次")
|
raise ParseError("必须指定合并后的批次")
|
||||||
|
|
||||||
|
|
||||||
wm:WMaterial = attrs.get('wm', None)
|
wm:WMaterial = attrs.get('wm', None)
|
||||||
handoverb = attrs.get('handoverb', [])
|
handoverb = attrs.get('handoverb', [])
|
||||||
if wm:
|
if wm:
|
||||||
|
@ -987,6 +993,15 @@ class HandoverSerializer(CustomModelSerializer):
|
||||||
tracking = attrs["material"].tracking
|
tracking = attrs["material"].tracking
|
||||||
for ind, item in enumerate(attrs['handoverb']):
|
for ind, item in enumerate(attrs['handoverb']):
|
||||||
wm = item["wm"]
|
wm = item["wm"]
|
||||||
|
if mtype == Handover.H_MERGE:
|
||||||
|
if new_state is None:
|
||||||
|
new_state = wm.state
|
||||||
|
new_defect = wm.defect
|
||||||
|
else:
|
||||||
|
if new_state != wm.state:
|
||||||
|
raise ParseError(f'第{ind+1}行-合并的物料状态不一致')
|
||||||
|
if new_defect != wm.defect:
|
||||||
|
raise ParseError(f'第{ind+1}行-合并的物料缺陷不一致')
|
||||||
if tracking == Material.MA_TRACKING_SINGLE:
|
if tracking == Material.MA_TRACKING_SINGLE:
|
||||||
handoverbw = item.get("handoverbw", [])
|
handoverbw = item.get("handoverbw", [])
|
||||||
if handoverbw:
|
if handoverbw:
|
||||||
|
|
Loading…
Reference in New Issue