|
|
@ -156,9 +156,8 @@ import javax.servlet.ServletOutputStream; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
|
|
|
|
import lombok.NonNull; |
|
|
|
import lombok.NonNull; |
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
|
|
|
|
|
|
import org.slf4j.Logger; |
|
|
|
|
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.context.annotation.Lazy; |
|
|
|
import org.springframework.context.annotation.Lazy; |
|
|
|
import org.springframework.http.MediaType; |
|
|
|
import org.springframework.http.MediaType; |
|
|
@ -177,10 +176,9 @@ import com.google.common.collect.Lists; |
|
|
|
* process definition service impl |
|
|
|
* process definition service impl |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
@Service |
|
|
|
|
|
|
|
@Slf4j |
|
|
|
public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements ProcessDefinitionService { |
|
|
|
public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements ProcessDefinitionService { |
|
|
|
|
|
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(ProcessDefinitionServiceImpl.class); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final String RELEASESTATE = "releaseState"; |
|
|
|
private static final String RELEASESTATE = "releaseState"; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
@ -292,13 +290,13 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
if (checkDescriptionLength(description)) { |
|
|
|
if (checkDescriptionLength(description)) { |
|
|
|
logger.warn("Parameter description is too long."); |
|
|
|
log.warn("Parameter description is too long."); |
|
|
|
throw new ServiceException(Status.DESCRIPTION_TOO_LONG_ERROR); |
|
|
|
throw new ServiceException(Status.DESCRIPTION_TOO_LONG_ERROR); |
|
|
|
} |
|
|
|
} |
|
|
|
// check whether the new process define name exist
|
|
|
|
// check whether the new process define name exist
|
|
|
|
ProcessDefinition definition = processDefinitionMapper.verifyByDefineName(project.getCode(), name); |
|
|
|
ProcessDefinition definition = processDefinitionMapper.verifyByDefineName(project.getCode(), name); |
|
|
|
if (definition != null) { |
|
|
|
if (definition != null) { |
|
|
|
logger.warn("Process definition with the same name {} already exists, processDefinitionCode:{}.", |
|
|
|
log.warn("Process definition with the same name {} already exists, processDefinitionCode:{}.", |
|
|
|
definition.getName(), definition.getCode()); |
|
|
|
definition.getName(), definition.getCode()); |
|
|
|
throw new ServiceException(Status.PROCESS_DEFINITION_NAME_EXIST, name); |
|
|
|
throw new ServiceException(Status.PROCESS_DEFINITION_NAME_EXIST, name); |
|
|
|
} |
|
|
|
} |
|
|
@ -308,7 +306,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
if (!Constants.DEFAULT.equals(tenantCode)) { |
|
|
|
if (!Constants.DEFAULT.equals(tenantCode)) { |
|
|
|
Tenant tenant = tenantMapper.queryByTenantCode(tenantCode); |
|
|
|
Tenant tenant = tenantMapper.queryByTenantCode(tenantCode); |
|
|
|
if (tenant == null) { |
|
|
|
if (tenant == null) { |
|
|
|
logger.error("Tenant does not exist."); |
|
|
|
log.error("Tenant does not exist."); |
|
|
|
throw new ServiceException(Status.TENANT_NOT_EXIST); |
|
|
|
throw new ServiceException(Status.TENANT_NOT_EXIST); |
|
|
|
} |
|
|
|
} |
|
|
|
tenantId = tenant.getId(); |
|
|
|
tenantId = tenant.getId(); |
|
|
@ -406,29 +404,29 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
int saveTaskResult = processService.saveTaskDefine(loginUser, processDefinition.getProjectCode(), |
|
|
|
int saveTaskResult = processService.saveTaskDefine(loginUser, processDefinition.getProjectCode(), |
|
|
|
taskDefinitionLogs, Boolean.TRUE); |
|
|
|
taskDefinitionLogs, Boolean.TRUE); |
|
|
|
if (saveTaskResult == Constants.EXIT_CODE_SUCCESS) { |
|
|
|
if (saveTaskResult == Constants.EXIT_CODE_SUCCESS) { |
|
|
|
logger.info("The task has not changed, so skip"); |
|
|
|
log.info("The task has not changed, so skip"); |
|
|
|
} |
|
|
|
} |
|
|
|
if (saveTaskResult == Constants.DEFINITION_FAILURE) { |
|
|
|
if (saveTaskResult == Constants.DEFINITION_FAILURE) { |
|
|
|
logger.error("Save task definition error."); |
|
|
|
log.error("Save task definition error."); |
|
|
|
throw new ServiceException(Status.CREATE_TASK_DEFINITION_ERROR); |
|
|
|
throw new ServiceException(Status.CREATE_TASK_DEFINITION_ERROR); |
|
|
|
} |
|
|
|
} |
|
|
|
int insertVersion = processService.saveProcessDefine(loginUser, processDefinition, Boolean.TRUE, Boolean.TRUE); |
|
|
|
int insertVersion = processService.saveProcessDefine(loginUser, processDefinition, Boolean.TRUE, Boolean.TRUE); |
|
|
|
if (insertVersion == 0) { |
|
|
|
if (insertVersion == 0) { |
|
|
|
logger.error("Save process definition error, processCode:{}.", processDefinition.getCode()); |
|
|
|
log.error("Save process definition error, processCode:{}.", processDefinition.getCode()); |
|
|
|
throw new ServiceException(Status.CREATE_PROCESS_DEFINITION_ERROR); |
|
|
|
throw new ServiceException(Status.CREATE_PROCESS_DEFINITION_ERROR); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
logger.info("Save process definition complete, processCode:{}, processVersion:{}.", |
|
|
|
log.info("Save process definition complete, processCode:{}, processVersion:{}.", |
|
|
|
processDefinition.getCode(), insertVersion); |
|
|
|
processDefinition.getCode(), insertVersion); |
|
|
|
} |
|
|
|
} |
|
|
|
int insertResult = processService.saveTaskRelation(loginUser, processDefinition.getProjectCode(), |
|
|
|
int insertResult = processService.saveTaskRelation(loginUser, processDefinition.getProjectCode(), |
|
|
|
processDefinition.getCode(), |
|
|
|
processDefinition.getCode(), |
|
|
|
insertVersion, taskRelationList, taskDefinitionLogs, Boolean.TRUE); |
|
|
|
insertVersion, taskRelationList, taskDefinitionLogs, Boolean.TRUE); |
|
|
|
if (insertResult != Constants.EXIT_CODE_SUCCESS) { |
|
|
|
if (insertResult != Constants.EXIT_CODE_SUCCESS) { |
|
|
|
logger.error("Save process task relations error, projectCode:{}, processCode:{}, processVersion:{}.", |
|
|
|
log.error("Save process task relations error, projectCode:{}, processCode:{}, processVersion:{}.", |
|
|
|
processDefinition.getProjectCode(), processDefinition.getCode(), insertVersion); |
|
|
|
processDefinition.getProjectCode(), processDefinition.getCode(), insertVersion); |
|
|
|
throw new ServiceException(Status.CREATE_PROCESS_TASK_RELATION_ERROR); |
|
|
|
throw new ServiceException(Status.CREATE_PROCESS_TASK_RELATION_ERROR); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
logger.info("Save process task relations complete, projectCode:{}, processCode:{}, processVersion:{}.", |
|
|
|
log.info("Save process task relations complete, projectCode:{}, processCode:{}, processVersion:{}.", |
|
|
|
processDefinition.getProjectCode(), processDefinition.getCode(), insertVersion); |
|
|
|
processDefinition.getProjectCode(), processDefinition.getCode(), insertVersion); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -443,7 +441,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
try { |
|
|
|
try { |
|
|
|
List<TaskDefinitionLog> taskDefinitionLogs = JSONUtils.toList(taskDefinitionJson, TaskDefinitionLog.class); |
|
|
|
List<TaskDefinitionLog> taskDefinitionLogs = JSONUtils.toList(taskDefinitionJson, TaskDefinitionLog.class); |
|
|
|
if (CollectionUtils.isEmpty(taskDefinitionLogs)) { |
|
|
|
if (CollectionUtils.isEmpty(taskDefinitionLogs)) { |
|
|
|
logger.error("Generate task definition list failed, the given taskDefinitionJson is invalided: {}", |
|
|
|
log.error("Generate task definition list failed, the given taskDefinitionJson is invalided: {}", |
|
|
|
taskDefinitionJson); |
|
|
|
taskDefinitionJson); |
|
|
|
throw new ServiceException(Status.DATA_IS_NOT_VALID, taskDefinitionJson); |
|
|
|
throw new ServiceException(Status.DATA_IS_NOT_VALID, taskDefinitionJson); |
|
|
|
} |
|
|
|
} |
|
|
@ -453,7 +451,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
.taskParams(taskDefinitionLog.getTaskParams()) |
|
|
|
.taskParams(taskDefinitionLog.getTaskParams()) |
|
|
|
.dependence(taskDefinitionLog.getDependence()) |
|
|
|
.dependence(taskDefinitionLog.getDependence()) |
|
|
|
.build())) { |
|
|
|
.build())) { |
|
|
|
logger.error( |
|
|
|
log.error( |
|
|
|
"Generate task definition list failed, the given task definition parameter is invalided, taskName: {}, taskDefinition: {}", |
|
|
|
"Generate task definition list failed, the given task definition parameter is invalided, taskName: {}, taskDefinition: {}", |
|
|
|
taskDefinitionLog.getName(), taskDefinitionLog); |
|
|
|
taskDefinitionLog.getName(), taskDefinitionLog); |
|
|
|
throw new ServiceException(Status.PROCESS_NODE_S_PARAMETER_INVALID, taskDefinitionLog.getName()); |
|
|
|
throw new ServiceException(Status.PROCESS_NODE_S_PARAMETER_INVALID, taskDefinitionLog.getName()); |
|
|
@ -463,7 +461,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
} catch (ServiceException ex) { |
|
|
|
} catch (ServiceException ex) { |
|
|
|
throw ex; |
|
|
|
throw ex; |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("Generate task definition list failed, meet an unknown exception", e); |
|
|
|
log.error("Generate task definition list failed, meet an unknown exception", e); |
|
|
|
throw new ServiceException(Status.REQUEST_PARAMS_NOT_VALID_ERROR); |
|
|
|
throw new ServiceException(Status.REQUEST_PARAMS_NOT_VALID_ERROR); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -474,7 +472,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
List<ProcessTaskRelationLog> taskRelationList = |
|
|
|
List<ProcessTaskRelationLog> taskRelationList = |
|
|
|
JSONUtils.toList(taskRelationJson, ProcessTaskRelationLog.class); |
|
|
|
JSONUtils.toList(taskRelationJson, ProcessTaskRelationLog.class); |
|
|
|
if (CollectionUtils.isEmpty(taskRelationList)) { |
|
|
|
if (CollectionUtils.isEmpty(taskRelationList)) { |
|
|
|
logger.error("Generate task relation list failed the taskRelation list is empty, taskRelationJson: {}", |
|
|
|
log.error("Generate task relation list failed the taskRelation list is empty, taskRelationJson: {}", |
|
|
|
taskRelationJson); |
|
|
|
taskRelationJson); |
|
|
|
throw new ServiceException(Status.DATA_IS_NOT_VALID); |
|
|
|
throw new ServiceException(Status.DATA_IS_NOT_VALID); |
|
|
|
} |
|
|
|
} |
|
|
@ -490,19 +488,19 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
Collection<Long> codes = CollectionUtils.subtract(postTaskCodes, taskNodeCodes); |
|
|
|
Collection<Long> codes = CollectionUtils.subtract(postTaskCodes, taskNodeCodes); |
|
|
|
if (CollectionUtils.isNotEmpty(codes)) { |
|
|
|
if (CollectionUtils.isNotEmpty(codes)) { |
|
|
|
String taskCodes = StringUtils.join(codes, Constants.COMMA); |
|
|
|
String taskCodes = StringUtils.join(codes, Constants.COMMA); |
|
|
|
logger.error("Task definitions do not exist, taskCodes:{}.", taskCodes); |
|
|
|
log.error("Task definitions do not exist, taskCodes:{}.", taskCodes); |
|
|
|
throw new ServiceException(Status.TASK_DEFINE_NOT_EXIST, taskCodes); |
|
|
|
throw new ServiceException(Status.TASK_DEFINE_NOT_EXIST, taskCodes); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (graphHasCycle(taskNodeList)) { |
|
|
|
if (graphHasCycle(taskNodeList)) { |
|
|
|
logger.error("Process DAG has cycle."); |
|
|
|
log.error("Process DAG has cycle."); |
|
|
|
throw new ServiceException(Status.PROCESS_NODE_HAS_CYCLE); |
|
|
|
throw new ServiceException(Status.PROCESS_NODE_HAS_CYCLE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// check whether the task relation json is normal
|
|
|
|
// check whether the task relation json is normal
|
|
|
|
for (ProcessTaskRelationLog processTaskRelationLog : taskRelationList) { |
|
|
|
for (ProcessTaskRelationLog processTaskRelationLog : taskRelationList) { |
|
|
|
if (processTaskRelationLog.getPostTaskCode() == 0) { |
|
|
|
if (processTaskRelationLog.getPostTaskCode() == 0) { |
|
|
|
logger.error("The post_task_code or post_task_version of processTaskRelationLog can not be zero, " + |
|
|
|
log.error("The post_task_code or post_task_version of processTaskRelationLog can not be zero, " + |
|
|
|
"processTaskRelationLogId:{}.", processTaskRelationLog.getId()); |
|
|
|
"processTaskRelationLogId:{}.", processTaskRelationLog.getId()); |
|
|
|
throw new ServiceException(Status.CHECK_PROCESS_TASK_RELATION_ERROR); |
|
|
|
throw new ServiceException(Status.CHECK_PROCESS_TASK_RELATION_ERROR); |
|
|
|
} |
|
|
|
} |
|
|
@ -511,7 +509,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
} catch (ServiceException ex) { |
|
|
|
} catch (ServiceException ex) { |
|
|
|
throw ex; |
|
|
|
throw ex; |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("Check task relation list error, meet an unknown exception, given taskRelationJson: {}", |
|
|
|
log.error("Check task relation list error, meet an unknown exception, given taskRelationJson: {}", |
|
|
|
taskRelationJson, e); |
|
|
|
taskRelationJson, e); |
|
|
|
throw new ServiceException(Status.REQUEST_PARAMS_NOT_VALID_ERROR); |
|
|
|
throw new ServiceException(Status.REQUEST_PARAMS_NOT_VALID_ERROR); |
|
|
|
} |
|
|
|
} |
|
|
@ -686,7 +684,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
|
|
|
|
|
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code); |
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code); |
|
|
|
if (processDefinition == null || projectCode != processDefinition.getProjectCode()) { |
|
|
|
if (processDefinition == null || projectCode != processDefinition.getProjectCode()) { |
|
|
|
logger.error("Process definition does not exist, processCode:{}.", code); |
|
|
|
log.error("Process definition does not exist, processCode:{}.", code); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, String.valueOf(code)); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, String.valueOf(code)); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
Tenant tenant = tenantMapper.queryById(processDefinition.getTenantId()); |
|
|
|
Tenant tenant = tenantMapper.queryById(processDefinition.getTenantId()); |
|
|
@ -738,7 +736,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.queryByDefineName(projectCode, name); |
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.queryByDefineName(projectCode, name); |
|
|
|
|
|
|
|
|
|
|
|
if (processDefinition == null) { |
|
|
|
if (processDefinition == null) { |
|
|
|
logger.error("Process definition does not exist, projectCode:{}.", projectCode); |
|
|
|
log.error("Process definition does not exist, projectCode:{}.", projectCode); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, name); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, name); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
DagData dagData = processService.genDagData(processDefinition); |
|
|
|
DagData dagData = processService.genDagData(processDefinition); |
|
|
@ -790,7 +788,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (checkDescriptionLength(description)) { |
|
|
|
if (checkDescriptionLength(description)) { |
|
|
|
logger.warn("Parameter description is too long."); |
|
|
|
log.warn("Parameter description is too long."); |
|
|
|
putMsg(result, Status.DESCRIPTION_TOO_LONG_ERROR); |
|
|
|
putMsg(result, Status.DESCRIPTION_TOO_LONG_ERROR); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -801,7 +799,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
if (!Constants.DEFAULT.equals(tenantCode)) { |
|
|
|
if (!Constants.DEFAULT.equals(tenantCode)) { |
|
|
|
Tenant tenant = tenantMapper.queryByTenantCode(tenantCode); |
|
|
|
Tenant tenant = tenantMapper.queryByTenantCode(tenantCode); |
|
|
|
if (tenant == null) { |
|
|
|
if (tenant == null) { |
|
|
|
logger.error("Tenant does not exist."); |
|
|
|
log.error("Tenant does not exist."); |
|
|
|
putMsg(result, Status.TENANT_NOT_EXIST); |
|
|
|
putMsg(result, Status.TENANT_NOT_EXIST); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -811,13 +809,13 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code); |
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code); |
|
|
|
// check process definition exists
|
|
|
|
// check process definition exists
|
|
|
|
if (processDefinition == null || projectCode != processDefinition.getProjectCode()) { |
|
|
|
if (processDefinition == null || projectCode != processDefinition.getProjectCode()) { |
|
|
|
logger.error("Process definition does not exist, processCode:{}.", code); |
|
|
|
log.error("Process definition does not exist, processCode:{}.", code); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, String.valueOf(code)); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, String.valueOf(code)); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
if (processDefinition.getReleaseState() == ReleaseState.ONLINE) { |
|
|
|
if (processDefinition.getReleaseState() == ReleaseState.ONLINE) { |
|
|
|
// online can not permit edit
|
|
|
|
// online can not permit edit
|
|
|
|
logger.warn("Process definition is not allowed to be modified due to {}, processDefinitionCode:{}.", |
|
|
|
log.warn("Process definition is not allowed to be modified due to {}, processDefinitionCode:{}.", |
|
|
|
ReleaseState.ONLINE.getDescp(), processDefinition.getCode()); |
|
|
|
ReleaseState.ONLINE.getDescp(), processDefinition.getCode()); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_ALLOWED_EDIT, processDefinition.getName()); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_ALLOWED_EDIT, processDefinition.getName()); |
|
|
|
return result; |
|
|
|
return result; |
|
|
@ -826,7 +824,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
// check whether the new process define name exist
|
|
|
|
// check whether the new process define name exist
|
|
|
|
ProcessDefinition definition = processDefinitionMapper.verifyByDefineName(project.getCode(), name); |
|
|
|
ProcessDefinition definition = processDefinitionMapper.verifyByDefineName(project.getCode(), name); |
|
|
|
if (definition != null) { |
|
|
|
if (definition != null) { |
|
|
|
logger.warn("Process definition with the same name already exists, processDefinitionCode:{}.", |
|
|
|
log.warn("Process definition with the same name already exists, processDefinitionCode:{}.", |
|
|
|
definition.getCode()); |
|
|
|
definition.getCode()); |
|
|
|
putMsg(result, Status.PROCESS_DEFINITION_NAME_EXIST, name); |
|
|
|
putMsg(result, Status.PROCESS_DEFINITION_NAME_EXIST, name); |
|
|
|
return result; |
|
|
|
return result; |
|
|
@ -865,7 +863,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
taskDepMsg.ifPresent(sb::append); |
|
|
|
taskDepMsg.ifPresent(sb::append); |
|
|
|
} |
|
|
|
} |
|
|
|
if (sb.length() != 0) { |
|
|
|
if (sb.length() != 0) { |
|
|
|
logger.error("Task cannot be deleted because it is dependent"); |
|
|
|
log.error("Task cannot be deleted because it is dependent"); |
|
|
|
throw new ServiceException(sb.toString()); |
|
|
|
throw new ServiceException(sb.toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -881,10 +879,10 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
int saveTaskResult = processService.saveTaskDefine(loginUser, processDefinition.getProjectCode(), |
|
|
|
int saveTaskResult = processService.saveTaskDefine(loginUser, processDefinition.getProjectCode(), |
|
|
|
taskDefinitionLogs, Boolean.TRUE); |
|
|
|
taskDefinitionLogs, Boolean.TRUE); |
|
|
|
if (saveTaskResult == Constants.EXIT_CODE_SUCCESS) { |
|
|
|
if (saveTaskResult == Constants.EXIT_CODE_SUCCESS) { |
|
|
|
logger.info("The task has not changed, so skip"); |
|
|
|
log.info("The task has not changed, so skip"); |
|
|
|
} |
|
|
|
} |
|
|
|
if (saveTaskResult == Constants.DEFINITION_FAILURE) { |
|
|
|
if (saveTaskResult == Constants.DEFINITION_FAILURE) { |
|
|
|
logger.error("Update task definitions error, projectCode:{}, processCode:{}.", |
|
|
|
log.error("Update task definitions error, projectCode:{}, processCode:{}.", |
|
|
|
processDefinition.getProjectCode(), processDefinition.getCode()); |
|
|
|
processDefinition.getProjectCode(), processDefinition.getCode()); |
|
|
|
putMsg(result, Status.UPDATE_TASK_DEFINITION_ERROR); |
|
|
|
putMsg(result, Status.UPDATE_TASK_DEFINITION_ERROR); |
|
|
|
throw new ServiceException(Status.UPDATE_TASK_DEFINITION_ERROR); |
|
|
|
throw new ServiceException(Status.UPDATE_TASK_DEFINITION_ERROR); |
|
|
@ -911,17 +909,17 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
isChange = true; |
|
|
|
isChange = true; |
|
|
|
} |
|
|
|
} |
|
|
|
if (isChange) { |
|
|
|
if (isChange) { |
|
|
|
logger.info("Process definition needs to be updated, projectCode:{}, processCode:{}, processVersion:{}.", |
|
|
|
log.info("Process definition needs to be updated, projectCode:{}, processCode:{}, processVersion:{}.", |
|
|
|
processDefinition.getProjectCode(), processDefinition.getCode(), processDefinition.getVersion()); |
|
|
|
processDefinition.getProjectCode(), processDefinition.getCode(), processDefinition.getVersion()); |
|
|
|
processDefinition.setUpdateTime(new Date()); |
|
|
|
processDefinition.setUpdateTime(new Date()); |
|
|
|
int insertVersion = |
|
|
|
int insertVersion = |
|
|
|
processService.saveProcessDefine(loginUser, processDefinition, Boolean.TRUE, Boolean.TRUE); |
|
|
|
processService.saveProcessDefine(loginUser, processDefinition, Boolean.TRUE, Boolean.TRUE); |
|
|
|
if (insertVersion <= 0) { |
|
|
|
if (insertVersion <= 0) { |
|
|
|
logger.error("Update process definition error, processCode:{}.", processDefinition.getCode()); |
|
|
|
log.error("Update process definition error, processCode:{}.", processDefinition.getCode()); |
|
|
|
putMsg(result, Status.UPDATE_PROCESS_DEFINITION_ERROR); |
|
|
|
putMsg(result, Status.UPDATE_PROCESS_DEFINITION_ERROR); |
|
|
|
throw new ServiceException(Status.UPDATE_PROCESS_DEFINITION_ERROR); |
|
|
|
throw new ServiceException(Status.UPDATE_PROCESS_DEFINITION_ERROR); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
logger.info("Update process definition complete, processCode:{}, processVersion:{}.", |
|
|
|
log.info("Update process definition complete, processCode:{}, processVersion:{}.", |
|
|
|
processDefinition.getCode(), insertVersion); |
|
|
|
processDefinition.getCode(), insertVersion); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -929,20 +927,20 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
int insertResult = processService.saveTaskRelation(loginUser, processDefinition.getProjectCode(), |
|
|
|
int insertResult = processService.saveTaskRelation(loginUser, processDefinition.getProjectCode(), |
|
|
|
processDefinition.getCode(), insertVersion, taskRelationList, taskDefinitionLogs, Boolean.TRUE); |
|
|
|
processDefinition.getCode(), insertVersion, taskRelationList, taskDefinitionLogs, Boolean.TRUE); |
|
|
|
if (insertResult == Constants.EXIT_CODE_SUCCESS) { |
|
|
|
if (insertResult == Constants.EXIT_CODE_SUCCESS) { |
|
|
|
logger.info( |
|
|
|
log.info( |
|
|
|
"Update process task relations complete, projectCode:{}, processCode:{}, processVersion:{}.", |
|
|
|
"Update process task relations complete, projectCode:{}, processCode:{}, processVersion:{}.", |
|
|
|
processDefinition.getProjectCode(), processDefinition.getCode(), insertVersion); |
|
|
|
processDefinition.getProjectCode(), processDefinition.getCode(), insertVersion); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
result.put(Constants.DATA_LIST, processDefinition); |
|
|
|
result.put(Constants.DATA_LIST, processDefinition); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
logger.error("Update process task relations error, projectCode:{}, processCode:{}, processVersion:{}.", |
|
|
|
log.error("Update process task relations error, projectCode:{}, processCode:{}, processVersion:{}.", |
|
|
|
processDefinition.getProjectCode(), processDefinition.getCode(), insertVersion); |
|
|
|
processDefinition.getProjectCode(), processDefinition.getCode(), insertVersion); |
|
|
|
putMsg(result, Status.UPDATE_PROCESS_DEFINITION_ERROR); |
|
|
|
putMsg(result, Status.UPDATE_PROCESS_DEFINITION_ERROR); |
|
|
|
throw new ServiceException(Status.UPDATE_PROCESS_DEFINITION_ERROR); |
|
|
|
throw new ServiceException(Status.UPDATE_PROCESS_DEFINITION_ERROR); |
|
|
|
} |
|
|
|
} |
|
|
|
saveOtherRelation(loginUser, processDefinition, result, otherParamsJson); |
|
|
|
saveOtherRelation(loginUser, processDefinition, result, otherParamsJson); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
logger.info( |
|
|
|
log.info( |
|
|
|
"Process definition does not need to be updated because there is no change, projectCode:{}, processCode:{}, processVersion:{}.", |
|
|
|
"Process definition does not need to be updated because there is no change, projectCode:{}, processCode:{}, processVersion:{}.", |
|
|
|
processDefinition.getProjectCode(), processDefinition.getCode(), processDefinition.getVersion()); |
|
|
|
processDefinition.getProjectCode(), processDefinition.getCode(), processDefinition.getVersion()); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
@ -979,7 +977,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
logger.warn("Process definition with the same name {} already exists, processDefinitionCode:{}.", |
|
|
|
log.warn("Process definition with the same name {} already exists, processDefinitionCode:{}.", |
|
|
|
processDefinition.getName(), processDefinition.getCode()); |
|
|
|
processDefinition.getName(), processDefinition.getCode()); |
|
|
|
putMsg(result, Status.PROCESS_DEFINITION_NAME_EXIST, name.trim()); |
|
|
|
putMsg(result, Status.PROCESS_DEFINITION_NAME_EXIST, name.trim()); |
|
|
|
return result; |
|
|
|
return result; |
|
|
@ -990,7 +988,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
public Map<String, Object> batchDeleteProcessDefinitionByCodes(User loginUser, long projectCode, String codes) { |
|
|
|
public Map<String, Object> batchDeleteProcessDefinitionByCodes(User loginUser, long projectCode, String codes) { |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
if (StringUtils.isEmpty(codes)) { |
|
|
|
if (StringUtils.isEmpty(codes)) { |
|
|
|
logger.error("Parameter processDefinitionCodes is empty, projectCode is {}.", projectCode); |
|
|
|
log.error("Parameter processDefinitionCodes is empty, projectCode is {}.", projectCode); |
|
|
|
putMsg(result, Status.PROCESS_DEFINITION_CODES_IS_EMPTY); |
|
|
|
putMsg(result, Status.PROCESS_DEFINITION_CODES_IS_EMPTY); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -1005,7 +1003,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
definitionCodes.stream().filter(code -> !queryCodes.contains(code)).collect(Collectors.toSet()); |
|
|
|
definitionCodes.stream().filter(code -> !queryCodes.contains(code)).collect(Collectors.toSet()); |
|
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(diffCode)) { |
|
|
|
if (CollectionUtils.isNotEmpty(diffCode)) { |
|
|
|
logger.error("Process definition does not exist, processCodes:{}.", |
|
|
|
log.error("Process definition does not exist, processCodes:{}.", |
|
|
|
diffCode.stream().map(String::valueOf).collect(Collectors.joining(Constants.COMMA))); |
|
|
|
diffCode.stream().map(String::valueOf).collect(Collectors.joining(Constants.COMMA))); |
|
|
|
throw new ServiceException(Status.BATCH_DELETE_PROCESS_DEFINE_BY_CODES_ERROR, |
|
|
|
throw new ServiceException(Status.BATCH_DELETE_PROCESS_DEFINE_BY_CODES_ERROR, |
|
|
|
diffCode.stream().map(code -> code + "[process definition not exist]") |
|
|
|
diffCode.stream().map(code -> code + "[process definition not exist]") |
|
|
@ -1099,7 +1097,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
// we delete the workflow definition at last to avoid using transaction here.
|
|
|
|
// we delete the workflow definition at last to avoid using transaction here.
|
|
|
|
// If delete error, we can call this interface again.
|
|
|
|
// If delete error, we can call this interface again.
|
|
|
|
processDefinitionDao.deleteByWorkflowDefinitionCode(processDefinition.getCode()); |
|
|
|
processDefinitionDao.deleteByWorkflowDefinitionCode(processDefinition.getCode()); |
|
|
|
logger.info("Success delete workflow definition workflowDefinitionCode: {}", code); |
|
|
|
log.info("Success delete workflow definition workflowDefinitionCode: {}", code); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -1131,7 +1129,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
|
|
|
|
|
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code); |
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code); |
|
|
|
if (processDefinition == null || projectCode != processDefinition.getProjectCode()) { |
|
|
|
if (processDefinition == null || projectCode != processDefinition.getProjectCode()) { |
|
|
|
logger.error("Process definition does not exist, processDefinitionCode:{}.", code); |
|
|
|
log.error("Process definition does not exist, processDefinitionCode:{}.", code); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, String.valueOf(code)); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, String.valueOf(code)); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -1140,13 +1138,13 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
List<ProcessTaskRelation> relationList = |
|
|
|
List<ProcessTaskRelation> relationList = |
|
|
|
processService.findRelationByCode(code, processDefinition.getVersion()); |
|
|
|
processService.findRelationByCode(code, processDefinition.getVersion()); |
|
|
|
if (CollectionUtils.isEmpty(relationList)) { |
|
|
|
if (CollectionUtils.isEmpty(relationList)) { |
|
|
|
logger.warn("Process definition has no task relation, processDefinitionCode:{}.", code); |
|
|
|
log.warn("Process definition has no task relation, processDefinitionCode:{}.", code); |
|
|
|
putMsg(result, Status.PROCESS_DAG_IS_EMPTY); |
|
|
|
putMsg(result, Status.PROCESS_DAG_IS_EMPTY); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
processDefinition.setReleaseState(releaseState); |
|
|
|
processDefinition.setReleaseState(releaseState); |
|
|
|
processDefinitionMapper.updateById(processDefinition); |
|
|
|
processDefinitionMapper.updateById(processDefinition); |
|
|
|
logger.info("Set process definition online, projectCode:{}, processDefinitionCode:{}.", projectCode, |
|
|
|
log.info("Set process definition online, projectCode:{}, processDefinitionCode:{}.", projectCode, |
|
|
|
code); |
|
|
|
code); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case OFFLINE: |
|
|
|
case OFFLINE: |
|
|
@ -1154,20 +1152,20 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
int updateProcess = processDefinitionMapper.updateById(processDefinition); |
|
|
|
int updateProcess = processDefinitionMapper.updateById(processDefinition); |
|
|
|
Schedule schedule = scheduleMapper.queryByProcessDefinitionCode(code); |
|
|
|
Schedule schedule = scheduleMapper.queryByProcessDefinitionCode(code); |
|
|
|
if (updateProcess > 0) { |
|
|
|
if (updateProcess > 0) { |
|
|
|
logger.info("Set process definition offline, projectCode:{}, processDefinitionCode:{}.", |
|
|
|
log.info("Set process definition offline, projectCode:{}, processDefinitionCode:{}.", |
|
|
|
projectCode, code); |
|
|
|
projectCode, code); |
|
|
|
if (schedule != null) { |
|
|
|
if (schedule != null) { |
|
|
|
// set status
|
|
|
|
// set status
|
|
|
|
schedule.setReleaseState(releaseState); |
|
|
|
schedule.setReleaseState(releaseState); |
|
|
|
int updateSchedule = scheduleMapper.updateById(schedule); |
|
|
|
int updateSchedule = scheduleMapper.updateById(schedule); |
|
|
|
if (updateSchedule == 0) { |
|
|
|
if (updateSchedule == 0) { |
|
|
|
logger.error( |
|
|
|
log.error( |
|
|
|
"Set schedule offline error, projectCode:{}, processDefinitionCode:{}, scheduleId:{}", |
|
|
|
"Set schedule offline error, projectCode:{}, processDefinitionCode:{}, scheduleId:{}", |
|
|
|
projectCode, code, schedule.getId()); |
|
|
|
projectCode, code, schedule.getId()); |
|
|
|
putMsg(result, Status.OFFLINE_SCHEDULE_ERROR); |
|
|
|
putMsg(result, Status.OFFLINE_SCHEDULE_ERROR); |
|
|
|
throw new ServiceException(Status.OFFLINE_SCHEDULE_ERROR); |
|
|
|
throw new ServiceException(Status.OFFLINE_SCHEDULE_ERROR); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
logger.info("Set schedule offline, projectCode:{}, processDefinitionCode:{}, scheduleId:{}", |
|
|
|
log.info("Set schedule offline, projectCode:{}, processDefinitionCode:{}, scheduleId:{}", |
|
|
|
projectCode, code, schedule.getId()); |
|
|
|
projectCode, code, schedule.getId()); |
|
|
|
} |
|
|
|
} |
|
|
|
schedulerService.deleteSchedule(project.getId(), schedule.getId()); |
|
|
|
schedulerService.deleteSchedule(project.getId(), schedule.getId()); |
|
|
@ -1190,7 +1188,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
public void batchExportProcessDefinitionByCodes(User loginUser, long projectCode, String codes, |
|
|
|
public void batchExportProcessDefinitionByCodes(User loginUser, long projectCode, String codes, |
|
|
|
HttpServletResponse response) { |
|
|
|
HttpServletResponse response) { |
|
|
|
if (StringUtils.isEmpty(codes)) { |
|
|
|
if (StringUtils.isEmpty(codes)) { |
|
|
|
logger.warn("Process definition codes to be exported is empty."); |
|
|
|
log.warn("Process definition codes to be exported is empty."); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
Project project = projectMapper.queryByCode(projectCode); |
|
|
|
Project project = projectMapper.queryByCode(projectCode); |
|
|
@ -1204,7 +1202,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
.collect(Collectors.toSet()); |
|
|
|
.collect(Collectors.toSet()); |
|
|
|
List<ProcessDefinition> processDefinitionList = processDefinitionMapper.queryByCodes(defineCodeSet); |
|
|
|
List<ProcessDefinition> processDefinitionList = processDefinitionMapper.queryByCodes(defineCodeSet); |
|
|
|
if (CollectionUtils.isEmpty(processDefinitionList)) { |
|
|
|
if (CollectionUtils.isEmpty(processDefinitionList)) { |
|
|
|
logger.error("Process definitions to be exported do not exist, processDefinitionCodes:{}.", defineCodeSet); |
|
|
|
log.error("Process definitions to be exported do not exist, processDefinitionCodes:{}.", defineCodeSet); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
// check processDefinition exist in project
|
|
|
|
// check processDefinition exist in project
|
|
|
@ -1213,10 +1211,10 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
List<DagDataSchedule> dagDataSchedules = |
|
|
|
List<DagDataSchedule> dagDataSchedules = |
|
|
|
processDefinitionListInProject.stream().map(this::exportProcessDagData).collect(Collectors.toList()); |
|
|
|
processDefinitionListInProject.stream().map(this::exportProcessDagData).collect(Collectors.toList()); |
|
|
|
if (CollectionUtils.isNotEmpty(dagDataSchedules)) { |
|
|
|
if (CollectionUtils.isNotEmpty(dagDataSchedules)) { |
|
|
|
logger.info("Start download process definition file, processDefinitionCodes:{}.", defineCodeSet); |
|
|
|
log.info("Start download process definition file, processDefinitionCodes:{}.", defineCodeSet); |
|
|
|
downloadProcessDefinitionFile(response, dagDataSchedules); |
|
|
|
downloadProcessDefinitionFile(response, dagDataSchedules); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
logger.error("There is no exported process dag data."); |
|
|
|
log.error("There is no exported process dag data."); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1234,20 +1232,20 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
buff.flush(); |
|
|
|
buff.flush(); |
|
|
|
buff.close(); |
|
|
|
buff.close(); |
|
|
|
} catch (IOException e) { |
|
|
|
} catch (IOException e) { |
|
|
|
logger.warn("Export process definition fail", e); |
|
|
|
log.warn("Export process definition fail", e); |
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
if (null != buff) { |
|
|
|
if (null != buff) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
buff.close(); |
|
|
|
buff.close(); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
logger.warn("Buffer does not close", e); |
|
|
|
log.warn("Buffer does not close", e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (null != out) { |
|
|
|
if (null != out) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
out.close(); |
|
|
|
out.close(); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
logger.warn("Output stream does not close", e); |
|
|
|
log.warn("Output stream does not close", e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1290,7 +1288,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
} |
|
|
|
} |
|
|
|
// check file content
|
|
|
|
// check file content
|
|
|
|
if (CollectionUtils.isEmpty(dagDataScheduleList)) { |
|
|
|
if (CollectionUtils.isEmpty(dagDataScheduleList)) { |
|
|
|
logger.warn("Process definition file content is empty."); |
|
|
|
log.warn("Process definition file content is empty."); |
|
|
|
putMsg(result, Status.DATA_IS_NULL, "fileContent"); |
|
|
|
putMsg(result, Status.DATA_IS_NULL, "fileContent"); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -1408,7 +1406,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
dataSource = queryDatasourceByNameAndUser(datasourceName, loginUser); |
|
|
|
dataSource = queryDatasourceByNameAndUser(datasourceName, loginUser); |
|
|
|
} |
|
|
|
} |
|
|
|
if (dataSource == null) { |
|
|
|
if (dataSource == null) { |
|
|
|
logger.error("Datasource does not found, may be its name is illegal."); |
|
|
|
log.error("Datasource does not found, may be its name is illegal."); |
|
|
|
putMsg(result, Status.DATASOURCE_NAME_ILLEGAL); |
|
|
|
putMsg(result, Status.DATASOURCE_NAME_ILLEGAL); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -1433,7 +1431,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("Import process definition error.", e); |
|
|
|
log.error("Import process definition error.", e); |
|
|
|
putMsg(result, Status.IMPORT_PROCESS_DEFINE_ERROR); |
|
|
|
putMsg(result, Status.IMPORT_PROCESS_DEFINE_ERROR); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -1538,7 +1536,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
try { |
|
|
|
try { |
|
|
|
processDefinition.setCode(CodeGenerateUtils.getInstance().genCode()); |
|
|
|
processDefinition.setCode(CodeGenerateUtils.getInstance().genCode()); |
|
|
|
} catch (CodeGenerateException e) { |
|
|
|
} catch (CodeGenerateException e) { |
|
|
|
logger.error( |
|
|
|
log.error( |
|
|
|
"Save process definition error because generate process definition code error, projectCode:{}.", |
|
|
|
"Save process definition error because generate process definition code error, projectCode:{}.", |
|
|
|
projectCode, e); |
|
|
|
projectCode, e); |
|
|
|
putMsg(result, Status.CREATE_PROCESS_DEFINITION_ERROR); |
|
|
|
putMsg(result, Status.CREATE_PROCESS_DEFINITION_ERROR); |
|
|
@ -1563,7 +1561,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
taskCodeMap.put(taskDefinitionLog.getCode(), code); |
|
|
|
taskCodeMap.put(taskDefinitionLog.getCode(), code); |
|
|
|
taskDefinitionLog.setCode(code); |
|
|
|
taskDefinitionLog.setCode(code); |
|
|
|
} catch (CodeGenerateException e) { |
|
|
|
} catch (CodeGenerateException e) { |
|
|
|
logger.error("Generate task definition code error, projectCode:{}, processDefinitionCode:{}", |
|
|
|
log.error("Generate task definition code error, projectCode:{}, processDefinitionCode:{}", |
|
|
|
projectCode, processDefinition.getCode(), e); |
|
|
|
projectCode, processDefinition.getCode(), e); |
|
|
|
putMsg(result, Status.INTERNAL_SERVER_ERROR_ARGS, "Error generating task definition code"); |
|
|
|
putMsg(result, Status.INTERNAL_SERVER_ERROR_ARGS, "Error generating task definition code"); |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -1573,7 +1571,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
int insert = taskDefinitionMapper.batchInsert(taskDefinitionLogList); |
|
|
|
int insert = taskDefinitionMapper.batchInsert(taskDefinitionLogList); |
|
|
|
int logInsert = taskDefinitionLogMapper.batchInsert(taskDefinitionLogList); |
|
|
|
int logInsert = taskDefinitionLogMapper.batchInsert(taskDefinitionLogList); |
|
|
|
if ((logInsert & insert) == 0) { |
|
|
|
if ((logInsert & insert) == 0) { |
|
|
|
logger.error("Save task definition error, projectCode:{}, processDefinitionCode:{}", projectCode, |
|
|
|
log.error("Save task definition error, projectCode:{}, processDefinitionCode:{}", projectCode, |
|
|
|
processDefinition.getCode()); |
|
|
|
processDefinition.getCode()); |
|
|
|
putMsg(result, Status.CREATE_TASK_DEFINITION_ERROR); |
|
|
|
putMsg(result, Status.CREATE_TASK_DEFINITION_ERROR); |
|
|
|
throw new ServiceException(Status.CREATE_TASK_DEFINITION_ERROR); |
|
|
|
throw new ServiceException(Status.CREATE_TASK_DEFINITION_ERROR); |
|
|
@ -1617,7 +1615,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
putMsg(createDagResult, Status.SUCCESS); |
|
|
|
putMsg(createDagResult, Status.SUCCESS); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
result.putAll(createDagResult); |
|
|
|
result.putAll(createDagResult); |
|
|
|
logger.error("Import process definition error, projectCode:{}, processDefinitionCode:{}.", projectCode, |
|
|
|
log.error("Import process definition error, projectCode:{}, processDefinitionCode:{}.", projectCode, |
|
|
|
processDefinition.getCode()); |
|
|
|
processDefinition.getCode()); |
|
|
|
throw new ServiceException(Status.IMPORT_PROCESS_DEFINE_ERROR); |
|
|
|
throw new ServiceException(Status.IMPORT_PROCESS_DEFINE_ERROR); |
|
|
|
} |
|
|
|
} |
|
|
@ -1631,7 +1629,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
schedule.setUpdateTime(now); |
|
|
|
schedule.setUpdateTime(now); |
|
|
|
int scheduleInsert = scheduleMapper.insert(schedule); |
|
|
|
int scheduleInsert = scheduleMapper.insert(schedule); |
|
|
|
if (0 == scheduleInsert) { |
|
|
|
if (0 == scheduleInsert) { |
|
|
|
logger.error( |
|
|
|
log.error( |
|
|
|
"Import process definition error due to save schedule fail, projectCode:{}, processDefinitionCode:{}.", |
|
|
|
"Import process definition error due to save schedule fail, projectCode:{}, processDefinitionCode:{}.", |
|
|
|
projectCode, processDefinition.getCode()); |
|
|
|
projectCode, processDefinition.getCode()); |
|
|
|
putMsg(result, Status.IMPORT_PROCESS_DEFINE_ERROR); |
|
|
|
putMsg(result, Status.IMPORT_PROCESS_DEFINE_ERROR); |
|
|
@ -1639,7 +1637,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
logger.info("Import process definition complete, projectCode:{}, processDefinitionCode:{}.", projectCode, |
|
|
|
log.info("Import process definition complete, projectCode:{}, processDefinitionCode:{}.", projectCode, |
|
|
|
processDefinition.getCode()); |
|
|
|
processDefinition.getCode()); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
@ -1649,17 +1647,17 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private boolean checkImportanceParams(DagDataSchedule dagDataSchedule, Map<String, Object> result) { |
|
|
|
private boolean checkImportanceParams(DagDataSchedule dagDataSchedule, Map<String, Object> result) { |
|
|
|
if (dagDataSchedule.getProcessDefinition() == null) { |
|
|
|
if (dagDataSchedule.getProcessDefinition() == null) { |
|
|
|
logger.warn("Process definition is null."); |
|
|
|
log.warn("Process definition is null."); |
|
|
|
putMsg(result, Status.DATA_IS_NULL, "ProcessDefinition"); |
|
|
|
putMsg(result, Status.DATA_IS_NULL, "ProcessDefinition"); |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
if (CollectionUtils.isEmpty(dagDataSchedule.getTaskDefinitionList())) { |
|
|
|
if (CollectionUtils.isEmpty(dagDataSchedule.getTaskDefinitionList())) { |
|
|
|
logger.warn("Task definition list is null."); |
|
|
|
log.warn("Task definition list is null."); |
|
|
|
putMsg(result, Status.DATA_IS_NULL, "TaskDefinitionList"); |
|
|
|
putMsg(result, Status.DATA_IS_NULL, "TaskDefinitionList"); |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
if (CollectionUtils.isEmpty(dagDataSchedule.getProcessTaskRelationList())) { |
|
|
|
if (CollectionUtils.isEmpty(dagDataSchedule.getProcessTaskRelationList())) { |
|
|
|
logger.warn("Process task relation list is null."); |
|
|
|
log.warn("Process task relation list is null."); |
|
|
|
putMsg(result, Status.DATA_IS_NULL, "ProcessTaskRelationList"); |
|
|
|
putMsg(result, Status.DATA_IS_NULL, "ProcessTaskRelationList"); |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
@ -1694,7 +1692,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
try { |
|
|
|
try { |
|
|
|
if (processTaskRelationJson == null) { |
|
|
|
if (processTaskRelationJson == null) { |
|
|
|
logger.error("Process task relation data is null."); |
|
|
|
log.error("Process task relation data is null."); |
|
|
|
putMsg(result, Status.DATA_IS_NOT_VALID, processTaskRelationJson); |
|
|
|
putMsg(result, Status.DATA_IS_NOT_VALID, processTaskRelationJson); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -1705,14 +1703,14 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
List<TaskNode> taskNodes = processService.transformTask(taskRelationList, taskDefinitionLogsList); |
|
|
|
List<TaskNode> taskNodes = processService.transformTask(taskRelationList, taskDefinitionLogsList); |
|
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(taskNodes)) { |
|
|
|
if (CollectionUtils.isEmpty(taskNodes)) { |
|
|
|
logger.error("Task node data is empty."); |
|
|
|
log.error("Task node data is empty."); |
|
|
|
putMsg(result, Status.PROCESS_DAG_IS_EMPTY); |
|
|
|
putMsg(result, Status.PROCESS_DAG_IS_EMPTY); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// check has cycle
|
|
|
|
// check has cycle
|
|
|
|
if (graphHasCycle(taskNodes)) { |
|
|
|
if (graphHasCycle(taskNodes)) { |
|
|
|
logger.error("Process DAG has cycle."); |
|
|
|
log.error("Process DAG has cycle."); |
|
|
|
putMsg(result, Status.PROCESS_NODE_HAS_CYCLE); |
|
|
|
putMsg(result, Status.PROCESS_NODE_HAS_CYCLE); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -1725,7 +1723,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
.dependence(taskNode.getDependence()) |
|
|
|
.dependence(taskNode.getDependence()) |
|
|
|
.switchResult(taskNode.getSwitchResult()) |
|
|
|
.switchResult(taskNode.getSwitchResult()) |
|
|
|
.build())) { |
|
|
|
.build())) { |
|
|
|
logger.error("Task node {} parameter invalid.", taskNode.getName()); |
|
|
|
log.error("Task node {} parameter invalid.", taskNode.getName()); |
|
|
|
putMsg(result, Status.PROCESS_NODE_S_PARAMETER_INVALID, taskNode.getName()); |
|
|
|
putMsg(result, Status.PROCESS_NODE_S_PARAMETER_INVALID, taskNode.getName()); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -1737,7 +1735,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
result.put(Constants.STATUS, Status.INTERNAL_SERVER_ERROR_ARGS); |
|
|
|
result.put(Constants.STATUS, Status.INTERNAL_SERVER_ERROR_ARGS); |
|
|
|
putMsg(result, Status.INTERNAL_SERVER_ERROR_ARGS, e.getMessage()); |
|
|
|
putMsg(result, Status.INTERNAL_SERVER_ERROR_ARGS, e.getMessage()); |
|
|
|
logger.error(Status.INTERNAL_SERVER_ERROR_ARGS.getMsg(), e); |
|
|
|
log.error(Status.INTERNAL_SERVER_ERROR_ARGS.getMsg(), e); |
|
|
|
} |
|
|
|
} |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -1760,7 +1758,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
} |
|
|
|
} |
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code); |
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code); |
|
|
|
if (processDefinition == null || projectCode != processDefinition.getProjectCode()) { |
|
|
|
if (processDefinition == null || projectCode != processDefinition.getProjectCode()) { |
|
|
|
logger.error("Process definition does not exist, processDefinitionCode:{}.", code); |
|
|
|
log.error("Process definition does not exist, processDefinitionCode:{}.", code); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, String.valueOf(code)); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, String.valueOf(code)); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -1792,7 +1790,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
.collect(Collectors.toSet()); |
|
|
|
.collect(Collectors.toSet()); |
|
|
|
List<ProcessDefinition> processDefinitionList = processDefinitionMapper.queryByCodes(defineCodeSet); |
|
|
|
List<ProcessDefinition> processDefinitionList = processDefinitionMapper.queryByCodes(defineCodeSet); |
|
|
|
if (CollectionUtils.isEmpty(processDefinitionList)) { |
|
|
|
if (CollectionUtils.isEmpty(processDefinitionList)) { |
|
|
|
logger.error("Process definitions do not exist, codes:{}.", defineCodeSet); |
|
|
|
log.error("Process definitions do not exist, codes:{}.", defineCodeSet); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, codes); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, codes); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -1806,7 +1804,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
if (CollectionUtils.isEmpty(processDefinitionListInProject)) { |
|
|
|
if (CollectionUtils.isEmpty(processDefinitionListInProject)) { |
|
|
|
Set<Long> codesInProject = processDefinitionListInProject.stream() |
|
|
|
Set<Long> codesInProject = processDefinitionListInProject.stream() |
|
|
|
.map(ProcessDefinition::getCode).collect(Collectors.toSet()); |
|
|
|
.map(ProcessDefinition::getCode).collect(Collectors.toSet()); |
|
|
|
logger.error("Process definitions do not exist in project, projectCode:{}, processDefinitionsCodes:{}.", |
|
|
|
log.error("Process definitions do not exist in project, projectCode:{}, processDefinitionsCodes:{}.", |
|
|
|
processDefinitionListInProject.get(0).getProjectCode(), codesInProject); |
|
|
|
processDefinitionListInProject.get(0).getProjectCode(), codesInProject); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, codes); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, codes); |
|
|
|
return result; |
|
|
|
return result; |
|
|
@ -1924,7 +1922,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
} |
|
|
|
} |
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code); |
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code); |
|
|
|
if (null == processDefinition || projectCode != processDefinition.getProjectCode()) { |
|
|
|
if (null == processDefinition || projectCode != processDefinition.getProjectCode()) { |
|
|
|
logger.error("Process definition does not exist, code:{}.", code); |
|
|
|
log.error("Process definition does not exist, code:{}.", code); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, String.valueOf(code)); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, String.valueOf(code)); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -2113,7 +2111,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
if (projectCode == targetProjectCode) { |
|
|
|
if (projectCode == targetProjectCode) { |
|
|
|
logger.warn("Project code is same as target project code, projectCode:{}.", projectCode); |
|
|
|
log.warn("Project code is same as target project code, projectCode:{}.", projectCode); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -2135,7 +2133,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(processDefinitionCodes)) { |
|
|
|
if (StringUtils.isEmpty(processDefinitionCodes)) { |
|
|
|
logger.error("Parameter processDefinitionCodes is empty, projectCode is {}.", projectCode); |
|
|
|
log.error("Parameter processDefinitionCodes is empty, projectCode is {}.", projectCode); |
|
|
|
putMsg(result, Status.PROCESS_DEFINITION_CODES_IS_EMPTY, processDefinitionCodes); |
|
|
|
putMsg(result, Status.PROCESS_DEFINITION_CODES_IS_EMPTY, processDefinitionCodes); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -2176,7 +2174,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
processDefinition.setProjectCode(targetProjectCode); |
|
|
|
processDefinition.setProjectCode(targetProjectCode); |
|
|
|
String otherParamsJson = doOtherOperateProcess(loginUser, processDefinition); |
|
|
|
String otherParamsJson = doOtherOperateProcess(loginUser, processDefinition); |
|
|
|
if (isCopy) { |
|
|
|
if (isCopy) { |
|
|
|
logger.info("Copy process definition..."); |
|
|
|
log.info("Copy process definition..."); |
|
|
|
List<TaskDefinitionLog> taskDefinitionLogs = |
|
|
|
List<TaskDefinitionLog> taskDefinitionLogs = |
|
|
|
taskDefinitionLogDao.getTaskDefineLogList(processTaskRelations); |
|
|
|
taskDefinitionLogDao.getTaskDefineLogList(processTaskRelations); |
|
|
|
Map<Long, Long> taskCodeMap = new HashMap<>(); |
|
|
|
Map<Long, Long> taskCodeMap = new HashMap<>(); |
|
|
@ -2186,7 +2184,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
taskCodeMap.put(taskDefinitionLog.getCode(), taskCode); |
|
|
|
taskCodeMap.put(taskDefinitionLog.getCode(), taskCode); |
|
|
|
taskDefinitionLog.setCode(taskCode); |
|
|
|
taskDefinitionLog.setCode(taskCode); |
|
|
|
} catch (CodeGenerateException e) { |
|
|
|
} catch (CodeGenerateException e) { |
|
|
|
logger.error("Generate task definition code error, projectCode:{}.", targetProjectCode, e); |
|
|
|
log.error("Generate task definition code error, projectCode:{}.", targetProjectCode, e); |
|
|
|
putMsg(result, Status.INTERNAL_SERVER_ERROR_ARGS); |
|
|
|
putMsg(result, Status.INTERNAL_SERVER_ERROR_ARGS); |
|
|
|
throw new ServiceException(Status.INTERNAL_SERVER_ERROR_ARGS); |
|
|
|
throw new ServiceException(Status.INTERNAL_SERVER_ERROR_ARGS); |
|
|
|
} |
|
|
|
} |
|
|
@ -2207,7 +2205,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
try { |
|
|
|
try { |
|
|
|
processDefinition.setCode(CodeGenerateUtils.getInstance().genCode()); |
|
|
|
processDefinition.setCode(CodeGenerateUtils.getInstance().genCode()); |
|
|
|
} catch (CodeGenerateException e) { |
|
|
|
} catch (CodeGenerateException e) { |
|
|
|
logger.error("Generate process definition code error, projectCode:{}.", targetProjectCode, e); |
|
|
|
log.error("Generate process definition code error, projectCode:{}.", targetProjectCode, e); |
|
|
|
putMsg(result, Status.INTERNAL_SERVER_ERROR_ARGS); |
|
|
|
putMsg(result, Status.INTERNAL_SERVER_ERROR_ARGS); |
|
|
|
throw new ServiceException(Status.INTERNAL_SERVER_ERROR_ARGS); |
|
|
|
throw new ServiceException(Status.INTERNAL_SERVER_ERROR_ARGS); |
|
|
|
} |
|
|
|
} |
|
|
@ -2238,7 +2236,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
scheduleObj.setUpdateTime(date); |
|
|
|
scheduleObj.setUpdateTime(date); |
|
|
|
int insertResult = scheduleMapper.insert(scheduleObj); |
|
|
|
int insertResult = scheduleMapper.insert(scheduleObj); |
|
|
|
if (insertResult != 1) { |
|
|
|
if (insertResult != 1) { |
|
|
|
logger.error("Schedule create error, processDefinitionCode:{}.", processDefinition.getCode()); |
|
|
|
log.error("Schedule create error, processDefinitionCode:{}.", processDefinition.getCode()); |
|
|
|
putMsg(result, Status.CREATE_SCHEDULE_ERROR); |
|
|
|
putMsg(result, Status.CREATE_SCHEDULE_ERROR); |
|
|
|
throw new ServiceException(Status.CREATE_SCHEDULE_ERROR); |
|
|
|
throw new ServiceException(Status.CREATE_SCHEDULE_ERROR); |
|
|
|
} |
|
|
|
} |
|
|
@ -2247,18 +2245,18 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
result.putAll(createDagDefine(loginUser, taskRelationList, processDefinition, taskDefinitionLogs, |
|
|
|
result.putAll(createDagDefine(loginUser, taskRelationList, processDefinition, taskDefinitionLogs, |
|
|
|
otherParamsJson)); |
|
|
|
otherParamsJson)); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("Copy process definition error, processDefinitionCode from {} to {}.", |
|
|
|
log.error("Copy process definition error, processDefinitionCode from {} to {}.", |
|
|
|
oldProcessDefinitionCode, processDefinition.getCode(), e); |
|
|
|
oldProcessDefinitionCode, processDefinition.getCode(), e); |
|
|
|
putMsg(result, Status.COPY_PROCESS_DEFINITION_ERROR); |
|
|
|
putMsg(result, Status.COPY_PROCESS_DEFINITION_ERROR); |
|
|
|
throw new ServiceException(Status.COPY_PROCESS_DEFINITION_ERROR); |
|
|
|
throw new ServiceException(Status.COPY_PROCESS_DEFINITION_ERROR); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
logger.info("Move process definition..."); |
|
|
|
log.info("Move process definition..."); |
|
|
|
try { |
|
|
|
try { |
|
|
|
result.putAll(updateDagDefine(loginUser, taskRelationList, processDefinition, null, |
|
|
|
result.putAll(updateDagDefine(loginUser, taskRelationList, processDefinition, null, |
|
|
|
Lists.newArrayList(), otherParamsJson)); |
|
|
|
Lists.newArrayList(), otherParamsJson)); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("Move process definition error, processDefinitionCode:{}.", |
|
|
|
log.error("Move process definition error, processDefinitionCode:{}.", |
|
|
|
processDefinition.getCode(), e); |
|
|
|
processDefinition.getCode(), e); |
|
|
|
putMsg(result, Status.MOVE_PROCESS_DEFINITION_ERROR); |
|
|
|
putMsg(result, Status.MOVE_PROCESS_DEFINITION_ERROR); |
|
|
|
throw new ServiceException(Status.MOVE_PROCESS_DEFINITION_ERROR); |
|
|
|
throw new ServiceException(Status.MOVE_PROCESS_DEFINITION_ERROR); |
|
|
@ -2315,7 +2313,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
|
|
|
|
|
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code); |
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code); |
|
|
|
if (Objects.isNull(processDefinition) || projectCode != processDefinition.getProjectCode()) { |
|
|
|
if (Objects.isNull(processDefinition) || projectCode != processDefinition.getProjectCode()) { |
|
|
|
logger.error( |
|
|
|
log.error( |
|
|
|
"Switch process definition error because it does not exist, projectCode:{}, processDefinitionCode:{}.", |
|
|
|
"Switch process definition error because it does not exist, projectCode:{}, processDefinitionCode:{}.", |
|
|
|
projectCode, code); |
|
|
|
projectCode, code); |
|
|
|
putMsg(result, Status.SWITCH_PROCESS_DEFINITION_VERSION_NOT_EXIST_PROCESS_DEFINITION_ERROR, code); |
|
|
|
putMsg(result, Status.SWITCH_PROCESS_DEFINITION_VERSION_NOT_EXIST_PROCESS_DEFINITION_ERROR, code); |
|
|
@ -2325,7 +2323,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
ProcessDefinitionLog processDefinitionLog = |
|
|
|
ProcessDefinitionLog processDefinitionLog = |
|
|
|
processDefinitionLogMapper.queryByDefinitionCodeAndVersion(code, version); |
|
|
|
processDefinitionLogMapper.queryByDefinitionCodeAndVersion(code, version); |
|
|
|
if (Objects.isNull(processDefinitionLog)) { |
|
|
|
if (Objects.isNull(processDefinitionLog)) { |
|
|
|
logger.error( |
|
|
|
log.error( |
|
|
|
"Switch process definition error because version does not exist, projectCode:{}, processDefinitionCode:{}, version:{}.", |
|
|
|
"Switch process definition error because version does not exist, projectCode:{}, processDefinitionCode:{}, version:{}.", |
|
|
|
projectCode, code, version); |
|
|
|
projectCode, code, version); |
|
|
|
putMsg(result, Status.SWITCH_PROCESS_DEFINITION_VERSION_NOT_EXIST_PROCESS_DEFINITION_VERSION_ERROR, |
|
|
|
putMsg(result, Status.SWITCH_PROCESS_DEFINITION_VERSION_NOT_EXIST_PROCESS_DEFINITION_VERSION_ERROR, |
|
|
@ -2334,13 +2332,13 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
} |
|
|
|
} |
|
|
|
int switchVersion = processService.switchVersion(processDefinition, processDefinitionLog); |
|
|
|
int switchVersion = processService.switchVersion(processDefinition, processDefinitionLog); |
|
|
|
if (switchVersion <= 0) { |
|
|
|
if (switchVersion <= 0) { |
|
|
|
logger.error( |
|
|
|
log.error( |
|
|
|
"Switch process definition version error, projectCode:{}, processDefinitionCode:{}, version:{}.", |
|
|
|
"Switch process definition version error, projectCode:{}, processDefinitionCode:{}, version:{}.", |
|
|
|
projectCode, code, version); |
|
|
|
projectCode, code, version); |
|
|
|
putMsg(result, Status.SWITCH_PROCESS_DEFINITION_VERSION_ERROR); |
|
|
|
putMsg(result, Status.SWITCH_PROCESS_DEFINITION_VERSION_ERROR); |
|
|
|
throw new ServiceException(Status.SWITCH_PROCESS_DEFINITION_VERSION_ERROR); |
|
|
|
throw new ServiceException(Status.SWITCH_PROCESS_DEFINITION_VERSION_ERROR); |
|
|
|
} |
|
|
|
} |
|
|
|
logger.info("Switch process definition version complete, projectCode:{}, processDefinitionCode:{}, version:{}.", |
|
|
|
log.info("Switch process definition version complete, projectCode:{}, processDefinitionCode:{}, version:{}.", |
|
|
|
projectCode, code, version); |
|
|
|
projectCode, code, version); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
return result; |
|
|
|
return result; |
|
|
@ -2360,18 +2358,18 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
if (!failedProcessList.isEmpty()) { |
|
|
|
if (!failedProcessList.isEmpty()) { |
|
|
|
String failedProcess = String.join(",", failedProcessList); |
|
|
|
String failedProcess = String.join(",", failedProcessList); |
|
|
|
if (isCopy) { |
|
|
|
if (isCopy) { |
|
|
|
logger.error( |
|
|
|
log.error( |
|
|
|
"Copy process definition error, srcProjectCode:{}, targetProjectCode:{}, failedProcessList:{}.", |
|
|
|
"Copy process definition error, srcProjectCode:{}, targetProjectCode:{}, failedProcessList:{}.", |
|
|
|
srcProjectCode, targetProjectCode, failedProcess); |
|
|
|
srcProjectCode, targetProjectCode, failedProcess); |
|
|
|
putMsg(result, Status.COPY_PROCESS_DEFINITION_ERROR, srcProjectCode, targetProjectCode, failedProcess); |
|
|
|
putMsg(result, Status.COPY_PROCESS_DEFINITION_ERROR, srcProjectCode, targetProjectCode, failedProcess); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
logger.error( |
|
|
|
log.error( |
|
|
|
"Move process definition error, srcProjectCode:{}, targetProjectCode:{}, failedProcessList:{}.", |
|
|
|
"Move process definition error, srcProjectCode:{}, targetProjectCode:{}, failedProcessList:{}.", |
|
|
|
srcProjectCode, targetProjectCode, failedProcess); |
|
|
|
srcProjectCode, targetProjectCode, failedProcess); |
|
|
|
putMsg(result, Status.MOVE_PROCESS_DEFINITION_ERROR, srcProjectCode, targetProjectCode, failedProcess); |
|
|
|
putMsg(result, Status.MOVE_PROCESS_DEFINITION_ERROR, srcProjectCode, targetProjectCode, failedProcess); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
logger.info("Batch {} process definition complete, srcProjectCode:{}, targetProjectCode:{}.", |
|
|
|
log.info("Batch {} process definition complete, srcProjectCode:{}, targetProjectCode:{}.", |
|
|
|
isCopy ? "copy" : "move", srcProjectCode, targetProjectCode); |
|
|
|
isCopy ? "copy" : "move", srcProjectCode, targetProjectCode); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
} |
|
|
|
} |
|
|
@ -2438,11 +2436,11 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code); |
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code); |
|
|
|
|
|
|
|
|
|
|
|
if (processDefinition == null || projectCode != processDefinition.getProjectCode()) { |
|
|
|
if (processDefinition == null || projectCode != processDefinition.getProjectCode()) { |
|
|
|
logger.error("Process definition does not exist, code:{}.", code); |
|
|
|
log.error("Process definition does not exist, code:{}.", code); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, String.valueOf(code)); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, String.valueOf(code)); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (processDefinition.getVersion() == version) { |
|
|
|
if (processDefinition.getVersion() == version) { |
|
|
|
logger.warn( |
|
|
|
log.warn( |
|
|
|
"Process definition can not be deleted due to version is being used, projectCode:{}, processDefinitionCode:{}, version:{}.", |
|
|
|
"Process definition can not be deleted due to version is being used, projectCode:{}, processDefinitionCode:{}, version:{}.", |
|
|
|
projectCode, code, version); |
|
|
|
projectCode, code, version); |
|
|
|
putMsg(result, Status.MAIN_TABLE_USING_VERSION); |
|
|
|
putMsg(result, Status.MAIN_TABLE_USING_VERSION); |
|
|
@ -2451,14 +2449,14 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
int deleteLog = processDefinitionLogMapper.deleteByProcessDefinitionCodeAndVersion(code, version); |
|
|
|
int deleteLog = processDefinitionLogMapper.deleteByProcessDefinitionCodeAndVersion(code, version); |
|
|
|
int deleteRelationLog = processTaskRelationLogMapper.deleteByCode(code, version); |
|
|
|
int deleteRelationLog = processTaskRelationLogMapper.deleteByCode(code, version); |
|
|
|
if (deleteLog == 0 || deleteRelationLog == 0) { |
|
|
|
if (deleteLog == 0 || deleteRelationLog == 0) { |
|
|
|
logger.error( |
|
|
|
log.error( |
|
|
|
"Delete process definition version error, projectCode:{}, processDefinitionCode:{}, version:{}.", |
|
|
|
"Delete process definition version error, projectCode:{}, processDefinitionCode:{}, version:{}.", |
|
|
|
projectCode, code, version); |
|
|
|
projectCode, code, version); |
|
|
|
putMsg(result, Status.DELETE_PROCESS_DEFINE_BY_CODE_ERROR); |
|
|
|
putMsg(result, Status.DELETE_PROCESS_DEFINE_BY_CODE_ERROR); |
|
|
|
throw new ServiceException(Status.DELETE_PROCESS_DEFINE_BY_CODE_ERROR); |
|
|
|
throw new ServiceException(Status.DELETE_PROCESS_DEFINE_BY_CODE_ERROR); |
|
|
|
} |
|
|
|
} |
|
|
|
deleteOtherRelation(project, result, processDefinition); |
|
|
|
deleteOtherRelation(project, result, processDefinition); |
|
|
|
logger.info( |
|
|
|
log.info( |
|
|
|
"Delete process definition version complete, projectCode:{}, processDefinitionCode:{}, version:{}.", |
|
|
|
"Delete process definition version complete, projectCode:{}, processDefinitionCode:{}, version:{}.", |
|
|
|
projectCode, code, version); |
|
|
|
projectCode, code, version); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
@ -2499,14 +2497,14 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
if (checkDescriptionLength(description)) { |
|
|
|
if (checkDescriptionLength(description)) { |
|
|
|
logger.warn("Parameter description is too long."); |
|
|
|
log.warn("Parameter description is too long."); |
|
|
|
putMsg(result, Status.DESCRIPTION_TOO_LONG_ERROR); |
|
|
|
putMsg(result, Status.DESCRIPTION_TOO_LONG_ERROR); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
// check whether the new process define name exist
|
|
|
|
// check whether the new process define name exist
|
|
|
|
ProcessDefinition definition = processDefinitionMapper.verifyByDefineName(project.getCode(), name); |
|
|
|
ProcessDefinition definition = processDefinitionMapper.verifyByDefineName(project.getCode(), name); |
|
|
|
if (definition != null) { |
|
|
|
if (definition != null) { |
|
|
|
logger.warn("Process definition with the same name {} already exists, processDefinitionCode:{}.", |
|
|
|
log.warn("Process definition with the same name {} already exists, processDefinitionCode:{}.", |
|
|
|
definition.getName(), definition.getCode()); |
|
|
|
definition.getName(), definition.getCode()); |
|
|
|
putMsg(result, Status.PROCESS_DEFINITION_NAME_EXIST, name); |
|
|
|
putMsg(result, Status.PROCESS_DEFINITION_NAME_EXIST, name); |
|
|
|
return result; |
|
|
|
return result; |
|
|
@ -2516,7 +2514,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
if (!Constants.DEFAULT.equals(tenantCode)) { |
|
|
|
if (!Constants.DEFAULT.equals(tenantCode)) { |
|
|
|
Tenant tenant = tenantMapper.queryByTenantCode(tenantCode); |
|
|
|
Tenant tenant = tenantMapper.queryByTenantCode(tenantCode); |
|
|
|
if (tenant == null) { |
|
|
|
if (tenant == null) { |
|
|
|
logger.error("Tenant does not exist."); |
|
|
|
log.error("Tenant does not exist."); |
|
|
|
putMsg(result, Status.TENANT_NOT_EXIST); |
|
|
|
putMsg(result, Status.TENANT_NOT_EXIST); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -2526,7 +2524,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
try { |
|
|
|
try { |
|
|
|
processDefinitionCode = CodeGenerateUtils.getInstance().genCode(); |
|
|
|
processDefinitionCode = CodeGenerateUtils.getInstance().genCode(); |
|
|
|
} catch (CodeGenerateException e) { |
|
|
|
} catch (CodeGenerateException e) { |
|
|
|
logger.error("Generate process definition code error, projectCode:{}.", projectCode, e); |
|
|
|
log.error("Generate process definition code error, projectCode:{}.", projectCode, e); |
|
|
|
putMsg(result, Status.INTERNAL_SERVER_ERROR_ARGS); |
|
|
|
putMsg(result, Status.INTERNAL_SERVER_ERROR_ARGS); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -2536,7 +2534,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
processDefinition.setExecutionType(executionType); |
|
|
|
processDefinition.setExecutionType(executionType); |
|
|
|
result = createEmptyDagDefine(loginUser, processDefinition); |
|
|
|
result = createEmptyDagDefine(loginUser, processDefinition); |
|
|
|
if (result.get(Constants.STATUS) != Status.SUCCESS) { |
|
|
|
if (result.get(Constants.STATUS) != Status.SUCCESS) { |
|
|
|
logger.error("Create empty process definition error."); |
|
|
|
log.error("Create empty process definition error."); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -2558,7 +2556,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
int insertVersion = processService.saveProcessDefine(loginUser, processDefinition, Boolean.TRUE, Boolean.TRUE); |
|
|
|
int insertVersion = processService.saveProcessDefine(loginUser, processDefinition, Boolean.TRUE, Boolean.TRUE); |
|
|
|
if (insertVersion == 0) { |
|
|
|
if (insertVersion == 0) { |
|
|
|
logger.error("Save process definition error, processDefinitionCode:{}.", processDefinition.getCode()); |
|
|
|
log.error("Save process definition error, processDefinitionCode:{}.", processDefinition.getCode()); |
|
|
|
putMsg(result, Status.CREATE_PROCESS_DEFINITION_ERROR); |
|
|
|
putMsg(result, Status.CREATE_PROCESS_DEFINITION_ERROR); |
|
|
|
throw new ServiceException(Status.CREATE_PROCESS_DEFINITION_ERROR); |
|
|
|
throw new ServiceException(Status.CREATE_PROCESS_DEFINITION_ERROR); |
|
|
|
} |
|
|
|
} |
|
|
@ -2578,13 +2576,13 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
Date now = new Date(); |
|
|
|
Date now = new Date(); |
|
|
|
scheduleObj.setProcessDefinitionCode(processDefinition.getCode()); |
|
|
|
scheduleObj.setProcessDefinitionCode(processDefinition.getCode()); |
|
|
|
if (DateUtils.differSec(scheduleObj.getStartTime(), scheduleObj.getEndTime()) == 0) { |
|
|
|
if (DateUtils.differSec(scheduleObj.getStartTime(), scheduleObj.getEndTime()) == 0) { |
|
|
|
logger.warn("The schedule start time must not be the same as the end, processDefinitionCode:{}.", |
|
|
|
log.warn("The schedule start time must not be the same as the end, processDefinitionCode:{}.", |
|
|
|
processDefinition.getCode()); |
|
|
|
processDefinition.getCode()); |
|
|
|
putMsg(result, Status.SCHEDULE_START_TIME_END_TIME_SAME); |
|
|
|
putMsg(result, Status.SCHEDULE_START_TIME_END_TIME_SAME); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!org.quartz.CronExpression.isValidExpression(scheduleObj.getCrontab())) { |
|
|
|
if (!org.quartz.CronExpression.isValidExpression(scheduleObj.getCrontab())) { |
|
|
|
logger.error("CronExpression verify failure, cron:{}.", scheduleObj.getCrontab()); |
|
|
|
log.error("CronExpression verify failure, cron:{}.", scheduleObj.getCrontab()); |
|
|
|
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, scheduleObj.getCrontab()); |
|
|
|
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, scheduleObj.getCrontab()); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -2647,7 +2645,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
if (checkDescriptionLength(description)) { |
|
|
|
if (checkDescriptionLength(description)) { |
|
|
|
logger.warn("Parameter description is too long."); |
|
|
|
log.warn("Parameter description is too long."); |
|
|
|
putMsg(result, Status.DESCRIPTION_TOO_LONG_ERROR); |
|
|
|
putMsg(result, Status.DESCRIPTION_TOO_LONG_ERROR); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -2655,7 +2653,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
if (!Constants.DEFAULT.equals(tenantCode)) { |
|
|
|
if (!Constants.DEFAULT.equals(tenantCode)) { |
|
|
|
Tenant tenant = tenantMapper.queryByTenantCode(tenantCode); |
|
|
|
Tenant tenant = tenantMapper.queryByTenantCode(tenantCode); |
|
|
|
if (tenant == null) { |
|
|
|
if (tenant == null) { |
|
|
|
logger.error("Tenant does not exist."); |
|
|
|
log.error("Tenant does not exist."); |
|
|
|
putMsg(result, Status.TENANT_NOT_EXIST); |
|
|
|
putMsg(result, Status.TENANT_NOT_EXIST); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -2665,13 +2663,13 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code); |
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code); |
|
|
|
// check process definition exists
|
|
|
|
// check process definition exists
|
|
|
|
if (processDefinition == null || projectCode != processDefinition.getProjectCode()) { |
|
|
|
if (processDefinition == null || projectCode != processDefinition.getProjectCode()) { |
|
|
|
logger.error("Process definition does not exist, code:{}.", code); |
|
|
|
log.error("Process definition does not exist, code:{}.", code); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, String.valueOf(code)); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, String.valueOf(code)); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
if (processDefinition.getReleaseState() == ReleaseState.ONLINE) { |
|
|
|
if (processDefinition.getReleaseState() == ReleaseState.ONLINE) { |
|
|
|
// online can not permit edit
|
|
|
|
// online can not permit edit
|
|
|
|
logger.warn("Process definition is not allowed to be modified due to {}, processDefinitionCode:{}.", |
|
|
|
log.warn("Process definition is not allowed to be modified due to {}, processDefinitionCode:{}.", |
|
|
|
ReleaseState.ONLINE.getDescp(), processDefinition.getCode()); |
|
|
|
ReleaseState.ONLINE.getDescp(), processDefinition.getCode()); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_ALLOWED_EDIT, processDefinition.getName()); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_ALLOWED_EDIT, processDefinition.getName()); |
|
|
|
return result; |
|
|
|
return result; |
|
|
@ -2680,7 +2678,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
// check whether the new process define name exist
|
|
|
|
// check whether the new process define name exist
|
|
|
|
ProcessDefinition definition = processDefinitionMapper.verifyByDefineName(project.getCode(), name); |
|
|
|
ProcessDefinition definition = processDefinitionMapper.verifyByDefineName(project.getCode(), name); |
|
|
|
if (definition != null) { |
|
|
|
if (definition != null) { |
|
|
|
logger.warn("Process definition with the same name {} already exists, processDefinitionCode:{}.", |
|
|
|
log.warn("Process definition with the same name {} already exists, processDefinitionCode:{}.", |
|
|
|
definition.getName(), definition.getCode()); |
|
|
|
definition.getName(), definition.getCode()); |
|
|
|
putMsg(result, Status.PROCESS_DEFINITION_NAME_EXIST, name); |
|
|
|
putMsg(result, Status.PROCESS_DEFINITION_NAME_EXIST, name); |
|
|
|
return result; |
|
|
|
return result; |
|
|
@ -2695,7 +2693,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
result = updateDagDefine(loginUser, taskRelationList, processDefinition, processDefinitionDeepCopy, |
|
|
|
result = updateDagDefine(loginUser, taskRelationList, processDefinition, processDefinitionDeepCopy, |
|
|
|
Lists.newArrayList(), otherParamsJson); |
|
|
|
Lists.newArrayList(), otherParamsJson); |
|
|
|
if (result.get(Constants.STATUS) != Status.SUCCESS) { |
|
|
|
if (result.get(Constants.STATUS) != Status.SUCCESS) { |
|
|
|
logger.error("Update process definition basic info error."); |
|
|
|
log.error("Update process definition basic info error."); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -2768,7 +2766,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
} |
|
|
|
} |
|
|
|
int insertVersion = this.saveProcessDefine(loginUser, processDefinitionUpdate); |
|
|
|
int insertVersion = this.saveProcessDefine(loginUser, processDefinitionUpdate); |
|
|
|
if (insertVersion == 0) { |
|
|
|
if (insertVersion == 0) { |
|
|
|
logger.error("Update process definition error, projectCode:{}, processDefinitionName:{}.", |
|
|
|
log.error("Update process definition error, projectCode:{}, processDefinitionName:{}.", |
|
|
|
processDefinitionUpdate.getCode(), |
|
|
|
processDefinitionUpdate.getCode(), |
|
|
|
processDefinitionUpdate.getName()); |
|
|
|
processDefinitionUpdate.getName()); |
|
|
|
throw new ServiceException(Status.UPDATE_PROCESS_DEFINITION_ERROR); |
|
|
|
throw new ServiceException(Status.UPDATE_PROCESS_DEFINITION_ERROR); |
|
|
@ -2776,11 +2774,11 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
|
|
|
|
|
|
|
|
int insertRelationVersion = this.saveTaskRelation(loginUser, processDefinitionUpdate, insertVersion); |
|
|
|
int insertRelationVersion = this.saveTaskRelation(loginUser, processDefinitionUpdate, insertVersion); |
|
|
|
if (insertRelationVersion != Constants.EXIT_CODE_SUCCESS) { |
|
|
|
if (insertRelationVersion != Constants.EXIT_CODE_SUCCESS) { |
|
|
|
logger.error("Save process task relations error, projectCode:{}, processCode:{}, processVersion:{}.", |
|
|
|
log.error("Save process task relations error, projectCode:{}, processCode:{}, processVersion:{}.", |
|
|
|
processDefinition.getProjectCode(), processDefinition.getCode(), insertVersion); |
|
|
|
processDefinition.getProjectCode(), processDefinition.getCode(), insertVersion); |
|
|
|
throw new ServiceException(Status.CREATE_PROCESS_TASK_RELATION_ERROR); |
|
|
|
throw new ServiceException(Status.CREATE_PROCESS_TASK_RELATION_ERROR); |
|
|
|
} |
|
|
|
} |
|
|
|
logger.info("Save process task relations complete, projectCode:{}, processCode:{}, processVersion:{}.", |
|
|
|
log.info("Save process task relations complete, projectCode:{}, processCode:{}, processVersion:{}.", |
|
|
|
processDefinition.getProjectCode(), processDefinition.getCode(), insertVersion); |
|
|
|
processDefinition.getProjectCode(), processDefinition.getCode(), insertVersion); |
|
|
|
processDefinitionUpdate.setVersion(insertVersion); |
|
|
|
processDefinitionUpdate.setVersion(insertVersion); |
|
|
|
return processDefinitionUpdate; |
|
|
|
return processDefinitionUpdate; |
|
|
@ -2859,7 +2857,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
boolean isSame = CollectionUtils.isEqualCollection(processTaskRelationSet, |
|
|
|
boolean isSame = CollectionUtils.isEqualCollection(processTaskRelationSet, |
|
|
|
taskRelationSet); |
|
|
|
taskRelationSet); |
|
|
|
if (isSame) { |
|
|
|
if (isSame) { |
|
|
|
logger.info("process task relations is non-existent, projectCode:{}, processCode:{}.", |
|
|
|
log.info("process task relations is non-existent, projectCode:{}, processCode:{}.", |
|
|
|
processDefinition.getProjectCode(), processDefinition.getCode()); |
|
|
|
processDefinition.getProjectCode(), processDefinition.getCode()); |
|
|
|
return Constants.EXIT_CODE_SUCCESS; |
|
|
|
return Constants.EXIT_CODE_SUCCESS; |
|
|
|
} |
|
|
|
} |
|
|
@ -2939,13 +2937,13 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
|
|
|
|
|
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code); |
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code); |
|
|
|
if (processDefinition == null) { |
|
|
|
if (processDefinition == null) { |
|
|
|
logger.error("Process definition does not exist, code:{}.", code); |
|
|
|
log.error("Process definition does not exist, code:{}.", code); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, String.valueOf(code)); |
|
|
|
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, String.valueOf(code)); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
Schedule scheduleObj = scheduleMapper.queryByProcessDefinitionCode(code); |
|
|
|
Schedule scheduleObj = scheduleMapper.queryByProcessDefinitionCode(code); |
|
|
|
if (scheduleObj == null) { |
|
|
|
if (scheduleObj == null) { |
|
|
|
logger.error("Schedule cron does not exist, processDefinitionCode:{}.", code); |
|
|
|
log.error("Schedule cron does not exist, processDefinitionCode:{}.", code); |
|
|
|
putMsg(result, Status.SCHEDULE_CRON_NOT_EXISTS, "processDefinitionCode:" + code); |
|
|
|
putMsg(result, Status.SCHEDULE_CRON_NOT_EXISTS, "processDefinitionCode:" + code); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -2954,7 +2952,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
List<ProcessTaskRelation> relationList = |
|
|
|
List<ProcessTaskRelation> relationList = |
|
|
|
processService.findRelationByCode(code, processDefinition.getVersion()); |
|
|
|
processService.findRelationByCode(code, processDefinition.getVersion()); |
|
|
|
if (CollectionUtils.isEmpty(relationList)) { |
|
|
|
if (CollectionUtils.isEmpty(relationList)) { |
|
|
|
logger.warn("Process definition has no task relation, processDefinitionCode:{}.", code); |
|
|
|
log.warn("Process definition has no task relation, processDefinitionCode:{}.", code); |
|
|
|
putMsg(result, Status.PROCESS_DAG_IS_EMPTY); |
|
|
|
putMsg(result, Status.PROCESS_DAG_IS_EMPTY); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -2966,13 +2964,13 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
processDefinition.setReleaseState(releaseState); |
|
|
|
processDefinition.setReleaseState(releaseState); |
|
|
|
int updateProcess = processDefinitionMapper.updateById(processDefinition); |
|
|
|
int updateProcess = processDefinitionMapper.updateById(processDefinition); |
|
|
|
if (updateProcess > 0) { |
|
|
|
if (updateProcess > 0) { |
|
|
|
logger.info("Set schedule offline, projectCode:{}, processDefinitionCode:{}, scheduleId:{}.", |
|
|
|
log.info("Set schedule offline, projectCode:{}, processDefinitionCode:{}, scheduleId:{}.", |
|
|
|
projectCode, code, scheduleObj.getId()); |
|
|
|
projectCode, code, scheduleObj.getId()); |
|
|
|
// set status
|
|
|
|
// set status
|
|
|
|
scheduleObj.setReleaseState(ReleaseState.OFFLINE); |
|
|
|
scheduleObj.setReleaseState(ReleaseState.OFFLINE); |
|
|
|
int updateSchedule = scheduleMapper.updateById(scheduleObj); |
|
|
|
int updateSchedule = scheduleMapper.updateById(scheduleObj); |
|
|
|
if (updateSchedule == 0) { |
|
|
|
if (updateSchedule == 0) { |
|
|
|
logger.error( |
|
|
|
log.error( |
|
|
|
"Set schedule offline error, projectCode:{}, processDefinitionCode:{}, scheduleId:{}", |
|
|
|
"Set schedule offline error, projectCode:{}, processDefinitionCode:{}, scheduleId:{}", |
|
|
|
projectCode, code, scheduleObj.getId()); |
|
|
|
projectCode, code, scheduleObj.getId()); |
|
|
|
putMsg(result, Status.OFFLINE_SCHEDULE_ERROR); |
|
|
|
putMsg(result, Status.OFFLINE_SCHEDULE_ERROR); |
|
|
@ -3035,7 +3033,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code); |
|
|
|
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code); |
|
|
|
|
|
|
|
|
|
|
|
if (Objects.isNull(processDefinition) || projectCode != processDefinition.getProjectCode()) { |
|
|
|
if (Objects.isNull(processDefinition) || projectCode != processDefinition.getProjectCode()) { |
|
|
|
logger.error("Process definition does not exist, projectCode:{}, processDefinitionCode:{}.", projectCode, |
|
|
|
log.error("Process definition does not exist, projectCode:{}, processDefinitionCode:{}.", projectCode, |
|
|
|
code); |
|
|
|
code); |
|
|
|
putMsg(result, PROCESS_DEFINE_NOT_EXIST, code); |
|
|
|
putMsg(result, PROCESS_DEFINE_NOT_EXIST, code); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|