Commit 98e6aa04 authored by yangyang's avatar yangyang

智慧分析 - 健康等级区域、全域修改

parent 9060a6a9
package com.yeejoin.amos.boot.module.jxiop.biz.dto;
import lombok.Data;
/**
* TODO(一句话描述该类的功能)
* <p>
* ProjectName: amos-boot-zx-biz
* PackageName: com.yeejoin.amos.boot.module.jxiop.biz.dto
*
* @author yangyang
* @version v1.0
* @date 2024/7/25 11:05
*/
@Data
public class HealthIndexDTO {
private String type;
private Long ts;
private String recDate;
private String analysisObjType;
private String analysisObjSeq;
private Double weight;
private Double healthIndex;
private String healthLevel;
private String analysisType;
private String analysisStartTime;
private String analysisEndTime;
private String area;
private String station;
private String subSystem;
private String number;
private String equipmentName;
private String gatewayId;
private String indexAddress;
private Double anomaly;
private String pointName;
private String analysisTime;
private String kks;
private String orgCode;
}
package com.yeejoin.amos.boot.module.jxiop.biz.service; package com.yeejoin.amos.boot.module.jxiop.biz.service;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.HealthIndexDTO;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex; import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndex;
import java.util.List; import java.util.List;
...@@ -87,4 +89,12 @@ public interface IFanHealthIndexService { ...@@ -87,4 +89,12 @@ public interface IFanHealthIndexService {
* @date 2024/7/23 21:02 * @date 2024/7/23 21:02
*/ */
List<FanHealthIndex> getInfoListByGroupByQgFan(String startTime, String tableName, String analysisObjectType); List<FanHealthIndex> getInfoListByGroupByQgFan(String startTime, String tableName, String analysisObjectType);
List<HealthIndexDTO> getInfoListByGroupByQy(String startTime, String fanTableName, String pvTableName, String analysisObjectType);
List<HealthIndexDTO> getInfoListByGroupByQg(String startTime, String fanTableName, String pvTableName, String analysisObjectType);
FanHealthIndex toFanHealthIndex(HealthIndexDTO healthIndex);
PvHealthIndex toPvHealthIndex(HealthIndexDTO healthIndex);
} }
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl; package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.HealthIndexDTO;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanWeight; import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanWeight;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvWeight;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanWeightMapper; import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanWeightMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizPvWeightMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.service.IFanHealthIndexService; import com.yeejoin.amos.boot.module.jxiop.biz.service.IFanHealthIndexService;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanHealthIndexMapper; import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanHealthIndexMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvHealthIndexMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex; import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndex;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.Supplier; import java.util.function.Supplier;
...@@ -36,6 +43,12 @@ public class FanHealthIndexServiceImpl implements IFanHealthIndexService { ...@@ -36,6 +43,12 @@ public class FanHealthIndexServiceImpl implements IFanHealthIndexService {
@Autowired @Autowired
private IdxBizFanWeightMapper idxBizFanWeightMapper; private IdxBizFanWeightMapper idxBizFanWeightMapper;
@Autowired
private PvHealthIndexMapper pvHealthIndexMapper;
@Autowired
private IdxBizPvWeightMapper idxBizPvWeightMapper;
@Override @Override
public List<FanHealthIndex> getInfoListByGroupByCdFan(String startTime, String tableName, String analysisObjectType) { public List<FanHealthIndex> getInfoListByGroupByCdFan(String startTime, String tableName, String analysisObjectType) {
List<FanHealthIndex> fanHealthIndicesZxt = fanHealthIndexMapper.getInfoList(startTime, tableName, analysisObjectType); List<FanHealthIndex> fanHealthIndicesZxt = fanHealthIndexMapper.getInfoList(startTime, tableName, analysisObjectType);
...@@ -262,6 +275,7 @@ public class FanHealthIndexServiceImpl implements IFanHealthIndexService { ...@@ -262,6 +275,7 @@ public class FanHealthIndexServiceImpl implements IFanHealthIndexService {
* @date 2024/7/23 21:02 * @date 2024/7/23 21:02
*/ */
@Override @Override
@Deprecated
public List<FanHealthIndex> getInfoListByGroupByQyFan(String startTime, String tableName, String analysisObjectType) { public List<FanHealthIndex> getInfoListByGroupByQyFan(String startTime, String tableName, String analysisObjectType) {
List<FanHealthIndex> fanHealthIndicesZxt = fanHealthIndexMapper.getInfoList(startTime, tableName, analysisObjectType); List<FanHealthIndex> fanHealthIndicesZxt = fanHealthIndexMapper.getInfoList(startTime, tableName, analysisObjectType);
QueryWrapper<IdxBizFanWeight> idxBizFanWeightQueryWrapper = new QueryWrapper<>(); QueryWrapper<IdxBizFanWeight> idxBizFanWeightQueryWrapper = new QueryWrapper<>();
...@@ -313,6 +327,7 @@ public class FanHealthIndexServiceImpl implements IFanHealthIndexService { ...@@ -313,6 +327,7 @@ public class FanHealthIndexServiceImpl implements IFanHealthIndexService {
* @date 2024/7/23 21:02 * @date 2024/7/23 21:02
*/ */
@Override @Override
@Deprecated
public List<FanHealthIndex> getInfoListByGroupByQgFan(String startTime, String tableName, String analysisObjectType) { public List<FanHealthIndex> getInfoListByGroupByQgFan(String startTime, String tableName, String analysisObjectType) {
List<FanHealthIndex> fanHealthIndicesZxt = fanHealthIndexMapper.getInfoList(startTime, tableName, analysisObjectType); List<FanHealthIndex> fanHealthIndicesZxt = fanHealthIndexMapper.getInfoList(startTime, tableName, analysisObjectType);
QueryWrapper<IdxBizFanWeight> idxBizFanWeightQueryWrapper = new QueryWrapper<>(); QueryWrapper<IdxBizFanWeight> idxBizFanWeightQueryWrapper = new QueryWrapper<>();
...@@ -347,6 +362,96 @@ public class FanHealthIndexServiceImpl implements IFanHealthIndexService { ...@@ -347,6 +362,96 @@ public class FanHealthIndexServiceImpl implements IFanHealthIndexService {
return fanHealthIndicesZxtNews; return fanHealthIndicesZxtNews;
} }
@Override
public List<HealthIndexDTO> getInfoListByGroupByQy(String startTime, String fanTableName, String pvTableName, String analysisObjectType) {
List<FanHealthIndex> fanHealthIndices = fanHealthIndexMapper.getInfoList(startTime, fanTableName, analysisObjectType);
List<IdxBizFanWeight> idxBizFanWeights = idxBizFanWeightMapper.selectList(new QueryWrapper<IdxBizFanWeight>().eq("type", "2").isNotNull("value"));
Map<String, Float> fanWeightMap = idxBizFanWeights.stream().collect(Collectors.toMap(o -> "fan" + o.getArae() + o.getStation(), IdxBizFanWeight::getValue));
List<PvHealthIndex> pvHealthIndices = pvHealthIndexMapper.getInfoList(startTime, pvTableName, analysisObjectType);
List<IdxBizPvWeight> pvIdxBizFanWeights = idxBizPvWeightMapper.selectList(new QueryWrapper<IdxBizPvWeight>().eq("type", "2").isNotNull("value"));
Map<String, Float> pvWeightMap = pvIdxBizFanWeights.stream().collect(Collectors.toMap(o -> "pv" + o.getArae() + o.getStation(), IdxBizPvWeight::getValue));
List<HealthIndexDTO> healthIndexDTOS = new ArrayList<>();
healthIndexDTOS.addAll(fanHealthIndices.stream().map(this::toHealthIndexDTO).collect(Collectors.toList()));
healthIndexDTOS.addAll(pvHealthIndices.stream().map(this::toHealthIndexDTO).collect(Collectors.toList()));
Map<String, Float> weightMap = new HashMap<>();
weightMap.putAll(fanWeightMap);
weightMap.putAll(pvWeightMap);
// 开始计算加权平均
Map<String, List<HealthIndexDTO>> fanHealthIndicesZxtMap = healthIndexDTOS.stream().collect(Collectors.groupingBy(o -> o.getAnalysisObjType() + o.getArea() + o.getOrgCode()));
List<HealthIndexDTO> fanHealthIndicesZxtNews = new ArrayList<>();
fanHealthIndicesZxtMap.forEach((k, v) -> {
HealthIndexDTO healthIndex = new HealthIndexDTO();
healthIndex.setAnalysisObjType("片区");
healthIndex.setArea(v.get(0).getArea());
healthIndex.setOrgCode(v.get(0).getOrgCode());
// 例如 子系统 = (测点1 * 测点1权重 + 测点2 * 测点2权重 + .... 测点n权重) / (测点1权重 + 测点2权重 + .... 测点n权重)
// 但是测点是没有权重的,所以子系统无法计算加权平均
// 设备 = (子系统1 * 子系统1权重 + 子系统2 * 子系统2权重 + .... 子系统n权重) / (子系统1权重 + 子系统2权重 + .... 子系统n权重)
// 但如果没有配置子系统的权重,如何计算?
try {
// 加权平均
Double totalHealthIndex = v.stream().mapToDouble(o -> getWeight(() -> o.getType() + o.getArea() + o.getStation(), weightMap) * o.getHealthIndex()).sum();
Double totalAnomaly = v.stream().mapToDouble(o -> getWeight(() -> o.getType() + o.getArea() + o.getStation(), weightMap) * o.getAnomaly()).sum();
Double totalWeight = v.stream().mapToDouble(o -> getWeight(() -> o.getType() + o.getArea() + o.getStation(), weightMap)).sum();
healthIndex.setAnomaly(totalAnomaly / totalWeight);
healthIndex.setHealthIndex(totalHealthIndex / totalWeight);
} catch (Exception e) {
// 普通平均
this.calculateAvg(healthIndex, v);
}
fanHealthIndicesZxtNews.add(healthIndex);
});
return fanHealthIndicesZxtNews;
}
@Override
public List<HealthIndexDTO> getInfoListByGroupByQg(String startTime, String fanTableName, String pvTableName, String analysisObjectType) {
List<FanHealthIndex> fanHealthIndices = fanHealthIndexMapper.getInfoList(startTime, fanTableName, analysisObjectType);
List<IdxBizFanWeight> idxBizFanWeights = idxBizFanWeightMapper.selectList(new QueryWrapper<IdxBizFanWeight>().eq("type", "1").isNotNull("value"));
Map<String, Float> fanWeightMap = idxBizFanWeights.stream().collect(Collectors.toMap(o -> "fan" + o.getArae(), IdxBizFanWeight::getValue));
List<PvHealthIndex> pvHealthIndices = pvHealthIndexMapper.getInfoList(startTime, pvTableName, analysisObjectType);
List<IdxBizPvWeight> pvIdxBizFanWeights = idxBizPvWeightMapper.selectList(new QueryWrapper<IdxBizPvWeight>().eq("type", "1").isNotNull("value"));
Map<String, Float> pvWeightMap = pvIdxBizFanWeights.stream().collect(Collectors.toMap(o -> "pv" + o.getArae(), IdxBizPvWeight::getValue));
List<HealthIndexDTO> healthIndexDTOS = new ArrayList<>();
healthIndexDTOS.addAll(fanHealthIndices.stream().map(this::toHealthIndexDTO).collect(Collectors.toList()));
healthIndexDTOS.addAll(pvHealthIndices.stream().map(this::toHealthIndexDTO).collect(Collectors.toList()));
Map<String, Float> weightMap = new HashMap<>();
weightMap.putAll(fanWeightMap);
weightMap.putAll(pvWeightMap);
// 开始计算加权平均
Map<String, List<HealthIndexDTO>> fanHealthIndicesZxtMap = healthIndexDTOS.stream().collect(Collectors.groupingBy(o -> o.getAnalysisObjType() + o.getOrgCode()));
List<HealthIndexDTO> fanHealthIndicesZxtNews = new ArrayList<>();
fanHealthIndicesZxtMap.forEach((k, v) -> {
HealthIndexDTO healthIndex = new HealthIndexDTO();
healthIndex.setAnalysisObjType("全域");
healthIndex.setOrgCode(v.get(0).getOrgCode());
// 例如 子系统 = (测点1 * 测点1权重 + 测点2 * 测点2权重 + .... 测点n权重) / (测点1权重 + 测点2权重 + .... 测点n权重)
// 但是测点是没有权重的,所以子系统无法计算加权平均
// 设备 = (子系统1 * 子系统1权重 + 子系统2 * 子系统2权重 + .... 子系统n权重) / (子系统1权重 + 子系统2权重 + .... 子系统n权重)
// 但如果没有配置子系统的权重,如何计算?
try {
// 加权平均
Double totalHealthIndex = v.stream().mapToDouble(o -> getWeight(() -> o.getType() + o.getArea(), weightMap) * o.getHealthIndex()).sum();
Double totalAnomaly = v.stream().mapToDouble(o -> getWeight(() -> o.getType() + o.getArea(), weightMap) * o.getAnomaly()).sum();
Double totalWeight = v.stream().mapToDouble(o -> getWeight(() -> o.getType() + o.getArea(), weightMap)).sum();
healthIndex.setAnomaly(totalAnomaly / totalWeight);
healthIndex.setHealthIndex(totalHealthIndex / totalWeight);
} catch (Exception e) {
// 普通平均
this.calculateAvg(healthIndex, v);
}
fanHealthIndicesZxtNews.add(healthIndex);
});
return fanHealthIndicesZxtNews;
}
public void calculateAvg(FanHealthIndex healthIndex, List<FanHealthIndex> v) { public void calculateAvg(FanHealthIndex healthIndex, List<FanHealthIndex> v) {
// 普通平均 // 普通平均
Double avgHealthIndex = v.stream().mapToDouble(o -> o.getHealthIndex()).sum(); Double avgHealthIndex = v.stream().mapToDouble(o -> o.getHealthIndex()).sum();
...@@ -357,6 +462,16 @@ public class FanHealthIndexServiceImpl implements IFanHealthIndexService { ...@@ -357,6 +462,16 @@ public class FanHealthIndexServiceImpl implements IFanHealthIndexService {
healthIndex.setHealthIndex(avgHealthIndex / totalAnomaly); healthIndex.setHealthIndex(avgHealthIndex / totalAnomaly);
} }
public void calculateAvg(HealthIndexDTO healthIndex, List<HealthIndexDTO> v) {
// 普通平均
Double avgHealthIndex = v.stream().mapToDouble(o -> o.getHealthIndex()).sum();
Double avgAnomaly = v.stream().mapToDouble(o -> o.getAnomaly()).sum();
Long totalHealthIndex = v.stream().filter(o -> o.getHealthIndex() != null).mapToDouble(o -> o.getHealthIndex()).count();
Long totalAnomaly = v.stream().filter(o -> o.getAnomaly() != null).mapToDouble(o -> o.getAnomaly()).count();
healthIndex.setAnomaly(avgAnomaly / totalHealthIndex);
healthIndex.setHealthIndex(avgHealthIndex / totalAnomaly);
}
public Double getWeight(Supplier<String> key, Map<String, Float> weightMap) { public Double getWeight(Supplier<String> key, Map<String, Float> weightMap) {
Float weight = weightMap.get(key.get()); Float weight = weightMap.get(key.get());
if (weight == null) { if (weight == null) {
...@@ -366,4 +481,36 @@ public class FanHealthIndexServiceImpl implements IFanHealthIndexService { ...@@ -366,4 +481,36 @@ public class FanHealthIndexServiceImpl implements IFanHealthIndexService {
return weight.doubleValue(); return weight.doubleValue();
} }
public HealthIndexDTO toHealthIndexDTO(FanHealthIndex healthIndex) {
HealthIndexDTO healthIndexDTO = new HealthIndexDTO();
BeanUtils.copyProperties(healthIndex, healthIndexDTO);
healthIndexDTO.setSubSystem(healthIndex.getSubSystem());
healthIndexDTO.setType("fan");
return healthIndexDTO;
}
public HealthIndexDTO toHealthIndexDTO(PvHealthIndex healthIndex) {
HealthIndexDTO healthIndexDTO = new HealthIndexDTO();
BeanUtils.copyProperties(healthIndex, healthIndexDTO);
healthIndexDTO.setSubSystem(healthIndex.getSubarray());
healthIndexDTO.setType("pv");
return healthIndexDTO;
}
@Override
public FanHealthIndex toFanHealthIndex(HealthIndexDTO healthIndex) {
FanHealthIndex fanHealthIndex = new FanHealthIndex();
BeanUtils.copyProperties(healthIndex, fanHealthIndex);
fanHealthIndex.setSubSystem(healthIndex.getSubSystem());
return fanHealthIndex;
}
@Override
public PvHealthIndex toPvHealthIndex(HealthIndexDTO healthIndex) {
PvHealthIndex pvHealthIndex = new PvHealthIndex();
BeanUtils.copyProperties(healthIndex, pvHealthIndex);
pvHealthIndex.setSubarray(healthIndex.getSubSystem());
return pvHealthIndex;
}
} }
...@@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil; ...@@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils; import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.jxiop.biz.Enum.WarningPeriodEnum; import com.yeejoin.amos.boot.module.jxiop.biz.Enum.WarningPeriodEnum;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.HealthIndexDTO;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanHealthLevel; import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanHealthLevel;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvHealthLevel; import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvHealthLevel;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanHealthLevelMapper; import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanHealthLevelMapper;
...@@ -27,6 +28,7 @@ import java.util.ArrayList; ...@@ -27,6 +28,7 @@ import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
@Slf4j @Slf4j
...@@ -120,18 +122,49 @@ public class TdengineTimeServiceImpl { ...@@ -120,18 +122,49 @@ public class TdengineTimeServiceImpl {
List<IdxBizFanHealthLevel> levelListCz = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "场站").last("limit 4")); List<IdxBizFanHealthLevel> levelListCz = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "场站").last("limit 4"));
List<FanHealthIndex> fanHealthIndicesCz = fanHealthIndexService.getInfoListByGroupByCzFan(startTime, "fan_health_index_moment", "设备"); List<FanHealthIndex> fanHealthIndicesCz = fanHealthIndexService.getInfoListByGroupByCzFan(startTime, "fan_health_index_moment", "设备");
saveBatchFan(fanHealthIndicesCz, "fan_health_index_hour", recDate, WarningPeriodEnum.HOUR.getName(), levelListCz); saveBatchFan(fanHealthIndicesCz, "fan_health_index_hour", recDate, WarningPeriodEnum.HOUR.getName(), levelListCz);
idxFanHealthIndexMapper.deleteAllDataByTableName("pv_health_index_latest_data", "按小时");
// 测点
List<IdxBizPvHealthLevel> pvLevelList = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "测点").last("limit 4"));
List<PvHealthIndex> pvHealthIndices = pvHealthIndexMapper.getInfoListByGroupByCdPv(startTime, "pv_health_index_moment", "测点");
saveBatchPv(pvHealthIndices, "pv_health_index_hour", recDate, WarningPeriodEnum.HOUR.getName(), pvLevelList);
// 设备
List<IdxBizPvHealthLevel> pvLevelListSb = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "设备").last("limit 4"));
List<PvHealthIndex> pvHealthIndicesSb = pvHealthIndexService.getInfoListByGroupBySbPv(startTime, "pv_health_index_moment", "测点");
saveBatchPv(pvHealthIndicesSb, "pv_health_index_hour", recDate, WarningPeriodEnum.HOUR.getName(), pvLevelListSb);
// 子阵
List<IdxBizPvHealthLevel> pvLevelListZz = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "子阵").last("limit 4"));
List<PvHealthIndex> pvHealthIndicesZz = pvHealthIndexService.getInfoListByGroupByZzPv(startTime, "pv_health_index_moment", "设备");
saveBatchPv(pvHealthIndicesZz, "pv_health_index_hour", recDate, WarningPeriodEnum.HOUR.getName(), pvLevelListZz);
// 场站
List<IdxBizPvHealthLevel> pvLevelListCz = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "场站").last("limit 4"));
List<PvHealthIndex> pvHealthIndicesCz = pvHealthIndexService.getInfoListByGroupByCzPv(startTime, "pv_health_index_moment", "子阵");
saveBatchPv(pvHealthIndicesCz, "pv_health_index_hour", recDate, WarningPeriodEnum.HOUR.getName(), pvLevelListCz);
// 区域 // 区域
List<HealthIndexDTO> healthIndexQyDTOS = fanHealthIndexService.getInfoListByGroupByQy(startTime,"fan_health_index_moment", "pv_health_index_moment","场站");
List<IdxBizFanHealthLevel> levelListQy = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "片区").last("limit 4")); List<IdxBizFanHealthLevel> levelListQy = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "片区").last("limit 4"));
List<FanHealthIndex> fanHealthIndicesQy = fanHealthIndexService.getInfoListByGroupByQyFan(startTime, "fan_health_index_moment", "场站"); List<FanHealthIndex> fanHealthIndicesQy = healthIndexQyDTOS.stream().map(o -> fanHealthIndexService.toFanHealthIndex(o)).collect(Collectors.toList());
saveBatchFan(fanHealthIndicesQy, "fan_health_index_hour", recDate, WarningPeriodEnum.HOUR.getName(), levelListQy); saveBatchFan(fanHealthIndicesQy, "fan_health_index_hour", recDate, WarningPeriodEnum.HOUR.getName(), levelListQy);
// 片区
List<IdxBizPvHealthLevel> pvLevelListQy = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "片区").last("limit 4"));
List<PvHealthIndex> pvHealthIndicesQy = healthIndexQyDTOS.stream().map(o -> fanHealthIndexService.toPvHealthIndex(o)).collect(Collectors.toList());
saveBatchPv(pvHealthIndicesQy, "pv_health_index_hour", recDate, WarningPeriodEnum.HOUR.getName(), pvLevelListQy);
// 全域【所有 / 全国】 // 全域【所有 / 全国】
List<HealthIndexDTO> healthIndexQgDTOS = fanHealthIndexService.getInfoListByGroupByQg(startTime, "fan_health_index_moment", "pv_health_index_moment", "片区");
List<IdxBizFanHealthLevel> levelListQg = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "全域").last("limit 4")); List<IdxBizFanHealthLevel> levelListQg = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "全域").last("limit 4"));
List<FanHealthIndex> fanHealthIndicesQg = fanHealthIndexService.getInfoListByGroupByQgFan(startTime, "fan_health_index_moment", "片区"); List<FanHealthIndex> fanHealthIndicesQg = healthIndexQgDTOS.stream().map(o -> fanHealthIndexService.toFanHealthIndex(o)).collect(Collectors.toList());
saveBatchFan(fanHealthIndicesQg, "fan_health_index_hour", recDate, WarningPeriodEnum.HOUR.getName(), levelListQg); saveBatchFan(fanHealthIndicesQg, "fan_health_index_hour", recDate, WarningPeriodEnum.HOUR.getName(), levelListQg);
// 全域【所有 / 全国】
List<IdxBizPvHealthLevel> pvLevelListQg = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "全域").last("limit 4"));
List<PvHealthIndex> pvHealthIndicesQg = healthIndexQgDTOS.stream().map(o -> fanHealthIndexService.toPvHealthIndex(o)).collect(Collectors.toList());
saveBatchPv(pvHealthIndicesQg, "pv_health_index_hour", recDate, WarningPeriodEnum.HOUR.getName(), pvLevelListQg);
//预警生成 //预警生成
healthStatusIndicatorServiceImpl.healthWarningHour(); healthStatusIndicatorServiceImpl.healthWarningHour();
//预警生成
healthStatusIndicatorServiceImpl.healthWarningHourGF();
} }
/** /**
...@@ -147,10 +180,10 @@ public class TdengineTimeServiceImpl { ...@@ -147,10 +180,10 @@ public class TdengineTimeServiceImpl {
recOriginalDate = DateUtil.offsetDay(recOriginalDate, -1); recOriginalDate = DateUtil.offsetDay(recOriginalDate, -1);
String recDate = DateUtil.format(recOriginalDate, "yyyy-MM-dd"); String recDate = DateUtil.format(recOriginalDate, "yyyy-MM-dd");
String startTime = DateUtils.dateFormat(DateUtils.dateAddHours(new Date(), -32), DateUtils.DATE_TIME_PATTERN); String startTime = DateUtils.dateFormat(DateUtils.dateAddHours(new Date(), -32), DateUtils.DATE_TIME_PATTERN);
List<IdxBizFanHealthLevel> levelList = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "测点").last("limit 4")); List<IdxBizFanHealthLevel> levelList = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "测点").last("limit 4"));
List<FanHealthIndex> fanHealthIndices = fanHealthIndexMapper.getInfoListByGroupByCdFan(startTime, "fan_health_index_hour", "测点"); List<FanHealthIndex> fanHealthIndices = fanHealthIndexMapper.getInfoListByGroupByCdFan(startTime, "fan_health_index_hour", "测点");
saveBatchFan(fanHealthIndices, "fan_health_index_day", recDate, WarningPeriodEnum.DAY.getName(), levelList); saveBatchFan(fanHealthIndices, "fan_health_index_day", recDate, WarningPeriodEnum.DAY.getName(), levelList);
// 子系统 // 子系统
List<IdxBizFanHealthLevel> levelListZxt = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "子系统").last("limit 4")); List<IdxBizFanHealthLevel> levelListZxt = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "子系统").last("limit 4"));
List<FanHealthIndex> fanHealthIndicesZxt = fanHealthIndexService.getInfoListByGroupByZxtFan(startTime, "fan_health_index_hour", "测点"); List<FanHealthIndex> fanHealthIndicesZxt = fanHealthIndexService.getInfoListByGroupByZxtFan(startTime, "fan_health_index_hour", "测点");
...@@ -163,17 +196,49 @@ public class TdengineTimeServiceImpl { ...@@ -163,17 +196,49 @@ public class TdengineTimeServiceImpl {
List<IdxBizFanHealthLevel> levelListCz = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "场站").last("limit 4")); List<IdxBizFanHealthLevel> levelListCz = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "场站").last("limit 4"));
List<FanHealthIndex> fanHealthIndicesCz = fanHealthIndexService.getInfoListByGroupByCzFan(startTime, "fan_health_index_hour", "设备"); List<FanHealthIndex> fanHealthIndicesCz = fanHealthIndexService.getInfoListByGroupByCzFan(startTime, "fan_health_index_hour", "设备");
saveBatchFan(fanHealthIndicesCz, "fan_health_index_day", recDate, WarningPeriodEnum.DAY.getName(), levelListCz); saveBatchFan(fanHealthIndicesCz, "fan_health_index_day", recDate, WarningPeriodEnum.DAY.getName(), levelListCz);
idxFanHealthIndexMapper.deleteAllDataByTableName("pv_health_index_latest_data", WarningPeriodEnum.DAY.getName());
List<IdxBizPvHealthLevel> pvLevelList = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "测点").last("limit 4"));
List<PvHealthIndex> pvHealthIndices = pvHealthIndexMapper.getInfoListByGroupByCdPv(startTime, "pv_health_index_hour", "测点");
saveBatchPv(pvHealthIndices, "pv_health_index_day", recDate, WarningPeriodEnum.DAY.getName(), pvLevelList);
// 设备
List<IdxBizPvHealthLevel> pvLevelListSb = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "设备").last("limit 4"));
List<PvHealthIndex> pvHealthIndicesSb = pvHealthIndexService.getInfoListByGroupBySbPv(startTime, "pv_health_index_hour", "测点");
saveBatchPv(pvHealthIndicesSb, "pv_health_index_day", recDate, WarningPeriodEnum.DAY.getName(), pvLevelListSb);
// 子阵
List<IdxBizPvHealthLevel> pvLevelListZz = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "子阵").last("limit 4"));
List<PvHealthIndex> pvHealthIndicesZz = pvHealthIndexService.getInfoListByGroupByZzPv(startTime, "pv_health_index_hour", "设备");
saveBatchPv(pvHealthIndicesZz, "pv_health_index_day", recDate, WarningPeriodEnum.DAY.getName(), pvLevelListZz);
// 场站
List<IdxBizPvHealthLevel> pvLevelListCz = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "场站").last("limit 4"));
List<PvHealthIndex> pvHealthIndicesCz = pvHealthIndexService.getInfoListByGroupByCzPv(startTime, "pv_health_index_hour", "子阵");
saveBatchPv(pvHealthIndicesCz, "pv_health_index_day", recDate, WarningPeriodEnum.DAY.getName(), pvLevelListCz);
// 区域 // 区域
List<HealthIndexDTO> healthIndexQyDTOS = fanHealthIndexService.getInfoListByGroupByQy(startTime,"fan_health_index_hour", "pv_health_index_hour","场站");
List<IdxBizFanHealthLevel> levelListQy = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "片区").last("limit 4")); List<IdxBizFanHealthLevel> levelListQy = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "片区").last("limit 4"));
List<FanHealthIndex> fanHealthIndicesQy = fanHealthIndexService.getInfoListByGroupByQyFan(startTime, "fan_health_index_hour", "场站"); List<FanHealthIndex> fanHealthIndicesQy = healthIndexQyDTOS.stream().map(o -> fanHealthIndexService.toFanHealthIndex(o)).collect(Collectors.toList());
saveBatchFan(fanHealthIndicesQy, "fan_health_index_day", recDate, WarningPeriodEnum.DAY.getName(), levelListQy); saveBatchFan(fanHealthIndicesQy, "fan_health_index_day", recDate, WarningPeriodEnum.DAY.getName(), levelListQy);
// 片区
List<IdxBizPvHealthLevel> pvLevelListQy = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "片区").last("limit 4"));
List<PvHealthIndex> pvHealthIndicesQy = healthIndexQyDTOS.stream().map(o -> fanHealthIndexService.toPvHealthIndex(o)).collect(Collectors.toList());
saveBatchPv(pvHealthIndicesQy, "pv_health_index_day", recDate, WarningPeriodEnum.DAY.getName(), pvLevelListQy);
// 全域【所有 / 全国】 // 全域【所有 / 全国】
List<HealthIndexDTO> healthIndexQgDTOS = fanHealthIndexService.getInfoListByGroupByQg(startTime, "fan_health_index_hour", "pv_health_index_hour", "片区");
List<IdxBizFanHealthLevel> levelListQg = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "全域").last("limit 4")); List<IdxBizFanHealthLevel> levelListQg = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "全域").last("limit 4"));
List<FanHealthIndex> fanHealthIndicesQg = fanHealthIndexService.getInfoListByGroupByQgFan(startTime, "fan_health_index_hour", "片区"); List<FanHealthIndex> fanHealthIndicesQg = healthIndexQgDTOS.stream().map(o -> fanHealthIndexService.toFanHealthIndex(o)).collect(Collectors.toList());
saveBatchFan(fanHealthIndicesQg, "fan_health_index_day", recDate, WarningPeriodEnum.DAY.getName(), levelListQg); saveBatchFan(fanHealthIndicesQg, "fan_health_index_day", recDate, WarningPeriodEnum.DAY.getName(), levelListQg);
// 全域【所有 / 全国】
List<IdxBizPvHealthLevel> pvLevelListQg = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "全域").last("limit 4"));
List<PvHealthIndex> pvHealthIndicesQg = healthIndexQgDTOS.stream().map(o -> fanHealthIndexService.toPvHealthIndex(o)).collect(Collectors.toList());
saveBatchPv(pvHealthIndicesQg, "pv_health_index_day", recDate, WarningPeriodEnum.DAY.getName(), pvLevelListQg);
//预警生成 //预警生成
healthStatusIndicatorServiceImpl.healthWarningDay(); healthStatusIndicatorServiceImpl.healthWarningDay();
//预警生成
healthStatusIndicatorServiceImpl.healthWarningDayGF();
} }
...@@ -249,7 +314,7 @@ public class TdengineTimeServiceImpl { ...@@ -249,7 +314,7 @@ public class TdengineTimeServiceImpl {
/** /**
* 光伏 - 按小时生成 测点、设备、子阵、场站和片区数据 * 光伏 - 按小时生成 测点、设备、子阵、场站和片区数据
*/ */
@Scheduled(cron = "0 0 0/1 * * ? ") // @Scheduled(cron = "0 0 0/1 * * ? ")
public void insertHourDataPv() throws ParseException { public void insertHourDataPv() throws ParseException {
if (!openHealth) { if (!openHealth) {
return; return;
...@@ -290,7 +355,7 @@ public class TdengineTimeServiceImpl { ...@@ -290,7 +355,7 @@ public class TdengineTimeServiceImpl {
/** /**
* 光伏 - 按天生成 测点、设备、子阵、场站和片区数据 * 光伏 - 按天生成 测点、设备、子阵、场站和片区数据
*/ */
@Scheduled(cron = "0 05 0 1/1 * ? ") // @Scheduled(cron = "0 05 0 1/1 * ? ")
public void insertDayDataPv() throws ParseException { public void insertDayDataPv() throws ParseException {
if (!openHealth) { if (!openHealth) {
return; return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment