feat(REQ-2924) - 在业务设置了审批人后,重新取消告警任务
This commit is contained in:
parent
7a898d0f5b
commit
bacec8a72e
@ -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<Boolean>
|
||||
|
||||
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<Boolean>
|
||||
@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<Boolean>
|
||||
|
||||
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<Boolean>
|
||||
|
||||
private void changeAssigneeSnapshot(CommandContext commandContext, Task task) {
|
||||
ProcessEngineConfigurationImpl processEngineConfiguration =
|
||||
CommandContextUtil.getProcessEngineConfiguration(commandContext);
|
||||
CommandContextUtil.getProcessEngineConfiguration(commandContext);
|
||||
RuntimeService runtimeService = processEngineConfiguration.getRuntimeService();
|
||||
|
||||
List<BpmnTaskDelegateAssigner> 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<Boolean>
|
||||
}
|
||||
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) {
|
||||
|
||||
@ -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";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user