|
|
@ -2101,64 +2101,31 @@ public class ProcessService { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* switch process definition version to process definition log version |
|
|
|
* switch process definition version to process definition log version |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public int processDefinitionToDB(ProcessDefinition processDefinition, ProcessDefinitionLog processDefinitionLog, Boolean isFromProcessDefine) { |
|
|
|
public int switchVersion(ProcessDefinition processDefinition, ProcessDefinitionLog processDefinitionLog) { |
|
|
|
if (null == processDefinition || null == processDefinitionLog) { |
|
|
|
if (null == processDefinition || null == processDefinitionLog) { |
|
|
|
return Constants.DEFINITION_FAILURE; |
|
|
|
return Constants.DEFINITION_FAILURE; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
processDefinitionLog.setId(processDefinition.getId()); |
|
|
|
processDefinitionLog.setId(processDefinition.getId()); |
|
|
|
processDefinitionLog.setReleaseState(isFromProcessDefine ? ReleaseState.OFFLINE : ReleaseState.ONLINE); |
|
|
|
processDefinitionLog.setReleaseState(ReleaseState.OFFLINE); |
|
|
|
processDefinitionLog.setFlag(Flag.YES); |
|
|
|
processDefinitionLog.setFlag(Flag.YES); |
|
|
|
|
|
|
|
|
|
|
|
int result; |
|
|
|
int result = processDefineMapper.updateById(processDefinitionLog); |
|
|
|
if (0 == processDefinition.getId()) { |
|
|
|
if (result > 0) { |
|
|
|
result = processDefineMapper.insert(processDefinitionLog); |
|
|
|
result = switchProcessTaskRelationVersion(processDefinition); |
|
|
|
} else { |
|
|
|
if (result <= 0) { |
|
|
|
result = processDefineMapper.updateById(processDefinitionLog); |
|
|
|
return Constants.DEFINITION_FAILURE; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* switch process definition version to process definition log version |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public int switchVersion(ProcessDefinition processDefinition, ProcessDefinitionLog processDefinitionLog) { |
|
|
|
|
|
|
|
int switchResult = processDefinitionToDB(processDefinition, processDefinitionLog, true); |
|
|
|
|
|
|
|
if (switchResult != Constants.DEFINITION_FAILURE) { |
|
|
|
|
|
|
|
switchResult = switchProcessTaskRelationVersion(processDefinition); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return switchResult; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int switchProcessTaskRelationVersion(ProcessDefinition processDefinition) { |
|
|
|
public int switchProcessTaskRelationVersion(ProcessDefinition processDefinition) { |
|
|
|
List<ProcessTaskRelation> processTaskRelationList = processTaskRelationMapper.queryByProcessCode(processDefinition.getProjectCode(), processDefinition.getCode()); |
|
|
|
List<ProcessTaskRelation> processTaskRelationList = processTaskRelationMapper.queryByProcessCode(processDefinition.getProjectCode(), processDefinition.getCode()); |
|
|
|
if (!processTaskRelationList.isEmpty()) { |
|
|
|
if (!processTaskRelationList.isEmpty()) { |
|
|
|
processTaskRelationMapper.deleteByCode(processDefinition.getProjectCode(), processDefinition.getCode()); |
|
|
|
processTaskRelationMapper.deleteByCode(processDefinition.getProjectCode(), processDefinition.getCode()); |
|
|
|
} |
|
|
|
} |
|
|
|
int result = 0; |
|
|
|
|
|
|
|
List<ProcessTaskRelationLog> processTaskRelationLogList = processTaskRelationLogMapper.queryByProcessCodeAndVersion(processDefinition.getCode(), processDefinition.getVersion()); |
|
|
|
List<ProcessTaskRelationLog> processTaskRelationLogList = processTaskRelationLogMapper.queryByProcessCodeAndVersion(processDefinition.getCode(), processDefinition.getVersion()); |
|
|
|
for (ProcessTaskRelationLog processTaskRelationLog : processTaskRelationLogList) { |
|
|
|
return processTaskRelationMapper.batchInsert(processTaskRelationLogList); |
|
|
|
result += processTaskRelationMapper.insert(processTaskRelationLog); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void setTaskFromTaskNode(TaskNode taskNode, TaskDefinition taskDefinition) { |
|
|
|
|
|
|
|
taskDefinition.setName(taskNode.getName()); |
|
|
|
|
|
|
|
taskDefinition.setDescription(taskNode.getDesc()); |
|
|
|
|
|
|
|
taskDefinition.setTaskType(taskNode.getType().toUpperCase()); |
|
|
|
|
|
|
|
taskDefinition.setTaskParams(taskNode.getTaskParams()); |
|
|
|
|
|
|
|
taskDefinition.setFlag(taskNode.isForbidden() ? Flag.NO : Flag.YES); |
|
|
|
|
|
|
|
taskDefinition.setTaskPriority(taskNode.getTaskInstancePriority()); |
|
|
|
|
|
|
|
taskDefinition.setWorkerGroup(taskNode.getWorkerGroup()); |
|
|
|
|
|
|
|
taskDefinition.setEnvironmentCode(Objects.isNull(taskNode.getEnvironmentCode()) ? -1 : taskNode.getEnvironmentCode()); |
|
|
|
|
|
|
|
taskDefinition.setFailRetryTimes(taskNode.getMaxRetryTimes()); |
|
|
|
|
|
|
|
taskDefinition.setFailRetryInterval(taskNode.getRetryInterval()); |
|
|
|
|
|
|
|
taskDefinition.setTimeoutFlag(taskNode.getTaskTimeoutParameter().getEnable() ? TimeoutFlag.OPEN : TimeoutFlag.CLOSE); |
|
|
|
|
|
|
|
taskDefinition.setTimeoutNotifyStrategy(taskNode.getTaskTimeoutParameter().getStrategy()); |
|
|
|
|
|
|
|
taskDefinition.setTimeout(taskNode.getTaskTimeoutParameter().getInterval()); |
|
|
|
|
|
|
|
taskDefinition.setDelayTime(taskNode.getDelayTime()); |
|
|
|
|
|
|
|
taskDefinition.setResourceIds(getResourceIds(taskDefinition)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|