feat(REQ-2924) - 增加开关控制是否需要针对业务节点进行告警

This commit is contained in:
wangli 2024-09-12 13:37:57 +08:00
parent bacec8a72e
commit f5ac06fc75
2 changed files with 11 additions and 9 deletions

View File

@ -1,13 +1,10 @@
package cn.axzo.workflow.core.conf;
import com.google.common.collect.Lists;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
@ -30,21 +27,23 @@ public class SupportRefreshProperties {
@Value("${workflow.apiLog.filterApiType:}")
private String filterApiType;
@Value("${workflow.alter.enable:false}")
private Boolean alterEnable = false;
/**
* 业务节点暂停告警的次数
*/
@Value("${workflow.alter.retries:3}")
private Integer retries;
private Integer alterRetries;
/**
* 业务节点暂停告警次数间的间隔
*/
@Value("${workflow.alter.interval:10}")
private Integer interval;
private Integer alterInterval;
/**
* 业务节点暂停告警次数间隔的时间单位
*/
@Value("${workflow.alter.intervalUnit:minutes}")
private TimeUnit intervalUnit;
private TimeUnit alterIntervalUnit;
}

View File

@ -59,6 +59,9 @@ public class InternalBpmnActivityEventListener_lo_Listener extends AbstractBpmnE
*/
@Override
public void onStart(DelegateExecution execution) {
if(!Boolean.TRUE.equals(refreshProperties.getAlterEnable())) {
return;
}
BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(execution.getProcessDefinitionId());
FlowElement flowElement = bpmnModel.getFlowElement(execution.getCurrentActivityId());
BpmnMetaParserHelper.getNodeType(flowElement).ifPresent(e -> {
@ -70,7 +73,7 @@ public class InternalBpmnActivityEventListener_lo_Listener extends AbstractBpmnE
// FIXME 业务指定审批人需要在业务设置了人后清除定时
TimerEventDefinition timerEventDefinition = new TimerEventDefinition();
String timeUnit;
switch (refreshProperties.getIntervalUnit()) {
switch (refreshProperties.getAlterIntervalUnit()) {
case SECONDS:
timeUnit = "S";
break;
@ -85,13 +88,13 @@ public class InternalBpmnActivityEventListener_lo_Listener extends AbstractBpmnE
timeUnit = "M";
break;
}
timerEventDefinition.setTimeCycle("R" + refreshProperties.getInterval() + "/PT" + refreshProperties.getInterval() + timeUnit);
timerEventDefinition.setTimeCycle("R" + refreshProperties.getAlterInterval() + "/PT" + refreshProperties.getAlterInterval() + timeUnit);
TimerJobEntity timerJob = TimerUtil.createTimerEntityForTimerEventDefinition(timerEventDefinition, execution.getCurrentFlowElement(),
false, (ExecutionEntity) execution, AsyncTermNodeAlterJobHandler.TYPE,
TimerEventHandler.createConfiguration(execution.getCurrentActivityId(), null, timerEventDefinition.getCalendarName()));
if (timerJob != null) {
timerJob.setCustomValues(JSON.toJSONString(new TermNodePausingDTO(execution.getProcessInstanceId(), execution.getCurrentActivityId(), refreshProperties.getRetries())));
timerJob.setCustomValues(JSON.toJSONString(new TermNodePausingDTO(execution.getProcessInstanceId(), execution.getCurrentActivityId(), refreshProperties.getAlterRetries())));
CommandContextUtil.getTimerJobService().scheduleTimerJob(timerJob);
}
break;