|
|
@ -802,66 +802,68 @@ public class ProcessDefinitionService extends BaseDAGService { |
|
|
|
JSONObject subParams = JSONUtils.parseObject(taskNode.getString("params")); |
|
|
|
JSONObject subParams = JSONUtils.parseObject(taskNode.getString("params")); |
|
|
|
Integer subProcessId = subParams.getInteger("processDefinitionId"); |
|
|
|
Integer subProcessId = subParams.getInteger("processDefinitionId"); |
|
|
|
ProcessDefinition subProcess = processDefineMapper.queryByDefineId(subProcessId); |
|
|
|
ProcessDefinition subProcess = processDefineMapper.queryByDefineId(subProcessId); |
|
|
|
String subProcessJson = subProcess.getProcessDefinitionJson(); |
|
|
|
//check is sub process exist in db
|
|
|
|
//check current project has sub process
|
|
|
|
if (null != subProcess) { |
|
|
|
ProcessDefinition currentProjectSubProcess = processDefineMapper.queryByDefineName(targetProject.getId(), subProcess.getName()); |
|
|
|
String subProcessJson = subProcess.getProcessDefinitionJson(); |
|
|
|
|
|
|
|
//check current project has sub process
|
|
|
|
if (null == currentProjectSubProcess) { |
|
|
|
ProcessDefinition currentProjectSubProcess = processDefineMapper.queryByDefineName(targetProject.getId(), subProcess.getName()); |
|
|
|
JSONArray subJsonArray = (JSONArray) JSONUtils.parseObject(subProcess.getProcessDefinitionJson()).get("tasks"); |
|
|
|
|
|
|
|
|
|
|
|
if (null == currentProjectSubProcess) { |
|
|
|
List<Object> subProcessList = subJsonArray.stream() |
|
|
|
JSONArray subJsonArray = (JSONArray) JSONUtils.parseObject(subProcess.getProcessDefinitionJson()).get("tasks"); |
|
|
|
.filter(item -> checkTaskHasSubProcess(JSONUtils.parseObject(item.toString()).getString("type"))) |
|
|
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
List<Object> subProcessList = subJsonArray.stream() |
|
|
|
|
|
|
|
.filter(item -> checkTaskHasSubProcess(JSONUtils.parseObject(item.toString()).getString("type"))) |
|
|
|
if (CollectionUtils.isNotEmpty(subProcessList)) { |
|
|
|
.collect(Collectors.toList()); |
|
|
|
importSubProcess(loginUser, targetProject, subJsonArray, subProcessIdMap); |
|
|
|
|
|
|
|
//sub process processId correct
|
|
|
|
if (CollectionUtils.isNotEmpty(subProcessList)) { |
|
|
|
if (!subProcessIdMap.isEmpty()) { |
|
|
|
importSubProcess(loginUser, targetProject, subJsonArray, subProcessIdMap); |
|
|
|
|
|
|
|
//sub process processId correct
|
|
|
|
for (Map.Entry<Integer, Integer> entry : subProcessIdMap.entrySet()) { |
|
|
|
if (!subProcessIdMap.isEmpty()) { |
|
|
|
String oldSubProcessId = "\"processDefinitionId\":" + entry.getKey(); |
|
|
|
|
|
|
|
String newSubProcessId = "\"processDefinitionId\":" + entry.getValue(); |
|
|
|
for (Map.Entry<Integer, Integer> entry : subProcessIdMap.entrySet()) { |
|
|
|
subProcessJson = subProcessJson.replaceAll(oldSubProcessId, newSubProcessId); |
|
|
|
String oldSubProcessId = "\"processDefinitionId\":" + entry.getKey(); |
|
|
|
|
|
|
|
String newSubProcessId = "\"processDefinitionId\":" + entry.getValue(); |
|
|
|
|
|
|
|
subProcessJson = subProcessJson.replaceAll(oldSubProcessId, newSubProcessId); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subProcessIdMap.clear(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
subProcessIdMap.clear(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if sub-process recursion
|
|
|
|
//if sub-process recursion
|
|
|
|
Date now = new Date(); |
|
|
|
Date now = new Date(); |
|
|
|
//create sub process in target project
|
|
|
|
//create sub process in target project
|
|
|
|
ProcessDefinition processDefine = new ProcessDefinition(); |
|
|
|
ProcessDefinition processDefine = new ProcessDefinition(); |
|
|
|
processDefine.setName(subProcess.getName()); |
|
|
|
processDefine.setName(subProcess.getName()); |
|
|
|
processDefine.setVersion(subProcess.getVersion()); |
|
|
|
processDefine.setVersion(subProcess.getVersion()); |
|
|
|
processDefine.setReleaseState(subProcess.getReleaseState()); |
|
|
|
processDefine.setReleaseState(subProcess.getReleaseState()); |
|
|
|
processDefine.setProjectId(targetProject.getId()); |
|
|
|
processDefine.setProjectId(targetProject.getId()); |
|
|
|
processDefine.setUserId(loginUser.getId()); |
|
|
|
processDefine.setUserId(loginUser.getId()); |
|
|
|
processDefine.setProcessDefinitionJson(subProcessJson); |
|
|
|
processDefine.setProcessDefinitionJson(subProcessJson); |
|
|
|
processDefine.setDescription(subProcess.getDescription()); |
|
|
|
processDefine.setDescription(subProcess.getDescription()); |
|
|
|
processDefine.setLocations(subProcess.getLocations()); |
|
|
|
processDefine.setLocations(subProcess.getLocations()); |
|
|
|
processDefine.setConnects(subProcess.getConnects()); |
|
|
|
processDefine.setConnects(subProcess.getConnects()); |
|
|
|
processDefine.setTimeout(subProcess.getTimeout()); |
|
|
|
processDefine.setTimeout(subProcess.getTimeout()); |
|
|
|
processDefine.setTenantId(subProcess.getTenantId()); |
|
|
|
processDefine.setTenantId(subProcess.getTenantId()); |
|
|
|
processDefine.setGlobalParams(subProcess.getGlobalParams()); |
|
|
|
processDefine.setGlobalParams(subProcess.getGlobalParams()); |
|
|
|
processDefine.setCreateTime(now); |
|
|
|
processDefine.setCreateTime(now); |
|
|
|
processDefine.setUpdateTime(now); |
|
|
|
processDefine.setUpdateTime(now); |
|
|
|
processDefine.setFlag(subProcess.getFlag()); |
|
|
|
processDefine.setFlag(subProcess.getFlag()); |
|
|
|
processDefine.setReceivers(subProcess.getReceivers()); |
|
|
|
processDefine.setReceivers(subProcess.getReceivers()); |
|
|
|
processDefine.setReceiversCc(subProcess.getReceiversCc()); |
|
|
|
processDefine.setReceiversCc(subProcess.getReceiversCc()); |
|
|
|
processDefineMapper.insert(processDefine); |
|
|
|
processDefineMapper.insert(processDefine); |
|
|
|
|
|
|
|
|
|
|
|
logger.info("create sub process, project: {}, process name: {}", targetProject.getName(), processDefine.getName()); |
|
|
|
logger.info("create sub process, project: {}, process name: {}", targetProject.getName(), processDefine.getName()); |
|
|
|
|
|
|
|
|
|
|
|
//modify task node
|
|
|
|
//modify task node
|
|
|
|
ProcessDefinition newSubProcessDefine = processDefineMapper.queryByDefineName(processDefine.getProjectId(),processDefine.getName()); |
|
|
|
ProcessDefinition newSubProcessDefine = processDefineMapper.queryByDefineName(processDefine.getProjectId(),processDefine.getName()); |
|
|
|
|
|
|
|
|
|
|
|
if (null != newSubProcessDefine) { |
|
|
|
if (null != newSubProcessDefine) { |
|
|
|
subProcessIdMap.put(subProcessId, newSubProcessDefine.getId()); |
|
|
|
subProcessIdMap.put(subProcessId, newSubProcessDefine.getId()); |
|
|
|
subParams.put("processDefinitionId", newSubProcessDefine.getId()); |
|
|
|
subParams.put("processDefinitionId", newSubProcessDefine.getId()); |
|
|
|
taskNode.put("params", subParams); |
|
|
|
taskNode.put("params", subParams); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|