调整
All checks were successful
local-test分支构建docker并发布运行 / Docker-Build (push) Successful in 1m15s

This commit is contained in:
tiger_zhou 2024-10-23 14:47:43 +08:00
parent b29a5fb5aa
commit 69eed1fc96
22 changed files with 352 additions and 76 deletions

View File

@ -2,12 +2,16 @@ package club.joylink.xiannccda.alert;
import club.joylink.xiannccda.alert.NccAlertInfo.AlertStatus;
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.event.Listener;
import club.joylink.xiannccda.repository.IAlertRecordRepository;
import club.joylink.xiannccda.ws.NccAlertMessageServer;
import club.joylink.xiannccda.ws.WsMessageServerManager;
import java.util.concurrent.atomic.AtomicInteger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
@ -19,6 +23,8 @@ public class AlertListenerJob implements ApplicationRunner {
private final WsMessageServerManager wsMessageServerManager;
private final IAlertRecordRepository alertRecordRepository;
@Autowired
private OccServerProto serverProto;
public AlertListenerJob(WsMessageServerManager wsMessageServerManager,
IAlertRecordRepository alertRecordRepository) {
@ -31,13 +37,14 @@ public class AlertListenerJob implements ApplicationRunner {
//添加报警事件监听器
addAlertListeners();
//注册西安NCC的报警ws消息发送服务
wsMessageServerManager.registerMessageServer(NccAlertMessageServer.getDefault());
wsMessageServerManager.registerMessageServer(NccAlertMessageServer.getInstance(LineTypeEnum.NCC));
wsMessageServerManager.registerMessageServer(NccAlertMessageServer.getInstance(LineTypeEnum.OCC));
//启动报警源事件监测任务
AlertManager.getDefault().taskStart();
}
private void addAlertListeners() {
NccAlertMessageServer nccAlertMessageServer = NccAlertMessageServer.getDefault();
AlertManager alertManager = AlertManager.getDefault();
//添加消息
alertManager.on(new Listener<NccAlertInfo>() {
@ -51,11 +58,19 @@ public class AlertListenerJob implements ApplicationRunner {
alertInfo.setId(idGenerator.decrementAndGet());
}*/
//不论是否mock 都保存数据库
OccClientMessage clientMessage = serverProto.getClientMessage(alertInfo.getLineId());
for (LineTypeEnum lineType : clientMessage.getLineTypes()) {
NccAlertMessageServer nccAlertMessageServer = NccAlertMessageServer.getInstance(lineType);
alertInfo.setLineType(lineType);
AlertRecord record = convertToRecord(alertInfo);
alertRecordRepository.save(record);
alertInfo.setId(record.getId());
nccAlertMessageServer.addMsg(alertInfo);
}
}
});
}

View File

@ -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.NameChangerEnum;
import club.joylink.xiannccda.configuration.protos.OccServerProto;
import club.joylink.xiannccda.configuration.protos.OccServerProto.OccClientMessage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import java.util.HashMap;
import java.util.List;
@ -10,6 +12,7 @@ import java.util.Objects;
import lombok.Data;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.context.properties.ConfigurationProperties;
@ -21,11 +24,10 @@ import org.springframework.stereotype.Component;
@Slf4j
@Component
@Setter
@ConfigurationProperties(prefix = "occ-client")
public class OccMessageManage implements ApplicationRunner {
private Map<Integer, OccClientMessage> clientInfoMap;
@Autowired
private OccServerProto occServerProto;
Map<Integer, XianOccMessagingClient> clientMap = new HashMap<>();
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) {
OccClientMessage clientMessage = this.clientInfoMap.get(lineId);
OccClientMessage clientMessage = this.occServerProto.getClientMessage(lineId);
if (Objects.isNull(clientMessage)) {
return true;
}
if (CollectionUtils.isEmpty(clientMessage.filterRtuIds)) {
if (CollectionUtils.isEmpty(clientMessage.getFilterRtuIds())) {
return true;
}
if (clientMessage.filterRtuIds.contains(rtuId)) {
if (clientMessage.rtuIdExists(rtuId)) {
return false;
}
return true;
@ -66,33 +68,16 @@ public class OccMessageManage implements ApplicationRunner {
DeviceNameChangerManage.init();
this.clientInfoMap.forEach((k, v) -> {
log.info("初始化 occ tcp连接.... 是否监控cpulineId:{} 内存信息:{}", k, v.monitorHandwareChange);
this.occServerProto.getClientInfoMap().forEach((k, v) -> {
log.info("初始化 occ tcp连接.... 是否监控cpulineId:{} 内存信息:{}", k, v.isMonitorHandwareChange());
DeviceNameChangerManage.initLineIdNameCHanger(k, v.getNameChanger());
XianOccMessagingClient client = new XianOccMessagingClient(k, v);
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;
}
}

View File

@ -1,15 +1,14 @@
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.ApplyTypeEnum;
import club.joylink.xiannccda.configuration.protos.OccServerProto.OccClientMessage;
import java.time.LocalDateTime;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import lombok.Getter;

View File

@ -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);
}
}
}

View File

@ -52,15 +52,7 @@ public class AlertTipTimeConfigController {
@Operation(summary = "保存修改")
@PostMapping("page")
@CommonLogAnno(name = "决策信息时间-分页查询", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.QUERY)
public IPage<AlertTipTimeConfig> page(Principal user, 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());
public IPage<AlertTipTimeConfig> page(AlertTipTimeQueryDTO dto) {
return this.configRepository.page(dto, Wrappers.lambdaQuery(AlertTipTimeConfig.class).eq(AlertTipTimeConfig::getListShower, 1));
}

View File

@ -72,6 +72,7 @@ public class RoleAuthController {
this.authPathRepository.removeById(id);
}
@GetMapping("/role/page")
@SecurityRequirement(name = "jwt")
@Operation(summary = "角色分页")
@ -88,4 +89,11 @@ public class RoleAuthController {
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);
}
}

View File

@ -14,4 +14,5 @@ public class AuthRoleDTO {
private List<Long> resList;
@JsonIgnore
private String apiIds;
private String roleConfigStr;
}

View File

@ -180,6 +180,26 @@ public final class NccAlertInfoMessageProto {
* @return The mock.
*/
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}
@ -200,6 +220,7 @@ public final class NccAlertInfoMessageProto {
alertObject_ = "";
alertType_ = 0;
locatorDeviceId_ = "";
lineType_ = "";
}
@java.lang.Override
@ -483,6 +504,53 @@ public final class NccAlertInfoMessageProto {
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;
@java.lang.Override
public final boolean isInitialized() {
@ -527,6 +595,9 @@ public final class NccAlertInfoMessageProto {
if (mock_ != false) {
output.writeBool(10, mock_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(lineType_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 11, lineType_);
}
getUnknownFields().writeTo(output);
}
@ -571,6 +642,9 @@ public final class NccAlertInfoMessageProto {
size += com.google.protobuf.CodedOutputStream
.computeBoolSize(10, mock_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(lineType_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(11, lineType_);
}
size += getUnknownFields().getSerializedSize();
memoizedSize = size;
return size;
@ -605,6 +679,8 @@ public final class NccAlertInfoMessageProto {
!= other.getAlertLocationId()) return false;
if (getMock()
!= other.getMock()) return false;
if (!getLineType()
.equals(other.getLineType())) return false;
if (!getUnknownFields().equals(other.getUnknownFields())) return false;
return true;
}
@ -638,6 +714,8 @@ public final class NccAlertInfoMessageProto {
hash = (37 * hash) + MOCK_FIELD_NUMBER;
hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(
getMock());
hash = (37 * hash) + LINE_TYPE_FIELD_NUMBER;
hash = (53 * hash) + getLineType().hashCode();
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
@ -779,6 +857,7 @@ public final class NccAlertInfoMessageProto {
locatorDeviceId_ = "";
alertLocationId_ = 0L;
mock_ = false;
lineType_ = "";
return this;
}
@ -842,6 +921,9 @@ public final class NccAlertInfoMessageProto {
if (((from_bitField0_ & 0x00000200) != 0)) {
result.mock_ = mock_;
}
if (((from_bitField0_ & 0x00000400) != 0)) {
result.lineType_ = lineType_;
}
}
@java.lang.Override
@ -896,6 +978,11 @@ public final class NccAlertInfoMessageProto {
if (other.getMock() != false) {
setMock(other.getMock());
}
if (!other.getLineType().isEmpty()) {
lineType_ = other.lineType_;
bitField0_ |= 0x00000400;
onChanged();
}
this.mergeUnknownFields(other.getUnknownFields());
onChanged();
return this;
@ -972,6 +1059,11 @@ public final class NccAlertInfoMessageProto {
bitField0_ |= 0x00000200;
break;
} // case 80
case 90: {
lineType_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000400;
break;
} // case 90
default: {
if (!super.parseUnknownField(input, extensionRegistry, tag)) {
done = true; // was an endgroup tag
@ -1541,6 +1633,98 @@ public final class NccAlertInfoMessageProto {
onChanged();
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
public final Builder setUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
@ -2311,16 +2495,16 @@ public final class NccAlertInfoMessageProto {
static {
java.lang.String[] descriptorData = {
"\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" +
"\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(" +
"\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" +
"\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" +
"nk.xiannccda.dto.protosB\030NccAlertInfoMes" +
"sageProtob\006proto3"
"ion_id\030\t \001(\003\022\014\n\004mock\030\n \001(\010\022\021\n\tline_type\030" +
"\013 \001(\tB=\n!club.joylink.xiannccda.dto.prot" +
"osB\030NccAlertInfoMessageProtob\006proto3"
};
descriptor = com.google.protobuf.Descriptors.FileDescriptor
.internalBuildGeneratedFileFrom(descriptorData,
@ -2338,7 +2522,7 @@ public final class NccAlertInfoMessageProto {
internal_static_alert_NccAlertInfoMessage_Message_fieldAccessorTable = new
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
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();
}

View File

@ -22,4 +22,6 @@ public interface IAuthRoleRepository extends IService<AuthRole> {
Page<AuthRoleDTO> roleApiPage(AuthRoleQueryDTO role);
List<AuthRole> getAuthRoleByUserId(String userId);
void roleConfig(Long id, AuthRoleDTO configStr);
}

View File

@ -5,6 +5,7 @@ import club.joylink.xiannccda.dto.auth.AuthRoleQueryDTO;
import club.joylink.xiannccda.entity.AuthRole;
import club.joylink.xiannccda.mapper.AuthRoleMapper;
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.service.impl.ServiceImpl;
import java.util.Arrays;
@ -40,4 +41,13 @@ public class AuthRoleRepository extends ServiceImpl<AuthRoleMapper, AuthRole> im
public List<AuthRole> getAuthRoleByUserId(String 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);
}
}

View File

@ -3,6 +3,7 @@ package club.joylink.xiannccda.service;
import club.joylink.xiannccda.alert.NccAlertInfo;
import club.joylink.xiannccda.alert.NccAlertInfo.AlertStatus;
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.CommonPageRequest;
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 AlertTip findTipFromAlertTime(AlertRecord ar, String tipType, Long areaConfigId, boolean hasAreaConfigId) {
if (Objects.isNull(ar)) {
return this.findAlertTip(tipType, areaConfigId, Optional.empty(), hasAreaConfigId);
}
/* if (Objects.isNull(ar)) {
return this.findAlertTip(ar.getLineId(), ar.getLineType(), tipType, areaConfigId, Optional.empty(), hasAreaConfigId);
}*/
Collection<AlertTipTimeConfig> collection = this.timeConfigService.getCache();
if (CollectionUtils.isEmpty(collection)) {
log.info("高低峰配置数据为空,返回默认的辅助消息");
return this.findAlertTip(tipType, areaConfigId, Optional.empty(), hasAreaConfigId);
return this.findAlertTip(ar.getLineId(), ar.getLineType(), tipType, areaConfigId, Optional.empty(), hasAreaConfigId);
} else {
int hour = LocalDateTime.now().getHour();
if (Objects.nonNull(ar.getAlertTime())) {
@ -111,20 +112,21 @@ public class AlertRecordService {
if (tipTimeConfigOptional.isEmpty() && normalOptional.isEmpty()) {
//高低峰都没有找到
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()) {
//匹配上高峰
return this.findAlertTip(tipType, areaConfigId, tipTimeConfigOptional, hasAreaConfigId);
return this.findAlertTip(ar.getLineId(), ar.getLineType(), tipType, areaConfigId, tipTimeConfigOptional, hasAreaConfigId);
} 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);
Long id = tipTimeConfigOptional.map(AlertTipTimeConfig::getId).orElse(null);
List<AlertTip> alertTips = this.alertTipRepository.list(qw);
@ -145,6 +147,7 @@ public class AlertRecordService {
public AlertTip confirm(Long recordId, String tipType, Long areaConfigId) {
AlertRecord ar = this.alertRecordRepository.getById(recordId);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(ar), "未找到对应的告警记录");
Long newAreaConfigId = null;
if (Objects.nonNull(ar)) {
newAreaConfigId = this.findAreaConfig(ar, tipType);

View File

@ -38,6 +38,7 @@ public class AlertTipService {
AlertTip saveEntity = convertToEntity(saveDTO);
LambdaQueryWrapper<AlertTip> queryWrapper = Wrappers.lambdaQuery(AlertTip.class);
queryWrapper.eq(AlertTip::getAlertType, saveEntity.getAlertType())
.eq(AlertTip::getLineId, saveEntity.getLineId()).eq(AlertTip::getLineType, saveEntity.getLineType())
.eq(AlertTip::getAreaConfigId, saveEntity.getAreaConfigId());
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 "));

View File

@ -28,6 +28,12 @@ public interface IMessageServer {
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
*

View File

@ -1,15 +1,18 @@
package club.joylink.xiannccda.ws;
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.Builder;
import club.joylink.xiannccda.dto.protos.NccAlertInfoMessageProto.NccAlertInfoMessage.Message;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Queue;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
@ -18,20 +21,25 @@ import java.util.concurrent.ConcurrentLinkedQueue;
*/
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 final String Destination = "/queue/xian/ncc/alert";
private LineTypeEnum lineType;
private Set<String> lineIdSet = Sets.newHashSet();
private final String DestinationOcc = "/queue/xian/{lineType}/{lineId}/alert";
Queue<NccAlertInfo> pendingMsgQueue = new ConcurrentLinkedQueue<>();
@Override
public String getDestinationPattern() {
return Destination;
return DestinationOcc;
}
@Override
public Object onSubscription(String destination, Map<String, String> paramMap) {
String lineId = paramMap.get("lineId");
this.lineIdSet.add(lineId);
return null;
}
@ -51,26 +59,22 @@ public class NccAlertMessageServer implements IMessageServer {
builder.addMessages(message);
byte[] bytes = builder.build().toByteArray();
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 {
break;
}
}
return list;
}
private NccAlertMessageServer(String id) {
this.id = id;
private NccAlertMessageServer(LineTypeEnum lineType) {
this.lineType = lineType;
}
public static NccAlertMessageServer getDefault() {
return getInstance("default");
}
public static NccAlertMessageServer getInstance(String id) {
return SERVER_MAP.computeIfAbsent(id, k -> new NccAlertMessageServer(id));
public static NccAlertMessageServer getInstance(LineTypeEnum lineType) {
return SERVER_MAP.computeIfAbsent(lineType, k -> new NccAlertMessageServer(lineType));
}
public static NccAlertMessageServer removeInstance(String id) {
@ -88,7 +92,7 @@ public class NccAlertMessageServer implements IMessageServer {
.setAlertTime(alertInfo.getAlertTime().toString())
.setLineId(alertInfo.getLineId())
.setAlertObject(alertInfo.getAlertObject())
.setAlertType(alertInfo.getAlertType());
.setAlertType(alertInfo.getAlertType()).setLineType(alertInfo.getLineType().name());
if (Objects.nonNull(alertInfo.getAlertLocationId())) {
builder.setAlertLocationId(alertInfo.getAlertLocationId());
}

View File

@ -29,6 +29,9 @@ occ-client:
- 81
- 82
nameChanger: UNIVERSAL
lineTypes:
- OCC
- NCC
#故障测试
mock-alert-test: false

View File

@ -26,6 +26,9 @@ occ-client:
filterRtuIds:
- 81
- 82
lineTypes:
- OCC
- NCC
#故障测试
mock-alert-test: true
#加载历史模拟数据

View File

@ -29,6 +29,9 @@ occ-client:
- 81
- 82
nameChanger: UNIVERSAL
lineTypes:
- OCC
- NCC
mock-alert-test: true

View File

@ -32,6 +32,9 @@ occ-client:
filterRtuIds:
- 81
- 82
lineTypes:
- OCC
- NCC
mock-alert-test: false
load-mock-history-data: false

View File

@ -29,6 +29,9 @@ occ-client:
filterRtuIds:
- 81
- 82
lineTypes:
- OCC
- NCC
mock-alert-test: false
load-mock-history-data: false

View File

@ -35,6 +35,9 @@ occ-client:
filterRtuIds:
- 81
- 82
lineTypes:
- OCC
- NCC
mock-alert-test: true
load-mock-history-data: false
#延时加载告警处理

View File

@ -13,7 +13,7 @@
, name
</sql>
<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
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

@ -1 +1 @@
Subproject commit 785ad308eb19a62a8372fcd77501638cae4f7d7b
Subproject commit 4f9012b0795f62bf352b078ebbc1b1fffa86849d