|
|
@@ -177,16 +177,8 @@ 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<String, ProcessInstanceUserDto> userMap = userInfoService.getUserMapByIds(userSet); |
|
|
|
//res.setOwner(userMap.get((instance.getStartUserId()))); |
|
|
|
|
|
|
|
ProcessInstanceUserDto owner = new ProcessInstanceUserDto(); |
|
|
|
owner.setUserId(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()) |
|
|
@@ -319,9 +311,7 @@ public class TodoCenterManage { |
|
|
|
* @since 2023/02/01 |
|
|
|
*/ |
|
|
|
public void handler(ReqProcessHandlerDTO param) { |
|
|
|
|
|
|
|
// 获取登录用户ID |
|
|
|
|
|
|
|
// Long userId = LoginUserUtil.getUserId(); |
|
|
|
|
|
|
|
// Long userId = 381496L; |
|
|
@@ -330,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(); |
|
|
@@ -374,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); |
|
|
@@ -488,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); |
|
|
@@ -722,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(); |
|
|
@@ -736,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对象 |
|
|
@@ -870,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())) { |
|
|
@@ -1178,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<String, ProcessInstanceUserDto> userMap = userInfoService.getUserMapByIds(userSet); |
|
|
|
//res.setOwner(userMap.get(instance.getStartUserId())); |
|
|
|
ProcessInstanceUserDto owner = new ProcessInstanceUserDto(); |
|
|
|
owner.setUserId(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()); |
|
|
@@ -1335,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); |
|
|
|
|
|
|
@@ -1355,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<>(); |
|
|
|
|
|
|
@@ -1368,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(ist.getStartUserId()) ; |
|
|
|
//Map<String, ProcessInstanceUserDto> userMap = userInfoService.getUserMapByIds(userSet); |
|
|
|
//res.setOwner(userMap.get(ist.getStartUserId())); |
|
|
|
ProcessInstanceUserDto owner = new ProcessInstanceUserDto(); |
|
|
|
owner.setUserId(ist.getStartUserId()); |
|
|
|
res.setOwner(owner); |
|
|
|
|
|
|
|
ProcessInstanceVo processInstanceVo = getProcessInstanceVos(ist); |
|
|
|
res.setProcessInstanceInfo(processInstanceVo); |
|
|
|
return res; |
|
|
@@ -1393,7 +1389,7 @@ public class TodoCenterManage { |
|
|
|
if (isNotEmpty(staterUsers)) { |
|
|
|
//Map<String, ProcessInstanceUserDto> userMap = userInfoService.getUserMapByIds(staterUsers); |
|
|
|
//result = resVos.stream() |
|
|
|
// .peek(v -> v.getProcessTaskInfo().setStartUser(userMap.get(v.getProcessTaskInfo().getOwnerId()))) |
|
|
|
// .peek(v -> v.getProcessInstanceInfo().setStartUser(userMap.get(v.getProcessTaskInfo().getOwnerId()))) |
|
|
|
// .collect(Collectors.toList()); |
|
|
|
} |
|
|
|
// return PageVo.of(result, total); |
|
|
@@ -1436,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()); |
|
|
@@ -1455,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(); |
|
|
@@ -1473,7 +1477,6 @@ public class TodoCenterManage { |
|
|
|
instanceVo.setTaskName(ProcessStatusEnum.APPROVED.getDesc()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return instanceVo; |
|
|
|
} |
|
|
|
|
|
|
@@ -1591,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(ist.getStartUserId()) ; |
|
|
|
//Map<String, ProcessInstanceUserDto> userMap = userInfoService.getUserMapByIds(userSet); |
|
|
|
//res.setOwner(userMap.get(ist.getStartUserId())); |
|
|
|
ProcessInstanceUserDto owner = new ProcessInstanceUserDto(); |
|
|
|
owner.setUserId(ist.getStartUserId()); |
|
|
|
res.setOwner(owner); |
|
|
|
|
|
|
|
ProcessInstanceVo processInstanceVo = getProcessInstanceVos(ist); |
|
|
|
res.setProcessInstanceInfo(processInstanceVo); |
|
|
|
return res; |
|
|
@@ -1615,7 +1611,7 @@ public class TodoCenterManage { |
|
|
|
if (isNotEmpty(staterUsers)) { |
|
|
|
//Map<String, ProcessInstanceUserDto> userMap = userInfoService.getUserMapByIds(staterUsers); |
|
|
|
//result = resVos.stream() |
|
|
|
// .peek(v -> v.getProcessTaskInfo().setStartUser(userMap.get(v.getProcessTaskInfo().getOwnerId()))) |
|
|
|
// .peek(v -> v.getProcessInstanceInfo().setStartUser(userMap.get(v.getProcessTaskInfo().getOwnerId()))) |
|
|
|
// .collect(Collectors.toList()); |
|
|
|
} |
|
|
|
// return PageVo.of(result, total); |
|
|
|