1
0
forked from erp-dev/erp

feat: change api/v2/plate-orders/by-process-node/ logic ***** danger

This commit is contained in:
2026-02-06 19:30:57 +08:00
parent e3536e0b1a
commit a9f1e8f18a
3 changed files with 119 additions and 0 deletions

View File

@@ -484,8 +484,12 @@ class PlateOrderByProcessNodeView(APIView):
def get(self, request):
qp = request.query_params
process_node_id = qp.get('process_node_id')
param_key = (qp.get('param_key') or '').strip()
param_value = (qp.get('param_value') or '').strip()
if not process_node_id:
return Response({'detail': 'process_node_id 为必填参数'}, status=status.HTTP_400_BAD_REQUEST)
if (param_key and not param_value) or (param_value and not param_key):
return Response({'detail': 'param_key 与 param_value 必须同时提供'}, status=status.HTTP_400_BAD_REQUEST)
try:
process_node_id_int = int(process_node_id)
@@ -545,6 +549,15 @@ class PlateOrderByProcessNodeView(APIView):
)
).filter(completed_target=0)
if param_key and param_value:
matching_logs = stateflow_models.StateFlowRecord.objects.filter(
business_object_id=OuterRef('business_object_id'),
state_id=target_state_id,
is_cancelled=False,
parameter_records__parameters__contains={param_key: param_value},
)
queryset = queryset.annotate(_has_state_param=Exists(matching_logs)).filter(_has_state_param=True)
# search同时支持主键与 design_code icontains不新增额外参数
search = (qp.get('search') or '').strip()
if search: