From 01dabd0e6d0d53dd1e40e2e2c6fe259b9ed963cd Mon Sep 17 00:00:00 2001 From: CMM <2198256324@qq.com> Date: Thu, 16 Feb 2023 16:59:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=81=E7=A8=8B=E5=A4=84=E7=90=86=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E5=A2=9E=E5=8A=A0=E9=A1=B9=E7=9B=AEID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/todocenter/manage/TodoCenterManage.java | 144 ++++++++++----------- .../model/dto/req/ReqProcessHandlerDTO.java | 12 ++ .../model/dto/res/ResToBeProcessedDTO.java | 3 - 3 files changed, 82 insertions(+), 77 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java index 0302604..86a9eae 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java @@ -177,16 +177,8 @@ public class TodoCenterManage { Task task = taskMap.get(d.getInstCode()); HistoricProcessInstance instance = instanceMap.get(task.getProcessInstanceId()); - //HashSet userSet = new HashSet<>(); - //userSet.add(instance.getStartUserId()) ; - //Map 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 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 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 userSet = new HashSet<>(); - //userSet.add(instance.getStartUserId()) ; - //Map 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 historicProcessInstances = - instanceQuery.orderByProcessInstanceStartTime().desc().orderByProcessInstanceEndTime().desc().list(); - Set historicProcessInstanceIds = - historicProcessInstances.stream().map(HistoricProcessInstance::getId).collect(Collectors.toSet()); + List historicProcessInstances = instanceQuery.orderByProcessInstanceStartTime() + .desc().orderByProcessInstanceEndTime().desc().list(); + Set historicProcessInstanceIds = historicProcessInstances.stream() + .map(HistoricProcessInstance::getId).collect(Collectors.toSet()); List results = getMySubmittedProjects(param, historicProcessInstanceIds); @@ -1355,8 +1355,11 @@ public class TodoCenterManage { // 把已办任务流程实例一次性取出来,减少查询次数 Map 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 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 userSet = new HashSet<>(); - //userSet.add(ist.getStartUserId()) ; - //Map 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 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 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 list = - taskService.createTaskQuery().processInstanceId(ist.getId()).includeIdentityLinks().active().list(); + List 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 userSet = new HashSet<>(); - //userSet.add(ist.getStartUserId()) ; - //Map 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 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); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/req/ReqProcessHandlerDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/req/ReqProcessHandlerDTO.java index c6c307c..eba90b5 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/req/ReqProcessHandlerDTO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/req/ReqProcessHandlerDTO.java @@ -2,10 +2,13 @@ package com.ningdatech.pmapi.todocenter.model.dto.req; import com.ningdatech.pmapi.todocenter.bean.entity.ProcessComment; import com.wflow.workflow.enums.ProcessHandlerEnum; +import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import javax.validation.constraints.NotNull; + /** * 流程处理操作参数实体 * @@ -18,12 +21,20 @@ import lombok.NoArgsConstructor; public class ReqProcessHandlerDTO { /** + * 要处理的项目ID + */ + @NotNull(message = "要处理的项目ID不能为空!") + private Long projectId; + + /** * 实例ID */ + @NotNull(message = "流程实例ID不能为空!") private String instanceId; /** * 任务ID */ + @NotNull(message = "任务ID不能为空!") private String taskId; /** * 签名图片地址 @@ -32,6 +43,7 @@ public class ReqProcessHandlerDTO { /** * 操作类型 */ + @NotNull(message = "操作类型不能为空!") private ProcessHandlerEnum action; /** * 目标用户 diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/res/ResToBeProcessedDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/res/ResToBeProcessedDTO.java index 9fa4f1b..d62b39a 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/res/ResToBeProcessedDTO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/res/ResToBeProcessedDTO.java @@ -67,7 +67,4 @@ public class ResToBeProcessedDTO implements Serializable { @ApiModelProperty("流程实例信息") private ProcessInstanceVo processInstanceInfo; - - @ApiModelProperty("流程发起人信息") - private ProcessInstanceUserDto owner; }