This commit is contained in:
parent
b29a5fb5aa
commit
69eed1fc96
@ -2,12 +2,16 @@ package club.joylink.xiannccda.alert;
|
|||||||
|
|
||||||
import club.joylink.xiannccda.alert.NccAlertInfo.AlertStatus;
|
import club.joylink.xiannccda.alert.NccAlertInfo.AlertStatus;
|
||||||
import club.joylink.xiannccda.alert.core.AlertManager;
|
import club.joylink.xiannccda.alert.core.AlertManager;
|
||||||
|
import club.joylink.xiannccda.configuration.protos.OccServerProto;
|
||||||
|
import club.joylink.xiannccda.configuration.protos.OccServerProto.OccClientMessage;
|
||||||
|
import club.joylink.xiannccda.constants.common.LineTypeEnum;
|
||||||
import club.joylink.xiannccda.entity.AlertRecord;
|
import club.joylink.xiannccda.entity.AlertRecord;
|
||||||
import club.joylink.xiannccda.event.Listener;
|
import club.joylink.xiannccda.event.Listener;
|
||||||
import club.joylink.xiannccda.repository.IAlertRecordRepository;
|
import club.joylink.xiannccda.repository.IAlertRecordRepository;
|
||||||
import club.joylink.xiannccda.ws.NccAlertMessageServer;
|
import club.joylink.xiannccda.ws.NccAlertMessageServer;
|
||||||
import club.joylink.xiannccda.ws.WsMessageServerManager;
|
import club.joylink.xiannccda.ws.WsMessageServerManager;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.ApplicationArguments;
|
import org.springframework.boot.ApplicationArguments;
|
||||||
import org.springframework.boot.ApplicationRunner;
|
import org.springframework.boot.ApplicationRunner;
|
||||||
import org.springframework.core.annotation.Order;
|
import org.springframework.core.annotation.Order;
|
||||||
@ -19,6 +23,8 @@ public class AlertListenerJob implements ApplicationRunner {
|
|||||||
|
|
||||||
private final WsMessageServerManager wsMessageServerManager;
|
private final WsMessageServerManager wsMessageServerManager;
|
||||||
private final IAlertRecordRepository alertRecordRepository;
|
private final IAlertRecordRepository alertRecordRepository;
|
||||||
|
@Autowired
|
||||||
|
private OccServerProto serverProto;
|
||||||
|
|
||||||
public AlertListenerJob(WsMessageServerManager wsMessageServerManager,
|
public AlertListenerJob(WsMessageServerManager wsMessageServerManager,
|
||||||
IAlertRecordRepository alertRecordRepository) {
|
IAlertRecordRepository alertRecordRepository) {
|
||||||
@ -31,13 +37,14 @@ public class AlertListenerJob implements ApplicationRunner {
|
|||||||
//添加报警事件监听器
|
//添加报警事件监听器
|
||||||
addAlertListeners();
|
addAlertListeners();
|
||||||
//注册西安NCC的报警ws消息发送服务
|
//注册西安NCC的报警ws消息发送服务
|
||||||
wsMessageServerManager.registerMessageServer(NccAlertMessageServer.getDefault());
|
wsMessageServerManager.registerMessageServer(NccAlertMessageServer.getInstance(LineTypeEnum.NCC));
|
||||||
|
wsMessageServerManager.registerMessageServer(NccAlertMessageServer.getInstance(LineTypeEnum.OCC));
|
||||||
//启动报警源事件监测任务
|
//启动报警源事件监测任务
|
||||||
AlertManager.getDefault().taskStart();
|
AlertManager.getDefault().taskStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addAlertListeners() {
|
private void addAlertListeners() {
|
||||||
NccAlertMessageServer nccAlertMessageServer = NccAlertMessageServer.getDefault();
|
|
||||||
AlertManager alertManager = AlertManager.getDefault();
|
AlertManager alertManager = AlertManager.getDefault();
|
||||||
//添加消息
|
//添加消息
|
||||||
alertManager.on(new Listener<NccAlertInfo>() {
|
alertManager.on(new Listener<NccAlertInfo>() {
|
||||||
@ -51,11 +58,19 @@ public class AlertListenerJob implements ApplicationRunner {
|
|||||||
alertInfo.setId(idGenerator.decrementAndGet());
|
alertInfo.setId(idGenerator.decrementAndGet());
|
||||||
}*/
|
}*/
|
||||||
//不论是否mock 都保存数据库
|
//不论是否mock 都保存数据库
|
||||||
|
|
||||||
|
OccClientMessage clientMessage = serverProto.getClientMessage(alertInfo.getLineId());
|
||||||
|
for (LineTypeEnum lineType : clientMessage.getLineTypes()) {
|
||||||
|
|
||||||
|
NccAlertMessageServer nccAlertMessageServer = NccAlertMessageServer.getInstance(lineType);
|
||||||
|
alertInfo.setLineType(lineType);
|
||||||
AlertRecord record = convertToRecord(alertInfo);
|
AlertRecord record = convertToRecord(alertInfo);
|
||||||
|
|
||||||
alertRecordRepository.save(record);
|
alertRecordRepository.save(record);
|
||||||
alertInfo.setId(record.getId());
|
alertInfo.setId(record.getId());
|
||||||
nccAlertMessageServer.addMsg(alertInfo);
|
nccAlertMessageServer.addMsg(alertInfo);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@ package club.joylink.xiannccda.ats.message;
|
|||||||
|
|
||||||
import club.joylink.xiannccda.ats.message.changer.DeviceNameChangerManage;
|
import club.joylink.xiannccda.ats.message.changer.DeviceNameChangerManage;
|
||||||
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||||
|
import club.joylink.xiannccda.configuration.protos.OccServerProto;
|
||||||
|
import club.joylink.xiannccda.configuration.protos.OccServerProto.OccClientMessage;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -10,6 +12,7 @@ import java.util.Objects;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.ApplicationArguments;
|
import org.springframework.boot.ApplicationArguments;
|
||||||
import org.springframework.boot.ApplicationRunner;
|
import org.springframework.boot.ApplicationRunner;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
@ -21,11 +24,10 @@ import org.springframework.stereotype.Component;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
@Setter
|
@Setter
|
||||||
@ConfigurationProperties(prefix = "occ-client")
|
|
||||||
public class OccMessageManage implements ApplicationRunner {
|
public class OccMessageManage implements ApplicationRunner {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
private Map<Integer, OccClientMessage> clientInfoMap;
|
private OccServerProto occServerProto;
|
||||||
Map<Integer, XianOccMessagingClient> clientMap = new HashMap<>();
|
Map<Integer, XianOccMessagingClient> clientMap = new HashMap<>();
|
||||||
|
|
||||||
public void sendMsg(Integer lineId, MessageData md, boolean isRealTime) {
|
public void sendMsg(Integer lineId, MessageData md, boolean isRealTime) {
|
||||||
@ -37,14 +39,14 @@ public class OccMessageManage implements ApplicationRunner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean notMatchHandle(Integer lineId, Integer rtuId) {
|
public boolean notMatchHandle(Integer lineId, Integer rtuId) {
|
||||||
OccClientMessage clientMessage = this.clientInfoMap.get(lineId);
|
OccClientMessage clientMessage = this.occServerProto.getClientMessage(lineId);
|
||||||
if (Objects.isNull(clientMessage)) {
|
if (Objects.isNull(clientMessage)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (CollectionUtils.isEmpty(clientMessage.filterRtuIds)) {
|
if (CollectionUtils.isEmpty(clientMessage.getFilterRtuIds())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (clientMessage.filterRtuIds.contains(rtuId)) {
|
if (clientMessage.rtuIdExists(rtuId)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -66,33 +68,16 @@ public class OccMessageManage implements ApplicationRunner {
|
|||||||
|
|
||||||
DeviceNameChangerManage.init();
|
DeviceNameChangerManage.init();
|
||||||
|
|
||||||
this.clientInfoMap.forEach((k, v) -> {
|
this.occServerProto.getClientInfoMap().forEach((k, v) -> {
|
||||||
log.info("初始化 occ tcp连接.... 是否监控cpu,lineId:{} 内存信息:{}", k, v.monitorHandwareChange);
|
log.info("初始化 occ tcp连接.... 是否监控cpu,lineId:{} 内存信息:{}", k, v.isMonitorHandwareChange());
|
||||||
DeviceNameChangerManage.initLineIdNameCHanger(k, v.getNameChanger());
|
DeviceNameChangerManage.initLineIdNameCHanger(k, v.getNameChanger());
|
||||||
XianOccMessagingClient client = new XianOccMessagingClient(k, v);
|
XianOccMessagingClient client = new XianOccMessagingClient(k, v);
|
||||||
this.registerClient(client);
|
this.registerClient(client);
|
||||||
client.connect(v.monitorHandwareChange);
|
client.connect(v.isMonitorHandwareChange());
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class OccClientMessage {
|
|
||||||
|
|
||||||
private String serverHost;
|
|
||||||
|
|
||||||
private Integer realPort;
|
|
||||||
|
|
||||||
private Integer unRealPort;
|
|
||||||
|
|
||||||
private Boolean collectorData;
|
|
||||||
|
|
||||||
private Integer receiveMsgTimeout;
|
|
||||||
|
|
||||||
private boolean monitorHandwareChange;
|
|
||||||
|
|
||||||
private List<Integer> filterRtuIds;
|
|
||||||
private NameChangerEnum nameChanger;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
package club.joylink.xiannccda.ats.message;
|
package club.joylink.xiannccda.ats.message;
|
||||||
|
|
||||||
import club.joylink.xiannccda.ats.message.OccMessageManage.OccClientMessage;
|
|
||||||
import club.joylink.xiannccda.ats.message.line3.req.LoadHistoryTGDataRequest;
|
import club.joylink.xiannccda.ats.message.line3.req.LoadHistoryTGDataRequest;
|
||||||
import club.joylink.xiannccda.ats.message.line3.req.LoadHistoryTGDataRequest.ApplyTypeEnum;
|
import club.joylink.xiannccda.ats.message.line3.req.LoadHistoryTGDataRequest.ApplyTypeEnum;
|
||||||
|
import club.joylink.xiannccda.configuration.protos.OccServerProto.OccClientMessage;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
@ -0,0 +1,48 @@
|
|||||||
|
package club.joylink.xiannccda.configuration.protos;
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||||
|
import club.joylink.xiannccda.constants.common.LineTypeEnum;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Data
|
||||||
|
@ConfigurationProperties(prefix = "occ-client")
|
||||||
|
public class OccServerProto {
|
||||||
|
|
||||||
|
private Map<Integer, OccClientMessage> clientInfoMap;
|
||||||
|
|
||||||
|
public OccClientMessage getClientMessage(Integer lineId) {
|
||||||
|
return this.clientInfoMap.get(lineId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class OccClientMessage {
|
||||||
|
|
||||||
|
private String serverHost;
|
||||||
|
|
||||||
|
private Integer realPort;
|
||||||
|
|
||||||
|
private Integer unRealPort;
|
||||||
|
|
||||||
|
private Boolean collectorData;
|
||||||
|
|
||||||
|
private Integer receiveMsgTimeout;
|
||||||
|
|
||||||
|
private boolean monitorHandwareChange;
|
||||||
|
|
||||||
|
private List<Integer> filterRtuIds;
|
||||||
|
private NameChangerEnum nameChanger;
|
||||||
|
|
||||||
|
private List<LineTypeEnum> lineTypes;
|
||||||
|
|
||||||
|
public boolean rtuIdExists(Integer rtiud) {
|
||||||
|
return this.filterRtuIds.contains(rtiud);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -52,15 +52,7 @@ public class AlertTipTimeConfigController {
|
|||||||
@Operation(summary = "保存修改")
|
@Operation(summary = "保存修改")
|
||||||
@PostMapping("page")
|
@PostMapping("page")
|
||||||
@CommonLogAnno(name = "决策信息时间-分页查询", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.QUERY)
|
@CommonLogAnno(name = "决策信息时间-分页查询", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.QUERY)
|
||||||
public IPage<AlertTipTimeConfig> page(Principal user, AlertTipTimeQueryDTO dto) {
|
public IPage<AlertTipTimeConfig> page(AlertTipTimeQueryDTO dto) {
|
||||||
JwtAuthenticationToken authToken = (JwtAuthenticationToken) user;
|
|
||||||
System.out.println(authToken.getPrincipal());
|
|
||||||
System.out.println(authToken.getTokenAttributes());
|
|
||||||
Object exp = authToken.getTokenAttributes().get(JwtClaimNames.EXP);
|
|
||||||
Instant time = (Instant) exp;
|
|
||||||
System.out.println(time.getEpochSecond());
|
|
||||||
System.out.println(authToken.getCredentials());
|
|
||||||
System.out.println(authToken.getAuthorities());
|
|
||||||
return this.configRepository.page(dto, Wrappers.lambdaQuery(AlertTipTimeConfig.class).eq(AlertTipTimeConfig::getListShower, 1));
|
return this.configRepository.page(dto, Wrappers.lambdaQuery(AlertTipTimeConfig.class).eq(AlertTipTimeConfig::getListShower, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,6 +72,7 @@ public class RoleAuthController {
|
|||||||
this.authPathRepository.removeById(id);
|
this.authPathRepository.removeById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/role/page")
|
@GetMapping("/role/page")
|
||||||
@SecurityRequirement(name = "jwt")
|
@SecurityRequirement(name = "jwt")
|
||||||
@Operation(summary = "角色分页")
|
@Operation(summary = "角色分页")
|
||||||
@ -88,4 +89,11 @@ public class RoleAuthController {
|
|||||||
this.authService.saveOrUpdate(dto);
|
this.authService.saveOrUpdate(dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/config/{id}")
|
||||||
|
@Operation(summary = "角色配置")
|
||||||
|
@ApiResponse(description = "角色配置")
|
||||||
|
public void roleConfig(@PathVariable("id") Long id, AuthRoleDTO configStr) {
|
||||||
|
this.authRoleRepository.roleConfig(id, configStr);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,4 +14,5 @@ public class AuthRoleDTO {
|
|||||||
private List<Long> resList;
|
private List<Long> resList;
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private String apiIds;
|
private String apiIds;
|
||||||
|
private String roleConfigStr;
|
||||||
}
|
}
|
||||||
|
@ -180,6 +180,26 @@ public final class NccAlertInfoMessageProto {
|
|||||||
* @return The mock.
|
* @return The mock.
|
||||||
*/
|
*/
|
||||||
boolean getMock();
|
boolean getMock();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
*线路类型 occ/ncc
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* <code>string line_type = 11;</code>
|
||||||
|
* @return The lineType.
|
||||||
|
*/
|
||||||
|
java.lang.String getLineType();
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
*线路类型 occ/ncc
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* <code>string line_type = 11;</code>
|
||||||
|
* @return The bytes for lineType.
|
||||||
|
*/
|
||||||
|
com.google.protobuf.ByteString
|
||||||
|
getLineTypeBytes();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Protobuf type {@code alert.NccAlertInfoMessage.Message}
|
* Protobuf type {@code alert.NccAlertInfoMessage.Message}
|
||||||
@ -200,6 +220,7 @@ public final class NccAlertInfoMessageProto {
|
|||||||
alertObject_ = "";
|
alertObject_ = "";
|
||||||
alertType_ = 0;
|
alertType_ = 0;
|
||||||
locatorDeviceId_ = "";
|
locatorDeviceId_ = "";
|
||||||
|
lineType_ = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@java.lang.Override
|
@java.lang.Override
|
||||||
@ -483,6 +504,53 @@ public final class NccAlertInfoMessageProto {
|
|||||||
return mock_;
|
return mock_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final int LINE_TYPE_FIELD_NUMBER = 11;
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
private volatile java.lang.Object lineType_ = "";
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
*线路类型 occ/ncc
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* <code>string line_type = 11;</code>
|
||||||
|
* @return The lineType.
|
||||||
|
*/
|
||||||
|
@java.lang.Override
|
||||||
|
public java.lang.String getLineType() {
|
||||||
|
java.lang.Object ref = lineType_;
|
||||||
|
if (ref instanceof java.lang.String) {
|
||||||
|
return (java.lang.String) ref;
|
||||||
|
} else {
|
||||||
|
com.google.protobuf.ByteString bs =
|
||||||
|
(com.google.protobuf.ByteString) ref;
|
||||||
|
java.lang.String s = bs.toStringUtf8();
|
||||||
|
lineType_ = s;
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
*线路类型 occ/ncc
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* <code>string line_type = 11;</code>
|
||||||
|
* @return The bytes for lineType.
|
||||||
|
*/
|
||||||
|
@java.lang.Override
|
||||||
|
public com.google.protobuf.ByteString
|
||||||
|
getLineTypeBytes() {
|
||||||
|
java.lang.Object ref = lineType_;
|
||||||
|
if (ref instanceof java.lang.String) {
|
||||||
|
com.google.protobuf.ByteString b =
|
||||||
|
com.google.protobuf.ByteString.copyFromUtf8(
|
||||||
|
(java.lang.String) ref);
|
||||||
|
lineType_ = b;
|
||||||
|
return b;
|
||||||
|
} else {
|
||||||
|
return (com.google.protobuf.ByteString) ref;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private byte memoizedIsInitialized = -1;
|
private byte memoizedIsInitialized = -1;
|
||||||
@java.lang.Override
|
@java.lang.Override
|
||||||
public final boolean isInitialized() {
|
public final boolean isInitialized() {
|
||||||
@ -527,6 +595,9 @@ public final class NccAlertInfoMessageProto {
|
|||||||
if (mock_ != false) {
|
if (mock_ != false) {
|
||||||
output.writeBool(10, mock_);
|
output.writeBool(10, mock_);
|
||||||
}
|
}
|
||||||
|
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(lineType_)) {
|
||||||
|
com.google.protobuf.GeneratedMessageV3.writeString(output, 11, lineType_);
|
||||||
|
}
|
||||||
getUnknownFields().writeTo(output);
|
getUnknownFields().writeTo(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -571,6 +642,9 @@ public final class NccAlertInfoMessageProto {
|
|||||||
size += com.google.protobuf.CodedOutputStream
|
size += com.google.protobuf.CodedOutputStream
|
||||||
.computeBoolSize(10, mock_);
|
.computeBoolSize(10, mock_);
|
||||||
}
|
}
|
||||||
|
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(lineType_)) {
|
||||||
|
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(11, lineType_);
|
||||||
|
}
|
||||||
size += getUnknownFields().getSerializedSize();
|
size += getUnknownFields().getSerializedSize();
|
||||||
memoizedSize = size;
|
memoizedSize = size;
|
||||||
return size;
|
return size;
|
||||||
@ -605,6 +679,8 @@ public final class NccAlertInfoMessageProto {
|
|||||||
!= other.getAlertLocationId()) return false;
|
!= other.getAlertLocationId()) return false;
|
||||||
if (getMock()
|
if (getMock()
|
||||||
!= other.getMock()) return false;
|
!= other.getMock()) return false;
|
||||||
|
if (!getLineType()
|
||||||
|
.equals(other.getLineType())) return false;
|
||||||
if (!getUnknownFields().equals(other.getUnknownFields())) return false;
|
if (!getUnknownFields().equals(other.getUnknownFields())) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -638,6 +714,8 @@ public final class NccAlertInfoMessageProto {
|
|||||||
hash = (37 * hash) + MOCK_FIELD_NUMBER;
|
hash = (37 * hash) + MOCK_FIELD_NUMBER;
|
||||||
hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(
|
hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(
|
||||||
getMock());
|
getMock());
|
||||||
|
hash = (37 * hash) + LINE_TYPE_FIELD_NUMBER;
|
||||||
|
hash = (53 * hash) + getLineType().hashCode();
|
||||||
hash = (29 * hash) + getUnknownFields().hashCode();
|
hash = (29 * hash) + getUnknownFields().hashCode();
|
||||||
memoizedHashCode = hash;
|
memoizedHashCode = hash;
|
||||||
return hash;
|
return hash;
|
||||||
@ -779,6 +857,7 @@ public final class NccAlertInfoMessageProto {
|
|||||||
locatorDeviceId_ = "";
|
locatorDeviceId_ = "";
|
||||||
alertLocationId_ = 0L;
|
alertLocationId_ = 0L;
|
||||||
mock_ = false;
|
mock_ = false;
|
||||||
|
lineType_ = "";
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -842,6 +921,9 @@ public final class NccAlertInfoMessageProto {
|
|||||||
if (((from_bitField0_ & 0x00000200) != 0)) {
|
if (((from_bitField0_ & 0x00000200) != 0)) {
|
||||||
result.mock_ = mock_;
|
result.mock_ = mock_;
|
||||||
}
|
}
|
||||||
|
if (((from_bitField0_ & 0x00000400) != 0)) {
|
||||||
|
result.lineType_ = lineType_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@java.lang.Override
|
@java.lang.Override
|
||||||
@ -896,6 +978,11 @@ public final class NccAlertInfoMessageProto {
|
|||||||
if (other.getMock() != false) {
|
if (other.getMock() != false) {
|
||||||
setMock(other.getMock());
|
setMock(other.getMock());
|
||||||
}
|
}
|
||||||
|
if (!other.getLineType().isEmpty()) {
|
||||||
|
lineType_ = other.lineType_;
|
||||||
|
bitField0_ |= 0x00000400;
|
||||||
|
onChanged();
|
||||||
|
}
|
||||||
this.mergeUnknownFields(other.getUnknownFields());
|
this.mergeUnknownFields(other.getUnknownFields());
|
||||||
onChanged();
|
onChanged();
|
||||||
return this;
|
return this;
|
||||||
@ -972,6 +1059,11 @@ public final class NccAlertInfoMessageProto {
|
|||||||
bitField0_ |= 0x00000200;
|
bitField0_ |= 0x00000200;
|
||||||
break;
|
break;
|
||||||
} // case 80
|
} // case 80
|
||||||
|
case 90: {
|
||||||
|
lineType_ = input.readStringRequireUtf8();
|
||||||
|
bitField0_ |= 0x00000400;
|
||||||
|
break;
|
||||||
|
} // case 90
|
||||||
default: {
|
default: {
|
||||||
if (!super.parseUnknownField(input, extensionRegistry, tag)) {
|
if (!super.parseUnknownField(input, extensionRegistry, tag)) {
|
||||||
done = true; // was an endgroup tag
|
done = true; // was an endgroup tag
|
||||||
@ -1541,6 +1633,98 @@ public final class NccAlertInfoMessageProto {
|
|||||||
onChanged();
|
onChanged();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private java.lang.Object lineType_ = "";
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
*线路类型 occ/ncc
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* <code>string line_type = 11;</code>
|
||||||
|
* @return The lineType.
|
||||||
|
*/
|
||||||
|
public java.lang.String getLineType() {
|
||||||
|
java.lang.Object ref = lineType_;
|
||||||
|
if (!(ref instanceof java.lang.String)) {
|
||||||
|
com.google.protobuf.ByteString bs =
|
||||||
|
(com.google.protobuf.ByteString) ref;
|
||||||
|
java.lang.String s = bs.toStringUtf8();
|
||||||
|
lineType_ = s;
|
||||||
|
return s;
|
||||||
|
} else {
|
||||||
|
return (java.lang.String) ref;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
*线路类型 occ/ncc
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* <code>string line_type = 11;</code>
|
||||||
|
* @return The bytes for lineType.
|
||||||
|
*/
|
||||||
|
public com.google.protobuf.ByteString
|
||||||
|
getLineTypeBytes() {
|
||||||
|
java.lang.Object ref = lineType_;
|
||||||
|
if (ref instanceof String) {
|
||||||
|
com.google.protobuf.ByteString b =
|
||||||
|
com.google.protobuf.ByteString.copyFromUtf8(
|
||||||
|
(java.lang.String) ref);
|
||||||
|
lineType_ = b;
|
||||||
|
return b;
|
||||||
|
} else {
|
||||||
|
return (com.google.protobuf.ByteString) ref;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
*线路类型 occ/ncc
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* <code>string line_type = 11;</code>
|
||||||
|
* @param value The lineType to set.
|
||||||
|
* @return This builder for chaining.
|
||||||
|
*/
|
||||||
|
public Builder setLineType(
|
||||||
|
java.lang.String value) {
|
||||||
|
if (value == null) { throw new NullPointerException(); }
|
||||||
|
lineType_ = value;
|
||||||
|
bitField0_ |= 0x00000400;
|
||||||
|
onChanged();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
*线路类型 occ/ncc
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* <code>string line_type = 11;</code>
|
||||||
|
* @return This builder for chaining.
|
||||||
|
*/
|
||||||
|
public Builder clearLineType() {
|
||||||
|
lineType_ = getDefaultInstance().getLineType();
|
||||||
|
bitField0_ = (bitField0_ & ~0x00000400);
|
||||||
|
onChanged();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
*线路类型 occ/ncc
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* <code>string line_type = 11;</code>
|
||||||
|
* @param value The bytes for lineType to set.
|
||||||
|
* @return This builder for chaining.
|
||||||
|
*/
|
||||||
|
public Builder setLineTypeBytes(
|
||||||
|
com.google.protobuf.ByteString value) {
|
||||||
|
if (value == null) { throw new NullPointerException(); }
|
||||||
|
checkByteStringIsUtf8(value);
|
||||||
|
lineType_ = value;
|
||||||
|
bitField0_ |= 0x00000400;
|
||||||
|
onChanged();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
@java.lang.Override
|
@java.lang.Override
|
||||||
public final Builder setUnknownFields(
|
public final Builder setUnknownFields(
|
||||||
final com.google.protobuf.UnknownFieldSet unknownFields) {
|
final com.google.protobuf.UnknownFieldSet unknownFields) {
|
||||||
@ -2311,16 +2495,16 @@ public final class NccAlertInfoMessageProto {
|
|||||||
static {
|
static {
|
||||||
java.lang.String[] descriptorData = {
|
java.lang.String[] descriptorData = {
|
||||||
"\n\017alertInfo.proto\022\005alert\032\020alertConst.pro" +
|
"\n\017alertInfo.proto\022\005alert\032\020alertConst.pro" +
|
||||||
"to\"\255\002\n\023NccAlertInfoMessage\0224\n\010messages\030\001" +
|
"to\"\300\002\n\023NccAlertInfoMessage\0224\n\010messages\030\001" +
|
||||||
" \003(\0132\".alert.NccAlertInfoMessage.Message" +
|
" \003(\0132\".alert.NccAlertInfoMessage.Message" +
|
||||||
"\032\337\001\n\007Message\022\n\n\002id\030\001 \001(\t\022\r\n\005level\030\002 \001(\t\022" +
|
"\032\362\001\n\007Message\022\n\n\002id\030\001 \001(\t\022\r\n\005level\030\002 \001(\t\022" +
|
||||||
"\022\n\nalert_time\030\003 \001(\t\022\024\n\014alert_tip_id\030\004 \001(" +
|
"\022\n\nalert_time\030\003 \001(\t\022\024\n\014alert_tip_id\030\004 \001(" +
|
||||||
"\005\022\017\n\007line_id\030\005 \001(\005\022\024\n\014alert_object\030\006 \001(\t" +
|
"\005\022\017\n\007line_id\030\005 \001(\005\022\024\n\014alert_object\030\006 \001(\t" +
|
||||||
"\022$\n\nalert_type\030\007 \001(\0162\020.alert.AlertType\022\031" +
|
"\022$\n\nalert_type\030\007 \001(\0162\020.alert.AlertType\022\031" +
|
||||||
"\n\021locator_device_id\030\010 \001(\t\022\031\n\021alert_locat" +
|
"\n\021locator_device_id\030\010 \001(\t\022\031\n\021alert_locat" +
|
||||||
"ion_id\030\t \001(\003\022\014\n\004mock\030\n \001(\010B=\n!club.joyli" +
|
"ion_id\030\t \001(\003\022\014\n\004mock\030\n \001(\010\022\021\n\tline_type\030" +
|
||||||
"nk.xiannccda.dto.protosB\030NccAlertInfoMes" +
|
"\013 \001(\tB=\n!club.joylink.xiannccda.dto.prot" +
|
||||||
"sageProtob\006proto3"
|
"osB\030NccAlertInfoMessageProtob\006proto3"
|
||||||
};
|
};
|
||||||
descriptor = com.google.protobuf.Descriptors.FileDescriptor
|
descriptor = com.google.protobuf.Descriptors.FileDescriptor
|
||||||
.internalBuildGeneratedFileFrom(descriptorData,
|
.internalBuildGeneratedFileFrom(descriptorData,
|
||||||
@ -2338,7 +2522,7 @@ public final class NccAlertInfoMessageProto {
|
|||||||
internal_static_alert_NccAlertInfoMessage_Message_fieldAccessorTable = new
|
internal_static_alert_NccAlertInfoMessage_Message_fieldAccessorTable = new
|
||||||
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
|
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
|
||||||
internal_static_alert_NccAlertInfoMessage_Message_descriptor,
|
internal_static_alert_NccAlertInfoMessage_Message_descriptor,
|
||||||
new java.lang.String[] { "Id", "Level", "AlertTime", "AlertTipId", "LineId", "AlertObject", "AlertType", "LocatorDeviceId", "AlertLocationId", "Mock", });
|
new java.lang.String[] { "Id", "Level", "AlertTime", "AlertTipId", "LineId", "AlertObject", "AlertType", "LocatorDeviceId", "AlertLocationId", "Mock", "LineType", });
|
||||||
club.joylink.xiannccda.dto.protos.AlertConstProto.getDescriptor();
|
club.joylink.xiannccda.dto.protos.AlertConstProto.getDescriptor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,4 +22,6 @@ public interface IAuthRoleRepository extends IService<AuthRole> {
|
|||||||
Page<AuthRoleDTO> roleApiPage(AuthRoleQueryDTO role);
|
Page<AuthRoleDTO> roleApiPage(AuthRoleQueryDTO role);
|
||||||
|
|
||||||
List<AuthRole> getAuthRoleByUserId(String userId);
|
List<AuthRole> getAuthRoleByUserId(String userId);
|
||||||
|
|
||||||
|
void roleConfig(Long id, AuthRoleDTO configStr);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import club.joylink.xiannccda.dto.auth.AuthRoleQueryDTO;
|
|||||||
import club.joylink.xiannccda.entity.AuthRole;
|
import club.joylink.xiannccda.entity.AuthRole;
|
||||||
import club.joylink.xiannccda.mapper.AuthRoleMapper;
|
import club.joylink.xiannccda.mapper.AuthRoleMapper;
|
||||||
import club.joylink.xiannccda.repository.IAuthRoleRepository;
|
import club.joylink.xiannccda.repository.IAuthRoleRepository;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -40,4 +41,13 @@ public class AuthRoleRepository extends ServiceImpl<AuthRoleMapper, AuthRole> im
|
|||||||
public List<AuthRole> getAuthRoleByUserId(String userId) {
|
public List<AuthRole> getAuthRoleByUserId(String userId) {
|
||||||
return this.baseMapper.getAuthRoleByUserId(userId);
|
return this.baseMapper.getAuthRoleByUserId(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void roleConfig(Long id, AuthRoleDTO configStr) {
|
||||||
|
UpdateWrapper<AuthRole> uw = new UpdateWrapper<>();
|
||||||
|
uw.lambda().eq(AuthRole::getId, id).set(AuthRole::getRoleConfigStr, configStr.getRoleConfigStr());
|
||||||
|
|
||||||
|
this.update(uw);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package club.joylink.xiannccda.service;
|
|||||||
import club.joylink.xiannccda.alert.NccAlertInfo;
|
import club.joylink.xiannccda.alert.NccAlertInfo;
|
||||||
import club.joylink.xiannccda.alert.NccAlertInfo.AlertStatus;
|
import club.joylink.xiannccda.alert.NccAlertInfo.AlertStatus;
|
||||||
import club.joylink.xiannccda.alert.core.AlertDeviceType;
|
import club.joylink.xiannccda.alert.core.AlertDeviceType;
|
||||||
|
import club.joylink.xiannccda.constants.common.LineTypeEnum;
|
||||||
import club.joylink.xiannccda.dto.CommonPage;
|
import club.joylink.xiannccda.dto.CommonPage;
|
||||||
import club.joylink.xiannccda.dto.CommonPageRequest;
|
import club.joylink.xiannccda.dto.CommonPageRequest;
|
||||||
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
||||||
@ -91,14 +92,14 @@ public class AlertRecordService {
|
|||||||
private static final List<String> FILTER_LIST = List.of(TipTimeConfig.EVENING_PEARK.name(), TipTimeConfig.MORN_PEAK.name()/*, TipTimeConfig.NORMAL_UNPEARK.name()*/);
|
private static final List<String> FILTER_LIST = List.of(TipTimeConfig.EVENING_PEARK.name(), TipTimeConfig.MORN_PEAK.name()/*, TipTimeConfig.NORMAL_UNPEARK.name()*/);
|
||||||
|
|
||||||
private AlertTip findTipFromAlertTime(AlertRecord ar, String tipType, Long areaConfigId, boolean hasAreaConfigId) {
|
private AlertTip findTipFromAlertTime(AlertRecord ar, String tipType, Long areaConfigId, boolean hasAreaConfigId) {
|
||||||
if (Objects.isNull(ar)) {
|
/* if (Objects.isNull(ar)) {
|
||||||
return this.findAlertTip(tipType, areaConfigId, Optional.empty(), hasAreaConfigId);
|
return this.findAlertTip(ar.getLineId(), ar.getLineType(), tipType, areaConfigId, Optional.empty(), hasAreaConfigId);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
Collection<AlertTipTimeConfig> collection = this.timeConfigService.getCache();
|
Collection<AlertTipTimeConfig> collection = this.timeConfigService.getCache();
|
||||||
if (CollectionUtils.isEmpty(collection)) {
|
if (CollectionUtils.isEmpty(collection)) {
|
||||||
log.info("高低峰配置数据为空,返回默认的辅助消息");
|
log.info("高低峰配置数据为空,返回默认的辅助消息");
|
||||||
return this.findAlertTip(tipType, areaConfigId, Optional.empty(), hasAreaConfigId);
|
return this.findAlertTip(ar.getLineId(), ar.getLineType(), tipType, areaConfigId, Optional.empty(), hasAreaConfigId);
|
||||||
} else {
|
} else {
|
||||||
int hour = LocalDateTime.now().getHour();
|
int hour = LocalDateTime.now().getHour();
|
||||||
if (Objects.nonNull(ar.getAlertTime())) {
|
if (Objects.nonNull(ar.getAlertTime())) {
|
||||||
@ -111,20 +112,21 @@ public class AlertRecordService {
|
|||||||
if (tipTimeConfigOptional.isEmpty() && normalOptional.isEmpty()) {
|
if (tipTimeConfigOptional.isEmpty() && normalOptional.isEmpty()) {
|
||||||
//高低峰都没有找到
|
//高低峰都没有找到
|
||||||
log.info("高低峰均未匹配,告警时间(小时) {}", hour);
|
log.info("高低峰均未匹配,告警时间(小时) {}", hour);
|
||||||
return this.findAlertTip(tipType, areaConfigId, Optional.empty(), hasAreaConfigId);
|
return this.findAlertTip(ar.getLineId(), ar.getLineType(), tipType, areaConfigId, Optional.empty(), hasAreaConfigId);
|
||||||
} else if (tipTimeConfigOptional.isPresent()) {
|
} else if (tipTimeConfigOptional.isPresent()) {
|
||||||
//匹配上高峰
|
//匹配上高峰
|
||||||
return this.findAlertTip(tipType, areaConfigId, tipTimeConfigOptional, hasAreaConfigId);
|
return this.findAlertTip(ar.getLineId(), ar.getLineType(), tipType, areaConfigId, tipTimeConfigOptional, hasAreaConfigId);
|
||||||
} else {
|
} else {
|
||||||
//匹配上低峰
|
//匹配上低峰
|
||||||
return this.findAlertTip(tipType, areaConfigId, normalOptional, hasAreaConfigId);
|
return this.findAlertTip(ar.getLineId(), ar.getLineType(), tipType, areaConfigId, normalOptional, hasAreaConfigId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private AlertTip findAlertTip(String tipType, Long areaConfigId, Optional<AlertTipTimeConfig> tipTimeConfigOptional, boolean hasAreaConfigId) {
|
private AlertTip findAlertTip(Integer lineId, LineTypeEnum lineType, String tipType, Long areaConfigId, Optional<AlertTipTimeConfig> tipTimeConfigOptional, boolean hasAreaConfigId) {
|
||||||
|
|
||||||
LambdaQueryWrapper<AlertTip> qw = Wrappers.lambdaQuery(AlertTip.class).eq(AlertTip::getAlertType, tipType);
|
LambdaQueryWrapper<AlertTip> qw = Wrappers.lambdaQuery(AlertTip.class)
|
||||||
|
.eq(AlertTip::getLineId, lineId).eq(AlertTip::getLineType, lineType).eq(AlertTip::getAlertType, tipType);
|
||||||
qw.eq(hasAreaConfigId, AlertTip::getAreaConfigId, areaConfigId);
|
qw.eq(hasAreaConfigId, AlertTip::getAreaConfigId, areaConfigId);
|
||||||
Long id = tipTimeConfigOptional.map(AlertTipTimeConfig::getId).orElse(null);
|
Long id = tipTimeConfigOptional.map(AlertTipTimeConfig::getId).orElse(null);
|
||||||
List<AlertTip> alertTips = this.alertTipRepository.list(qw);
|
List<AlertTip> alertTips = this.alertTipRepository.list(qw);
|
||||||
@ -145,6 +147,7 @@ public class AlertRecordService {
|
|||||||
|
|
||||||
public AlertTip confirm(Long recordId, String tipType, Long areaConfigId) {
|
public AlertTip confirm(Long recordId, String tipType, Long areaConfigId) {
|
||||||
AlertRecord ar = this.alertRecordRepository.getById(recordId);
|
AlertRecord ar = this.alertRecordRepository.getById(recordId);
|
||||||
|
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(ar), "未找到对应的告警记录");
|
||||||
Long newAreaConfigId = null;
|
Long newAreaConfigId = null;
|
||||||
if (Objects.nonNull(ar)) {
|
if (Objects.nonNull(ar)) {
|
||||||
newAreaConfigId = this.findAreaConfig(ar, tipType);
|
newAreaConfigId = this.findAreaConfig(ar, tipType);
|
||||||
|
@ -38,6 +38,7 @@ public class AlertTipService {
|
|||||||
AlertTip saveEntity = convertToEntity(saveDTO);
|
AlertTip saveEntity = convertToEntity(saveDTO);
|
||||||
LambdaQueryWrapper<AlertTip> queryWrapper = Wrappers.lambdaQuery(AlertTip.class);
|
LambdaQueryWrapper<AlertTip> queryWrapper = Wrappers.lambdaQuery(AlertTip.class);
|
||||||
queryWrapper.eq(AlertTip::getAlertType, saveEntity.getAlertType())
|
queryWrapper.eq(AlertTip::getAlertType, saveEntity.getAlertType())
|
||||||
|
.eq(AlertTip::getLineId, saveEntity.getLineId()).eq(AlertTip::getLineType, saveEntity.getLineType())
|
||||||
.eq(AlertTip::getAreaConfigId, saveEntity.getAreaConfigId());
|
.eq(AlertTip::getAreaConfigId, saveEntity.getAreaConfigId());
|
||||||
if (CollectionUtils.isNotEmpty(saveDTO.getTipTimeIds())) {
|
if (CollectionUtils.isNotEmpty(saveDTO.getTipTimeIds())) {
|
||||||
String tipTimeCond = saveDTO.getTipTimeIds().stream().map(d -> String.format(" find_in_set('%s',%s) > 0 ", d, AlertTip.TIP_TIME_REF)).collect(Collectors.joining(" OR "));
|
String tipTimeCond = saveDTO.getTipTimeIds().stream().map(d -> String.format(" find_in_set('%s',%s) > 0 ", d, AlertTip.TIP_TIME_REF)).collect(Collectors.joining(" OR "));
|
||||||
|
@ -28,6 +28,12 @@ public interface IMessageServer {
|
|||||||
return PLACEHOLDER_HELPER.replacePlaceholders(this.getDestinationPattern(), properties);
|
return PLACEHOLDER_HELPER.replacePlaceholders(this.getDestinationPattern(), properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default String createPlace(Map<String, String> properMap) {
|
||||||
|
Properties properties = new Properties();
|
||||||
|
properMap.forEach((k, v) -> properties.put(k, v));
|
||||||
|
return PLACEHOLDER_HELPER.replacePlaceholders(this.getDestinationPattern(), properties);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 服务路径pattern
|
* 服务路径pattern
|
||||||
*
|
*
|
||||||
|
@ -1,15 +1,18 @@
|
|||||||
package club.joylink.xiannccda.ws;
|
package club.joylink.xiannccda.ws;
|
||||||
|
|
||||||
import club.joylink.xiannccda.alert.NccAlertInfo;
|
import club.joylink.xiannccda.alert.NccAlertInfo;
|
||||||
|
import club.joylink.xiannccda.constants.common.LineTypeEnum;
|
||||||
import club.joylink.xiannccda.dto.protos.NccAlertInfoMessageProto.NccAlertInfoMessage;
|
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.Builder;
|
||||||
import club.joylink.xiannccda.dto.protos.NccAlertInfoMessageProto.NccAlertInfoMessage.Message;
|
import club.joylink.xiannccda.dto.protos.NccAlertInfoMessageProto.NccAlertInfoMessage.Message;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
|
|
||||||
@ -18,20 +21,25 @@ import java.util.concurrent.ConcurrentLinkedQueue;
|
|||||||
*/
|
*/
|
||||||
public class NccAlertMessageServer implements IMessageServer {
|
public class NccAlertMessageServer implements IMessageServer {
|
||||||
|
|
||||||
private static final Map<String, NccAlertMessageServer> SERVER_MAP = new ConcurrentHashMap<>();
|
private static final Map<LineTypeEnum, NccAlertMessageServer> SERVER_MAP = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private String id;
|
private LineTypeEnum lineType;
|
||||||
private final String Destination = "/queue/xian/ncc/alert";
|
|
||||||
|
private Set<String> lineIdSet = Sets.newHashSet();
|
||||||
|
|
||||||
|
private final String DestinationOcc = "/queue/xian/{lineType}/{lineId}/alert";
|
||||||
|
|
||||||
Queue<NccAlertInfo> pendingMsgQueue = new ConcurrentLinkedQueue<>();
|
Queue<NccAlertInfo> pendingMsgQueue = new ConcurrentLinkedQueue<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDestinationPattern() {
|
public String getDestinationPattern() {
|
||||||
return Destination;
|
return DestinationOcc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object onSubscription(String destination, Map<String, String> paramMap) {
|
public Object onSubscription(String destination, Map<String, String> paramMap) {
|
||||||
|
String lineId = paramMap.get("lineId");
|
||||||
|
this.lineIdSet.add(lineId);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,26 +59,22 @@ public class NccAlertMessageServer implements IMessageServer {
|
|||||||
builder.addMessages(message);
|
builder.addMessages(message);
|
||||||
byte[] bytes = builder.build().toByteArray();
|
byte[] bytes = builder.build().toByteArray();
|
||||||
if (bytes != null && bytes.length != 0) {
|
if (bytes != null && bytes.length != 0) {
|
||||||
list.add(new TopicMessage(getDestinationPattern(), bytes));
|
String dest = this.createPlace(Map.of("lineType", this.lineType.name(), "lineId", alertInfo.getLineId().toString()));
|
||||||
|
list.add(new TopicMessage(dest, bytes));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
private NccAlertMessageServer(String id) {
|
private NccAlertMessageServer(LineTypeEnum lineType) {
|
||||||
this.id = id;
|
this.lineType = lineType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NccAlertMessageServer getDefault() {
|
public static NccAlertMessageServer getInstance(LineTypeEnum lineType) {
|
||||||
return getInstance("default");
|
return SERVER_MAP.computeIfAbsent(lineType, k -> new NccAlertMessageServer(lineType));
|
||||||
}
|
|
||||||
|
|
||||||
public static NccAlertMessageServer getInstance(String id) {
|
|
||||||
return SERVER_MAP.computeIfAbsent(id, k -> new NccAlertMessageServer(id));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NccAlertMessageServer removeInstance(String id) {
|
public static NccAlertMessageServer removeInstance(String id) {
|
||||||
@ -88,7 +92,7 @@ public class NccAlertMessageServer implements IMessageServer {
|
|||||||
.setAlertTime(alertInfo.getAlertTime().toString())
|
.setAlertTime(alertInfo.getAlertTime().toString())
|
||||||
.setLineId(alertInfo.getLineId())
|
.setLineId(alertInfo.getLineId())
|
||||||
.setAlertObject(alertInfo.getAlertObject())
|
.setAlertObject(alertInfo.getAlertObject())
|
||||||
.setAlertType(alertInfo.getAlertType());
|
.setAlertType(alertInfo.getAlertType()).setLineType(alertInfo.getLineType().name());
|
||||||
if (Objects.nonNull(alertInfo.getAlertLocationId())) {
|
if (Objects.nonNull(alertInfo.getAlertLocationId())) {
|
||||||
builder.setAlertLocationId(alertInfo.getAlertLocationId());
|
builder.setAlertLocationId(alertInfo.getAlertLocationId());
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,9 @@ occ-client:
|
|||||||
- 81
|
- 81
|
||||||
- 82
|
- 82
|
||||||
nameChanger: UNIVERSAL
|
nameChanger: UNIVERSAL
|
||||||
|
lineTypes:
|
||||||
|
- OCC
|
||||||
|
- NCC
|
||||||
|
|
||||||
#故障测试
|
#故障测试
|
||||||
mock-alert-test: false
|
mock-alert-test: false
|
||||||
|
@ -26,6 +26,9 @@ occ-client:
|
|||||||
filterRtuIds:
|
filterRtuIds:
|
||||||
- 81
|
- 81
|
||||||
- 82
|
- 82
|
||||||
|
lineTypes:
|
||||||
|
- OCC
|
||||||
|
- NCC
|
||||||
#故障测试
|
#故障测试
|
||||||
mock-alert-test: true
|
mock-alert-test: true
|
||||||
#加载历史模拟数据
|
#加载历史模拟数据
|
||||||
|
@ -29,6 +29,9 @@ occ-client:
|
|||||||
- 81
|
- 81
|
||||||
- 82
|
- 82
|
||||||
nameChanger: UNIVERSAL
|
nameChanger: UNIVERSAL
|
||||||
|
lineTypes:
|
||||||
|
- OCC
|
||||||
|
- NCC
|
||||||
|
|
||||||
|
|
||||||
mock-alert-test: true
|
mock-alert-test: true
|
||||||
|
@ -32,6 +32,9 @@ occ-client:
|
|||||||
filterRtuIds:
|
filterRtuIds:
|
||||||
- 81
|
- 81
|
||||||
- 82
|
- 82
|
||||||
|
lineTypes:
|
||||||
|
- OCC
|
||||||
|
- NCC
|
||||||
|
|
||||||
mock-alert-test: false
|
mock-alert-test: false
|
||||||
load-mock-history-data: false
|
load-mock-history-data: false
|
||||||
|
@ -29,6 +29,9 @@ occ-client:
|
|||||||
filterRtuIds:
|
filterRtuIds:
|
||||||
- 81
|
- 81
|
||||||
- 82
|
- 82
|
||||||
|
lineTypes:
|
||||||
|
- OCC
|
||||||
|
- NCC
|
||||||
|
|
||||||
mock-alert-test: false
|
mock-alert-test: false
|
||||||
load-mock-history-data: false
|
load-mock-history-data: false
|
||||||
|
@ -35,6 +35,9 @@ occ-client:
|
|||||||
filterRtuIds:
|
filterRtuIds:
|
||||||
- 81
|
- 81
|
||||||
- 82
|
- 82
|
||||||
|
lineTypes:
|
||||||
|
- OCC
|
||||||
|
- NCC
|
||||||
mock-alert-test: true
|
mock-alert-test: true
|
||||||
load-mock-history-data: false
|
load-mock-history-data: false
|
||||||
#延时加载告警处理
|
#延时加载告警处理
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
, name
|
, name
|
||||||
</sql>
|
</sql>
|
||||||
<select id="queryRole" resultType="club.joylink.xiannccda.dto.auth.AuthRoleDTO">
|
<select id="queryRole" resultType="club.joylink.xiannccda.dto.auth.AuthRoleDTO">
|
||||||
select A.id, A.name, B.api_ids
|
select A.id, A.name, A.role_config_str, B.api_ids
|
||||||
from auth_role A
|
from auth_role A
|
||||||
left join (select role_id, group_concat(api_id) as api_ids from auth_role_api_ref GROUP BY role_id) B
|
left join (select role_id, group_concat(api_id) as api_ids from auth_role_api_ref GROUP BY role_id) B
|
||||||
on A.id = B.role_id
|
on A.id = B.role_id
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 785ad308eb19a62a8372fcd77501638cae4f7d7b
|
Subproject commit 4f9012b0795f62bf352b078ebbc1b1fffa86849d
|
Loading…
Reference in New Issue
Block a user