合并代码

This commit is contained in:
2022-10-18 11:17:20 +08:00
parent 1efdfa5cd6
commit 7b790e6dc2
93 changed files with 5045 additions and 555 deletions

View File

@@ -1,8 +1,10 @@
package com.njcn.harmonic.service;
import com.njcn.common.pojo.param.StatisticsBizBaseParam;
import com.njcn.harmonic.pojo.param.HistoryParam;
import com.njcn.harmonic.pojo.param.NormHistoryParam;
import com.njcn.harmonic.pojo.vo.HistoryDataResultVO;
import com.njcn.harmonic.pojo.vo.StatHarmonicOrgVO;
import java.util.List;
@@ -27,4 +29,11 @@ public interface HistoryResultService {
* @return 结果
*/
List<HistoryDataResultVO> getHistoryLineData(NormHistoryParam normHistoryParam);
/**
* 获取谐波越限监测点占比
* @param statisticsBizBaseParam 参数
* @return 结果
*/
List<StatHarmonicOrgVO> getHarmonicProportion(StatisticsBizBaseParam statisticsBizBaseParam);
}

View File

@@ -17,5 +17,5 @@ public interface NormLimitService {
* @param historyHarmOverLimitParam 参数
* @return 返回值
*/
List<HistoryHarmOverLimitVO> getHistoryTableData(HistoryHarmOverLimitParam historyHarmOverLimitParam);
List<HistoryHarmOverLimitVO> getHistoryData(HistoryHarmOverLimitParam historyHarmOverLimitParam,int type);
}

View File

@@ -0,0 +1,29 @@
package com.njcn.harmonic.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.harmonic.pojo.param.PollutionSubstationQuryParam;
import com.njcn.harmonic.pojo.po.RStatPollutionSubstationM;
import com.njcn.harmonic.pojo.vo.PollutionSubstationVO;
import java.util.List;
/**
*
* Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html
* Date: 2022/10/13 8:56【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface PollutionSubstationService extends IService<RStatPollutionSubstationM>{
/**
* @Description: getPollutionSubstationData
* @Param: [pollutionSubstationQuryParam]
* @return: java.util.List<com.njcn.harmonic.pojo.vo.PollutionSubstationVO>
* @Author: clam
* @Date: 2022/10/13
*/
List<PollutionSubstationVO> getPollutionSubstationData(PollutionSubstationQuryParam pollutionSubstationQuryParam);
}

View File

@@ -1,6 +1,8 @@
package com.njcn.harmonic.service;
import com.njcn.common.pojo.param.StatisticsBizBaseParam;
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.harmonic.pojo.vo.RMpVThdVO;
import com.njcn.harmonic.pojo.vo.THDistortionCensusVO;
import com.njcn.harmonic.pojo.vo.THDistortionVO;
@@ -27,4 +29,12 @@ public interface THDistortionService {
* @return
*/
THDistortionCensusVO getTHDistortionCensus(DeviceInfoParam.BusinessParam thDistortionCensusParam);
/**
* @Description: 谐波总畸变率前十列表
* @Param: [statisticsBizBaseParam]
* @return: java.util.List<com.njcn.harmonic.pojo.vo.RMpVThdVO>
* @Author: clam
* @Date: 2022/10/10
*/
List<RMpVThdVO> getTHDTopTenData(StatisticsBizBaseParam statisticsBizBaseParam);
}

View File

@@ -2,6 +2,8 @@ package com.njcn.harmonic.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import com.njcn.common.pojo.constant.BizParamConstant;
import com.njcn.common.pojo.param.StatisticsBizBaseParam;
import com.njcn.common.utils.PubUtils;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.pq.pojo.po.Overlimit;
@@ -9,14 +11,22 @@ import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
import com.njcn.event.api.EventDetailFeignClient;
import com.njcn.event.pojo.po.EventDetail;
import com.njcn.harmonic.constant.Param;
import com.njcn.harmonic.mapper.StatHarmonicOrgDMapper;
import com.njcn.harmonic.mapper.StatHarmonicOrgMMapper;
import com.njcn.harmonic.mapper.StatHarmonicOrgQMapper;
import com.njcn.harmonic.mapper.StatHarmonicOrgYMapper;
import com.njcn.harmonic.pojo.param.HistoryParam;
import com.njcn.harmonic.pojo.param.NormHistoryParam;
import com.njcn.harmonic.pojo.vo.EventDetailVO;
import com.njcn.harmonic.pojo.vo.HistoryDataResultVO;
import com.njcn.harmonic.pojo.vo.QueryResultLimitVO;
import com.njcn.harmonic.pojo.vo.StatHarmonicOrgVO;
import com.njcn.harmonic.service.HistoryResultService;
import com.njcn.influxdb.param.InfluxDBPublicParam;
import com.njcn.influxdb.utils.InfluxDbUtils;
import com.njcn.user.api.DeptFeignClient;
import com.njcn.user.pojo.dto.DeptDTO;
import com.njcn.web.utils.WebUtil;
import lombok.AllArgsConstructor;
import lombok.SneakyThrows;
import org.influxdb.dto.QueryResult;
@@ -27,9 +37,9 @@ import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
* @author denghuajun
@@ -45,6 +55,16 @@ public class HistoryResultServiceImpl implements HistoryResultService {
private final EventDetailFeignClient eventDetailFeignClient;
private final DeptFeignClient deptFeignClient;
private final StatHarmonicOrgYMapper statHarmonicOrgYMapper;
private final StatHarmonicOrgQMapper statHarmonicOrgQMapper;
private final StatHarmonicOrgMMapper statHarmonicOrgMMapper;
private final StatHarmonicOrgDMapper statHarmonicOrgDMapper;
@Override
public List<HistoryDataResultVO> getHistoryResult(HistoryParam historyParam) {
List<HistoryDataResultVO> historyDataResultVOList = new ArrayList<>();
@@ -859,4 +879,119 @@ public class HistoryResultServiceImpl implements HistoryResultService {
}
return historyDataResultVO;
}
@Override
public List<StatHarmonicOrgVO> getHarmonicProportion(StatisticsBizBaseParam statisticsBizBaseParam){
List<StatHarmonicOrgVO> statHarmonicOrgVOS = new ArrayList<>();
//获取子部门
List<DeptDTO> depts = deptFeignClient.getDeptDescendantIndexes(statisticsBizBaseParam.getId(), WebUtil.filterDeptType()).getData();
if (depts.size() != 0) {
//根据上层id查询子数据并返回一个顺序流
depts = depts.stream().filter(allItem -> allItem.getPid().equals(statisticsBizBaseParam.getId())).collect(Collectors.toList());
//根据时间区分表查询
//年 季 月 日
switch (statisticsBizBaseParam.getType().toString()) {
case BizParamConstant.STAT_BIZ_YEAR:
statHarmonicOrgVOS = statHarmonicOrgYMapper.listYearRatio(depts, statisticsBizBaseParam.getStartTime(),statisticsBizBaseParam.getEndTime());
break;
case BizParamConstant.STAT_BIZ_QUARTER:
statHarmonicOrgVOS = statHarmonicOrgQMapper.listQuarterRatio(depts, statisticsBizBaseParam.getStartTime(),statisticsBizBaseParam.getEndTime());
break;
case BizParamConstant.STAT_BIZ_MONTH:
statHarmonicOrgVOS = statHarmonicOrgMMapper.listMonthRatio(depts, statisticsBizBaseParam.getStartTime(),statisticsBizBaseParam.getEndTime());
break;
case BizParamConstant.STAT_BIZ_DAY:
statHarmonicOrgVOS = statHarmonicOrgDMapper.listDayRatio(depts, statisticsBizBaseParam.getStartTime(),statisticsBizBaseParam.getEndTime());
break;
default:
break;
}
}
//使用流对象的方法插入name值
if (statHarmonicOrgVOS.size() != 0){
statHarmonicOrgVOS = transName(statHarmonicOrgVOS, depts);
}
return statHarmonicOrgVOS;
}
/**
* 使用流对象的方法插入数据
*/
private static List<StatHarmonicOrgVO> transName(List<StatHarmonicOrgVO> statHarmonicOrgVOS, List<DeptDTO> deptDTOS) {
List<StatHarmonicOrgVO> list = statHarmonicOrgVOS.stream().map(e1 -> {
return deptDTOS.stream().filter(e2 -> {//条件判断
return e1.getId().equals(e2.getId());
}).map(e2 -> {
if (e2.getType() == 0) {
e1.setName(e2.getArea());
} else {
e1.setName(e2.getName());
}
return e1;//返回的结果
}).collect(Collectors.toList());
}).flatMap(List::stream).collect(Collectors.toList());//设置返回结果类型
return list;
}
// /**
// * 获取季度时间段
// * @param date
// * @return 结果
// */
// private static Map<String, Date> getSeasonDate(Date date) {
// Map<String, Date> result = new HashMap<>();
// //根据当前时间初始化
// Calendar start = Calendar.getInstance();
// Calendar end = Calendar.getInstance();
// start.setTime(date);
// end.setTime(date);
// //根据月份计算出季度时间段
// int month = start.get(Calendar.MONTH);
// switch (month) {
// case Calendar.JANUARY:
// case Calendar.FEBRUARY:
// case Calendar.MARCH:
// start.set(Calendar.MONTH, 0);
// start.set(Calendar.DATE,1);
// end.set(Calendar.MONTH, 2);
// end.set(Calendar.DATE, 31);
// break;
// case Calendar.APRIL:
// case Calendar.MAY:
// case Calendar.JUNE:
// start.set(Calendar.MONTH, 3);
// start.set(Calendar.DATE,1);
// end.set(Calendar.MONTH, 5);
// end.set(Calendar.DATE, 30);
// break;
// case Calendar.JULY:
// case Calendar.AUGUST:
// case Calendar.SEPTEMBER:
// start.set(Calendar.MONTH, 6);
// start.set(Calendar.DATE,1);
// end.set(Calendar.MONTH, 8);
// end.set(Calendar.DATE, 30);
// break;
// case Calendar.OCTOBER:
// case Calendar.NOVEMBER:
// case Calendar.DECEMBER:
// start.set(Calendar.MONTH, 9);
// start.set(Calendar.DATE,1);
// end.set(Calendar.MONTH, 11);
// end.set(Calendar.DATE, 31);
// break;
// default:
// break;
// }
// //转换成date组装返回
// result.put("startTime",start.getTime());
// result.put("endTime",end.getTime());
// return result;
// }
}

View File

@@ -1,31 +1,22 @@
package com.njcn.harmonic.service.impl;
import com.njcn.common.utils.PubUtils;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
import com.njcn.harmonic.constant.Param;
import cn.hutool.core.date.DateUtil;
import com.njcn.common.pojo.dto.SimpleDTO;
import com.njcn.common.pojo.enums.common.ServerEnum;
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.harmonic.mapper.NormLimitMapper;
import com.njcn.harmonic.pojo.param.HistoryHarmOverLimitParam;
import com.njcn.harmonic.pojo.vo.HistoryHarmOverLimitVO;
import com.njcn.harmonic.service.NormLimitService;
import com.njcn.influxdb.param.InfluxDBPublicParam;
import com.njcn.influxdb.utils.InfluxDbUtils;
import com.njcn.web.utils.RequestUtil;
import lombok.AllArgsConstructor;
import lombok.SneakyThrows;
import org.influxdb.dto.QueryResult;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
import java.util.concurrent.TimeUnit;
/**
* 类介绍
@@ -38,23 +29,38 @@ import java.util.concurrent.TimeUnit;
@AllArgsConstructor
public class NormLimitServiceImpl implements NormLimitService {
private final InfluxDbUtils influxDbUtils;
private final GeneralDeviceInfoClient generalDeviceInfoClient;
private final LineFeignClient lineFeignClient;
private final NormLimitMapper normLimitMapper;
@SneakyThrows
@Override
public List<HistoryHarmOverLimitVO> getHistoryTableData(HistoryHarmOverLimitParam historyHarmOverLimitParam) {
public List<HistoryHarmOverLimitVO> getHistoryData(HistoryHarmOverLimitParam historyHarmOverLimitParam, int type) {
List<HistoryHarmOverLimitVO> historyHarmOverLimitVOList = new ArrayList<>();
List<HistoryHarmOverLimitVO> historyHarmOverLimitVO;
//处理接口数据
String[] lineIds = new String[historyHarmOverLimitParam.getLineId().length];
List<String> lineIds = new ArrayList<>();
if (type == 0) {
//处理接口数据
System.arraycopy(historyHarmOverLimitParam.getLineId(), 0, lineIds, 0, historyHarmOverLimitParam.getLineId().length);
} else {
DeviceInfoParam deviceInfoParam = new DeviceInfoParam();
deviceInfoParam.setDeptIndex(RequestUtil.getDeptIndex());
deviceInfoParam.setPowerFlag(2);
deviceInfoParam.setMonitorFlag(2);
deviceInfoParam.setServerName(ServerEnum.HARMONIC.getName());
SimpleDTO simpleDTO = new SimpleDTO();
simpleDTO.setName("电网拓扑");
simpleDTO.setSort(0);
simpleDTO.setCode("Power_Network");
deviceInfoParam.setStatisticalType(simpleDTO);
//处理监测点
List<GeneralDeviceDTO> deviceDataList = generalDeviceInfoClient.getPracticalAllDeviceInfo(deviceInfoParam).getData();
for (GeneralDeviceDTO generalDeviceDTO : deviceDataList) {
lineIds.addAll(generalDeviceDTO.getLineIndexes());
}
}
int[] types = new int[historyHarmOverLimitParam.getCondition().length];
int[] inde = new int[0];
int[] inharm = new int[0];
for (int i = 0; i < historyHarmOverLimitParam.getLineId().length; i++) {
lineIds[i] = historyHarmOverLimitParam.getLineId()[i];
}
for (int i = 0; i < historyHarmOverLimitParam.getCondition().length; i++) {
types[i] = Integer.parseInt(historyHarmOverLimitParam.getCondition()[i]);
@@ -73,124 +79,172 @@ public class NormLimitServiceImpl implements NormLimitService {
inharm[i] = Integer.parseInt(historyHarmOverLimitParam.getInHarmonics()[i]);
}
}
for (int i = 0; i < lineIds.length; i++) {
//查询数据
for (int j = 0; j < types.length; j++) {
historyHarmOverLimitVO = getCondition(historyHarmOverLimitParam.getSearchBeginTime(), historyHarmOverLimitParam.getSearchEndTime(), String.valueOf(lineIds[i]), String.valueOf(types[j]), inde, inharm);
historyHarmOverLimitVOList.addAll(historyHarmOverLimitVO);
}
for (int i : types) {
historyHarmOverLimitVO = getMyCondition(historyHarmOverLimitParam.getSearchBeginTime(), historyHarmOverLimitParam.getSearchEndTime(), lineIds, String.valueOf(i), inde, inharm);
historyHarmOverLimitVOList.addAll(historyHarmOverLimitVO);
}
//获取值
//处理数据
return historyHarmOverLimitVOList;
}
/**
* influxDB相关操作
* mysql相关操作
* 查询稳态数据分析
*/
@SneakyThrows
private List<HistoryHarmOverLimitVO> getCondition(String startTime, String endTime, String lineId, String contion, int[] number, int[] valueType) {
private List<HistoryHarmOverLimitVO> getMyCondition(String startTime, String endTime, List<String> lineId, String contion, int[] number, int[] inharm) {
List<HistoryHarmOverLimitVO> historyHarmOverLimitVOList = new ArrayList<>();
//数据的转化
historyHarmOverLimitVOList = getQueryResult(startTime, endTime, lineId, contion, number, valueType);
return historyHarmOverLimitVOList;
}
private List<HistoryHarmOverLimitVO> getQueryResult(String startTime, String endTime, String lineList, String contion, int[] number, int[] inHarmNum) {
List<HistoryHarmOverLimitVO> historyHarmOverLimitVOList = new ArrayList<>();
QueryResult queryResult = null;
if (!lineList.isEmpty()) {
//组装sql语句
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(InfluxDBPublicParam.TIME + " >= '").append(startTime).append(InfluxDBPublicParam.START_TIME).append("' and ").append(InfluxDBPublicParam.TIME).append(" <= '").append(endTime).append(InfluxDBPublicParam.END_TIME).append("' and (");
//sql语句
stringBuilder.append(InfluxDBPublicParam.LINE_ID).append("='").append(lineList).append("')");
String sql;
String targetName;//指标名称
String unit;//单位
if (!lineId.isEmpty()) {
switch (Integer.parseInt(contion)) {
case 12:
//电压偏差
sql = "SELECT time as time, voltage_dev as aValue,phasic_type , value_type FROM pqs_abnormaldata WHERE " + stringBuilder.toString() +
" and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') " +
" and (value_type = 'MAX' or value_type = 'MIN' or value_type = 'AVG' or value_type = 'CP95') group by phasic_type order by time asc tz('Asia/Shanghai');";
queryResult = influxDbUtils.query(sql);
historyHarmOverLimitVOList = getNormData(queryResult, contion, lineList, "电压偏差", "%");
targetName = "电压偏差";
unit = "%";
historyHarmOverLimitVOList = normLimitMapper.getDyPc(lineId, DateUtil.beginOfDay(DateUtil.parse(startTime)), DateUtil.endOfDay(DateUtil.parse(endTime)));
for (HistoryHarmOverLimitVO historyHarmOverLimitVO : historyHarmOverLimitVOList) {
if (historyHarmOverLimitVO.getAvgData() == -3.14159 && historyHarmOverLimitVO.getMaxData() == -3.14159 && historyHarmOverLimitVO.getMinData() == -3.14159 && historyHarmOverLimitVO.getCp95Data() == -3.14159) {
historyHarmOverLimitVOList.remove(historyHarmOverLimitVO);
} else {
historyHarmOverLimitVO.setTargetName(targetName);
historyHarmOverLimitVO.setUnit(unit);
historyHarmOverLimitVO.setTargetCode(contion);
historyHarmOverLimitVO.setStatisticalType(Math.abs(historyHarmOverLimitVO.getMaxData()) > Math.abs(historyHarmOverLimitVO.getMinData()) ? 3 : 2);
}
}
break;
case 13:
//三相电压不平衡度
sql = "SELECT time as time, ubalance as aValue,phasic_type , value_type FROM pqs_abnormaldata WHERE " + stringBuilder.toString() +
" and (phasic_type ='T') " +
" and (value_type = 'MAX' or value_type = 'MIN' or value_type = 'AVG' or value_type = 'CP95') group by phasic_type order by time asc tz('Asia/Shanghai');";
queryResult = influxDbUtils.query(sql);
historyHarmOverLimitVOList = getNormData(queryResult, contion, lineList, "三相电压不平衡度", "/");
targetName = "三相电压不平衡度";
unit = "/";
historyHarmOverLimitVOList = normLimitMapper.getSxBpHd(lineId, DateUtil.beginOfDay(DateUtil.parse(startTime)), DateUtil.endOfDay(DateUtil.parse(endTime)));
for (HistoryHarmOverLimitVO historyHarmOverLimitVO : historyHarmOverLimitVOList) {
if (historyHarmOverLimitVO.getAvgData() == -3.14159 && historyHarmOverLimitVO.getMaxData() == -3.14159 && historyHarmOverLimitVO.getMinData() == -3.14159 && historyHarmOverLimitVO.getCp95Data() == -3.14159) {
historyHarmOverLimitVOList.remove(historyHarmOverLimitVO);
} else {
historyHarmOverLimitVO.setTargetName(targetName);
historyHarmOverLimitVO.setUnit(unit);
historyHarmOverLimitVO.setTargetCode(contion);
historyHarmOverLimitVO.setStatisticalType(Math.abs(historyHarmOverLimitVO.getMaxData()) > Math.abs(historyHarmOverLimitVO.getCp95Data()) ? 3 : 4);
}
}
break;
case 15:
//电压总谐波畸变率
sql = "SELECT time as time, uaberrance as aValue,phasic_type , value_type FROM pqs_abnormaldata WHERE " + stringBuilder.toString() +
" and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') " +
" and (value_type = 'MAX' or value_type = 'MIN' or value_type = 'AVG' or value_type = 'CP95') group by phasic_type order by time asc tz('Asia/Shanghai');";
queryResult = influxDbUtils.query(sql);
historyHarmOverLimitVOList = getNormData(queryResult, contion, lineList, "电压总谐波畸变率", "%");
targetName = "电压总谐波畸变率";
unit = "%";
historyHarmOverLimitVOList = normLimitMapper.getDyZjBl(lineId, DateUtil.beginOfDay(DateUtil.parse(startTime)), DateUtil.endOfDay(DateUtil.parse(endTime)));
for (HistoryHarmOverLimitVO historyHarmOverLimitVO : historyHarmOverLimitVOList) {
if (historyHarmOverLimitVO.getAvgData() == -3.14159 && historyHarmOverLimitVO.getMaxData() == -3.14159 && historyHarmOverLimitVO.getMinData() == -3.14159 && historyHarmOverLimitVO.getCp95Data() == -3.14159) {
historyHarmOverLimitVOList.remove(historyHarmOverLimitVO);
} else {
historyHarmOverLimitVO.setTargetName(targetName);
historyHarmOverLimitVO.setUnit(unit);
historyHarmOverLimitVO.setTargetCode(contion);
historyHarmOverLimitVO.setStatisticalType(4);
}
}
break;
case 22:
//负序电流
sql = "SELECT time as time, i_neg as aValue ,phasic_type , value_type FROM pqs_abnormaldata WHERE " + stringBuilder.toString() +
" and (phasic_type ='T') " +
" and (value_type = 'MAX' or value_type = 'MIN' or value_type = 'AVG' or value_type = 'CP95') group by phasic_type order by time asc tz('Asia/Shanghai');";
queryResult = influxDbUtils.query(sql);
historyHarmOverLimitVOList = getNormData(queryResult, contion, lineList, "负序电流", "/");
targetName = "负序电流";
unit = "/";
historyHarmOverLimitVOList = normLimitMapper.getFxDl(lineId, DateUtil.beginOfDay(DateUtil.parse(startTime)), DateUtil.endOfDay(DateUtil.parse(endTime)));
for (HistoryHarmOverLimitVO historyHarmOverLimitVO : historyHarmOverLimitVOList) {
if (historyHarmOverLimitVO.getAvgData() == -3.14159 && historyHarmOverLimitVO.getMaxData() == -3.14159 && historyHarmOverLimitVO.getMinData() == -3.14159 && historyHarmOverLimitVO.getCp95Data() == -3.14159) {
historyHarmOverLimitVOList.remove(historyHarmOverLimitVO);
} else {
historyHarmOverLimitVO.setTargetName(targetName);
historyHarmOverLimitVO.setUnit(unit);
historyHarmOverLimitVO.setTargetCode(contion);
historyHarmOverLimitVO.setStatisticalType(Math.abs(historyHarmOverLimitVO.getMaxData()) > Math.abs(historyHarmOverLimitVO.getCp95Data()) ? 3 : 4);
}
}
break;
case 30:
//频率 V9暂时代表Freq
sql = "SELECT time as time, freq_dev as aValue ,phasic_type , value_type FROM pqs_abnormaldata WHERE " + stringBuilder.toString() +
" and (phasic_type ='T') " +
" and (value_type = 'MAX' or value_type = 'MIN' or value_type = 'AVG' or value_type = 'CP95') group by phasic_type order by time asc tz('Asia/Shanghai');";
queryResult = influxDbUtils.query(sql);
historyHarmOverLimitVOList = getNormData(queryResult, contion, lineList, "频率", "Hz");
targetName = "频率";
unit = "Hz";
historyHarmOverLimitVOList = normLimitMapper.getPl(lineId, DateUtil.beginOfDay(DateUtil.parse(startTime)), DateUtil.endOfDay(DateUtil.parse(endTime)));
for (HistoryHarmOverLimitVO historyHarmOverLimitVO : historyHarmOverLimitVOList) {
if (historyHarmOverLimitVO.getAvgData() == -3.14159 && historyHarmOverLimitVO.getMaxData() == -3.14159 && historyHarmOverLimitVO.getMinData() == -3.14159 && historyHarmOverLimitVO.getCp95Data() == -3.14159) {
historyHarmOverLimitVOList.remove(historyHarmOverLimitVO);
} else {
historyHarmOverLimitVO.setTargetName(targetName);
historyHarmOverLimitVO.setUnit(unit);
historyHarmOverLimitVO.setTargetCode(contion);
historyHarmOverLimitVO.setStatisticalType(Math.abs(historyHarmOverLimitVO.getMaxData()) > Math.abs(historyHarmOverLimitVO.getMinData()) ? 3 : 2);
}
}
break;
case 40:
for (int i = 0; i < number.length; i++) {
List<HistoryHarmOverLimitVO> harmOverLimitVOList;
//谐波电压含有率
sql = "SELECT time as time, uharm_" + number[i] + " as aValue ,phasic_type , value_type FROM pqs_abnormaldata WHERE " + stringBuilder.toString() +
" and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') " +
" and (value_type = 'MAX' or value_type = 'MIN' or value_type = 'AVG' or value_type = 'CP95') group by phasic_type order by time asc tz('Asia/Shanghai');";
queryResult = influxDbUtils.query(sql);
harmOverLimitVOList = getNormData(queryResult, contion, lineList, "谐波电压含有率", "%", number[i]);
historyHarmOverLimitVOList.addAll(harmOverLimitVOList);
targetName = "谐波电压含有率";
unit = "%";
for (int i : number) {
historyHarmOverLimitVOList = normLimitMapper.getXbDyHyl(lineId, DateUtil.beginOfDay(DateUtil.parse(startTime)), DateUtil.endOfDay(DateUtil.parse(endTime)), i);
for (HistoryHarmOverLimitVO historyHarmOverLimitVO : historyHarmOverLimitVOList) {
if (historyHarmOverLimitVO.getAvgData() == -3.14159 && historyHarmOverLimitVO.getMaxData() == -3.14159 && historyHarmOverLimitVO.getMinData() == -3.14159 && historyHarmOverLimitVO.getCp95Data() == -3.14159) {
historyHarmOverLimitVOList.remove(historyHarmOverLimitVO);
} else {
historyHarmOverLimitVO.setTargetName(targetName);
historyHarmOverLimitVO.setUnit(unit);
historyHarmOverLimitVO.setNumber(i);
historyHarmOverLimitVO.setTargetCode(contion);
historyHarmOverLimitVO.setStatisticalType(4);
}
}
}
break;
case 43:
for (int i = 0; i < number.length; i++) {
List<HistoryHarmOverLimitVO> harmOverLimitVOList;
//谐波电流幅值
sql = "SELECT time as time, iharm_" + number[i] + " as aValue ,phasic_type , value_type FROM pqs_abnormaldata WHERE " + stringBuilder.toString() +
" and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') " +
" and (value_type = 'MAX' or value_type = 'MIN' or value_type = 'AVG' or value_type = 'CP95') group by phasic_type order by time asc tz('Asia/Shanghai');";
queryResult = influxDbUtils.query(sql);
harmOverLimitVOList = getNormData(queryResult, contion, lineList, "谐波电流幅值", "A", number[i]);
historyHarmOverLimitVOList.addAll(harmOverLimitVOList);
targetName = "谐波电流幅值";
unit = "A";
for (int i : number) {
historyHarmOverLimitVOList = normLimitMapper.getXbDlFz(lineId, DateUtil.beginOfDay(DateUtil.parse(startTime)), DateUtil.endOfDay(DateUtil.parse(endTime)), i);
for (HistoryHarmOverLimitVO historyHarmOverLimitVO : historyHarmOverLimitVOList) {
if (historyHarmOverLimitVO.getAvgData() == -3.14159 && historyHarmOverLimitVO.getMaxData() == -3.14159 && historyHarmOverLimitVO.getMinData() == -3.14159 && historyHarmOverLimitVO.getCp95Data() == -3.14159) {
historyHarmOverLimitVOList.remove(historyHarmOverLimitVO);
} else {
historyHarmOverLimitVO.setTargetName(targetName);
historyHarmOverLimitVO.setUnit(unit);
historyHarmOverLimitVO.setNumber(i);
historyHarmOverLimitVO.setTargetCode(contion);
historyHarmOverLimitVO.setStatisticalType(4);
}
}
}
break;
case 46:
for (int i = 0; i < inHarmNum.length; i++) {
List<HistoryHarmOverLimitVO> harmOverLimitVOList;
//间谐波电压含有率
sql = "SELECT time as time, inuharm_" + inHarmNum[i] + " as aValue ,phasic_type , value_type FROM pqs_abnormaldata WHERE " + stringBuilder.toString() +
" and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') " +
" and (value_type = 'MAX' or value_type = 'MIN' or value_type = 'AVG' or value_type = 'CP95') group by phasic_type order by time asc tz('Asia/Shanghai');";
queryResult = influxDbUtils.query(sql);
harmOverLimitVOList = getNormData(queryResult, contion, lineList, "间谐波电压含有率", "%", inHarmNum[i]);
historyHarmOverLimitVOList.addAll(harmOverLimitVOList);
targetName = "间谐波电压含有率";
unit = "%";
for (int i : inharm) {
historyHarmOverLimitVOList = normLimitMapper.getJxbHyl(lineId, DateUtil.beginOfDay(DateUtil.parse(startTime)), DateUtil.endOfDay(DateUtil.parse(endTime)), i);
for (HistoryHarmOverLimitVO historyHarmOverLimitVO : historyHarmOverLimitVOList) {
if (historyHarmOverLimitVO.getAvgData() == -3.14159 && historyHarmOverLimitVO.getMaxData() == -3.14159 && historyHarmOverLimitVO.getMinData() == -3.14159 && historyHarmOverLimitVO.getCp95Data() == -3.14159) {
historyHarmOverLimitVOList.remove(historyHarmOverLimitVO);
} else {
historyHarmOverLimitVO.setTargetName(targetName);
historyHarmOverLimitVO.setUnit(unit);
historyHarmOverLimitVO.setNumber(i);
historyHarmOverLimitVO.setTargetCode(contion);
historyHarmOverLimitVO.setStatisticalType(4);
}
}
}
break;
case 61:
//长时闪变
sql = "SELECT time as time, flicker as aValue ,phasic_type , value_type FROM pqs_abnormaldata WHERE " + stringBuilder.toString() +
" and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') " +
" and (value_type = 'AVG') group by phasic_type order by time asc tz('Asia/Shanghai');";
queryResult = influxDbUtils.query(sql);
historyHarmOverLimitVOList = getNormData(queryResult, contion, lineList, "长时闪变", "/");
targetName = "长时闪变";
unit = "/";
historyHarmOverLimitVOList = normLimitMapper.getCsSb(lineId, DateUtil.beginOfDay(DateUtil.parse(startTime)), DateUtil.endOfDay(DateUtil.parse(endTime)));
for (HistoryHarmOverLimitVO historyHarmOverLimitVO : historyHarmOverLimitVOList) {
if (historyHarmOverLimitVO.getAvgData() == -3.14159) {
historyHarmOverLimitVOList.remove(historyHarmOverLimitVO);
} else {
historyHarmOverLimitVO.setTargetName(targetName);
historyHarmOverLimitVO.setUnit(unit);
historyHarmOverLimitVO.setMaxData(3.14159f);
historyHarmOverLimitVO.setMinData(3.14159f);
historyHarmOverLimitVO.setCp95Data(3.14159f);
historyHarmOverLimitVO.setTargetCode(contion);
historyHarmOverLimitVO.setStatisticalType(1);
}
}
break;
default:
break;
@@ -200,328 +254,4 @@ public class NormLimitServiceImpl implements NormLimitService {
}
return historyHarmOverLimitVOList;
}
//数据组装
@SneakyThrows
private List<HistoryHarmOverLimitVO> getNormData(QueryResult queryResult, String contion, String lineList, String phaseName, String unit) {
List<HistoryHarmOverLimitVO> historyHarmOverLimitVOList = new ArrayList<>();
List<QueryResult.Result> qusery = queryResult.getResults();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SS'Z'");
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
//获取监测点详情
LineDetailDataVO lineDetailDataVO = lineFeignClient.getLineDetailData(lineList).getData();
if (!CollectionUtils.isEmpty(qusery.get(0).getSeries())) {
String time = "";
Float aMax = 0.0f, aMin = 0.0f, aAvg = 0.0f, aCp95 = 0.0f, bMax = 0.0f, bMin = 0.0f, bAvg = 0.0f, bCp95 = 0.0f, cMax = 0.0f, cMin = 0.0f, cAvg = 0.0f, cCp95 = 0.0f;
for (int i = 0; i < qusery.get(0).getSeries().size(); i++) {
if (qusery.get(0).getSeries().get(i).getTags().get("phasic_type").equals("A")) {
HistoryHarmOverLimitVO historyDataResultVO = new HistoryHarmOverLimitVO();
if (!CollectionUtils.isEmpty(qusery.get(0).getSeries().get(i).getValues())) {
for (int j = 0; j < qusery.get(0).getSeries().get(i).getValues().size(); j++) {
List<Object> objectList = qusery.get(0).getSeries().get(i).getValues().get(j);
String aa = String.valueOf(objectList.get(0));
Date sd = dateFormat.parse(aa);
time = dateFormat.format(sd);
if (Integer.parseInt(contion) == 61) {
historyDataResultVO.setMaxValue((float) 3.14159);
historyDataResultVO.setMinValue((float) 3.14159);
historyDataResultVO.setCp95Value((float) 3.14159);
aAvg = Float.parseFloat(String.valueOf(objectList.get(1)));
historyDataResultVO.setAvgValue(aAvg);
} else {
if (objectList.get(3).equals("MAX")) {
aMax = Float.parseFloat(String.valueOf(objectList.get(1)));
historyDataResultVO.setMaxValue(aMax);
} else if (objectList.get(3).equals("MIN")) {
aMin = Float.parseFloat(String.valueOf(objectList.get(1)));
historyDataResultVO.setMinValue(aMin);
} else if (objectList.get(3).equals("AVG")) {
aAvg = Float.parseFloat(String.valueOf(objectList.get(1)));
historyDataResultVO.setAvgValue(aAvg);
} else if (objectList.get(3).equals("CP95")) {
aCp95 = Float.parseFloat(String.valueOf(objectList.get(1)));
historyDataResultVO.setCp95Value(aCp95);
}
}
}
}
historyDataResultVO.setTime(time);
historyDataResultVO.setLineName(lineDetailDataVO.getLineName());
historyDataResultVO.setLineId(lineList);
historyDataResultVO.setNumber(0);
historyDataResultVO.setSubName(lineDetailDataVO.getBdName());
historyDataResultVO.setTargetCode(contion);
historyDataResultVO.setTargetName(phaseName);
if (Integer.parseInt(contion) == 12 || Integer.parseInt(contion) == 15) {
if (PubUtils.ptTypeName(lineDetailDataVO.getPtType()) != 0) {
historyDataResultVO.setPhaseType("AB");
} else {
historyDataResultVO.setPhaseType("A");
}
historyDataResultVO.setStatisticalType(Math.abs(aMax) > Math.abs(aMin) ? 3 : 2);
} else if (Integer.parseInt(contion) == 13 || Integer.parseInt(contion) == 22) {
historyDataResultVO.setPhaseType("/");
historyDataResultVO.setStatisticalType(Math.abs(aMax) > Math.abs(aCp95) ? 3 : 4);
} else {
if (PubUtils.ptTypeName(lineDetailDataVO.getPtType()) != 0) {
historyDataResultVO.setPhaseType("AB");
} else {
historyDataResultVO.setPhaseType("A");
}
historyDataResultVO.setStatisticalType(3);
}
historyDataResultVO.setScale(lineDetailDataVO.getScale());
historyDataResultVO.setUnit(unit);
historyHarmOverLimitVOList.add(historyDataResultVO);
}
if ("12".equals(contion) || "15".equals(contion) || "40".equals(contion) || "61".equals(contion)) {
if (qusery.get(0).getSeries().get(i).getTags().get("phasic_type").equals("B")) {
HistoryHarmOverLimitVO historyDataResultVO = new HistoryHarmOverLimitVO();
if (!CollectionUtils.isEmpty(qusery.get(0).getSeries().get(i).getValues())) {
for (int j = 0; j < qusery.get(0).getSeries().get(i).getValues().size(); j++) {
List<Object> objectList = qusery.get(0).getSeries().get(i).getValues().get(j);
String aa = String.valueOf(objectList.get(0));
Date sd = dateFormat.parse(aa);
time = dateFormat.format(sd);
if (Integer.parseInt(contion) == 61) {
historyDataResultVO.setMaxValue((float) 3.14159);
historyDataResultVO.setMinValue((float) 3.14159);
historyDataResultVO.setCp95Value((float) 3.14159);
aAvg = Float.parseFloat(String.valueOf(objectList.get(1)));
historyDataResultVO.setAvgValue(aAvg);
} else {
if (objectList.get(3).equals("MAX")) {
bMax = Float.parseFloat(String.valueOf(objectList.get(1)));
historyDataResultVO.setMaxValue(bMax);
} else if (objectList.get(3).equals("MIN")) {
bMin = Float.parseFloat(String.valueOf(objectList.get(1)));
historyDataResultVO.setMinValue(bMin);
} else if (objectList.get(3).equals("AVG")) {
bAvg = Float.parseFloat(String.valueOf(objectList.get(1)));
historyDataResultVO.setAvgValue(bAvg);
} else if (objectList.get(3).equals("CP95")) {
bCp95 = Float.parseFloat(String.valueOf(objectList.get(1)));
historyDataResultVO.setCp95Value(bCp95);
}
}
}
}
historyDataResultVO.setTime(time);
historyDataResultVO.setLineName(lineDetailDataVO.getLineName());
historyDataResultVO.setLineId(lineList);
historyDataResultVO.setNumber(0);
historyDataResultVO.setSubName(lineDetailDataVO.getBdName());
historyDataResultVO.setTargetCode(contion);
historyDataResultVO.setTargetName(phaseName);
if (Integer.parseInt(contion) == 12 || Integer.parseInt(contion) == 15) {
if (PubUtils.ptTypeName(lineDetailDataVO.getPtType()) != 0) {
historyDataResultVO.setPhaseType("BC");
} else {
historyDataResultVO.setPhaseType("B");
}
historyDataResultVO.setStatisticalType(Math.abs(aMax) > Math.abs(aMin) ? 3 : 2);
} else if (Integer.parseInt(contion) == 13 || Integer.parseInt(contion) == 22) {
historyDataResultVO.setPhaseType("/");
historyDataResultVO.setStatisticalType(Math.abs(aMax) > Math.abs(aCp95) ? 3 : 4);
} else {
if (PubUtils.ptTypeName(lineDetailDataVO.getPtType()) != 0) {
historyDataResultVO.setPhaseType("BC");
} else {
historyDataResultVO.setPhaseType("B");
}
historyDataResultVO.setStatisticalType(3);
}
historyDataResultVO.setScale(lineDetailDataVO.getScale());
historyDataResultVO.setUnit(unit);
historyHarmOverLimitVOList.add(historyDataResultVO);
} else if (qusery.get(0).getSeries().get(i).getTags().get("phasic_type").equals("C")) {
if (!CollectionUtils.isEmpty(qusery.get(0).getSeries().get(i).getValues())) {
HistoryHarmOverLimitVO historyDataResultVO = new HistoryHarmOverLimitVO();
for (int j = 0; j < qusery.get(0).getSeries().get(i).getValues().size(); j++) {
List<Object> objectList = qusery.get(0).getSeries().get(i).getValues().get(j);
String aa = String.valueOf(objectList.get(0));
Date sd = dateFormat.parse(aa);
time = dateFormat.format(sd);
if (Integer.parseInt(contion) == 61) {
historyDataResultVO.setMaxValue((float) 3.14159);
historyDataResultVO.setMinValue((float) 3.14159);
historyDataResultVO.setCp95Value((float) 3.14159);
aAvg = Float.parseFloat(String.valueOf(objectList.get(1)));
historyDataResultVO.setAvgValue(aAvg);
} else {
if (objectList.get(3).equals("MAX")) {
cMax = Float.parseFloat(String.valueOf(objectList.get(1)));
historyDataResultVO.setMaxValue(cMax);
} else if (objectList.get(3).equals("MIN")) {
cMin = Float.parseFloat(String.valueOf(objectList.get(1)));
historyDataResultVO.setMinValue(cMin);
} else if (objectList.get(3).equals("AVG")) {
cAvg = Float.parseFloat(String.valueOf(objectList.get(1)));
historyDataResultVO.setAvgValue(cAvg);
} else if (objectList.get(3).equals("CP95")) {
cCp95 = Float.parseFloat(String.valueOf(objectList.get(1)));
historyDataResultVO.setCp95Value(cCp95);
}
}
}
historyDataResultVO.setTime(time);
historyDataResultVO.setLineName(lineDetailDataVO.getLineName());
historyDataResultVO.setLineId(lineList);
historyDataResultVO.setNumber(0);
historyDataResultVO.setSubName(lineDetailDataVO.getBdName());
historyDataResultVO.setTargetCode(contion);
historyDataResultVO.setTargetName(phaseName);
if (Integer.parseInt(contion) == 12 || Integer.parseInt(contion) == 15) {
if (PubUtils.ptTypeName(lineDetailDataVO.getPtType()) != 0) {
historyDataResultVO.setPhaseType("CA");
} else {
historyDataResultVO.setPhaseType("C");
}
historyDataResultVO.setStatisticalType(Math.abs(cMax) > Math.abs(cMin) ? 3 : 2);
} else if (Integer.parseInt(contion) == 13 || Integer.parseInt(contion) == 22) {
historyDataResultVO.setPhaseType("/");
historyDataResultVO.setStatisticalType(Math.abs(cMax) > Math.abs(cCp95) ? 3 : 4);
} else {
if (PubUtils.ptTypeName(lineDetailDataVO.getPtType()) != 0) {
historyDataResultVO.setPhaseType("CA");
} else {
historyDataResultVO.setPhaseType("C");
}
historyDataResultVO.setStatisticalType(3);
}
historyDataResultVO.setScale(lineDetailDataVO.getScale());
historyDataResultVO.setUnit(unit);
historyHarmOverLimitVOList.add(historyDataResultVO);
}
}
}
}
}
return historyHarmOverLimitVOList;
}
@SneakyThrows
private List<HistoryHarmOverLimitVO> getNormData(QueryResult queryResult, String contion, String lineList, String phaseName, String unit, int number) {
List<HistoryHarmOverLimitVO> historyHarmOverLimitVOList = new ArrayList<>();
List<QueryResult.Result> qusery = queryResult.getResults();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SS'Z'");
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
//获取监测点详情
LineDetailDataVO lineDetailDataVO = lineFeignClient.getLineDetailData(lineList).getData();
if (!CollectionUtils.isEmpty(qusery.get(0).getSeries())) {
String time = "";
Float aMax = 0.0f, aMin = 0.0f, aAvg = 0.0f, aCp95 = 0.0f, bMax = 0.0f, bMin = 0.0f, bAvg = 0.0f, bCp95 = 0.0f, cMax = 0.0f, cMin = 0.0f, cAvg = 0.0f, cCp95 = 0.0f;
HistoryHarmOverLimitVO historyDataResultVO = new HistoryHarmOverLimitVO();
for (int i = 0; i < qusery.get(0).getSeries().get(0).getValues().size(); i++) {
//A相的最大值
if (!CollectionUtils.isEmpty(qusery.get(0).getSeries())) {
aMax = Float.parseFloat(qusery.get(0).getSeries().get(0).getValues().get(i).get(1).toString());
historyDataResultVO.setMaxValue(aMax);
}
//A相的最小值
if (!CollectionUtils.isEmpty(qusery.get(1).getSeries())) {
aMin = Float.parseFloat(qusery.get(1).getSeries().get(0).getValues().get(i).get(1).toString());
historyDataResultVO.setMinValue(aMin);
}
//A相的评价值
if (!CollectionUtils.isEmpty(qusery.get(2).getSeries())) {
aAvg = Float.parseFloat(qusery.get(2).getSeries().get(0).getValues().get(i).get(1).toString());
historyDataResultVO.setAvgValue(aAvg);
}
//A相的CP95
if (!CollectionUtils.isEmpty(qusery.get(3).getSeries())) {
time = String.valueOf(qusery.get(3).getSeries().get(0).getValues().get(i).get(0));
aCp95 = Float.parseFloat(qusery.get(3).getSeries().get(0).getValues().get(i).get(1).toString());
historyDataResultVO.setTime(dateFormat.format(sdf.parse(time)));
historyDataResultVO.setCp95Value(aCp95);
}
historyDataResultVO.setLineName(lineDetailDataVO.getLineName());
historyDataResultVO.setLineId(lineList);
historyDataResultVO.setNumber(number);
historyDataResultVO.setSubName(lineDetailDataVO.getBdName());
historyDataResultVO.setTargetCode(contion);
historyDataResultVO.setTargetName(number + "" + phaseName);
historyDataResultVO.setPhaseType("A");
historyDataResultVO.setStatisticalType(4);
historyDataResultVO.setScale(lineDetailDataVO.getScale());
historyDataResultVO.setUnit(unit);
historyHarmOverLimitVOList.add(historyDataResultVO);
}
for (int i = 0; i < qusery.get(4).getSeries().get(0).getValues().size(); i++) {
HistoryHarmOverLimitVO historyDataResultVOB = new HistoryHarmOverLimitVO();
//B相的最大值
if (!CollectionUtils.isEmpty(qusery.get(4).getSeries())) {
bMax = Float.parseFloat(qusery.get(4).getSeries().get(0).getValues().get(i).get(1).toString());
historyDataResultVOB.setMaxValue(bMax);
}
//B相的最小值
if (!CollectionUtils.isEmpty(qusery.get(5).getSeries())) {
bMin = Float.parseFloat(qusery.get(5).getSeries().get(0).getValues().get(i).get(1).toString());
historyDataResultVOB.setMinValue(bMin);
}
//B相的平均值
if (!CollectionUtils.isEmpty(qusery.get(6).getSeries())) {
bAvg = Float.parseFloat(qusery.get(6).getSeries().get(0).getValues().get(i).get(1).toString());
historyDataResultVOB.setAvgValue(bAvg);
}
//B相的CP95
if (!CollectionUtils.isEmpty(qusery.get(7).getSeries())) {
time = String.valueOf(qusery.get(7).getSeries().get(0).getValues().get(i).get(0));
bCp95 = Float.parseFloat(qusery.get(7).getSeries().get(0).getValues().get(i).get(1).toString());
historyDataResultVOB.setTime(dateFormat.format(sdf.parse(time)));
historyDataResultVOB.setCp95Value(bCp95);
}
historyDataResultVOB.setLineName(lineDetailDataVO.getLineName());
historyDataResultVOB.setLineId(lineList);
historyDataResultVOB.setNumber(number);
historyDataResultVOB.setSubName(lineDetailDataVO.getBdName());
historyDataResultVOB.setTargetCode(contion);
historyDataResultVOB.setTargetName(number + "" + phaseName);
historyDataResultVOB.setPhaseType("B");
historyDataResultVOB.setScale(lineDetailDataVO.getScale());
historyDataResultVOB.setUnit(unit);
historyHarmOverLimitVOList.add(historyDataResultVOB);
}
for (int i = 0; i < qusery.get(8).getSeries().get(0).getValues().size(); i++) {
HistoryHarmOverLimitVO historyDataResultVOC = new HistoryHarmOverLimitVO();
//C相的最大值
if (!CollectionUtils.isEmpty(qusery.get(8).getSeries())) {
cMax = Float.parseFloat(qusery.get(8).getSeries().get(0).getValues().get(i).get(1).toString());
historyDataResultVOC.setMaxValue(cMax);
}
//C相的最小值
if (!CollectionUtils.isEmpty(qusery.get(9).getSeries())) {
cMin = Float.parseFloat(qusery.get(9).getSeries().get(0).getValues().get(i).get(1).toString());
historyDataResultVOC.setMinValue(cMin);
}
//C相的平均值
if (!CollectionUtils.isEmpty(qusery.get(10).getSeries())) {
cAvg = Float.parseFloat(qusery.get(10).getSeries().get(0).getValues().get(i).get(1).toString());
historyDataResultVOC.setAvgValue(cAvg);
}
//C相的CP95
if (!CollectionUtils.isEmpty(qusery.get(11).getSeries())) {
time = String.valueOf(qusery.get(11).getSeries().get(0).getValues().get(i).get(0));
cCp95 = Float.parseFloat(qusery.get(11).getSeries().get(0).getValues().get(i).get(1).toString());
historyDataResultVOC.setTime(dateFormat.format(sdf.parse(time)));
historyDataResultVOC.setCp95Value(cCp95);
}
historyDataResultVOC.setLineName(lineDetailDataVO.getLineName());
historyDataResultVOC.setLineId(lineList);
historyDataResultVOC.setNumber(number);
historyDataResultVOC.setSubName(lineDetailDataVO.getBdName());
historyDataResultVOC.setTargetCode(contion);
historyDataResultVOC.setTargetName(number + "" + phaseName);
historyDataResultVOC.setPhaseType("C");
historyDataResultVOC.setScale(lineDetailDataVO.getScale());
historyDataResultVOC.setUnit(unit);
historyHarmOverLimitVOList.add(historyDataResultVOC);
}
}
return historyHarmOverLimitVOList;
}
}

View File

@@ -0,0 +1,111 @@
package com.njcn.harmonic.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.config.GeneralInfo;
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.pq.api.SubstationFeignClient;
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
import com.njcn.device.pq.pojo.dto.PollutionSubstationDTO;
import com.njcn.device.pq.pojo.dto.SubstationDTO;
import com.njcn.harmonic.mapper.RStatPollutionSubstationMMapper;
import com.njcn.harmonic.pojo.param.HarmonicPublicParam;
import com.njcn.harmonic.pojo.param.PollutionSubstationQuryParam;
import com.njcn.harmonic.pojo.po.RStatPollutionSubstationM;
import com.njcn.harmonic.pojo.vo.PollutionSubstationVO;
import com.njcn.harmonic.service.PollutionSubstationService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
/**
*
* Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html
* Date: 2022/10/13 8:56【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Slf4j
@Service
@AllArgsConstructor
public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSubstationMMapper, RStatPollutionSubstationM> implements PollutionSubstationService {
private final SubstationFeignClient substationFeignClient;
private final RStatPollutionSubstationMMapper pollutionSubstationMMapper;
private final GeneralDeviceInfoClient generalDeviceInfoClient;
private final LineFeignClient lineFeignClient;
private final GeneralInfo generalInfo;
/**
* @param pollutionSubstationQuryParam
* @Description: getPollutionSubstationData
* @Param: [pollutionSubstationQuryParam]
* @return: java.util.List<com.njcn.harmonic.pojo.vo.PollutionSubstationVO>
* @Author: clam
* @Date: 2022/10/13
*/
@Override
public List<PollutionSubstationVO> getPollutionSubstationData(PollutionSubstationQuryParam pollutionSubstationQuryParam) {
List<PollutionSubstationVO> pollutionSubstationVOList = new ArrayList<> ();
/*根据部门获取变电站详情*/
HarmonicPublicParam harmonicPublicParam = new HarmonicPublicParam();
BeanUtils.copyProperties (pollutionSubstationQuryParam, harmonicPublicParam);
harmonicPublicParam.setServerName(generalInfo.getMicroServiceName());
List<PollutionSubstationDTO> pollutionSubstationDTOList = new ArrayList<>();
List<GeneralDeviceDTO> sub = generalDeviceInfoClient.getPracticalRunDeviceInfoAsSubstation(harmonicPublicParam).getData();
sub.forEach(item->{
PollutionSubstationDTO pollutionSubstationDTO = lineFeignClient.getSubstationInfo(item.getIndex()).getData();
pollutionSubstationDTOList.add(pollutionSubstationDTO);
});
List<String> collect = pollutionSubstationDTOList.stream ( ).map (PollutionSubstationDTO::getId).collect (Collectors.toList ( ));
List<SubstationDTO> locationData = substationFeignClient.getSubstationById (collect).getData ( );
/*todo 后期可以把locationData存入redis*/
/*把所有的变电站的污染指数查出来*/
QueryWrapper<RStatPollutionSubstationM> wrapper = new QueryWrapper<> ();
wrapper.in ("substation_id",collect).
eq ("pollution_type", pollutionSubstationQuryParam.getPollutionStatis ().getId ()).
apply("DATE_FORMAT( data_date ,'%Y-%m') = '"+pollutionSubstationQuryParam.getLocalDate ()+"'");
List<RStatPollutionSubstationM> rStatPollutionSubstationMList = pollutionSubstationMMapper.selectList (wrapper);
pollutionSubstationDTOList.forEach (substationInfo ->{
PollutionSubstationVO pollutionSubstationVO =new PollutionSubstationVO ();
pollutionSubstationVO.setSubstationId (substationInfo.getId ());
pollutionSubstationVO.setSubstationName (substationInfo.getName ());
/*todo 添加经纬度接口返回数据暂时没有*/
SubstationDTO substationDTO = locationData.stream ().filter (temp -> Objects.equals (substationInfo.getId ( ), temp.getId ())).
collect (Collectors.toList ( )).get (0);
pollutionSubstationVO.setLatitude (substationDTO.getLat ());
pollutionSubstationVO.setLongitude (substationDTO.getLng ());
Double value = Optional.ofNullable (
rStatPollutionSubstationMList.stream ( ).filter (temp -> Objects.equals (substationInfo.getId ( ), temp.getSubstationId ( ))).
collect (Collectors.toList ( )).get (0).getValue ( )
).orElse (new Double ("0.00"));
pollutionSubstationVO.setPollutionData (value);
pollutionSubstationVO.setPollutionStatis ( pollutionSubstationQuryParam.getStatisticalType ().getName ());
pollutionSubstationVOList.add (pollutionSubstationVO);
});
List<PollutionSubstationVO> result = pollutionSubstationVOList.stream ( ).sorted (Comparator.comparing (PollutionSubstationVO::getPollutionData).reversed ( )).collect (Collectors.toList ( ));
return result;
}
}

View File

@@ -1,27 +1,33 @@
package com.njcn.harmonic.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.njcn.common.config.GeneralInfo;
import com.njcn.common.pojo.dto.SimpleDTO;
import com.njcn.common.pojo.param.StatisticsBizBaseParam;
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.pq.enums.LineBaseEnum;
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
import com.njcn.harmonic.constant.Param;
import com.njcn.harmonic.mapper.RMpVThdMapper;
import com.njcn.harmonic.mapper.THDistortionMapper;
import com.njcn.harmonic.pojo.dto.PublicDTO;
import com.njcn.harmonic.pojo.po.RMpVThd;
import com.njcn.harmonic.pojo.vo.RMpVThdVO;
import com.njcn.harmonic.pojo.vo.THDistortionCensusVO;
import com.njcn.harmonic.pojo.vo.THDistortionVO;
import com.njcn.harmonic.service.THDistortionService;
import com.njcn.influxdb.utils.InfluxDbUtils;
import lombok.AllArgsConstructor;
import org.influxdb.dto.QueryResult;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
/**
@@ -41,6 +47,9 @@ public class THDistortionServiceImpl implements THDistortionService {
private final InfluxDbUtils influxDbUtils;
private final RMpVThdMapper rMpVThdMapper;
private final LineFeignClient lineFeignClient;
@Override
public List<THDistortionVO> getTHDistortionData(DeviceInfoParam.BusinessParam thDistortionParam) {
List<THDistortionVO> thDistortionVOS = new ArrayList<>();
@@ -96,6 +105,47 @@ public class THDistortionServiceImpl implements THDistortionService {
return distortionCensusVO;
}
/**
* @param statisticsBizBaseParam
* @Description: 谐波总畸变率前十列表
* @Param: [statisticsBizBaseParam]
* @return: java.util.List<com.njcn.harmonic.pojo.vo.RMpVThdVO>
* @Author: clam
* @Date: 2022/10/10
*/
@Override
public List<RMpVThdVO> getTHDTopTenData(StatisticsBizBaseParam statisticsBizBaseParam) {
List<RMpVThdVO> rMpVThdVOList = new ArrayList<> ();
DeviceInfoParam deviceInfoParam = new DeviceInfoParam ();
deviceInfoParam.setDeptIndex (statisticsBizBaseParam.getId ());
deviceInfoParam.setStatisticalType (new SimpleDTO ());
deviceInfoParam.setServerName (generalInfo.getMicroServiceName());
deviceInfoParam.setPowerFlag (0);
deviceInfoParam.setMonitorFlag (0);
/*获取按部门分类的实际所有终端综合信息*/
List<GeneralDeviceDTO> deviceList = generalDeviceInfoClient.getPracticalAllDeviceInfoAsDept (deviceInfoParam).getData ();
/*监测点ID扁平化*/
List<String> collect = deviceList.stream ( ).map (GeneralDeviceDTO::getLineIndexes).flatMap (Collection::stream).distinct ( ).collect (Collectors.toList ( ));
QueryWrapper<RMpVThd> wrapper = new QueryWrapper<>();
wrapper.in ("measurement_point_id",collect).
eq ("data_type", statisticsBizBaseParam.getType ()).
between ("data_date", statisticsBizBaseParam.getStartTime (), statisticsBizBaseParam.getEndTime ()).
orderByDesc ("v_thd").
last (" limit 10");
List<RMpVThd> rMpVThdList = rMpVThdMapper.selectList (wrapper);
rMpVThdVOList = rMpVThdList.stream ( ).map (rMpVThd -> {
RMpVThdVO rMpVThdVO = new RMpVThdVO ( );
BeanUtils.copyProperties (rMpVThd, rMpVThdVO);
/*查询监测点详情获取名称*/
LineDetailDataVO data = lineFeignClient.getLineDetailData (rMpVThd.getMeasurementPointId ( )).getData ( );
rMpVThdVO.setName (data.getLineName ());
return rMpVThdVO;
}).collect (Collectors.toList ( ));
return rMpVThdVOList;
}
/**
* 计算父级畸变率