diff --git a/laws-modules/src/main/java/com/jero/modules/activiti/process/common/entity/CommonVO.java b/laws-modules/src/main/java/com/jero/modules/activiti/process/common/entity/CommonVO.java index 6bfeb008..d02bdd58 100644 --- a/laws-modules/src/main/java/com/jero/modules/activiti/process/common/entity/CommonVO.java +++ b/laws-modules/src/main/java/com/jero/modules/activiti/process/common/entity/CommonVO.java @@ -16,6 +16,18 @@ import java.util.Date; @ApiModel(value="流程通用信息对象", description="流程通用信息对象") public class CommonVO { + /** + * 流程定义ID + */ + @ApiModelProperty("流程定义ID") + private String processDefinitionId; + + /** + * 流程实例ID + */ + @ApiModelProperty("流程实例ID") + private String processInstanceId; + /** * 任务ID */ @@ -71,4 +83,6 @@ public class CommonVO { */ @ApiModelProperty("制修订计划说明") private String processDescription; + + } diff --git a/laws-modules/src/main/java/com/jero/modules/activiti/process/esInitChange/entity/vo/InitChangeDataVO.java b/laws-modules/src/main/java/com/jero/modules/activiti/process/esInitChange/entity/vo/InitChangeDataVO.java index 2b02f945..67c9d461 100644 --- a/laws-modules/src/main/java/com/jero/modules/activiti/process/esInitChange/entity/vo/InitChangeDataVO.java +++ b/laws-modules/src/main/java/com/jero/modules/activiti/process/esInitChange/entity/vo/InitChangeDataVO.java @@ -6,6 +6,7 @@ import com.jero.modules.activiti.process.esInitChange.entity.ProcessEsInitChange import lombok.Data; import java.util.List; +import java.util.Map; /** * @author: Mzaxd @@ -21,5 +22,5 @@ public class InitChangeDataVO { List dataList; @JsonProperty("flowUser") - InitChangeFlowUserVO flowUserInfoVO; + Map flowUserInfoVO; } diff --git a/laws-modules/src/main/java/com/jero/modules/activiti/process/esInitChange/service/impl/ProcessEsInitChangeServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/activiti/process/esInitChange/service/impl/ProcessEsInitChangeServiceImpl.java index 7302fad1..2932ddd4 100644 --- a/laws-modules/src/main/java/com/jero/modules/activiti/process/esInitChange/service/impl/ProcessEsInitChangeServiceImpl.java +++ b/laws-modules/src/main/java/com/jero/modules/activiti/process/esInitChange/service/impl/ProcessEsInitChangeServiceImpl.java @@ -7,7 +7,6 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.jero.common.constant.enums.YesOrNoEnum; import com.jero.common.exception.JeroBootException; 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.entity.ProcessDraft; @@ -15,7 +14,6 @@ import com.jero.modules.activiti.process.common.enums.ProcessType; import com.jero.modules.activiti.process.common.service.ActFlowCommonService; import com.jero.modules.activiti.process.common.service.ProcessDraftService; import com.jero.modules.activiti.process.esInitChange.entity.ProcessEsInitChange; -import com.jero.modules.activiti.process.esInitChange.entity.vo.InitChangeFlowUserVO; import com.jero.modules.activiti.process.esInitChange.entity.vo.InitChangeDataVO; import com.jero.modules.activiti.process.esInitChange.service.ProcessEsInitChangeService; import com.jero.modules.activiti.process.esInitChange.mapper.ProcessEsInitChangeMapper; @@ -106,27 +104,23 @@ public class ProcessEsInitChangeServiceImpl extends ServiceImpl setVariables(InitChangeDataVO initChangeData) { - InitChangeFlowUserVO initChangeFlowUserVO = initChangeData.getFlowUserInfoVO(); + Map flowUserInfoVO = initChangeData.getFlowUserInfoVO(); + HashMap map = new HashMap<>(flowUserInfoVO); ProcessEsInitChange initChange = initChangeData.getDataList().get(0); - HashMap map = new HashMap<>(this.setUserVariables(initChangeFlowUserVO)); + // 添加非列表类型的变量 actFlowCommonService.putIfNotNull(map, "applicationCategory", initChange.getApplicationCategory()); actFlowCommonService.putIfNotNull(map, "projectType", initChange.getProjectType()); + // 添加列表类型的变量 + convertAndPutList(map, flowUserInfoVO, "standardExpertList"); + convertAndPutList(map, flowUserInfoVO, "relatedUserList"); return map; } - public Map setUserVariables(InitChangeFlowUserVO initChangeFlowUserVO) { - HashMap map = new HashMap<>(); - // 使用一个通用方法来只在不为空时添加键值对 - actFlowCommonService.putIfNotNull(map, "createUser", initChangeFlowUserVO.getCreateUser()); - actFlowCommonService.putIfNotNull(map, "contactUser", initChangeFlowUserVO.getContactUser()); - actFlowCommonService.putIfNotNull(map, "standardExpertList", Optional.ofNullable(initChangeFlowUserVO.getStandardExpert()).map(s -> Arrays.asList(s.split(","))).orElse(null)); - actFlowCommonService.putIfNotNull(map, "mainDraftUserLeader", initChangeFlowUserVO.getMainDraftUserLeader()); - actFlowCommonService.putIfNotNull(map, "mainDraftUserLeaderLeader", initChangeFlowUserVO.getMainDraftUserLeaderLeader()); - actFlowCommonService.putIfNotNull(map, "standardizationApprovalUser", initChangeFlowUserVO.getStandardizationApprovalUser()); - actFlowCommonService.putIfNotNull(map, "newMainDraftUserLeaderLeader", initChangeFlowUserVO.getNewMainDraftUserLeaderLeader()); - actFlowCommonService.putIfNotNull(map, "newMainDraftUserLeader", initChangeFlowUserVO.getNewMainDraftUserLeader()); - actFlowCommonService.putIfNotNull(map, "relatedUserList", Optional.ofNullable(initChangeFlowUserVO.getRelatedUser()).map(s -> Arrays.asList(s.split(","))).orElse(null)); - return map; + private void convertAndPutList(HashMap map, Map flowUserInfoVO, String key) { + Optional.ofNullable(flowUserInfoVO.get(key)) + .map(Object::toString) + .map(s -> Arrays.asList(s.split(","))) + .ifPresent(list -> map.put(key, list)); } private Map getUserMap(Map variables) { @@ -159,6 +153,8 @@ public class ProcessEsInitChangeServiceImpl extends ServiceImpl lambdaQueryWrapper = new LambdaQueryWrapper<>(); @@ -166,38 +162,36 @@ public class ProcessEsInitChangeServiceImpl extends ServiceImpl dataList = list(lambdaQueryWrapper); initChangeDataVO.setDataList(dataList); - // 选人组件内容填充 - initChangeDataVO.setFlowUserInfoVO(this.getProcessUserInfo(processDefinitionId, processInstanceId)); return initChangeDataVO; } - private InitChangeFlowUserVO getProcessUserInfo(String processDefinitionId, String processInstanceId) { - List nodeList = processNodeService.getNodeList(processDefinitionId, processInstanceId); - InitChangeFlowUserVO initChangeFlowUserVO = new InitChangeFlowUserVO(); - 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("createUser")).ifPresent(node -> initChangeFlowUserVO.setCreateUser(node.getLinkUserIds())); - Optional.ofNullable(userMap.get("contactUser")).ifPresent(node -> initChangeFlowUserVO.setContactUser(node.getLinkUserIds())); - Optional.ofNullable(userMap.get("standardExpertList")).ifPresent(node -> initChangeFlowUserVO.setStandardExpert(node.getLinkUserIds())); - Optional.ofNullable(userMap.get("mainDraftUserLeader")).ifPresent(node -> initChangeFlowUserVO.setMainDraftUserLeader(node.getLinkUserIds())); - Optional.ofNullable(userMap.get("mainDraftUserLeaderLeader")).ifPresent(node -> initChangeFlowUserVO.setMainDraftUserLeaderLeader(node.getLinkUserIds())); - Optional.ofNullable(userMap.get("standardizationApprovalUser")).ifPresent(node -> initChangeFlowUserVO.setStandardizationApprovalUser(node.getLinkUserIds())); - Optional.ofNullable(userMap.get("newMainDraftUserLeaderLeader")).ifPresent(node -> initChangeFlowUserVO.setNewMainDraftUserLeaderLeader(node.getLinkUserIds())); - Optional.ofNullable(userMap.get("newMainDraftUserLeader")).ifPresent(node -> initChangeFlowUserVO.setNewMainDraftUserLeader(node.getLinkUserIds())); - Optional.ofNullable(userMap.get("relatedUserList")).ifPresent(node -> initChangeFlowUserVO.setRelatedUser(node.getLinkUserIds())); - return initChangeFlowUserVO; - } +// private InitChangeFlowUserVO getProcessUserInfo(String processDefinitionId, String processInstanceId) { +// List nodeList = processNodeService.getNodeList(processDefinitionId, processInstanceId); +// InitChangeFlowUserVO initChangeFlowUserVO = new InitChangeFlowUserVO(); +// 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("createUser")).ifPresent(node -> initChangeFlowUserVO.setCreateUser(node.getLinkUserIds())); +// Optional.ofNullable(userMap.get("contactUser")).ifPresent(node -> initChangeFlowUserVO.setContactUser(node.getLinkUserIds())); +// Optional.ofNullable(userMap.get("standardExpertList")).ifPresent(node -> initChangeFlowUserVO.setStandardExpert(node.getLinkUserIds())); +// Optional.ofNullable(userMap.get("mainDraftUserLeader")).ifPresent(node -> initChangeFlowUserVO.setMainDraftUserLeader(node.getLinkUserIds())); +// Optional.ofNullable(userMap.get("mainDraftUserLeaderLeader")).ifPresent(node -> initChangeFlowUserVO.setMainDraftUserLeaderLeader(node.getLinkUserIds())); +// Optional.ofNullable(userMap.get("standardizationApprovalUser")).ifPresent(node -> initChangeFlowUserVO.setStandardizationApprovalUser(node.getLinkUserIds())); +// Optional.ofNullable(userMap.get("newMainDraftUserLeaderLeader")).ifPresent(node -> initChangeFlowUserVO.setNewMainDraftUserLeaderLeader(node.getLinkUserIds())); +// Optional.ofNullable(userMap.get("newMainDraftUserLeader")).ifPresent(node -> initChangeFlowUserVO.setNewMainDraftUserLeader(node.getLinkUserIds())); +// Optional.ofNullable(userMap.get("relatedUserList")).ifPresent(node -> initChangeFlowUserVO.setRelatedUser(node.getLinkUserIds())); +// return initChangeFlowUserVO; +// } @Override public void approvalInitChange(InitChangeDataVO initChangeDataVO, boolean pass) { String userId = UserUtils.getUserId(); CommonVO commonVO = initChangeDataVO.getCommonVO(); List initChangeList = initChangeDataVO.getDataList(); - InitChangeFlowUserVO flowUserInfoVO = initChangeDataVO.getFlowUserInfoVO(); + Map flowUserInfoVO = initChangeDataVO.getFlowUserInfoVO(); String taskId = commonVO.getTaskId(); if (StrUtil.isBlank(taskId) && !actFlowCommonService.taskExists(taskId)) { throw new JeroBootException("taskId为空或任务不存在"); @@ -205,16 +199,13 @@ public class ProcessEsInitChangeServiceImpl extends ServiceImpl variables = this.setVariables(initChangeDataVO); - actFlowCommonService.setProcessVariables(processInstanceId, variables); - processNodeLinkService.saveNodeUserLink(processDefinitionId, processInstanceId, this.getUserMap(variables)); } - if (flowUserInfoVO != null) { - Map variables = this.setUserVariables(flowUserInfoVO); + if (flowUserInfoVO != null && !flowUserInfoVO.isEmpty()) { + Map variables = setVariables(initChangeDataVO); actFlowCommonService.setProcessVariables(processInstanceId, variables); - processNodeLinkService.saveNodeUserLink(processDefinitionId, processInstanceId, this.getUserMap(variables)); + processNodeLinkService.saveNodeUserLink(processDefinitionId, processInstanceId, getUserMap(variables)); } runtimeService.setVariableLocal(processInstanceId, "pass", true); } else { @@ -268,7 +259,7 @@ public class ProcessEsInitChangeServiceImpl extends ServiceImpl esInitChangeList = initChangeData.getDataList(); // 校验企标编号是否冲突 - if (!esUtil.verifyEnStandardNumber(esInitChangeList.get(0).getOriginEnStandardNo())) { + if (!esUtil.verifyEnStandardNumber(esInitChangeList.get(0).getNewEnStandardNo())) { throw new JeroBootException("企标编号冲突,请重新生成"); } }