feat(REQ-7380) - 调整预检查逻辑中未适配category 版本的问题
This commit is contained in:
parent
1eea58850d
commit
1397e09913
@ -13,6 +13,7 @@ import cn.hutool.json.JSONUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.flowable.bpmn.model.FlowElement;
|
||||
import org.flowable.bpmn.model.Process;
|
||||
import org.flowable.bpmn.model.ReceiveTask;
|
||||
import org.flowable.bpmn.model.ServiceTask;
|
||||
import org.flowable.bpmn.model.UserTask;
|
||||
@ -22,6 +23,7 @@ import org.flowable.engine.RuntimeService;
|
||||
import org.flowable.engine.delegate.DelegateExecution;
|
||||
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
|
||||
import org.flowable.engine.impl.util.CommandContextUtil;
|
||||
import org.flowable.engine.impl.util.ProcessDefinitionUtil;
|
||||
import org.flowable.engine.runtime.Execution;
|
||||
import org.flowable.engine.runtime.ProcessInstance;
|
||||
import org.flowable.job.service.JobHandler;
|
||||
@ -38,6 +40,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
import static cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper.getApprovalMethod;
|
||||
import static cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper.getApproverEmptyHandleType;
|
||||
import static cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper.getApproverSpecify;
|
||||
import static cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper.getCategoryVersion;
|
||||
|
||||
/**
|
||||
* 检查节点配置是否合法
|
||||
@ -71,7 +74,9 @@ public class NextActivityConfigCheckJobHandler extends AbstractJobHandler implem
|
||||
return;
|
||||
}
|
||||
try {
|
||||
doCheck(job, flowElements, processEngineConfiguration);
|
||||
Process mainProcess = ProcessDefinitionUtil.getBpmnModel(processInstance.getProcessDefinitionId()).getMainProcess();
|
||||
Optional<Integer> categoryVersion = getCategoryVersion(mainProcess);
|
||||
doCheck(job, flowElements, processEngineConfiguration, categoryVersion.get());
|
||||
} catch (Exception e) {
|
||||
// 有任何异常,则通过钉钉告警
|
||||
log.warn("NextActivityConfigCheckJobHandler msg: {}", e.getMessage(), e);
|
||||
@ -89,7 +94,7 @@ public class NextActivityConfigCheckJobHandler extends AbstractJobHandler implem
|
||||
}
|
||||
}
|
||||
|
||||
private void doCheck(JobEntity job, List<FlowElement> flowElements, ProcessEngineConfigurationImpl processEngineConfiguration) {
|
||||
private void doCheck(JobEntity job, List<FlowElement> flowElements, ProcessEngineConfigurationImpl processEngineConfiguration, Integer categoryVersion) {
|
||||
AtomicReference<String> checkActivityId = new AtomicReference<>("");
|
||||
ListUtils.emptyIfNull(flowElements).stream()
|
||||
.filter(i -> i instanceof UserTask || i instanceof ReceiveTask || i instanceof ServiceTask)
|
||||
@ -115,8 +120,9 @@ public class NextActivityConfigCheckJobHandler extends AbstractJobHandler implem
|
||||
assigners.addAll(approverSelect(specify.getType(), flowElement, (DelegateExecution) executions.get(0), true));
|
||||
});
|
||||
|
||||
|
||||
// 审批候选人为空时的兜底
|
||||
emptyAssigneeHandle(assigners, flowElement, (DelegateExecution) executions.get(0));
|
||||
emptyAssigneeHandle(assigners, flowElement, (DelegateExecution) executions.get(0), categoryVersion);
|
||||
break;
|
||||
}
|
||||
});
|
||||
@ -144,12 +150,13 @@ public class NextActivityConfigCheckJobHandler extends AbstractJobHandler implem
|
||||
/**
|
||||
* 计算节点的待审批人为空时, 执行模型配置中的审批人为空时的处理方式
|
||||
*
|
||||
* @param assigners 节点计算的待审批人集合, 可能为空
|
||||
* @param flowElement 当前节点
|
||||
* @param execution 当前执行实例
|
||||
* @param assigners 节点计算的待审批人集合, 可能为空
|
||||
* @param flowElement 当前节点
|
||||
* @param execution 当前执行实例
|
||||
* @param categoryVersion
|
||||
*/
|
||||
private void emptyAssigneeHandle(List<BpmnTaskDelegateAssigner> assigners, FlowElement flowElement,
|
||||
DelegateExecution execution) {
|
||||
DelegateExecution execution, Integer categoryVersion) {
|
||||
// 审批人为空并且当前节点设置了自动跳过条件
|
||||
if (!CollectionUtils.isEmpty(assigners)) {
|
||||
return;
|
||||
@ -163,10 +170,12 @@ public class NextActivityConfigCheckJobHandler extends AbstractJobHandler implem
|
||||
break;
|
||||
case transferToAdmin:
|
||||
try {
|
||||
assigners.addAll(approverSelect(ApproverEmptyHandleTypeEnum.transferToAdmin.getType(), flowElement,
|
||||
execution, true));
|
||||
if (CollectionUtils.isEmpty(assigners)) {
|
||||
throw new IllegalArgumentException("审批人为空后转交管理员仍然为空");
|
||||
if (categoryVersion < 2) {
|
||||
assigners.addAll(approverSelect(ApproverEmptyHandleTypeEnum.transferToAdmin.getType(), flowElement,
|
||||
execution, true));
|
||||
if (CollectionUtils.isEmpty(assigners)) {
|
||||
throw new IllegalArgumentException("审批人为空后转交管理员仍然为空");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (e instanceof IllegalArgumentException) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user