update 优化事件发布
This commit is contained in:
parent
aab87d322c
commit
4ab4e1685c
@ -56,7 +56,7 @@ public class FlowProcessEventHandler {
|
||||
* @param instance 实例数据
|
||||
* @param taskId 任务id
|
||||
*/
|
||||
public void processCreateTaskHandler(String flowCode, Instance instance, Long taskId) {
|
||||
public void processTaskHandler(String flowCode, Instance instance, Long taskId) {
|
||||
String tenantId = TenantHelper.getTenantId();
|
||||
log.info("【流程任务事件发布】租户ID: {}, 流程编码: {}, 业务ID: {}, 节点类型: {}, 节点编码: {}, 节点名称: {}, 任务ID: {}",
|
||||
tenantId, flowCode, instance.getBusinessId(), instance.getNodeType(), instance.getNodeCode(), instance.getNodeName(), taskId);
|
||||
|
@ -54,13 +54,7 @@ public class WorkflowGlobalListener implements GlobalListener {
|
||||
*/
|
||||
@Override
|
||||
public void create(ListenerVariable listenerVariable) {
|
||||
Instance instance = listenerVariable.getInstance();
|
||||
Definition definition = listenerVariable.getDefinition();
|
||||
Task task = listenerVariable.getTask();
|
||||
if (task != null) {
|
||||
// 判断流程状态(发布审批中事件)
|
||||
flowProcessEventHandler.processCreateTaskHandler(definition.getFlowCode(), instance, task.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -98,13 +92,6 @@ 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);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -116,6 +103,7 @@ public class WorkflowGlobalListener implements GlobalListener {
|
||||
public void finish(ListenerVariable listenerVariable) {
|
||||
Instance instance = listenerVariable.getInstance();
|
||||
Definition definition = listenerVariable.getDefinition();
|
||||
Task task = listenerVariable.getTask();
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
FlowParams flowParams = listenerVariable.getFlowParams();
|
||||
if (ObjectUtil.isNotNull(flowParams)) {
|
||||
@ -126,20 +114,28 @@ public class WorkflowGlobalListener implements GlobalListener {
|
||||
// 办理意见
|
||||
params.put("message", flowParams.getMessage());
|
||||
}
|
||||
Map<String, Object> variable = flowParams.getVariable();
|
||||
//申请人提交事件
|
||||
Boolean submit = MapUtil.getBool(variable, FlowConstant.SUBMIT);
|
||||
if (submit != null && submit) {
|
||||
flowProcessEventHandler.processHandler(definition.getFlowCode(), instance, instance.getFlowStatus(), variable, true);
|
||||
} else {
|
||||
// 判断流程状态(发布:撤销,退回,作废,终止,已完成事件)
|
||||
String status = determineFlowStatus(instance);
|
||||
if (StringUtils.isNotBlank(status)) {
|
||||
flowProcessEventHandler.processHandler(definition.getFlowCode(), instance, status, params, false);
|
||||
}
|
||||
|
||||
}
|
||||
//发布任务事件
|
||||
if (task != null) {
|
||||
flowProcessEventHandler.processTaskHandler(definition.getFlowCode(), instance, task.getId());
|
||||
}
|
||||
if (ObjectUtil.isNull(flowParams)) {
|
||||
return;
|
||||
}
|
||||
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);
|
||||
@ -158,6 +154,7 @@ public class WorkflowGlobalListener implements GlobalListener {
|
||||
variableMap.remove(FlowConstant.FLOW_COPY_LIST);
|
||||
variableMap.remove(FlowConstant.MESSAGE_TYPE);
|
||||
variableMap.remove(FlowConstant.MESSAGE_NOTICE);
|
||||
variableMap.remove(FlowConstant.SUBMIT);
|
||||
instance.setVariable(FlowEngine.jsonConvert.objToStr(variableMap));
|
||||
insService.updateById(instance);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user