预处理兼容pq/pms处理

This commit is contained in:
2023-09-21 15:34:38 +08:00
parent 511924fd75
commit 4e7da3a056
29 changed files with 280 additions and 55 deletions

View File

@@ -4,7 +4,6 @@ package com.njcn.harmonic.controller;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
@@ -15,11 +14,10 @@ import com.njcn.device.pms.pojo.po.Monitor;
import com.njcn.device.pq.api.DeviceUnitClient;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.biz.pojo.po.Overlimit;
import com.njcn.device.pq.pojo.po.PqsDeviceUnit;
import com.njcn.device.biz.pojo.po.PqsDeviceUnit;
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
import com.njcn.event.enums.EventResponseEnum;
import com.njcn.harmonic.pojo.param.ReportQueryParam;
import com.njcn.harmonic.pojo.po.ExcelRptTemp;
import com.njcn.harmonic.pojo.po.report.EnumPass;
import com.njcn.harmonic.pojo.po.report.OverLimitInfo;
import com.njcn.harmonic.pojo.po.report.Pass;

View File

@@ -13,7 +13,7 @@ import com.njcn.common.utils.FileUtil;
import com.njcn.device.pq.api.DeptLineFeignClient;
import com.njcn.device.pq.api.DeviceUnitClient;
import com.njcn.device.pq.pojo.po.DeptLine;
import com.njcn.device.pq.pojo.po.PqsDeviceUnit;
import com.njcn.device.biz.pojo.po.PqsDeviceUnit;
import com.njcn.harmonic.enums.HarmonicResponseEnum;
import com.njcn.harmonic.mapper.DeptTempMapper;
import com.njcn.harmonic.mapper.EleEpdMapper;

View File

@@ -9,11 +9,10 @@ import com.njcn.common.pojo.constant.BizParamConstant;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.param.StatisticsBizBaseParam;
import com.njcn.common.utils.PubUtils;
import com.njcn.device.pq.api.DeviceUnitClient;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
import com.njcn.device.biz.pojo.dto.LineDevGetDTO;
import com.njcn.device.biz.pojo.po.Overlimit;
import com.njcn.device.pq.pojo.po.PqsDeviceUnit;
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
import com.njcn.device.biz.pojo.po.PqsDeviceUnit;
import com.njcn.event.api.EventDetailFeignClient;
import com.njcn.event.pojo.po.EventDetail;
import com.njcn.harmonic.enums.HarmonicResponseEnum;
@@ -65,8 +64,6 @@ import java.util.stream.Stream;
@AllArgsConstructor
public class HistoryResultServiceImpl implements HistoryResultService {
private final LineFeignClient lineFeignClient;
private final EventDetailFeignClient eventDetailFeignClient;
private final DeptFeignClient deptFeignClient;
@@ -85,7 +82,8 @@ public class HistoryResultServiceImpl implements HistoryResultService {
private final DataHarmRateVMapper dataHarmRateVMapper;
private final DeviceUnitClient deviceUnitClient;
private final CommTerminalGeneralClient commTerminalGeneralClient;
@Override
@@ -119,12 +117,14 @@ public class HistoryResultServiceImpl implements HistoryResultService {
number = historyParam.getInHarmonic();
}
historyDataResultVO = getCondition(historyParam.getSearchBeginTime(), historyParam.getSearchEndTime(), points[i], contions[j], number, historyParam.getValueType(), historyParam.getPtType());
historyDataResultVOList.add(historyDataResultVO);
if (points.length == 1 && j == 0) {
/* if (points.length == 1 && j == 0) {
historyDataResultVO.setEventDetail(eventDetailVOList);
} else if (points.length > 1) {
historyDataResultVO.setEventDetail(eventDetailVOList);
}
}*/
historyDataResultVO.setEventDetail(eventDetailVOList);
historyDataResultVOList.add(historyDataResultVO);
}
}
return historyDataResultVOList;
@@ -239,22 +239,22 @@ public class HistoryResultServiceImpl implements HistoryResultService {
return historyDataResultVO;
}
private QueryResultLimitVO getQueryResult(String startTime, String endTime, String lineList, String contion, Integer number, Integer valueType, Integer ptType) {
PqsDeviceUnit pqsDeviceUnit = deviceUnitClient.lineUnitDetail(lineList).getData();
private QueryResultLimitVO getQueryResult(String startTime, String endTime, String lineId, String contion, Integer number, Integer valueType, Integer ptType) {
PqsDeviceUnit pqsDeviceUnit = commTerminalGeneralClient.lineUnitDetail(lineId).getData();
QueryResultLimitVO queryResultLimitVO = new QueryResultLimitVO();
if (!lineList.isEmpty()) {
if (!lineId.isEmpty()) {
Float topLimit = 0f;
Float lowerLimit = 0f;
//获取限值
Overlimit overlimit = lineFeignClient.getOverLimitData(lineList).getData();
Overlimit overlimit = commTerminalGeneralClient.getOverLimitData(lineId).getData();
//获取监测点信息
LineDetailDataVO lineDetailDataVO = lineFeignClient.getLineDetailData(lineList).getData();
LineDevGetDTO lineDetailDataVO = commTerminalGeneralClient.getMonitorDetail(lineId).getData();
//组装sql语句
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(InfluxDBTableConstant.TIME + " >= '").append(startTime).append(InfluxDBTableConstant.START_TIME).append("' and ").append(InfluxDBTableConstant.TIME).append(" <= '").append(endTime).append(InfluxDBTableConstant.END_TIME).append("' and (");
//sql语句
stringBuilder.append(InfluxDBTableConstant.LINE_ID + "='").append(lineList).append("')");
stringBuilder.append(InfluxDBTableConstant.LINE_ID + "='").append(lineId).append("')");
String valueTypeName = "";
switch (valueType) {
case 1:
@@ -754,7 +754,7 @@ public class HistoryResultServiceImpl implements HistoryResultService {
queryResultLimitVO.setLowerLimit(lowerLimit);
queryResultLimitVO.setPhaiscType(phasicType);
queryResultLimitVO.setUnit(unit);
queryResultLimitVO.setLineName(lineDetailDataVO.getLineName());
queryResultLimitVO.setLineName(lineDetailDataVO.getPointName());
queryResultLimitVO.setHarmNum(number);
queryResultLimitVO.setTargetName(targetName);
} else {
@@ -775,9 +775,9 @@ public class HistoryResultServiceImpl implements HistoryResultService {
String endTime = sdf.format(DateUtil.endOfDay(DateUtil.parse(normHistoryParam.getSearchTime())));
Integer valueType = normHistoryParam.getValueType();
//获取限值
Overlimit overlimit = lineFeignClient.getOverLimitData(lineList).getData();
Overlimit overlimit = commTerminalGeneralClient.getOverLimitData(lineList).getData();
//获取监测点信息
LineDetailDataVO lineDetailDataVO = lineFeignClient.getLineDetailData(lineList).getData();
LineDevGetDTO lineDetailDataVO = commTerminalGeneralClient.getMonitorDetail(lineList).getData();
//组装sql语句
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(InfluxDBTableConstant.TIME + " >= '").append(startTime).append("' and ").append(InfluxDBTableConstant.TIME).append(" <= '").append(endTime).append("' and (");
@@ -910,7 +910,7 @@ public class HistoryResultServiceImpl implements HistoryResultService {
queryResultLimitVO.setLowerLimit(lowerLimit);
queryResultLimitVO.setPhaiscType(Collections.singletonList(phasicType));
queryResultLimitVO.setUnit(unit);
queryResultLimitVO.setLineName(lineDetailDataVO.getLineName());
queryResultLimitVO.setLineName(lineDetailDataVO.getPointName());
queryResultLimitVO.setHarmNum(number);
queryResultLimitVO.setTargetName(targetName);
} else {
@@ -995,7 +995,7 @@ public class HistoryResultServiceImpl implements HistoryResultService {
public HarmHistoryDataDTO getHistoryHarmData(HistoryHarmParam historyHarmParam) {
List<HarmData> historyData;
float overLimit;
Overlimit overlimit = lineFeignClient.getOverLimitData(historyHarmParam.getLineId()).getData();
Overlimit overlimit = commTerminalGeneralClient.getOverLimitData(historyHarmParam.getLineId()).getData();
//判断是电流还是电压谐波
if (historyHarmParam.getType() == 0) {
historyData = getIHistoryData(historyHarmParam);
@@ -1013,7 +1013,7 @@ public class HistoryResultServiceImpl implements HistoryResultService {
* @date 2023/7/19 10:03
*/
private List<HarmData> getIHistoryData(HistoryHarmParam historyHarmParam) {
LineDetailDataVO lineDetailData = lineFeignClient.getLineDetailData(historyHarmParam.getLineId()).getData();
LineDevGetDTO lineDetailData = commTerminalGeneralClient.getMonitorDetail(historyHarmParam.getLineId()).getData();
List<HarmData> historyData;
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataI.class, HarmData.class);
influxQueryWrapper
@@ -1023,7 +1023,7 @@ public class HistoryResultServiceImpl implements HistoryResultService {
.eq(DataI::getLineId, historyHarmParam.getLineId())
.or(DataI::getPhaseType, Stream.of(InfluxDBTableConstant.PHASE_TYPE_A, InfluxDBTableConstant.PHASE_TYPE_B, InfluxDBTableConstant.PHASE_TYPE_C).collect(Collectors.toList()))
//以时间分组时,需要加上时间间隔,比如此处需要加上监测点的采样间隔
.groupBy("time(" + lineDetailData.getTimeInterval() + "m)")
.groupBy("time(" + lineDetailData.getInterval() + "m)")
.timeAsc();
historyData = dataIMapper.getIHistoryData(influxQueryWrapper);
if (CollectionUtils.isEmpty(historyData)) {
@@ -1031,7 +1031,7 @@ public class HistoryResultServiceImpl implements HistoryResultService {
throw new BusinessException(HarmonicResponseEnum.NO_DATA);
}
//最新两条数据的间隔与监测点查出的间隔做对比,返回一个合理的间隔
int lineInterval = getInterval(lineDetailData.getTimeInterval(), PubUtils.instantToDate(historyData.get(historyData.size() - 1).getTime()), PubUtils.instantToDate(historyData.get(historyData.size() - 2).getTime()));
int lineInterval = getInterval(lineDetailData.getInterval(), PubUtils.instantToDate(historyData.get(historyData.size() - 1).getTime()), PubUtils.instantToDate(historyData.get(historyData.size() - 2).getTime()));
historyData = dealHistoryData(historyData, lineInterval);
if (CollectionUtils.isEmpty(historyData)) {
//如果数据为空,则提示给用户暂无数据
@@ -1054,7 +1054,7 @@ public class HistoryResultServiceImpl implements HistoryResultService {
* 因历史谐波表data_harmrate_v
*/
private List<HarmData> getVHistoryData(HistoryHarmParam historyHarmParam) {
LineDetailDataVO lineDetailData = lineFeignClient.getLineDetailData(historyHarmParam.getLineId()).getData();
LineDevGetDTO lineDetailData = commTerminalGeneralClient.getMonitorDetail(historyHarmParam.getLineId()).getData();
List<HarmData> historyData;
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmRateV.class, HarmData.class);
influxQueryWrapper
@@ -1063,14 +1063,14 @@ public class HistoryResultServiceImpl implements HistoryResultService {
.between(DataHarmRateV::getTime, historyHarmParam.getSearchBeginTime().concat(" 00:00:00"), historyHarmParam.getSearchEndTime().concat(" 23:59:59"))
.eq(DataHarmRateV::getLineId, historyHarmParam.getLineId())
.or(DataHarmRateV::getPhaseType, Stream.of(InfluxDBTableConstant.PHASE_TYPE_A, InfluxDBTableConstant.PHASE_TYPE_B, InfluxDBTableConstant.PHASE_TYPE_C).collect(Collectors.toList()))
.groupBy("time(" + lineDetailData.getTimeInterval() + "m)")
.groupBy("time(" + lineDetailData.getInterval() + "m)")
.timeAsc();
historyData = dataHarmRateVMapper.getHarmRateVHistoryData(influxQueryWrapper);
if (CollectionUtils.isEmpty(historyData)) {
//如果数据为空,则提示给用户暂无数据
throw new BusinessException(HarmonicResponseEnum.NO_DATA);
}
int lineInterval = getInterval(lineDetailData.getTimeInterval(), PubUtils.instantToDate(historyData.get(historyData.size() - 1).getTime()), PubUtils.instantToDate(historyData.get(historyData.size() - 2).getTime()));
int lineInterval = getInterval(lineDetailData.getInterval(), PubUtils.instantToDate(historyData.get(historyData.size() - 1).getTime()), PubUtils.instantToDate(historyData.get(historyData.size() - 2).getTime()));
//最新两条数据的间隔与监测点查出的间隔做对比,返回一个合理的间隔
historyData = dealHistoryData(historyData, lineInterval);
if (CollectionUtils.isEmpty(historyData)) {