|
|
@ -46,13 +46,14 @@ import org.apache.dolphinscheduler.common.enums.TimeoutFlag; |
|
|
|
import org.apache.dolphinscheduler.common.enums.WarningType; |
|
|
|
import org.apache.dolphinscheduler.common.enums.WarningType; |
|
|
|
import org.apache.dolphinscheduler.common.graph.DAG; |
|
|
|
import org.apache.dolphinscheduler.common.graph.DAG; |
|
|
|
import org.apache.dolphinscheduler.common.model.DateInterval; |
|
|
|
import org.apache.dolphinscheduler.common.model.DateInterval; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.common.model.PreviousTaskNode; |
|
|
|
import org.apache.dolphinscheduler.common.model.TaskNode; |
|
|
|
import org.apache.dolphinscheduler.common.model.TaskNode; |
|
|
|
import org.apache.dolphinscheduler.common.model.TaskNodeRelation; |
|
|
|
import org.apache.dolphinscheduler.common.model.TaskNodeRelation; |
|
|
|
import org.apache.dolphinscheduler.common.process.ProcessDag; |
|
|
|
import org.apache.dolphinscheduler.common.process.ProcessDag; |
|
|
|
import org.apache.dolphinscheduler.common.process.Property; |
|
|
|
import org.apache.dolphinscheduler.common.process.Property; |
|
|
|
import org.apache.dolphinscheduler.common.process.ResourceInfo; |
|
|
|
import org.apache.dolphinscheduler.common.process.ResourceInfo; |
|
|
|
import org.apache.dolphinscheduler.common.task.AbstractParameters; |
|
|
|
import org.apache.dolphinscheduler.common.task.AbstractParameters; |
|
|
|
import org.apache.dolphinscheduler.common.task.conditions.ConditionsParameters; |
|
|
|
import org.apache.dolphinscheduler.common.task.TaskTimeoutParameter; |
|
|
|
import org.apache.dolphinscheduler.common.task.subprocess.SubProcessParameters; |
|
|
|
import org.apache.dolphinscheduler.common.task.subprocess.SubProcessParameters; |
|
|
|
import org.apache.dolphinscheduler.common.utils.CollectionUtils; |
|
|
|
import org.apache.dolphinscheduler.common.utils.CollectionUtils; |
|
|
|
import org.apache.dolphinscheduler.common.utils.DateUtils; |
|
|
|
import org.apache.dolphinscheduler.common.utils.DateUtils; |
|
|
@ -499,7 +500,7 @@ public class ProcessService { |
|
|
|
* recursive query sub process definition id by parent id. |
|
|
|
* recursive query sub process definition id by parent id. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param parentId parentId |
|
|
|
* @param parentId parentId |
|
|
|
* @param ids ids |
|
|
|
* @param ids ids |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void recurseFindSubProcessId(int parentId, List<Integer> ids) { |
|
|
|
public void recurseFindSubProcessId(int parentId, List<Integer> ids) { |
|
|
|
List<TaskNode> taskNodeList = this.getTaskNodeListByDefinitionId(parentId); |
|
|
|
List<TaskNode> taskNodeList = this.getTaskNodeListByDefinitionId(parentId); |
|
|
@ -524,7 +525,7 @@ public class ProcessService { |
|
|
|
* create recovery waiting thread command and delete origin command at the same time. |
|
|
|
* create recovery waiting thread command and delete origin command at the same time. |
|
|
|
* if the recovery command is exists, only update the field update_time |
|
|
|
* if the recovery command is exists, only update the field update_time |
|
|
|
* |
|
|
|
* |
|
|
|
* @param originCommand originCommand |
|
|
|
* @param originCommand originCommand |
|
|
|
* @param processInstance processInstance |
|
|
|
* @param processInstance processInstance |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void createRecoveryWaitingThreadCommand(Command originCommand, ProcessInstance processInstance) { |
|
|
|
public void createRecoveryWaitingThreadCommand(Command originCommand, ProcessInstance processInstance) { |
|
|
@ -576,7 +577,7 @@ public class ProcessService { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* get schedule time from command |
|
|
|
* get schedule time from command |
|
|
|
* |
|
|
|
* |
|
|
|
* @param command command |
|
|
|
* @param command command |
|
|
|
* @param cmdParam cmdParam map |
|
|
|
* @param cmdParam cmdParam map |
|
|
|
* @return date |
|
|
|
* @return date |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -592,8 +593,8 @@ public class ProcessService { |
|
|
|
* generate a new work process instance from command. |
|
|
|
* generate a new work process instance from command. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param processDefinition processDefinition |
|
|
|
* @param processDefinition processDefinition |
|
|
|
* @param command command |
|
|
|
* @param command command |
|
|
|
* @param cmdParam cmdParam map |
|
|
|
* @param cmdParam cmdParam map |
|
|
|
* @return process instance |
|
|
|
* @return process instance |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private ProcessInstance generateNewProcessInstance(ProcessDefinition processDefinition, |
|
|
|
private ProcessInstance generateNewProcessInstance(ProcessDefinition processDefinition, |
|
|
@ -667,7 +668,7 @@ public class ProcessService { |
|
|
|
* use definition creator's tenant. |
|
|
|
* use definition creator's tenant. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param tenantId tenantId |
|
|
|
* @param tenantId tenantId |
|
|
|
* @param userId userId |
|
|
|
* @param userId userId |
|
|
|
* @return tenant |
|
|
|
* @return tenant |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public Tenant getTenantForProcess(int tenantId, int userId) { |
|
|
|
public Tenant getTenantForProcess(int tenantId, int userId) { |
|
|
@ -690,7 +691,7 @@ public class ProcessService { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* check command parameters is valid |
|
|
|
* check command parameters is valid |
|
|
|
* |
|
|
|
* |
|
|
|
* @param command command |
|
|
|
* @param command command |
|
|
|
* @param cmdParam cmdParam map |
|
|
|
* @param cmdParam cmdParam map |
|
|
|
* @return whether command param is valid |
|
|
|
* @return whether command param is valid |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -710,7 +711,7 @@ public class ProcessService { |
|
|
|
* construct process instance according to one command. |
|
|
|
* construct process instance according to one command. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param command command |
|
|
|
* @param command command |
|
|
|
* @param host host |
|
|
|
* @param host host |
|
|
|
* @return process instance |
|
|
|
* @return process instance |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private ProcessInstance constructProcessInstance(Command command, String host) { |
|
|
|
private ProcessInstance constructProcessInstance(Command command, String host) { |
|
|
@ -868,7 +869,7 @@ public class ProcessService { |
|
|
|
* return complement data if the process start with complement data |
|
|
|
* return complement data if the process start with complement data |
|
|
|
* |
|
|
|
* |
|
|
|
* @param processInstance processInstance |
|
|
|
* @param processInstance processInstance |
|
|
|
* @param command command |
|
|
|
* @param command command |
|
|
|
* @return command type |
|
|
|
* @return command type |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private CommandType getCommandTypeIfComplement(ProcessInstance processInstance, Command command) { |
|
|
|
private CommandType getCommandTypeIfComplement(ProcessInstance processInstance, Command command) { |
|
|
@ -883,8 +884,8 @@ public class ProcessService { |
|
|
|
* initialize complement data parameters |
|
|
|
* initialize complement data parameters |
|
|
|
* |
|
|
|
* |
|
|
|
* @param processDefinition processDefinition |
|
|
|
* @param processDefinition processDefinition |
|
|
|
* @param processInstance processInstance |
|
|
|
* @param processInstance processInstance |
|
|
|
* @param cmdParam cmdParam |
|
|
|
* @param cmdParam cmdParam |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void initComplementDataParam(ProcessDefinition processDefinition, |
|
|
|
private void initComplementDataParam(ProcessDefinition processDefinition, |
|
|
|
ProcessInstance processInstance, |
|
|
|
ProcessInstance processInstance, |
|
|
@ -956,7 +957,7 @@ public class ProcessService { |
|
|
|
* only the keys doesn't in sub process global would be joined. |
|
|
|
* only the keys doesn't in sub process global would be joined. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param parentGlobalParams parentGlobalParams |
|
|
|
* @param parentGlobalParams parentGlobalParams |
|
|
|
* @param subGlobalParams subGlobalParams |
|
|
|
* @param subGlobalParams subGlobalParams |
|
|
|
* @return global params join |
|
|
|
* @return global params join |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private String joinGlobalParams(String parentGlobalParams, String subGlobalParams) { |
|
|
|
private String joinGlobalParams(String parentGlobalParams, String subGlobalParams) { |
|
|
@ -1026,7 +1027,7 @@ public class ProcessService { |
|
|
|
* set map {parent instance id, task instance id, 0(child instance id)} |
|
|
|
* set map {parent instance id, task instance id, 0(child instance id)} |
|
|
|
* |
|
|
|
* |
|
|
|
* @param parentInstance parentInstance |
|
|
|
* @param parentInstance parentInstance |
|
|
|
* @param parentTask parentTask |
|
|
|
* @param parentTask parentTask |
|
|
|
* @return process instance map |
|
|
|
* @return process instance map |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private ProcessInstanceMap setProcessInstanceMap(ProcessInstance parentInstance, TaskInstance parentTask) { |
|
|
|
private ProcessInstanceMap setProcessInstanceMap(ProcessInstance parentInstance, TaskInstance parentTask) { |
|
|
@ -1055,7 +1056,7 @@ public class ProcessService { |
|
|
|
* find previous task work process map. |
|
|
|
* find previous task work process map. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param parentProcessInstance parentProcessInstance |
|
|
|
* @param parentProcessInstance parentProcessInstance |
|
|
|
* @param parentTask parentTask |
|
|
|
* @param parentTask parentTask |
|
|
|
* @return process instance map |
|
|
|
* @return process instance map |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private ProcessInstanceMap findPreviousTaskProcessMap(ProcessInstance parentProcessInstance, |
|
|
|
private ProcessInstanceMap findPreviousTaskProcessMap(ProcessInstance parentProcessInstance, |
|
|
@ -1081,7 +1082,7 @@ public class ProcessService { |
|
|
|
* create sub work process command |
|
|
|
* create sub work process command |
|
|
|
* |
|
|
|
* |
|
|
|
* @param parentProcessInstance parentProcessInstance |
|
|
|
* @param parentProcessInstance parentProcessInstance |
|
|
|
* @param task task |
|
|
|
* @param task task |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void createSubWorkProcess(ProcessInstance parentProcessInstance, TaskInstance task) { |
|
|
|
public void createSubWorkProcess(ProcessInstance parentProcessInstance, TaskInstance task) { |
|
|
|
if (!task.isSubProcess()) { |
|
|
|
if (!task.isSubProcess()) { |
|
|
@ -1180,7 +1181,7 @@ public class ProcessService { |
|
|
|
* update sub process definition |
|
|
|
* update sub process definition |
|
|
|
* |
|
|
|
* |
|
|
|
* @param parentProcessInstance parentProcessInstance |
|
|
|
* @param parentProcessInstance parentProcessInstance |
|
|
|
* @param childDefinitionId childDefinitionId |
|
|
|
* @param childDefinitionId childDefinitionId |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void updateSubProcessDefinitionByParent(ProcessInstance parentProcessInstance, int childDefinitionId) { |
|
|
|
private void updateSubProcessDefinitionByParent(ProcessInstance parentProcessInstance, int childDefinitionId) { |
|
|
|
ProcessDefinition fatherDefinition = this.findProcessDefineById(parentProcessInstance.getProcessDefinitionId()); |
|
|
|
ProcessDefinition fatherDefinition = this.findProcessDefineById(parentProcessInstance.getProcessDefinitionId()); |
|
|
@ -1194,7 +1195,7 @@ public class ProcessService { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* submit task to mysql |
|
|
|
* submit task to mysql |
|
|
|
* |
|
|
|
* |
|
|
|
* @param taskInstance taskInstance |
|
|
|
* @param taskInstance taskInstance |
|
|
|
* @param processInstance processInstance |
|
|
|
* @param processInstance processInstance |
|
|
|
* @return task instance |
|
|
|
* @return task instance |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -1248,7 +1249,7 @@ public class ProcessService { |
|
|
|
* return stop if work process state is ready stop |
|
|
|
* return stop if work process state is ready stop |
|
|
|
* if all of above are not satisfied, return submit success |
|
|
|
* if all of above are not satisfied, return submit success |
|
|
|
* |
|
|
|
* |
|
|
|
* @param taskInstance taskInstance |
|
|
|
* @param taskInstance taskInstance |
|
|
|
* @param processInstanceState processInstanceState |
|
|
|
* @param processInstanceState processInstanceState |
|
|
|
* @return process instance state |
|
|
|
* @return process instance state |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -1424,7 +1425,7 @@ public class ProcessService { |
|
|
|
* get id list by task state |
|
|
|
* get id list by task state |
|
|
|
* |
|
|
|
* |
|
|
|
* @param instanceId instanceId |
|
|
|
* @param instanceId instanceId |
|
|
|
* @param state state |
|
|
|
* @param state state |
|
|
|
* @return task instance states |
|
|
|
* @return task instance states |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public List<Integer> findTaskIdByInstanceState(int instanceId, ExecutionStatus state) { |
|
|
|
public List<Integer> findTaskIdByInstanceState(int instanceId, ExecutionStatus state) { |
|
|
@ -1479,7 +1480,7 @@ public class ProcessService { |
|
|
|
* find work process map by parent process id and parent task id. |
|
|
|
* find work process map by parent process id and parent task id. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param parentWorkProcessId parentWorkProcessId |
|
|
|
* @param parentWorkProcessId parentWorkProcessId |
|
|
|
* @param parentTaskId parentTaskId |
|
|
|
* @param parentTaskId parentTaskId |
|
|
|
* @return process instance map |
|
|
|
* @return process instance map |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public ProcessInstanceMap findWorkProcessMapByParent(Integer parentWorkProcessId, Integer parentTaskId) { |
|
|
|
public ProcessInstanceMap findWorkProcessMapByParent(Integer parentWorkProcessId, Integer parentTaskId) { |
|
|
@ -1501,7 +1502,7 @@ public class ProcessService { |
|
|
|
* find sub process instance |
|
|
|
* find sub process instance |
|
|
|
* |
|
|
|
* |
|
|
|
* @param parentProcessId parentProcessId |
|
|
|
* @param parentProcessId parentProcessId |
|
|
|
* @param parentTaskId parentTaskId |
|
|
|
* @param parentTaskId parentTaskId |
|
|
|
* @return process instance |
|
|
|
* @return process instance |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public ProcessInstance findSubProcessInstance(Integer parentProcessId, Integer parentTaskId) { |
|
|
|
public ProcessInstance findSubProcessInstance(Integer parentProcessId, Integer parentTaskId) { |
|
|
@ -1533,12 +1534,12 @@ public class ProcessService { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* change task state |
|
|
|
* change task state |
|
|
|
* |
|
|
|
* |
|
|
|
* @param state state |
|
|
|
* @param state state |
|
|
|
* @param startTime startTime |
|
|
|
* @param startTime startTime |
|
|
|
* @param host host |
|
|
|
* @param host host |
|
|
|
* @param executePath executePath |
|
|
|
* @param executePath executePath |
|
|
|
* @param logPath logPath |
|
|
|
* @param logPath logPath |
|
|
|
* @param taskInstId taskInstId |
|
|
|
* @param taskInstId taskInstId |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void changeTaskState(TaskInstance taskInstance, ExecutionStatus state, Date startTime, String host, |
|
|
|
public void changeTaskState(TaskInstance taskInstance, ExecutionStatus state, Date startTime, String host, |
|
|
|
String executePath, |
|
|
|
String executePath, |
|
|
@ -1566,12 +1567,12 @@ public class ProcessService { |
|
|
|
* update the process instance |
|
|
|
* update the process instance |
|
|
|
* |
|
|
|
* |
|
|
|
* @param processInstanceId processInstanceId |
|
|
|
* @param processInstanceId processInstanceId |
|
|
|
* @param processJson processJson |
|
|
|
* @param processJson processJson |
|
|
|
* @param globalParams globalParams |
|
|
|
* @param globalParams globalParams |
|
|
|
* @param scheduleTime scheduleTime |
|
|
|
* @param scheduleTime scheduleTime |
|
|
|
* @param flag flag |
|
|
|
* @param flag flag |
|
|
|
* @param locations locations |
|
|
|
* @param locations locations |
|
|
|
* @param connects connects |
|
|
|
* @param connects connects |
|
|
|
* @return update process instance result |
|
|
|
* @return update process instance result |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public int updateProcessInstance(Integer processInstanceId, String processJson, |
|
|
|
public int updateProcessInstance(Integer processInstanceId, String processJson, |
|
|
@ -1592,10 +1593,10 @@ public class ProcessService { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* change task state |
|
|
|
* change task state |
|
|
|
* |
|
|
|
* |
|
|
|
* @param state state |
|
|
|
* @param state state |
|
|
|
* @param endTime endTime |
|
|
|
* @param endTime endTime |
|
|
|
* @param taskInstId taskInstId |
|
|
|
* @param taskInstId taskInstId |
|
|
|
* @param varPool varPool |
|
|
|
* @param varPool varPool |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void changeTaskState(TaskInstance taskInstance, ExecutionStatus state, |
|
|
|
public void changeTaskState(TaskInstance taskInstance, ExecutionStatus state, |
|
|
|
Date endTime, |
|
|
|
Date endTime, |
|
|
@ -1763,7 +1764,7 @@ public class ProcessService { |
|
|
|
* update process instance state by id |
|
|
|
* update process instance state by id |
|
|
|
* |
|
|
|
* |
|
|
|
* @param processInstanceId processInstanceId |
|
|
|
* @param processInstanceId processInstanceId |
|
|
|
* @param executionStatus executionStatus |
|
|
|
* @param executionStatus executionStatus |
|
|
|
* @return update process result |
|
|
|
* @return update process result |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public int updateProcessInstanceState(Integer processInstanceId, ExecutionStatus executionStatus) { |
|
|
|
public int updateProcessInstanceState(Integer processInstanceId, ExecutionStatus executionStatus) { |
|
|
@ -1800,7 +1801,7 @@ public class ProcessService { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* find tenant code by resource name |
|
|
|
* find tenant code by resource name |
|
|
|
* |
|
|
|
* |
|
|
|
* @param resName resource name |
|
|
|
* @param resName resource name |
|
|
|
* @param resourceType resource type |
|
|
|
* @param resourceType resource type |
|
|
|
* @return tenant code |
|
|
|
* @return tenant code |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -1824,9 +1825,9 @@ public class ProcessService { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* get dependency cycle by work process define id and scheduler fire time |
|
|
|
* get dependency cycle by work process define id and scheduler fire time |
|
|
|
* |
|
|
|
* |
|
|
|
* @param masterId masterId |
|
|
|
* @param masterId masterId |
|
|
|
* @param processDefinitionId processDefinitionId |
|
|
|
* @param processDefinitionId processDefinitionId |
|
|
|
* @param scheduledFireTime the time the task schedule is expected to trigger |
|
|
|
* @param scheduledFireTime the time the task schedule is expected to trigger |
|
|
|
* @return CycleDependency |
|
|
|
* @return CycleDependency |
|
|
|
* @throws Exception if error throws Exception |
|
|
|
* @throws Exception if error throws Exception |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -1839,8 +1840,8 @@ public class ProcessService { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* get dependency cycle list by work process define id list and scheduler fire time |
|
|
|
* get dependency cycle list by work process define id list and scheduler fire time |
|
|
|
* |
|
|
|
* |
|
|
|
* @param masterId masterId |
|
|
|
* @param masterId masterId |
|
|
|
* @param ids ids |
|
|
|
* @param ids ids |
|
|
|
* @param scheduledFireTime the time the task schedule is expected to trigger |
|
|
|
* @param scheduledFireTime the time the task schedule is expected to trigger |
|
|
|
* @return CycleDependency list |
|
|
|
* @return CycleDependency list |
|
|
|
* @throws Exception if error throws Exception |
|
|
|
* @throws Exception if error throws Exception |
|
|
@ -1935,8 +1936,8 @@ public class ProcessService { |
|
|
|
* find last running process instance |
|
|
|
* find last running process instance |
|
|
|
* |
|
|
|
* |
|
|
|
* @param definitionId process definition id |
|
|
|
* @param definitionId process definition id |
|
|
|
* @param startTime start time |
|
|
|
* @param startTime start time |
|
|
|
* @param endTime end time |
|
|
|
* @param endTime end time |
|
|
|
* @return process instance |
|
|
|
* @return process instance |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public ProcessInstance findLastRunningProcess(int definitionId, Date startTime, Date endTime) { |
|
|
|
public ProcessInstance findLastRunningProcess(int definitionId, Date startTime, Date endTime) { |
|
|
@ -2036,7 +2037,7 @@ public class ProcessService { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* list unauthorized udf function |
|
|
|
* list unauthorized udf function |
|
|
|
* |
|
|
|
* |
|
|
|
* @param userId user id |
|
|
|
* @param userId user id |
|
|
|
* @param needChecks data source id array |
|
|
|
* @param needChecks data source id array |
|
|
|
* @return unauthorized udf function list |
|
|
|
* @return unauthorized udf function list |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -2227,7 +2228,6 @@ public class ProcessService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* save processDefinition (including create or update processDefinition) |
|
|
|
* save processDefinition (including create or update processDefinition) |
|
|
|
* |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public int saveProcessDefinition(User operator, Project project, String name, String desc, String locations, |
|
|
|
public int saveProcessDefinition(User operator, Project project, String name, String desc, String locations, |
|
|
|
String connects, ProcessData processData, ProcessDefinition processDefinition) { |
|
|
|
String connects, ProcessData processData, ProcessDefinition processDefinition) { |
|
|
@ -2403,10 +2403,6 @@ public class ProcessService { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* get process task relation list |
|
|
|
* get process task relation list |
|
|
|
* this function can be query relation list from log record |
|
|
|
* this function can be query relation list from log record |
|
|
|
* |
|
|
|
|
|
|
|
* @param processCode |
|
|
|
|
|
|
|
* @param processVersion |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public List<ProcessTaskRelation> getProcessTaskRelationList(Long processCode, int processVersion) { |
|
|
|
public List<ProcessTaskRelation> getProcessTaskRelationList(Long processCode, int processVersion) { |
|
|
|
List<ProcessTaskRelationLog> taskRelationLogs = processTaskRelationLogMapper.queryByProcessCodeAndVersion( |
|
|
|
List<ProcessTaskRelationLog> taskRelationLogs = processTaskRelationLogMapper.queryByProcessCodeAndVersion( |
|
|
@ -2419,4 +2415,57 @@ public class ProcessService { |
|
|
|
return processTaskRelations; |
|
|
|
return processTaskRelations; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<TaskNode> genTaskNodeList(Long processCode, int processVersion) { |
|
|
|
|
|
|
|
List<ProcessTaskRelation> processTaskRelations = this.getProcessTaskRelationList(processCode, processVersion); |
|
|
|
|
|
|
|
Set<TaskDefinition> taskDefinitionSet = new HashSet<>(); |
|
|
|
|
|
|
|
Map<Long, TaskNode> taskNodeMap = new HashMap<>(); |
|
|
|
|
|
|
|
for (ProcessTaskRelation processTaskRelation : processTaskRelations) { |
|
|
|
|
|
|
|
if (processTaskRelation.getPreTaskCode() > 0) { |
|
|
|
|
|
|
|
taskDefinitionSet.add(new TaskDefinition(processTaskRelation.getPreTaskCode(), processTaskRelation.getPreNodeVersion())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (processTaskRelation.getPostTaskCode() > 0) { |
|
|
|
|
|
|
|
taskDefinitionSet.add(new TaskDefinition(processTaskRelation.getPostTaskCode(), processTaskRelation.getPostNodeVersion())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
taskNodeMap.compute(processTaskRelation.getPostTaskCode(), (k, v) -> { |
|
|
|
|
|
|
|
if (v == null) { |
|
|
|
|
|
|
|
v = new TaskNode(); |
|
|
|
|
|
|
|
v.setCode(processTaskRelation.getPostTaskCode()); |
|
|
|
|
|
|
|
v.setVersion(processTaskRelation.getPostNodeVersion()); |
|
|
|
|
|
|
|
v.setConditionResult(processTaskRelation.getConditionParams()); |
|
|
|
|
|
|
|
List<PreviousTaskNode> preTaskNodeList = new ArrayList<>(); |
|
|
|
|
|
|
|
if (processTaskRelation.getPreTaskCode() > 0) { |
|
|
|
|
|
|
|
preTaskNodeList.add(new PreviousTaskNode(processTaskRelation.getPreTaskCode(), "", processTaskRelation.getPreNodeVersion())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
v.setPreTaskNodeList(preTaskNodeList); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
List<PreviousTaskNode> preTaskDefinitionList = v.getPreTaskNodeList(); |
|
|
|
|
|
|
|
preTaskDefinitionList.add(new PreviousTaskNode(processTaskRelation.getPreTaskCode(), "", processTaskRelation.getPreNodeVersion())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return v; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<TaskDefinitionLog> taskDefinitionLogs = taskDefinitionLogMapper.queryByTaskDefinitions(taskDefinitionSet); |
|
|
|
|
|
|
|
Map<Long, TaskDefinitionLog> taskDefinitionLogMap = taskDefinitionLogs.stream().collect(Collectors.toMap(TaskDefinitionLog::getCode, log -> log)); |
|
|
|
|
|
|
|
taskNodeMap.forEach((k, v) -> { |
|
|
|
|
|
|
|
TaskDefinitionLog taskDefinitionLog = taskDefinitionLogMap.get(k); |
|
|
|
|
|
|
|
v.setId("task-" + taskDefinitionLog.getId()); |
|
|
|
|
|
|
|
v.setCode(taskDefinitionLog.getCode()); |
|
|
|
|
|
|
|
v.setName(taskDefinitionLog.getName()); |
|
|
|
|
|
|
|
v.setDesc(taskDefinitionLog.getDescription()); |
|
|
|
|
|
|
|
v.setType(taskDefinitionLog.getTaskType().getDescp()); |
|
|
|
|
|
|
|
v.setRunFlag(taskDefinitionLog.getFlag() == Flag.YES ? Constants.FLOWNODE_RUN_FLAG_FORBIDDEN : "NORMAL"); |
|
|
|
|
|
|
|
v.setMaxRetryTimes(taskDefinitionLog.getFailRetryTimes()); |
|
|
|
|
|
|
|
v.setRetryInterval(taskDefinitionLog.getFailRetryInterval()); |
|
|
|
|
|
|
|
v.setParams(taskDefinitionLog.getTaskParams()); |
|
|
|
|
|
|
|
v.setTaskInstancePriority(taskDefinitionLog.getTaskPriority()); |
|
|
|
|
|
|
|
v.setWorkerGroup(taskDefinitionLog.getWorkerGroup()); |
|
|
|
|
|
|
|
v.setTimeout(JSONUtils.toJsonString(new TaskTimeoutParameter(taskDefinitionLog.getTimeoutFlag() == TimeoutFlag.OPEN, |
|
|
|
|
|
|
|
taskDefinitionLog.getTaskTimeoutStrategy(), |
|
|
|
|
|
|
|
taskDefinitionLog.getTimeout()))); |
|
|
|
|
|
|
|
// TODO name will be remove
|
|
|
|
|
|
|
|
v.getPreTaskNodeList().forEach(task -> task.setName(taskDefinitionLogMap.get(task.getCode()).getName())); |
|
|
|
|
|
|
|
v.setPreTasks(StringUtils.join(v.getPreTaskNodeList().stream().map(PreviousTaskNode::getName).collect(Collectors.toList()), ",")); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
return new ArrayList<>(taskNodeMap.values()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|