[Enhancement][API] Copy workflow with scheduler info (#10677)

* support batch copy workflow with scheduler
This commit is contained in:
zhuxt2015 2022-07-27 13:45:45 +08:00 committed by GitHub
parent de5c22b276
commit cc2f17ddcc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 0 deletions

View File

@ -1716,6 +1716,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
* @param targetProjectCode targetProjectCode
*/
@Override
@Transactional
public Map<String, Object> batchCopyProcessDefinition(User loginUser,
long projectCode,
String codes,
@ -1834,6 +1835,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
processTaskRelationLog.setPostTaskCode(taskCodeMap.get(processTaskRelationLog.getPostTaskCode()));
}
}
final long oldProcessDefinitionCode = processDefinition.getCode();
try {
processDefinition.setCode(CodeGenerateUtils.getInstance().genCode());
} catch (CodeGenerateException e) {
@ -1856,6 +1858,19 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
}
processDefinition.setLocations(JSONUtils.toJsonString(jsonNodes));
}
//copy timing configuration
Schedule scheduleObj = scheduleMapper.queryByProcessDefinitionCode(oldProcessDefinitionCode);
if (scheduleObj != null) {
scheduleObj.setProcessDefinitionCode(processDefinition.getCode());
scheduleObj.setReleaseState(ReleaseState.OFFLINE);
scheduleObj.setCreateTime(date);
scheduleObj.setUpdateTime(date);
int insertResult = scheduleMapper.insert(scheduleObj);
if (insertResult != 1) {
putMsg(result, Status.CREATE_SCHEDULE_ERROR);
throw new ServiceException(Status.CREATE_SCHEDULE_ERROR);
}
}
try {
result.putAll(createDagDefine(loginUser, taskRelationList, processDefinition, taskDefinitionLogs, otherParamsJson));
} catch (Exception e) {