From 2e06bedf95a9d885c79f43168ef430a13e5d94c7 Mon Sep 17 00:00:00 2001 From: caihaohan Date: Sun, 12 Nov 2023 20:30:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=B9=B4=E5=BA=A6=E5=88=B6=E4=BF=AE?= =?UTF-8?q?=E8=AE=A2=E5=90=84=E9=83=A8=E9=97=A8=E4=B8=BB=E5=8A=A8=E4=B8=8A?= =?UTF-8?q?=E6=8A=A5=E6=B5=81=E7=A8=8B=E6=9B=B4=E6=8D=A2=E9=80=9A=E7=94=A8?= =?UTF-8?q?=E4=BA=BA=E5=91=98=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/vo/AnnualReportDataVO.java | 3 +- .../entity/vo/AnnualReportFlowUserVO.java | 40 ------- .../ProcessEsAnnualReportServiceImpl.java | 105 +++++++----------- 3 files changed, 40 insertions(+), 108 deletions(-) delete mode 100644 laws-modules/src/main/java/com/jero/modules/activiti/process/esAnnualReport/entity/vo/AnnualReportFlowUserVO.java diff --git a/laws-modules/src/main/java/com/jero/modules/activiti/process/esAnnualReport/entity/vo/AnnualReportDataVO.java b/laws-modules/src/main/java/com/jero/modules/activiti/process/esAnnualReport/entity/vo/AnnualReportDataVO.java index 7ca2c6f7..a15ab3fd 100644 --- a/laws-modules/src/main/java/com/jero/modules/activiti/process/esAnnualReport/entity/vo/AnnualReportDataVO.java +++ b/laws-modules/src/main/java/com/jero/modules/activiti/process/esAnnualReport/entity/vo/AnnualReportDataVO.java @@ -6,6 +6,7 @@ import com.jero.modules.activiti.process.esAnnualReport.entity.ProcessEsAnnualRe import lombok.Data; import java.util.List; +import java.util.Map; /** * @author: Mzaxd @@ -21,6 +22,6 @@ public class AnnualReportDataVO { private List dataList; @JsonProperty("flowUser") - private AnnualReportFlowUserVO flowUserVO; + private Map flowUser; } diff --git a/laws-modules/src/main/java/com/jero/modules/activiti/process/esAnnualReport/entity/vo/AnnualReportFlowUserVO.java b/laws-modules/src/main/java/com/jero/modules/activiti/process/esAnnualReport/entity/vo/AnnualReportFlowUserVO.java deleted file mode 100644 index fc0d3c09..00000000 --- a/laws-modules/src/main/java/com/jero/modules/activiti/process/esAnnualReport/entity/vo/AnnualReportFlowUserVO.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.jero.modules.activiti.process.esAnnualReport.entity.vo; - -import com.jero.common.aspect.annotation.Dict; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -/** - * @author: Mzaxd - * @Date: 2023/10/26 17:29 - */ -@Data -public class AnnualReportFlowUserVO { - - @Dict(dictTable = "sys_user", dicCode = "id", dicText = "realname") - @ApiModelProperty("标准化工程师") - private String standardEngineer; - - // 部所联络人 - @Dict(dictTable = "sys_user", dicCode = "id", dicText = "realname") - @ApiModelProperty("个部所联络人") - private String contactUserList; - - // 标准专家 - @Dict(dictTable = "sys_user", dicCode = "id", dicText = "realname") - @ApiModelProperty("工作组联络人") - private String workGroupUserList; - - // 主起草人主管级领导 - @Dict(dictTable = "sys_user", dicCode = "id", dicText = "realname") - @ApiModelProperty("收集联络人主管级领导") - private String collectUserLeader; - - // 主起草人主管级领导上级领导 - @Dict(dictTable = "sys_user", dicCode = "id", dicText = "realname") - @ApiModelProperty("联络人主管级上级领导") - private String contactUserLeaderLeader; - - @ApiModelProperty("是否下发") - private boolean distribute; -} diff --git a/laws-modules/src/main/java/com/jero/modules/activiti/process/esAnnualReport/service/impl/ProcessEsAnnualReportServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/activiti/process/esAnnualReport/service/impl/ProcessEsAnnualReportServiceImpl.java index 8ced4e3a..e2711299 100644 --- a/laws-modules/src/main/java/com/jero/modules/activiti/process/esAnnualReport/service/impl/ProcessEsAnnualReportServiceImpl.java +++ b/laws-modules/src/main/java/com/jero/modules/activiti/process/esAnnualReport/service/impl/ProcessEsAnnualReportServiceImpl.java @@ -8,14 +8,12 @@ import com.jero.common.constant.enums.YesOrNoEnum; import com.jero.common.exception.JeroBootException; import com.jero.common.system.vo.SysDictItemCore; import com.jero.modules.activiti.entity.ProcessAll; -import com.jero.modules.activiti.entity.ProcessNode; import com.jero.modules.activiti.enums.ProcessTypeEnum; import com.jero.modules.activiti.process.common.entity.CommonVO; import com.jero.modules.activiti.process.common.enums.ProcessType; import com.jero.modules.activiti.process.common.service.ActFlowCommonService; import com.jero.modules.activiti.process.esAnnualReport.entity.ProcessEsAnnualReport; import com.jero.modules.activiti.process.esAnnualReport.entity.vo.AnnualReportDataVO; -import com.jero.modules.activiti.process.esAnnualReport.entity.vo.AnnualReportFlowUserVO; import com.jero.modules.activiti.process.esAnnualReport.mapper.ProcessEsAnnualReportMapper; import com.jero.modules.activiti.process.esAnnualReport.service.ProcessEsAnnualReportService; import com.jero.modules.activiti.process.esInitChange.entity.enums.ESPProjectType; @@ -69,9 +67,6 @@ public class ProcessEsAnnualReportServiceImpl extends ServiceImpl variables = annualReportData.getFlowUser(); // 设置流程变量 - Map variables = this.setVariables(annualReportData); + Map actVariables = this.setVariables(annualReportData); // 启动流程 - ProcessInstance processInstance = actFlowCommonService.startProcess(processDefinitionKey, variables); + ProcessInstance processInstance = actFlowCommonService.startProcess(processDefinitionKey, actVariables); // 获取流程实例ID String processDefinitionId = processInstance.getProcessDefinitionId(); String processInstanceId = processInstance.getId(); // 手动设置所有流程变量 - actFlowCommonService.setProcessVariables(processInstanceId, variables); + actFlowCommonService.setProcessVariables(processInstanceId, actVariables); // 自动完成第一个任务 actFlowCommonService.autoCompleteFirstTask(userId, processInstanceId, processDefinitionId, commonVO); // 保存选人信息 @@ -113,32 +110,32 @@ public class ProcessEsAnnualReportServiceImpl extends ServiceImpl setVariables(AnnualReportDataVO annualReportData) { - AnnualReportFlowUserVO annualReportFlowUserVO = annualReportData.getFlowUserVO(); + Map actVariables = new HashMap<>(); CommonVO commonVO = annualReportData.getCommonVO(); - // 设置流程中各个节点的人 - Map map = new HashMap<>(this.setUserVariables(annualReportFlowUserVO)); - // 设置流程分支判断变量 - map.put("processDescription", commonVO.getProcessDescription()); - return map; - } - - public Map setUserVariables(AnnualReportFlowUserVO userVO) { - HashMap map = new HashMap<>(); - // 使用一个通用方法来只在不为空时添加键值对 - actFlowCommonService.putIfNotNull(map, "standardEngineer", userVO.getStandardEngineer()); - actFlowCommonService.putIfNotNull(map, "contactUserList", Optional.ofNullable(userVO.getContactUserList()).map(s -> Arrays.asList(s.split(","))).orElse(null)); - return map; + Map flowUser = annualReportData.getFlowUser(); + actFlowCommonService.putIfNotNull(actVariables, "contactUserList", Optional.ofNullable((String)flowUser.get("contactUserList")).map(s -> Arrays.asList(s.split(","))).orElse(null)); + if (flowUser.get("workGroupUserList") == null || StrUtil.isBlank((String)flowUser.get("workGroupUserList"))) { + actFlowCommonService.putIfNotNull(actVariables, "distribute", false); + } else { + actFlowCommonService.putIfNotNull(actVariables, "distribute", true); + String relatedUsers = (String) flowUser.get("relatedUserList"); + // 将relatedUserList从逗号拼接转为List + List relatedUserList = StrUtil.split(relatedUsers, ','); + actFlowCommonService.putIfNotNull(actVariables, "relatedUserList", relatedUserList); + } + for (Map.Entry entry : flowUser.entrySet()) { + String key = entry.getKey(); + if (!key.equals("contactUserList") && !key.equals("workGroupUserList")) { + actVariables.put(key, entry.getValue()); + } + } + actVariables.put("processDescription", commonVO.getProcessDescription()); + return actVariables; } private Map getUserMap(Map variables) { + variables.remove("pass"); variables.remove("processDescription"); - // 转成逗号拼接 - variables.put("contactUserList", Optional.ofNullable((List) variables.get("contactUserList")) - .map(list -> String.join(",", list)) - .orElse("")); - variables.put("workGroupUserList", Optional.ofNullable((List) variables.get("workGroupUserList")) - .map(list -> String.join(",", list)) - .orElse("")); return variables; } @@ -150,7 +147,7 @@ public class ProcessEsAnnualReportServiceImpl extends ServiceImpl flowUserVO = annualReportDataVO.getFlowUser(); List dataList = annualReportDataVO.getDataList(); String taskId = commonVO.getTaskId(); // 获取task @@ -163,18 +160,22 @@ public class ProcessEsAnnualReportServiceImpl extends ServiceImpl workGroupUserList = StrUtil.split(workGroupUsers, ','); // 设置流程变量 - taskService.setVariableLocal(taskId, "workGroupUserList", flowUserVO.getWorkGroupUserList()); + taskService.setVariableLocal(taskId, "workGroupUserList", workGroupUserList); }else { + String contactUserLeaderLeader = (String)flowUserVO.get("contactUserLeaderLeader"); // 保存联络人主管级上级领导 - dataList.forEach(data -> data.setContactUserLeaderLeader(flowUserVO.getContactUserLeaderLeader())); + dataList.forEach(data -> data.setContactUserLeaderLeader(contactUserLeaderLeader)); // 不分发,入库存表 saveBatch(dataList); - taskService.setVariableLocal(taskId, "contactUserLeaderLeader", flowUserVO.getContactUserLeaderLeader()); + taskService.setVariableLocal(taskId, "contactUserLeaderLeader", contactUserLeaderLeader); } break; case WORK_GROUP_COLLECT: @@ -182,11 +183,11 @@ public class ProcessEsAnnualReportServiceImpl extends ServiceImpl data.setContactUser(contactUser)); // 保存收集联络人主管级领导 - dataList.forEach(data -> data.setCollectUserLeader(flowUserVO.getCollectUserLeader())); + dataList.forEach(data -> data.setCollectUserLeader((String)flowUserVO.get("collectUserLeader"))); dataList.forEach(data -> data.setWorkGroupUser(UserUtils.getUserId())); saveBatch(dataList); // 设置下一个节点的审批人流程变量 - taskService.setVariableLocal(taskId, "collectUserLeader", flowUserVO.getCollectUserLeader()); + taskService.setVariableLocal(taskId, "collectUserLeader", flowUserVO.get("collectUserLeader")); break; case CONTACT_USER_COLLECT: // 先删后增 @@ -196,18 +197,7 @@ public class ProcessEsAnnualReportServiceImpl extends ServiceImpl userMap = new HashMap<>(this.setUserVariables(flowUserVO)); - processNodeLinkService.saveNodeUserLink(processDefinitionId, processInstanceId, userMap); - Map variables = setUserVariables(flowUserVO); - actFlowCommonService.setProcessVariables(processInstanceId, variables); - } - runtimeService.setVariable(processInstanceId, "pass", true); - } else { - // 设置流程变量 - runtimeService.setVariable(processInstanceId, "pass", false); - } + runtimeService.setVariable(processInstanceId, "pass", pass); // 更新审批表为完成,填充数据 actFlowCommonService.updateApprovalInfo(commonVO, taskId, pass); // 审批节点 @@ -276,28 +266,9 @@ public class ProcessEsAnnualReportServiceImpl extends ServiceImpl nodeList = processNodeService.getNodeList(processDefinitionId, processInstanceId); - AnnualReportFlowUserVO annualReportFlowUserVO = new AnnualReportFlowUserVO(); - Map userMap = nodeList.stream() - .collect(Collectors.groupingBy(ProcessNode::getVariableName)) - .values() - .stream() - .map(nodes -> nodes.get(0)) // 选择每组的第一个元素 - .collect(Collectors.toMap(ProcessNode::getVariableName, node -> node)); - Optional.ofNullable(userMap.get("standardEngineer")).ifPresent(node -> annualReportFlowUserVO.setStandardEngineer(node.getLinkUserIds())); - Optional.ofNullable(userMap.get("contactUserList")).ifPresent(node -> annualReportFlowUserVO.setContactUserList(node.getLinkUserIds())); - Optional.ofNullable(userMap.get("workGroupUserList")).ifPresent(node -> annualReportFlowUserVO.setWorkGroupUserList(node.getLinkUserIds())); - Optional.ofNullable(userMap.get("collectUserLeader")).ifPresent(node -> annualReportFlowUserVO.setCollectUserLeader(node.getLinkUserIds())); - Optional.ofNullable(userMap.get("contactUserLeaderLeader")).ifPresent(node -> annualReportFlowUserVO.setContactUserLeaderLeader(node.getLinkUserIds())); - return annualReportFlowUserVO; - } - @Override public Map importData(MultipartFile file) { List listDict = commonAPI.getDictItemAll();