feat(REQ-2924) - 在业务设置了审批人后,重新取消告警任务

This commit is contained in:
wangli 2024-09-11 20:47:18 +08:00
parent 7a898d0f5b
commit bacec8a72e
2 changed files with 30 additions and 9 deletions

View File

@ -6,11 +6,14 @@ import cn.axzo.workflow.core.engine.cmd.helper.CustomTaskHelper;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import org.flowable.common.engine.impl.interceptor.CommandContext; import org.flowable.common.engine.impl.interceptor.CommandContext;
import org.flowable.engine.HistoryService; import org.flowable.engine.HistoryService;
import org.flowable.engine.ManagementService;
import org.flowable.engine.RuntimeService; import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService; import org.flowable.engine.TaskService;
import org.flowable.engine.history.HistoricProcessInstance; import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.flowable.engine.impl.util.CommandContextUtil; 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.api.Task;
import org.flowable.task.service.impl.persistence.entity.TaskEntity; import org.flowable.task.service.impl.persistence.entity.TaskEntity;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
@ -91,9 +94,26 @@ public class CustomBizSpecifyAssigneeToTaskCmd extends AbstractCommand<Boolean>
addAssignee(commandContext, taskService, task); addAssignee(commandContext, taskService, task);
clearAlterTimeJob(commandContext, task);
return true; 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) { public static void validProcessInstance(CommandContext commandContext, Task task) {
ProcessEngineConfigurationImpl processEngineConfiguration = ProcessEngineConfigurationImpl processEngineConfiguration =
CommandContextUtil.getProcessEngineConfiguration(commandContext); CommandContextUtil.getProcessEngineConfiguration(commandContext);

View File

@ -67,8 +67,9 @@ public class InternalBpmnActivityEventListener_lo_Listener extends AbstractBpmnE
switch (method) { switch (method) {
case nobody: case nobody:
case bizSpecify: case bizSpecify:
// FIXME 业务指定审批人需要在业务设置了人后清除定时
TimerEventDefinition timerEventDefinition = new TimerEventDefinition(); TimerEventDefinition timerEventDefinition = new TimerEventDefinition();
String timeUnit = "M"; String timeUnit;
switch (refreshProperties.getIntervalUnit()) { switch (refreshProperties.getIntervalUnit()) {
case SECONDS: case SECONDS:
timeUnit = "S"; timeUnit = "S";