@ -219,13 +219,12 @@ public class FlowOperationController {
@@ -219,13 +219,12 @@ public class FlowOperationController {
if ( StrUtil . isNotBlank ( flowTaskExt . getVariableListJson ( ) ) ) {
taskInfoVo . setVariableList ( JSON . parseArray ( flowTaskExt . getVariableListJson ( ) , JSONObject . class ) ) ;
}
FlowWorkOrder workOrder = flowWorkOrderService . getFlowWorkOrderByProcessInstanceId ( processInstanceId ) ;
// 单条详情:只查一次节点扩展(复用批量接口传单元素集合),无 N+1 风险。
String taskKey = taskInfoVo . getTaskKey ( ) ;
FlowTaskInstanceExt taskInstanceExt = workOrder = = null | | StrUtil . isBlank ( taskKey ) ? null
FlowTaskInstanceExt taskInstanceExt = StrUtil . isBlank ( taskKey ) ? null
: flowTaskInstanceExtService . getMapByProcessInstanceIds ( CollUtil . newHashSet ( processInstanceId ) )
. get ( processInstanceId + ":" + taskKey ) ;
taskInfoVo . setTitle ( flowApiService . resolveTitleCached ( workOrder , taskKey , taskInstanceExt ) ) ;
taskInfoVo . setTitle ( flowApiService . resolveTitleCached ( taskInstanceExt ) ) ;
}
return ResponseResult . success ( taskInfoVo ) ;
}
@ -835,24 +834,16 @@ public class FlowOperationController {
@@ -835,24 +834,16 @@ public class FlowOperationController {
pageData . getDataList ( ) . forEach ( instance - > resultList . add ( BeanUtil . beanToMap ( instance ) ) ) ;
List < HistoricTaskInstance > taskInstanceList = pageData . getDataList ( ) ;
if ( CollUtil . isNotEmpty ( taskInstanceList ) ) {
Set < String > instanceIdSet = taskInstanceList . stream ( )
. map ( HistoricTaskInstance : : getProcessInstanceId ) . collect ( Collectors . toSet ( ) ) ;
Set < String > instanceIdSet = taskInstanceList . stream ( ) . map ( HistoricTaskInstance : : getProcessInstanceId ) . collect ( Collectors . toSet ( ) ) ;
List < HistoricProcessInstance > instanceList = flowApiService . getHistoricProcessInstanceList ( instanceIdSet ) ;
Set < String > loginNameSet = instanceList . stream ( )
. map ( HistoricProcessInstance : : getStartUserId ) . collect ( Collectors . toSet ( ) ) ;
List < FlowUserInfoVo > userInfoList = flowCustomExtFactory
. getFlowIdentityExtHelper ( ) . getUserInfoListByUsernameSet ( loginNameSet ) ;
Map < String , FlowUserInfoVo > userInfoMap =
userInfoList . stream ( ) . collect ( Collectors . toMap ( FlowUserInfoVo : : getLoginName , c - > c ) ) ;
Map < String , HistoricProcessInstance > instanceMap =
instanceList . stream ( ) . collect ( Collectors . toMap ( HistoricProcessInstance : : getId , c - > c ) ) ;
List < FlowWorkOrder > workOrderList =
flowWorkOrderService . getInList ( INSTANCE_ID , instanceIdSet ) ;
Map < String , FlowWorkOrder > workOrderMap =
workOrderList . stream ( ) . collect ( Collectors . toMap ( FlowWorkOrder : : getProcessInstanceId , c - > c ) ) ;
Set < String > loginNameSet = instanceList . stream ( ) . map ( HistoricProcessInstance : : getStartUserId ) . collect ( Collectors . toSet ( ) ) ;
List < FlowUserInfoVo > userInfoList = flowCustomExtFactory . getFlowIdentityExtHelper ( ) . getUserInfoListByUsernameSet ( loginNameSet ) ;
Map < String , FlowUserInfoVo > userInfoMap = userInfoList . stream ( ) . collect ( Collectors . toMap ( FlowUserInfoVo : : getLoginName , c - > c ) ) ;
Map < String , HistoricProcessInstance > instanceMap = instanceList . stream ( ) . collect ( Collectors . toMap ( HistoricProcessInstance : : getId , c - > c ) ) ;
List < FlowWorkOrder > workOrderList = flowWorkOrderService . getInList ( INSTANCE_ID , instanceIdSet ) ;
Map < String , FlowWorkOrder > workOrderMap = workOrderList . stream ( ) . collect ( Collectors . toMap ( FlowWorkOrder : : getProcessInstanceId , c - > c ) ) ;
// 节点标题按实例批量预载(一次 IN 查询覆盖整页),避免逐行查询造成 N+1。
Map < String , FlowTaskInstanceExt > taskInstanceExtMap =
flowTaskInstanceExtService . getMapByProcessInstanceIds ( instanceIdSet ) ;
Map < String , FlowTaskInstanceExt > taskInstanceExtMap = flowTaskInstanceExtService . getMapByProcessInstanceIds ( instanceIdSet ) ;
resultList . forEach ( result - > {
String instanceId = result . get ( INSTANCE_ID ) . toString ( ) ;
HistoricProcessInstance instance = instanceMap . get ( instanceId ) ;
@ -869,15 +860,13 @@ public class FlowOperationController {
@@ -869,15 +860,13 @@ public class FlowOperationController {
// 标题只认 zz_flow_task_instance_ext 的落库值:没有标题行就是空
Object taskDefinitionKey = result . get ( "taskDefinitionKey" ) ;
String taskKey = taskDefinitionKey = = null ? null : taskDefinitionKey . toString ( ) ;
result . put ( "title" , flowApiService . resolveTitleCached ( flowWorkOrder , taskKey ,
result . put ( "title" , flowApiService . resolveTitleCached (
taskKey = = null ? null : taskInstanceExtMap . get ( instanceId + ":" + taskKey ) ) ) ;
}
} ) ;
Set < String > taskIdSet =
taskInstanceList . stream ( ) . map ( HistoricTaskInstance : : getId ) . collect ( Collectors . toSet ( ) ) ;
Set < String > taskIdSet = taskInstanceList . stream ( ) . map ( HistoricTaskInstance : : getId ) . collect ( Collectors . toSet ( ) ) ;
List < FlowTaskComment > commentList = flowTaskCommentService . getFlowTaskCommentListByTaskIds ( taskIdSet ) ;
Map < String , List < FlowTaskComment > > commentMap =
commentList . stream ( ) . collect ( Collectors . groupingBy ( FlowTaskComment : : getTaskId ) ) ;
Map < String , List < FlowTaskComment > > commentMap = commentList . stream ( ) . collect ( Collectors . groupingBy ( FlowTaskComment : : getTaskId ) ) ;
resultList . forEach ( result - > {
List < FlowTaskComment > comments = commentMap . get ( result . get ( "id" ) . toString ( ) ) ;
if ( CollUtil . isNotEmpty ( comments ) ) {
@ -956,7 +945,7 @@ public class FlowOperationController {
@@ -956,7 +945,7 @@ public class FlowOperationController {
data . put ( "flowStatus" , workOrder . getFlowStatus ( ) ) ;
// 流程实例列表使用起始节点的标题;标题只认落库值,没有标题行就是空
String initTaskKey = initTaskKeyMap . get ( instance . getProcessDefinitionId ( ) ) ;
data . put ( "title" , flowApiService . resolveTitleCached ( workOrder , initTaskKey ,
data . put ( "title" , flowApiService . resolveTitleCached (
initTaskKey = = null ? null : taskInstanceExtMap . get ( instance . getId ( ) + ":" + initTaskKey ) ) ) ;
}
resultList . add ( data ) ;