fix: 立项变更发起报错
This commit is contained in:
+27
-6
@@ -83,6 +83,33 @@ public class ActFlowCommonService {
|
||||
Optional.ofNullable(value).ifPresent(v -> map.put(key, v));
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换逗号拼接为List
|
||||
* @param map
|
||||
* @param flowUserInfoVO
|
||||
* @param key
|
||||
*/
|
||||
public void convertAndPutList(HashMap<String, Object> map, Map<String, Object> flowUserInfoVO, String key) {
|
||||
Optional.ofNullable(flowUserInfoVO.get(key))
|
||||
.map(Object::toString)
|
||||
.map(s -> Arrays.asList(s.split(",")))
|
||||
.ifPresent(list -> map.put(key, list));
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统中保存选人信息 多实例节点需要将List转为逗号拼接
|
||||
*/
|
||||
public void convertListToString(Map<String, Object> variables) {
|
||||
for (Map.Entry<String, Object> entry : variables.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
if (key.endsWith("List")) {
|
||||
List<String> list = (List<String>) entry.getValue();
|
||||
String s = String.join(",", list);
|
||||
variables.put(key, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 循环设置流程变量
|
||||
*
|
||||
@@ -92,12 +119,6 @@ public class ActFlowCommonService {
|
||||
public void setProcessVariables(String processInstanceId, Map<String, Object> variables) {
|
||||
for (Map.Entry<String, Object> entry : variables.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
if (key.endsWith("List")) {
|
||||
String value = (String) entry.getValue();
|
||||
List<String> valueList = Arrays.asList(value.split(","));
|
||||
runtimeService.setVariable(processInstanceId, entry.getKey(), valueList);
|
||||
continue;
|
||||
}
|
||||
runtimeService.setVariable(processInstanceId, key, entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
+21
-18
@@ -73,10 +73,10 @@ public class ProcessEsAbolishServiceImpl extends ServiceImpl<ProcessEsAbolishMap
|
||||
CommonVO commonVO = abolishData.getCommon();
|
||||
// 人员数据
|
||||
Map<String, Object> variables = abolishData.getFlowUser();
|
||||
// 设置流程变量
|
||||
this.setVariables(variables);
|
||||
// 流程变量
|
||||
Map<String, Object> actVariables = this.setVariables(variables);
|
||||
// 启动流程
|
||||
ProcessInstance processInstance = actFlowCommonService.startProcess(processDefinitionKey, variables);
|
||||
ProcessInstance processInstance = actFlowCommonService.startProcess(processDefinitionKey, actVariables);
|
||||
// 获取流程实例ID
|
||||
String processDefinitionId = processInstance.getProcessDefinitionId();
|
||||
String processInstanceId = processInstance.getId();
|
||||
@@ -99,25 +99,28 @@ public class ProcessEsAbolishServiceImpl extends ServiceImpl<ProcessEsAbolishMap
|
||||
}
|
||||
|
||||
public Map<String, Object> setVariables(Map<String, Object> flowUser) {
|
||||
HashMap<String, Object> map = new HashMap<>(this.setUserVariables(flowUser));
|
||||
boolean counterSign = StrUtil.isNotBlank((String)flowUser.get("relatedUserList"));
|
||||
actFlowCommonService.putIfNotNull(map, "counterSign", counterSign);
|
||||
return map;
|
||||
}
|
||||
|
||||
public Map<String, Object> setUserVariables(Map<String, Object> flowUser) {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
// 使用一个通用方法来只在不为空时添加键值对
|
||||
actFlowCommonService.putIfNotNull(map, "createUser", flowUser.get("createUser"));
|
||||
actFlowCommonService.putIfNotNull(map, "relatedUserList", flowUser.get("relatedUserList"));
|
||||
actFlowCommonService.putIfNotNull(map, "leader", flowUser.get("leader"));
|
||||
actFlowCommonService.putIfNotNull(map, "standardizationApprovalUser", flowUser.get("standardizationApprovalUser"));
|
||||
return map;
|
||||
Map<String, Object> actVariables = new HashMap<>();
|
||||
if (flowUser.get("relatedUserList") == null || StrUtil.isBlank((String)flowUser.get("relatedUserList"))) {
|
||||
actFlowCommonService.putIfNotNull(actVariables, "countersign", false);
|
||||
} else {
|
||||
actFlowCommonService.putIfNotNull(actVariables, "countersign", true);
|
||||
String relatedUsers = (String) flowUser.get("relatedUserList");
|
||||
// 将relatedUserList从逗号拼接转为List
|
||||
List<String> relatedUserList = StrUtil.split(relatedUsers, ',');
|
||||
actFlowCommonService.putIfNotNull(actVariables, "relatedUserList", relatedUserList);
|
||||
}
|
||||
for (Map.Entry<String, Object> entry : flowUser.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
if (!key.equals("relatedUserList")) {
|
||||
actVariables.put(key, entry.getValue());
|
||||
}
|
||||
}
|
||||
return actVariables;
|
||||
}
|
||||
|
||||
private Map<String, Object> getUserMap(Map<String, Object> variables) {
|
||||
variables.remove("pass");
|
||||
variables.remove("counterSign");
|
||||
variables.remove("countersign");
|
||||
return variables;
|
||||
}
|
||||
|
||||
|
||||
+7
-10
@@ -94,7 +94,9 @@ public class ProcessEsInitChangeServiceImpl extends ServiceImpl<ProcessEsInitCha
|
||||
// 保存到业务流程表
|
||||
saveBatch(esInitChangeList);
|
||||
// 保存选人信息
|
||||
processNodeLinkService.saveNodeUserLink(processDefinitionId, processInstanceId, this.getUserMap(variables));
|
||||
// 人员
|
||||
Map<String, Object> flowUserInfoVO = initChangeData.getFlowUserInfoVO();
|
||||
processNodeLinkService.saveNodeUserLink(processDefinitionId, processInstanceId, flowUserInfoVO);
|
||||
// 根据流程实例id更新流程总表
|
||||
String prcName = commonVO.getPrcName();
|
||||
String prcMes = commonVO.getPrcMes();
|
||||
@@ -111,22 +113,17 @@ public class ProcessEsInitChangeServiceImpl extends ServiceImpl<ProcessEsInitCha
|
||||
actFlowCommonService.putIfNotNull(map, "applicationCategory", initChange.getApplicationCategory());
|
||||
actFlowCommonService.putIfNotNull(map, "projectType", initChange.getProjectType());
|
||||
// 添加列表类型的变量
|
||||
convertAndPutList(map, flowUserInfoVO, "standardExpertList");
|
||||
convertAndPutList(map, flowUserInfoVO, "relatedUserList");
|
||||
actFlowCommonService.convertAndPutList(map, flowUserInfoVO, "standardExpertList");
|
||||
actFlowCommonService.convertAndPutList(map, flowUserInfoVO, "relatedUserList");
|
||||
return map;
|
||||
}
|
||||
|
||||
private void convertAndPutList(HashMap<String, Object> map, Map<String, Object> 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<String, Object> getUserMap(Map<String, Object> variables) {
|
||||
variables.remove("pass");
|
||||
variables.remove("applicationCategory");
|
||||
variables.remove("projectType");
|
||||
// 转成逗号拼接
|
||||
actFlowCommonService.convertListToString(variables);
|
||||
return variables;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user