feat(topology): 添加拓扑图目标指标功能并重构数据处理逻辑

- 在AppLineTopologyDiagram相关类中添加target字段用于绑定指标
- 重构DeviceMessageClient的getLineInfo方法参数结构
- 实现CsLineTopologyFeignClient的queryTopologyDiagram接口及降级处理
- 更新MqttMessageHandler中拓扑图数据处理逻辑,支持自定义指标查询
- 添加PqdData数据拆分服务IPqdDataSplitService及其实现
- 优化PortableOfflLogServiceImpl中的数据入库逻辑
- 修复CsTerminalReplyServiceImpl中时间范围查询条件
- 移除未使用的导入和代码,优化服务依赖注入
This commit is contained in:
xy
2026-05-25 14:38:35 +08:00
parent 1d8d714d66
commit ea2962840c
17 changed files with 1079 additions and 453 deletions

View File

@@ -125,7 +125,7 @@ public class TestController {
collect.forEach((tempPhase,byNameMap)->{
//最小值
InfluxQueryWrapper influxQueryWrapperMin = new InfluxQueryWrapper(PqdData.class, clazz);
influxQueryWrapperMin.regular(PqdData::getLineId, lineIndex).eq(InfluxDBTableConstant.VALUE_TYPE, "min")
influxQueryWrapperMin.regular(PqdData::getLineId, lineIndex).eq(InfluxDBTableConstant.VALUE_TYPE, "MIN")
.eq(InfluxDBTableConstant.PHASIC_TYPE,tempPhase);
// .eq(InfluxDBTableConstant.IS_ABNORMAL, 0);
@@ -156,7 +156,7 @@ public class TestController {
//最大值
InfluxQueryWrapper influxQueryWrapperMax = new InfluxQueryWrapper(PqdData.class, clazz);
influxQueryWrapperMax.regular(PqdData::getLineId, lineIndex).eq(InfluxDBTableConstant.VALUE_TYPE, "max")
influxQueryWrapperMax.regular(PqdData::getLineId, lineIndex).eq(InfluxDBTableConstant.VALUE_TYPE, "MAX")
.eq(InfluxDBTableConstant.PHASIC_TYPE,tempPhase);
// .eq(InfluxDBTableConstant.IS_ABNORMAL, 0);
@@ -186,7 +186,7 @@ public class TestController {
//平均值
InfluxQueryWrapper influxQueryWrapperAvg = new InfluxQueryWrapper(PqdData.class, clazz);
influxQueryWrapperAvg.regular(PqdData::getLineId, lineIndex).eq(InfluxDBTableConstant.VALUE_TYPE, "avg")
influxQueryWrapperAvg.regular(PqdData::getLineId, lineIndex).eq(InfluxDBTableConstant.VALUE_TYPE, "AVG")
.eq(InfluxDBTableConstant.PHASIC_TYPE,tempPhase);
// .eq(InfluxDBTableConstant.IS_ABNORMAL, 0);
@@ -216,7 +216,7 @@ public class TestController {
//CP95
InfluxQueryWrapper influxQueryWrapperCp95 = new InfluxQueryWrapper(PqdData.class, clazz);
influxQueryWrapperCp95.regular(PqdData::getLineId, lineIndex).eq(InfluxDBTableConstant.VALUE_TYPE, "avg")
influxQueryWrapperCp95.regular(PqdData::getLineId, lineIndex).eq(InfluxDBTableConstant.VALUE_TYPE, "AVG")
.eq(InfluxDBTableConstant.PHASIC_TYPE,tempPhase);
// .eq(InfluxDBTableConstant.IS_ABNORMAL, 0);

View File

@@ -1,348 +1,348 @@
package com.njcn.csreport.job;
import cn.hutool.extra.spring.SpringUtil;
import com.github.jeffreyning.mybatisplus.service.IMppService;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.utils.HarmonicTimesUtil;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csdevice.api.CsLedgerFeignClient;
import com.njcn.csdevice.pojo.dto.LineParamDTO;
import com.njcn.csdevice.pojo.po.CsLedger;
import com.njcn.csreport.enums.ReportTableEnum;
import com.njcn.csreport.service.RStatDataVDService;
import com.njcn.influx.constant.InfluxDbSqlConstant;
import com.njcn.influx.imapper.CommonMapper;
import com.njcn.influx.imapper.PqdDataMapper;
import com.njcn.influx.imapper.day.GovernReportMapper;
import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
import com.njcn.influx.pojo.po.DataV;
import com.njcn.influx.pojo.po.cs.PqdData;
import com.njcn.influx.query.InfluxQueryWrapper;
import com.njcn.system.api.CsStatisticalSetFeignClient;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.api.EpdFeignClient;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.pojo.po.DictData;
import com.njcn.system.pojo.po.EleEpdPqd;
import com.njcn.system.pojo.vo.EleEpdPqdListVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.lang.reflect.Field;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* Description:
* Date: 2024/1/18 10:15【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Component
@EnableScheduling
@RequiredArgsConstructor
@Slf4j
public class ReportCovertJob {
private final CsLedgerFeignClient csLedgerFeignClient;
private final DicDataFeignClient dicDataFeignClient;
private final EpdFeignClient epdFeignClient;
private final GovernReportMapper reportMapper;
private final RStatDataVDService rStatDataVDService;
private final static String SERVICE_PACKAGE_PREFIX = "com.njcn.csreport.service.";
private final static String ENTITY_PACKAGE_PREFIX = "com.njcn.csreport.pojo.po.";
private final static String SERVICE_SUFFIX = "Service";
/**
* 每天同步influxdb数据到mysql
*
* @date 2024/3/5
*/
@Scheduled(cron = "0 0 1 * * ? ")
public void executeEvent() throws ClassNotFoundException {
DateTimeFormatter formatter1 = DateTimeFormatter.ISO_DATE;
// 获取当前日期
LocalDate today = LocalDate.now();
// 计算前一天的日期
LocalDate yesterday = today.minusDays(1);
// 获取前一天的开始时间00:00:00
LocalDateTime startOfYesterday = yesterday.atStartOfDay();
// 获取前一天的结束时间23:59:59
LocalDateTime endOfYesterday = yesterday.plusDays(1).atStartOfDay().minusSeconds(1);
// 定义时间格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
// 格式化时间为字符串
String startTime = startOfYesterday.format(formatter);
String endTime = endOfYesterday.format(formatter);
// String startTime ="2024-07-31 00:00:00";
// String endTime ="2024-09-20 23:00:00";
List<CsLedger> data = csLedgerFeignClient.queryLine(new LineParamDTO()).getData();
List<String> lineIndex = data.stream().map(CsLedger::getId).collect(Collectors.toList());
// List<String> lineIndex = Stream.of("00B78D016AB32","00B78D016AB51").collect(Collectors.toList());
//查询电能质量数据指标
DictData pqd = dicDataFeignClient.getDicDataByCode(DicDataEnum.PQD.getCode()).getData();
List<DictData> tableNameList = dicDataFeignClient.getDicDataByTypeCode("Data_Day").getData();
Map<String, String> tableMap = tableNameList.stream().collect(Collectors.toMap(DictData::getId, DictData::getCode, (code, code2) -> code));
List<EleEpdPqdListVO> eleEpdPqdListVOList = epdFeignClient.selectAll().getData();
EleEpdPqdListVO eleEpdPqdListVO = eleEpdPqdListVOList.stream().filter(temp -> Objects.equals(temp.getDataType(), pqd.getId())).collect(Collectors.toList()).get(0);
Map<String, List<EleEpdPqd>> eleEpdMap = eleEpdPqdListVO.getEleEpdPqdVOS().stream().filter(temp -> StringUtils.isNotEmpty(temp.getOtherName())
&& StringUtils.isNotEmpty(temp.getResourcesId()))
.collect(Collectors.groupingBy(EleEpdPqd::getResourcesId));//不能全表表分组查,根据映射的
for (Map.Entry<String, List<EleEpdPqd>> entry : eleEpdMap.entrySet()) {
String k = entry.getKey();
List<EleEpdPqd> v = entry.getValue();
String tableName = tableMap.get(k);
List result = new ArrayList<>();
Class clazz = Class.forName(ENTITY_PACKAGE_PREFIX + ReportTableEnum.getEntityName(tableName));
IMppService bean = (IMppService) SpringUtil.getBean(Class.forName(SERVICE_PACKAGE_PREFIX+ReportTableEnum.getEntityName(tableName)+SERVICE_SUFFIX));
//由于epd配置表ABC三项对应指标一样这里做去重处理由于功率表功率和三项总功率都对应P只是项别不一一样因此M相要和,A,B,C相分开计算
Map<String, Map<String, List<EleEpdPqd>>> collect = v.stream().collect(Collectors.groupingBy(EleEpdPqd::getPhase, Collectors.groupingBy(EleEpdPqd::getName)));
collect.forEach((tempPhase,byNameMap)->{
//最小值
InfluxQueryWrapper influxQueryWrapperMin = new InfluxQueryWrapper(PqdData.class, clazz);
influxQueryWrapperMin.regular(PqdData::getLineId, lineIndex).eq(InfluxDBTableConstant.VALUE_TYPE, "min")
.eq(InfluxDBTableConstant.PHASIC_TYPE,tempPhase);
// .eq(InfluxDBTableConstant.IS_ABNORMAL, 0);
byNameMap.forEach((name, eleEpdPqdList) -> {
EleEpdPqd tempEleEpdPqd = eleEpdPqdList.get(0);
if (Objects.nonNull(tempEleEpdPqd.getHarmStart()) && Objects.nonNull(tempEleEpdPqd.getHarmEnd())) {
//0-49转成1-50
if(tempEleEpdPqd.getHarmStart()==0){
tempEleEpdPqd.setHarmStart(tempEleEpdPqd.getHarmStart()+1);
tempEleEpdPqd.setHarmEnd(tempEleEpdPqd.getHarmEnd()+1);
}
for (int i = tempEleEpdPqd.getHarmStart(); i < tempEleEpdPqd.getHarmEnd() + 1; i++) {
influxQueryWrapperMin.min(tempEleEpdPqd.getName() + "_" + i, tempEleEpdPqd.getOtherName() + "_" + i);
}
} else {
influxQueryWrapperMin.min(tempEleEpdPqd.getName(), tempEleEpdPqd.getOtherName());
}
});
influxQueryWrapperMin.groupBy(InfluxDBTableConstant.LINE_ID)
.groupBy(InfluxDBTableConstant.PHASIC_TYPE)
.groupBy(InfluxDBTableConstant.VALUE_TYPE)
.between(InfluxDBTableConstant.TIME, startTime, endTime);
List list1 = reportMapper.selectByQueryWrapper(influxQueryWrapperMin);
//最大值
InfluxQueryWrapper influxQueryWrapperMax = new InfluxQueryWrapper(PqdData.class, clazz);
influxQueryWrapperMax.regular(PqdData::getLineId, lineIndex).eq(InfluxDBTableConstant.VALUE_TYPE, "max")
.eq(InfluxDBTableConstant.PHASIC_TYPE,tempPhase);
// .eq(InfluxDBTableConstant.IS_ABNORMAL, 0);
byNameMap.forEach((name, eleEpdPqdList) -> {
EleEpdPqd tempEleEpdPqd = eleEpdPqdList.get(0);
if (Objects.nonNull(tempEleEpdPqd.getHarmStart()) && Objects.nonNull(tempEleEpdPqd.getHarmEnd())) {
//0-49转成1-50
if(tempEleEpdPqd.getHarmStart()==0){
tempEleEpdPqd.setHarmStart(tempEleEpdPqd.getHarmStart()+1);
tempEleEpdPqd.setHarmEnd(tempEleEpdPqd.getHarmEnd()+1);
}
for (int i = tempEleEpdPqd.getHarmStart(); i < tempEleEpdPqd.getHarmEnd() + 1; i++) {
influxQueryWrapperMax.max(tempEleEpdPqd.getName() + "_" + i, tempEleEpdPqd.getOtherName() + "_" + i);
}
} else {
influxQueryWrapperMax.max(tempEleEpdPqd.getName(), tempEleEpdPqd.getOtherName());
}
});
influxQueryWrapperMax.groupBy(InfluxDBTableConstant.LINE_ID)
.groupBy(InfluxDBTableConstant.PHASIC_TYPE)
.groupBy(InfluxDBTableConstant.VALUE_TYPE)
.between(InfluxDBTableConstant.TIME, startTime, endTime);
List list2 = reportMapper.selectByQueryWrapper(influxQueryWrapperMax);
//平均值
InfluxQueryWrapper influxQueryWrapperAvg = new InfluxQueryWrapper(PqdData.class, clazz);
influxQueryWrapperAvg.regular(PqdData::getLineId, lineIndex).eq(InfluxDBTableConstant.VALUE_TYPE, "avg")
.eq(InfluxDBTableConstant.PHASIC_TYPE,tempPhase);
// .eq(InfluxDBTableConstant.IS_ABNORMAL, 0);
byNameMap.forEach((name, eleEpdPqdList) -> {
EleEpdPqd tempEleEpdPqd = eleEpdPqdList.get(0);
if (Objects.nonNull(tempEleEpdPqd.getHarmStart()) && Objects.nonNull(tempEleEpdPqd.getHarmEnd())) {
//0-49转成1-50
if(tempEleEpdPqd.getHarmStart()==0){
tempEleEpdPqd.setHarmStart(tempEleEpdPqd.getHarmStart()+1);
tempEleEpdPqd.setHarmEnd(tempEleEpdPqd.getHarmEnd()+1);
}
for (int i = tempEleEpdPqd.getHarmStart(); i < tempEleEpdPqd.getHarmEnd() + 1; i++) {
influxQueryWrapperAvg.mean(tempEleEpdPqd.getName() + "_" + i, tempEleEpdPqd.getOtherName() + "_" + i);
}
} else {
influxQueryWrapperAvg.mean(tempEleEpdPqd.getName(), tempEleEpdPqd.getOtherName());
}
});
influxQueryWrapperAvg.groupBy(InfluxDBTableConstant.LINE_ID)
.groupBy(InfluxDBTableConstant.PHASIC_TYPE)
.groupBy(InfluxDBTableConstant.VALUE_TYPE)
.between(InfluxDBTableConstant.TIME, startTime, endTime);
List list3 = reportMapper.selectByQueryWrapper(influxQueryWrapperAvg);
//CP95
InfluxQueryWrapper influxQueryWrapperCp95 = new InfluxQueryWrapper(PqdData.class, clazz);
influxQueryWrapperCp95.regular(PqdData::getLineId, lineIndex).eq(InfluxDBTableConstant.VALUE_TYPE, "avg")
.eq(InfluxDBTableConstant.PHASIC_TYPE,tempPhase);
// .eq(InfluxDBTableConstant.IS_ABNORMAL, 0);
byNameMap.forEach((name, eleEpdPqdList) -> {
EleEpdPqd tempEleEpdPqd = eleEpdPqdList.get(0);
if (Objects.nonNull(tempEleEpdPqd.getHarmStart()) && Objects.nonNull(tempEleEpdPqd.getHarmEnd())) {
//0-49转成1-50
if(tempEleEpdPqd.getHarmStart()==0){
tempEleEpdPqd.setHarmStart(tempEleEpdPqd.getHarmStart()+1);
tempEleEpdPqd.setHarmEnd(tempEleEpdPqd.getHarmEnd()+1);
}
for (int i = tempEleEpdPqd.getHarmStart(); i < tempEleEpdPqd.getHarmEnd() + 1; i++) {
influxQueryWrapperCp95.percentile(tempEleEpdPqd.getName() + "_" + i, tempEleEpdPqd.getOtherName() + "_" + i, 95);
}
} else {
influxQueryWrapperCp95.percentile(tempEleEpdPqd.getName(), tempEleEpdPqd.getOtherName(),95);
}
});
influxQueryWrapperCp95.groupBy(InfluxDBTableConstant.LINE_ID)
.groupBy(InfluxDBTableConstant.PHASIC_TYPE)
.groupBy(InfluxDBTableConstant.VALUE_TYPE)
.between(InfluxDBTableConstant.TIME, startTime, endTime);
List list4 = reportMapper.selectByQueryWrapper(influxQueryWrapperCp95);
//为ValueType转成cp95
list4.forEach(temp -> {
//获取
Field vauleField = null;
try {
vauleField = temp.getClass().getDeclaredField("valueType");
vauleField.setAccessible(true); //暴力访问id
vauleField.set(temp, "CP95");
} catch (NoSuchFieldException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
});
result.addAll(list1);
result.addAll(list2);
result.addAll(list3);
result.addAll(list4);
} );
//1.为time赋值2.映射
result.forEach(temp -> {
//获取
Field phasicTypeeField = null;
Field timeField = null;
Field vauleTypeField = null;
Field qualityFlagField = null;
try {
timeField = temp.getClass().getDeclaredField("time");
timeField.setAccessible(true);
timeField.set(temp, yesterday);
phasicTypeeField = temp.getClass().getDeclaredField("phasicType");
phasicTypeeField.setAccessible(true);
String phase = phasicTypeeField.get(temp).toString();
phasicTypeeField.set(temp, getPhase(phase));
vauleTypeField = temp.getClass().getDeclaredField("valueType");
vauleTypeField.setAccessible(true);
String valueType = vauleTypeField.get(temp).toString();
vauleTypeField.set(temp, valueType.toUpperCase());
qualityFlagField = temp.getClass().getDeclaredField("qualityFlag");
qualityFlagField.setAccessible(true);
qualityFlagField.set(temp, 0);
} catch (NoSuchFieldException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
});
log.info("插入数据");
//由于ABA对应的都是A不能批量插入会爆主键冲突
result.forEach(temp->{
bean.saveOrUpdateByMultiId(temp);
});
}
}
public String getPhase( String phase) {
switch (phase) {
case "A":
return "A";
case "B":
return "B";
case "C":
return "C";
case "M":
return "T";
case "AB":
return "A";
case "BC":
return "B";
case "CA":
return "C";
default:
break;
}
return "";
}
}
//package com.njcn.csreport.job;
//
//import cn.hutool.extra.spring.SpringUtil;
//import com.github.jeffreyning.mybatisplus.service.IMppService;
//import com.njcn.common.pojo.enums.response.CommonResponseEnum;
//import com.njcn.common.utils.HarmonicTimesUtil;
//import com.njcn.common.utils.HttpResultUtil;
//import com.njcn.csdevice.api.CsLedgerFeignClient;
//import com.njcn.csdevice.pojo.dto.LineParamDTO;
//import com.njcn.csdevice.pojo.po.CsLedger;
//
//import com.njcn.csreport.enums.ReportTableEnum;
//import com.njcn.csreport.service.RStatDataVDService;
//import com.njcn.influx.constant.InfluxDbSqlConstant;
//import com.njcn.influx.imapper.CommonMapper;
//import com.njcn.influx.imapper.PqdDataMapper;
//import com.njcn.influx.imapper.day.GovernReportMapper;
//import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
//import com.njcn.influx.pojo.po.DataV;
//import com.njcn.influx.pojo.po.cs.PqdData;
//import com.njcn.influx.query.InfluxQueryWrapper;
//import com.njcn.system.api.CsStatisticalSetFeignClient;
//import com.njcn.system.api.DicDataFeignClient;
//
//import com.njcn.system.api.EpdFeignClient;
//import com.njcn.system.enums.DicDataEnum;
//import com.njcn.system.pojo.po.DictData;
//import com.njcn.system.pojo.po.EleEpdPqd;
//import com.njcn.system.pojo.vo.EleEpdPqdListVO;
//import lombok.RequiredArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.scheduling.annotation.EnableScheduling;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//
//import java.lang.reflect.Field;
//import java.time.LocalDate;
//import java.time.LocalDateTime;
//import java.time.format.DateTimeFormatter;
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Map;
//import java.util.Objects;
//import java.util.stream.Collectors;
//
///**
// * Description:
// * Date: 2024/1/18 10:15【需求编号】
// *
// * @author clam
// * @version V1.0.0
// */
//@Component
//@EnableScheduling
//@RequiredArgsConstructor
//@Slf4j
//public class ReportCovertJob {
//
// private final CsLedgerFeignClient csLedgerFeignClient;
// private final DicDataFeignClient dicDataFeignClient;
// private final EpdFeignClient epdFeignClient;
// private final GovernReportMapper reportMapper;
// private final RStatDataVDService rStatDataVDService;
//
// private final static String SERVICE_PACKAGE_PREFIX = "com.njcn.csreport.service.";
// private final static String ENTITY_PACKAGE_PREFIX = "com.njcn.csreport.pojo.po.";
// private final static String SERVICE_SUFFIX = "Service";
//
//
// /**
// * 每天同步influxdb数据到mysql
// *
// * @date 2024/3/5
// */
// @Scheduled(cron = "0 0 1 * * ? ")
// public void executeEvent() throws ClassNotFoundException {
// DateTimeFormatter formatter1 = DateTimeFormatter.ISO_DATE;
// // 获取当前日期
// LocalDate today = LocalDate.now();
//
//
// // 计算前一天的日期
// LocalDate yesterday = today.minusDays(1);
// // 获取前一天的开始时间00:00:00
// LocalDateTime startOfYesterday = yesterday.atStartOfDay();
// // 获取前一天的结束时间23:59:59
// LocalDateTime endOfYesterday = yesterday.plusDays(1).atStartOfDay().minusSeconds(1);
//
// // 定义时间格式
// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
//
// // 格式化时间为字符串
// String startTime = startOfYesterday.format(formatter);
// String endTime = endOfYesterday.format(formatter);
//// String startTime ="2024-07-31 00:00:00";
//// String endTime ="2024-09-20 23:00:00";
// List<CsLedger> data = csLedgerFeignClient.queryLine(new LineParamDTO()).getData();
// List<String> lineIndex = data.stream().map(CsLedger::getId).collect(Collectors.toList());
//// List<String> lineIndex = Stream.of("00B78D016AB32","00B78D016AB51").collect(Collectors.toList());
//
// //查询电能质量数据指标
// DictData pqd = dicDataFeignClient.getDicDataByCode(DicDataEnum.PQD.getCode()).getData();
// List<DictData> tableNameList = dicDataFeignClient.getDicDataByTypeCode("Data_Day").getData();
// Map<String, String> tableMap = tableNameList.stream().collect(Collectors.toMap(DictData::getId, DictData::getCode, (code, code2) -> code));
//
//
// List<EleEpdPqdListVO> eleEpdPqdListVOList = epdFeignClient.selectAll().getData();
// EleEpdPqdListVO eleEpdPqdListVO = eleEpdPqdListVOList.stream().filter(temp -> Objects.equals(temp.getDataType(), pqd.getId())).collect(Collectors.toList()).get(0);
//
//
// Map<String, List<EleEpdPqd>> eleEpdMap = eleEpdPqdListVO.getEleEpdPqdVOS().stream().filter(temp -> StringUtils.isNotEmpty(temp.getOtherName())
// && StringUtils.isNotEmpty(temp.getResourcesId()))
// .collect(Collectors.groupingBy(EleEpdPqd::getResourcesId));//不能全表表分组查,根据映射的
//
// for (Map.Entry<String, List<EleEpdPqd>> entry : eleEpdMap.entrySet()) {
// String k = entry.getKey();
// List<EleEpdPqd> v = entry.getValue();
// String tableName = tableMap.get(k);
// List result = new ArrayList<>();
// Class clazz = Class.forName(ENTITY_PACKAGE_PREFIX + ReportTableEnum.getEntityName(tableName));
// IMppService bean = (IMppService) SpringUtil.getBean(Class.forName(SERVICE_PACKAGE_PREFIX+ReportTableEnum.getEntityName(tableName)+SERVICE_SUFFIX));
//
// //由于epd配置表ABC三项对应指标一样这里做去重处理由于功率表功率和三项总功率都对应P只是项别不一一样因此M相要和,A,B,C相分开计算
// Map<String, Map<String, List<EleEpdPqd>>> collect = v.stream().collect(Collectors.groupingBy(EleEpdPqd::getPhase, Collectors.groupingBy(EleEpdPqd::getName)));
//
// collect.forEach((tempPhase,byNameMap)->{
// //最小值
// InfluxQueryWrapper influxQueryWrapperMin = new InfluxQueryWrapper(PqdData.class, clazz);
// influxQueryWrapperMin.regular(PqdData::getLineId, lineIndex).eq(InfluxDBTableConstant.VALUE_TYPE, "min")
// .eq(InfluxDBTableConstant.PHASIC_TYPE,tempPhase);
//// .eq(InfluxDBTableConstant.IS_ABNORMAL, 0);
//
//
// byNameMap.forEach((name, eleEpdPqdList) -> {
// EleEpdPqd tempEleEpdPqd = eleEpdPqdList.get(0);
// if (Objects.nonNull(tempEleEpdPqd.getHarmStart()) && Objects.nonNull(tempEleEpdPqd.getHarmEnd())) {
// //0-49转成1-50
// if(tempEleEpdPqd.getHarmStart()==0){
// tempEleEpdPqd.setHarmStart(tempEleEpdPqd.getHarmStart()+1);
// tempEleEpdPqd.setHarmEnd(tempEleEpdPqd.getHarmEnd()+1);
// }
// for (int i = tempEleEpdPqd.getHarmStart(); i < tempEleEpdPqd.getHarmEnd() + 1; i++) {
// influxQueryWrapperMin.min(tempEleEpdPqd.getName() + "_" + i, tempEleEpdPqd.getOtherName() + "_" + i);
// }
// } else {
// influxQueryWrapperMin.min(tempEleEpdPqd.getName(), tempEleEpdPqd.getOtherName());
// }
//
// });
//
// influxQueryWrapperMin.groupBy(InfluxDBTableConstant.LINE_ID)
// .groupBy(InfluxDBTableConstant.PHASIC_TYPE)
// .groupBy(InfluxDBTableConstant.VALUE_TYPE)
// .between(InfluxDBTableConstant.TIME, startTime, endTime);
// List list1 = reportMapper.selectByQueryWrapper(influxQueryWrapperMin);
//
//
// //最大值
// InfluxQueryWrapper influxQueryWrapperMax = new InfluxQueryWrapper(PqdData.class, clazz);
// influxQueryWrapperMax.regular(PqdData::getLineId, lineIndex).eq(InfluxDBTableConstant.VALUE_TYPE, "max")
// .eq(InfluxDBTableConstant.PHASIC_TYPE,tempPhase);
//// .eq(InfluxDBTableConstant.IS_ABNORMAL, 0);
//
//
// byNameMap.forEach((name, eleEpdPqdList) -> {
// EleEpdPqd tempEleEpdPqd = eleEpdPqdList.get(0);
// if (Objects.nonNull(tempEleEpdPqd.getHarmStart()) && Objects.nonNull(tempEleEpdPqd.getHarmEnd())) {
// //0-49转成1-50
// if(tempEleEpdPqd.getHarmStart()==0){
// tempEleEpdPqd.setHarmStart(tempEleEpdPqd.getHarmStart()+1);
// tempEleEpdPqd.setHarmEnd(tempEleEpdPqd.getHarmEnd()+1);
// }
// for (int i = tempEleEpdPqd.getHarmStart(); i < tempEleEpdPqd.getHarmEnd() + 1; i++) {
// influxQueryWrapperMax.max(tempEleEpdPqd.getName() + "_" + i, tempEleEpdPqd.getOtherName() + "_" + i);
// }
// } else {
// influxQueryWrapperMax.max(tempEleEpdPqd.getName(), tempEleEpdPqd.getOtherName());
// }
//
// });
//
// influxQueryWrapperMax.groupBy(InfluxDBTableConstant.LINE_ID)
// .groupBy(InfluxDBTableConstant.PHASIC_TYPE)
// .groupBy(InfluxDBTableConstant.VALUE_TYPE)
// .between(InfluxDBTableConstant.TIME, startTime, endTime);
// List list2 = reportMapper.selectByQueryWrapper(influxQueryWrapperMax);
//
// //平均值
// InfluxQueryWrapper influxQueryWrapperAvg = new InfluxQueryWrapper(PqdData.class, clazz);
// influxQueryWrapperAvg.regular(PqdData::getLineId, lineIndex).eq(InfluxDBTableConstant.VALUE_TYPE, "avg")
// .eq(InfluxDBTableConstant.PHASIC_TYPE,tempPhase);
//// .eq(InfluxDBTableConstant.IS_ABNORMAL, 0);
//
// byNameMap.forEach((name, eleEpdPqdList) -> {
// EleEpdPqd tempEleEpdPqd = eleEpdPqdList.get(0);
// if (Objects.nonNull(tempEleEpdPqd.getHarmStart()) && Objects.nonNull(tempEleEpdPqd.getHarmEnd())) {
// //0-49转成1-50
// if(tempEleEpdPqd.getHarmStart()==0){
// tempEleEpdPqd.setHarmStart(tempEleEpdPqd.getHarmStart()+1);
// tempEleEpdPqd.setHarmEnd(tempEleEpdPqd.getHarmEnd()+1);
// }
// for (int i = tempEleEpdPqd.getHarmStart(); i < tempEleEpdPqd.getHarmEnd() + 1; i++) {
// influxQueryWrapperAvg.mean(tempEleEpdPqd.getName() + "_" + i, tempEleEpdPqd.getOtherName() + "_" + i);
// }
// } else {
// influxQueryWrapperAvg.mean(tempEleEpdPqd.getName(), tempEleEpdPqd.getOtherName());
// }
//
// });
//
// influxQueryWrapperAvg.groupBy(InfluxDBTableConstant.LINE_ID)
// .groupBy(InfluxDBTableConstant.PHASIC_TYPE)
// .groupBy(InfluxDBTableConstant.VALUE_TYPE)
// .between(InfluxDBTableConstant.TIME, startTime, endTime);
// List list3 = reportMapper.selectByQueryWrapper(influxQueryWrapperAvg);
//
//
// //CP95
// InfluxQueryWrapper influxQueryWrapperCp95 = new InfluxQueryWrapper(PqdData.class, clazz);
// influxQueryWrapperCp95.regular(PqdData::getLineId, lineIndex).eq(InfluxDBTableConstant.VALUE_TYPE, "avg")
// .eq(InfluxDBTableConstant.PHASIC_TYPE,tempPhase);
//// .eq(InfluxDBTableConstant.IS_ABNORMAL, 0);
//
// byNameMap.forEach((name, eleEpdPqdList) -> {
// EleEpdPqd tempEleEpdPqd = eleEpdPqdList.get(0);
// if (Objects.nonNull(tempEleEpdPqd.getHarmStart()) && Objects.nonNull(tempEleEpdPqd.getHarmEnd())) {
// //0-49转成1-50
// if(tempEleEpdPqd.getHarmStart()==0){
// tempEleEpdPqd.setHarmStart(tempEleEpdPqd.getHarmStart()+1);
// tempEleEpdPqd.setHarmEnd(tempEleEpdPqd.getHarmEnd()+1);
// }
// for (int i = tempEleEpdPqd.getHarmStart(); i < tempEleEpdPqd.getHarmEnd() + 1; i++) {
// influxQueryWrapperCp95.percentile(tempEleEpdPqd.getName() + "_" + i, tempEleEpdPqd.getOtherName() + "_" + i, 95);
// }
// } else {
// influxQueryWrapperCp95.percentile(tempEleEpdPqd.getName(), tempEleEpdPqd.getOtherName(),95);
// }
//
// });
//
// influxQueryWrapperCp95.groupBy(InfluxDBTableConstant.LINE_ID)
// .groupBy(InfluxDBTableConstant.PHASIC_TYPE)
// .groupBy(InfluxDBTableConstant.VALUE_TYPE)
// .between(InfluxDBTableConstant.TIME, startTime, endTime);
// List list4 = reportMapper.selectByQueryWrapper(influxQueryWrapperCp95);
// //为ValueType转成cp95
// list4.forEach(temp -> {
// //获取
// Field vauleField = null;
// try {
// vauleField = temp.getClass().getDeclaredField("valueType");
//
// vauleField.setAccessible(true); //暴力访问id
// vauleField.set(temp, "CP95");
//
// } catch (NoSuchFieldException e) {
// throw new RuntimeException(e);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
//
//
// });
//
//
// result.addAll(list1);
// result.addAll(list2);
// result.addAll(list3);
// result.addAll(list4);
//
//
// } );
// //1.为time赋值2.映射
// result.forEach(temp -> {
// //获取
// Field phasicTypeeField = null;
// Field timeField = null;
// Field vauleTypeField = null;
// Field qualityFlagField = null;
//
// try {
//
// timeField = temp.getClass().getDeclaredField("time");
//
// timeField.setAccessible(true);
// timeField.set(temp, yesterday);
// phasicTypeeField = temp.getClass().getDeclaredField("phasicType");
// phasicTypeeField.setAccessible(true);
// String phase = phasicTypeeField.get(temp).toString();
// phasicTypeeField.set(temp, getPhase(phase));
//
//
// vauleTypeField = temp.getClass().getDeclaredField("valueType");
// vauleTypeField.setAccessible(true);
// String valueType = vauleTypeField.get(temp).toString();
// vauleTypeField.set(temp, valueType.toUpperCase());
//
// qualityFlagField = temp.getClass().getDeclaredField("qualityFlag");
//
// qualityFlagField.setAccessible(true);
// qualityFlagField.set(temp, 0);
//
// } catch (NoSuchFieldException e) {
// throw new RuntimeException(e);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
//
//
// });
// log.info("插入数据");
// //由于ABA对应的都是A不能批量插入会爆主键冲突
// result.forEach(temp->{
// bean.saveOrUpdateByMultiId(temp);
// });
//
//
// }
//
//
// }
//
// public String getPhase( String phase) {
//
// switch (phase) {
// case "A":
// return "A";
// case "B":
// return "B";
// case "C":
// return "C";
// case "M":
// return "T";
// case "AB":
// return "A";
// case "BC":
// return "B";
// case "CA":
// return "C";
// default:
// break;
// }
// return "";
// }
//
//
//}