From bacec8a72e15ccf01e94866eedd95864e657663b Mon Sep 17 00:00:00 2001 From: wangli <274027703@qq.com> Date: Wed, 11 Sep 2024 20:47:18 +0800 Subject: [PATCH] =?UTF-8?q?feat(REQ-2924)=20-=20=E5=9C=A8=E4=B8=9A?= =?UTF-8?q?=E5=8A=A1=E8=AE=BE=E7=BD=AE=E4=BA=86=E5=AE=A1=E6=89=B9=E4=BA=BA?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E9=87=8D=E6=96=B0=E5=8F=96=E6=B6=88=E5=91=8A?= =?UTF-8?q?=E8=AD=A6=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CustomBizSpecifyAssigneeToTaskCmd.java | 36 ++++++++++++++----- ...BpmnActivityEventListener_lo_Listener.java | 3 +- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/workflow-engine-core/src/main/java/cn/axzo/workflow/core/engine/cmd/CustomBizSpecifyAssigneeToTaskCmd.java b/workflow-engine-core/src/main/java/cn/axzo/workflow/core/engine/cmd/CustomBizSpecifyAssigneeToTaskCmd.java index f1dd7acbc..e6b891e63 100644 --- a/workflow-engine-core/src/main/java/cn/axzo/workflow/core/engine/cmd/CustomBizSpecifyAssigneeToTaskCmd.java +++ b/workflow-engine-core/src/main/java/cn/axzo/workflow/core/engine/cmd/CustomBizSpecifyAssigneeToTaskCmd.java @@ -6,11 +6,14 @@ import cn.axzo.workflow.core.engine.cmd.helper.CustomTaskHelper; import com.alibaba.fastjson.JSON; import org.flowable.common.engine.impl.interceptor.CommandContext; import org.flowable.engine.HistoryService; +import org.flowable.engine.ManagementService; import org.flowable.engine.RuntimeService; import org.flowable.engine.TaskService; import org.flowable.engine.history.HistoricProcessInstance; import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; import org.flowable.engine.impl.util.CommandContextUtil; +import org.flowable.job.api.Job; +import org.flowable.job.service.impl.persistence.entity.TimerJobEntity; import org.flowable.task.api.Task; import org.flowable.task.service.impl.persistence.entity.TaskEntity; import org.springframework.util.CollectionUtils; @@ -59,8 +62,8 @@ public class CustomBizSpecifyAssigneeToTaskCmd extends AbstractCommand public static Task getOperateTask(TaskService taskService, String executionId) { return taskService.createTaskQuery().executionId(executionId) - .taskAssignee(NO_ASSIGNEE) - .singleResult(); + .taskAssignee(NO_ASSIGNEE) + .singleResult(); } /** @@ -79,7 +82,7 @@ public class CustomBizSpecifyAssigneeToTaskCmd extends AbstractCommand @Override public Boolean execute(CommandContext commandContext) { ProcessEngineConfigurationImpl processEngineConfiguration = - CommandContextUtil.getProcessEngineConfiguration(commandContext); + CommandContextUtil.getProcessEngineConfiguration(commandContext); TaskService taskService = processEngineConfiguration.getTaskService(); TaskEntity task = (TaskEntity) getOperateTask(taskService, executionId); //校验 @@ -91,12 +94,29 @@ public class CustomBizSpecifyAssigneeToTaskCmd extends AbstractCommand addAssignee(commandContext, taskService, task); + clearAlterTimeJob(commandContext, task); + return true; } + /** + * 清空告警的任务 + * + * @param commandContext + * @param task + */ + private void clearAlterTimeJob(CommandContext commandContext, TaskEntity task) { + ManagementService managementService = CommandContextUtil.getProcessEngineConfiguration(commandContext).getManagementService(); + Job timerJob = managementService.createTimerJobQuery().elementId(task.getTaskDefinitionKey()).processInstanceId(task.getProcessInstanceId()).singleResult(); + if (Objects.nonNull(timerJob)) { + CommandContextUtil.getTimerJobService().deleteTimerJob((TimerJobEntity) timerJob); + } + + } + public static void validProcessInstance(CommandContext commandContext, Task task) { ProcessEngineConfigurationImpl processEngineConfiguration = - CommandContextUtil.getProcessEngineConfiguration(commandContext); + CommandContextUtil.getProcessEngineConfiguration(commandContext); HistoryService historyService = processEngineConfiguration.getHistoryService(); HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult(); if (Objects.isNull(processInstance)) { @@ -110,11 +130,11 @@ public class CustomBizSpecifyAssigneeToTaskCmd extends AbstractCommand private void changeAssigneeSnapshot(CommandContext commandContext, Task task) { ProcessEngineConfigurationImpl processEngineConfiguration = - CommandContextUtil.getProcessEngineConfiguration(commandContext); + CommandContextUtil.getProcessEngineConfiguration(commandContext); RuntimeService runtimeService = processEngineConfiguration.getRuntimeService(); List originAssingeeList = runtimeService.getVariable(task.getProcessInstanceId(), - INTERNAL_ACTIVITY_RELATION_ASSIGNEE_LIST_INFO_SNAPSHOT + task.getTaskDefinitionKey(), List.class); + INTERNAL_ACTIVITY_RELATION_ASSIGNEE_LIST_INFO_SNAPSHOT + task.getTaskDefinitionKey(), List.class); for (BpmnTaskDelegateAssigner assigner : originAssingeeList) { if (Objects.equals(assigner.buildAssigneeId(), NO_ASSIGNEE)) { @@ -124,8 +144,8 @@ public class CustomBizSpecifyAssigneeToTaskCmd extends AbstractCommand } originAssingeeList.addAll(addedAssigners); runtimeService.setVariable(task.getProcessInstanceId(), - INTERNAL_ACTIVITY_RELATION_ASSIGNEE_LIST_INFO_SNAPSHOT + task.getTaskDefinitionKey(), - originAssingeeList); + INTERNAL_ACTIVITY_RELATION_ASSIGNEE_LIST_INFO_SNAPSHOT + task.getTaskDefinitionKey(), + originAssingeeList); } private void addAssignee(CommandContext commandContext, TaskService taskService, Task task) { diff --git a/workflow-engine-core/src/main/java/cn/axzo/workflow/core/listener/impl/InternalBpmnActivityEventListener_lo_Listener.java b/workflow-engine-core/src/main/java/cn/axzo/workflow/core/listener/impl/InternalBpmnActivityEventListener_lo_Listener.java index 8dd6cdf46..50dc371f0 100644 --- a/workflow-engine-core/src/main/java/cn/axzo/workflow/core/listener/impl/InternalBpmnActivityEventListener_lo_Listener.java +++ b/workflow-engine-core/src/main/java/cn/axzo/workflow/core/listener/impl/InternalBpmnActivityEventListener_lo_Listener.java @@ -67,8 +67,9 @@ public class InternalBpmnActivityEventListener_lo_Listener extends AbstractBpmnE switch (method) { case nobody: case bizSpecify: + // FIXME 业务指定审批人,需要在业务设置了人后,清除定时 TimerEventDefinition timerEventDefinition = new TimerEventDefinition(); - String timeUnit = "M"; + String timeUnit; switch (refreshProperties.getIntervalUnit()) { case SECONDS: timeUnit = "S";