|
|
@@ -48,7 +48,7 @@ import com.wflow.mapper.WflowCcTasksMapper; |
|
|
|
import com.wflow.mapper.WflowModelHistorysMapper; |
|
|
|
import com.wflow.service.OrgRepositoryService; |
|
|
|
import com.wflow.utils.CodeUtil; |
|
|
|
import com.wflow.workflow.bean.process.OrgUser; |
|
|
|
import com.wflow.workflow.bean.dto.ProcessInstanceUserDto; |
|
|
|
import com.wflow.workflow.bean.process.ProcessNode; |
|
|
|
import com.wflow.workflow.bean.process.enums.ApprovalModeEnum; |
|
|
|
import com.wflow.workflow.bean.process.enums.NodeTypeEnum; |
|
|
@@ -56,7 +56,6 @@ import com.wflow.workflow.bean.process.form.Form; |
|
|
|
import com.wflow.workflow.bean.process.props.ApprovalProps; |
|
|
|
import com.wflow.workflow.bean.vo.ProcessInstanceVo; |
|
|
|
import com.wflow.workflow.bean.vo.ProcessTaskVo; |
|
|
|
import com.wflow.workflow.bean.vo.UserInfoVO; |
|
|
|
import com.wflow.workflow.config.WflowGlobalVarDef; |
|
|
|
import com.wflow.workflow.enums.ProcessHandlerEnum; |
|
|
|
import com.wflow.workflow.service.FormService; |
|
|
@@ -177,15 +176,9 @@ public class TodoCenterManage { |
|
|
|
// 从待办任务列表中取出当前登录用户及项目实例对应的任务 |
|
|
|
Task task = taskMap.get(d.getInstCode()); |
|
|
|
HistoricProcessInstance instance = instanceMap.get(task.getProcessInstanceId()); |
|
|
|
//HashSet<String> userSet = new HashSet<>(); |
|
|
|
//userSet.add(instance.getStartUserId()) ; |
|
|
|
//Map<Long, UserInfoVO> userMap = userInfoService.getUserMapByIds(userSet); |
|
|
|
//res.setOwner(userMap.get(Long.valueOf(instance.getStartUserId()))); |
|
|
|
UserInfoVO owner = new UserInfoVO(); |
|
|
|
owner.setUserId(Long.valueOf(instance.getStartUserId())); |
|
|
|
res.setOwner(owner); |
|
|
|
|
|
|
|
// 从缓存取 |
|
|
|
staterUsers.add(String.valueOf(userId)); |
|
|
|
staterUsers.add(String.valueOf(instance.getStartUserId())); |
|
|
|
ProcessTaskVo processTaskVo = ProcessTaskVo.builder() |
|
|
|
.taskId(task.getId()) |
|
|
|
.taskName(task.getName()) |
|
|
@@ -210,7 +203,7 @@ public class TodoCenterManage { |
|
|
|
// 取用户信息,减少数据库查询,一次构建 |
|
|
|
List<ResToBeProcessedDTO> result = null; |
|
|
|
if (isNotEmpty(staterUsers)) { |
|
|
|
//Map<Long, UserInfoVO> userMap = userInfoService.getUserMapByIds(staterUsers); |
|
|
|
//Map<String, ProcessInstanceUserDto> userMap = userInfoService.getUserMapByIds(staterUsers); |
|
|
|
//result = resVos.stream() |
|
|
|
// .peek(v -> v.getProcessTaskInfo().setStartUser(userMap.get(Long.valueOf(v.getProcessTaskInfo().getOwnerId())))) |
|
|
|
// .collect(Collectors.toList()); |
|
|
@@ -318,9 +311,7 @@ public class TodoCenterManage { |
|
|
|
* @since 2023/02/01 |
|
|
|
*/ |
|
|
|
public void handler(ReqProcessHandlerDTO param) { |
|
|
|
|
|
|
|
// 获取登录用户ID |
|
|
|
|
|
|
|
// Long userId = LoginUserUtil.getUserId(); |
|
|
|
|
|
|
|
// Long userId = 381496L; |
|
|
@@ -329,8 +320,12 @@ public class TodoCenterManage { |
|
|
|
|
|
|
|
// 若进行的是撤回操作(流程发起人和当前流程审核人的前一个审核人操作) |
|
|
|
if (param.getAction().equals(ProcessHandlerEnum.WITHDRAW)) { |
|
|
|
HistoricTaskInstance handledTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(param.getTaskId()).singleResult(); |
|
|
|
doWithDrawProcess(handledTaskInstance, userId); |
|
|
|
HistoricTaskInstance handledTaskInstance = historyService.createHistoricTaskInstanceQuery() |
|
|
|
.taskId(param.getTaskId()) |
|
|
|
.singleResult(); |
|
|
|
// 获取要处理的项目ID |
|
|
|
Long projectId = param.getProjectId(); |
|
|
|
doWithDrawProcess(handledTaskInstance, userId, projectId); |
|
|
|
return; |
|
|
|
} |
|
|
|
Task task = taskService.createTaskQuery().taskId(param.getTaskId()).active().singleResult(); |
|
|
@@ -373,8 +368,9 @@ public class TodoCenterManage { |
|
|
|
*/ |
|
|
|
private void doReject(Task task, Long userId, ReqProcessHandlerDTO param) { |
|
|
|
// 获取当前申报项目 |
|
|
|
Project declaredProject = projectService |
|
|
|
.getOne(Wrappers.lambdaQuery(Project.class).eq(Project::getInstCode, task.getProcessInstanceId())); |
|
|
|
Project declaredProject = projectService.getOne(Wrappers.lambdaQuery(Project.class) |
|
|
|
.eq(Project::getInstCode, task.getProcessInstanceId()) |
|
|
|
.eq(Project::getId,param.getProjectId())); |
|
|
|
String projectName = declaredProject.getProjectName(); |
|
|
|
|
|
|
|
Map<String, Object> var = new HashMap<>(16); |
|
|
@@ -487,8 +483,9 @@ public class TodoCenterManage { |
|
|
|
private void doPass(Task task, Long userId, ReqProcessHandlerDTO param) { |
|
|
|
String processInstanceId = task.getProcessInstanceId(); |
|
|
|
// 获取当前申报项目 |
|
|
|
Project declaredProject = projectService |
|
|
|
.getOne(Wrappers.lambdaQuery(Project.class).eq(Project::getInstCode, task.getProcessInstanceId())); |
|
|
|
Project declaredProject = projectService.getOne(Wrappers.lambdaQuery(Project.class) |
|
|
|
.eq(Project::getInstCode, task.getProcessInstanceId()) |
|
|
|
.eq(Project::getId,param.getProjectId())); |
|
|
|
String projectName = declaredProject.getProjectName(); |
|
|
|
|
|
|
|
Map<String, Object> var = new HashMap<>(16); |
|
|
@@ -721,8 +718,9 @@ public class TodoCenterManage { |
|
|
|
* |
|
|
|
* @param handledTaskInstance 已处理的历史任务实例 |
|
|
|
* @param userId 当前登录用户ID |
|
|
|
* @param projectId |
|
|
|
*/ |
|
|
|
private void doWithDrawProcess(HistoricTaskInstance handledTaskInstance, Long userId) { |
|
|
|
private void doWithDrawProcess(HistoricTaskInstance handledTaskInstance, Long userId, Long projectId) { |
|
|
|
String processInstanceId = handledTaskInstance.getProcessInstanceId(); |
|
|
|
// 获取当前流程实例待审核任务信息 |
|
|
|
Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult(); |
|
|
@@ -735,7 +733,8 @@ public class TodoCenterManage { |
|
|
|
String startUserId = historicProcessInstance.getStartUserId(); |
|
|
|
// 获取当前申报项目 |
|
|
|
Project declaredProject = projectService.getOne(Wrappers.lambdaQuery(Project.class) |
|
|
|
.eq(Project::getInstCode, processInstanceId)); |
|
|
|
.eq(Project::getInstCode, processInstanceId) |
|
|
|
.eq(Project::getId,projectId)); |
|
|
|
String projectName = declaredProject.getProjectName(); |
|
|
|
|
|
|
|
// 获取bpm对象 |
|
|
@@ -869,8 +868,9 @@ public class TodoCenterManage { |
|
|
|
*/ |
|
|
|
private void doBackTask(Task task, Long userId, ReqProcessHandlerDTO param) { |
|
|
|
// 获取当前申报项目 |
|
|
|
Project declaredProject = projectService |
|
|
|
.getOne(Wrappers.lambdaQuery(Project.class).eq(Project::getInstCode, task.getProcessInstanceId())); |
|
|
|
Project declaredProject = projectService.getOne(Wrappers.lambdaQuery(Project.class) |
|
|
|
.eq(Project::getInstCode, task.getProcessInstanceId()) |
|
|
|
.eq(Project::getId,param.getProjectId())); |
|
|
|
String projectName = declaredProject.getProjectName(); |
|
|
|
// 保存审核意见 |
|
|
|
if (hasComment(param.getAuditInfo())) { |
|
|
@@ -910,11 +910,10 @@ public class TodoCenterManage { |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询流程表单数据及审批的进度步骤 |
|
|
|
* @param nodeId 当前获取流程人员关联的流程节点ID |
|
|
|
* @param instanceId 流程实例ID |
|
|
|
* @return 流程进度及表单详情 |
|
|
|
*/ |
|
|
|
public ProcessProgressDetailVo getProcessDetail(String nodeId, String instanceId, Long projectId) { |
|
|
|
public ProcessProgressDetailVo getProcessDetail(String instanceId, Long projectId) { |
|
|
|
HistoricProcessInstance instance = historyService.createHistoricProcessInstanceQuery() |
|
|
|
.processInstanceId(instanceId) |
|
|
|
.singleResult(); |
|
|
@@ -924,39 +923,59 @@ public class TodoCenterManage { |
|
|
|
.variableName(WflowGlobalVarDef.WFLOW_FORMS) |
|
|
|
.singleResult(); |
|
|
|
List<HistoricVariableInstance> formDatas = null; |
|
|
|
if (nodeId.equals("undefined")) { |
|
|
|
List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery().processInstanceId(instanceId).list(); |
|
|
|
formDatas = historyService |
|
|
|
.createHistoricVariableInstanceQuery() |
|
|
|
.executionIds(historicTaskInstances.stream() |
|
|
|
.map(HistoricTaskInstance::getExecutionId) |
|
|
|
.collect(Collectors.toSet())) |
|
|
|
.processInstanceId(instanceId) |
|
|
|
.list(); |
|
|
|
} else { |
|
|
|
formDatas = historyService |
|
|
|
.createHistoricVariableInstanceQuery() |
|
|
|
.processInstanceId(instanceId) |
|
|
|
.list(); |
|
|
|
} |
|
|
|
//if (nodeId.equals("undefined")) { |
|
|
|
// List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery().processInstanceId(instanceId).list(); |
|
|
|
// formDatas = historyService |
|
|
|
// .createHistoricVariableInstanceQuery() |
|
|
|
// .executionIds(historicTaskInstances.stream() |
|
|
|
// .map(HistoricTaskInstance::getExecutionId) |
|
|
|
// .collect(Collectors.toSet())) |
|
|
|
// .processInstanceId(instanceId) |
|
|
|
// .list(); |
|
|
|
//} else { |
|
|
|
// formDatas = historyService |
|
|
|
// .createHistoricVariableInstanceQuery() |
|
|
|
// .processInstanceId(instanceId) |
|
|
|
// .list(); |
|
|
|
//} |
|
|
|
List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery() |
|
|
|
.processInstanceId(instanceId).list(); |
|
|
|
formDatas = historyService.createHistoricVariableInstanceQuery() |
|
|
|
.executionIds(historicTaskInstances.stream() |
|
|
|
.map(HistoricTaskInstance::getExecutionId) |
|
|
|
.collect(Collectors.toSet())) |
|
|
|
.processInstanceId(instanceId).list(); |
|
|
|
|
|
|
|
// 取节点设置 |
|
|
|
HistoricVariableInstance nodeProps = historyService.createHistoricVariableInstanceQuery() |
|
|
|
.processInstanceId(instanceId).variableName(WflowGlobalVarDef.WFLOW_NODE_PROPS).singleResult(); |
|
|
|
Map<String, Object> nodePropsValue = (Map<String, Object>) nodeProps.getValue(); |
|
|
|
|
|
|
|
ProcessNode<?> currentNode = null; |
|
|
|
if (StrUtil.isNotBlank(nodeId)) { |
|
|
|
// 搜索当前版本流程的配置 |
|
|
|
WflowModelHistorys modelHistory = modelHistorysMapper.selectOne(new QueryWrapper<>(WflowModelHistorys.builder() |
|
|
|
|
|
|
|
//if (StrUtil.isNotBlank(nodeId)) { |
|
|
|
// // 搜索当前版本流程的配置 |
|
|
|
// WflowModelHistorys modelHistory = modelHistorysMapper.selectOne(new QueryWrapper<>(WflowModelHistorys.builder() |
|
|
|
// .processDefId(instance.getProcessDefinitionId()) |
|
|
|
// .version(instance.getProcessDefinitionVersion()) |
|
|
|
// .build())); |
|
|
|
// currentNode = nodeCatchService.reloadProcessByStr(modelHistory.getProcess()).get(nodeId); |
|
|
|
//} |
|
|
|
// 搜索当前版本流程的配置 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WflowModelHistorys modelHistory = modelHistorysMapper.selectOne(new QueryWrapper<>(WflowModelHistorys.builder() |
|
|
|
.processDefId(instance.getProcessDefinitionId()) |
|
|
|
.version(instance.getProcessDefinitionVersion()) |
|
|
|
.build())); |
|
|
|
currentNode = nodeCatchService.reloadProcessByStr(modelHistory.getProcess()).get(nodeId); |
|
|
|
} |
|
|
|
currentNode = nodeCatchService.reloadProcessByStr(modelHistory.getProcess()).get("undefined"); |
|
|
|
|
|
|
|
//UserInfo userInfo = userInfoService.getById(Long.valueOf(instance.getStartUserId())); |
|
|
|
//HashSet<String> userSet = new HashSet<>(); |
|
|
|
//userSet.add(String.valueOf(userInfo.getId())); |
|
|
|
//Map<Long, UserInfoVO> userMap = userInfoService.getUserMapByIds(userSet); |
|
|
|
//UserInfoVO userInfoVO = userMap.get(userInfo.getId()); |
|
|
|
//Map<String, ProcessInstanceUserDto> userMap = userInfoService.getUserMapByIds(userSet); |
|
|
|
//ProcessInstanceUserDto startUser = userMap.get(String.valueOf(userInfo.getId())); |
|
|
|
List<ProgressNode> taskRecords = getHisTaskRecords(instanceId, nodePropsValue); |
|
|
|
// 获取添加抄送任务 |
|
|
|
taskRecords.addAll(getCcTaskRecords(instanceId)); |
|
|
@@ -989,7 +1008,7 @@ public class TodoCenterManage { |
|
|
|
.startTime(instance.getStartTime()) |
|
|
|
.progress(taskRecords) |
|
|
|
.build(); |
|
|
|
//res.setStartUser(userInfoVO); |
|
|
|
//res.setStartUser(startUser); |
|
|
|
Project project = projectService.getById(projectId); |
|
|
|
res.setStatus(ProcessStatusEnum.getDescByCode(project.getProcessStatus())); |
|
|
|
return res; |
|
|
@@ -1010,13 +1029,13 @@ public class TodoCenterManage { |
|
|
|
ccUsers.add(task.getUserId()); |
|
|
|
return ProgressNode.builder().nodeId(task.getNodeId()).nodeType(NodeTypeEnum.CC) |
|
|
|
.name(task.getNodeName()) |
|
|
|
.user(UserInfoVO.builder().userId(Long.valueOf(task.getUserId())).build()) |
|
|
|
.user(ProcessInstanceUserDto.builder().userId(task.getUserId()).build()) |
|
|
|
.startTime(task.getCreateTime()) |
|
|
|
.finishTime(task.getCreateTime()) |
|
|
|
.build(); |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
if (isNotEmpty(ccUsers)) { |
|
|
|
Map<Long, UserInfoVO> userMap = userInfoService.getUserMapByIds(ccUsers); |
|
|
|
Map<String, ProcessInstanceUserDto> userMap = userInfoService.getUserMapByIds(ccUsers); |
|
|
|
ccList.stream().peek(v -> v.setUser(userMap.get(v.getUser().getUserId()))).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
return ccList; |
|
|
@@ -1051,7 +1070,7 @@ public class TodoCenterManage { |
|
|
|
.commentType(comment.getType()) |
|
|
|
.type("COMMENT") |
|
|
|
.createTime(comment.getTime()) |
|
|
|
.user(UserInfoVO.builder().userId(Long.valueOf(comment.getUserId())).build()) |
|
|
|
.user(ProcessInstanceUserDto.builder().userId(comment.getUserId()).build()) |
|
|
|
.build(); |
|
|
|
ProcessComment processComment = JSONObject.parseObject(comment.getFullMessage(), ProcessComment.class); |
|
|
|
progressNodeAuditInfoVo.setText(processComment.getText()); |
|
|
@@ -1079,7 +1098,7 @@ public class TodoCenterManage { |
|
|
|
.nodeId(his.getActivityId()) |
|
|
|
.name(his.getActivityName()) |
|
|
|
.nodeType(NodeTypeEnum.APPROVAL) |
|
|
|
.user(UserInfoVO.builder().userId(Long.valueOf(his.getAssignee())).build()) |
|
|
|
.user(ProcessInstanceUserDto.builder().userId(his.getAssignee()).build()) |
|
|
|
.startTime(his.getStartTime()) |
|
|
|
.finishTime(his.getEndTime()) |
|
|
|
.taskId(his.getTaskId()) |
|
|
@@ -1088,7 +1107,7 @@ public class TodoCenterManage { |
|
|
|
.result(varMap.get("approve_" + his.getTaskId())).build(); |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
if (isNotEmpty(userSet)) { |
|
|
|
Map<Long, UserInfoVO> userMap = userInfoService.getUserMapByIds(userSet); |
|
|
|
Map<String, ProcessInstanceUserDto> userMap = userInfoService.getUserMapByIds(userSet); |
|
|
|
progressNodes.stream().peek(v -> v.setUser(userMap.get(v.getUser().getUserId()))).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
return progressNodes; |
|
|
@@ -1158,34 +1177,35 @@ public class TodoCenterManage { |
|
|
|
res.setProcessStatusName(ProcessStatusEnum.getDescByCode(d.getProcessStatus())); |
|
|
|
LocalDateTime processLaunchTime = d.getCreateOn(); |
|
|
|
String launchTimeFormat = NdDateUtils.format(processLaunchTime, "yyyy-MM-dd HH:mm"); |
|
|
|
LocalDateTime launchTime = |
|
|
|
LocalDateTime.parse(launchTimeFormat, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")); |
|
|
|
LocalDateTime launchTime = LocalDateTime.parse(launchTimeFormat, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")); |
|
|
|
res.setProcessLaunchTime(launchTime); |
|
|
|
LocalDateTime processHandleTime = d.getUpdateOn(); |
|
|
|
String handleTimeFormat = NdDateUtils.format(processHandleTime, "yyyy-MM-dd HH:mm"); |
|
|
|
LocalDateTime handleTime = |
|
|
|
LocalDateTime.parse(handleTimeFormat, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")); |
|
|
|
LocalDateTime handleTime = LocalDateTime.parse(handleTimeFormat, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")); |
|
|
|
res.setProcessHandleTime(handleTime); |
|
|
|
|
|
|
|
// 从已处理任务实例列表中取出当前登录用户及项目实例对应的任务实例 |
|
|
|
HistoricTaskInstance task = taskInstanceMap.get(d.getInstCode()); |
|
|
|
HistoricProcessInstance instance = instanceMap.get(task.getProcessInstanceId()); |
|
|
|
//HashSet<String> userSet = new HashSet<>(); |
|
|
|
//userSet.add(instance.getStartUserId()) ; |
|
|
|
//Map<Long, UserInfoVO> userMap = userInfoService.getUserMapByIds(userSet); |
|
|
|
//res.setOwner(userMap.get(Long.valueOf(instance.getStartUserId()))); |
|
|
|
UserInfoVO owner = new UserInfoVO(); |
|
|
|
owner.setUserId(Long.valueOf(instance.getStartUserId())); |
|
|
|
res.setOwner(owner); |
|
|
|
|
|
|
|
// 从缓存取 |
|
|
|
staterUsers.add(instance.getStartUserId()); |
|
|
|
ProcessTaskVo processTaskVo = ProcessTaskVo.builder().taskId(task.getId()).taskName(task.getName()) |
|
|
|
.taskDefKey(task.getTaskDefinitionKey()).processDefId(task.getProcessDefinitionId()) |
|
|
|
.executionId(task.getExecutionId()).nodeId(task.getTaskDefinitionKey()) |
|
|
|
.deployId(instance.getDeploymentId()).processDefName(instance.getProcessDefinitionName()) |
|
|
|
.version(instance.getProcessDefinitionVersion()).instanceId(task.getProcessInstanceId()) |
|
|
|
.ownerId(instance.getStartUserId()).createTime(instance.getStartTime()) |
|
|
|
.taskCreateTime(task.getCreateTime()).build(); |
|
|
|
ProcessTaskVo processTaskVo = ProcessTaskVo |
|
|
|
.builder() |
|
|
|
.taskId(task.getId()) |
|
|
|
.taskName(task.getName()) |
|
|
|
.taskDefKey(task.getTaskDefinitionKey()) |
|
|
|
.processDefId(task.getProcessDefinitionId()) |
|
|
|
.executionId(task.getExecutionId()) |
|
|
|
.nodeId(task.getTaskDefinitionKey()) |
|
|
|
.deployId(instance.getDeploymentId()) |
|
|
|
.processDefName(instance.getProcessDefinitionName()) |
|
|
|
.version(instance.getProcessDefinitionVersion()) |
|
|
|
.instanceId(task.getProcessInstanceId()) |
|
|
|
.ownerId(instance.getStartUserId()) |
|
|
|
.createTime(instance.getStartTime()) |
|
|
|
.taskCreateTime(task.getCreateTime()) |
|
|
|
.build(); |
|
|
|
res.setProcessTaskInfo(processTaskVo); |
|
|
|
return res; |
|
|
|
}).collect(Collectors.toList()); |
|
|
@@ -1195,9 +1215,9 @@ public class TodoCenterManage { |
|
|
|
// 取用户信息,减少数据库查询,一次构建 |
|
|
|
List<ResToBeProcessedDTO> result = null; |
|
|
|
if (isNotEmpty(staterUsers)) { |
|
|
|
//Map<Long, UserInfoVO> userMap = userInfoService.getUserMapByIds(staterUsers); |
|
|
|
//Map<String, ProcessInstanceUserDto> userMap = userInfoService.getUserMapByIds(staterUsers); |
|
|
|
//result = resVos.stream().peek(v -> v.getProcessTaskInfo() |
|
|
|
// .setStartUser(userMap.get(Long.valueOf(v.getProcessTaskInfo().getOwnerId())))) |
|
|
|
// .setStartUser(userMap.get(v.getProcessTaskInfo().getOwnerId()))) |
|
|
|
// .collect(Collectors.toList()); |
|
|
|
} |
|
|
|
// return PageVo.of(result, total); |
|
|
@@ -1315,10 +1335,10 @@ public class TodoCenterManage { |
|
|
|
Long startUserId = 381496L; |
|
|
|
HistoricProcessInstanceQuery instanceQuery = historyService.createHistoricProcessInstanceQuery(); |
|
|
|
Executor.builder().ifNotBlankNext(String.valueOf(startUserId), instanceQuery::startedBy); |
|
|
|
List<HistoricProcessInstance> historicProcessInstances = |
|
|
|
instanceQuery.orderByProcessInstanceStartTime().desc().orderByProcessInstanceEndTime().desc().list(); |
|
|
|
Set<String> historicProcessInstanceIds = |
|
|
|
historicProcessInstances.stream().map(HistoricProcessInstance::getId).collect(Collectors.toSet()); |
|
|
|
List<HistoricProcessInstance> historicProcessInstances = instanceQuery.orderByProcessInstanceStartTime() |
|
|
|
.desc().orderByProcessInstanceEndTime().desc().list(); |
|
|
|
Set<String> historicProcessInstanceIds = historicProcessInstances.stream() |
|
|
|
.map(HistoricProcessInstance::getId).collect(Collectors.toSet()); |
|
|
|
|
|
|
|
List<Project> results = getMySubmittedProjects(param, historicProcessInstanceIds); |
|
|
|
|
|
|
@@ -1335,8 +1355,11 @@ public class TodoCenterManage { |
|
|
|
// 把已办任务流程实例一次性取出来,减少查询次数 |
|
|
|
Map<String, HistoricProcessInstance> instanceMap = isNotEmpty(historicProcessInstances) ? historyService |
|
|
|
.createHistoricProcessInstanceQuery() |
|
|
|
.processInstanceIds(historicProcessInstances.stream().map(HistoricProcessInstance::getId).collect(Collectors.toSet())) |
|
|
|
.list().stream().collect(Collectors.toMap(HistoricProcessInstance::getId, v -> v)) : new HashMap<>(); |
|
|
|
.processInstanceIds(historicProcessInstances.stream() |
|
|
|
.map(HistoricProcessInstance::getId) |
|
|
|
.collect(Collectors.toSet())) |
|
|
|
.list().stream() |
|
|
|
.collect(Collectors.toMap(HistoricProcessInstance::getId, v -> v)) : new HashMap<>(); |
|
|
|
|
|
|
|
Set<String> staterUsers = new HashSet<>(); |
|
|
|
|
|
|
@@ -1348,18 +1371,11 @@ public class TodoCenterManage { |
|
|
|
res.setProcessStatusName(ProcessStatusEnum.getDescByCode(d.getProcessStatus())); |
|
|
|
LocalDateTime processLaunchTime = d.getCreateOn(); |
|
|
|
String launchTimeFormat = NdDateUtils.format(processLaunchTime, "yyyy-MM-dd HH:mm"); |
|
|
|
LocalDateTime launchTime = |
|
|
|
LocalDateTime.parse(launchTimeFormat, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")); |
|
|
|
LocalDateTime launchTime = LocalDateTime.parse(launchTimeFormat, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")); |
|
|
|
res.setProcessLaunchTime(launchTime); |
|
|
|
HistoricProcessInstance ist = instanceMap.get(d.getInstCode()); |
|
|
|
staterUsers.add(ist.getStartUserId()); |
|
|
|
//HashSet<String> userSet = new HashSet<>(); |
|
|
|
//userSet.add(instance.getStartUserId()) ; |
|
|
|
//Map<Long, UserInfoVO> userMap = userInfoService.getUserMapByIds(userSet); |
|
|
|
//res.setOwner(userMap.get(Long.valueOf(ist.getStartUserId()))); |
|
|
|
UserInfoVO owner = new UserInfoVO(); |
|
|
|
owner.setUserId(Long.valueOf(ist.getStartUserId())); |
|
|
|
res.setOwner(owner); |
|
|
|
|
|
|
|
ProcessInstanceVo processInstanceVo = getProcessInstanceVos(ist); |
|
|
|
res.setProcessInstanceInfo(processInstanceVo); |
|
|
|
return res; |
|
|
@@ -1371,9 +1387,9 @@ public class TodoCenterManage { |
|
|
|
// 取用户信息,减少数据库查询,一次构建 |
|
|
|
List<ResToBeProcessedDTO> result = null; |
|
|
|
if (isNotEmpty(staterUsers)) { |
|
|
|
//Map<Long, UserInfoVO> userMap = userInfoService.getUserMapByIds(staterUsers); |
|
|
|
//Map<String, ProcessInstanceUserDto> userMap = userInfoService.getUserMapByIds(staterUsers); |
|
|
|
//result = resVos.stream() |
|
|
|
// .peek(v -> v.getProcessTaskInfo().setStartUser(userMap.get(Long.valueOf(v.getProcessTaskInfo().getOwnerId())))) |
|
|
|
// .peek(v -> v.getProcessInstanceInfo().setStartUser(userMap.get(v.getProcessTaskInfo().getOwnerId()))) |
|
|
|
// .collect(Collectors.toList()); |
|
|
|
} |
|
|
|
// return PageVo.of(result, total); |
|
|
@@ -1416,16 +1432,25 @@ public class TodoCenterManage { |
|
|
|
*/ |
|
|
|
private ProcessInstanceVo getProcessInstanceVos(HistoricProcessInstance ist) { |
|
|
|
Map<String, String> instanceNodeMap = new HashMap<>(); |
|
|
|
ProcessInstanceVo instanceVo = ProcessInstanceVo.builder().processDefId(ist.getProcessDefinitionId()) |
|
|
|
.instanceId(ist.getId()).nodeId(instanceNodeMap.get(ist.getId())).formId(ist.getProcessDefinitionKey()) |
|
|
|
.staterUserId(ist.getStartUserId()).startTime(ist.getStartTime()).finishTime(ist.getEndTime()) |
|
|
|
.processDefName(ist.getProcessDefinitionName()).result(ist.getEndActivityId()) |
|
|
|
.version(ist.getProcessDefinitionVersion()).build(); |
|
|
|
ProcessInstanceVo instanceVo = ProcessInstanceVo |
|
|
|
.builder() |
|
|
|
.processDefId(ist.getProcessDefinitionId()) |
|
|
|
.instanceId(ist.getId()) |
|
|
|
.nodeId(instanceNodeMap.get(ist.getId())) |
|
|
|
.formId(ist.getProcessDefinitionKey()) |
|
|
|
.staterUserId(ist.getStartUserId()) |
|
|
|
.startTime(ist.getStartTime()) |
|
|
|
.finishTime(ist.getEndTime()) |
|
|
|
.processDefName(ist.getProcessDefinitionName()) |
|
|
|
.result(ist.getEndActivityId()) |
|
|
|
.version(ist.getProcessDefinitionVersion()) |
|
|
|
.build(); |
|
|
|
|
|
|
|
if (Objects.isNull(ist.getEndActivityId())) { |
|
|
|
instanceVo.setStatus(ProcessStatusEnum.UNDER_REVIEW.name()); |
|
|
|
} else if (HisProInsEndActId.BACK.equals(ist.getEndActivityId())) { |
|
|
|
// TODO 被退回的审核节点状态这里只是暂时这么判断,具体怎么保存这个退回状态,后面讨论 |
|
|
|
// 被流程发起人退回的审核节点状态,此时项目回到上一个状态,当前流程结束 |
|
|
|
// (由前一个审核人撤回的流程,未结束,仍在审核中) |
|
|
|
instanceVo.setStatus(ProcessStatusEnum.BE_BACKED.name()); |
|
|
|
} else if (HisProInsEndActId.REJECT.equals(ist.getEndActivityId())) { |
|
|
|
instanceVo.setStatus(ProcessStatusEnum.BE_REJECTED.name()); |
|
|
@@ -1435,8 +1460,7 @@ public class TodoCenterManage { |
|
|
|
|
|
|
|
if (ObjectUtil.isNull(ist.getEndActivityId())) { |
|
|
|
// 没有结束,还在走流程,获取任务 |
|
|
|
List<Task> list = |
|
|
|
taskService.createTaskQuery().processInstanceId(ist.getId()).includeIdentityLinks().active().list(); |
|
|
|
List<Task> list = taskService.createTaskQuery().processInstanceId(ist.getId()).includeIdentityLinks().active().list(); |
|
|
|
instanceVo.setNodeId(Optional.ofNullable(instanceVo.getNodeId()).orElseGet(() -> { |
|
|
|
if (isNotEmpty(list)) { |
|
|
|
return list.get(0).getTaskDefinitionKey(); |
|
|
@@ -1453,7 +1477,6 @@ public class TodoCenterManage { |
|
|
|
instanceVo.setTaskName(ProcessStatusEnum.APPROVED.getDesc()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return instanceVo; |
|
|
|
} |
|
|
|
|
|
|
@@ -1571,18 +1594,11 @@ public class TodoCenterManage { |
|
|
|
res.setProcessStatusName(ProcessStatusEnum.getDescByCode(d.getProcessStatus())); |
|
|
|
LocalDateTime processLaunchTime = d.getCreateOn(); |
|
|
|
String launchTimeFormat = NdDateUtils.format(processLaunchTime, "yyyy-MM-dd HH:mm"); |
|
|
|
LocalDateTime launchTime = |
|
|
|
LocalDateTime.parse(launchTimeFormat, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")); |
|
|
|
LocalDateTime launchTime = LocalDateTime.parse(launchTimeFormat, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")); |
|
|
|
res.setProcessLaunchTime(launchTime); |
|
|
|
HistoricProcessInstance ist = instanceMap.get(d.getInstCode()); |
|
|
|
staterUsers.add(ist.getStartUserId()); |
|
|
|
//HashSet<String> userSet = new HashSet<>(); |
|
|
|
//userSet.add(instance.getStartUserId()) ; |
|
|
|
//Map<Long, UserInfoVO> userMap = userInfoService.getUserMapByIds(userSet); |
|
|
|
//res.setOwner(userMap.get(Long.valueOf(ist.getStartUserId()))); |
|
|
|
UserInfoVO owner = new UserInfoVO(); |
|
|
|
owner.setUserId(Long.valueOf(ist.getStartUserId())); |
|
|
|
res.setOwner(owner); |
|
|
|
|
|
|
|
ProcessInstanceVo processInstanceVo = getProcessInstanceVos(ist); |
|
|
|
res.setProcessInstanceInfo(processInstanceVo); |
|
|
|
return res; |
|
|
@@ -1593,9 +1609,9 @@ public class TodoCenterManage { |
|
|
|
// 取用户信息,减少数据库查询,一次构建 |
|
|
|
List<ResToBeProcessedDTO> result = null; |
|
|
|
if (isNotEmpty(staterUsers)) { |
|
|
|
//Map<Long, UserInfoVO> userMap = userInfoService.getUserMapByIds(staterUsers); |
|
|
|
//Map<String, ProcessInstanceUserDto> userMap = userInfoService.getUserMapByIds(staterUsers); |
|
|
|
//result = resVos.stream() |
|
|
|
// .peek(v -> v.getProcessTaskInfo().setStartUser(userMap.get(Long.valueOf(v.getProcessTaskInfo().getOwnerId())))) |
|
|
|
// .peek(v -> v.getProcessInstanceInfo().setStartUser(userMap.get(v.getProcessTaskInfo().getOwnerId()))) |
|
|
|
// .collect(Collectors.toList()); |
|
|
|
} |
|
|
|
// return PageVo.of(result, total); |
|
|
|