From 973fe5f096356b6efbf721e1b3fdbf3309a07b9f Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Fri, 15 Sep 2023 10:32:14 +0800 Subject: [PATCH 1/3] =?UTF-8?q?#poi=E7=89=88=E6=9C=AC=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E8=A7=A3=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hzims-service/operational/pom.xml | 23 ++++++++++++++++++++++ .../service/impl/RunMonthReportServiceImpl.java | 4 ++-- .../hnac/hzims/safeproduct/utils/ExcelUtil.java | 5 ----- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/hzims-service/operational/pom.xml b/hzims-service/operational/pom.xml index ea3b0b7..cc0dbf1 100644 --- a/hzims-service/operational/pom.xml +++ b/hzims-service/operational/pom.xml @@ -69,11 +69,34 @@ com.xuxueli xxl-job-core + + + + org.apache.poi + poi + 3.15 + + + org.apache.poi + poi-ooxml + 3.15 + org.apache.poi poi-ooxml-schemas 3.15 + + cn.afterturn + easypoi-base + 3.2.0 + + + cn.afterturn + easypoi-annotation + 3.2.0 + + org.apache.poi diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/RunMonthReportServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/RunMonthReportServiceImpl.java index 63c2194..d7add83 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/RunMonthReportServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/RunMonthReportServiceImpl.java @@ -815,8 +815,8 @@ public class RunMonthReportServiceImpl extends ServiceImpl Date: Sun, 17 Sep 2023 12:11:58 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E9=9B=86=E4=B8=AD=E7=9B=91=E6=8E=A7?= =?UTF-8?q?=E5=91=8A=E8=AD=A6=E6=B6=88=E6=81=AF=E5=A4=84=E7=90=86=E7=BB=93?= =?UTF-8?q?=E6=9E=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/hzims/alarm/vo/ConditionAlarmVo.java | 58 +++++++++++++++++ .../config/mapper/AlarmConfigDetailMapper.xml | 16 +++++ .../alarm/config/mapper/AlarmConfigMapper.xml | 23 +++++++ .../alarm/config/mapper/AlarmHistoryMapper.java | 12 ++++ .../alarm/config/mapper/AlarmHistoryMapper.xml | 5 ++ .../hzims/alarm/config/mapper/AlarmMapper.java | 12 ++++ .../hnac/hzims/alarm/config/mapper/AlarmMapper.xml | 5 ++ .../hnac/hzims/alarm/config/task/fdpAlarmTask.java | 33 ++++++++++ .../alarm/show/controller/ShowAlarmController.java | 13 +++- .../alarm/show/mapper/AlarmHistoryMapper.java | 12 ---- .../hnac/hzims/alarm/show/mapper/AlarmMapper.java | 12 ---- .../hzims/alarm/show/service/AlarmService.java | 7 +++ .../alarm/show/service/ConditionAlarmService.java | 6 +- .../hzims/alarm/show/service/FdpAlarmService.java | 6 +- .../alarm/show/service/LevelAlarmService.java | 6 +- .../alarm/show/service/SystemAlarmService.java | 6 +- .../show/service/impl/AlarmHistoryServiceImpl.java | 2 +- .../alarm/show/service/impl/AlarmServiceImpl.java | 42 ++++++++++++- .../service/impl/ConditionAlarmServiceImpl.java | 47 +++++++++++++- .../show/service/impl/FdpAlarmServiceImpl.java | 49 ++++----------- .../show/service/impl/LevelAlarmServiceImpl.java | 73 ++++++++++------------ .../show/service/impl/MessageServiceImpl.java | 7 ++- .../show/service/impl/SystemAlarmServiceImpl.java | 47 ++++---------- .../alarm/ws/condition/ConditionAlarmRegular.java | 6 +- .../ws/condition/ConditionAlarmWebSocket.java | 26 +++++--- .../hnac/hzims/alarm/ws/fdp/FdpAlarmRegular.java | 5 ++ .../hnac/hzims/alarm/ws/fdp/FdpAlarmWebSocket.java | 24 +++++-- .../hzims/alarm/ws/hz3000/SystemAlarmRegular.java | 3 + .../alarm/ws/hz3000/SystemAlarmWebSocket.java | 24 +++++-- .../hzims/alarm/ws/level/LevelAlarmWebSocket.java | 15 ++++- .../resources/mapper/AlarmConfigDetatilMapper.xml | 16 ----- .../main/resources/mapper/AlarmConfigMapper.xml | 23 ------- .../main/resources/mapper/AlarmHistoryMapper.xml | 5 -- .../src/main/resources/mapper/AlarmMapper.xml | 5 -- 34 files changed, 432 insertions(+), 219 deletions(-) create mode 100644 hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/ConditionAlarmVo.java create mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmConfigDetailMapper.xml create mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmConfigMapper.xml create mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmHistoryMapper.java create mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmHistoryMapper.xml create mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmMapper.java create mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmMapper.xml create mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/task/fdpAlarmTask.java delete mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmHistoryMapper.java delete mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmMapper.java delete mode 100644 hzims-service/hzims-alarm/src/main/resources/mapper/AlarmConfigDetatilMapper.xml delete mode 100644 hzims-service/hzims-alarm/src/main/resources/mapper/AlarmConfigMapper.xml delete mode 100644 hzims-service/hzims-alarm/src/main/resources/mapper/AlarmHistoryMapper.xml delete mode 100644 hzims-service/hzims-alarm/src/main/resources/mapper/AlarmMapper.xml diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/ConditionAlarmVo.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/ConditionAlarmVo.java new file mode 100644 index 0000000..ed79389 --- /dev/null +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/ConditionAlarmVo.java @@ -0,0 +1,58 @@ +package com.hnac.hzims.alarm.vo; + +import io.swagger.annotations.ApiModel; +import lombok.Data; + +import java.util.Date; + + +/** + * @author ty + */ +@Data +@ApiModel(value = "条件预警对象", description = "条件预警对象") +public class ConditionAlarmVo { + //todo + + private static final long serialVersionUID = 1L; + /** + * 故障ID + */ + private String faultId; + /** + * 故障站点 + */ + private String station; + /** + * 故障名称 + */ + private String name; + /** + * 位置 + */ + private String ord; + /** + * 故障状态 + */ + private Float status; + /** + * 故障的附属信息 + */ + private String info; + /** + * 报警类型 + */ + private String ftype; + /** + * 报警内容 + */ + private String finfo; + /** + * 报警内容 + */ + private Object[] children; + /** + * 创建时间 + */ + private Date createTime; +} \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmConfigDetailMapper.xml b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmConfigDetailMapper.xml new file mode 100644 index 0000000..d29dafa --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmConfigDetailMapper.xml @@ -0,0 +1,16 @@ + + + + + + diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmConfigMapper.xml b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmConfigMapper.xml new file mode 100644 index 0000000..7692ae7 --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmConfigMapper.xml @@ -0,0 +1,23 @@ + + + + + + diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmHistoryMapper.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmHistoryMapper.java new file mode 100644 index 0000000..74194c3 --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmHistoryMapper.java @@ -0,0 +1,12 @@ +package com.hnac.hzims.alarm.config.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.alarm.entity.AlarmHistoryEntity; + +/** + * @author ysj + */ +public interface AlarmHistoryMapper extends BaseMapper { + + +} diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmHistoryMapper.xml b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmHistoryMapper.xml new file mode 100644 index 0000000..8b355d0 --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmHistoryMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmMapper.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmMapper.java new file mode 100644 index 0000000..455f550 --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmMapper.java @@ -0,0 +1,12 @@ +package com.hnac.hzims.alarm.config.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.alarm.entity.AlarmEntity; + +/** + * @author ysj + */ +public interface AlarmMapper extends BaseMapper { + + +} diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmMapper.xml b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmMapper.xml new file mode 100644 index 0000000..4a83fce --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/mapper/AlarmMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/task/fdpAlarmTask.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/task/fdpAlarmTask.java new file mode 100644 index 0000000..1d7e51a --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/task/fdpAlarmTask.java @@ -0,0 +1,33 @@ +package com.hnac.hzims.alarm.config.task; + +// +//@Slf4j +//@Component +//@RequiredArgsConstructor +//public class fdpAlarmTask { +// +// private final IUserClient userClient; +// +// private final IStationClient stationClient; +// @Value("${url.getAutoFault}") +// public String autoFaultPath; +// +// @XxlJob(PERSONAL_MONTH_REPORT) +// public ReturnT execute(String param) throws IOException { +// log.info("----FDP智能预警查询----",param); +// R> listAll = stationClient.getListAll(); +// if (!listAll.isSuccess()||CollectionUtil.isEmpty(listAll.getData())){ +// log.error("FDP智能预警查询失败:无站点数据",listAll); +// } +// List stations = listAll.getData(); +// Map paramMap = new HashMap<>(); +// paramMap.put("stationIds",stations); +// String result = HttpRequestUtil.postCall(paramMap, autoFaultPath, "POST"); +// if (StringUtil.isBlank(result)){ +// return null; +// } +// JSONObject.parseObject(result).get("data").toString(); +// log.info("----FDP智能预警查询----",param); +// return new ReturnT<>("SUCCESS"); +// } +//} 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 0efe96e..c1b113c 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 @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.alarm.entity.AlarmEntity; import com.hnac.hzims.alarm.show.service.AlarmService; +import com.hnac.hzims.alarm.show.service.SystemAlarmService; import com.hnac.hzims.alarm.vo.AlarmCountVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -15,6 +16,7 @@ import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; @@ -31,7 +33,9 @@ import java.util.Map; @Api(value = "告警配置", tags = "告警配置") public class ShowAlarmController extends BladeController { - private final AlarmService alarmService; + @Autowired + private AlarmService alarmService; + private SystemAlarmService systemAlarmService; @PostMapping("/alarms") @ApiOperationSupport(order = 1) @@ -87,6 +91,13 @@ public class ShowAlarmController extends BladeController { AlarmEntity detail = alarmService.getOne(Condition.getQueryWrapper(entity)); return R.data(detail); } + @PostMapping("/test") + @ApiOperationSupport(order = 5) + @ApiOperation(value = "详情", notes = "传入em_model_param") + public R test(@RequestBody String param) { + systemAlarmService.receiveMessage(param); + return R.success("结束"); + } } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmHistoryMapper.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmHistoryMapper.java deleted file mode 100644 index 5745262..0000000 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmHistoryMapper.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.hnac.hzims.alarm.show.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.hnac.hzims.alarm.entity.AlarmHistoryEntity; - -/** - * @author ysj - */ -public interface AlarmHistoryMapper extends BaseMapper { - - -} diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmMapper.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmMapper.java deleted file mode 100644 index 7e9d343..0000000 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmMapper.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.hnac.hzims.alarm.show.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.hnac.hzims.alarm.entity.AlarmEntity; - -/** - * @author ysj - */ -public interface AlarmMapper extends BaseMapper { - - -} diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java index 2f2ed5e..be1c599 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java @@ -15,4 +15,11 @@ public interface AlarmService extends BaseService { IPage alarms(AlarmEntity alarm, IPage page); List counts(); + + /** + * websocket 消息推送保存 + * @param param + */ + void dealAlarmEntities(List param); + } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/ConditionAlarmService.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/ConditionAlarmService.java index d79f7f9..0b1544d 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/ConditionAlarmService.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/ConditionAlarmService.java @@ -1,5 +1,9 @@ package com.hnac.hzims.alarm.show.service; +import com.hnac.hzims.alarm.entity.AlarmEntity; + +import java.util.List; + /** * 等级处理接口 * @author ysj @@ -8,5 +12,5 @@ public interface ConditionAlarmService { String message(); - void receive(String message); + List receiveMessage(String message); } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/FdpAlarmService.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/FdpAlarmService.java index 8015ac3..cafb946 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/FdpAlarmService.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/FdpAlarmService.java @@ -1,5 +1,9 @@ package com.hnac.hzims.alarm.show.service; +import com.hnac.hzims.alarm.entity.AlarmEntity; + +import java.util.List; + /** * 告警处理接口 * @author ysj @@ -8,5 +12,5 @@ public interface FdpAlarmService { String sendMessage(); - void receiveMessage(String message); + List receiveMessage(String message); } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/LevelAlarmService.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/LevelAlarmService.java index 01696b8..bf2c3a3 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/LevelAlarmService.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/LevelAlarmService.java @@ -1,5 +1,9 @@ package com.hnac.hzims.alarm.show.service; +import com.hnac.hzims.alarm.entity.AlarmEntity; + +import java.util.List; + /** * 等级处理接口 * @author ysj @@ -8,5 +12,5 @@ public interface LevelAlarmService { String message(); - void receive(String message); + List receiveMessage(String message); } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/SystemAlarmService.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/SystemAlarmService.java index 7f0cff4..6dc2969 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/SystemAlarmService.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/SystemAlarmService.java @@ -1,5 +1,9 @@ package com.hnac.hzims.alarm.show.service; +import com.hnac.hzims.alarm.entity.AlarmEntity; + +import java.util.List; + /** * 告警处理接口 * @author ysj @@ -8,5 +12,5 @@ public interface SystemAlarmService { String sendMessage(); - void receiveMessage(String message); + List receiveMessage(String message); } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHistoryServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHistoryServiceImpl.java index 166a41f..b2ae4af 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHistoryServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHistoryServiceImpl.java @@ -1,7 +1,7 @@ package com.hnac.hzims.alarm.show.service.impl; import com.hnac.hzims.alarm.entity.AlarmHistoryEntity; -import com.hnac.hzims.alarm.show.mapper.AlarmHistoryMapper; +import com.hnac.hzims.alarm.config.mapper.AlarmHistoryMapper; import com.hnac.hzims.alarm.show.service.AlarmHistoryService; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java index c5df876..6816733 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java @@ -2,23 +2,28 @@ package com.hnac.hzims.alarm.show.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hnac.hzims.alarm.config.mapper.AlarmMapper; import com.hnac.hzims.alarm.config.service.AlarmConfigService; import com.hnac.hzims.alarm.constants.AlarmConstants; import com.hnac.hzims.alarm.entity.AlarmEntity; -import com.hnac.hzims.alarm.show.mapper.AlarmMapper; import com.hnac.hzims.alarm.show.service.AlarmService; +import com.hnac.hzims.alarm.show.service.MessageService; import com.hnac.hzims.alarm.vo.AlarmCountVo; import com.hnac.hzims.alarm.vo.ChildAlarmCountVo; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.StringUtil; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.Collections; +import java.util.Date; import java.util.List; +import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; /** @@ -30,6 +35,7 @@ import java.util.stream.Collectors; public class AlarmServiceImpl extends BaseServiceImpl implements AlarmService { private final AlarmConfigService configService; + private final MessageService messageService; /** * 查询告警列表 @@ -90,6 +96,40 @@ public class AlarmServiceImpl extends BaseServiceImpl }).collect(Collectors.toList()); } + /** + * websocket 消息推送保存 + * @param param + */ + @Override + public void dealAlarmEntities(List param) { + if (CollectionUtil.isNotEmpty(param)) { + // 查询当天已经记录的告警 + List historys = this.list(Wrappers.lambdaQuery(). + ge(AlarmEntity::getCreateTime, DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00") + .eq(AlarmEntity::getAlarmSource, param.get(0).getAlarmSource())); + + // 数据过滤 + List entitys = param.stream() + .filter(alarm -> CollectionUtil.isNotEmpty(historys) || !historys.stream().map(AlarmEntity::getAlarmId).collect(Collectors.toList()).contains(alarm.getAlarmId())) + .map(item -> { + //消息推送 + // 短信 + CompletableFuture.runAsync(() -> messageService.message(item)); + // web/app消息推送 + CompletableFuture.runAsync(() -> messageService.webAppMessage(item)); + // 微信公众号推送 + CompletableFuture.runAsync(() -> messageService.weChatMessage(item)); + return item; + }).collect(Collectors.toList()); + if (CollectionUtil.isEmpty(entitys)) { + return; + } + // 批量保存 + this.saveBatch(entitys); + } + } + + /** * 子类型数量集合 diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/ConditionAlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/ConditionAlarmServiceImpl.java index 6f763da..3409174 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/ConditionAlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/ConditionAlarmServiceImpl.java @@ -1,15 +1,29 @@ package com.hnac.hzims.alarm.show.service.impl; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import com.hnac.hzims.alarm.entity.AlarmEntity; import com.hnac.hzims.alarm.show.service.AlarmService; import com.hnac.hzims.alarm.show.service.ConditionAlarmService; import com.hnac.hzims.alarm.show.service.MessageService; +import com.hnac.hzims.alarm.vo.ConditionAlarmVo; import com.hnac.hzims.equipment.feign.IEmInfoClient; +import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.feign.IStationClient; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.CollectionUtil; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import static com.hnac.hzims.alarm.constants.AlarmConstants.EARLY; +import static com.hnac.hzims.alarm.constants.AlarmConstants.EARLY_WARNING; + /** * 等级告警实现类 * @author ysj @@ -40,11 +54,40 @@ public class ConditionAlarmServiceImpl implements ConditionAlarmService { return ""; } + /** - * 处理websocket消息 + * 转换接收服务推送消息 * @param message */ @Override - public void receive(String message) { + public List receiveMessage(String message) { + // 对象转换 + List alarms = JSONObject.parseArray(message, ConditionAlarmVo.class); + if (CollectionUtil.isEmpty(alarms)) { + return new ArrayList<>(); + } + List res = alarms.stream().map(s -> { + AlarmEntity entity = getAlarmEntity(s); + return entity; + }).collect(Collectors.toList()); + return res; + } + + private AlarmEntity getAlarmEntity(ConditionAlarmVo item) { + AlarmEntity entity = new AlarmEntity(); + entity.setAlarmId(item.getFaultId()); + entity.setAlarmTime(item.getCreateTime()); + entity.setAlarmContext(item.getFinfo()); + entity.setAlarmType(EARLY); + entity.setAlarmStatus(Integer.valueOf(String.valueOf(item.getStatus()))); + entity.setStationId(item.getStation()); + entity.setAlarmStatus(EARLY_WARNING); + entity.setTenantId("200000"); + R stationByCode = stationClient.getStationByCode(item.getStation()); + if (stationByCode.isSuccess()&& ObjectUtils.isNotEmpty(stationByCode.getData())){ + entity.setCreateDept(stationByCode.getData().getCreateDept()); + entity.setStationName(stationByCode.getData().getName()); + } + return entity; } } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/FdpAlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/FdpAlarmServiceImpl.java index b51eded..7914954 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/FdpAlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/FdpAlarmServiceImpl.java @@ -2,7 +2,6 @@ package com.hnac.hzims.alarm.show.service.impl; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hnac.hzims.alarm.entity.AlarmEntity; import com.hnac.hzims.alarm.show.service.AlarmService; import com.hnac.hzims.alarm.show.service.FdpAlarmService; @@ -16,15 +15,13 @@ import lombok.extern.slf4j.Slf4j; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.CollectionUtil; -import org.springblade.core.tool.utils.DateUtil; import org.springblade.system.feign.ISysClient; import org.springblade.system.user.feign.IUserClient; import org.springframework.stereotype.Service; -import java.util.Date; +import java.util.ArrayList; import java.util.List; import java.util.Map; -import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; @@ -64,50 +61,25 @@ public class FdpAlarmServiceImpl implements FdpAlarmService { return JSONObject.toJSONString(map); } - /** - * 接收服务推送消息 + * 转换接收服务推送消息 * @param message */ @Override - public void receiveMessage(String message) { + public List receiveMessage(String message) { // 对象转换 List alarms = JSONObject.parseArray(message, FdpAlarmVo.class); - if(CollectionUtil.isEmpty(alarms)){ - return; + if (CollectionUtil.isEmpty(alarms)) { + return new ArrayList<>(); } -// R> listAll = stationClient.getListAll(); -// if (!listAll.isSuccess()||CollectionUtil.isEmpty(listAll.getData())){ -// throw new ServiceException("FdpAlarm send message is null"); -// } -// List stations = listAll.getData(); - // 查询当天已经记录的告警 - List historys = alarmService.list(Wrappers.lambdaQuery(). - ge(AlarmEntity::getCreateTime, DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00") - .eq(AlarmEntity::getAlarmSource, EARLY_WARNING)); - - // 数据过滤 - List entitys = alarms.stream() - .filter(alarm -> CollectionUtil.isNotEmpty(historys) || !historys.stream().map(AlarmEntity::getAlarmId).collect(Collectors.toList()).contains(alarm.getFaultId())) - .map(item->{ - //转换对象 - AlarmEntity entity = getAlarmEntity(item); - // 短信 - CompletableFuture.runAsync(() -> messageService.message(entity)); - // web/app消息推送 - CompletableFuture.runAsync(() -> messageService.webAppMessage(entity)); - // 微信公众号推送 - CompletableFuture.runAsync(() -> messageService.weChatMessage(entity)); + List res = alarms.stream().map(s -> { + AlarmEntity entity = getAlarmEntity(s); return entity; }).collect(Collectors.toList()); - if(CollectionUtil.isEmpty(entitys)){ - return; - } - // 批量保存 - alarmService.saveBatch(entitys); + return res; } - private AlarmEntity getAlarmEntity(FdpAlarmVo item) { + private AlarmEntity getAlarmEntity(FdpAlarmVo item) { AlarmEntity entity = new AlarmEntity(); entity.setAlarmId(item.getFaultId()); entity.setAlarmTime(item.getCreateTime()); @@ -116,10 +88,13 @@ public class FdpAlarmServiceImpl implements FdpAlarmService { entity.setAlarmStatus(Integer.valueOf(String.valueOf(item.getStatus()))); entity.setStationId(item.getStation()); entity.setAlarmStatus(EARLY_WARNING); + entity.setTenantId("200000"); R stationByCode = stationClient.getStationByCode(item.getStation()); if (stationByCode.isSuccess()&& ObjectUtils.isNotEmpty(stationByCode.getData())){ entity.setCreateDept(stationByCode.getData().getCreateDept()); + entity.setStationName(stationByCode.getData().getName()); } return entity; } + } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/LevelAlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/LevelAlarmServiceImpl.java index 28412d3..f8ad2cd 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/LevelAlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/LevelAlarmServiceImpl.java @@ -2,7 +2,6 @@ package com.hnac.hzims.alarm.show.service.impl; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hnac.hzims.alarm.constants.AlarmConstants; import com.hnac.hzims.alarm.entity.AlarmEntity; import com.hnac.hzims.alarm.show.service.AlarmService; @@ -22,9 +21,9 @@ import org.springblade.core.tool.utils.DateUtil; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.Date; import java.util.List; -import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; /** @@ -70,48 +69,42 @@ public class LevelAlarmServiceImpl implements LevelAlarmService { } /** - * 处理websocket消息 + * 转换接收服务推送消息 * @param message */ @Override - public void receive(String message) { + public List receiveMessage(String message) { // 对象转换 - List levels = JSONObject.parseArray(message,LevelVo.class); - if(CollectionUtil.isEmpty(levels)){ - return; + List alarms = JSONObject.parseArray(message, LevelVo.class); + if (CollectionUtil.isEmpty(alarms)) { + return new ArrayList<>(); } - // 设备 + List res = alarms.stream().map(s -> { + AlarmEntity entity = getAlarmEntity(s); + return entity; + }).collect(Collectors.toList()); + return res; + } + + private AlarmEntity getAlarmEntity(LevelVo level) { List devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_cofig_final).toString(),new TypeReference>() {}); - // 查询已经保存等级告警数据 - List records = alarmService.list(Wrappers.lambdaQuery() - .ge(AlarmEntity::getAlarmSource,AlarmConstants.LEVEL_ALARM) - .in(AlarmEntity::getAlarmId,levels.stream().map(LevelVo::getId).collect(Collectors.toList())) - ); - // 遍历等级告警数据 - levels.stream().filter(o-> CollectionUtil.isEmpty(records) || !records.stream().map(AlarmEntity::getAlarmId).collect(Collectors.toList()).contains(o.getId())). - forEach(level->{ - AlarmEntity entity = new AlarmEntity(); - entity.setAlarmSource(AlarmConstants.LEVEL_ALARM); - entity.setAlarmId(level.getId()); - entity.setAlarmTime(DateUtil.parse(level.getTs(), "yyyy-MM-dd HH:mm:ss.s")); - entity.setAlarmType(level.getType()); - entity.setRealId(level.getSignage()); - entity.setAlarmContext(level.getName()); - entity.setDeviceCode(level.getDevicecode()); - entity.setDeviceName(level.getDevicename()); - entity.setAlarmLevel(level.getLevel()); - List ems = devices.stream().filter(o->level.getDevicecode().equals(o.getEmCode())).collect(Collectors.toList()); - if(CollectionUtil.isNotEmpty(ems)){ - entity.setStationId(ems.get(0).getStationCode()); - entity.setDeviceName(ems.get(0).getStationName()); - } - this.alarmService.save(entity); - // 短信 - CompletableFuture.runAsync(() -> this.messageService.message(entity)); - // web/app消息推送 - CompletableFuture.runAsync(() -> this.messageService.webAppMessage(entity)); - // 微信公众号推送 - CompletableFuture.runAsync(() -> this.messageService.weChatMessage(entity)); - }); - } + AlarmEntity entity = new AlarmEntity(); + entity.setAlarmSource(AlarmConstants.LEVEL_ALARM); + entity.setAlarmId(level.getId()); + entity.setAlarmTime(DateUtil.parse(level.getTs(), "yyyy-MM-dd HH:mm:ss.s")); + entity.setAlarmType(level.getType()); + entity.setRealId(level.getSignage()); + entity.setAlarmContext(level.getName()); + entity.setDeviceCode(level.getDevicecode()); + entity.setDeviceName(level.getDevicename()); + entity.setAlarmLevel(level.getLevel()); + List ems = devices.stream().filter(o->level.getDevicecode().equals(o.getEmCode())).collect(Collectors.toList()); + if(CollectionUtil.isNotEmpty(ems)){ + entity.setStationId(ems.get(0).getStationCode()); + entity.setDeviceName(ems.get(0).getStationName()); + } + return entity; + } + + } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/MessageServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/MessageServiceImpl.java index 099d953..765dbeb 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/MessageServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/MessageServiceImpl.java @@ -10,7 +10,7 @@ import com.hnac.hzims.message.dto.BusinessMessageDTO; import com.hnac.hzims.message.fegin.IMessageClient; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.feign.IStationClient; -import lombok.RequiredArgsConstructor; +import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.CollectionUtil; @@ -28,7 +28,7 @@ import java.util.stream.Collectors; */ @Slf4j @Service -@RequiredArgsConstructor +@AllArgsConstructor public class MessageServiceImpl implements MessageService { private final ISysClient sysClient; private final IStationClient stationClient; @@ -68,7 +68,8 @@ public class MessageServiceImpl implements MessageService { message.setBusinessClassify("warning"); message.setBusinessKey(MessageConstants.BusinessClassifyEnum.WARNING.getKey()); message.setSubject(MessageConstants.BusinessClassifyEnum.WARNING.getDescription()); - message.setTaskId(entity.getId()); +// todo +// message.setTaskId(entity.getAlarmId()); message.setTenantId("200000"); message.setContent(entity.getAlarmContext()); message.setDeptId(dept); diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/SystemAlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/SystemAlarmServiceImpl.java index 2c553cc..9f878fb 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/SystemAlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/SystemAlarmServiceImpl.java @@ -2,7 +2,6 @@ package com.hnac.hzims.alarm.show.service.impl; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hnac.hzims.alarm.constants.AlarmConstants; import com.hnac.hzims.alarm.entity.AlarmEntity; import com.hnac.hzims.alarm.show.service.AlarmService; @@ -23,10 +22,9 @@ import org.springblade.system.feign.ISysClient; import org.springblade.system.user.feign.IUserClient; import org.springframework.stereotype.Service; -import java.util.Date; +import java.util.ArrayList; import java.util.List; import java.util.Map; -import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; @@ -69,46 +67,21 @@ public class SystemAlarmServiceImpl implements SystemAlarmService { /** - * 接收服务推送消息 + * 转换接收服务推送消息 * @param message */ @Override - public void receiveMessage(String message) { + public List receiveMessage(String message) { // 对象转换 List alarms = JSONObject.parseArray(message, SystemAlarmVo.class); if (CollectionUtil.isEmpty(alarms)) { - return; + return new ArrayList<>(); } -// -// R> listAll = stationClient.getListAll(); -// if (!listAll.isSuccess() || CollectionUtil.isEmpty(listAll.getData())) { -// throw new ServiceException("systemAlarm send message is null"); -// } -// List stations = listAll.getData(); - // 查询当天已经记录的告警 - List historys = alarmService.list(Wrappers.lambdaQuery(). - ge(AlarmEntity::getCreateTime, DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00") - .eq(AlarmEntity::getAlarmSource, AlarmConstants.HZ3000_ALARM)); - // 数据过滤 - List entitys = alarms.stream() - .filter(alarm -> CollectionUtil.isNotEmpty(historys) || !historys.stream().map(AlarmEntity::getAlarmId).collect(Collectors.toList()).contains(alarm.getId())) - .map(item -> { - AlarmEntity entity = getAlarmEntity(item); - if (ObjectUtils.isNotEmpty(entity)){ - // 短信 - CompletableFuture.runAsync(() -> messageService.message(entity)); - // web/app消息推送 - CompletableFuture.runAsync(() -> messageService.webAppMessage(entity)); - // 微信公众号推送 - CompletableFuture.runAsync(() -> messageService.weChatMessage(entity)); - } - return entity; - }).collect(Collectors.toList()); - if (CollectionUtil.isEmpty(entitys)) { - return; - } - // 批量保存 - alarmService.saveBatch(entitys); + List res = alarms.stream().map(s -> { + AlarmEntity entity = getAlarmEntity(s); + return entity; + }).collect(Collectors.toList()); + return res; } private AlarmEntity getAlarmEntity(SystemAlarmVo item) { @@ -121,9 +94,11 @@ public class SystemAlarmServiceImpl implements SystemAlarmService { entity.setAlarmValue(item.getOptionvals()); entity.setStationId(item.getStation()); entity.setAlarmSource(AlarmConstants.HZ3000_ALARM); + entity.setTenantId("200000"); R stationByCode = stationClient.getStationByCode(item.getStation()); if (stationByCode.isSuccess() && ObjectUtils.isNotEmpty(stationByCode.getData())) { entity.setCreateDept(stationByCode.getData().getCreateDept()); + entity.setStationName(stationByCode.getData().getName()); } return entity; } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/condition/ConditionAlarmRegular.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/condition/ConditionAlarmRegular.java index 3d98a08..18d9059 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/condition/ConditionAlarmRegular.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/condition/ConditionAlarmRegular.java @@ -42,9 +42,9 @@ public class ConditionAlarmRegular { socket.send(message); } } - log.error("level websocket survival check : {}","重新建立链接"); + log.error("conditionAlarm survival check : {}","重新建立链接"); }else{ - log.error("level websocket survival check : {}","存活"); + log.error("conditionAlarm survival check : {}","存活"); } } @@ -54,7 +54,7 @@ public class ConditionAlarmRegular { socket = new LevelAlarmWebSocket(new URI(condition_wss_url)); socket.connectBlocking(); }catch (Exception e){ - log.error("level create error : {}",e.getMessage()); + log.error("conditionAlarm create error : {}",e.getMessage()); } } } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/condition/ConditionAlarmWebSocket.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/condition/ConditionAlarmWebSocket.java index 29183f6..f619d8b 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/condition/ConditionAlarmWebSocket.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/condition/ConditionAlarmWebSocket.java @@ -1,10 +1,12 @@ package com.hnac.hzims.alarm.ws.condition; +import com.hnac.hzims.alarm.entity.AlarmEntity; +import com.hnac.hzims.alarm.show.service.AlarmService; import com.hnac.hzims.alarm.show.service.ConditionAlarmService; -import com.hnac.hzims.alarm.show.service.LevelAlarmService; import lombok.extern.slf4j.Slf4j; import org.java_websocket.client.WebSocketClient; import org.java_websocket.handshake.ServerHandshake; +import org.springblade.core.log.exception.ServiceException; import org.springblade.core.tool.utils.SpringUtil; import org.springblade.core.tool.utils.StringUtil; @@ -15,6 +17,7 @@ import java.net.Socket; import java.net.URI; import java.security.SecureRandom; import java.security.cert.X509Certificate; +import java.util.List; import java.util.Optional; /** @@ -25,6 +28,7 @@ public class ConditionAlarmWebSocket extends WebSocketClient { private final ConditionAlarmService conditionService; + private AlarmService alarmService; /** * 构造等级告警websocket @@ -39,30 +43,36 @@ public class ConditionAlarmWebSocket extends WebSocketClient { // 链接到服务器回调接口 @Override public void onOpen(ServerHandshake handshakedata) { - log.error("systemAlarm websocket open"); + log.error("conditionAlarm websocket open"); } // 接收到服务器消息回调接口 @Override public void onMessage(String message) { if(StringUtil.isEmpty(message)){ - log.error("level alarm on message is null"); + log.error("conditionAlarm on message is null"); }else{ + // 告警数据转化 + List alarmEntities = conditionService.receiveMessage(message); // 等级告警数据处理 - conditionService.receive(message); + try { + alarmService.dealAlarmEntities(alarmEntities); + }catch (Exception e){ + throw new ServiceException("集中监控告警数据处理报错(conditionAlarm):"+e); + } } } // 与服务器链接中断回调接口 @Override public void onClose(int code, String reason, boolean remote) { - log.error("level alarm websocket close"); + log.error("conditionAlarm websocket close"); } // 与服务器通讯异常触发 @Override public void onError(Exception e) { - log.error("level alarm websocket error : {}",e.getMessage()); + log.error("conditionAlarm websocket error : {}",e.getMessage()); } /** @@ -89,7 +99,7 @@ public class ConditionAlarmWebSocket extends WebSocketClient { try{ socket = context.getSocketFactory().createSocket(); }catch (Exception e){ - log.error("level alarm socket create error : {}",e.getMessage()); + log.error("conditionAlarm socket create error : {}",e.getMessage()); } return socket; } @@ -118,7 +128,7 @@ public class ConditionAlarmWebSocket extends WebSocketClient { } }}, new SecureRandom()); }catch (Exception e){ - log.error("level alarm SSL init error : {}",e.getMessage()); + log.error("conditionAlarm SSL init error : {}",e.getMessage()); } return SSL; } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/fdp/FdpAlarmRegular.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/fdp/FdpAlarmRegular.java index cff203f..63e9814 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/fdp/FdpAlarmRegular.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/fdp/FdpAlarmRegular.java @@ -31,11 +31,15 @@ public class FdpAlarmRegular { // 定时发送消息 @Scheduled(cron = "0 0/30 * * * ?") private void regular(){ + System.out.println("系统告警链接检查"); // 检查链接存活状态 if(ObjectUtil.isNotEmpty(client) && client.isOpen()){ client.send(fdpAlarmService.sendMessage()); + System.out.println("FdpAlarm:链接成功"); }else { + System.out.println("FdpAlarm:链接失败"); this.createClient(); + System.out.println("FdpAlarm:重新链接"); } } @@ -44,6 +48,7 @@ public class FdpAlarmRegular { try{ client = new FdpAlarmWebSocket(new URI(fdp_alarm_url)); client.connectBlocking(); + System.out.println("FdpAlarm create success"); }catch (Exception e){ log.error("FdpAlarm create error : {}",e.getMessage()); } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/fdp/FdpAlarmWebSocket.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/fdp/FdpAlarmWebSocket.java index 319a3b5..6e514e0 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/fdp/FdpAlarmWebSocket.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/fdp/FdpAlarmWebSocket.java @@ -1,11 +1,15 @@ package com.hnac.hzims.alarm.ws.fdp; -import com.hnac.hzims.alarm.show.service.SystemAlarmService; +import com.hnac.hzims.alarm.entity.AlarmEntity; +import com.hnac.hzims.alarm.show.service.AlarmService; +import com.hnac.hzims.alarm.show.service.FdpAlarmService; import lombok.extern.slf4j.Slf4j; import org.java_websocket.client.WebSocketClient; import org.java_websocket.handshake.ServerHandshake; +import org.springblade.core.log.exception.ServiceException; import org.springblade.core.tool.utils.SpringUtil; import org.springblade.core.tool.utils.StringUtil; +import org.springframework.beans.factory.annotation.Autowired; import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManager; @@ -14,6 +18,7 @@ import java.net.Socket; import java.net.URI; import java.security.SecureRandom; import java.security.cert.X509Certificate; +import java.util.List; import java.util.Optional; /** @@ -22,8 +27,9 @@ import java.util.Optional; */ @Slf4j public class FdpAlarmWebSocket extends WebSocketClient { - - private final SystemAlarmService systemAlarmService; + @Autowired + private FdpAlarmService fdpAlarmService; + private AlarmService alarmService; /** * 构造等级告警websocket @@ -31,7 +37,7 @@ public class FdpAlarmWebSocket extends WebSocketClient { */ public FdpAlarmWebSocket(URI uri) { super(uri); - systemAlarmService = SpringUtil.getBean(SystemAlarmService.class); + fdpAlarmService = SpringUtil.getBean(FdpAlarmService.class); connection(this); } @@ -47,8 +53,16 @@ public class FdpAlarmWebSocket extends WebSocketClient { if(StringUtil.isEmpty(message)){ log.error("FdpAlarm on message is null"); }else{ + // 告警数据转化 + List alarmEntities = fdpAlarmService.receiveMessage(message); + //统一数据处理 + try { + alarmService.dealAlarmEntities(alarmEntities); + }catch (Exception e){ + throw new ServiceException("集中监控告警数据处理报错(FdpAlarm):"+e); + } // 等级告警数据处理 - systemAlarmService.receiveMessage(message); + fdpAlarmService.receiveMessage(message); } } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/hz3000/SystemAlarmRegular.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/hz3000/SystemAlarmRegular.java index 2338dd1..06b84f2 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/hz3000/SystemAlarmRegular.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/hz3000/SystemAlarmRegular.java @@ -34,7 +34,9 @@ public class SystemAlarmRegular { // 检查链接存活状态 if(ObjectUtil.isNotEmpty(client) && client.isOpen()){ client.send(systemAlarmService.sendMessage()); + System.out.println("systemAlarm:存活"); }else { + System.out.println("systemAlarm:链接失败"); this.createClient(); } } @@ -44,6 +46,7 @@ public class SystemAlarmRegular { try{ client = new SystemAlarmWebSocket(new URI(system_wss_url)); client.connectBlocking(); + System.out.println("systemAlarm create success"); }catch (Exception e){ log.error("systemAlarm create error : {}",e.getMessage()); } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/hz3000/SystemAlarmWebSocket.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/hz3000/SystemAlarmWebSocket.java index 83da5d4..e4b6c41 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/hz3000/SystemAlarmWebSocket.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/hz3000/SystemAlarmWebSocket.java @@ -1,9 +1,12 @@ package com.hnac.hzims.alarm.ws.hz3000; +import com.hnac.hzims.alarm.entity.AlarmEntity; +import com.hnac.hzims.alarm.show.service.AlarmService; import com.hnac.hzims.alarm.show.service.SystemAlarmService; import lombok.extern.slf4j.Slf4j; import org.java_websocket.client.WebSocketClient; import org.java_websocket.handshake.ServerHandshake; +import org.springblade.core.log.exception.ServiceException; import org.springblade.core.tool.utils.SpringUtil; import org.springblade.core.tool.utils.StringUtil; @@ -14,6 +17,7 @@ import java.net.Socket; import java.net.URI; import java.security.SecureRandom; import java.security.cert.X509Certificate; +import java.util.List; import java.util.Optional; /** @@ -25,6 +29,8 @@ public class SystemAlarmWebSocket extends WebSocketClient { private final SystemAlarmService systemAlarmService; + private AlarmService alarmService; + /** * 构造等级告警websocket * @param uri @@ -38,7 +44,7 @@ public class SystemAlarmWebSocket extends WebSocketClient { // 链接到服务器回调接口 @Override public void onOpen(ServerHandshake handshakedata) { - log.error("systemAlarm websocket open"); + log.error("SystemAlarmWebSocket链接到服务器回调接口"); } // 接收到服务器消息回调接口 @@ -47,15 +53,22 @@ public class SystemAlarmWebSocket extends WebSocketClient { if(StringUtil.isEmpty(message)){ log.error("systemAlarm on message is null"); }else{ - // 等级告警数据处理 - systemAlarmService.receiveMessage(message); + // 华自3000告警数据转化 + List alarmEntities = systemAlarmService.receiveMessage(message); + //统一数据处理 + try { + alarmService.dealAlarmEntities(alarmEntities); + }catch (Exception e){ + throw new ServiceException("集中监控告警数据处理报错:"+e); + } + log.error("华自3000告警数据处理"); } } // 与服务器链接中断回调接口 @Override public void onClose(int code, String reason, boolean remote) { - log.error("systemAlarm websocket close"); + log.error("SystemAlarmWebSocket与服务器链接中断回调接口 "); } // 与服务器通讯异常触发 @@ -76,6 +89,7 @@ public class SystemAlarmWebSocket extends WebSocketClient { webSocket.setSocket(socket); } } + System.out.println("systemAlarm create success"); } /** @@ -87,6 +101,7 @@ public class SystemAlarmWebSocket extends WebSocketClient { Socket socket = null; try{ socket = context.getSocketFactory().createSocket(); + log.error("SystemAlarmWebSocket链接创建成功"); }catch (Exception e){ log.error("systemAlarm socket create error : {}",e.getMessage()); } @@ -116,6 +131,7 @@ public class SystemAlarmWebSocket extends WebSocketClient { return new X509Certificate[0]; } }}, new SecureRandom()); + log.error("SystemAlarmWebSocket初始化成功"); }catch (Exception e){ log.error("systemAlarm SSL init error : {}",e.getMessage()); } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/level/LevelAlarmWebSocket.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/level/LevelAlarmWebSocket.java index c9008a8..11ebc3f 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/level/LevelAlarmWebSocket.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/level/LevelAlarmWebSocket.java @@ -1,9 +1,12 @@ package com.hnac.hzims.alarm.ws.level; +import com.hnac.hzims.alarm.entity.AlarmEntity; +import com.hnac.hzims.alarm.show.service.AlarmService; import com.hnac.hzims.alarm.show.service.LevelAlarmService; import lombok.extern.slf4j.Slf4j; import org.java_websocket.client.WebSocketClient; import org.java_websocket.handshake.ServerHandshake; +import org.springblade.core.log.exception.ServiceException; import org.springblade.core.tool.utils.SpringUtil; import org.springblade.core.tool.utils.StringUtil; @@ -14,6 +17,7 @@ import java.net.Socket; import java.net.URI; import java.security.SecureRandom; import java.security.cert.X509Certificate; +import java.util.List; import java.util.Optional; /** @@ -25,6 +29,8 @@ public class LevelAlarmWebSocket extends WebSocketClient { private final LevelAlarmService levelService; + private AlarmService alarmService; + /** * 构造等级告警websocket * @param uri @@ -47,8 +53,15 @@ public class LevelAlarmWebSocket extends WebSocketClient { if(StringUtil.isEmpty(message)){ log.error("level alarm on message is null"); }else{ + + // 告警数据转化 + List alarmEntities = levelService.receiveMessage(message); // 等级告警数据处理 - levelService.receive(message); + try { + alarmService.dealAlarmEntities(alarmEntities); + }catch (Exception e){ + throw new ServiceException("集中监控告警数据处理报错(levelAlarm):"+e); + } } } diff --git a/hzims-service/hzims-alarm/src/main/resources/mapper/AlarmConfigDetatilMapper.xml b/hzims-service/hzims-alarm/src/main/resources/mapper/AlarmConfigDetatilMapper.xml deleted file mode 100644 index d29dafa..0000000 --- a/hzims-service/hzims-alarm/src/main/resources/mapper/AlarmConfigDetatilMapper.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - diff --git a/hzims-service/hzims-alarm/src/main/resources/mapper/AlarmConfigMapper.xml b/hzims-service/hzims-alarm/src/main/resources/mapper/AlarmConfigMapper.xml deleted file mode 100644 index 7692ae7..0000000 --- a/hzims-service/hzims-alarm/src/main/resources/mapper/AlarmConfigMapper.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - diff --git a/hzims-service/hzims-alarm/src/main/resources/mapper/AlarmHistoryMapper.xml b/hzims-service/hzims-alarm/src/main/resources/mapper/AlarmHistoryMapper.xml deleted file mode 100644 index 6d4fd62..0000000 --- a/hzims-service/hzims-alarm/src/main/resources/mapper/AlarmHistoryMapper.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/hzims-service/hzims-alarm/src/main/resources/mapper/AlarmMapper.xml b/hzims-service/hzims-alarm/src/main/resources/mapper/AlarmMapper.xml deleted file mode 100644 index 3fd4b39..0000000 --- a/hzims-service/hzims-alarm/src/main/resources/mapper/AlarmMapper.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - From 5d858b31dee51504a163b3de32e8212de7e2772c Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Fri, 22 Sep 2023 09:23:52 +0800 Subject: [PATCH 3/3] =?UTF-8?q?#poi=E7=89=88=E6=9C=AC=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E8=A7=A3=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hnac/hzims/operational/census/service/impl/TargetServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java index 83aac67..aaafcdc 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java @@ -149,7 +149,7 @@ public class TargetServiceImpl implements TargetService { double sum = stationDevices.stream().mapToDouble(EminfoAndEmParamVo::getInstalledCapacity).sum(); item.setInstalledCapacity(sum); // 装机容量详情 - List details = stationDevices.stream().map(device-> "[" + device.getName() + " " +device.getInstalledCapacity() +"kw]").collect(Collectors.toList()); + List details = stationDevices.stream().map(device-> "[" + device.getName() + " " +device.getInstalledCapacity() +"kW]").collect(Collectors.toList()); item.setDetail(String.join("|",details)); return item; }).filter(capacity->Math.abs(capacity.getInstalledCapacity()) > 0).collect(Collectors.toList());