Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix-10762] [bug] Dependent tasks wait for the workflow to end #10765

Merged
merged 10 commits into from
Jul 4, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.regex.Matcher;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,16 @@ private DependResult calculateResultForTasks(DependentItem dependentItem, List<D
dependentItem.getDefinitionCode(), dependentItem.getDepTaskCode());
return DependResult.WAITING;
}
if (!processInstance.getState().typeIsFinished()) {
logger.info("Wait for the dependent workflow to complete, processDefiniteCode:{}, taskCode:{}, processInstanceId:{}, processInstance state:{}",
dependentItem.getDefinitionCode(), dependentItem.getDepTaskCode(), processInstance.getId(), processInstance.getState());
return DependResult.WAITING;
}
// need to check workflow for updates, so get all task and check the task state
if (dependentItem.getDepTaskCode() == Constants.DEPENDENT_ALL_TASK_CODE) {
if (!processInstance.getState().typeIsFinished()) {
logger.info("Wait for the dependent workflow to complete, processDefiniteCode:{}, taskCode:{}, processInstanceId:{}, processInstance state:{}",
dependentItem.getDefinitionCode(), dependentItem.getDepTaskCode(), processInstance.getId(), processInstance.getState());
return DependResult.WAITING;
}
result = dependResultByProcessInstance(processInstance, dateInterval);
} else {
result = getDependTaskResult(dependentItem.getDepTaskCode(), dateInterval);
result = getDependTaskResult(processInstance, dependentItem.getDepTaskCode(), dateInterval);
}
if (result != DependResult.SUCCESS) {
break;
Expand Down Expand Up @@ -192,10 +192,15 @@ private DependResult dependResultByProcessInstance(ProcessInstance processInstan
/**
* get depend task result
*/
private DependResult getDependTaskResult(long taskCode, DateInterval dateInterval) {
private DependResult getDependTaskResult(ProcessInstance processInstance, long taskCode, DateInterval dateInterval) {
TaskInstance taskInstance = processService.findLastTaskInstanceInterval(taskCode, dateInterval);
DependResult result;
if (taskInstance == null) {
if (!processInstance.getState().typeIsFinished()) {
logger.info("Wait for the dependent workflow to complete, taskCode:{}, processInstanceId:{}, processInstance state:{}",
taskCode, processInstance.getId(), processInstance.getState());
return DependResult.WAITING;
}
TaskDefinition taskDefinition = processService.findTaskDefinitionByCode(taskCode);
if (taskDefinition == null) {
logger.error("Cannot find the task definition, something error, taskCode: {}", taskCode);
Expand Down