feat: 立项变更流程切换到通用人员接口
This commit is contained in:
+14
@@ -16,6 +16,18 @@ import java.util.Date;
|
|||||||
@ApiModel(value="流程通用信息对象", description="流程通用信息对象")
|
@ApiModel(value="流程通用信息对象", description="流程通用信息对象")
|
||||||
public class CommonVO {
|
public class CommonVO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流程定义ID
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("流程定义ID")
|
||||||
|
private String processDefinitionId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流程实例ID
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("流程实例ID")
|
||||||
|
private String processInstanceId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 任务ID
|
* 任务ID
|
||||||
*/
|
*/
|
||||||
@@ -71,4 +83,6 @@ public class CommonVO {
|
|||||||
*/
|
*/
|
||||||
@ApiModelProperty("制修订计划说明")
|
@ApiModelProperty("制修订计划说明")
|
||||||
private String processDescription;
|
private String processDescription;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -6,6 +6,7 @@ import com.jero.modules.activiti.process.esInitChange.entity.ProcessEsInitChange
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author: Mzaxd
|
* @author: Mzaxd
|
||||||
@@ -21,5 +22,5 @@ public class InitChangeDataVO {
|
|||||||
List<ProcessEsInitChange> dataList;
|
List<ProcessEsInitChange> dataList;
|
||||||
|
|
||||||
@JsonProperty("flowUser")
|
@JsonProperty("flowUser")
|
||||||
InitChangeFlowUserVO flowUserInfoVO;
|
Map<String, Object> flowUserInfoVO;
|
||||||
}
|
}
|
||||||
|
|||||||
+39
-48
@@ -7,7 +7,6 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||||||
import com.jero.common.constant.enums.YesOrNoEnum;
|
import com.jero.common.constant.enums.YesOrNoEnum;
|
||||||
import com.jero.common.exception.JeroBootException;
|
import com.jero.common.exception.JeroBootException;
|
||||||
import com.jero.modules.activiti.entity.ProcessAll;
|
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.enums.ProcessTypeEnum;
|
||||||
import com.jero.modules.activiti.process.common.entity.CommonVO;
|
import com.jero.modules.activiti.process.common.entity.CommonVO;
|
||||||
import com.jero.modules.activiti.process.common.entity.ProcessDraft;
|
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.ActFlowCommonService;
|
||||||
import com.jero.modules.activiti.process.common.service.ProcessDraftService;
|
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.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.entity.vo.InitChangeDataVO;
|
||||||
import com.jero.modules.activiti.process.esInitChange.service.ProcessEsInitChangeService;
|
import com.jero.modules.activiti.process.esInitChange.service.ProcessEsInitChangeService;
|
||||||
import com.jero.modules.activiti.process.esInitChange.mapper.ProcessEsInitChangeMapper;
|
import com.jero.modules.activiti.process.esInitChange.mapper.ProcessEsInitChangeMapper;
|
||||||
@@ -106,27 +104,23 @@ public class ProcessEsInitChangeServiceImpl extends ServiceImpl<ProcessEsInitCha
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Object> setVariables(InitChangeDataVO initChangeData) {
|
public Map<String, Object> setVariables(InitChangeDataVO initChangeData) {
|
||||||
InitChangeFlowUserVO initChangeFlowUserVO = initChangeData.getFlowUserInfoVO();
|
Map<String, Object> flowUserInfoVO = initChangeData.getFlowUserInfoVO();
|
||||||
|
HashMap<String, Object> map = new HashMap<>(flowUserInfoVO);
|
||||||
ProcessEsInitChange initChange = initChangeData.getDataList().get(0);
|
ProcessEsInitChange initChange = initChangeData.getDataList().get(0);
|
||||||
HashMap<String, Object> map = new HashMap<>(this.setUserVariables(initChangeFlowUserVO));
|
// 添加非列表类型的变量
|
||||||
actFlowCommonService.putIfNotNull(map, "applicationCategory", initChange.getApplicationCategory());
|
actFlowCommonService.putIfNotNull(map, "applicationCategory", initChange.getApplicationCategory());
|
||||||
actFlowCommonService.putIfNotNull(map, "projectType", initChange.getProjectType());
|
actFlowCommonService.putIfNotNull(map, "projectType", initChange.getProjectType());
|
||||||
|
// 添加列表类型的变量
|
||||||
|
convertAndPutList(map, flowUserInfoVO, "standardExpertList");
|
||||||
|
convertAndPutList(map, flowUserInfoVO, "relatedUserList");
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Object> setUserVariables(InitChangeFlowUserVO initChangeFlowUserVO) {
|
private void convertAndPutList(HashMap<String, Object> map, Map<String, Object> flowUserInfoVO, String key) {
|
||||||
HashMap<String, Object> map = new HashMap<>();
|
Optional.ofNullable(flowUserInfoVO.get(key))
|
||||||
// 使用一个通用方法来只在不为空时添加键值对
|
.map(Object::toString)
|
||||||
actFlowCommonService.putIfNotNull(map, "createUser", initChangeFlowUserVO.getCreateUser());
|
.map(s -> Arrays.asList(s.split(",")))
|
||||||
actFlowCommonService.putIfNotNull(map, "contactUser", initChangeFlowUserVO.getContactUser());
|
.ifPresent(list -> map.put(key, list));
|
||||||
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 Map<String, Object> getUserMap(Map<String, Object> variables) {
|
private Map<String, Object> getUserMap(Map<String, Object> variables) {
|
||||||
@@ -159,6 +153,8 @@ public class ProcessEsInitChangeServiceImpl extends ServiceImpl<ProcessEsInitCha
|
|||||||
commonVO.setTaskId(process.getTaskId());
|
commonVO.setTaskId(process.getTaskId());
|
||||||
commonVO.setPrcMes(process.getPrcMes());
|
commonVO.setPrcMes(process.getPrcMes());
|
||||||
commonVO.setDueTime(process.getDueTime());
|
commonVO.setDueTime(process.getDueTime());
|
||||||
|
commonVO.setProcessDefinitionId(processDefinitionId);
|
||||||
|
commonVO.setProcessInstanceId(processInstanceId);
|
||||||
initChangeDataVO.setCommonVO(commonVO);
|
initChangeDataVO.setCommonVO(commonVO);
|
||||||
// 获取流程实例数据
|
// 获取流程实例数据
|
||||||
LambdaQueryWrapper<ProcessEsInitChange> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<ProcessEsInitChange> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
@@ -166,38 +162,36 @@ public class ProcessEsInitChangeServiceImpl extends ServiceImpl<ProcessEsInitCha
|
|||||||
lambdaQueryWrapper.eq(ProcessEsInitChange::getDelFlag, YesOrNoEnum.NO.getValue());
|
lambdaQueryWrapper.eq(ProcessEsInitChange::getDelFlag, YesOrNoEnum.NO.getValue());
|
||||||
List<ProcessEsInitChange> dataList = list(lambdaQueryWrapper);
|
List<ProcessEsInitChange> dataList = list(lambdaQueryWrapper);
|
||||||
initChangeDataVO.setDataList(dataList);
|
initChangeDataVO.setDataList(dataList);
|
||||||
// 选人组件内容填充
|
|
||||||
initChangeDataVO.setFlowUserInfoVO(this.getProcessUserInfo(processDefinitionId, processInstanceId));
|
|
||||||
return initChangeDataVO;
|
return initChangeDataVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
private InitChangeFlowUserVO getProcessUserInfo(String processDefinitionId, String processInstanceId) {
|
// private InitChangeFlowUserVO getProcessUserInfo(String processDefinitionId, String processInstanceId) {
|
||||||
List<ProcessNode> nodeList = processNodeService.getNodeList(processDefinitionId, processInstanceId);
|
// List<ProcessNode> nodeList = processNodeService.getNodeList(processDefinitionId, processInstanceId);
|
||||||
InitChangeFlowUserVO initChangeFlowUserVO = new InitChangeFlowUserVO();
|
// InitChangeFlowUserVO initChangeFlowUserVO = new InitChangeFlowUserVO();
|
||||||
Map<String, ProcessNode> userMap = nodeList.stream()
|
// Map<String, ProcessNode> userMap = nodeList.stream()
|
||||||
.collect(Collectors.groupingBy(ProcessNode::getVariableName))
|
// .collect(Collectors.groupingBy(ProcessNode::getVariableName))
|
||||||
.values()
|
// .values()
|
||||||
.stream()
|
// .stream()
|
||||||
.map(nodes -> nodes.get(0)) // 选择每组的第一个元素
|
// .map(nodes -> nodes.get(0)) // 选择每组的第一个元素
|
||||||
.collect(Collectors.toMap(ProcessNode::getVariableName, node -> node));
|
// .collect(Collectors.toMap(ProcessNode::getVariableName, node -> node));
|
||||||
Optional.ofNullable(userMap.get("createUser")).ifPresent(node -> initChangeFlowUserVO.setCreateUser(node.getLinkUserIds()));
|
// 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("contactUser")).ifPresent(node -> initChangeFlowUserVO.setContactUser(node.getLinkUserIds()));
|
||||||
Optional.ofNullable(userMap.get("standardExpertList")).ifPresent(node -> initChangeFlowUserVO.setStandardExpert(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("mainDraftUserLeader")).ifPresent(node -> initChangeFlowUserVO.setMainDraftUserLeader(node.getLinkUserIds()));
|
||||||
Optional.ofNullable(userMap.get("mainDraftUserLeaderLeader")).ifPresent(node -> initChangeFlowUserVO.setMainDraftUserLeaderLeader(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("standardizationApprovalUser")).ifPresent(node -> initChangeFlowUserVO.setStandardizationApprovalUser(node.getLinkUserIds()));
|
||||||
Optional.ofNullable(userMap.get("newMainDraftUserLeaderLeader")).ifPresent(node -> initChangeFlowUserVO.setNewMainDraftUserLeaderLeader(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("newMainDraftUserLeader")).ifPresent(node -> initChangeFlowUserVO.setNewMainDraftUserLeader(node.getLinkUserIds()));
|
||||||
Optional.ofNullable(userMap.get("relatedUserList")).ifPresent(node -> initChangeFlowUserVO.setRelatedUser(node.getLinkUserIds()));
|
// Optional.ofNullable(userMap.get("relatedUserList")).ifPresent(node -> initChangeFlowUserVO.setRelatedUser(node.getLinkUserIds()));
|
||||||
return initChangeFlowUserVO;
|
// return initChangeFlowUserVO;
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void approvalInitChange(InitChangeDataVO initChangeDataVO, boolean pass) {
|
public void approvalInitChange(InitChangeDataVO initChangeDataVO, boolean pass) {
|
||||||
String userId = UserUtils.getUserId();
|
String userId = UserUtils.getUserId();
|
||||||
CommonVO commonVO = initChangeDataVO.getCommonVO();
|
CommonVO commonVO = initChangeDataVO.getCommonVO();
|
||||||
List<ProcessEsInitChange> initChangeList = initChangeDataVO.getDataList();
|
List<ProcessEsInitChange> initChangeList = initChangeDataVO.getDataList();
|
||||||
InitChangeFlowUserVO flowUserInfoVO = initChangeDataVO.getFlowUserInfoVO();
|
Map<String, Object> flowUserInfoVO = initChangeDataVO.getFlowUserInfoVO();
|
||||||
String taskId = commonVO.getTaskId();
|
String taskId = commonVO.getTaskId();
|
||||||
if (StrUtil.isBlank(taskId) && !actFlowCommonService.taskExists(taskId)) {
|
if (StrUtil.isBlank(taskId) && !actFlowCommonService.taskExists(taskId)) {
|
||||||
throw new JeroBootException("taskId为空或任务不存在");
|
throw new JeroBootException("taskId为空或任务不存在");
|
||||||
@@ -205,16 +199,13 @@ public class ProcessEsInitChangeServiceImpl extends ServiceImpl<ProcessEsInitCha
|
|||||||
String processInstanceId = actFlowCommonService.getProcessInstanceIdByTaskId(taskId);
|
String processInstanceId = actFlowCommonService.getProcessInstanceIdByTaskId(taskId);
|
||||||
String processDefinitionId = actFlowCommonService.getProcessDefId(processInstanceId);
|
String processDefinitionId = actFlowCommonService.getProcessDefId(processInstanceId);
|
||||||
if (pass) {
|
if (pass) {
|
||||||
if (initChangeList != null && flowUserInfoVO != null) {
|
if (initChangeList != null) {
|
||||||
saveOrUpdateBatch(initChangeList);
|
saveOrUpdateBatch(initChangeList);
|
||||||
Map<String, Object> variables = this.setVariables(initChangeDataVO);
|
|
||||||
actFlowCommonService.setProcessVariables(processInstanceId, variables);
|
|
||||||
processNodeLinkService.saveNodeUserLink(processDefinitionId, processInstanceId, this.getUserMap(variables));
|
|
||||||
}
|
}
|
||||||
if (flowUserInfoVO != null) {
|
if (flowUserInfoVO != null && !flowUserInfoVO.isEmpty()) {
|
||||||
Map<String, Object> variables = this.setUserVariables(flowUserInfoVO);
|
Map<String, Object> variables = setVariables(initChangeDataVO);
|
||||||
actFlowCommonService.setProcessVariables(processInstanceId, variables);
|
actFlowCommonService.setProcessVariables(processInstanceId, variables);
|
||||||
processNodeLinkService.saveNodeUserLink(processDefinitionId, processInstanceId, this.getUserMap(variables));
|
processNodeLinkService.saveNodeUserLink(processDefinitionId, processInstanceId, getUserMap(variables));
|
||||||
}
|
}
|
||||||
runtimeService.setVariableLocal(processInstanceId, "pass", true);
|
runtimeService.setVariableLocal(processInstanceId, "pass", true);
|
||||||
} else {
|
} else {
|
||||||
@@ -268,7 +259,7 @@ public class ProcessEsInitChangeServiceImpl extends ServiceImpl<ProcessEsInitCha
|
|||||||
public void startRunTask(InitChangeDataVO initChangeData) {
|
public void startRunTask(InitChangeDataVO initChangeData) {
|
||||||
List<ProcessEsInitChange> esInitChangeList = initChangeData.getDataList();
|
List<ProcessEsInitChange> esInitChangeList = initChangeData.getDataList();
|
||||||
// 校验企标编号是否冲突
|
// 校验企标编号是否冲突
|
||||||
if (!esUtil.verifyEnStandardNumber(esInitChangeList.get(0).getOriginEnStandardNo())) {
|
if (!esUtil.verifyEnStandardNumber(esInitChangeList.get(0).getNewEnStandardNo())) {
|
||||||
throw new JeroBootException("企标编号冲突,请重新生成");
|
throw new JeroBootException("企标编号冲突,请重新生成");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user