Commit 39aaa9b3 authored by yangyang's avatar yangyang

智慧分析 - 健康等级 片区/全国计算调整

parent d86c5abe
......@@ -211,7 +211,10 @@ public class TestController extends BaseController {
time = DateUtil.offsetMinute(time, -DateUtil.minute(time) % 10);
String format = DateUtil.format(time, "yyyy-MM-dd HH:mm:00");
time = DateUtil.parse(format, "yyyy-MM-dd HH:mm:00");
tdengineTimeService.insertMomentDataPvTest("2024-07-25 08:00:00");
// tdengineTimeService.insertMomentDataPvTest("2024-07-24 08:00:00");
//区域 全域最后统一生成
tdengineTimeService.insertMomentDataAllTest("2024-07-24 08:00:00");
} catch (Exception e) {
e.printStackTrace();
}
......
......@@ -90,8 +90,34 @@ public interface IFanHealthIndexService {
*/
List<FanHealthIndex> getInfoListByGroupByQgFan(String startTime, String tableName, String analysisObjectType);
/**
* 光伏 & 风电加权平均计算 :区域
*
*
* @param startTime startTime
* @param fanTableName fanTableName
* @param pvTableName pvTableName
* @param analysisObjectType analysisObjectType
* @return {@link List< HealthIndexDTO>}
* @author yangyang
* @throws
* @date 2024/7/25 14:01
*/
List<HealthIndexDTO> getInfoListByGroupByQy(String startTime, String fanTableName, String pvTableName, String analysisObjectType);
/**
* 光伏 & 风电加权平均计算 :全域【所有 / 全国】
*
*
* @param startTime startTime
* @param fanTableName fanTableName
* @param pvTableName pvTableName
* @param analysisObjectType analysisObjectType
* @return {@link List< HealthIndexDTO>}
* @author yangyang
* @throws
* @date 2024/7/25 14:01
*/
List<HealthIndexDTO> getInfoListByGroupByQg(String startTime, String fanTableName, String pvTableName, String analysisObjectType);
FanHealthIndex toFanHealthIndex(HealthIndexDTO healthIndex);
......
......@@ -380,7 +380,7 @@ public class FanHealthIndexServiceImpl implements IFanHealthIndexService {
weightMap.putAll(fanWeightMap);
weightMap.putAll(pvWeightMap);
// 开始计算加权平均
Map<String, List<HealthIndexDTO>> fanHealthIndicesZxtMap = healthIndexDTOS.stream().collect(Collectors.groupingBy(o -> o.getAnalysisObjType() + o.getArea() + o.getOrgCode()));
Map<String, List<HealthIndexDTO>> fanHealthIndicesZxtMap = healthIndexDTOS.stream().collect(Collectors.groupingBy(o -> o.getAnalysisObjType() + o.getArea()));
List<HealthIndexDTO> fanHealthIndicesZxtNews = new ArrayList<>();
fanHealthIndicesZxtMap.forEach((k, v) -> {
HealthIndexDTO healthIndex = new HealthIndexDTO();
......@@ -426,7 +426,7 @@ public class FanHealthIndexServiceImpl implements IFanHealthIndexService {
weightMap.putAll(pvWeightMap);
// 开始计算加权平均
Map<String, List<HealthIndexDTO>> fanHealthIndicesZxtMap = healthIndexDTOS.stream().collect(Collectors.groupingBy(o -> o.getAnalysisObjType() + o.getOrgCode()));
Map<String, List<HealthIndexDTO>> fanHealthIndicesZxtMap = healthIndexDTOS.stream().collect(Collectors.groupingBy(o -> o.getAnalysisObjType()));
List<HealthIndexDTO> fanHealthIndicesZxtNews = new ArrayList<>();
fanHealthIndicesZxtMap.forEach((k, v) -> {
HealthIndexDTO healthIndex = new HealthIndexDTO();
......@@ -475,8 +475,8 @@ public class FanHealthIndexServiceImpl implements IFanHealthIndexService {
public Double getWeight(Supplier<String> key, Map<String, Float> weightMap) {
Float weight = weightMap.get(key.get());
if (weight == null) {
log.error("计算加权平均异常【" + key.get() + "】没有配置测点权重");
throw new RuntimeException("【" + key.get() + "】没有配置测点权重");
log.error("计算加权平均异常【" + key.get() + "】未配置权重");
throw new RuntimeException("【" + key.get() + "】未配置权重");
}
return weight.doubleValue();
}
......
......@@ -162,7 +162,7 @@ public class PvHealthIndexServiceImpl implements IPvHealthIndexService {
String analysisObjectType) {
List<PvHealthIndex> pvHealthIndices = pvHealthIndexMapper.getInfoList(startTime, tableName, analysisObjectType);
QueryWrapper<IdxBizPvWeight> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("type", "4");
queryWrapper.eq("type", "3");
queryWrapper.isNotNull("value");
List<IdxBizPvWeight> idxBizFanWeights = idxBizPvWeightMapper.selectList(queryWrapper);
Map<String, Float> weightMap = idxBizFanWeights.stream().collect(Collectors.toMap(o -> o.getArae() + o.getStation() + o.getEquipmentName() + o.getSubarray(), IdxBizPvWeight::getValue));
......@@ -218,7 +218,7 @@ public class PvHealthIndexServiceImpl implements IPvHealthIndexService {
String analysisObjectType) {
List<PvHealthIndex> pvHealthIndices = pvHealthIndexMapper.getInfoList(startTime, tableName, analysisObjectType);
QueryWrapper<IdxBizPvWeight> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("type", "3");
queryWrapper.eq("type", "4");
queryWrapper.isNotNull("value");
List<IdxBizPvWeight> idxBizFanWeights = idxBizPvWeightMapper.selectList(queryWrapper);
Map<String, Float> weightMap = idxBizFanWeights.stream().collect(Collectors.toMap(o -> o.getArae() + o.getStation() + o.getEquipmentName(), IdxBizPvWeight::getValue));
......@@ -371,8 +371,8 @@ public class PvHealthIndexServiceImpl implements IPvHealthIndexService {
public Double getWeight(Supplier<String> key, Map<String, Float> weightMap) {
Float weight = weightMap.get(key.get());
if (weight == null) {
log.error("计算加权平均异常【" + key.get() + "】没有配置测点权重");
throw new RuntimeException("没有配置测点权重");
log.error("计算加权平均异常【" + key.get() + "】未配置权重");
throw new RuntimeException("未配置权重");
}
return weight.doubleValue();
}
......
......@@ -443,14 +443,6 @@ public class TdengineTimeServiceImpl {
List<FanHealthIndex> fanHealthIndicesCz = fanHealthIndexMapper.getInfoListByGroupByCzFan(startTime, "fan_health_index_moment", "设备");
List<FanHealthIndex> fanHealthIndicesCzNew = fanHealthIndexService.getInfoListByGroupByCzFan(startTime, "fan_health_index_moment", "设备");
print("场站", fanHealthIndicesCz, fanHealthIndicesCzNew);
// 区域
List<FanHealthIndex> fanHealthIndicesQy = fanHealthIndexMapper.getInfoListByGroupByQyFan(startTime, "fan_health_index_moment", "场站");
List<FanHealthIndex> fanHealthIndicesQyNew = fanHealthIndexService.getInfoListByGroupByQyFan(startTime, "fan_health_index_moment", "场站");
print("区域", fanHealthIndicesQy, fanHealthIndicesQyNew);
// 全域【所有 / 全国】
List<FanHealthIndex> fanHealthIndicesQg = fanHealthIndexMapper.getInfoListByGroupByQgFan(startTime, "fan_health_index_moment", "片区");
List<FanHealthIndex> fanHealthIndicesQgNew = fanHealthIndexService.getInfoListByGroupByQgFan(startTime, "fan_health_index_moment", "片区");
print("全域", fanHealthIndicesQg, fanHealthIndicesQgNew);
}
public void insertMomentDataPvTest(String startTime) throws ParseException {
......@@ -466,15 +458,6 @@ public class TdengineTimeServiceImpl {
List<PvHealthIndex> fanHealthIndicesCz = pvHealthIndexMapper.getInfoListByGroupByCzPv(startTime, "pv_health_index_moment", "子阵");
List<PvHealthIndex> fanHealthIndicesCzNew = pvHealthIndexService.getInfoListByGroupByCzPv(startTime, "pv_health_index_moment", "子阵");
printPv("场站", fanHealthIndicesCz, fanHealthIndicesCzNew);
// 片区
List<PvHealthIndex> fanHealthIndicesQy = pvHealthIndexMapper.getInfoListByGroupByQyPv(startTime, "pv_health_index_moment", "场站");
List<PvHealthIndex> fanHealthIndicesQyNew = pvHealthIndexService.getInfoListByGroupByQyPv(startTime, "pv_health_index_moment", "场站");
printPv("片区", fanHealthIndicesQy, fanHealthIndicesQyNew);
// 全域【所有 / 全国】
List<PvHealthIndex> fanHealthIndicesQg = pvHealthIndexMapper.getInfoListByGroupByQgPv(startTime, "pv_health_index_moment", "片区");
List<PvHealthIndex> fanHealthIndicesQgNew = pvHealthIndexService.getInfoListByGroupByQgPv(startTime, "pv_health_index_moment", "片区");
printPv("全域", fanHealthIndicesQg, fanHealthIndicesQgNew);
}
public void print(String desc, List<FanHealthIndex> olds, List<FanHealthIndex> news) {
......@@ -485,10 +468,14 @@ public class TdengineTimeServiceImpl {
}
public void printPv(String desc, List<PvHealthIndex> olds, List<PvHealthIndex> news) {
olds.sort(Comparator.comparing(PvHealthIndex::getArea).thenComparing(PvHealthIndex::getStation).thenComparing(PvHealthIndex::getEquipmentName).thenComparing(PvHealthIndex::getSubarray).thenComparing(PvHealthIndex::getPointName));
news.sort(Comparator.comparing(PvHealthIndex::getArea).thenComparing(PvHealthIndex::getStation).thenComparing(PvHealthIndex::getEquipmentName).thenComparing(PvHealthIndex::getSubarray).thenComparing(PvHealthIndex::getPointName));
log.info("对比{} old => {}", desc, olds);
log.info("对比{} news => {}", desc, news);
try {
olds.sort(Comparator.comparing(PvHealthIndex::getArea).thenComparing(PvHealthIndex::getStation).thenComparing(PvHealthIndex::getEquipmentName).thenComparing(PvHealthIndex::getSubarray).thenComparing(PvHealthIndex::getPointName));
news.sort(Comparator.comparing(PvHealthIndex::getArea).thenComparing(PvHealthIndex::getStation).thenComparing(PvHealthIndex::getEquipmentName).thenComparing(PvHealthIndex::getSubarray).thenComparing(PvHealthIndex::getPointName));
log.info("对比{} old => {}", desc, olds);
log.info("对比{} news => {}", desc, news);
} catch (Exception e) {
e.printStackTrace();
}
}
public void insertMomentDataAll(String recDate) throws ParseException {
......@@ -518,4 +505,16 @@ public class TdengineTimeServiceImpl {
List<PvHealthIndex> pvHealthIndicesQg = healthIndexQgDTOS.stream().map(o -> fanHealthIndexService.toPvHealthIndex(o)).collect(Collectors.toList());
saveBatchPv(pvHealthIndicesQg, "pv_health_index_moment", recDate, WarningPeriodEnum.MINUTES.getName(), pvLevelListQg);
}
public void insertMomentDataAllTest(String startTime) throws ParseException {
List<HealthIndexDTO> healthIndexQyDTOS = fanHealthIndexService.getInfoListByGroupByQy(startTime,"fan_health_index_moment", "pv_health_index_moment","场站");
List<FanHealthIndex> fanHealthIndicesQy = healthIndexQyDTOS.stream().map(o -> fanHealthIndexService.toFanHealthIndex(o)).collect(Collectors.toList());
List<PvHealthIndex> pvHealthIndicesQy = healthIndexQyDTOS.stream().map(o -> fanHealthIndexService.toPvHealthIndex(o)).collect(Collectors.toList());
log.info("场站 => {}", healthIndexQyDTOS);
List<HealthIndexDTO> healthIndexQgDTOS = fanHealthIndexService.getInfoListByGroupByQg(startTime, "fan_health_index_moment", "pv_health_index_moment", "片区");
List<FanHealthIndex> fanHealthIndicesQg = healthIndexQgDTOS.stream().map(o -> fanHealthIndexService.toFanHealthIndex(o)).collect(Collectors.toList());
List<PvHealthIndex> pvHealthIndicesQg = healthIndexQgDTOS.stream().map(o -> fanHealthIndexService.toPvHealthIndex(o)).collect(Collectors.toList());
log.info("片区 => {}", healthIndexQgDTOS);
}
}
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