|
|
|
@ -853,18 +853,6 @@ public class FlowOperationController { |
|
|
|
// 节点标题按实例批量预载(一次 IN 查询覆盖整页),避免逐行查询造成 N+1。
|
|
|
|
// 节点标题按实例批量预载(一次 IN 查询覆盖整页),避免逐行查询造成 N+1。
|
|
|
|
Map<String, FlowTaskInstanceExt> taskInstanceExtMap = |
|
|
|
Map<String, FlowTaskInstanceExt> taskInstanceExtMap = |
|
|
|
flowTaskInstanceExtService.getMapByProcessInstanceIds(instanceIdSet); |
|
|
|
flowTaskInstanceExtService.getMapByProcessInstanceIds(instanceIdSet); |
|
|
|
Set<String> processDefinitionIdSet = taskInstanceList.stream() |
|
|
|
|
|
|
|
.map(HistoricTaskInstance::getProcessDefinitionId).collect(Collectors.toSet()); |
|
|
|
|
|
|
|
List<FlowEntryPublish> flowEntryPublishList = |
|
|
|
|
|
|
|
flowEntryService.getFlowEntryPublishList(processDefinitionIdSet); |
|
|
|
|
|
|
|
Map<String, FlowEntryPublish> flowEntryPublishMap = |
|
|
|
|
|
|
|
flowEntryPublishList.stream().collect(Collectors.toMap(FlowEntryPublish::getProcessDefinitionId, c -> c)); |
|
|
|
|
|
|
|
Set<Long> entryIdSet = flowEntryPublishList.stream() |
|
|
|
|
|
|
|
.map(FlowEntryPublish::getEntryId).filter(Objects::nonNull).collect(Collectors.toSet()); |
|
|
|
|
|
|
|
Map<Long, FlowEntry> flowEntryMap = flowEntryService.listByIds(entryIdSet).stream() |
|
|
|
|
|
|
|
.collect(Collectors.toMap(FlowEntry::getEntryId, e -> e)); |
|
|
|
|
|
|
|
Map<String, FlowTaskExt> flowTaskExtMap = flowTaskExtService.getByProcessDefinitionId(processDefinitionIdSet).stream() |
|
|
|
|
|
|
|
.collect(Collectors.toMap(t -> t.getProcessDefinitionId() + ":" + t.getTaskId(), t -> t, (k1, k2) -> k1)); |
|
|
|
|
|
|
|
resultList.forEach(result -> { |
|
|
|
resultList.forEach(result -> { |
|
|
|
String instanceId = result.get(INSTANCE_ID).toString(); |
|
|
|
String instanceId = result.get(INSTANCE_ID).toString(); |
|
|
|
HistoricProcessInstance instance = instanceMap.get(instanceId); |
|
|
|
HistoricProcessInstance instance = instanceMap.get(instanceId); |
|
|
|
@ -878,19 +866,11 @@ public class FlowOperationController { |
|
|
|
FlowWorkOrder flowWorkOrder = workOrderMap.get(instanceId); |
|
|
|
FlowWorkOrder flowWorkOrder = workOrderMap.get(instanceId); |
|
|
|
if (flowWorkOrder != null) { |
|
|
|
if (flowWorkOrder != null) { |
|
|
|
result.put("workOrderCode", flowWorkOrder.getWorkOrderCode()); |
|
|
|
result.put("workOrderCode", flowWorkOrder.getWorkOrderCode()); |
|
|
|
String processDefinitionId = result.get("processDefinitionId").toString(); |
|
|
|
// 标题只认 zz_flow_task_instance_ext 的落库值:没有标题行就是空
|
|
|
|
FlowEntryPublish flowEntryPublish = flowEntryPublishMap.get(processDefinitionId); |
|
|
|
Object taskDefinitionKey = result.get("taskDefinitionKey"); |
|
|
|
FlowTaskExt flowTaskExt = flowTaskExtMap.get( |
|
|
|
String taskKey = taskDefinitionKey == null ? null : taskDefinitionKey.toString(); |
|
|
|
processDefinitionId + ":" + result.get("taskDefinitionKey")); |
|
|
|
result.put("title", flowApiService.resolveTitleCached(flowWorkOrder, taskKey, |
|
|
|
if (flowEntryPublish != null && flowTaskExt != null) { |
|
|
|
taskKey == null ? null : taskInstanceExtMap.get(instanceId + ":" + taskKey))); |
|
|
|
FlowEntry flowEntry = flowEntryMap.get(flowEntryPublish.getEntryId()); |
|
|
|
|
|
|
|
if (flowEntry != null) { |
|
|
|
|
|
|
|
Object taskDefinitionKey = result.get("taskDefinitionKey"); |
|
|
|
|
|
|
|
String taskKey = taskDefinitionKey == null ? null : taskDefinitionKey.toString(); |
|
|
|
|
|
|
|
result.put("title", flowApiService.resolveTitleCached(flowWorkOrder, taskKey, |
|
|
|
|
|
|
|
taskKey == null ? null : taskInstanceExtMap.get(instanceId + ":" + taskKey))); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
Set<String> taskIdSet = |
|
|
|
Set<String> taskIdSet = |
|
|
|
@ -949,22 +929,11 @@ public class FlowOperationController { |
|
|
|
Map<String, FlowTaskInstanceExt> taskInstanceExtMap = flowTaskInstanceExtService.getMapByProcessInstanceIds(instanceIdSet); |
|
|
|
Map<String, FlowTaskInstanceExt> taskInstanceExtMap = flowTaskInstanceExtService.getMapByProcessInstanceIds(instanceIdSet); |
|
|
|
Set<String> processDefinitionIdSet = pageData.getDataList().stream() |
|
|
|
Set<String> processDefinitionIdSet = pageData.getDataList().stream() |
|
|
|
.map(HistoricProcessInstance::getProcessDefinitionId).collect(Collectors.toSet()); |
|
|
|
.map(HistoricProcessInstance::getProcessDefinitionId).collect(Collectors.toSet()); |
|
|
|
Map<String, FlowEntryPublish> flowEntryPublishMap = new HashMap<>(); |
|
|
|
// 流程实例列表使用起始节点的标题,首节点 taskKey 存在发布版本的 initTaskInfo 里。
|
|
|
|
Map<Long, FlowEntry> flowEntryMap = new HashMap<>(); |
|
|
|
|
|
|
|
Map<String, FlowTaskExt> flowTaskExtMap = new HashMap<>(); |
|
|
|
|
|
|
|
// 流程实例列表使用起始节点的标题模板。
|
|
|
|
|
|
|
|
Map<String, String> initTaskKeyMap = new HashMap<>(); |
|
|
|
Map<String, String> initTaskKeyMap = new HashMap<>(); |
|
|
|
if (CollUtil.isNotEmpty(processDefinitionIdSet)) { |
|
|
|
if (CollUtil.isNotEmpty(processDefinitionIdSet)) { |
|
|
|
List<FlowEntryPublish> flowEntryPublishList = |
|
|
|
List<FlowEntryPublish> flowEntryPublishList = |
|
|
|
flowEntryService.getFlowEntryPublishList(processDefinitionIdSet); |
|
|
|
flowEntryService.getFlowEntryPublishList(processDefinitionIdSet); |
|
|
|
flowEntryPublishMap.putAll(flowEntryPublishList.stream() |
|
|
|
|
|
|
|
.collect(Collectors.toMap(FlowEntryPublish::getProcessDefinitionId, c -> c))); |
|
|
|
|
|
|
|
Set<Long> entryIdSet = flowEntryPublishList.stream() |
|
|
|
|
|
|
|
.map(FlowEntryPublish::getEntryId).filter(Objects::nonNull).collect(Collectors.toSet()); |
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(entryIdSet)) { |
|
|
|
|
|
|
|
flowEntryMap.putAll(flowEntryService.listByIds(entryIdSet).stream() |
|
|
|
|
|
|
|
.collect(Collectors.toMap(FlowEntry::getEntryId, e -> e))); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
for (FlowEntryPublish flowEntryPublish : flowEntryPublishList) { |
|
|
|
for (FlowEntryPublish flowEntryPublish : flowEntryPublishList) { |
|
|
|
TaskInfoVo initTaskInfo = StrUtil.isBlank(flowEntryPublish.getInitTaskInfo()) |
|
|
|
TaskInfoVo initTaskInfo = StrUtil.isBlank(flowEntryPublish.getInitTaskInfo()) |
|
|
|
? null : JSON.parseObject(flowEntryPublish.getInitTaskInfo(), TaskInfoVo.class); |
|
|
|
? null : JSON.parseObject(flowEntryPublish.getInitTaskInfo(), TaskInfoVo.class); |
|
|
|
@ -972,8 +941,6 @@ public class FlowOperationController { |
|
|
|
initTaskKeyMap.put(flowEntryPublish.getProcessDefinitionId(), initTaskInfo.getTaskKey()); |
|
|
|
initTaskKeyMap.put(flowEntryPublish.getProcessDefinitionId(), initTaskInfo.getTaskKey()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
flowTaskExtMap.putAll(flowTaskExtService.getByProcessDefinitionId(processDefinitionIdSet).stream() |
|
|
|
|
|
|
|
.collect(Collectors.toMap(t -> t.getProcessDefinitionId() + ":" + t.getTaskId(), t -> t, (k1, k2) -> k1))); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
List<Map<String, Object>> resultList = new LinkedList<>(); |
|
|
|
List<Map<String, Object>> resultList = new LinkedList<>(); |
|
|
|
pageData.getDataList().forEach(instance -> { |
|
|
|
pageData.getDataList().forEach(instance -> { |
|
|
|
@ -987,18 +954,10 @@ public class FlowOperationController { |
|
|
|
if (workOrder != null) { |
|
|
|
if (workOrder != null) { |
|
|
|
data.put("workOrderCode", workOrder.getWorkOrderCode()); |
|
|
|
data.put("workOrderCode", workOrder.getWorkOrderCode()); |
|
|
|
data.put("flowStatus", workOrder.getFlowStatus()); |
|
|
|
data.put("flowStatus", workOrder.getFlowStatus()); |
|
|
|
FlowEntryPublish flowEntryPublish = flowEntryPublishMap.get(instance.getProcessDefinitionId()); |
|
|
|
// 流程实例列表使用起始节点的标题;标题只认落库值,没有标题行就是空
|
|
|
|
FlowTaskExt flowTaskExt = flowTaskExtMap.get( |
|
|
|
String initTaskKey = initTaskKeyMap.get(instance.getProcessDefinitionId()); |
|
|
|
instance.getProcessDefinitionId() + ":" + initTaskKeyMap.get(instance.getProcessDefinitionId())); |
|
|
|
data.put("title", flowApiService.resolveTitleCached(workOrder, initTaskKey, |
|
|
|
if (flowEntryPublish != null && flowTaskExt != null) { |
|
|
|
initTaskKey == null ? null : taskInstanceExtMap.get(instance.getId() + ":" + initTaskKey))); |
|
|
|
FlowEntry flowEntry = flowEntryMap.get(flowEntryPublish.getEntryId()); |
|
|
|
|
|
|
|
if (flowEntry != null) { |
|
|
|
|
|
|
|
// 流程实例列表使用起始节点的标题。
|
|
|
|
|
|
|
|
String initTaskKey = initTaskKeyMap.get(instance.getProcessDefinitionId()); |
|
|
|
|
|
|
|
data.put("title", flowApiService.resolveTitleCached(workOrder, initTaskKey, |
|
|
|
|
|
|
|
initTaskKey == null ? null : taskInstanceExtMap.get(instance.getId() + ":" + initTaskKey))); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
resultList.add(data); |
|
|
|
resultList.add(data); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|