fix - 添加节点告警逻辑

This commit is contained in:
wangli 2025-09-05 17:51:37 +08:00
parent ffbf270948
commit 972557b32c
2 changed files with 17 additions and 1 deletions

View File

@ -41,6 +41,16 @@ public class SupportRefreshProperties {
@Value(value = "${workflow.alter.enable:false}") @Value(value = "${workflow.alter.enable:false}")
private Boolean alterEnable; private Boolean alterEnable;
/**
* 是否全量业务 ID 都开启告警功能
*/
@Value(value = "${workflow.alter.allDefinitionKey:false}")
private Boolean alterAllDefinitionKey;
/**
* 需要开启告警功能的业务 ID 列表
*/
@Value(value = "${workflow.alter.definitionKeys:}")
private List<String> alterDefinitionKeys;
/** /**
* 节点卡住多久才告警单位分钟 * 节点卡住多久才告警单位分钟
*/ */

View File

@ -11,6 +11,7 @@ import cn.axzo.workflow.core.listener.AbstractBpmnEventListener;
import cn.axzo.workflow.core.listener.BpmnActivityEventListener; import cn.axzo.workflow.core.listener.BpmnActivityEventListener;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.ListUtils;
import org.flowable.bpmn.model.BpmnModel; import org.flowable.bpmn.model.BpmnModel;
import org.flowable.bpmn.model.FlowElement; import org.flowable.bpmn.model.FlowElement;
import org.flowable.common.engine.impl.cfg.TransactionState; import org.flowable.common.engine.impl.cfg.TransactionState;
@ -60,11 +61,16 @@ public class InternalBpmnActivityEventListener_lo_Listener extends AbstractBpmnE
if (!Boolean.TRUE.equals(refreshProperties.getAlterEnable())) { if (!Boolean.TRUE.equals(refreshProperties.getAlterEnable())) {
return; return;
} }
BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(execution.getProcessDefinitionId());
if (!refreshProperties.getAlterAllDefinitionKey()) {
if (!ListUtils.emptyIfNull(refreshProperties.getAlterDefinitionKeys()).contains(bpmnModel.getMainProcess().getId())) {
return;
}
}
ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(); ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration();
RuntimeService runtimeService = processEngineConfiguration.getRuntimeService(); RuntimeService runtimeService = processEngineConfiguration.getRuntimeService();
TermNodePausingDTO dto = new TermNodePausingDTO(execution.getProcessInstanceId(), execution.getCurrentActivityId(), 0); TermNodePausingDTO dto = new TermNodePausingDTO(execution.getProcessInstanceId(), execution.getCurrentActivityId(), 0);
runtimeService.setVariable(execution.getProcessInstanceId(), BIZ_NODE_ALTER + execution.getCurrentActivityId(), dto); runtimeService.setVariable(execution.getProcessInstanceId(), BIZ_NODE_ALTER + execution.getCurrentActivityId(), dto);
BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(execution.getProcessDefinitionId());
FlowElement flowElement = bpmnModel.getFlowElement(execution.getCurrentActivityId()); FlowElement flowElement = bpmnModel.getFlowElement(execution.getCurrentActivityId());
BpmnMetaParserHelper.getNodeType(flowElement).ifPresent(e -> { BpmnMetaParserHelper.getNodeType(flowElement).ifPresent(e -> {
if (Objects.equals(BpmnFlowNodeType.NODE_BUSINESS, e)) { if (Objects.equals(BpmnFlowNodeType.NODE_BUSINESS, e)) {