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