1.电能质量代码调整
2.微服务-监测点数据完整性调用中心任务 3.分布式光伏部分接口移植
This commit is contained in:
@@ -0,0 +1,150 @@
|
||||
package com.njcn.harmonic.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.device.pojo.param.DeviceInfoParam;
|
||||
import com.njcn.harmonic.pojo.param.HistoryParam;
|
||||
import com.njcn.harmonic.pojo.photoVO.WarningAreaVO;
|
||||
import com.njcn.harmonic.pojo.photoVO.WarningMonitorVO;
|
||||
import com.njcn.harmonic.pojo.vo.*;
|
||||
import com.njcn.harmonic.service.HistoryResultService;
|
||||
import com.njcn.harmonic.service.IAnalyzeService;
|
||||
import com.njcn.harmonic.service.PhotovoltaicService;
|
||||
import com.njcn.harmonic.service.SteadyQualifyService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/7/5 10:37
|
||||
*/
|
||||
@Validated
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/photovoltaicHarmonic")
|
||||
@Api(tags = "分布式光伏-稳态")
|
||||
@AllArgsConstructor
|
||||
public class PhotovoltaicController extends BaseController {
|
||||
|
||||
private final IAnalyzeService IAnalyzeService;
|
||||
|
||||
private final SteadyQualifyService steadyQualifyService;
|
||||
|
||||
private final HistoryResultService historyResultService;
|
||||
|
||||
private final PhotovoltaicService photovoltaicService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/overAreaStatistics")
|
||||
@ApiOperation("稳态指标超标统计")
|
||||
@ApiImplicitParam(name = "param", value = "实体参数", required = true)
|
||||
public HttpResult<Page<OverAreaLimitVO>> overAreaStatistics(@Validated @RequestBody OverAreaVO param) {
|
||||
String methodDescribe = getMethodDescribe("overAreaStatistics");
|
||||
LogUtil.njcnDebug(log, "{},实体参数:{}", methodDescribe, param);
|
||||
Page<OverAreaLimitVO> list = IAnalyzeService.getAreaData(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/test")
|
||||
@ApiOperation("有问题-稳态指标超标分类统计")
|
||||
@ApiImplicitParam(name = "param", value = "实体参数", required = true)
|
||||
public HttpResult<Page<OverAreaLimitVO>> test(@Validated @RequestBody OverAreaVO param) {
|
||||
String methodDescribe = getMethodDescribe("overAreaStatistics");
|
||||
LogUtil.njcnDebug(log, "{},实体参数:{}", methodDescribe, param);
|
||||
Page<OverAreaLimitVO> list = IAnalyzeService.getAreaData(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/lineOverLimit")
|
||||
@ApiOperation("稳态指标超标明细")
|
||||
@ApiImplicitParam(name = "param", value = "实体参数", required = true)
|
||||
public HttpResult<Page<MonitorOverLimitVO>> lineOverLimit(@Validated @RequestBody OverAreaVO param) {
|
||||
String methodDescribe = getMethodDescribe("lineOverLimit");
|
||||
LogUtil.njcnDebug(log, "{},实体参数:{}", methodDescribe, param);
|
||||
Page<MonitorOverLimitVO> list = IAnalyzeService.monitorOverLimitVO(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getSteadyQualifyData")
|
||||
@ApiOperation("稳态合格率统计")
|
||||
@ApiImplicitParam(name = "steadyParam", value = "稳态列表参数", required = true)
|
||||
public HttpResult<List<SteadyQualifyVO>> getSteadyQualifyData(@RequestBody @Validated DeviceInfoParam.BusinessParam steadyParam){
|
||||
String methodDescribe = getMethodDescribe("getSteadyQualifyData");
|
||||
List<SteadyQualifyVO> list = steadyQualifyService.getSteadyQualifyData(steadyParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getHistoryResult")
|
||||
@ApiOperation("稳态指标历史趋势")
|
||||
@ApiImplicitParam(name = "historyParam", value = "稳态数据分析参数", required = true)
|
||||
public HttpResult<List<HistoryDataResultVO>> getHistoryResult(@RequestBody @Validated HistoryParam historyParam) {
|
||||
String methodDescribe = getMethodDescribe("getHistoryResult");
|
||||
List<HistoryDataResultVO> list = historyResultService.getHistoryResult(historyParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/wholeEvaluation")
|
||||
@ApiOperation("有问题-全网水平评价")
|
||||
@ApiImplicitParam(name = "param", value = "实体参数", required = true)
|
||||
public HttpResult<List<HistoryDataResultVO>> wholeEvaluation(@Validated @RequestBody OverAreaVO param) {
|
||||
String methodDescribe = getMethodDescribe("wholeEvaluation");
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/areaWithEvaluation")
|
||||
@ApiOperation("有问题-台区水平评价")
|
||||
@ApiImplicitParam(name = "param", value = "实体参数", required = true)
|
||||
public HttpResult<List<HistoryDataResultVO>> areaWithEvaluation(@Validated @RequestBody OverAreaVO param) {
|
||||
String methodDescribe = getMethodDescribe("areaWithEvaluation");
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/areaWarningManage")
|
||||
@ApiOperation("区域告警管理")
|
||||
@ApiImplicitParam(name = "param", value = "实体参数", required = true)
|
||||
public HttpResult<Page<WarningAreaVO>> areaWarningManage(@Validated @RequestBody OverAreaVO param) {
|
||||
String methodDescribe = getMethodDescribe("areaWarningManage");
|
||||
Page<WarningAreaVO> page = photovoltaicService.areaWarningManage(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/monitorWarningManage")
|
||||
@ApiOperation("监测点告警管理")
|
||||
@ApiImplicitParam(name = "param", value = "实体参数", required = true)
|
||||
public HttpResult<Page<WarningMonitorVO>> monitorWarningManage(@Validated @RequestBody OverAreaVO param) {
|
||||
String methodDescribe = getMethodDescribe("monitorWarningManage");
|
||||
Page<WarningMonitorVO> page = photovoltaicService.monitorWarningManage(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.njcn.harmonic.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.harmonic.pojo.photoVO.WarningAreaVO;
|
||||
import com.njcn.harmonic.pojo.photoVO.WarningMonitorVO;
|
||||
import com.njcn.harmonic.pojo.vo.OverAreaVO;
|
||||
|
||||
/**
|
||||
* @author 徐扬
|
||||
*/
|
||||
public interface PhotovoltaicService {
|
||||
|
||||
/**
|
||||
* 功能描述:区域告警管理
|
||||
* @author xy
|
||||
* @param param 参数
|
||||
* @date 2022/7/7 9:48
|
||||
* @return 分页数据
|
||||
*/
|
||||
Page<WarningAreaVO> areaWarningManage(OverAreaVO param);
|
||||
|
||||
/**
|
||||
* 功能描述:监测点告警管理
|
||||
* @author xy
|
||||
* @param param 参数
|
||||
* @date 2022/7/7 9:48
|
||||
* @return 分页数据
|
||||
*/
|
||||
Page<WarningMonitorVO> monitorWarningManage(OverAreaVO param);
|
||||
|
||||
|
||||
}
|
||||
@@ -152,8 +152,6 @@ public class AnalyzeServiceImpl implements IAnalyzeService {
|
||||
LimitRate limitRate = map.get(item2).get(0);
|
||||
if (!Objects.isNull(limitRate)){
|
||||
onlineMonitorCount++;
|
||||
System.out.println("1==:" + limitRate.getFreqDevOverTime());
|
||||
System.out.println("2==:" + limitRate.getVoltageDevOverTime());
|
||||
if (limitRate.getFreqDevOverTime() > 0 || limitRate.getVoltageDevOverTime() > 0 || limitRate.getUBalanceOverTime() > 0 || limitRate.getFlickerOverTime() > 0 || limitRate.getINegOverTime() > 0 || limitRate.getUHarm2OverTime() > 0 || limitRate.getIHarm2OverTime() > 0 || limitRate.getInuHarm1OverTime() > 0){
|
||||
alertMonitorCount++;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,443 @@
|
||||
package com.njcn.harmonic.service.impl;
|
||||
|
||||
import com.alibaba.nacos.shaded.com.google.common.collect.Lists;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.device.api.GeneralDeviceInfoClient;
|
||||
import com.njcn.device.api.LineFeignClient;
|
||||
import com.njcn.device.pojo.dto.GeneralDeviceDTO;
|
||||
import com.njcn.device.pojo.dto.OverLimitLineDTO;
|
||||
import com.njcn.device.pojo.dto.PollutionParamDTO;
|
||||
import com.njcn.device.pojo.dto.WarningSubstationDTO;
|
||||
import com.njcn.harmonic.constant.Param;
|
||||
import com.njcn.harmonic.enums.HarmonicResponseEnum;
|
||||
import com.njcn.harmonic.pojo.photoVO.WarningAreaVO;
|
||||
import com.njcn.harmonic.pojo.photoVO.WarningMonitorVO;
|
||||
import com.njcn.harmonic.pojo.po.EventDetail;
|
||||
import com.njcn.harmonic.pojo.po.LimitRate;
|
||||
import com.njcn.harmonic.pojo.po.LimitTarget;
|
||||
import com.njcn.harmonic.pojo.vo.OverAreaVO;
|
||||
import com.njcn.harmonic.service.PhotovoltaicService;
|
||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.influxdb.dto.QueryResult;
|
||||
import org.influxdb.impl.InfluxDBResultMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/7/7 9:26
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class PhotovoltaicServiceImpl implements PhotovoltaicService {
|
||||
|
||||
private final GeneralDeviceInfoClient generalDeviceInfoClient;
|
||||
|
||||
private final InfluxDbUtils influxDbUtils;
|
||||
|
||||
private final LineFeignClient lineFeignClient;
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Page<WarningAreaVO> areaWarningManage(OverAreaVO param) {
|
||||
List<String> line = new ArrayList<>();
|
||||
Map<String,List<LimitRate>> map = new HashMap<>();
|
||||
Map<String,List<EventDetail>> map2 = new HashMap<>();
|
||||
Page<WarningAreaVO> page = new Page<>();
|
||||
List<WarningAreaVO> list = new ArrayList<>();
|
||||
page.setSize(param.getPageSize());
|
||||
page.setCurrent(param.getPageNum());
|
||||
List<GeneralDeviceDTO> subList = generalDeviceInfoClient.getPracticalRunDeviceInfo(param).getData();
|
||||
if (!CollectionUtils.isEmpty(subList)){
|
||||
page.setTotal(subList.size());
|
||||
int pages = (int)Math.ceil(subList.size()*1.0/param.getPageSize());
|
||||
page.setPages(pages);
|
||||
List<List<GeneralDeviceDTO>> pageList = Lists.partition(subList,param.getPageSize());
|
||||
List<GeneralDeviceDTO> temList = pageList.get(param.getPageNum()-1);
|
||||
temList.forEach(item->{
|
||||
line.addAll(item.getLineIndexes());
|
||||
});
|
||||
if (!CollectionUtils.isEmpty(line)){
|
||||
List<LimitRate> limitRateList = (List<LimitRate>)getAllData(line,param.getSearchBeginTime(),param.getSearchEndTime(), Param.LIMIT_RATE);
|
||||
if (!CollectionUtils.isEmpty(limitRateList)){
|
||||
map = limitRateList.stream().collect(Collectors.groupingBy(LimitRate::getLineId));
|
||||
}
|
||||
List<EventDetail> eventDetailList = getEventDetail(line,param.getSearchBeginTime(),param.getSearchEndTime());
|
||||
if (!CollectionUtils.isEmpty(eventDetailList)){
|
||||
map2 = eventDetailList.stream().collect(Collectors.groupingBy(EventDetail::getLineId));
|
||||
}
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(temList)){
|
||||
for (GeneralDeviceDTO item : temList) {
|
||||
int onlineMonitorCount = 0,alertMonitorCount = 0,alertCount = 0,freqCount = 0,voltageCount = 0,ubalanceCount = 0,flickerCount = 0,iNegCount = 0,uharmCount = 0,iharmCount = 0,inuharmCount = 0;
|
||||
int freqCounts = 0,voltageCounts = 0,uharmCounts = 0,iharmCounts = 0,ubalanceCounts = 0,flickerCounts = 0,inuharmCounts = 0,iNegCounts = 0;
|
||||
int eventUp = 0,eventDown = 0,eventInterrupt = 0,eventUps = 0,eventDowns = 0,eventInterrupts = 0;
|
||||
WarningAreaVO warningAreaVO = new WarningAreaVO();
|
||||
//单位id
|
||||
warningAreaVO.setId(item.getIndex());
|
||||
//单位名称
|
||||
warningAreaVO.setName(item.getName());
|
||||
if (!CollectionUtils.isEmpty(item.getLineIndexes())){
|
||||
for (String item2 : item.getLineIndexes()) {
|
||||
//谐波统计
|
||||
if (!CollectionUtils.isEmpty(map.get(item2))){
|
||||
LimitRate limitRate = map.get(item2).get(0);
|
||||
if (!Objects.isNull(limitRate)){
|
||||
onlineMonitorCount++;
|
||||
if (limitRate.getFreqDevOverTime() > 0 || limitRate.getVoltageDevOverTime() > 0 || limitRate.getUBalanceOverTime() > 0 || limitRate.getFlickerOverTime() > 0 || limitRate.getINegOverTime() > 0 || limitRate.getUHarm2OverTime() > 0 || limitRate.getIHarm2OverTime() > 0 || limitRate.getInuHarm1OverTime() > 0){
|
||||
alertMonitorCount++;
|
||||
}
|
||||
if (limitRate.getFreqDevOverTime() > 0){
|
||||
freqCount++;
|
||||
freqCounts = freqCounts + limitRate.getFreqDevOverTime();
|
||||
}
|
||||
if (limitRate.getVoltageDevOverTime() > 0){
|
||||
voltageCount++;
|
||||
voltageCounts = voltageCounts + limitRate.getVoltageDevOverTime();
|
||||
}
|
||||
if (limitRate.getUHarm2OverTime() > 0){
|
||||
uharmCount++;
|
||||
uharmCounts = uharmCounts + limitRate.getUHarm2OverTime();
|
||||
}
|
||||
if (limitRate.getIHarm2OverTime() > 0){
|
||||
iharmCount++;
|
||||
iharmCounts = iharmCounts + limitRate.getIHarm2OverTime();
|
||||
}
|
||||
if (limitRate.getUBalanceOverTime() > 0){
|
||||
ubalanceCount++;
|
||||
ubalanceCounts = ubalanceCounts + limitRate.getUBalanceOverTime();
|
||||
}
|
||||
if (limitRate.getFlickerOverTime() > 0){
|
||||
flickerCount++;
|
||||
flickerCounts = flickerCounts + limitRate.getFlickerOverTime();
|
||||
}
|
||||
if (limitRate.getInuHarm1OverTime() > 0){
|
||||
inuharmCount++;
|
||||
inuharmCounts = inuharmCounts + limitRate.getInuHarm1OverTime();
|
||||
}
|
||||
if (limitRate.getINegOverTime() > 0){
|
||||
iNegCount++;
|
||||
iNegCounts = iNegCounts + limitRate.getINegOverTime();
|
||||
}
|
||||
alertCount = limitRate.getFreqDevOverTime() + limitRate.getVoltageDevOverTime() + limitRate.getUBalanceOverTime() + limitRate.getFlickerOverTime() + limitRate.getINegOverTime() + limitRate.getUHarm2OverTime() + limitRate.getIHarm2OverTime() + limitRate.getInuHarm1OverTime();
|
||||
} else {
|
||||
log.info("此监测点在限值表中无数据:" + item2);
|
||||
throw new BusinessException(HarmonicResponseEnum.LIMIT_MISSING_ERROR);
|
||||
}
|
||||
}
|
||||
//暂降统计
|
||||
if (!CollectionUtils.isEmpty(map2.get(item2))){
|
||||
List<EventDetail> eventDetailList = map2.get(item2);
|
||||
if (!CollectionUtils.isEmpty(eventDetailList)){
|
||||
for (EventDetail item3 : eventDetailList) {
|
||||
if (item3.getWaveType() == 1){
|
||||
eventDowns++;
|
||||
} else if (item3.getWaveType() == 2){
|
||||
eventUps++;
|
||||
} else if (item3.getWaveType() == 3){
|
||||
eventInterrupts++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (eventDowns > 0){
|
||||
eventDown++;
|
||||
}
|
||||
if (eventUps > 0){
|
||||
eventUp++;
|
||||
}
|
||||
if (eventInterrupts > 0){
|
||||
eventInterrupt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
//在线监测点数量(个)
|
||||
warningAreaVO.setOnlineMonitorCounts(onlineMonitorCount);
|
||||
if (onlineMonitorCount != 0){
|
||||
//告警监测点数量(个)
|
||||
warningAreaVO.setAlertMonitorCounts(alertMonitorCount);
|
||||
//告警次数
|
||||
warningAreaVO.setAlertCounts(alertCount);
|
||||
//告警频次(次/点)
|
||||
warningAreaVO.setAlertAlarmFrequency(alertMonitorCount==0?0: BigDecimal.valueOf(alertCount*1.0/alertMonitorCount).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
//频率偏差
|
||||
warningAreaVO.setFrequencyDeviation(freqCount==0?0:BigDecimal.valueOf(freqCounts*1.0/freqCount).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
//电压偏差
|
||||
warningAreaVO.setVoltageDeviation(voltageCount==0?0:BigDecimal.valueOf(voltageCounts*1.0/voltageCount).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
//谐波电压
|
||||
warningAreaVO.setHarmonicVoltage(uharmCount==0?0:BigDecimal.valueOf(uharmCounts*1.0/uharmCount).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
//谐波电流
|
||||
warningAreaVO.setHarmonicCurrent(iharmCount==0?0:BigDecimal.valueOf(iharmCounts*1.0/iharmCount).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
//三相电压不平衡
|
||||
warningAreaVO.setThreePhaseVoltageUnbalance(ubalanceCount==0?0:BigDecimal.valueOf(ubalanceCounts*1.0/ubalanceCount).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
//闪变
|
||||
warningAreaVO.setFlicker(flickerCount==0?0:BigDecimal.valueOf(flickerCounts*1.0/flickerCount).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
//间谐波电压
|
||||
warningAreaVO.setInterHarmonic(inuharmCount==0?0:BigDecimal.valueOf(inuharmCounts*1.0/inuharmCount).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
//负序电流
|
||||
warningAreaVO.setNegative(iNegCount==0?0:BigDecimal.valueOf(iNegCounts*1.0/iNegCount).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
//电压暂降
|
||||
warningAreaVO.setVoltageDip(eventDown==0?0:BigDecimal.valueOf(eventDowns*1.0/eventDown).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
//电压暂升
|
||||
warningAreaVO.setVoltageSwell(eventUp==0?0:BigDecimal.valueOf(eventUps*1.0/eventUp).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
//短时中断
|
||||
warningAreaVO.setShortInterruption(eventInterrupt==0?0:BigDecimal.valueOf(eventInterrupts*1.0/eventInterrupt).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
}
|
||||
list.add(warningAreaVO);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(list)){
|
||||
List<WarningAreaVO> recordList = new ArrayList<>();
|
||||
//默认 在线监测点数量 倒叙排序
|
||||
recordList = list.stream().sorted(Comparator.comparing(WarningAreaVO::getOnlineMonitorCounts).reversed().thenComparing(WarningAreaVO::getName)).collect(Collectors.toList());
|
||||
page.setRecords(recordList);
|
||||
return page;
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Page<WarningMonitorVO> monitorWarningManage(OverAreaVO param) {
|
||||
List<String> line = new ArrayList<>(),temList = new ArrayList<>();
|
||||
Map<String,List<LimitRate>> map = new HashMap<>();
|
||||
Map<String,List<EventDetail>> map2 = new HashMap<>();
|
||||
Page<WarningMonitorVO> page = new Page<>();
|
||||
List<WarningMonitorVO> list = new ArrayList<>();
|
||||
page.setSize(param.getPageSize());
|
||||
page.setCurrent(param.getPageNum());
|
||||
List<GeneralDeviceDTO> areaList = generalDeviceInfoClient.getPracticalRunDeviceInfo(param).getData();
|
||||
if (!CollectionUtils.isEmpty(areaList)){
|
||||
areaList.forEach(item->{
|
||||
line.addAll(item.getLineIndexes());
|
||||
});
|
||||
if (!CollectionUtils.isEmpty(line)){
|
||||
page.setTotal(line.size());
|
||||
int pages = (int)Math.ceil(line.size()*1.0/param.getPageSize());
|
||||
page.setPages(pages);
|
||||
List<List<String>> pageList = Lists.partition(line,param.getPageSize());
|
||||
temList = pageList.get(param.getPageNum()-1);
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(temList)){
|
||||
List<LimitRate> limitRateList = (List<LimitRate>)getAllData(temList,param.getSearchBeginTime(),param.getSearchEndTime(), Param.LIMIT_RATE);
|
||||
if (!CollectionUtils.isEmpty(limitRateList)){
|
||||
map = limitRateList.stream().collect(Collectors.groupingBy(LimitRate::getLineId));
|
||||
}
|
||||
List<EventDetail> eventDetailList = getEventDetail(temList,param.getSearchBeginTime(),param.getSearchEndTime());
|
||||
if (!CollectionUtils.isEmpty(eventDetailList)){
|
||||
map2 = eventDetailList.stream().collect(Collectors.groupingBy(EventDetail::getLineId));
|
||||
}
|
||||
PollutionParamDTO pollutionParamDTO = new PollutionParamDTO();
|
||||
pollutionParamDTO.setLineList(temList);
|
||||
List<OverLimitLineDTO> overLimitLineList = lineFeignClient.getOverLimitLineInfo(pollutionParamDTO).getData();
|
||||
for (OverLimitLineDTO pojo:overLimitLineList) {
|
||||
String item = pojo.getId();
|
||||
String name = pojo.getLineName();
|
||||
int alertMonitorCount = 0,alertCount = 0,freqCount = 0,voltageCount = 0,ubalanceCount = 0,flickerCount = 0,iNegCount = 0,uharmCount = 0,iharmCount = 0,inuharmCount = 0;
|
||||
int freqCounts = 0,voltageCounts = 0,uharmCounts = 0,iharmCounts = 0,ubalanceCounts = 0,flickerCounts = 0,inuharmCounts = 0,iNegCounts = 0;
|
||||
int eventUp = 0,eventDown = 0,eventInterrupt = 0,eventUps = 0,eventDowns = 0,eventInterrupts = 0;
|
||||
WarningMonitorVO warningMonitorVO = new WarningMonitorVO();
|
||||
//监测点id
|
||||
warningMonitorVO.setId(item);
|
||||
//监测点名称
|
||||
warningMonitorVO.setName(name);
|
||||
//谐波统计
|
||||
if (!CollectionUtils.isEmpty(map.get(item))){
|
||||
LimitRate limitRate = map.get(item).get(0);
|
||||
if (!Objects.isNull(limitRate)){
|
||||
if (limitRate.getFreqDevOverTime() > 0 || limitRate.getVoltageDevOverTime() > 0 || limitRate.getUBalanceOverTime() > 0 || limitRate.getFlickerOverTime() > 0 || limitRate.getINegOverTime() > 0 || limitRate.getUHarm2OverTime() > 0 || limitRate.getIHarm2OverTime() > 0 || limitRate.getInuHarm1OverTime() > 0){
|
||||
alertMonitorCount++;
|
||||
}
|
||||
if (limitRate.getFreqDevOverTime() > 0){
|
||||
freqCount++;
|
||||
freqCounts = freqCounts + limitRate.getFreqDevOverTime();
|
||||
}
|
||||
if (limitRate.getVoltageDevOverTime() > 0){
|
||||
voltageCount++;
|
||||
voltageCounts = voltageCounts + limitRate.getVoltageDevOverTime();
|
||||
}
|
||||
if (limitRate.getUHarm2OverTime() > 0){
|
||||
uharmCount++;
|
||||
uharmCounts = uharmCounts + limitRate.getUHarm2OverTime();
|
||||
}
|
||||
if (limitRate.getIHarm2OverTime() > 0){
|
||||
iharmCount++;
|
||||
iharmCounts = iharmCounts + limitRate.getIHarm2OverTime();
|
||||
}
|
||||
if (limitRate.getUBalanceOverTime() > 0){
|
||||
ubalanceCount++;
|
||||
ubalanceCounts = ubalanceCounts + limitRate.getUBalanceOverTime();
|
||||
}
|
||||
if (limitRate.getFlickerOverTime() > 0){
|
||||
flickerCount++;
|
||||
flickerCounts = flickerCounts + limitRate.getFlickerOverTime();
|
||||
}
|
||||
if (limitRate.getInuHarm1OverTime() > 0){
|
||||
inuharmCount++;
|
||||
inuharmCounts = inuharmCounts + limitRate.getInuHarm1OverTime();
|
||||
}
|
||||
if (limitRate.getINegOverTime() > 0){
|
||||
iNegCount++;
|
||||
iNegCounts = iNegCounts + limitRate.getINegOverTime();
|
||||
}
|
||||
alertCount = limitRate.getFreqDevOverTime() + limitRate.getVoltageDevOverTime() + limitRate.getUBalanceOverTime() + limitRate.getFlickerOverTime() + limitRate.getINegOverTime() + limitRate.getUHarm2OverTime() + limitRate.getIHarm2OverTime() + limitRate.getInuHarm1OverTime();
|
||||
} else {
|
||||
log.info("此监测点在限值表中无数据:" + item);
|
||||
throw new BusinessException(HarmonicResponseEnum.LIMIT_MISSING_ERROR);
|
||||
}
|
||||
}
|
||||
//暂降统计
|
||||
if (!CollectionUtils.isEmpty(map2.get(item))){
|
||||
List<EventDetail> eventDetailList2 = map2.get(item);
|
||||
if (!CollectionUtils.isEmpty(eventDetailList2)){
|
||||
for (EventDetail item3 : eventDetailList2) {
|
||||
if (item3.getWaveType() == 1){
|
||||
eventDowns++;
|
||||
} else if (item3.getWaveType() == 2){
|
||||
eventUps++;
|
||||
} else if (item3.getWaveType() == 3){
|
||||
eventInterrupts++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (eventDowns > 0){
|
||||
eventDown++;
|
||||
}
|
||||
if (eventUps > 0){
|
||||
eventUp++;
|
||||
}
|
||||
if (eventInterrupts > 0){
|
||||
eventInterrupt++;
|
||||
}
|
||||
//告警次数
|
||||
warningMonitorVO.setAlertCounts(alertCount);
|
||||
//告警频次(次/点)
|
||||
warningMonitorVO.setAlertAlarmFrequency(alertMonitorCount==0?0: BigDecimal.valueOf(alertCount*1.0/alertMonitorCount).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
//频率偏差
|
||||
warningMonitorVO.setFrequencyDeviation(freqCount==0?0:BigDecimal.valueOf(freqCounts*1.0/freqCount).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
//电压偏差
|
||||
warningMonitorVO.setVoltageDeviation(voltageCount==0?0:BigDecimal.valueOf(voltageCounts*1.0/voltageCount).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
//谐波电压
|
||||
warningMonitorVO.setHarmonicVoltage(uharmCount==0?0:BigDecimal.valueOf(uharmCounts*1.0/uharmCount).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
//谐波电流
|
||||
warningMonitorVO.setHarmonicCurrent(iharmCount==0?0:BigDecimal.valueOf(iharmCounts*1.0/iharmCount).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
//三相电压不平衡
|
||||
warningMonitorVO.setThreePhaseVoltageUnbalance(ubalanceCount==0?0:BigDecimal.valueOf(ubalanceCounts*1.0/ubalanceCount).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
//闪变
|
||||
warningMonitorVO.setFlicker(flickerCount==0?0:BigDecimal.valueOf(flickerCounts*1.0/flickerCount).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
//间谐波电压
|
||||
warningMonitorVO.setInterHarmonic(inuharmCount==0?0:BigDecimal.valueOf(inuharmCounts*1.0/inuharmCount).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
//负序电流
|
||||
warningMonitorVO.setNegative(iNegCount==0?0:BigDecimal.valueOf(iNegCounts*1.0/iNegCount).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
//电压暂降
|
||||
warningMonitorVO.setVoltageDip(eventDown==0?0:BigDecimal.valueOf(eventDowns*1.0/eventDown).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
//电压暂升
|
||||
warningMonitorVO.setVoltageSwell(eventUp==0?0:BigDecimal.valueOf(eventUps*1.0/eventUp).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
//短时中断
|
||||
warningMonitorVO.setShortInterruption(eventInterrupt==0?0:BigDecimal.valueOf(eventInterrupts*1.0/eventInterrupt).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
list.add(warningMonitorVO);
|
||||
}
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(list)){
|
||||
List<WarningMonitorVO> recordList = new ArrayList<>();
|
||||
//默认 监测点告警次数 倒叙排序
|
||||
recordList = list.stream().sorted(Comparator.comparing(WarningMonitorVO::getAlertCounts).reversed()).collect(Collectors.toList());
|
||||
page.setRecords(recordList);
|
||||
return page;
|
||||
}
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 功能描述: 处理区域在线监测点数、超标监测点数
|
||||
* @param list 集合
|
||||
* @return
|
||||
* @author xy
|
||||
* @date 2022/2/25 15:05
|
||||
*/
|
||||
private List<?> getAllData(List<String> list, String startTime, String endTime, String databaseName){
|
||||
List<?> result = new ArrayList<>();
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
StringBuilder stringBuilder1 = new StringBuilder();
|
||||
stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and (");
|
||||
for (int i=0;i<list.size();i++){
|
||||
if (list.size() - i != 1){
|
||||
stringBuilder.append(Param.LINE_ID + "='").append(list.get(i)).append("' or ");
|
||||
} else {
|
||||
stringBuilder.append(Param.LINE_ID + "='").append(list.get(i)).append("')");
|
||||
}
|
||||
}
|
||||
stringBuilder.append(" group by line_id tz('Asia/Shanghai')");
|
||||
stringBuilder1.append("sum(freq_dev_overtime) AS freq_dev_overtime,sum(voltage_dev_overtime) AS voltage_dev_overtime,sum(ubalance_overtime) AS ubalance_overtime,sum(flicker_overtime) AS flicker_overtime,sum(i_neg_overtime) AS i_neg_overtime,");
|
||||
stringBuilder1.append("sum(uaberrance_overtime)+");
|
||||
for (int i = 2; i <= 25; i++) {
|
||||
if (i==25){
|
||||
stringBuilder1.append("sum(uharm_").append(i).append("_overtime) AS ").append("uharm_2").append("_overtime,");
|
||||
} else {
|
||||
stringBuilder1.append("sum(uharm_").append(i).append("_overtime)+");
|
||||
}
|
||||
}
|
||||
for (int i = 2; i <= 25; i++) {
|
||||
if (i==25){
|
||||
stringBuilder1.append("sum(iharm_").append(i).append("_overtime) AS ").append("iharm_2").append("_overtime,");
|
||||
} else {
|
||||
stringBuilder1.append("sum(iharm_").append(i).append("_overtime)+");
|
||||
}
|
||||
}
|
||||
for (int i = 1; i <= 16; i++) {
|
||||
if (i==16){
|
||||
stringBuilder1.append("sum(inuharm_").append(i).append("_overtime) AS ").append("inuharm_1").append("_overtime");
|
||||
} else {
|
||||
stringBuilder1.append("sum(inuharm_").append(i).append("_overtime)+");
|
||||
}
|
||||
}
|
||||
String sql = "select "+stringBuilder1+" from "+databaseName+" where " + stringBuilder;
|
||||
QueryResult sqlResult = influxDbUtils.query(sql);
|
||||
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
|
||||
switch (databaseName) {
|
||||
case Param.LIMIT_TARGET:
|
||||
result = resultMapper.toPOJO(sqlResult, LimitTarget.class);
|
||||
break;
|
||||
case Param.LIMIT_RATE:
|
||||
result = resultMapper.toPOJO(sqlResult,LimitRate.class);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<EventDetail> getEventDetail(List<String> list, String startTime, String endTime){
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and (");
|
||||
for (int i=0;i<list.size();i++){
|
||||
if (list.size() - i != 1){
|
||||
stringBuilder.append(Param.LINE_ID + "='").append(list.get(i)).append("' or ");
|
||||
} else {
|
||||
stringBuilder.append(Param.LINE_ID + "='").append(list.get(i)).append("')");
|
||||
}
|
||||
}
|
||||
stringBuilder.append(" group by line_id tz('Asia/Shanghai')");
|
||||
String sql = "select * from pqs_eventdetail where " + stringBuilder;
|
||||
QueryResult sqlResult = influxDbUtils.query(sql);
|
||||
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
|
||||
return resultMapper.toPOJO(sqlResult, EventDetail.class);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user