|
|
@ -142,6 +142,18 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private ProcessTaskRelationMapper processTaskRelationMapper; |
|
|
|
private ProcessTaskRelationMapper processTaskRelationMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
TaskDefinitionLogMapper taskDefinitionLogMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
private TaskDefinitionMapper taskDefinitionMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
private SchedulerService schedulerService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
private TenantMapper tenantMapper; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* create process definition |
|
|
|
* create process definition |
|
|
|
* |
|
|
|
* |
|
|
@ -193,11 +205,15 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
return checkRelationJson; |
|
|
|
return checkRelationJson; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int tenantId = -1; |
|
|
|
|
|
|
|
if (!Constants.DEFAULT.equals(tenantCode)) { |
|
|
|
Tenant tenant = tenantMapper.queryByTenantCode(tenantCode); |
|
|
|
Tenant tenant = tenantMapper.queryByTenantCode(tenantCode); |
|
|
|
if (tenant == null) { |
|
|
|
if (tenant == null) { |
|
|
|
putMsg(result, Status.TENANT_NOT_EXIST); |
|
|
|
putMsg(result, Status.TENANT_NOT_EXIST); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
tenantId = tenant.getId(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
long processDefinitionCode; |
|
|
|
long processDefinitionCode; |
|
|
|
try { |
|
|
|
try { |
|
|
@ -207,23 +223,11 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
ProcessDefinition processDefinition = new ProcessDefinition(projectCode, name, processDefinitionCode, description, |
|
|
|
ProcessDefinition processDefinition = new ProcessDefinition(projectCode, name, processDefinitionCode, description, |
|
|
|
globalParams, locations, timeout, loginUser.getId(), tenant.getId()); |
|
|
|
globalParams, locations, timeout, loginUser.getId(), tenantId); |
|
|
|
|
|
|
|
|
|
|
|
return createProcessDefine(loginUser, result, taskRelationList, processDefinition, taskDefinitionLogs); |
|
|
|
return createProcessDefine(loginUser, result, taskRelationList, processDefinition, taskDefinitionLogs); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
TaskDefinitionLogMapper taskDefinitionLogMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
private TaskDefinitionMapper taskDefinitionMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
private SchedulerService schedulerService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
private TenantMapper tenantMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void createTaskDefinition(Map<String, Object> result, |
|
|
|
private void createTaskDefinition(Map<String, Object> result, |
|
|
|
User loginUser, |
|
|
|
User loginUser, |
|
|
|
long projectCode, |
|
|
|
long projectCode, |
|
|
@ -240,12 +244,6 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
putMsg(result, Status.PROCESS_NODE_S_PARAMETER_INVALID, taskDefinitionLog.getName()); |
|
|
|
putMsg(result, Status.PROCESS_NODE_S_PARAMETER_INVALID, taskDefinitionLog.getName()); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
TaskDefinition taskDefinition = taskDefinitionMapper.queryByName(projectCode, taskDefinitionLog.getName()); |
|
|
|
|
|
|
|
if (taskDefinition != null) { |
|
|
|
|
|
|
|
logger.error("task definition name {} already exists", taskDefinitionLog.getName()); |
|
|
|
|
|
|
|
putMsg(result, Status.TASK_DEFINITION_NAME_EXISTED, taskDefinitionLog.getName()); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (processService.saveTaskDefine(loginUser, projectCode, taskDefinitionLogs)) { |
|
|
|
if (processService.saveTaskDefine(loginUser, projectCode, taskDefinitionLogs)) { |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
@ -401,6 +399,10 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
if (processDefinition == null) { |
|
|
|
if (processDefinition == null) { |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, code); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, code); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
Tenant tenant = tenantMapper.queryById(processDefinition.getTenantId()); |
|
|
|
|
|
|
|
if (tenant != null) { |
|
|
|
|
|
|
|
processDefinition.setTenantCode(tenant.getTenantCode()); |
|
|
|
|
|
|
|
} |
|
|
|
DagData dagData = processService.genDagData(processDefinition); |
|
|
|
DagData dagData = processService.genDagData(processDefinition); |
|
|
|
result.put(Constants.DATA_LIST, dagData); |
|
|
|
result.put(Constants.DATA_LIST, dagData); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
@ -475,11 +477,15 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
return checkRelationJson; |
|
|
|
return checkRelationJson; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int tenantId = -1; |
|
|
|
|
|
|
|
if (!Constants.DEFAULT.equals(tenantCode)) { |
|
|
|
Tenant tenant = tenantMapper.queryByTenantCode(tenantCode); |
|
|
|
Tenant tenant = tenantMapper.queryByTenantCode(tenantCode); |
|
|
|
if (tenant == null) { |
|
|
|
if (tenant == null) { |
|
|
|
putMsg(result, Status.TENANT_NOT_EXIST); |
|
|
|
putMsg(result, Status.TENANT_NOT_EXIST); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
tenantId = tenant.getId(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code); |
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code); |
|
|
|
// check process definition exists
|
|
|
|
// check process definition exists
|
|
|
@ -500,21 +506,28 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
processDefinition.set(projectCode, name, description, globalParams, locations, timeout, tenant.getId()); |
|
|
|
ProcessDefinition processDefinitionDeepCopy = JSONUtils.parseObject(JSONUtils.toJsonString(processDefinition), ProcessDefinition.class); |
|
|
|
return updateProcessDefine(loginUser, result, taskRelationList, processDefinition, taskDefinitionLogs); |
|
|
|
processDefinition.set(projectCode, name, description, globalParams, locations, timeout, tenantId); |
|
|
|
|
|
|
|
return updateProcessDefine(loginUser, result, taskRelationList, processDefinition, processDefinitionDeepCopy, taskDefinitionLogs); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private Map<String, Object> updateProcessDefine(User loginUser, |
|
|
|
private Map<String, Object> updateProcessDefine(User loginUser, |
|
|
|
Map<String, Object> result, |
|
|
|
Map<String, Object> result, |
|
|
|
List<ProcessTaskRelationLog> taskRelationList, |
|
|
|
List<ProcessTaskRelationLog> taskRelationList, |
|
|
|
ProcessDefinition processDefinition, |
|
|
|
ProcessDefinition processDefinition, |
|
|
|
|
|
|
|
ProcessDefinition processDefinitionDeepCopy, |
|
|
|
List<TaskDefinitionLog> taskDefinitionLogs) { |
|
|
|
List<TaskDefinitionLog> taskDefinitionLogs) { |
|
|
|
|
|
|
|
int insertVersion; |
|
|
|
|
|
|
|
if (processDefinition.equals(processDefinitionDeepCopy)) { |
|
|
|
|
|
|
|
insertVersion = processDefinitionDeepCopy.getVersion(); |
|
|
|
|
|
|
|
} else { |
|
|
|
processDefinition.setUpdateTime(new Date()); |
|
|
|
processDefinition.setUpdateTime(new Date()); |
|
|
|
int insertVersion = processService.saveProcessDefine(loginUser, processDefinition, true); |
|
|
|
insertVersion = processService.saveProcessDefine(loginUser, processDefinition, true); |
|
|
|
|
|
|
|
} |
|
|
|
if (insertVersion > 0) { |
|
|
|
if (insertVersion > 0) { |
|
|
|
int insertResult = processService.saveTaskRelation(loginUser, processDefinition.getProjectCode(), |
|
|
|
int insertResult = processService.saveTaskRelation(loginUser, processDefinition.getProjectCode(), |
|
|
|
processDefinition.getCode(), insertVersion, taskRelationList, taskDefinitionLogs); |
|
|
|
processDefinition.getCode(), insertVersion, taskRelationList, taskDefinitionLogs); |
|
|
|
if (insertResult > 0) { |
|
|
|
if (insertResult == Constants.EXIT_CODE_SUCCESS) { |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
result.put(Constants.DATA_LIST, processDefinition); |
|
|
|
result.put(Constants.DATA_LIST, processDefinition); |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -1286,7 +1299,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
processDefinition.setName(processDefinition.getName() + "_copy_" + DateUtils.getCurrentTimeStamp()); |
|
|
|
processDefinition.setName(processDefinition.getName() + "_copy_" + DateUtils.getCurrentTimeStamp()); |
|
|
|
createProcessDefine(loginUser, result, taskRelationList, processDefinition, Lists.newArrayList()); |
|
|
|
createProcessDefine(loginUser, result, taskRelationList, processDefinition, Lists.newArrayList()); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
updateProcessDefine(loginUser, result, taskRelationList, processDefinition, Lists.newArrayList()); |
|
|
|
updateProcessDefine(loginUser, result, taskRelationList, processDefinition, null, Lists.newArrayList()); |
|
|
|
} |
|
|
|
} |
|
|
|
if (result.get(Constants.STATUS) != Status.SUCCESS) { |
|
|
|
if (result.get(Constants.STATUS) != Status.SUCCESS) { |
|
|
|
failedProcessList.add(processDefinition.getCode() + "[" + processDefinition.getName() + "]"); |
|
|
|
failedProcessList.add(processDefinition.getCode() + "[" + processDefinition.getName() + "]"); |
|
|
|