fix: batchst的version字段bug
This commit is contained in:
parent
2987853afb
commit
dd4d958f86
|
@ -621,13 +621,14 @@ class BatchSt(BaseModel):
|
|||
if mio is None and handover is None and mlog is None:
|
||||
return cls.objects.get_or_create(batch=batch)
|
||||
else:
|
||||
latest_version = 0
|
||||
version = 1
|
||||
# 带有来源的批次获取,需检查批次号是否可用
|
||||
if cls.objects.filter(batch=batch, version=0).exists():
|
||||
if cls.objects.filter(batch=batch, version=1).exists():
|
||||
latest_version = BatchSt.objects.filter(batch=batch).aggregate(Max("version"))["version__max"]
|
||||
version = latest_version + 1
|
||||
if mio is None and handover is None and mlog is None:
|
||||
raise ParseError("mio or handover or mlog must be provided")
|
||||
ins = cls.objects.create(batch=batch, mio=mio, handover=handover, mlog=mlog, material_start=material_start, version=latest_version+1)
|
||||
ins = cls.objects.create(batch=batch, mio=mio, handover=handover, mlog=mlog, material_start=material_start, version=version)
|
||||
return ins, True
|
||||
|
||||
@classmethod
|
||||
|
|
Loading…
Reference in New Issue