告警调整

This commit is contained in:
tiger_zhou 2023-08-28 11:13:21 +08:00
parent 7446eed3d0
commit 1f9de574e6
2 changed files with 11 additions and 8 deletions

View File

@ -56,7 +56,7 @@ public class BlueAlertListener implements AlertSourceEventListener<BlueDisplayAl
}
int allControlStationSize = CONTROL_STATION_MAPER.get(rtu.getLineId()).size();
if (alertManager.needMostShow(rtu.getLineId(), BLUE_DISPLAY_NAME, 1)
if (alertManager.needMostShow(rtu.getLineId(), BLUE_DISPLAY_NAME, allControlStationSize)
&& alertManager.putAlterDevice(rtu.getLineId(), BLUE_DISPLAY_NAME, ALL_BLUE_DISPLAY_VAL)
) {
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(Optional.empty(), AlertType.ALL_LINE_BLUE_DISPLAY, rtu, ALL_BLUE_DISPLAY_VAL);

View File

@ -4,6 +4,7 @@ import club.joylink.xiannccda.alert.NccAlertInfo;
import club.joylink.xiannccda.dto.protos.NccAlertInfoMessageProto.NccAlertInfoMessage;
import club.joylink.xiannccda.dto.protos.NccAlertInfoMessageProto.NccAlertInfoMessage.Builder;
import club.joylink.xiannccda.dto.protos.NccAlertInfoMessageProto.NccAlertInfoMessage.Message;
import com.google.common.collect.Lists;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -41,21 +42,23 @@ public class NccAlertMessageServer implements IMessageServer {
@Override
public List<TopicMessage> onTick() {
Builder builder = NccAlertInfoMessage.newBuilder();
NccAlertInfo alertInfo;
List<TopicMessage> list = Lists.newArrayListWithCapacity(10);
for (int i = 0; i < 10; i++) { //加循环次数主要是为了防止while死循环
Builder builder = NccAlertInfoMessage.newBuilder();
NccAlertInfo alertInfo;
if ((alertInfo = pendingMsgQueue.poll()) != null) {
Message message = convertToMessage(alertInfo);
builder.addMessages(message);
byte[] bytes = builder.build().toByteArray();
if (bytes != null && bytes.length != 0) {
list.add(new TopicMessage(getDestinationPattern(), bytes));
}
} else {
break;
}
}
byte[] bytes = builder.build().toByteArray();
if (bytes != null && bytes.length != 0) {
return List.of(new TopicMessage(getDestinationPattern(), bytes));
}
return new ArrayList<>();
return list;
}
private NccAlertMessageServer(String id) {