Browse Source

Merge remote-tracking branch 'origin/prod-20240506' into prod-20240506

zhongwei
ty 6 months ago
parent
commit
039229668a
  1. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java
  2. 512
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java
  3. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java

2
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java

@ -88,7 +88,7 @@ public interface HomePageConstant {
*/
Integer HYDROPOWER_SERVETYPE = 2;
String HYDROPOWER_SERVETYPE_STR = "2";
String HYDROPOWER_SERVETYPE_STRING = "2";
/**
* 站点接入方式 数据采集

512
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java

@ -8,8 +8,6 @@ import com.google.common.collect.Lists;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.hnac.hzims.equipment.entity.WorkshopInfoEntity;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.fdp.vo.FdpFaultStatusVo;
import com.hnac.hzims.operational.config.entity.StAlarmRecordEntity;
import com.hnac.hzims.operational.config.enume.ConfigStatus;
import com.hnac.hzims.operational.config.vo.StationRealVo;
import com.hnac.hzims.operational.main.constant.HomePageConstant;
@ -41,6 +39,8 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.Function;
@ -207,9 +207,7 @@ public class MonitorServiceImpl implements MonitorService {
log.error("real_time_data: {},{}",stationReal.getStation(),realIds);
List<String> objects = redisClient.getBatchRealDataByRealId(stationReal.getStation(),realIds);
for(int i = 0; i < realIds.size() ;i++){
if(ObjectUtil.isEmpty(objects.get(i))){
// log.error(realIds.get(i) + "is null");
}else{
if(ObjectUtil.isNotEmpty(objects.get(i))){
Map<String,String> attribute = (Map<String, String>) JSONObject.parse(objects.get(i));
attribute.put("realId",attribute.get("k"));
attribute.put("value",attribute.get("v"));
@ -272,84 +270,51 @@ public class MonitorServiceImpl implements MonitorService {
*/
@Override
public void loadMonitoring(String param) {
Thread thread = Thread.currentThread();
Object json = redisTemplate.opsForValue().get(real_data_cache_final);
if (ObjectUtil.isEmpty(json)) {
return;
}
Map<String, Map<String, String>> map = JSONObject.parseObject(json.toString(), new TypeReference<Map<String, Map<String, String>>>() {
});
if (MapUtils.isEmpty(map)) {
// 集中监控属性配置
Map<String,List<StationAttributeEntity>> attributes = this.attributes();
// realId对应实时数据
Map<String,Map<String,String>> realTimeData = this.realTimeData();
if(MapUtils.isEmpty(attributes) || MapUtils.isEmpty(realTimeData)){
return;
}
// 获取所有设备重点属性
List<StationAttributeEntity> list = attbtService.list(new LambdaQueryWrapper<StationAttributeEntity>() {{
isNotNull(StationAttributeEntity::getStationId);
eq(StationAttributeEntity::getIsDeleted, "0");
orderByAsc(StationAttributeEntity::getSort);
}});
if (CollectionUtil.isEmpty(list)) {
// 集中监控站点
List<StationEntity> stations = this.monitorStations(new ArrayList<>(attributes.keySet()));
if(CollectionUtil.isEmpty(stations)){
return;
}
// 获取所有告警记录
List<StAlarmRecordEntity> alertList = alertService.list(new LambdaQueryWrapper<StAlarmRecordEntity>() {{
orderByDesc(StAlarmRecordEntity::getCreateTime);
}});
// 所有设备分类
// 机构(取排序字段)
Map<Long,Integer> sorts = this.monitorDeptSorts();
List<String> operations = stations.stream().filter(o->HomePageConstant.HYDROPOWER_SERVETYPE_STRING.equals(o.getServeType())).map(StationEntity::getCode).collect(Collectors.toList());
// 告警铃铛(代运维)
List<String> bells = alarmQueryService.bells(operations);
// 数据中断(代运维)
List<String> aborts = interruptionAlarmService.aborts(operations);
// 设备状态分类
Map<String, List<String>> deviceClassifyMap = (Map<String, List<String>>) redisTemplate.opsForValue().get(device_classify_cache_final);
// 所有设备
List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_final).toString(),new TypeReference<List<EminfoAndEmParamVo>>() {});
// 根据站点分组
Map<String, List<StationAttributeEntity>> stationAttbtMap = list.stream().collect(Collectors.groupingBy(StationAttributeEntity::getStationId));
// 获取站点列表
List<StationEntity> stationEntityList = stationService.list(Wrappers.<StationEntity>lambdaQuery()
.in(StationEntity::getCode,new ArrayList<>(stationAttbtMap.keySet())));
// 铃铛
List<String> bells = alarmQueryService.bells(stationEntityList.stream().map(StationEntity::getCode).collect(Collectors.toList()));
// 数据中断
List<String> aborts = interruptionAlarmService.aborts(stationEntityList.stream().filter(o->HomePageConstant.HYDROPOWER_SERVETYPE_STR.equals(o.getServeType())).map(StationEntity::getCode).collect(Collectors.toList()));
// 隐藏设备列表
List<String> hideList = attrConfigService.getHideList();
// 分割,每个map限制10个长度
List<Map<String, List<StationAttributeEntity>>> handleList = this.mapChunk(stationAttbtMap);
// 创建线程池
CountDownLatch countDownLatch = new CountDownLatch(handleList.size());
// 所有机构
R<List<Dept>> deptAll = sysClient.getDeptList();
// 按10个站点一组分割属性配置
List<Map<String, List<StationAttributeEntity>>> limit = this.limitMapChunk(attributes);
// 线程执行次数
CountDownLatch countDownLatch = new CountDownLatch(limit.size());
// 存储数据节点
List<RealStationVo> stationList = new CopyOnWriteArrayList<>();
// 线程处理数据
for(Map<String, List<StationAttributeEntity>> item : handleList){
List<RealStationVo> realStations = new CopyOnWriteArrayList<>();
// 切割数据遍历
for(Map<String, List<StationAttributeEntity>> item : limit){
// 提交线程任务
pool.submit(()->{
item.forEach((key,value)->{
RealStationVo station = new RealStationVo();
// 站点编码
station.setStationCode(key);
// 名称、限制水位、服务类型、机构、排序
this.stationParam(stationEntityList,station,deptAll.getData());
// 根据设备名称分组
Map<String, List<StationAttributeEntity>> deviceAttbtMap = value.stream().filter(o -> !StringUtil.isEmpty(o.getEmName()) && !hideList.contains(o.getEmName())).collect(Collectors.groupingBy(StationAttributeEntity::getEmName));
List<RealDeviceVo> deviceList = new ArrayList<>();
// device - 设备,arrbt - 设备重点属性
deviceAttbtMap.forEach((device, attbt) -> {
RealDeviceVo deviceVo = new RealDeviceVo();
// 设备名称
deviceVo.setDeviceName(device);
deviceVo.setDeviceCode(attbt.get(0).getEmCode());
// 设备处理
this.handleDevice(attbt, map, deviceVo, alertList);
deviceList.add(deviceVo);
});
RealStationVo realStation = new RealStationVo();
// 设备信息
List<RealDeviceVo> devices = this.monitorRealDevice(value,realTimeData);
// 设备状态
this.getDeviceParam(devices, deviceClassifyMap, deviceList);
// 设置站点状态:数据中断
this.setStationStatus(aborts,station,key,deviceList);
// 运行设备状态设置
this.deviceState(deviceList);
// 铃铛
this.stationBell(station,bells);
station.setDeviceList(deviceList.stream().sorted(Comparator.comparing((RealDeviceVo::getDeviceName))).collect(Collectors.toList()));
stationList.add(station);
this.deviceStatus(devices,deviceClassifyMap);
realStation.setDeviceList(devices.stream().sorted(Comparator.comparing(RealDeviceVo::getDeviceName)).collect(Collectors.toList()));
// 站点基础信息: 编码、名称、限制水位、服务类型、机构、排序
this.stationBaseInfo(stations.stream().filter(station->key.equals(station.getCode())).findFirst(),sorts,realStation);
// 站点总功率计算
this.stationActivePower(devices,realStation);
// 站点铃铛、数据中断状态
this.stationStatus(aborts,bells,realStation);
realStations.add(realStation);
});
countDownLatch.countDown();
});
@ -361,169 +326,223 @@ public class MonitorServiceImpl implements MonitorService {
e.printStackTrace();
Thread.currentThread().interrupt();
}
redisTemplate.opsForValue().set(moniter_station_cache_final, stationList);
redisTemplate.opsForValue().set(moniter_station_cache_final, realStations);
}
/**
* 站点铃铛设置
* @param station
* @param bells
* 设置设备状态
* @param devices
* @param deviceClassifyMap
*/
private void stationBell(RealStationVo station, List<String> bells) {
station.setBell(0);
if(CollectionUtil.isEmpty(bells)){
private void deviceStatus(List<RealDeviceVo> devices, Map<String, List<String>> deviceClassifyMap) {
if (CollectionUtil.isEmpty(devices) || MapUtils.isEmpty(deviceClassifyMap)) {
return;
}
if(bells.contains(station.getStationCode())){
station.setBell(1);
List<String> faults = deviceClassifyMap.get(HomePageConstant.FAULT);
List<String> overhaults = deviceClassifyMap.get(HomePageConstant.OVERHAUL);
devices.forEach(device -> {
int state = -1;
if(StringUtil.isNotBlank(device.getDeviceCode())){
// 故障
if (CollectionUtil.isNotEmpty(faults) && faults.contains(device.getDeviceCode())) {
state = 4;
// 检修
} else if (CollectionUtil.isNotEmpty(overhaults) && overhaults.contains(device.getDeviceCode())) {
state = 0;
}
}
if(state >= 0){
device.setState(state);
}else{
List<RealAttributeVo> attbts = device.getAttbtList();
// 功率属性记录
List<RealAttributeVo> powers = attbts.stream().filter(att-> HomePageConstant.powerList.contains(att.getName())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(powers)){
device.setState(-1);
return;
}
if("0.000000".equals(powers.get(0).getValue()) || "-".equals(powers.get(0).getValue()) || HomePageConstant.ON.equals(powers.get(0).getValue())){
device.setState(-1);
return;
}
device.setState(1);
}
});
}
/**
* 设备处理
*
* @param list
* @param map
* @param device
* 站点总功率计算
* @param devices
* @param realStation
*/
private void handleDevice(List<StationAttributeEntity> list, Map<String, Map<String, String>> map,
RealDeviceVo device, List<StAlarmRecordEntity> alertList) {
if (CollectionUtil.isEmpty(list) || MapUtils.isEmpty(map)) {
private void stationActivePower(List<RealDeviceVo> devices, RealStationVo realStation) {
realStation.setPowerSum(0.0);
if (CollectionUtil.isEmpty(devices)) {
return;
}
List<RealAttributeVo> attbtList = new ArrayList<>();
list.forEach(item -> {
RealAttributeVo realAttributeVo = new RealAttributeVo();
// 设备重点属性处理 : 单条-item
Map<String, String> real = map.get(item.getMonitorId());
if(MapUtils.isEmpty(real)){
realAttributeVo.setName(item.getAttributes());
realAttributeVo.setType(item.getAttributeType());
realAttributeVo.setRealId(item.getMonitorId());
realAttributeVo.setQuality(-1);
realAttributeVo.setStatus(0);
realAttributeVo.setValue("0");
realAttributeVo.setUnit(item.getUnit());
attbtList.add(realAttributeVo);
double powerSum = 0.0;
// 遍历设备
for (RealDeviceVo item : devices) {
List<RealAttributeVo> attributes = item.getAttbtList();
if (CollectionUtil.isEmpty(attributes)) {
return;
}
realAttributeVo = handleAttbt(item, real, alertList);
if (ObjectUtil.isEmpty(realAttributeVo)) {
List<RealAttributeVo> powerList = attributes.stream().filter(o -> StringUtil.isNoneBlank(o.getValue()) && !"-".equals(o.getValue()) && HomePageConstant.powerList.contains(o.getName())).collect(Collectors.toList());
if (CollectionUtil.isEmpty(powerList)) {
return;
}
attbtList.add(realAttributeVo);
});
device.setAttbtList(attbtList);
// 获取设备中属性为P/p的value值总和
powerSum += BigDecimal.valueOf(powerList.stream().mapToDouble(m -> Double.parseDouble(m.getValue())).sum()).setScale(2, RoundingMode.HALF_UP).doubleValue();
}
}
/**
* 设备状态
* @param deviceList
* 站点铃铛数据中断状态
* @param aborts
* @param bells
* @param realStation
*/
private void deviceState(List<RealDeviceVo> deviceList) {
deviceList.forEach(device->{
// 设备属性列表
List<RealAttributeVo> attbts = device.getAttbtList();
if(CollectionUtil.isEmpty(attbts)){
device.setState(-1);
return;
private void stationStatus(List<String> aborts, List<String> bells, RealStationVo realStation) {
realStation.setBell(0);
realStation.setStatus(0);
// 铃铛
if(bells.contains(realStation.getStationCode())){
realStation.setBell(1);
}
// 数据中断
if(realStation.getPowerSum() <= 0 && aborts.contains(realStation.getStationCode())){
realStation.setStatus(1);
}
}
// 功率属性记录
List<RealAttributeVo> powers = attbts.stream().filter(att-> HomePageConstant.powerList.contains(att.getName())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(powers)){
device.setState(-1);
return;
/**
* 监控设备实时信息
* @param attributes
* @param realTimeData
* @return
*/
private List<RealDeviceVo> monitorRealDevice(List<StationAttributeEntity> attributes,Map<String,Map<String,String>> realTimeData) {
if(CollectionUtil.isEmpty(attributes)){
return new ArrayList<>();
}
if("0.000000".equals(powers.get(0).getValue()) || "-".equals(powers.get(0).getValue()) || HomePageConstant.ON.equals(powers.get(0).getValue())){
device.setState(-1);
return;
// 根据设备名称分组
return attributes.stream().filter(o -> !StringUtil.isEmpty(o.getEmName())).collect(Collectors.groupingBy(StationAttributeEntity::getEmName)).entrySet().stream().map(entry->{
RealDeviceVo device = new RealDeviceVo();
device.setDeviceName(entry.getKey());
device.setDeviceCode(entry.getValue().get(0).getEmCode());
// 设备处理
this.handleDevice(entry.getValue(), realTimeData, device);
return device;
}).collect(Collectors.toList());
}
device.setState(1);
/**
* 获取缓存中实时数据
* @return
*/
private Map<String, Map<String, String>> realTimeData() {
Object json = redisTemplate.opsForValue().get(real_data_cache_final);
if (ObjectUtil.isEmpty(json)) {
return new HashMap<>();
}
return JSONObject.parseObject(json.toString(), new TypeReference<Map<String, Map<String, String>>>() {
});
}
/**
* 获取站点属性
* @param stationEntityList
* @param item
* 查询集中监控属性配置
* @return
*/
private void stationParam(List<StationEntity> stationEntityList, RealStationVo item,List<Dept> deptAll) {
item.setSort(9999);
if(CollectionUtil.isEmpty(stationEntityList)){
return;
private Map<String,List<StationAttributeEntity>> attributes() {
List<StationAttributeEntity> attributes = attbtService.list(new LambdaQueryWrapper<StationAttributeEntity>() {{
isNotNull(StationAttributeEntity::getStationId);
orderByAsc(StationAttributeEntity::getSort);
}});
if(CollectionUtil.isEmpty(attributes)){
return new HashMap<>();
}
List<StationEntity> filterList = stationEntityList.stream().filter(o->item.getStationCode().equals(o.getCode())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(filterList)){
return;
return attributes.stream().collect(Collectors.groupingBy(StationAttributeEntity::getStationId));
}
StationEntity station = filterList.get(0);
if(ObjectUtil.isEmpty(station)){
return;
/**
* 集中监控站点
* @param codes
* @return
*/
private List<StationEntity> monitorStations(ArrayList<String> codes) {
return stationService.list(Wrappers.<StationEntity>lambdaQuery()
.in(StationEntity::getCode,codes)
);
}
item.setStationName(station.getName());
item.setWaterLevelMax(Optional.ofNullable(station.getLimitWaterLevel()).orElse(0.0));
item.setServerType(station.getServeType());
item.setStationDeptId(station.getRefDept());
// 排序
List<Dept> list = deptAll.stream().filter(o-> station.getRefDept().equals(o.getId())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(list)){
return;
/**
* 机构排序
* @return
*/
private Map<Long, Integer> monitorDeptSorts() {
R<List<Dept>> depts = sysClient.getDeptList();
if (!depts.isSuccess() || CollectionUtil.isEmpty(depts.getData())) {
new HashMap<>();
}
item.setSort(list.get(0).getSort());
return depts.getData().stream().collect(Collectors.toMap(Dept::getId,Dept::getSort));
}
/**
* 设备参数设置
*
* @param devices
* @param deviceClassifyMap
* @param deviceList
* 站点基础信息
* @param realStation
*/
private void getDeviceParam(List<EminfoAndEmParamVo> devices, Map<String, List<String>> deviceClassifyMap, List<RealDeviceVo> deviceList) {
if (CollectionUtil.isEmpty(devices) || CollectionUtil.isEmpty(deviceList) || MapUtils.isEmpty(deviceClassifyMap)) {
private void stationBaseInfo(Optional<StationEntity> optional, Map<Long, Integer> sorts, RealStationVo realStation) {
realStation.setSort(999);
if(!optional.isPresent()){
return;
}
List<String> faultList = deviceClassifyMap.get(HomePageConstant.FAULT);
List<String> maintaintList = deviceClassifyMap.get(HomePageConstant.MAINTAIN);
List<String> overhaultList = deviceClassifyMap.get(HomePageConstant.OVERHAUL);
List<String> runtList = deviceClassifyMap.get(HomePageConstant.RUN);
List<String> sparetList = deviceClassifyMap.get(HomePageConstant.SPARE);
deviceList.forEach(device -> {
if (StringUtil.isBlank(device.getDeviceCode())) {
device.setState(-1);
return;
realStation.setStationCode(optional.get().getCode());
realStation.setStationName(optional.get().getName());
realStation.setWaterLevelMax(Optional.ofNullable(optional.get().getLimitWaterLevel()).orElse(0.0));
realStation.setServerType(optional.get().getServeType());
realStation.setStationDeptId(optional.get().getRefDept());
if(sorts.containsKey(optional.get().getRefDept())){
realStation.setSort(sorts.get(optional.get().getRefDept()));
}
List<EminfoAndEmParamVo> list = devices.stream().filter(o -> null != o.getId() && o.getId().toString().equals(device.getDeviceCode())).collect(Collectors.toList());
if (CollectionUtil.isEmpty(list)) {
device.setState(-1);
}
/**
* 设备处理
*
* @param list
* @param map
* @param device
*/
private void handleDevice(List<StationAttributeEntity> list, Map<String, Map<String, String>> map,RealDeviceVo device) {
if (CollectionUtil.isEmpty(list) || MapUtils.isEmpty(map)) {
return;
}
String deviceCode = list.get(0).getEmCode();
if (StringUtil.isBlank(deviceCode)) {
device.setState(-1);
List<RealAttributeVo> attbtList = new ArrayList<>();
list.forEach(item -> {
RealAttributeVo realAttributeVo = new RealAttributeVo();
// 设备重点属性处理 : 单条-item
Map<String, String> real = map.get(item.getMonitorId());
if(MapUtils.isEmpty(real)){
realAttributeVo.setName(item.getAttributes());
realAttributeVo.setType(item.getAttributeType());
realAttributeVo.setRealId(item.getMonitorId());
realAttributeVo.setQuality(-1);
realAttributeVo.setStatus(0);
realAttributeVo.setValue("0");
realAttributeVo.setUnit(item.getUnit());
attbtList.add(realAttributeVo);
return;
}
// 故障
if (CollectionUtil.isNotEmpty(faultList) && faultList.contains(deviceCode)) {
device.setState(4);
// 保养
} else if (CollectionUtil.isNotEmpty(maintaintList) && maintaintList.contains(deviceCode)) {
device.setState(3);
// 备用
} else if (CollectionUtil.isNotEmpty(sparetList) && sparetList.contains(deviceCode)) {
device.setState(2);
// 运行
} else if (CollectionUtil.isNotEmpty(runtList) && runtList.contains(deviceCode)) {
device.setState(1);
// 检修
} else if (CollectionUtil.isNotEmpty(overhaultList) && overhaultList.contains(deviceCode)) {
device.setState(0);
// 未知
} else {
device.setState(-1);
realAttributeVo = handleAttbt(item, real);
if (ObjectUtil.isEmpty(realAttributeVo)) {
return;
}
attbtList.add(realAttributeVo);
});
device.setAttbtList(attbtList);
}
/**
@ -533,8 +552,7 @@ public class MonitorServiceImpl implements MonitorService {
* @param real
* @return
*/
private RealAttributeVo handleAttbt(StationAttributeEntity item, Map<String, String> real,
List<StAlarmRecordEntity> alertList) {
private RealAttributeVo handleAttbt(StationAttributeEntity item, Map<String, String> real) {
RealAttributeVo attest = new RealAttributeVo();
this.setAttbtParam(attest, real);
attest.setRealId(item.getMonitorId());
@ -544,7 +562,7 @@ public class MonitorServiceImpl implements MonitorService {
String value = Optional.ofNullable(attest.getValue()).orElse("-");
// 正常状态
attest.setStatus(ConfigStatus.ConfigStatusEnum.NORMAL.getStatus());
int quality = Optional.ofNullable(attest.getQuality()).orElse(-1);
int quality = Optional.of(attest.getQuality()).orElse(-1);
String time = Optional.ofNullable(attest.getTime()).orElse("");
// 延时状态 :质量为空 && 时间为空
if (-1 == quality && StringUtil.isEmpty(time)) {
@ -552,14 +570,16 @@ public class MonitorServiceImpl implements MonitorService {
}
int type = item.getAttributeType();
switch (type) {
case 1://遥测
//遥测
case 1:
// 预警状态 :value值为"1" && quality值为0
if ("1".equals(value) && 0 == quality) {
attest.setStatus(ConfigStatus.ConfigStatusEnum.RED.getStatus());
}
break;
case 2://遥信
signalyRemote(item, attest, quality, value, alertList);
//遥信
case 2:
signalyRemote(item, attest, quality, value);
//处理
break;
default:
@ -606,9 +626,9 @@ public class MonitorServiceImpl implements MonitorService {
*
* @param attest
*/
private void signalyRemote(StationAttributeEntity item, RealAttributeVo attest, int quality, String strValue, List<StAlarmRecordEntity> alertList) {
//需要所有值的数据不为null,并且满足条件才会进去添加数据返回id
if (null == item.getUpUpLimit() || null == item.getDownDownLimit() || null == item.getUpLimit() || null == item.getDownLimit()) {
private void signalyRemote(StationAttributeEntity attribute, RealAttributeVo attest, int quality, String strValue) {
// 需要所有限制不为null,并且满足条件才会设置设备状态标识
if (null == attribute.getUpUpLimit() || null == attribute.getDownDownLimit() || null == attribute.getUpLimit() || null == attribute.getDownLimit()) {
return;
}
if (-1 == quality) {
@ -620,99 +640,17 @@ public class MonitorServiceImpl implements MonitorService {
if ("-".equals(strValue)) {
return;
}
double upup = item.getUpUpLimit();
double lwlw = item.getDownDownLimit();
double up = item.getUpLimit();
double lw = item.getDownLimit();
//查询出来已处理告警记录
List<StAlarmRecordEntity> handleList = alertList.stream().filter(o -> o.getStationId().equals(item.getStationId()) && o.getRealId().equals(attest.getRealId()) && o.getStatus() == 1).collect(Collectors.toList());
//查询出来未处理告警记录
List<StAlarmRecordEntity> recordList = alertList.stream().filter(o -> o.getStationId().equals(item.getStationId()) && o.getRealId().equals(attest.getRealId()) && o.getStatus() == 0).collect(Collectors.toList());
double upup = attribute.getUpUpLimit();
double lwlw = attribute.getDownDownLimit();
double up = attribute.getUpLimit();
double lw = attribute.getDownLimit();
long past = 0L;
double value = Double.parseDouble(strValue);
if (value > upup || value < lwlw) {
if (CollectionUtil.isNotEmpty(handleList)) {
// 现在时间 - 处理时间
past = System.currentTimeMillis() - handleList.get(0).getProcessTime().getTime();
}
boolean isOverrun = ((CollectionUtil.isEmpty(handleList) && CollectionUtil.isEmpty(recordList)) || (past / 1000 / 60 > 30 && CollectionUtil.isEmpty(recordList)));
if (isOverrun) {
Long alertId = alertService.insertAlert(item.getStationId(), item.getMonitorId());
attest.setId(alertId);
attest.setStatus(ConfigStatus.ConfigStatusEnum.YELLOW.getStatus());
} else if (CollectionUtil.isNotEmpty(recordList)) {
StAlarmRecordEntity record = recordList.get(0);
attest.setId(record.getId());
// 告警处理完成
if (record.getProcessTime() != null && record.getStatus() == (byte) 1) {
attest.setStatus(ConfigStatus.ConfigStatusEnum.NORMAL.getStatus());
// 告警未处理
} else if (record.getProcessTime() == null && record.getStatus() == (byte) 0) {
attest.setStatus(ConfigStatus.ConfigStatusEnum.HAND_DELAY_STATUS.getStatus());
}
}
attest.setStatus(ConfigStatus.ConfigStatusEnum.RED.getStatus());
} else if (value > up && value < upup || value < lw && value > lwlw) {
if (CollectionUtil.isNotEmpty(handleList)) {
// 现在时间 - 处理时间
past = System.currentTimeMillis() - handleList.get(0).getProcessTime().getTime();
}
boolean exist = ((CollectionUtil.isEmpty(handleList) && CollectionUtil.isEmpty(recordList)) || (past / 1000 / 60 > 30 && CollectionUtil.isEmpty(recordList)));
if (exist){
Long alertId = alertService.insertAlert(item.getStationId(), item.getMonitorId());
attest.setId(alertId);
attest.setStatus(ConfigStatus.ConfigStatusEnum.YELLOW.getStatus());
// 存在告警记录
} else if (CollectionUtil.isNotEmpty(recordList)) {
StAlarmRecordEntity record = recordList.get(0);
if (recordList.get(0).getStatus() == (byte) 0 && recordList.get(0).getCreateTime() != null) {
attest.setId(record.getId());
attest.setStatus(ConfigStatus.ConfigStatusEnum.RED.getStatus());
} else {
attest.setId(recordList.get(0).getId());
attest.setStatus(ConfigStatus.ConfigStatusEnum.NORMAL.getStatus());
}
}
}
}
/**
* 设置站点状态
* @param station
* @param key
*/
private void setStationStatus(List<String> aborts,RealStationVo station, String key,List<RealDeviceVo> deviceList) {
// 站点功率大于0为正常上送数据
for(RealDeviceVo item : deviceList){
if(!CollectionUtil.isEmpty(item.getAttbtList())){
List<RealAttributeVo> powers = item.getAttbtList().stream().filter(att-> HomePageConstant.powerList.contains(att.getName())).collect(Collectors.toList());
if(!CollectionUtil.isEmpty(powers)){
for(RealAttributeVo attr : powers){
if(!"-".equals(attr.getValue())){
if(attr.getQuality() == 0 && Double.parseDouble(attr.getValue()) > 0){
station.setStatus(0);
return;
}
}
}
}
}
}
if(aborts.contains(key)){
station.setStatus(1);
}
}
/**
* 获取所有告警记录
*
* @return
*/
private List<FdpFaultStatusVo> getFdpFaultAll() {
Object json = redisTemplate.opsForValue().get(fdp_fault_cache_final);
if (ObjectUtil.isEmpty(json)) {
return new ArrayList<>();
}
return (List<FdpFaultStatusVo>) json;
}
/**
@ -723,7 +661,7 @@ public class MonitorServiceImpl implements MonitorService {
* @param chunkMap
* @return
*/
private <k, v> List<Map<k, v>> mapChunk(Map<k, v> chunkMap) {
private <k, v> List<Map<k, v>> limitMapChunk(Map<k, v> chunkMap) {
if (chunkMap == null) {
return Lists.newArrayList();
}

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java

@ -252,8 +252,6 @@ public class RealMonitorServiceImpl implements IRealMonitorService {
this.weather(nowWeather,weekWeather,item);
// 前池水位
this.waterLevel(levelList,item);
// 总有功率
this.activePower(item);
});
log.info("步骤4站点数据处理 耗时 : {}",System.currentTimeMillis() - beginTime);
return new TextMessage(JSONObject.toJSONString(validList.stream().peek(o->{

Loading…
Cancel
Save