Browse Source

#集中监控状态设置

zhongwei
yang_shj 1 year ago
parent
commit
b1375a003a
  1. 3
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/RealStationVo.java
  2. 5
      hzims-service/hzims-scheduled/pom.xml
  3. 12
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/alarm/AlarmQueryMapper.java
  4. 16
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/AlarmQueryService.java
  5. 74
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmQueryServiceImpl.java
  6. 36
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java
  7. 5
      hzims-service/hzims-scheduled/src/main/resources/mapper/alarm/AlarmQueryMapper.xml

3
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-数据中断") @ApiModelProperty("站点状态 : 0-正常 1-数据中断")
private Integer status; private Integer status;
@ApiModelProperty("铃铛展示: 0-不展示 1-展示")
private Integer bell;
@ApiModelProperty("排序") @ApiModelProperty("排序")
private Integer sort; private Integer sort;
} }

5
hzims-service/hzims-scheduled/pom.xml

@ -47,6 +47,11 @@
<artifactId>inspect-api</artifactId> <artifactId>inspect-api</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.hnac.hzims</groupId>
<artifactId>alarm-api</artifactId>
<version>4.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springblade</groupId> <groupId>org.springblade</groupId>
<artifactId>blade-core-test</artifactId> <artifactId>blade-core-test</artifactId>
<scope>test</scope> <scope>test</scope>

12
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<AlarmEntity> {
}

16
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<AlarmEntity> {
List<String> bells(List<String> codes);
List<String> aborts(List<String> codes);
}

74
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<AlarmQueryMapper, AlarmEntity> implements AlarmQueryService {
/**
* 查询站点铃铛
* @param codes
* @return
*/
@Override
public List<String> bells(List<String> codes) {
List<AlarmEntity> alarms = this.list(Wrappers.<AlarmEntity>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<String> aborts(List<String> codes) {
List<AlarmEntity> alarms = this.list(Wrappers.<AlarmEntity>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());
}
}

36
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.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.util.concurrent.ThreadFactoryBuilder; 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.entity.WorkshopInfoEntity;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.fdp.vo.FdpFaultStatusVo; 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.main.vo.RealStationVo;
import com.hnac.hzims.operational.station.entity.StationAttributeEntity; import com.hnac.hzims.operational.station.entity.StationAttributeEntity;
import com.hnac.hzims.operational.station.entity.StationEntity; 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.equipment.WorkshopInfoService;
import com.hnac.hzims.scheduled.service.operation.alarm.AbnormalAlarmService; import com.hnac.hzims.scheduled.service.operation.alarm.AbnormalAlarmService;
import com.hnac.hzims.scheduled.service.operation.alarm.RecordService; import com.hnac.hzims.scheduled.service.operation.alarm.RecordService;
@ -57,6 +59,7 @@ public class MonitorServiceImpl implements MonitorService {
private final RecordService alertService; private final RecordService alertService;
private final StationService stationService; private final StationService stationService;
private final AlarmQueryService alarmQueryService;
private final StationAttributeService attbtService; private final StationAttributeService attbtService;
private final WorkshopInfoService workshopInfoService; private final WorkshopInfoService workshopInfoService;
private final AbnormalAlarmService abnormalAlarmService; private final AbnormalAlarmService abnormalAlarmService;
@ -278,7 +281,6 @@ public class MonitorServiceImpl implements MonitorService {
List<StAlarmRecordEntity> alertList = alertService.list(new LambdaQueryWrapper<StAlarmRecordEntity>() {{ List<StAlarmRecordEntity> alertList = alertService.list(new LambdaQueryWrapper<StAlarmRecordEntity>() {{
orderByDesc(StAlarmRecordEntity::getCreateTime); orderByDesc(StAlarmRecordEntity::getCreateTime);
}}); }});
List<String> alarmList = abnormalAlarmService.abnormalAlarms();
// 获取所有故障记录 // 获取所有故障记录
List<FdpFaultStatusVo> faultList = this.getFdpFaultAll(); List<FdpFaultStatusVo> faultList = this.getFdpFaultAll();
// 所有设备分类 // 所有设备分类
@ -290,6 +292,10 @@ public class MonitorServiceImpl implements MonitorService {
// 获取站点列表 // 获取站点列表
List<StationEntity> stationEntityList = stationService.list(Wrappers.<StationEntity>lambdaQuery() List<StationEntity> stationEntityList = stationService.list(Wrappers.<StationEntity>lambdaQuery()
.in(StationEntity::getCode,new ArrayList<>(stationAttbtMap.keySet()))); .in(StationEntity::getCode,new ArrayList<>(stationAttbtMap.keySet())));
// 铃铛
List<String> bells = alarmQueryService.bells(stationEntityList.stream().map(StationEntity::getCode).collect(Collectors.toList()));
// 数据中断
List<String> aborts = alarmQueryService.aborts(stationEntityList.stream().map(StationEntity::getCode).collect(Collectors.toList()));
// 隐藏设备列表 // 隐藏设备列表
List<String> hideList = attrConfigService.getHideList(); List<String> hideList = attrConfigService.getHideList();
// 分割,每个map限制10个长度 // 分割,每个map限制10个长度
@ -328,8 +334,10 @@ public class MonitorServiceImpl implements MonitorService {
this.getDeviceParam(devices, deviceClassifyMap, deviceList); this.getDeviceParam(devices, deviceClassifyMap, deviceList);
// 运行设备状态设置 // 运行设备状态设置
this.deviceState(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())); station.setDeviceList(deviceList.stream().sorted(Comparator.comparing((RealDeviceVo::getDeviceName))).collect(Collectors.toList()));
stationList.add(station); stationList.add(station);
}); });
@ -348,6 +356,21 @@ public class MonitorServiceImpl implements MonitorService {
} }
/** /**
* 站点铃铛设置
* @param station
* @param bells
*/
private void stationBell(RealStationVo station, List<String> bells) {
station.setBell(0);
if(CollectionUtil.isEmpty(bells)){
return;
}
if(bells.contains(station.getStationCode())){
station.setBell(1);
}
}
/**
* 设备处理 * 设备处理
* *
* @param list * @param list
@ -674,11 +697,10 @@ public class MonitorServiceImpl implements MonitorService {
/** /**
* 设置站点状态 * 设置站点状态
* @param alarmList
* @param station * @param station
* @param key * @param key
*/ */
private void setStationStatus(List<String> alarmList, RealStationVo station, String key,List<RealDeviceVo> deviceList) { private void setStationStatus(List<String> aborts,RealStationVo station, String key,List<RealDeviceVo> deviceList) {
// 站点功率大于0为正常上送数据 // 站点功率大于0为正常上送数据
for(RealDeviceVo item : deviceList){ for(RealDeviceVo item : deviceList){
if(!CollectionUtil.isEmpty(item.getAttbtList())){ if(!CollectionUtil.isEmpty(item.getAttbtList())){
@ -693,9 +715,9 @@ public class MonitorServiceImpl implements MonitorService {
} }
} }
} }
}
} }
} if(aborts.contains(key)){
if(alarmList.contains(key)){
station.setStatus(1); station.setStatus(1);
} }
} }

5
hzims-service/hzims-scheduled/src/main/resources/mapper/alarm/AlarmQueryMapper.xml

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hnac.hzims.alarm.show.mapper.AlarmMapper">
</mapper>
Loading…
Cancel
Save