|
|
@ -547,6 +547,25 @@ public class ProcessDefinitionService extends BaseDAGService { |
|
|
|
sqlParameters.put("datasourceName", dataSource.getName()); |
|
|
|
sqlParameters.put("datasourceName", dataSource.getName()); |
|
|
|
} |
|
|
|
} |
|
|
|
taskNode.put("params", sqlParameters); |
|
|
|
taskNode.put("params", sqlParameters); |
|
|
|
|
|
|
|
}else if(taskType.equals(TaskType.DEPENDENT.name())){ |
|
|
|
|
|
|
|
JSONObject dependentParameters = JSONUtils.parseObject(taskNode.getString("dependence")); |
|
|
|
|
|
|
|
if(dependentParameters != null){ |
|
|
|
|
|
|
|
JSONArray dependTaskList = (JSONArray) dependentParameters.get("dependTaskList"); |
|
|
|
|
|
|
|
for (int j = 0; j < dependTaskList.size(); j++) { |
|
|
|
|
|
|
|
JSONObject dependentTaskModel = dependTaskList.getJSONObject(j); |
|
|
|
|
|
|
|
JSONArray dependItemList = (JSONArray) dependentTaskModel.get("dependItemList"); |
|
|
|
|
|
|
|
for (int k = 0; k < dependItemList.size(); k++) { |
|
|
|
|
|
|
|
JSONObject dependentItem = dependItemList.getJSONObject(k); |
|
|
|
|
|
|
|
int definitionId = dependentItem.getInteger("definitionId"); |
|
|
|
|
|
|
|
ProcessDefinition definition = processDefineMapper.queryByDefineId(definitionId); |
|
|
|
|
|
|
|
if(definition != null){ |
|
|
|
|
|
|
|
dependentItem.put("projectName",definition.getProjectName()); |
|
|
|
|
|
|
|
dependentItem.put("definitionName",definition.getName()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
taskNode.put("dependence", dependentParameters); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -643,16 +662,19 @@ public class ProcessDefinitionService extends BaseDAGService { |
|
|
|
projectName = json.get("projectName").toString(); |
|
|
|
projectName = json.get("projectName").toString(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
putMsg(result, Status.DATA_IS_NULL, "processDefinitionName"); |
|
|
|
putMsg(result, Status.DATA_IS_NULL, "processDefinitionName"); |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
if (ObjectUtils.allNotNull(json.get("processDefinitionName"))) { |
|
|
|
if (ObjectUtils.allNotNull(json.get("processDefinitionName"))) { |
|
|
|
processDefinitionName = json.get("processDefinitionName").toString(); |
|
|
|
processDefinitionName = json.get("processDefinitionName").toString(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
putMsg(result, Status.DATA_IS_NULL, "processDefinitionName"); |
|
|
|
putMsg(result, Status.DATA_IS_NULL, "processDefinitionName"); |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
if (ObjectUtils.allNotNull(json.get("processDefinitionJson"))) { |
|
|
|
if (ObjectUtils.allNotNull(json.get("processDefinitionJson"))) { |
|
|
|
processDefinitionJson = json.get("processDefinitionJson").toString(); |
|
|
|
processDefinitionJson = json.get("processDefinitionJson").toString(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
putMsg(result, Status.DATA_IS_NULL, "processDefinitionJson"); |
|
|
|
putMsg(result, Status.DATA_IS_NULL, "processDefinitionJson"); |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
if (ObjectUtils.allNotNull(json.get("processDefinitionDesc"))) { |
|
|
|
if (ObjectUtils.allNotNull(json.get("processDefinitionDesc"))) { |
|
|
|
processDefinitionDesc = json.get("processDefinitionDesc").toString(); |
|
|
|
processDefinitionDesc = json.get("processDefinitionDesc").toString(); |
|
|
@ -664,10 +686,17 @@ public class ProcessDefinitionService extends BaseDAGService { |
|
|
|
processDefinitionConnects = json.get("processDefinitionConnects").toString(); |
|
|
|
processDefinitionConnects = json.get("processDefinitionConnects").toString(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Project project = projectMapper.queryByName(projectName); |
|
|
|
|
|
|
|
if(project != null){ |
|
|
|
|
|
|
|
processDefinitionName = recursionProcessDefinitionName(project.getId(), processDefinitionName,1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
JSONObject jsonObject = JSONUtils.parseObject(processDefinitionJson); |
|
|
|
JSONObject jsonObject = JSONUtils.parseObject(processDefinitionJson); |
|
|
|
JSONArray jsonArray = (JSONArray) jsonObject.get("tasks"); |
|
|
|
JSONArray jsonArray = (JSONArray) jsonObject.get("tasks"); |
|
|
|
for (int j = 0; j < jsonArray.size(); j++) { |
|
|
|
for (int j = 0; j < jsonArray.size(); j++) { |
|
|
|
JSONObject taskNode = jsonArray.getJSONObject(j); |
|
|
|
JSONObject taskNode = jsonArray.getJSONObject(j); |
|
|
|
|
|
|
|
String taskType = taskNode.getString("type"); |
|
|
|
|
|
|
|
if(taskType.equals(TaskType.SQL.name()) || taskType.equals(TaskType.PROCEDURE.name())) { |
|
|
|
JSONObject sqlParameters = JSONUtils.parseObject(taskNode.getString("params")); |
|
|
|
JSONObject sqlParameters = JSONUtils.parseObject(taskNode.getString("params")); |
|
|
|
List<DataSource> dataSources = dataSourceMapper.queryDataSourceByName(sqlParameters.getString("datasourceName")); |
|
|
|
List<DataSource> dataSources = dataSourceMapper.queryDataSourceByName(sqlParameters.getString("datasourceName")); |
|
|
|
if (dataSources.size() > 0) { |
|
|
|
if (dataSources.size() > 0) { |
|
|
@ -675,6 +704,28 @@ public class ProcessDefinitionService extends BaseDAGService { |
|
|
|
sqlParameters.put("datasource", dataSource.getId()); |
|
|
|
sqlParameters.put("datasource", dataSource.getId()); |
|
|
|
} |
|
|
|
} |
|
|
|
taskNode.put("params", sqlParameters); |
|
|
|
taskNode.put("params", sqlParameters); |
|
|
|
|
|
|
|
}else if(taskType.equals(TaskType.DEPENDENT.name())){ |
|
|
|
|
|
|
|
JSONObject dependentParameters = JSONUtils.parseObject(taskNode.getString("dependence")); |
|
|
|
|
|
|
|
if(dependentParameters != null){ |
|
|
|
|
|
|
|
JSONArray dependTaskList = (JSONArray) dependentParameters.get("dependTaskList"); |
|
|
|
|
|
|
|
for (int h = 0; h < dependTaskList.size(); h++) { |
|
|
|
|
|
|
|
JSONObject dependentTaskModel = dependTaskList.getJSONObject(h); |
|
|
|
|
|
|
|
JSONArray dependItemList = (JSONArray) dependentTaskModel.get("dependItemList"); |
|
|
|
|
|
|
|
for (int k = 0; k < dependItemList.size(); k++) { |
|
|
|
|
|
|
|
JSONObject dependentItem = dependItemList.getJSONObject(k); |
|
|
|
|
|
|
|
Project dependentItemProject = projectMapper.queryByName(dependentItem.getString("projectName")); |
|
|
|
|
|
|
|
if(dependentItemProject != null){ |
|
|
|
|
|
|
|
ProcessDefinition definition = processDefineMapper.queryByDefineName(dependentItemProject.getId(),dependentItem.getString("definitionName")); |
|
|
|
|
|
|
|
if(definition != null){ |
|
|
|
|
|
|
|
dependentItem.put("projectId",dependentItemProject.getId()); |
|
|
|
|
|
|
|
dependentItem.put("definitionId",definition.getId()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
taskNode.put("dependence", dependentParameters); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
jsonObject.put("tasks", jsonArray); |
|
|
|
jsonObject.put("tasks", jsonArray); |
|
|
|
|
|
|
|
|
|
|
@ -1112,5 +1163,20 @@ public class ProcessDefinitionService extends BaseDAGService { |
|
|
|
return graph.hasCycle(); |
|
|
|
return graph.hasCycle(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String recursionProcessDefinitionName(Integer projectId,String processDefinitionName,int num){ |
|
|
|
|
|
|
|
ProcessDefinition processDefinition = processDefineMapper.queryByDefineName(projectId, processDefinitionName); |
|
|
|
|
|
|
|
if (processDefinition != null) { |
|
|
|
|
|
|
|
if(num>1){ |
|
|
|
|
|
|
|
String str = processDefinitionName.substring(0,processDefinitionName.length() - 3); |
|
|
|
|
|
|
|
processDefinitionName = str + "("+num+")"; |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
processDefinitionName = processDefinition.getName() + "("+num+")"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
return processDefinitionName; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return recursionProcessDefinitionName(projectId,processDefinitionName,num + 1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|