From 29a3490f0c328c51ee5e269a85dc1abec8d2bcaf Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Tue, 14 May 2024 14:55:43 +0800 Subject: [PATCH] =?UTF-8?q?#=E9=9B=86=E4=B8=AD=E7=9B=91=E6=8E=A7=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E7=8A=B6=E6=80=81&=E4=B8=8A=E4=B8=8A=E9=99=90?= =?UTF-8?q?=EF=BC=8C=E4=B8=8B=E4=B8=8B=E9=99=90=E8=B6=85=E9=99=90=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 --- .../main/constant/HomePageConstant.java | 2 +- .../operation/monitor/impl/MonitorServiceImpl.java | 522 +++++++++------------ .../service/impl/RealMonitorServiceImpl.java | 2 - 3 files changed, 231 insertions(+), 295 deletions(-) diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java index af0113b..4337c56 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java +++ b/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"; /** * 站点接入方式 : 数据采集 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 dc7af4b..029080c 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 @@ -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 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 attribute = (Map) 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> map = JSONObject.parseObject(json.toString(), new TypeReference>>() { - }); - if (MapUtils.isEmpty(map)) { + // 集中监控属性配置 + Map> attributes = this.attributes(); + // realId对应实时数据 + Map> realTimeData = this.realTimeData(); + if(MapUtils.isEmpty(attributes) || MapUtils.isEmpty(realTimeData)){ return; } - // 获取所有设备重点属性 - List list = attbtService.list(new LambdaQueryWrapper() {{ - isNotNull(StationAttributeEntity::getStationId); - eq(StationAttributeEntity::getIsDeleted, "0"); - orderByAsc(StationAttributeEntity::getSort); - }}); - if (CollectionUtil.isEmpty(list)) { + // 集中监控站点 + List stations = this.monitorStations(new ArrayList<>(attributes.keySet())); + if(CollectionUtil.isEmpty(stations)){ return; } - // 获取所有告警记录 - List alertList = alertService.list(new LambdaQueryWrapper() {{ - orderByDesc(StAlarmRecordEntity::getCreateTime); - }}); - // 所有设备分类 + // 机构(取排序字段) + Map sorts = this.monitorDeptSorts(); + List operations = stations.stream().filter(o->HomePageConstant.HYDROPOWER_SERVETYPE_STRING.equals(o.getServeType())).map(StationEntity::getCode).collect(Collectors.toList()); + // 告警铃铛(代运维) + List bells = alarmQueryService.bells(operations); + // 数据中断(代运维) + List aborts = interruptionAlarmService.aborts(operations); + // 设备状态分类 Map> deviceClassifyMap = (Map>) redisTemplate.opsForValue().get(device_classify_cache_final); - // 所有设备 - List devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_final).toString(),new TypeReference>() {}); - // 根据站点分组 - Map> stationAttbtMap = list.stream().collect(Collectors.groupingBy(StationAttributeEntity::getStationId)); - // 获取站点列表 - 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 = interruptionAlarmService.aborts(stationEntityList.stream().filter(o->HomePageConstant.HYDROPOWER_SERVETYPE_STR.equals(o.getServeType())).map(StationEntity::getCode).collect(Collectors.toList())); - // 隐藏设备列表 - List hideList = attrConfigService.getHideList(); - // 分割,每个map限制10个长度 - List>> handleList = this.mapChunk(stationAttbtMap); - // 创建线程池 - CountDownLatch countDownLatch = new CountDownLatch(handleList.size()); - // 所有机构 - R> deptAll = sysClient.getDeptList(); + // 按10个站点一组分割属性配置 + List>> limit = this.limitMapChunk(attributes); + // 线程执行次数 + CountDownLatch countDownLatch = new CountDownLatch(limit.size()); // 存储数据节点 - List stationList = new CopyOnWriteArrayList<>(); - // 线程处理数据 - for(Map> item : handleList){ + List realStations = new CopyOnWriteArrayList<>(); + // 切割数据遍历 + for(Map> item : limit){ + // 提交线程任务 pool.submit(()->{ item.forEach((key,value)->{ - RealStationVo station = new RealStationVo(); - // 站点编码 - station.setStationCode(key); - // 名称、限制水位、服务类型、机构、排序 - this.stationParam(stationEntityList,station,deptAll.getData()); - // 根据设备名称分组 - Map> deviceAttbtMap = value.stream().filter(o -> !StringUtil.isEmpty(o.getEmName()) && !hideList.contains(o.getEmName())).collect(Collectors.groupingBy(StationAttributeEntity::getEmName)); - List 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 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 bells) { - station.setBell(0); - if(CollectionUtil.isEmpty(bells)){ + private void deviceStatus(List devices, Map> deviceClassifyMap) { + if (CollectionUtil.isEmpty(devices) || MapUtils.isEmpty(deviceClassifyMap)) { return; } - if(bells.contains(station.getStationCode())){ - station.setBell(1); - } + List faults = deviceClassifyMap.get(HomePageConstant.FAULT); + List 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 attbts = device.getAttbtList(); + // 功率属性记录 + List 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 list, Map> map, - RealDeviceVo device, List alertList) { - if (CollectionUtil.isEmpty(list) || MapUtils.isEmpty(map)) { + private void stationActivePower(List devices, RealStationVo realStation) { + realStation.setPowerSum(0.0); + if (CollectionUtil.isEmpty(devices)) { return; } - List attbtList = new ArrayList<>(); - list.forEach(item -> { - RealAttributeVo realAttributeVo = new RealAttributeVo(); - // 设备重点属性处理 : 单条-item - Map 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 attributes = item.getAttbtList(); + if (CollectionUtil.isEmpty(attributes)) { return; } - realAttributeVo = handleAttbt(item, real, alertList); - if (ObjectUtil.isEmpty(realAttributeVo)) { + List 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 deviceList) { - deviceList.forEach(device->{ - // 设备属性列表 - List attbts = device.getAttbtList(); - if(CollectionUtil.isEmpty(attbts)){ - device.setState(-1); - return; - } + private void stationStatus(List aborts, List 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 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 attributes + * @param realTimeData + * @return + */ + private List monitorRealDevice(List attributes,Map> realTimeData) { + if(CollectionUtil.isEmpty(attributes)){ + return new ArrayList<>(); + } + // 根据设备名称分组 + 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()); + } + + + /** + * 获取缓存中实时数据 + * @return + */ + private Map> realTimeData() { + Object json = redisTemplate.opsForValue().get(real_data_cache_final); + if (ObjectUtil.isEmpty(json)) { + return new HashMap<>(); + } + return JSONObject.parseObject(json.toString(), new TypeReference>>() { }); } /** - * 获取站点属性 - * @param stationEntityList - * @param item + * 查询集中监控属性配置 + * @return */ - private void stationParam(List stationEntityList, RealStationVo item,List deptAll) { - item.setSort(9999); - if(CollectionUtil.isEmpty(stationEntityList)){ - return; + private Map> attributes() { + List attributes = attbtService.list(new LambdaQueryWrapper() {{ + isNotNull(StationAttributeEntity::getStationId); + orderByAsc(StationAttributeEntity::getSort); + }}); + if(CollectionUtil.isEmpty(attributes)){ + return new HashMap<>(); } - List 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)); + } + + /** + * 集中监控站点 + * @param codes + * @return + */ + private List monitorStations(ArrayList codes) { + return stationService.list(Wrappers.lambdaQuery() + .in(StationEntity::getCode,codes) + ); + } + + /** + * 机构排序 + * @return + */ + private Map monitorDeptSorts() { + R> depts = sysClient.getDeptList(); + if (!depts.isSuccess() || CollectionUtil.isEmpty(depts.getData())) { + new HashMap<>(); } - StationEntity station = filterList.get(0); - if(ObjectUtil.isEmpty(station)){ + return depts.getData().stream().collect(Collectors.toMap(Dept::getId,Dept::getSort)); + } + + /** + * 站点基础信息 + * @param realStation + */ + private void stationBaseInfo(Optional optional, Map sorts, RealStationVo realStation) { + realStation.setSort(999); + if(!optional.isPresent()){ return; } - item.setStationName(station.getName()); - item.setWaterLevelMax(Optional.ofNullable(station.getLimitWaterLevel()).orElse(0.0)); - item.setServerType(station.getServeType()); - item.setStationDeptId(station.getRefDept()); - // 排序 - List list = deptAll.stream().filter(o-> station.getRefDept().equals(o.getId())).collect(Collectors.toList()); - if(CollectionUtil.isEmpty(list)){ - 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())); } - item.setSort(list.get(0).getSort()); } + + /** - * 设备参数设置 + * 设备处理 * - * @param devices - * @param deviceClassifyMap - * @param deviceList + * @param list、 + * @param map + * @param device */ - private void getDeviceParam(List devices, Map> deviceClassifyMap, List deviceList) { - if (CollectionUtil.isEmpty(devices) || CollectionUtil.isEmpty(deviceList) || MapUtils.isEmpty(deviceClassifyMap)) { + private void handleDevice(List list, Map> map,RealDeviceVo device) { + if (CollectionUtil.isEmpty(list) || MapUtils.isEmpty(map)) { return; } - List faultList = deviceClassifyMap.get(HomePageConstant.FAULT); - List maintaintList = deviceClassifyMap.get(HomePageConstant.MAINTAIN); - List overhaultList = deviceClassifyMap.get(HomePageConstant.OVERHAUL); - List runtList = deviceClassifyMap.get(HomePageConstant.RUN); - List sparetList = deviceClassifyMap.get(HomePageConstant.SPARE); - deviceList.forEach(device -> { - if (StringUtil.isBlank(device.getDeviceCode())) { - device.setState(-1); - return; - } - List list = devices.stream().filter(o -> null != o.getId() && o.getId().toString().equals(device.getDeviceCode())).collect(Collectors.toList()); - if (CollectionUtil.isEmpty(list)) { - device.setState(-1); + List attbtList = new ArrayList<>(); + list.forEach(item -> { + RealAttributeVo realAttributeVo = new RealAttributeVo(); + // 设备重点属性处理 : 单条-item + Map 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; } - String deviceCode = list.get(0).getEmCode(); - if (StringUtil.isBlank(deviceCode)) { - device.setState(-1); + realAttributeVo = handleAttbt(item, real); + if (ObjectUtil.isEmpty(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); - } + attbtList.add(realAttributeVo); }); + device.setAttbtList(attbtList); } /** @@ -533,8 +552,7 @@ public class MonitorServiceImpl implements MonitorService { * @param real * @return */ - private RealAttributeVo handleAttbt(StationAttributeEntity item, Map real, - List alertList) { + private RealAttributeVo handleAttbt(StationAttributeEntity item, Map 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 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 handleList = alertList.stream().filter(o -> o.getStationId().equals(item.getStationId()) && o.getRealId().equals(attest.getRealId()) && o.getStatus() == 1).collect(Collectors.toList()); - //查询出来未处理告警记录 - List 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 aborts,RealStationVo station, String key,List deviceList) { - // 站点功率大于0为正常上送数据 - for(RealDeviceVo item : deviceList){ - if(!CollectionUtil.isEmpty(item.getAttbtList())){ - List 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 getFdpFaultAll() { - Object json = redisTemplate.opsForValue().get(fdp_fault_cache_final); - if (ObjectUtil.isEmpty(json)) { - return new ArrayList<>(); + attest.setStatus(ConfigStatus.ConfigStatusEnum.YELLOW.getStatus()); } - return (List) json; } /** @@ -723,7 +661,7 @@ public class MonitorServiceImpl implements MonitorService { * @param chunkMap * @return */ - private List> mapChunk(Map chunkMap) { + private List> limitMapChunk(Map chunkMap) { if (chunkMap == null) { return Lists.newArrayList(); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java index e6aed35..251a618 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java +++ b/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->{