新能源专项分析功能开发

This commit is contained in:
wr
2025-03-31 20:56:05 +08:00
parent 82d616a99c
commit f3679cf868
7 changed files with 252 additions and 286 deletions

View File

@@ -1,5 +1,6 @@
package com.njcn.prepare.harmonic.service.mysql.Impl.event;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.IdUtil;
import com.alibaba.excel.util.DateUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -7,9 +8,7 @@ import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
import com.njcn.device.biz.commApi.CommLineClient;
import com.njcn.device.biz.pojo.dto.LineDTO;
import com.njcn.device.biz.pojo.po.Overlimit;
import com.njcn.device.pq.api.NewStationClient;
import com.njcn.device.pq.api.OverLimitClient;
import com.njcn.device.pq.pojo.po.NewStation;
import com.njcn.event.pojo.constant.Param;
import com.njcn.harmonic.pojo.vo.PowerStatisticsTargetVO;
import com.njcn.harmonic.pojo.vo.ThdDataVO;
@@ -21,10 +20,16 @@ import com.njcn.prepare.harmonic.mapper.mysql.event.RActivePowerRangeMapper;
import com.njcn.prepare.harmonic.pojo.param.RActivePowerRangeParam;
import com.njcn.prepare.harmonic.pojo.po.RActivePowerRangePO;
import com.njcn.prepare.harmonic.service.mysql.event.RActivePowerRangeService;
import com.njcn.supervision.api.UserLedgerFeignClient;
import com.njcn.supervision.pojo.vo.user.NewUserReportVO;
import com.njcn.system.api.DictTreeFeignClient;
import com.njcn.system.enums.DicTreeEnum;
import com.njcn.system.pojo.vo.DictTreeVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.lang.reflect.Field;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
@@ -48,31 +53,20 @@ import java.util.stream.Collectors;
public class RActivePowerRangeServiceImpl extends MppServiceImpl<RActivePowerRangeMapper, RActivePowerRangePO> implements RActivePowerRangeService {
private final CommonService commonService;
private final IDataVService iDataVService;
private final IDataIService iDataIService;
private final DataPltService dataPltService;
private final DataInHarmVService dataInHarmVService;
private final DataHarmRateVService dataHarmRateVService;
private final DataFlucService dataFlucService;
private final CommLineClient commLineClient;
private final NewStationClient newStationClient;
private final DictTreeFeignClient dictTreeFeignClient;
private final OverLimitClient overLimitClient;
private final UserLedgerFeignClient userLedgerFeignClient;
private DateTimeFormatter formatter = DateTimeFormatter.ofPattern(Param.DATE_FORMAT);
private final DecimalFormat df = new DecimalFormat(com.njcn.harmonic.constant.Param.DECIMAL_FORMATSTR);
private SimpleDateFormat sdf = new SimpleDateFormat(Param.DATE_FORMAT);
private List<String> PHASE = Arrays.asList(InfluxDBTableConstant.PHASE_TYPE_A, InfluxDBTableConstant.PHASE_TYPE_B, InfluxDBTableConstant.PHASE_TYPE_C);
/**
@@ -97,6 +91,7 @@ public class RActivePowerRangeServiceImpl extends MppServiceImpl<RActivePowerRan
@Override
@Transactional(rollbackFor = Exception.class)
public List<PowerStatisticsTargetVO> record(RActivePowerRangeParam rActivePowerRangeParam) {
DictTreeVO windFarms = dictTreeFeignClient.queryByCode(DicTreeEnum.Wind_Farms.getCode()).getData();
if (rActivePowerRangeParam == null) {
rActivePowerRangeParam = new RActivePowerRangeParam();
}
@@ -110,10 +105,10 @@ public class RActivePowerRangeServiceImpl extends MppServiceImpl<RActivePowerRan
CommonQueryParam commonQueryParam = new CommonQueryParam();
//控制参数中如果search为true,则获取有功功率集合的时间段内为BaseParam中的searchBeginTime和searchEndTime(用于前端有功功率查询页面相关接口)
if (rActivePowerRangeParam.isSearch()) {
if(rActivePowerRangeParam.isSearchTimeFort()){
if (rActivePowerRangeParam.isSearchTimeFort()) {
startTime = rActivePowerRangeParam.getSearchBeginTime() + Param.BEGIN;
endTime = rActivePowerRangeParam.getSearchEndTime() + Param.END;
}else{
} else {
startTime = rActivePowerRangeParam.getSearchBeginTime();
endTime = rActivePowerRangeParam.getSearchEndTime();
}
@@ -145,11 +140,10 @@ public class RActivePowerRangeServiceImpl extends MppServiceImpl<RActivePowerRan
//获取监测点
LineDTO lineDTO = commLineClient.getLineDetail(lineId).getData();
//监测点必须绑定新能源站
if (lineDTO != null && lineDTO.getNewStationId() != null) {
//获取监测点的新能源站
NewStation newStation = newStationClient.selectById(lineDTO.getNewStationId()).getData();
//新能源站有些必须是风电场
if (newStation != null && com.njcn.device.pq.constant.Param.WINDFARM.equals(newStation.getStationType())) {
if (lineDTO != null && lineDTO.getObjId() != null && windFarms.getId().equals(lineDTO.getBigObjType())) {
List<NewUserReportVO> data = userLedgerFeignClient.getUserReportByIds(Collections.singletonList(lineDTO.getObjId())).getData();
if (CollUtil.isNotEmpty(data)) {
//新能源站有些必须是风电场
RActivePowerRangePO rActivePowerRangePO = new RActivePowerRangePO();
rActivePowerRangePO.setLineId(lineId);
rActivePowerRangePO.setTimeId(LocalDate.now());
@@ -174,7 +168,7 @@ public class RActivePowerRangeServiceImpl extends MppServiceImpl<RActivePowerRan
//设置时间为当前功率的时间
powerStatisticsTargetVO.setTime(statisticalDataDTO.getTime().atZone(ZoneId.systemDefault()).format(formatter));
//当前功率的p字段 / 风电场额定功率
double temp = statisticalDataDTO.getValue() / Double.parseDouble(newStation.getRatedPower());
double temp = statisticalDataDTO.getValue() / data.get(0).getRatePower();
//区间过滤下(如果进去此判断 那么只能是查询某个区间下的指标越限列表)
if (finalRActivePowerRangeParam.isSearch() && finalRActivePowerRangeParam.getField() != null) {
if (Double.parseDouble(finalRActivePowerRangeParam.getField()) < temp * 10 && temp * 10 <= Double.parseDouble(finalRActivePowerRangeParam.getField()) + 1) {
@@ -185,16 +179,16 @@ public class RActivePowerRangeServiceImpl extends MppServiceImpl<RActivePowerRan
} else {
//否则是正常的定时任务插入,或者前端搜索插入
//设置每个区间的统计时间
rActivePowerRangePO.setMinsTime0(commonQueryParam.getStartTime()+","+commonQueryParam.getEndTime());
rActivePowerRangePO.setMinsTime1(commonQueryParam.getStartTime()+","+commonQueryParam.getEndTime());
rActivePowerRangePO.setMinsTime2(commonQueryParam.getStartTime()+","+commonQueryParam.getEndTime());
rActivePowerRangePO.setMinsTime3(commonQueryParam.getStartTime()+","+commonQueryParam.getEndTime());
rActivePowerRangePO.setMinsTime4(commonQueryParam.getStartTime()+","+commonQueryParam.getEndTime());
rActivePowerRangePO.setMinsTime5(commonQueryParam.getStartTime()+","+commonQueryParam.getEndTime());
rActivePowerRangePO.setMinsTime6(commonQueryParam.getStartTime()+","+commonQueryParam.getEndTime());
rActivePowerRangePO.setMinsTime7(commonQueryParam.getStartTime()+","+commonQueryParam.getEndTime());
rActivePowerRangePO.setMinsTime8(commonQueryParam.getStartTime()+","+commonQueryParam.getEndTime());
rActivePowerRangePO.setMinsTime9(commonQueryParam.getStartTime()+","+commonQueryParam.getEndTime());
rActivePowerRangePO.setMinsTime0(commonQueryParam.getStartTime() + "," + commonQueryParam.getEndTime());
rActivePowerRangePO.setMinsTime1(commonQueryParam.getStartTime() + "," + commonQueryParam.getEndTime());
rActivePowerRangePO.setMinsTime2(commonQueryParam.getStartTime() + "," + commonQueryParam.getEndTime());
rActivePowerRangePO.setMinsTime3(commonQueryParam.getStartTime() + "," + commonQueryParam.getEndTime());
rActivePowerRangePO.setMinsTime4(commonQueryParam.getStartTime() + "," + commonQueryParam.getEndTime());
rActivePowerRangePO.setMinsTime5(commonQueryParam.getStartTime() + "," + commonQueryParam.getEndTime());
rActivePowerRangePO.setMinsTime6(commonQueryParam.getStartTime() + "," + commonQueryParam.getEndTime());
rActivePowerRangePO.setMinsTime7(commonQueryParam.getStartTime() + "," + commonQueryParam.getEndTime());
rActivePowerRangePO.setMinsTime8(commonQueryParam.getStartTime() + "," + commonQueryParam.getEndTime());
rActivePowerRangePO.setMinsTime9(commonQueryParam.getStartTime() + "," + commonQueryParam.getEndTime());
if (temp <= 0.1) {
//占有率区间个数+1
rActivePowerRangePO.setMinsNum0(rActivePowerRangePO.getMinsNum0() + 1);
@@ -348,37 +342,39 @@ public class RActivePowerRangeServiceImpl extends MppServiceImpl<RActivePowerRan
}
//区间是否越限标识
switch (type) {
case 0:
if (isLimit) rActivePowerRangePO.setIsOrNot0(1);
break;
case 1:
if (isLimit) rActivePowerRangePO.setIsOrNot1(1);
break;
case 2:
if (isLimit) rActivePowerRangePO.setIsOrNot2(1);
break;
case 3:
if (isLimit) rActivePowerRangePO.setIsOrNot3(1);
break;
case 4:
if (isLimit) rActivePowerRangePO.setIsOrNot4(1);
break;
case 5:
if (isLimit) rActivePowerRangePO.setIsOrNot5(1);
break;
case 6:
if (isLimit) rActivePowerRangePO.setIsOrNot6(1);
break;
case 7:
if (isLimit) rActivePowerRangePO.setIsOrNot7(1);
break;
case 8:
if (isLimit) rActivePowerRangePO.setIsOrNot8(1);
break;
case 9:
if (isLimit) rActivePowerRangePO.setIsOrNot9(1);
break;
if (isLimit) {
switch (type) {
case 0:
rActivePowerRangePO.setIsOrNot0(1);
break;
case 1:
rActivePowerRangePO.setIsOrNot1(1);
break;
case 2:
rActivePowerRangePO.setIsOrNot2(1);
break;
case 3:
rActivePowerRangePO.setIsOrNot3(1);
break;
case 4:
rActivePowerRangePO.setIsOrNot4(1);
break;
case 5:
rActivePowerRangePO.setIsOrNot5(1);
break;
case 6:
rActivePowerRangePO.setIsOrNot6(1);
break;
case 7:
rActivePowerRangePO.setIsOrNot7(1);
break;
case 8:
rActivePowerRangePO.setIsOrNot8(1);
break;
case 9:
rActivePowerRangePO.setIsOrNot9(1);
break;
}
}
}
@@ -388,12 +384,12 @@ public class RActivePowerRangeServiceImpl extends MppServiceImpl<RActivePowerRan
StatisticalDataDTO maxDto = maxList.stream().max(Comparator.comparingDouble(StatisticalDataDTO::getValue)).orElse(null);
StatisticalDataDTO minDto = minList.stream().min(Comparator.comparingDouble(StatisticalDataDTO::getValue)).orElse(null);
if (!maxList.isEmpty()) {
if (Double.compare(maxDto.getValue(), 0) > 0 && Double.compare(maxDto.getValue(), overlimit.getVoltageDev()) > 0) {
if (Double.compare(maxDto.getValue(), 0) > 0 && Double.compare(maxDto.getValue(), overlimit.getVoltageDev()) < 0) {
return overlimit.getVoltageDev();
}
}
if (!minList.isEmpty()) {
if (Double.compare(minDto.getValue(), 0) < 0 && Double.compare(maxDto.getValue(), overlimit.getUvoltageDev()) > 0) {
if (Double.compare(minDto.getValue(), 0) < 0 && Double.compare(minDto.getValue(), overlimit.getUvoltageDev()) > 0) {
return overlimit.getUvoltageDev();
}
}
@@ -469,7 +465,7 @@ public class RActivePowerRangeServiceImpl extends MppServiceImpl<RActivePowerRan
//反射获取当前谐波次数对应的国标限值
Float frequencyLimit = (Float) reflexObjValue(overlimit, finalField + frequencyNum);
//相别和统计方式的值和ThdDataVO字段相对于
ThdDataVO tdv = initThdDataVO(frequencyGroupList,frequencyLimit);
ThdDataVO tdv = initThdDataVO(frequencyGroupList, frequencyLimit);
if (tdv != null) {
tdv.setAnotherName(name + (((frequencyNum - finalC) + "").replace(".0", "")) + "");
tdv.setLimit((Float) reflexObjValue(overlimit, finalField + frequencyNum));
@@ -479,7 +475,7 @@ public class RActivePowerRangeServiceImpl extends MppServiceImpl<RActivePowerRan
});
} else {
//无谐波次数
ThdDataVO tdv = initThdDataVO(list,limit);
ThdDataVO tdv = initThdDataVO(list, limit);
if (tdv != null) {
tdv.setAnotherName(name);
tdv.setLimit(limit);
@@ -489,7 +485,7 @@ public class RActivePowerRangeServiceImpl extends MppServiceImpl<RActivePowerRan
return thdDataVOS.stream().sorted(Comparator.comparing(ThdDataVO::getFrequency)).collect(Collectors.toList());
}
private ThdDataVO initThdDataVO(List<StatisticalDataDTO> list,Float limit) {
private ThdDataVO initThdDataVO(List<StatisticalDataDTO> list, Float limit) {
ThdDataVO tdv = new ThdDataVO();
boolean isF = false;
//list包含了一组不同相别不同统计方式的数据(最多12条,因为统计方式和相别自由组合最多12条)
@@ -500,7 +496,7 @@ public class RActivePowerRangeServiceImpl extends MppServiceImpl<RActivePowerRan
if (statisticalDataDTO.getValue() != null) {
value = df.format(statisticalDataDTO.getValue());
//判断是否有指标越界(不管哪一个相别及统计方式的指标,)
if(Double.compare(statisticalDataDTO.getValue(), limit) > 0){
if (Double.compare(statisticalDataDTO.getValue(), limit) > 0) {
isF = true;
}
}
@@ -567,7 +563,7 @@ public class RActivePowerRangeServiceImpl extends MppServiceImpl<RActivePowerRan
|| tdv.getMINPhaseA() != null || tdv.getMINPhaseB() != null
|| tdv.getMINPhaseC() != null || tdv.getMAXPhaseA() != null
|| tdv.getMAXPhaseB() != null || tdv.getMAXPhaseC() != null) {
if(isF){
if (isF) {
return tdv;
}
}

View File

@@ -7,11 +7,9 @@ import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
import com.njcn.device.biz.commApi.CommLineClient;
import com.njcn.device.pms.pojo.param.MonitorTerminalParam;
import com.njcn.device.pq.api.DeptLineFeignClient;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.pq.api.NewStationClient;
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
import com.njcn.event.api.EventDetailFeignClient;
import com.njcn.event.api.TransientFeignClient;
@@ -54,8 +52,6 @@ import java.util.stream.Collectors;
public class SpThroughServiceImpl extends MppServiceImpl<SpThroughMapper, SpThroughPO> implements SpThroughService {
private final EventDetailFeignClient eventDetailFeignClient;
private final CommLineClient commLineClient;
private final NewStationClient newStationClient;
private final TransientFeignClient transientFeignClient;
private final DeptLineFeignClient deptLineFeignClient;
private final UserLedgerFeignClient userLedgerFeignClient;
@@ -129,17 +125,17 @@ public class SpThroughServiceImpl extends MppServiceImpl<SpThroughMapper, SpThro
if (rmpEventDetailPO.getEventType().equals(rise.getId())) {
//风电场
if (line.getBigObjType().equals(windFarms.getId())) {
if (isThrough(waveDataDTO, 125, 130, 500, voltageLevel.floatValue(), newListRmsData)
&& isThrough(waveDataDTO, 120, 125, 1000, voltageLevel.floatValue(), newListRmsData)
&& isThrough(waveDataDTO, 110, 120, 10000, voltageLevel.floatValue(), newListRmsData)) {
if (isThrough(125, 130, 500, voltageLevel.floatValue(), newListRmsData)
&& isThrough(120, 125, 1000, voltageLevel.floatValue(), newListRmsData)
&& isThrough(110, 120, 10000, voltageLevel.floatValue(), newListRmsData)) {
spThroughPO.setIsOrNot(1);
}
}
//光伏电站
if (line.getBigObjType().equals(powerStation.getId())) {
if (isThrough(waveDataDTO, 125, 130, 500, voltageLevel.floatValue(), newListRmsData)
&& isThrough(waveDataDTO, 120, 125, 1000, voltageLevel.floatValue(), newListRmsData)
&& isThrough(waveDataDTO, 110, 120, 10000, voltageLevel.floatValue(), newListRmsData)) {
if (isThrough(125, 130, 500, voltageLevel.floatValue(), newListRmsData)
&& isThrough(120, 125, 1000, voltageLevel.floatValue(), newListRmsData)
&& isThrough(110, 120, 10000, voltageLevel.floatValue(), newListRmsData)) {
spThroughPO.setIsOrNot(1);
}
}
@@ -148,15 +144,15 @@ public class SpThroughServiceImpl extends MppServiceImpl<SpThroughMapper, SpThro
if (rmpEventDetailPO.getEventType().equals(dip.getId())) {
//风电场
if (line.getBigObjType().equals(windFarms.getId())) {
if (isThrough(waveDataDTO, 20, -1, 625, voltageLevel.floatValue(), newListRmsData)) {
if (isThrough(20, -1, 625, voltageLevel.floatValue(), newListRmsData)) {
spThroughPO.setIsOrNot(1);
}
}
//光伏电站
if (line.getBigObjType().equals(powerStation.getId())) {
if (isThrough(waveDataDTO, 0, -1, 150, voltageLevel.floatValue(), newListRmsData)
&& isThrough(waveDataDTO, 20, -1, 625, voltageLevel.floatValue(), newListRmsData)
&& isThrough(waveDataDTO, 20, 90, -1, voltageLevel.floatValue(), newListRmsData)) {
if (isThrough(0, -1, 150, voltageLevel.floatValue(), newListRmsData)
&& isThrough(20, -1, 625, voltageLevel.floatValue(), newListRmsData)
&& isThrough(20, 90, -1, voltageLevel.floatValue(), newListRmsData)) {
spThroughPO.setIsOrNot(1);
}
}
@@ -164,8 +160,6 @@ public class SpThroughServiceImpl extends MppServiceImpl<SpThroughMapper, SpThro
spThroughPO.setCreateTime(currentTime);
this.baseMapper.insert(spThroughPO);
}
;
}
}
@@ -174,7 +168,7 @@ public class SpThroughServiceImpl extends MppServiceImpl<SpThroughMapper, SpThro
}
}
private boolean isThrough(WaveDataDTO waveDataDTO, int start, int end, int ms, float voltageLevel, List<List<Float>> newListRmsData) {
private boolean isThrough(int start, int end, int ms, float voltageLevel, List<List<Float>> newListRmsData) {
boolean isThrough = false;
//格式化RMS源数据
float startVoltageLevel = voltageLevel * (start / 100F);
@@ -187,11 +181,9 @@ public class SpThroughServiceImpl extends MppServiceImpl<SpThroughMapper, SpThro
float curValue = newListRmsData.get(i).get(j);
//当电压达到目标值时
if (endVoltageLevel != -1 && startVoltageLevel < curValue && curValue <= endVoltageLevel) {
isContinuity(newListRmsData, i + 1, newListRmsData.get(i).get(0).intValue(), ms, j);
isThrough = true;
isThrough = isContinuity(newListRmsData, i + 1, newListRmsData.get(i).get(0).intValue(), ms, j);
} else if (startVoltageLevel == curValue) {
isContinuity(newListRmsData, i + 1, newListRmsData.get(i).get(0).intValue(), ms, j);
isThrough = true;
isThrough = isContinuity(newListRmsData, i + 1, newListRmsData.get(i).get(0).intValue(), ms, j);
}
}
}
@@ -327,7 +319,7 @@ public class SpThroughServiceImpl extends MppServiceImpl<SpThroughMapper, SpThro
private String dicTreeId(SpThroughParam spThroughParam) {
String dictTreeId = "";
if (spThroughParam.getStationType().equals("1")) {
if ("1".equals(spThroughParam.getStationType())) {
DictTreeVO windFarms = dictTreeFeignClient.queryByCode(DicTreeEnum.Wind_Farms.getCode()).getData();
if (ObjectUtil.isNotNull(windFarms)) {
dictTreeId = windFarms.getId();