From cb8997c820379a16f52b5d345c997a8024f5268e Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Thu, 9 Nov 2023 14:11:34 +0800 Subject: [PATCH 1/4] =?UTF-8?q?#=E5=91=8A=E8=AD=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alarm/monitor/listener/AlarmListener.java | 27 +++++++++++++ .../hzims/alarm/monitor/listener/QuqueConfig.java | 45 ++++++++++++++++++++++ .../alarm/monitor/service/AlarmSaveService.java | 8 ++++ .../monitor/service/impl/AlarmSaveServiceImpl.java | 16 ++++++++ .../alarm/show/controller/ShowAlarmController.java | 2 +- 5 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java create mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/QuqueConfig.java create mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/AlarmSaveService.java create mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java new file mode 100644 index 0000000..0ac19d4 --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java @@ -0,0 +1,27 @@ +package com.hnac.hzims.alarm.monitor.listener; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.connection.Message; +import org.springframework.data.redis.connection.MessageListener; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.serializer.RedisSerializer; +import org.springframework.stereotype.Component; + +/** + * @author ysj + * @version 4.0.0 + * @create 2023-11-09-14:04 + */ +@Component +public class AlarmListener implements MessageListener { + + @Autowired + private RedisTemplate redisTemplate; + + @Override + public void onMessage(Message message, byte[] pattern) { + RedisSerializer serializer = redisTemplate.getStringSerializer(); + String msg = serializer.deserialize(message.getBody()); + System.out.println("接收到的消息是:" + msg); + } +} diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/QuqueConfig.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/QuqueConfig.java new file mode 100644 index 0000000..418df54 --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/QuqueConfig.java @@ -0,0 +1,45 @@ +package com.hnac.hzims.alarm.monitor.listener; + +import com.hnac.hzims.common.config.RedisMessageListener; +import org.springframework.context.annotation.Bean; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.listener.PatternTopic; +import org.springframework.data.redis.listener.RedisMessageListenerContainer; +import org.springframework.data.redis.listener.adapter.MessageListenerAdapter; + +/** + * @author ysj + * @version 4.0.0 + * @create 2023-11-09 14:02 + */ +public class QuqueConfig { + + + /** + * 创建连接工厂 + * + * @param connectionFactory + * @param adapter + * @return + */ + @Bean + public RedisMessageListenerContainer container(RedisConnectionFactory connectionFactory, + MessageListenerAdapter adapter) { + RedisMessageListenerContainer container = new RedisMessageListenerContainer(); + container.setConnectionFactory(connectionFactory); + //监听对应的channel + container.addMessageListener(adapter, new PatternTopic("alarmchannel")); + return container; + } + + /** + * 绑定消息监听者和接收监听的方法 + * @param message + * @return + */ + @Bean + public MessageListenerAdapter adapter(RedisMessageListener message) { + // onMessage 如果RedisMessage 中 没有实现接口,这个参数必须跟RedisMessage中的读取信息的方法名称一样 + return new MessageListenerAdapter(message, "onMessage"); + } +} diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/AlarmSaveService.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/AlarmSaveService.java new file mode 100644 index 0000000..8bf2fa0 --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/AlarmSaveService.java @@ -0,0 +1,8 @@ +package com.hnac.hzims.alarm.monitor.service; + +/** + * @author ysj + */ +public interface AlarmSaveService { + +} \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java new file mode 100644 index 0000000..0472496 --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java @@ -0,0 +1,16 @@ +package com.hnac.hzims.alarm.monitor.service.impl; + +import com.hnac.hzims.alarm.monitor.service.AlarmSaveService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +/** + * @author ysj + */ +@AllArgsConstructor +@Service +@Slf4j +public class AlarmSaveServiceImpl implements AlarmSaveService { + +} \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java index 3c9eb67..66da6fe 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java @@ -48,7 +48,7 @@ public class ShowAlarmController extends BladeController { @PostMapping("/show") @ApiOperationSupport(order = 2) @ApiOperation(value = "告警列表分页", notes = "传入: AlarmConfigEntity对象,分页参数") - public R> alarms(@ApiIgnore @RequestParam AlarmEntity alarm, Query query) { + public R> alarms(AlarmEntity alarm, Query query) { return R.data(alarmService.alarms(alarm,Condition.getPage(query))); } From b214f8d75512556f236af225d9859ee9aa7e94eb Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Thu, 9 Nov 2023 18:01:10 +0800 Subject: [PATCH 2/4] =?UTF-8?q?#=E5=91=8A=E8=AD=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/hzims/alarm/vo/AlarmHandleMarkVo.java | 35 +++++++ .../operational/station/feign/IStationClient.java | 10 ++ .../station/feign/IStationClientFallBack.java | 6 ++ .../config/service/AlarmConfigDetailService.java | 2 + .../alarm/config/service/AlarmConfigService.java | 6 +- .../service/impl/AlarmConfigDetailServiceImpl.java | 102 +++++++++++++++++++++ .../service/impl/AlarmConfigServiceImpl.java | 44 +++++++++ .../hzims/alarm/monitor/listener/QuqueConfig.java | 53 ++++++----- .../alarm/monitor/service/AlarmSaveService.java | 5 + .../monitor/service/impl/AlarmSaveServiceImpl.java | 78 +++++++++++++++- .../operational/station/feign/StationClient.java | 8 +- 11 files changed, 315 insertions(+), 34 deletions(-) create mode 100644 hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/AlarmHandleMarkVo.java diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/AlarmHandleMarkVo.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/AlarmHandleMarkVo.java new file mode 100644 index 0000000..9259440 --- /dev/null +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/AlarmHandleMarkVo.java @@ -0,0 +1,35 @@ +package com.hnac.hzims.alarm.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + */ +@Data +public class AlarmHandleMarkVo { + + @ApiModelProperty(value = "是否集中监控右侧列表展示 : 0-展示 1-不展示") + private Integer isRightTabulation; + + @ApiModelProperty(value = "是否集中监控弹窗展示 : 0-展示 1-不展示") + private Integer isShowAlert; + + @ApiModelProperty(value = "是否集中监控铃铛展示 : 0-展示 1-不展示") + private Integer isSmallBell; + + @ApiModelProperty(value = "是否集中监控遮罩展示 : 0-展示 1-不展示") + private Integer isMask; + + @ApiModelProperty(value = "是否语音播报 : 0-播报 1-不播报") + private Integer isBroadcast; + + @ApiModelProperty(value = "是否进行平台消息推送 : 0-推送 1-不推送") + private Integer isPlatformMessage; + + @ApiModelProperty(value = "是否短信推送 :0-推送 1-不推送") + private Integer isShortMessage; + + @ApiModelProperty(value = "是否微信公众号消息推送 :0-推送 1-不推送") + private Integer isWxMessage; +} \ No newline at end of file diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java index 928167a..cc8856a 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java @@ -31,6 +31,8 @@ public interface IStationClient { String QUERY_EXIST_LGTD_LTTD = API_PREFIX + "/queryExistLgtdAndLttd"; String GET_ONE = API_PREFIX + "/getOne"; + String QUERY_STATION_BY_CODES = API_PREFIX + "/querySatationByCodes"; + @GetMapping(GET_LIST_ALL) R> getListAll(); @@ -71,4 +73,12 @@ public interface IStationClient { */ @PostMapping(GET_ONE) R getOne(@RequestBody StationEntity request); + + /** + * 根据站点code查询站点 + * @param codes + * @return + */ + @PostMapping(QUERY_STATION_BY_CODES) + R> querySatationByCodes(@RequestParam("codes") List codes); } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClientFallBack.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClientFallBack.java index 741a479..5c0aca1 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClientFallBack.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClientFallBack.java @@ -6,6 +6,7 @@ import org.springblade.core.tool.api.R; import org.springblade.system.user.entity.User; import org.springframework.stereotype.Component; +import java.util.ArrayList; import java.util.List; @Component @@ -70,4 +71,9 @@ public class IStationClientFallBack implements IStationClient { public R getOne(StationEntity request) { return R.data(null); } + + @Override + public R> querySatationByCodes(List codes) { + return R.data(new ArrayList<>()); + } } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/AlarmConfigDetailService.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/AlarmConfigDetailService.java index dc3548f..d66c2b4 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/AlarmConfigDetailService.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/AlarmConfigDetailService.java @@ -3,6 +3,7 @@ package com.hnac.hzims.alarm.config.service; import com.hnac.hzims.alarm.entity.AlarmConfigDetailEntity; import com.hnac.hzims.alarm.entity.AlarmConfigEntity; import com.hnac.hzims.alarm.vo.AlarmConfigSourceVo; +import com.hnac.hzims.alarm.vo.AlarmHandleMarkVo; import org.springblade.core.mp.base.BaseService; import org.springblade.core.tool.api.R; @@ -21,4 +22,5 @@ public interface AlarmConfigDetailService extends BaseService { List exclude(Integer operate); + AlarmHandleMarkVo mark(String code,Integer source,Integer type); + boolean isSupport(String code,Integer source,Integer type,Integer operate); boolean add(AlarmConfigEntity entity); diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/impl/AlarmConfigDetailServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/impl/AlarmConfigDetailServiceImpl.java index 732edc8..6195487 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/impl/AlarmConfigDetailServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/impl/AlarmConfigDetailServiceImpl.java @@ -8,6 +8,8 @@ import com.hnac.hzims.alarm.entity.AlarmConfigDetailEntity; import com.hnac.hzims.alarm.entity.AlarmConfigEntity; import com.hnac.hzims.alarm.vo.AlarmConfigChildVo; import com.hnac.hzims.alarm.vo.AlarmConfigSourceVo; +import com.hnac.hzims.alarm.vo.AlarmHandleMarkVo; +import io.swagger.models.auth.In; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.log.exception.ServiceException; @@ -59,6 +61,106 @@ public class AlarmConfigDetailServiceImpl extends BaseServiceImpllambdaQuery() + .eq(AlarmConfigEntity::getStationId,code) + .eq(AlarmConfigEntity::getIsEnable,"0")); + if(ObjectUtil.isEmpty(config)){ + return detailService.defaultMark(source,type); + } + AlarmConfigDetailEntity detail = detailService.getOne(Wrappers.lambdaQuery() + .eq(AlarmConfigDetailEntity::getStrategyId,config.getId()) + .eq(AlarmConfigDetailEntity::getAlarmType,source) + .eq(AlarmConfigDetailEntity::getAlarmChiledType,type) + ); + if(ObjectUtil.isEmpty(config)){ + return detailService.defaultMark(source,type); + } + AlarmHandleMarkVo mark = new AlarmHandleMarkVo(); + mark.setIsRightTabulation(detail.getIsRightTabulation()); + mark.setIsBroadcast(detail.getIsBroadcast()); + mark.setIsMask(detail.getIsMask()); + mark.setIsPlatformMessage(detail.getIsPlatformMessage()); + mark.setIsShowAlert(detail.getIsShowAlert()); + mark.setIsSmallBell(detail.getIsSmallBell()); + mark.setIsShortMessage(detail.getIsShortMessage()); + mark.setIsWxMessage(detail.getIsWxMessage()); + return mark; + } + + /** + * 获取默认告警配置 + * @return + */ + private AlarmHandleMarkVo defaultMark() { + + return new AlarmHandleMarkVo(); + } + + /** * 是否支持操作 * @param code : 站点编码 * @param source : 告警来源 diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/QuqueConfig.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/QuqueConfig.java index 418df54..31c63b6 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/QuqueConfig.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/QuqueConfig.java @@ -14,32 +14,31 @@ import org.springframework.data.redis.listener.adapter.MessageListenerAdapter; */ public class QuqueConfig { + /** + * 创建连接工厂 + * + * @param connectionFactory + * @param adapter + * @return + */ + @Bean + public RedisMessageListenerContainer container(RedisConnectionFactory connectionFactory, + MessageListenerAdapter adapter) { + RedisMessageListenerContainer container = new RedisMessageListenerContainer(); + container.setConnectionFactory(connectionFactory); + //监听对应的channel + container.addMessageListener(adapter, new PatternTopic("alarmchannel")); + return container; + } - /** - * 创建连接工厂 - * - * @param connectionFactory - * @param adapter - * @return - */ - @Bean - public RedisMessageListenerContainer container(RedisConnectionFactory connectionFactory, - MessageListenerAdapter adapter) { - RedisMessageListenerContainer container = new RedisMessageListenerContainer(); - container.setConnectionFactory(connectionFactory); - //监听对应的channel - container.addMessageListener(adapter, new PatternTopic("alarmchannel")); - return container; - } - - /** - * 绑定消息监听者和接收监听的方法 - * @param message - * @return - */ - @Bean - public MessageListenerAdapter adapter(RedisMessageListener message) { - // onMessage 如果RedisMessage 中 没有实现接口,这个参数必须跟RedisMessage中的读取信息的方法名称一样 - return new MessageListenerAdapter(message, "onMessage"); - } + /** + * 绑定消息监听者和接收监听的方法 + * @param message + * @return + */ + @Bean + public MessageListenerAdapter adapter(RedisMessageListener message) { + // onMessage 如果RedisMessage 中 没有实现接口,这个参数必须跟RedisMessage中的读取信息的方法名称一样 + return new MessageListenerAdapter(message, "onMessage"); + } } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/AlarmSaveService.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/AlarmSaveService.java index 8bf2fa0..b903032 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/AlarmSaveService.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/AlarmSaveService.java @@ -1,8 +1,13 @@ package com.hnac.hzims.alarm.monitor.service; +import com.hnac.hzims.alarm.entity.AlarmEntity; + +import java.util.List; + /** * @author ysj */ public interface AlarmSaveService { + Boolean save(List alarms); } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java index 0472496..2725a9b 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java @@ -1,9 +1,25 @@ package com.hnac.hzims.alarm.monitor.service.impl; +import com.hnac.hzims.alarm.config.service.AlarmConfigService; +import com.hnac.hzims.alarm.entity.AlarmEntity; import com.hnac.hzims.alarm.monitor.service.AlarmSaveService; +import com.hnac.hzims.alarm.show.service.AlarmService; +import com.hnac.hzims.alarm.vo.AlarmHandleMarkVo; +import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.operational.station.feign.IStationClient; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.ObjectUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; + +import java.util.List; +import java.util.stream.Collectors; /** * @author ysj @@ -11,6 +27,66 @@ import org.springframework.stereotype.Service; @AllArgsConstructor @Service @Slf4j -public class AlarmSaveServiceImpl implements AlarmSaveService { +public class AlarmSaveServiceImpl implements AlarmSaveService { + + private final AlarmService alarmService; + + private final AlarmConfigService alarmConfigService; + + private final IStationClient stationClient; + + private final RedisTemplate redisTemplate; + + @GetMapping(value = "pub/{msg}") + public String pubMsg(@PathVariable String msg){ + + return msg; + } + + /** + * 告警数据保存 + * @param alarms + * @return + */ + @Override + public Boolean save(List alarms) { + + // 步骤1.查询告警数据对应站点 + R> result = stationClient.querySatationByCodes(alarms.stream().map(AlarmEntity::getStationId).collect(Collectors.toList())); + if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ + log.error("alarm query station is null : {}",alarms.stream().map(AlarmEntity::getAlarmId).collect(Collectors.toList())); + return false; + } + // 步骤2.遍历保存告警数据 + alarms.forEach(alarm->{ + + // 步骤3.根据站点查询配置标识 + AlarmHandleMarkVo mark = alarmConfigService.mark(alarm.getStationId(),alarm.getAlarmSource(),alarm.getAlarmType()); + if(ObjectUtil.isEmpty(mark)){ + log.error("alarm obtain mark is null : {}",alarm.getAlarmId()); + return; + } + + // 步骤4.告警处理标识赋值 + alarm.setIsRightTabulation(mark.getIsRightTabulation()); + alarm.setIsBroadcast(mark.getIsBroadcast()); + alarm.setIsMask(mark.getIsMask()); + alarm.setIsPlatformMessage(mark.getIsPlatformMessage()); + alarm.setIsShowAlert(mark.getIsShowAlert()); + alarm.setIsSmallBell(mark.getIsSmallBell()); + alarm.setIsShortMessage(mark.getIsShortMessage()); + alarm.setIsWxMessage(mark.getIsWxMessage()); + + // 步骤5.保存当日告警数据 + boolean isSave = alarmService.save(alarm); + if(!isSave){ + log.error("alarm save fail : {}",alarm.getAlarmId()); + return; + } + // 步骤6.发生数据至redis告警队列 + redisTemplate.convertAndSend("alarmchannel",alarm); + }); + return true; + } } \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationClient.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationClient.java index e96e54a..38f7a68 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationClient.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationClient.java @@ -128,9 +128,11 @@ public class StationClient implements IStationClient { return R.data(stationService.getOne(request)); } - - - + @Override + public R> querySatationByCodes(List codes) { + return R.data(stationService.list(Wrappers.lambdaQuery() + .in(StationEntity::getCode,codes))); + } @Override From f685f0c8a6bc9f42b020502a2bac9c2db2905f4e Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Fri, 10 Nov 2023 09:04:05 +0800 Subject: [PATCH 3/4] =?UTF-8?q?#=E5=91=8A=E8=AD=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/AlarmConfigDetailServiceImpl.java | 81 +++++++++++++++++----- .../service/impl/AlarmConfigServiceImpl.java | 9 --- .../alarm/monitor/listener/AlarmListener.java | 4 ++ .../monitor/service/AlarmMessageSendService.java | 9 +++ .../service/impl/AlarmMessageSendServiceImpl.java | 17 +++++ 5 files changed, 92 insertions(+), 28 deletions(-) create mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/AlarmMessageSendService.java create mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmMessageSendServiceImpl.java diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/impl/AlarmConfigDetailServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/impl/AlarmConfigDetailServiceImpl.java index 6195487..7a9c1e4 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/impl/AlarmConfigDetailServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/impl/AlarmConfigDetailServiceImpl.java @@ -93,14 +93,37 @@ public class AlarmConfigDetailServiceImpl extends BaseServiceImpl redisTemplate; @Override diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/AlarmMessageSendService.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/AlarmMessageSendService.java new file mode 100644 index 0000000..b15c9d2 --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/AlarmMessageSendService.java @@ -0,0 +1,9 @@ +package com.hnac.hzims.alarm.monitor.service; + +/** + * @author ysj + */ +public interface AlarmMessageSendService { + + +} \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmMessageSendServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmMessageSendServiceImpl.java new file mode 100644 index 0000000..9fa6149 --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmMessageSendServiceImpl.java @@ -0,0 +1,17 @@ +package com.hnac.hzims.alarm.monitor.service.impl; + +import com.hnac.hzims.alarm.monitor.service.AlarmMessageSendService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +/** + * @author ysj + */ +@AllArgsConstructor +@Service +@Slf4j +public class AlarmMessageSendServiceImpl implements AlarmMessageSendService { + + +} \ No newline at end of file From b3ec70c789ff1a64d230b96158d33148afcfc442 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Fri, 10 Nov 2023 10:08:43 +0800 Subject: [PATCH 4/4] =?UTF-8?q?#=E5=91=8A=E8=AD=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../monitor/controller/AlarmTestController.java | 36 ++++++++++++++++++++++ .../alarm/monitor/listener/AlarmListener.java | 2 +- .../monitor/service/impl/AlarmSaveServiceImpl.java | 2 +- 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/controller/AlarmTestController.java diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/controller/AlarmTestController.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/controller/AlarmTestController.java new file mode 100644 index 0000000..4a79188 --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/controller/AlarmTestController.java @@ -0,0 +1,36 @@ +package com.hnac.hzims.alarm.monitor.controller; + +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.alarm.entity.AlarmEntity; +import com.hnac.hzims.alarm.monitor.service.AlarmSaveService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * @author ysj + */ +@RestController +@AllArgsConstructor +@RequestMapping("/alarm/test") +@Api(value = "告警配置", tags = "告警配置") +public class AlarmTestController extends BladeController { + + private final AlarmSaveService alarmSaveService; + + @PostMapping("/save") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "新增告警", notes = "传入AlarmConfigEntity对象") + public R save(@RequestBody List entitys) { + return R.status(alarmSaveService.save(entitys)); + } + +} \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java index 24c9fb8..2e553a7 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java @@ -20,7 +20,7 @@ public class AlarmListener implements MessageListener { private AlarmMessageSendService alarmMessageSendService; @Autowired - private RedisTemplate redisTemplate; + private RedisTemplate redisTemplate; @Override public void onMessage(Message message, byte[] pattern) { diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java index 2725a9b..bb22640 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java @@ -35,7 +35,7 @@ public class AlarmSaveServiceImpl implements AlarmSaveService { private final IStationClient stationClient; - private final RedisTemplate redisTemplate; + private final RedisTemplate redisTemplate; @GetMapping(value = "pub/{msg}") public String pubMsg(@PathVariable String msg){