From b1375a003adb23b6657b4ce1c6dabbac34da5094 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Tue, 28 Nov 2023 15:01:23 +0800 Subject: [PATCH] =?UTF-8?q?#=E9=9B=86=E4=B8=AD=E7=9B=91=E6=8E=A7=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/operational/main/vo/RealStationVo.java | 3 + hzims-service/hzims-scheduled/pom.xml | 5 ++ .../scheduled/mapper/alarm/AlarmQueryMapper.java | 12 ++++ .../scheduled/service/alarm/AlarmQueryService.java | 16 +++++ .../service/alarm/impl/AlarmQueryServiceImpl.java | 74 ++++++++++++++++++++++ .../operation/monitor/impl/MonitorServiceImpl.java | 36 +++++++++-- .../resources/mapper/alarm/AlarmQueryMapper.xml | 5 ++ 7 files changed, 144 insertions(+), 7 deletions(-) create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/alarm/AlarmQueryMapper.java create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/AlarmQueryService.java create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmQueryServiceImpl.java create mode 100644 hzims-service/hzims-scheduled/src/main/resources/mapper/alarm/AlarmQueryMapper.xml diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/RealStationVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/RealStationVo.java index 515d623..81ed1b8 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/RealStationVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/RealStationVo.java @@ -43,6 +43,9 @@ public class RealStationVo implements Serializable { @ApiModelProperty("站点状态 : 0-正常 1-数据中断") private Integer status; + @ApiModelProperty("铃铛展示: 0-不展示 1-展示") + private Integer bell; + @ApiModelProperty("排序") private Integer sort; } diff --git a/hzims-service/hzims-scheduled/pom.xml b/hzims-service/hzims-scheduled/pom.xml index e1a0e7d..3e004f3 100644 --- a/hzims-service/hzims-scheduled/pom.xml +++ b/hzims-service/hzims-scheduled/pom.xml @@ -47,6 +47,11 @@ inspect-api + com.hnac.hzims + alarm-api + 4.0.0-SNAPSHOT + + org.springblade blade-core-test test diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/alarm/AlarmQueryMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/alarm/AlarmQueryMapper.java new file mode 100644 index 0000000..a2f4840 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/alarm/AlarmQueryMapper.java @@ -0,0 +1,12 @@ +package com.hnac.hzims.scheduled.mapper.alarm; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.alarm.entity.AlarmEntity; + +/** + * @author ysj + */ +public interface AlarmQueryMapper extends BaseMapper { + + +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/AlarmQueryService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/AlarmQueryService.java new file mode 100644 index 0000000..b0b2ad2 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/AlarmQueryService.java @@ -0,0 +1,16 @@ +package com.hnac.hzims.scheduled.service.alarm; + +import com.hnac.hzims.alarm.entity.AlarmEntity; +import org.springblade.core.mp.base.BaseService; + +import java.util.List; + +/** + * @author ysj + */ +public interface AlarmQueryService extends BaseService { + + List bells(List codes); + + List aborts(List codes); +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmQueryServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmQueryServiceImpl.java new file mode 100644 index 0000000..c65ebcb --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmQueryServiceImpl.java @@ -0,0 +1,74 @@ +package com.hnac.hzims.scheduled.service.alarm.impl; + +import cn.hutool.core.stream.CollectorUtil; +import com.baomidou.dynamic.datasource.annotation.DS; +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.scheduled.mapper.alarm.AlarmQueryMapper; +import com.hnac.hzims.scheduled.service.alarm.AlarmQueryService; +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.StringUtil; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author ysj + */ +@AllArgsConstructor +@Service +@Slf4j +@DS("alarm") +public class AlarmQueryServiceImpl extends BaseServiceImpl implements AlarmQueryService { + + /** + * 查询站点铃铛 + * @param codes + * @return + */ + @Override + public List bells(List codes) { + List alarms = this.list(Wrappers.lambdaQuery() + .in(AlarmEntity::getStationId,codes) + .eq(AlarmEntity::getIsSmallBell,0) + ); + if(CollectionUtil.isEmpty(alarms)){ + return new ArrayList<>(); + } + return alarms.stream().map(AlarmEntity::getStationId).distinct().collect(Collectors.toList()); + } + + /** + * 查询站点数据中断 + * @param codes + * @return + */ + @Override + public List aborts(List codes) { + List alarms = this.list(Wrappers.lambdaQuery() + .in(AlarmEntity::getStationId,codes) + .eq(AlarmEntity::getAlarmSource, AlarmConstants.HZ3000_ALARM) + .in(AlarmEntity::getAlarmType, Arrays.asList(AlarmConstants.INTERRUPT,AlarmConstants.ABNORMAL)) + ); + if(CollectionUtil.isEmpty(alarms)){ + return new ArrayList<>(); + } + return alarms.stream().collect(Collectors.groupingBy(AlarmEntity::getStationId)).entrySet().stream().map(entry->{ + // 站点最近的一条数据中断、数据异常告警 + AlarmEntity alarm = entry.getValue().stream().sorted(Comparator.comparing(AlarmEntity::getCreateTime).reversed()).collect(Collectors.toList()).get(0); + // 状态为中断 + if(alarm.getAlarmStatus().equals(0)){ + return alarm.getStationId(); + } + return ""; + }).filter(StringUtil::isBlank).distinct().collect(Collectors.toList()); + } +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java index 831dade..21cff8b 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.common.collect.Lists; import com.google.common.util.concurrent.ThreadFactoryBuilder; +import com.hnac.hzims.alarm.entity.AlarmEntity; import com.hnac.hzims.equipment.entity.WorkshopInfoEntity; import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.fdp.vo.FdpFaultStatusVo; @@ -18,6 +19,7 @@ import com.hnac.hzims.operational.main.vo.RealDeviceVo; import com.hnac.hzims.operational.main.vo.RealStationVo; import com.hnac.hzims.operational.station.entity.StationAttributeEntity; import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.scheduled.service.alarm.AlarmQueryService; import com.hnac.hzims.scheduled.service.equipment.WorkshopInfoService; import com.hnac.hzims.scheduled.service.operation.alarm.AbnormalAlarmService; import com.hnac.hzims.scheduled.service.operation.alarm.RecordService; @@ -57,6 +59,7 @@ public class MonitorServiceImpl implements MonitorService { private final RecordService alertService; private final StationService stationService; + private final AlarmQueryService alarmQueryService; private final StationAttributeService attbtService; private final WorkshopInfoService workshopInfoService; private final AbnormalAlarmService abnormalAlarmService; @@ -278,7 +281,6 @@ public class MonitorServiceImpl implements MonitorService { List alertList = alertService.list(new LambdaQueryWrapper() {{ orderByDesc(StAlarmRecordEntity::getCreateTime); }}); - List alarmList = abnormalAlarmService.abnormalAlarms(); // 获取所有故障记录 List faultList = this.getFdpFaultAll(); // 所有设备分类 @@ -290,6 +292,10 @@ public class MonitorServiceImpl implements MonitorService { // 获取站点列表 List stationEntityList = stationService.list(Wrappers.lambdaQuery() .in(StationEntity::getCode,new ArrayList<>(stationAttbtMap.keySet()))); + // 铃铛 + List bells = alarmQueryService.bells(stationEntityList.stream().map(StationEntity::getCode).collect(Collectors.toList())); + // 数据中断 + List aborts = alarmQueryService.aborts(stationEntityList.stream().map(StationEntity::getCode).collect(Collectors.toList())); // 隐藏设备列表 List hideList = attrConfigService.getHideList(); // 分割,每个map限制10个长度 @@ -328,8 +334,10 @@ public class MonitorServiceImpl implements MonitorService { this.getDeviceParam(devices, deviceClassifyMap, deviceList); // 运行设备状态设置 this.deviceState(deviceList); - // 设置站点状态 - this.setStationStatus(alarmList,station,key,deviceList); + // 设置站点状态:数据中断 + this.setStationStatus(aborts,station,key,deviceList); + // 铃铛 + this.stationBell(station,bells); station.setDeviceList(deviceList.stream().sorted(Comparator.comparing((RealDeviceVo::getDeviceName))).collect(Collectors.toList())); stationList.add(station); }); @@ -348,6 +356,21 @@ public class MonitorServiceImpl implements MonitorService { } /** + * 站点铃铛设置 + * @param station + * @param bells + */ + private void stationBell(RealStationVo station, List bells) { + station.setBell(0); + if(CollectionUtil.isEmpty(bells)){ + return; + } + if(bells.contains(station.getStationCode())){ + station.setBell(1); + } + } + + /** * 设备处理 * * @param list @@ -674,11 +697,10 @@ public class MonitorServiceImpl implements MonitorService { /** * 设置站点状态 - * @param alarmList * @param station * @param key */ - private void setStationStatus(List alarmList, RealStationVo station, String key,List deviceList) { + private void setStationStatus(List aborts,RealStationVo station, String key,List deviceList) { // 站点功率大于0为正常上送数据 for(RealDeviceVo item : deviceList){ if(!CollectionUtil.isEmpty(item.getAttbtList())){ @@ -693,9 +715,9 @@ public class MonitorServiceImpl implements MonitorService { } } } + } } - } - if(alarmList.contains(key)){ + if(aborts.contains(key)){ station.setStatus(1); } } diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/alarm/AlarmQueryMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/alarm/AlarmQueryMapper.xml new file mode 100644 index 0000000..3fd4b39 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/alarm/AlarmQueryMapper.xml @@ -0,0 +1,5 @@ + + + + +