forked from erp-dev/erp
feat: change api/v2/plate-orders/by-process-node/ logic ***** danger
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user