feat: batches_to 获取已指向的批次号
This commit is contained in:
parent
ad5d8db283
commit
5d33301389
|
@ -705,4 +705,22 @@ class BatchLog(BaseModel):
|
||||||
cls.objects.filter(mlog=mlog).delete()
|
cls.objects.filter(mlog=mlog).delete()
|
||||||
BatchSt.objects.filter(mlog=mlog).delete()
|
BatchSt.objects.filter(mlog=mlog).delete()
|
||||||
if mio:
|
if mio:
|
||||||
BatchSt.objects.filter(mio=mio).delete()
|
BatchSt.objects.filter(mio=mio).delete()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def batches_to(cls, batch:str):
|
||||||
|
batches = BatchLog.objects.filter(source__batch=batch).values_list("target__batch", flat=True).order_by("target__batch").distinct()
|
||||||
|
batches = list(batches)
|
||||||
|
last_batch_num = None
|
||||||
|
if batches:
|
||||||
|
last_batch = batches[-1]
|
||||||
|
last_batch_list = last_batch.split("-")
|
||||||
|
if last_batch_list:
|
||||||
|
try:
|
||||||
|
last_batch_num = int(last_batch_list[-1])
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
return {"batches": batches, "last_batch_num": last_batch_num, "last_batch": last_batch}
|
||||||
|
return {"batches": [], "last_batch_num": None, "last_batch": None}
|
||||||
|
|
||||||
|
|
|
@ -883,4 +883,16 @@ class BatchLogViewSet(ListModelMixin, CustomGenericViewSet):
|
||||||
version = request.data.get("version", 1)
|
version = request.data.get("version", 1)
|
||||||
if not batch:
|
if not batch:
|
||||||
raise ParseError("缺少batch参数")
|
raise ParseError("缺少batch参数")
|
||||||
return Response(get_batch_dag(batch, version))
|
return Response(get_batch_dag(batch, version))
|
||||||
|
|
||||||
|
@action(methods=['post'], detail=False, perms_map={'post': '*'}, serializer_class=Serializer)
|
||||||
|
def batches_to(self, request, *args, **kwargs):
|
||||||
|
"""获取已指向的批次号
|
||||||
|
|
||||||
|
获取已指向的批次号
|
||||||
|
"""
|
||||||
|
data = request.data
|
||||||
|
batch = data.get("batch", None)
|
||||||
|
if not batch:
|
||||||
|
raise ParseError("请指定批次号")
|
||||||
|
return Response(BatchLog.batches_to(batch=batch))
|
Loading…
Reference in New Issue