|
|
@ -34,6 +34,7 @@ import org.apache.dolphinscheduler.api.utils.PageInfo; |
|
|
|
import org.apache.dolphinscheduler.api.utils.Result; |
|
|
|
import org.apache.dolphinscheduler.api.utils.Result; |
|
|
|
import org.apache.dolphinscheduler.common.Constants; |
|
|
|
import org.apache.dolphinscheduler.common.Constants; |
|
|
|
import org.apache.dolphinscheduler.common.enums.AuthorizationType; |
|
|
|
import org.apache.dolphinscheduler.common.enums.AuthorizationType; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.common.enums.ProcessExecutionTypeEnum; |
|
|
|
import org.apache.dolphinscheduler.common.enums.ReleaseState; |
|
|
|
import org.apache.dolphinscheduler.common.enums.ReleaseState; |
|
|
|
import org.apache.dolphinscheduler.common.enums.UserType; |
|
|
|
import org.apache.dolphinscheduler.common.enums.UserType; |
|
|
|
import org.apache.dolphinscheduler.common.graph.DAG; |
|
|
|
import org.apache.dolphinscheduler.common.graph.DAG; |
|
|
@ -72,8 +73,6 @@ import org.apache.dolphinscheduler.dao.mapper.UserMapper; |
|
|
|
import org.apache.dolphinscheduler.service.permission.PermissionCheck; |
|
|
|
import org.apache.dolphinscheduler.service.permission.PermissionCheck; |
|
|
|
import org.apache.dolphinscheduler.service.process.ProcessService; |
|
|
|
import org.apache.dolphinscheduler.service.process.ProcessService; |
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang.StringUtils; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.BufferedOutputStream; |
|
|
|
import java.io.BufferedOutputStream; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
import java.nio.charset.StandardCharsets; |
|
|
|
import java.nio.charset.StandardCharsets; |
|
|
@ -163,15 +162,15 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
/** |
|
|
|
/** |
|
|
|
* create process definition |
|
|
|
* create process definition |
|
|
|
* |
|
|
|
* |
|
|
|
* @param loginUser login user |
|
|
|
* @param loginUser login user |
|
|
|
* @param projectCode project code |
|
|
|
* @param projectCode project code |
|
|
|
* @param name process definition name |
|
|
|
* @param name process definition name |
|
|
|
* @param description description |
|
|
|
* @param description description |
|
|
|
* @param globalParams global params |
|
|
|
* @param globalParams global params |
|
|
|
* @param locations locations for nodes |
|
|
|
* @param locations locations for nodes |
|
|
|
* @param timeout timeout |
|
|
|
* @param timeout timeout |
|
|
|
* @param tenantCode tenantCode |
|
|
|
* @param tenantCode tenantCode |
|
|
|
* @param taskRelationJson relation json for nodes |
|
|
|
* @param taskRelationJson relation json for nodes |
|
|
|
* @param taskDefinitionJson taskDefinitionJson |
|
|
|
* @param taskDefinitionJson taskDefinitionJson |
|
|
|
* @return create result code |
|
|
|
* @return create result code |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -186,7 +185,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
int timeout, |
|
|
|
int timeout, |
|
|
|
String tenantCode, |
|
|
|
String tenantCode, |
|
|
|
String taskRelationJson, |
|
|
|
String taskRelationJson, |
|
|
|
String taskDefinitionJson) { |
|
|
|
String taskDefinitionJson, |
|
|
|
|
|
|
|
ProcessExecutionTypeEnum executionType) { |
|
|
|
Project project = projectMapper.queryByCode(projectCode); |
|
|
|
Project project = projectMapper.queryByCode(projectCode); |
|
|
|
//check user access for project
|
|
|
|
//check user access for project
|
|
|
|
Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode); |
|
|
|
Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode); |
|
|
@ -227,7 +227,9 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
ProcessDefinition processDefinition = new ProcessDefinition(projectCode, name, processDefinitionCode, description, |
|
|
|
ProcessDefinition processDefinition = new ProcessDefinition(projectCode, name, processDefinitionCode, description, |
|
|
|
globalParams, locations, timeout, loginUser.getId(), tenantId); |
|
|
|
globalParams, locations, timeout, loginUser.getId(), tenantId); |
|
|
|
|
|
|
|
processDefinition.setExecutionType(executionType); |
|
|
|
|
|
|
|
|
|
|
|
return createDagDefine(loginUser, taskRelationList, processDefinition, taskDefinitionLogs); |
|
|
|
return createDagDefine(loginUser, taskRelationList, processDefinition, taskDefinitionLogs); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -292,8 +294,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
List<ProcessTaskRelation> processTaskRelations = taskRelationList.stream() |
|
|
|
List<ProcessTaskRelation> processTaskRelations = taskRelationList.stream() |
|
|
|
.map(processTaskRelationLog -> JSONUtils.parseObject(JSONUtils.toJsonString(processTaskRelationLog), ProcessTaskRelation.class)) |
|
|
|
.map(processTaskRelationLog -> JSONUtils.parseObject(JSONUtils.toJsonString(processTaskRelationLog), ProcessTaskRelation.class)) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
.collect(Collectors.toList()); |
|
|
|
List<TaskNode> taskNodeList = processService.transformTask(processTaskRelations, taskDefinitionLogs); |
|
|
|
List<TaskNode> taskNodeList = processService.transformTask(processTaskRelations, taskDefinitionLogs); |
|
|
|
if (taskNodeList.size() != taskRelationList.size()) { |
|
|
|
if (taskNodeList.size() != taskRelationList.size()) { |
|
|
|
Set<Long> postTaskCodes = taskRelationList.stream().map(ProcessTaskRelationLog::getPostTaskCode).collect(Collectors.toSet()); |
|
|
|
Set<Long> postTaskCodes = taskRelationList.stream().map(ProcessTaskRelationLog::getPostTaskCode).collect(Collectors.toSet()); |
|
|
@ -301,7 +303,7 @@ 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)) { |
|
|
|
logger.error("the task code is not exit"); |
|
|
|
logger.error("the task code is not exit"); |
|
|
|
putMsg(result, Status.TASK_DEFINE_NOT_EXIST, StringUtils.join(codes, Constants.COMMA)); |
|
|
|
putMsg(result, Status.TASK_DEFINE_NOT_EXIST, org.apache.commons.lang.StringUtils.join(codes, Constants.COMMA)); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -330,7 +332,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
/** |
|
|
|
/** |
|
|
|
* query process definition list |
|
|
|
* query process definition list |
|
|
|
* |
|
|
|
* |
|
|
|
* @param loginUser login user |
|
|
|
* @param loginUser login user |
|
|
|
* @param projectCode project code |
|
|
|
* @param projectCode project code |
|
|
|
* @return definition list |
|
|
|
* @return definition list |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -352,12 +354,12 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
/** |
|
|
|
/** |
|
|
|
* query process definition list paging |
|
|
|
* query process definition list paging |
|
|
|
* |
|
|
|
* |
|
|
|
* @param loginUser login user |
|
|
|
* @param loginUser login user |
|
|
|
* @param projectCode project code |
|
|
|
* @param projectCode project code |
|
|
|
* @param searchVal search value |
|
|
|
* @param searchVal search value |
|
|
|
* @param userId user id |
|
|
|
* @param userId user id |
|
|
|
* @param pageNo page number |
|
|
|
* @param pageNo page number |
|
|
|
* @param pageSize page size |
|
|
|
* @param pageSize page size |
|
|
|
* @return process definition page |
|
|
|
* @return process definition page |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -374,7 +376,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
|
|
|
|
|
|
|
|
Page<ProcessDefinition> page = new Page<>(pageNo, pageSize); |
|
|
|
Page<ProcessDefinition> page = new Page<>(pageNo, pageSize); |
|
|
|
IPage<ProcessDefinition> processDefinitionIPage = processDefinitionMapper.queryDefineListPaging( |
|
|
|
IPage<ProcessDefinition> processDefinitionIPage = processDefinitionMapper.queryDefineListPaging( |
|
|
|
page, searchVal, userId, project.getCode(), isAdmin(loginUser)); |
|
|
|
page, searchVal, userId, project.getCode(), isAdmin(loginUser)); |
|
|
|
|
|
|
|
|
|
|
|
List<ProcessDefinition> records = processDefinitionIPage.getRecords(); |
|
|
|
List<ProcessDefinition> records = processDefinitionIPage.getRecords(); |
|
|
|
for (ProcessDefinition pd : records) { |
|
|
|
for (ProcessDefinition pd : records) { |
|
|
@ -395,9 +397,9 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
/** |
|
|
|
/** |
|
|
|
* query detail of process definition |
|
|
|
* query detail of process definition |
|
|
|
* |
|
|
|
* |
|
|
|
* @param loginUser login user |
|
|
|
* @param loginUser login user |
|
|
|
* @param projectCode project code |
|
|
|
* @param projectCode project code |
|
|
|
* @param code process definition code |
|
|
|
* @param code process definition code |
|
|
|
* @return process definition detail |
|
|
|
* @return process definition detail |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -447,16 +449,16 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
/** |
|
|
|
/** |
|
|
|
* update process definition |
|
|
|
* update process definition |
|
|
|
* |
|
|
|
* |
|
|
|
* @param loginUser login user |
|
|
|
* @param loginUser login user |
|
|
|
* @param projectCode project code |
|
|
|
* @param projectCode project code |
|
|
|
* @param name process definition name |
|
|
|
* @param name process definition name |
|
|
|
* @param code process definition code |
|
|
|
* @param code process definition code |
|
|
|
* @param description description |
|
|
|
* @param description description |
|
|
|
* @param globalParams global params |
|
|
|
* @param globalParams global params |
|
|
|
* @param locations locations for nodes |
|
|
|
* @param locations locations for nodes |
|
|
|
* @param timeout timeout |
|
|
|
* @param timeout timeout |
|
|
|
* @param tenantCode tenantCode |
|
|
|
* @param tenantCode tenantCode |
|
|
|
* @param taskRelationJson relation json for nodes |
|
|
|
* @param taskRelationJson relation json for nodes |
|
|
|
* @param taskDefinitionJson taskDefinitionJson |
|
|
|
* @param taskDefinitionJson taskDefinitionJson |
|
|
|
* @return update result code |
|
|
|
* @return update result code |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -472,7 +474,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
int timeout, |
|
|
|
int timeout, |
|
|
|
String tenantCode, |
|
|
|
String tenantCode, |
|
|
|
String taskRelationJson, |
|
|
|
String taskRelationJson, |
|
|
|
String taskDefinitionJson) { |
|
|
|
String taskDefinitionJson, |
|
|
|
|
|
|
|
ProcessExecutionTypeEnum executionType) { |
|
|
|
Project project = projectMapper.queryByCode(projectCode); |
|
|
|
Project project = projectMapper.queryByCode(projectCode); |
|
|
|
//check user access for project
|
|
|
|
//check user access for project
|
|
|
|
Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode); |
|
|
|
Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode); |
|
|
@ -522,6 +525,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
} |
|
|
|
} |
|
|
|
ProcessDefinition processDefinitionDeepCopy = JSONUtils.parseObject(JSONUtils.toJsonString(processDefinition), ProcessDefinition.class); |
|
|
|
ProcessDefinition processDefinitionDeepCopy = JSONUtils.parseObject(JSONUtils.toJsonString(processDefinition), ProcessDefinition.class); |
|
|
|
processDefinition.set(projectCode, name, description, globalParams, locations, timeout, tenantId); |
|
|
|
processDefinition.set(projectCode, name, description, globalParams, locations, timeout, tenantId); |
|
|
|
|
|
|
|
processDefinition.setExecutionType(executionType); |
|
|
|
return updateDagDefine(loginUser, taskRelationList, processDefinition, processDefinitionDeepCopy, taskDefinitionLogs); |
|
|
|
return updateDagDefine(loginUser, taskRelationList, processDefinition, processDefinitionDeepCopy, taskDefinitionLogs); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -551,7 +555,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
throw new ServiceException(Status.UPDATE_PROCESS_DEFINITION_ERROR); |
|
|
|
throw new ServiceException(Status.UPDATE_PROCESS_DEFINITION_ERROR); |
|
|
|
} |
|
|
|
} |
|
|
|
int insertResult = processService.saveTaskRelation(loginUser, processDefinition.getProjectCode(), |
|
|
|
int insertResult = processService.saveTaskRelation(loginUser, processDefinition.getProjectCode(), |
|
|
|
processDefinition.getCode(), insertVersion, taskRelationList, taskDefinitionLogs); |
|
|
|
processDefinition.getCode(), insertVersion, taskRelationList, taskDefinitionLogs); |
|
|
|
if (insertResult == Constants.EXIT_CODE_SUCCESS) { |
|
|
|
if (insertResult == Constants.EXIT_CODE_SUCCESS) { |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
result.put(Constants.DATA_LIST, processDefinition); |
|
|
|
result.put(Constants.DATA_LIST, processDefinition); |
|
|
@ -565,9 +569,9 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
/** |
|
|
|
/** |
|
|
|
* verify process definition name unique |
|
|
|
* verify process definition name unique |
|
|
|
* |
|
|
|
* |
|
|
|
* @param loginUser login user |
|
|
|
* @param loginUser login user |
|
|
|
* @param projectCode project code |
|
|
|
* @param projectCode project code |
|
|
|
* @param name name |
|
|
|
* @param name name |
|
|
|
* @return true if process definition name not exists, otherwise false |
|
|
|
* @return true if process definition name not exists, otherwise false |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -590,9 +594,9 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
/** |
|
|
|
/** |
|
|
|
* delete process definition by code |
|
|
|
* delete process definition by code |
|
|
|
* |
|
|
|
* |
|
|
|
* @param loginUser login user |
|
|
|
* @param loginUser login user |
|
|
|
* @param projectCode project code |
|
|
|
* @param projectCode project code |
|
|
|
* @param code process definition code |
|
|
|
* @param code process definition code |
|
|
|
* @return delete result code |
|
|
|
* @return delete result code |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -661,9 +665,9 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
/** |
|
|
|
/** |
|
|
|
* release process definition: online / offline |
|
|
|
* release process definition: online / offline |
|
|
|
* |
|
|
|
* |
|
|
|
* @param loginUser login user |
|
|
|
* @param loginUser login user |
|
|
|
* @param projectCode project code |
|
|
|
* @param projectCode project code |
|
|
|
* @param code process definition code |
|
|
|
* @param code process definition code |
|
|
|
* @param releaseState release state |
|
|
|
* @param releaseState release state |
|
|
|
* @return release result code |
|
|
|
* @return release result code |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -689,7 +693,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
case ONLINE: |
|
|
|
case ONLINE: |
|
|
|
// To check resources whether they are already cancel authorized or deleted
|
|
|
|
// To check resources whether they are already cancel authorized or deleted
|
|
|
|
String resourceIds = processDefinition.getResourceIds(); |
|
|
|
String resourceIds = processDefinition.getResourceIds(); |
|
|
|
if (StringUtils.isNotBlank(resourceIds)) { |
|
|
|
if (org.apache.commons.lang.StringUtils.isNotBlank(resourceIds)) { |
|
|
|
Integer[] resourceIdArray = Arrays.stream(resourceIds.split(Constants.COMMA)).map(Integer::parseInt).toArray(Integer[]::new); |
|
|
|
Integer[] resourceIdArray = Arrays.stream(resourceIds.split(Constants.COMMA)).map(Integer::parseInt).toArray(Integer[]::new); |
|
|
|
PermissionCheck<Integer> permissionCheck = new PermissionCheck<>(AuthorizationType.RESOURCE_FILE_ID, processService, resourceIdArray, loginUser.getId(), logger); |
|
|
|
PermissionCheck<Integer> permissionCheck = new PermissionCheck<>(AuthorizationType.RESOURCE_FILE_ID, processService, resourceIdArray, loginUser.getId(), logger); |
|
|
|
try { |
|
|
|
try { |
|
|
@ -708,7 +712,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
processDefinition.setReleaseState(releaseState); |
|
|
|
processDefinition.setReleaseState(releaseState); |
|
|
|
int updateProcess = processDefinitionMapper.updateById(processDefinition); |
|
|
|
int updateProcess = processDefinitionMapper.updateById(processDefinition); |
|
|
|
List<Schedule> scheduleList = scheduleMapper.selectAllByProcessDefineArray( |
|
|
|
List<Schedule> scheduleList = scheduleMapper.selectAllByProcessDefineArray( |
|
|
|
new long[]{processDefinition.getCode()} |
|
|
|
new long[]{processDefinition.getCode()} |
|
|
|
); |
|
|
|
); |
|
|
|
if (updateProcess > 0 && scheduleList.size() == 1) { |
|
|
|
if (updateProcess > 0 && scheduleList.size() == 1) { |
|
|
|
Schedule schedule = scheduleList.get(0); |
|
|
|
Schedule schedule = scheduleList.get(0); |
|
|
@ -737,7 +741,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void batchExportProcessDefinitionByCodes(User loginUser, long projectCode, String codes, HttpServletResponse response) { |
|
|
|
public void batchExportProcessDefinitionByCodes(User loginUser, long projectCode, String codes, HttpServletResponse response) { |
|
|
|
if (StringUtils.isEmpty(codes)) { |
|
|
|
if (org.apache.commons.lang.StringUtils.isEmpty(codes)) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
Project project = projectMapper.queryByCode(projectCode); |
|
|
|
Project project = projectMapper.queryByCode(projectCode); |
|
|
@ -807,9 +811,9 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
/** |
|
|
|
/** |
|
|
|
* import process definition |
|
|
|
* import process definition |
|
|
|
* |
|
|
|
* |
|
|
|
* @param loginUser login user |
|
|
|
* @param loginUser login user |
|
|
|
* @param projectCode project code |
|
|
|
* @param projectCode project code |
|
|
|
* @param file process metadata json file |
|
|
|
* @param file process metadata json file |
|
|
|
* @return import process |
|
|
|
* @return import process |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -1017,9 +1021,9 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
/** |
|
|
|
/** |
|
|
|
* get task node details based on process definition |
|
|
|
* get task node details based on process definition |
|
|
|
* |
|
|
|
* |
|
|
|
* @param loginUser loginUser |
|
|
|
* @param loginUser loginUser |
|
|
|
* @param projectCode project code |
|
|
|
* @param projectCode project code |
|
|
|
* @param code process definition code |
|
|
|
* @param code process definition code |
|
|
|
* @return task node list |
|
|
|
* @return task node list |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -1046,9 +1050,9 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
/** |
|
|
|
/** |
|
|
|
* get task node details map based on process definition |
|
|
|
* get task node details map based on process definition |
|
|
|
* |
|
|
|
* |
|
|
|
* @param loginUser loginUser |
|
|
|
* @param loginUser loginUser |
|
|
|
* @param projectCode project code |
|
|
|
* @param projectCode project code |
|
|
|
* @param codes define codes |
|
|
|
* @param codes define codes |
|
|
|
* @return task node list |
|
|
|
* @return task node list |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -1083,7 +1087,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
/** |
|
|
|
/** |
|
|
|
* query process definition all by project code |
|
|
|
* query process definition all by project code |
|
|
|
* |
|
|
|
* |
|
|
|
* @param loginUser loginUser |
|
|
|
* @param loginUser loginUser |
|
|
|
* @param projectCode project code |
|
|
|
* @param projectCode project code |
|
|
|
* @return process definitions in the project |
|
|
|
* @return process definitions in the project |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -1105,7 +1109,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Encapsulates the TreeView structure |
|
|
|
* Encapsulates the TreeView structure |
|
|
|
* |
|
|
|
* |
|
|
|
* @param code process definition code |
|
|
|
* @param code process definition code |
|
|
|
* @param limit limit |
|
|
|
* @param limit limit |
|
|
|
* @return tree view json data |
|
|
|
* @return tree view json data |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -1130,7 +1134,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
processInstanceList.forEach(processInstance -> processInstance.setDuration(DateUtils.format2Duration(processInstance.getStartTime(), processInstance.getEndTime()))); |
|
|
|
processInstanceList.forEach(processInstance -> processInstance.setDuration(DateUtils.format2Duration(processInstance.getStartTime(), processInstance.getEndTime()))); |
|
|
|
List<TaskDefinitionLog> taskDefinitionList = processService.genTaskDefineList(processTaskRelationMapper.queryByProcessCode(processDefinition.getProjectCode(), processDefinition.getCode())); |
|
|
|
List<TaskDefinitionLog> taskDefinitionList = processService.genTaskDefineList(processTaskRelationMapper.queryByProcessCode(processDefinition.getProjectCode(), processDefinition.getCode())); |
|
|
|
Map<Long, TaskDefinitionLog> taskDefinitionMap = taskDefinitionList.stream() |
|
|
|
Map<Long, TaskDefinitionLog> taskDefinitionMap = taskDefinitionList.stream() |
|
|
|
.collect(Collectors.toMap(TaskDefinitionLog::getCode, taskDefinitionLog -> taskDefinitionLog)); |
|
|
|
.collect(Collectors.toMap(TaskDefinitionLog::getCode, taskDefinitionLog -> taskDefinitionLog)); |
|
|
|
|
|
|
|
|
|
|
|
if (limit > processInstanceList.size()) { |
|
|
|
if (limit > processInstanceList.size()) { |
|
|
|
limit = processInstanceList.size(); |
|
|
|
limit = processInstanceList.size(); |
|
|
@ -1145,8 +1149,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
ProcessInstance processInstance = processInstanceList.get(i); |
|
|
|
ProcessInstance processInstance = processInstanceList.get(i); |
|
|
|
Date endTime = processInstance.getEndTime() == null ? new Date() : processInstance.getEndTime(); |
|
|
|
Date endTime = processInstance.getEndTime() == null ? new Date() : processInstance.getEndTime(); |
|
|
|
parentTreeViewDto.getInstances().add(new Instance(processInstance.getId(), processInstance.getName(), processInstance.getProcessDefinitionCode(), |
|
|
|
parentTreeViewDto.getInstances().add(new Instance(processInstance.getId(), processInstance.getName(), processInstance.getProcessDefinitionCode(), |
|
|
|
"", processInstance.getState().toString(), processInstance.getStartTime(), endTime, processInstance.getHost(), |
|
|
|
"", processInstance.getState().toString(), processInstance.getStartTime(), endTime, processInstance.getHost(), |
|
|
|
DateUtils.format2Readable(endTime.getTime() - processInstance.getStartTime().getTime()))); |
|
|
|
DateUtils.format2Readable(endTime.getTime() - processInstance.getStartTime().getTime()))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
List<TreeViewDto> parentTreeViewDtoList = new ArrayList<>(); |
|
|
|
List<TreeViewDto> parentTreeViewDtoList = new ArrayList<>(); |
|
|
@ -1184,11 +1188,11 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
if (taskInstance.isSubProcess()) { |
|
|
|
if (taskInstance.isSubProcess()) { |
|
|
|
TaskDefinition taskDefinition = taskDefinitionMap.get(taskInstance.getTaskCode()); |
|
|
|
TaskDefinition taskDefinition = taskDefinitionMap.get(taskInstance.getTaskCode()); |
|
|
|
subProcessId = Integer.parseInt(JSONUtils.parseObject( |
|
|
|
subProcessId = Integer.parseInt(JSONUtils.parseObject( |
|
|
|
taskDefinition.getTaskParams()).path(CMD_PARAM_SUB_PROCESS_DEFINE_ID).asText()); |
|
|
|
taskDefinition.getTaskParams()).path(CMD_PARAM_SUB_PROCESS_DEFINE_ID).asText()); |
|
|
|
} |
|
|
|
} |
|
|
|
treeViewDto.getInstances().add(new Instance(taskInstance.getId(), taskInstance.getName(), taskInstance.getTaskCode(), |
|
|
|
treeViewDto.getInstances().add(new Instance(taskInstance.getId(), taskInstance.getName(), taskInstance.getTaskCode(), |
|
|
|
taskInstance.getTaskType(), taskInstance.getState().toString(), taskInstance.getStartTime(), taskInstance.getEndTime(), |
|
|
|
taskInstance.getTaskType(), taskInstance.getState().toString(), taskInstance.getStartTime(), taskInstance.getEndTime(), |
|
|
|
taskInstance.getHost(), DateUtils.format2Readable(endTime.getTime() - startTime.getTime()), subProcessId)); |
|
|
|
taskInstance.getHost(), DateUtils.format2Readable(endTime.getTime() - startTime.getTime()), subProcessId)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
for (TreeViewDto pTreeViewDto : parentTreeViewDtoList) { |
|
|
|
for (TreeViewDto pTreeViewDto : parentTreeViewDtoList) { |
|
|
@ -1249,9 +1253,9 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
/** |
|
|
|
/** |
|
|
|
* batch copy process definition |
|
|
|
* batch copy process definition |
|
|
|
* |
|
|
|
* |
|
|
|
* @param loginUser loginUser |
|
|
|
* @param loginUser loginUser |
|
|
|
* @param projectCode projectCode |
|
|
|
* @param projectCode projectCode |
|
|
|
* @param codes processDefinitionCodes |
|
|
|
* @param codes processDefinitionCodes |
|
|
|
* @param targetProjectCode targetProjectCode |
|
|
|
* @param targetProjectCode targetProjectCode |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -1272,9 +1276,9 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
/** |
|
|
|
/** |
|
|
|
* batch move process definition |
|
|
|
* batch move process definition |
|
|
|
* |
|
|
|
* |
|
|
|
* @param loginUser loginUser |
|
|
|
* @param loginUser loginUser |
|
|
|
* @param projectCode projectCode |
|
|
|
* @param projectCode projectCode |
|
|
|
* @param codes processDefinitionCodes |
|
|
|
* @param codes processDefinitionCodes |
|
|
|
* @param targetProjectCode targetProjectCode |
|
|
|
* @param targetProjectCode targetProjectCode |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -1307,7 +1311,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(processDefinitionCodes)) { |
|
|
|
if (org.apache.commons.lang.StringUtils.isEmpty(processDefinitionCodes)) { |
|
|
|
putMsg(result, Status.PROCESS_DEFINITION_CODES_IS_EMPTY, processDefinitionCodes); |
|
|
|
putMsg(result, Status.PROCESS_DEFINITION_CODES_IS_EMPTY, processDefinitionCodes); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -1337,7 +1341,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
diffCode.forEach(code -> failedProcessList.add(code + "[null]")); |
|
|
|
diffCode.forEach(code -> failedProcessList.add(code + "[null]")); |
|
|
|
for (ProcessDefinition processDefinition : processDefinitionList) { |
|
|
|
for (ProcessDefinition processDefinition : processDefinitionList) { |
|
|
|
List<ProcessTaskRelation> processTaskRelations = |
|
|
|
List<ProcessTaskRelation> processTaskRelations = |
|
|
|
processTaskRelationMapper.queryByProcessCode(processDefinition.getProjectCode(), processDefinition.getCode()); |
|
|
|
processTaskRelationMapper.queryByProcessCode(processDefinition.getProjectCode(), processDefinition.getCode()); |
|
|
|
List<ProcessTaskRelationLog> taskRelationList = processTaskRelations.stream().map(ProcessTaskRelationLog::new).collect(Collectors.toList()); |
|
|
|
List<ProcessTaskRelationLog> taskRelationList = processTaskRelations.stream().map(ProcessTaskRelationLog::new).collect(Collectors.toList()); |
|
|
|
processDefinition.setProjectCode(targetProjectCode); |
|
|
|
processDefinition.setProjectCode(targetProjectCode); |
|
|
|
if (isCopy) { |
|
|
|
if (isCopy) { |
|
|
@ -1373,10 +1377,10 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
/** |
|
|
|
/** |
|
|
|
* switch the defined process definition version |
|
|
|
* switch the defined process definition version |
|
|
|
* |
|
|
|
* |
|
|
|
* @param loginUser login user |
|
|
|
* @param loginUser login user |
|
|
|
* @param projectCode project code |
|
|
|
* @param projectCode project code |
|
|
|
* @param code process definition code |
|
|
|
* @param code process definition code |
|
|
|
* @param version the version user want to switch |
|
|
|
* @param version the version user want to switch |
|
|
|
* @return switch process definition version result code |
|
|
|
* @return switch process definition version result code |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -1412,11 +1416,11 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
/** |
|
|
|
/** |
|
|
|
* check batch operate result |
|
|
|
* check batch operate result |
|
|
|
* |
|
|
|
* |
|
|
|
* @param srcProjectCode srcProjectCode |
|
|
|
* @param srcProjectCode srcProjectCode |
|
|
|
* @param targetProjectCode targetProjectCode |
|
|
|
* @param targetProjectCode targetProjectCode |
|
|
|
* @param result result |
|
|
|
* @param result result |
|
|
|
* @param failedProcessList failedProcessList |
|
|
|
* @param failedProcessList failedProcessList |
|
|
|
* @param isCopy isCopy |
|
|
|
* @param isCopy isCopy |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void checkBatchOperateResult(long srcProjectCode, long targetProjectCode, |
|
|
|
private void checkBatchOperateResult(long srcProjectCode, long targetProjectCode, |
|
|
|
Map<String, Object> result, List<String> failedProcessList, boolean isCopy) { |
|
|
|
Map<String, Object> result, List<String> failedProcessList, boolean isCopy) { |
|
|
@ -1434,11 +1438,11 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
/** |
|
|
|
/** |
|
|
|
* query the pagination versions info by one certain process definition code |
|
|
|
* query the pagination versions info by one certain process definition code |
|
|
|
* |
|
|
|
* |
|
|
|
* @param loginUser login user info to check auth |
|
|
|
* @param loginUser login user info to check auth |
|
|
|
* @param projectCode project code |
|
|
|
* @param projectCode project code |
|
|
|
* @param pageNo page number |
|
|
|
* @param pageNo page number |
|
|
|
* @param pageSize page size |
|
|
|
* @param pageSize page size |
|
|
|
* @param code process definition code |
|
|
|
* @param code process definition code |
|
|
|
* @return the pagination process definition versions info of the certain process definition |
|
|
|
* @return the pagination process definition versions info of the certain process definition |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -1468,10 +1472,10 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro |
|
|
|
/** |
|
|
|
/** |
|
|
|
* delete one certain process definition by version number and process definition code |
|
|
|
* delete one certain process definition by version number and process definition code |
|
|
|
* |
|
|
|
* |
|
|
|
* @param loginUser login user info to check auth |
|
|
|
* @param loginUser login user info to check auth |
|
|
|
* @param projectCode project code |
|
|
|
* @param projectCode project code |
|
|
|
* @param code process definition code |
|
|
|
* @param code process definition code |
|
|
|
* @param version version number |
|
|
|
* @param version version number |
|
|
|
* @return delete result code |
|
|
|
* @return delete result code |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|