update 调整优化监听
This commit is contained in:
parent
a0831dda45
commit
8c603ff8d7
@ -7,12 +7,14 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.enums.BusinessStatusEnum;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.warm.flow.core.FlowEngine;
|
||||
import org.dromara.warm.flow.core.dto.FlowParams;
|
||||
import org.dromara.warm.flow.core.entity.Definition;
|
||||
import org.dromara.warm.flow.core.entity.Instance;
|
||||
import org.dromara.warm.flow.core.entity.Task;
|
||||
import org.dromara.warm.flow.core.listener.GlobalListener;
|
||||
import org.dromara.warm.flow.core.listener.ListenerVariable;
|
||||
import org.dromara.warm.flow.core.service.InsService;
|
||||
import org.dromara.warm.flow.orm.entity.FlowTask;
|
||||
import org.dromara.workflow.common.ConditionalOnEnable;
|
||||
import org.dromara.workflow.common.constant.FlowConstant;
|
||||
@ -43,6 +45,7 @@ public class WorkflowGlobalListener implements GlobalListener {
|
||||
private final IFlwInstanceService instanceService;
|
||||
private final FlowProcessEventHandler flowProcessEventHandler;
|
||||
private final IFlwCommonService flwCommonService;
|
||||
private final InsService insService;
|
||||
|
||||
/**
|
||||
* 创建监听器,任务创建时执行
|
||||
@ -53,19 +56,11 @@ public class WorkflowGlobalListener implements GlobalListener {
|
||||
public void create(ListenerVariable listenerVariable) {
|
||||
Instance instance = listenerVariable.getInstance();
|
||||
Definition definition = listenerVariable.getDefinition();
|
||||
FlowParams flowParams = listenerVariable.getFlowParams();
|
||||
Map<String, Object> variable = flowParams.getVariable();
|
||||
Task task = listenerVariable.getTask();
|
||||
if (task != null) {
|
||||
// 判断流程状态(发布审批中事件)
|
||||
flowProcessEventHandler.processCreateTaskHandler(definition.getFlowCode(), instance, task.getId());
|
||||
}
|
||||
Boolean submit = MapUtil.getBool(variable, FlowConstant.SUBMIT);
|
||||
if (submit != null && submit) {
|
||||
flowProcessEventHandler.processHandler(definition.getFlowCode(), instance, instance.getFlowStatus(), variable, true);
|
||||
}
|
||||
variable.remove(FlowConstant.SUBMIT);
|
||||
flowParams.variable(variable);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -110,6 +105,13 @@ public class WorkflowGlobalListener implements GlobalListener {
|
||||
flowTask.setPermissionList(List.of(instance.getCreateBy()));
|
||||
}
|
||||
}
|
||||
//申请人提交事件
|
||||
Boolean submit = MapUtil.getBool(variable, FlowConstant.SUBMIT);
|
||||
if (submit != null && submit) {
|
||||
flowProcessEventHandler.processHandler(definition.getFlowCode(), instance, instance.getFlowStatus(), variable, true);
|
||||
}
|
||||
variable.remove(FlowConstant.SUBMIT);
|
||||
flowParams.variable(variable);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -136,24 +138,32 @@ public class WorkflowGlobalListener implements GlobalListener {
|
||||
if (StringUtils.isNotBlank(status)) {
|
||||
flowProcessEventHandler.processHandler(definition.getFlowCode(), instance, status, params, false);
|
||||
}
|
||||
Map<String, Object> variable = listenerVariable.getVariable();
|
||||
|
||||
Map<String, Object> variable = flowParams.getVariable();
|
||||
// 只有办理或者退回的时候才执行消息通知和抄送
|
||||
if (TaskStatusEnum.PASS.getStatus().equals(flowParams.getHisStatus())
|
||||
|| TaskStatusEnum.BACK.getStatus().equals(flowParams.getHisStatus())) {
|
||||
Task task = listenerVariable.getTask();
|
||||
if (variable != null) {
|
||||
if (variable.containsKey(FlowConstant.FLOW_COPY_LIST)) {
|
||||
List<FlowCopyBo> flowCopyList = (List<FlowCopyBo>) variable.get(FlowConstant.FLOW_COPY_LIST);
|
||||
List<String> messageType = (List<String>) variable.get(FlowConstant.MESSAGE_TYPE);
|
||||
String notice = (String) variable.get(FlowConstant.MESSAGE_NOTICE);
|
||||
|
||||
// 添加抄送人
|
||||
flwTaskService.setCopy(task, flowCopyList);
|
||||
variable.remove(FlowConstant.FLOW_COPY_LIST);
|
||||
|
||||
}
|
||||
if (variable.containsKey(FlowConstant.MESSAGE_TYPE)) {
|
||||
List<String> messageType = (List<String>) variable.get(FlowConstant.MESSAGE_TYPE);
|
||||
String notice = (String) variable.get(FlowConstant.MESSAGE_NOTICE);
|
||||
// 消息通知
|
||||
if (CollUtil.isNotEmpty(messageType)) {
|
||||
flwCommonService.sendMessage(definition.getFlowName(), instance.getId(), messageType, notice);
|
||||
variable.remove(FlowConstant.MESSAGE_TYPE);
|
||||
variable.remove(FlowConstant.MESSAGE_NOTICE);
|
||||
}
|
||||
}
|
||||
Map<String, Object> variableMap = instance.getVariableMap();
|
||||
variableMap.remove(FlowConstant.FLOW_COPY_LIST);
|
||||
variableMap.remove(FlowConstant.MESSAGE_TYPE);
|
||||
variableMap.remove(FlowConstant.MESSAGE_NOTICE);
|
||||
instance.setVariable(FlowEngine.jsonConvert.objToStr(variableMap));
|
||||
insService.updateById(instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -393,8 +393,6 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
String applyNodeCode = flwCommonService.applyNodeCode(definitionId);
|
||||
|
||||
Map<String, Object> variable = new HashMap<>();
|
||||
// 设置抄送人
|
||||
variable.put("flowCopyList", bo.getMessageType());
|
||||
// 消息类型
|
||||
variable.put("messageType", messageType);
|
||||
// 消息通知
|
||||
|
Loading…
x
Reference in New Issue
Block a user