优化污染值算法增加是否零票判断

This commit is contained in:
wr
2026-01-22 09:20:45 +08:00
parent 718fd012c8
commit 1aae135e83
9 changed files with 95 additions and 35 deletions

View File

@@ -122,9 +122,9 @@ public class ExecutionCenter extends BaseController {
startDate = DateUtil.offsetDay(startDate, 1);
}
calculatedParam.setDataDate(DateUtil.format(startDate, DatePattern.NORM_DATE_PATTERN));
// CalculatedParam repairParam = BeanUtil.copyProperties(calculatedParam, CalculatedParam.class);
calculatedParam.setType(0);
flowService.execute2Resp(methodDescribe, calculatedParam);
CalculatedParam repairParam = BeanUtil.copyProperties(calculatedParam, CalculatedParam.class);
repairParam.setType(0);
flowService.execute2Resp(methodDescribe, repairParam);
}
} else {
//非补招

View File

@@ -58,7 +58,7 @@ public class DataComAssServiceImpl implements IDataComAssService {
lineParam.setStartTime(TimeUtils.getBeginOfDay(calculatedParam.getDataDate()));
lineParam.setEndTime(TimeUtils.getEndOfDay(calculatedParam.getDataDate()));
List<String> lineIdList = calculatedParam.getIdList();
getAbnormalData(lineParam);
//getAbnormalData(lineParam);
for (String lineId : lineIdList) {
DataComassesDPO rStatComassesDpo = new DataComassesDPO();
rStatComassesDpo.setTime(calculatedParam.getDataDate());

View File

@@ -80,19 +80,21 @@ public class PollutionCalcImpl implements IPollutionCalc {
LineDevGetDTO line = lineDetailMap.get(id);
if (limitMap.containsKey(id)) {
Overlimit overlimit = limitMap.get(id);
dataPollutionD = new DataPollutionD();
dataPollutionD.setLineId(id);
dataPollutionD.setDataDate(LocalDateTimeUtil.parseDate(calculatedParam.getDataDate()));
dataPollutionD.setPollutionType(vHarmonicLimit);
lineParam.setValueType(Arrays.asList(line.getTimeInterval() + ""));
lineParam.setLineId(Arrays.asList(id));
List<DataVDto> dataVDtoList = dataVFeignClient.getGroupByTimeDataV(lineParam).getData();
List<DataHarmDto> dataHarmDtoList = dataHarmRateVFeignClient.getGroupByTimeHarmRateV(lineParam).getData();
//计算谐波电压污染值
dataPollutionD.setValue(PubUtils.doubleRound(2, calcVAllPollutionValue(dataVDtoList, dataHarmDtoList, overlimit) * line.getTimeInterval()));
if(!dataVFeignClient.excludeZeroData(lineParam).getData()){
dataPollutionD = new DataPollutionD();
dataPollutionD.setLineId(id);
dataPollutionD.setDataDate(LocalDateTimeUtil.parseDate(calculatedParam.getDataDate()));
dataPollutionD.setPollutionType(vHarmonicLimit);
List<DataVDto> dataVDtoList = dataVFeignClient.getGroupByTimeDataV(lineParam).getData();
List<DataHarmDto> dataHarmDtoList = dataHarmRateVFeignClient.getGroupByTimeHarmRateV(lineParam).getData();
//计算谐波电压污染值
dataPollutionD.setValue(PubUtils.doubleRound(2, calcVAllPollutionValue(dataVDtoList, dataHarmDtoList, overlimit) * line.getTimeInterval()));
list.add(dataPollutionD);
}
list.add(dataPollutionD);
dataPollutionD = new DataPollutionD();
dataPollutionD.setLineId(id);
dataPollutionD.setDataDate(LocalDateTimeUtil.parseDate(calculatedParam.getDataDate()));

View File

@@ -68,4 +68,8 @@ public interface DataVFeignClient {
//按时间分组获取原始数据
@PostMapping("/getGroupByTimeDataV")
HttpResult<List<DataVDto>> getGroupByTimeDataV(@RequestBody LineCountEvaluateParam lineParam);
@PostMapping("/excludeZeroData")
HttpResult<Boolean> excludeZeroData(@RequestBody LineCountEvaluateParam lineParam);
}

View File

@@ -116,6 +116,12 @@ public class DataVFeignClientFallbackFactory implements FallbackFactory<DataVFei
log.error("{}异常,降级处理,异常为:{}","DataV按时间分组获取原始数据",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<Boolean> excludeZeroData(LineCountEvaluateParam lineParam) {
log.error("{}异常,降级处理,异常为:{}","判断是否存在是零飘数据",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -166,6 +166,15 @@ public class DataVController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, dataV, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/excludeZeroData")
@ApiOperation("判断是否存在是零飘数据")
public HttpResult<Boolean> excludeZeroData(@RequestBody LineCountEvaluateParam lineParam) {
String methodDescribe = getMethodDescribe("excludeZeroData");
Boolean b = dataVQuery.excludeZeroData(lineParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, b, methodDescribe);
}

View File

@@ -81,4 +81,17 @@ public interface IDataV extends IMppService<RStatDataVD> {
List<DataVDto> getDataV(LineCountEvaluateParam lineParam);
List<DataVDto> getGroupByTimeDataV(LineCountEvaluateParam lineParam);
/**
* 查看监测点的电压,判断是否存在是零飘数据
* 如果零飘数据占比一半多,则抛弃该监测点数据
* @param lineParam
* @return: java.lang.Boolean
* @Author: wr
* @Date: 2026/1/15 9:26
*/
Boolean excludeZeroData(LineCountEvaluateParam lineParam);
}

View File

@@ -208,7 +208,7 @@ public class InfluxdbDataVImpl extends MppServiceImpl<RStatDataVRelationMapper,
List<DataV> list = dataVMapper.selectByQueryWrapper(influxQueryWrapper);
if (CollUtil.isNotEmpty(list)) {
Map<String, List<String>> abnormalTime = lineParam.getAbnormalTime();
if(CollUtil.isNotEmpty(abnormalTime)){
if (CollUtil.isNotEmpty(abnormalTime)) {
if (abnormalTime.containsKey(lineParam.getLineId().get(0))) {
List<String> timeList = abnormalTime.get(lineParam.getLineId().get(0));
//有异常数据,当前监测点自身的异常数据
@@ -216,7 +216,7 @@ public class InfluxdbDataVImpl extends MppServiceImpl<RStatDataVRelationMapper,
result.addAll(list.stream().filter(item -> !timeList.contains(DATE_TIME_FORMATTER.format(item.getTime()))).collect(Collectors.toList()));
}
}
}else{
} else {
result.addAll(list);
}
}
@@ -390,8 +390,8 @@ public class InfluxdbDataVImpl extends MppServiceImpl<RStatDataVRelationMapper,
.groupBy(DataV::getLineId)
.between(DataV::getTime, startTime, endTime);
List<MeasurementCountDTO> measurementCountDTOList = dataVMapper.getMeasurementCount(influxQueryWrapper);
if(CollUtil.isNotEmpty(measurementCountDTOList)){
for(MeasurementCountDTO m : measurementCountDTOList){
if (CollUtil.isNotEmpty(measurementCountDTOList)) {
for (MeasurementCountDTO m : measurementCountDTOList) {
MeasurementCountDTO.MeasurementCountResultDTO p = new MeasurementCountDTO.MeasurementCountResultDTO();
p.setFreq(m.getFreq());
p.setLineId(m.getLineId());
@@ -425,6 +425,27 @@ public class InfluxdbDataVImpl extends MppServiceImpl<RStatDataVRelationMapper,
return result;
}
@Override
public Boolean excludeZeroData(LineCountEvaluateParam lineParam) {
InfluxQueryWrapper dataVQueryWrapper = new InfluxQueryWrapper(DataV.class);
dataVQueryWrapper.eq(DataV::getLineId, lineParam.getLineId().get(0))
.eq(DataV::getValueType, InfluxDbSqlConstant.AVG_WEB)
.ne(DataV::getPhasicType, InfluxDBTableConstant.PHASE_TYPE_T)
.select(DataV::getRms)
.between(DataV::getTime, lineParam.getStartTime(), lineParam.getEndTime());
List<DataV> rmsResult = dataVMapper.selectByQueryWrapper(dataVQueryWrapper);
if (CollUtil.isNotEmpty(rmsResult)) {
List<DataV> exceptionData = rmsResult.stream().filter(dataV -> dataV.getRms() < 1.0).collect(Collectors.toList());
if (CollUtil.isNotEmpty(exceptionData)) {
if (exceptionData.size() * 2 >= rmsResult.size()) {
return true;
}
}
}
return false;
}
/**
* 按监测点集合、时间条件获取dataV分钟数据
* timeMap参数来判断是否进行数据处理 timeMap为空则不进行数据处理
@@ -483,53 +504,53 @@ public class InfluxdbDataVImpl extends MppServiceImpl<RStatDataVRelationMapper,
CsLinePO po = lineMap.get(lineId);
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataV.class);
influxQueryWrapper.eq(DataV::getLineId, lineId)
.eq(DataV::getProcess,Integer.toString(devsMap.get(devId).getProcess()))
.eq(DataV::getProcess, Integer.toString(devsMap.get(devId).getProcess()))
.select(DataV::getLineId)
.select(DataV::getPhasicType)
.select(DataV::getValueType)
//频率
.select("Pq_Freq","freq")
.select("Pq_Freq", "freq")
//频率偏差
.select("Pq_FreqDev","freq_dev")
.select("Pq_FreqDev", "freq_dev")
//相电压有效值
.select("Pq_RmsU","rms")
.select("Pq_RmsU", "rms")
//线电压有效值
.select("Pq_RmsLU","rms_lvr")
.select("Pq_RmsLU", "rms_lvr")
//电压负序
.select("Pq_SeqNegU","v_neg")
.select("Pq_SeqNegU", "v_neg")
//电压正序
.select("Pq_SeqPosU","v_pos")
.select("Pq_SeqPosU", "v_pos")
//电压零序
.select("Pq_SeqZeroU","v_zero")
.select("Pq_SeqZeroU", "v_zero")
//电压负序不平衡度
.select("Pq_UnbalNegU","v_unbalance")
.select("Pq_UnbalNegU", "v_unbalance")
.between(DataV::getTime, lineParam.getStartTime(), lineParam.getEndTime())
.eq(DataV::getQualityFlag, "0");
if (CollUtil.isNotEmpty(lineParam.getPhasicType())) {
influxQueryWrapper.regular(DataV::getPhasicType, lineParam.getPhasicType());
}
if (Objects.isNull(po.getLineNo())) {
influxQueryWrapper.eq(DataV::getCldid,Integer.toString(po.getClDid()));
influxQueryWrapper.eq(DataV::getCldid, Integer.toString(po.getClDid()));
} else {
influxQueryWrapper.eq(DataV::getCldid,Integer.toString(po.getLineNo()));
influxQueryWrapper.eq(DataV::getCldid, Integer.toString(po.getLineNo()));
}
//判断接线方式 (0-星型 1-角型 2-V型) 星型是相电压 角型或者v型是线电压
if (Objects.equals(po.getConType(),0)) {
if (Objects.equals(po.getConType(), 0)) {
//相电压偏差
influxQueryWrapper.select("Pq_UDev","vu_dev");
influxQueryWrapper.select("Pq_UDev", "vu_dev");
//相电压谐波总畸变率
influxQueryWrapper.select("Pq_ThdU","v_thd");
influxQueryWrapper.select("Pq_ThdU", "v_thd");
//相电压基波有效值
influxQueryWrapper.select("Pq_RmsFundU","v_1");
influxQueryWrapper.select("Pq_RmsFundU", "v_1");
//2-50次 相电压谐波有效值
influxQueryWrapper.samePrefixAndSuffix("Pq_HarmUV_", "v_", HarmonicTimesUtil.harmonicTimesList(2, 50, 1));
} else {
//线电压偏差
influxQueryWrapper.select("Pq_LUDev","vu_dev");
influxQueryWrapper.select("Pq_LUDev", "vu_dev");
//线电压谐波总畸变率
influxQueryWrapper.select("Pq_ThdLU","v_thd");
influxQueryWrapper.select("Pq_ThdLU", "v_thd");
//线电压基波有效值
influxQueryWrapper.select("Pq_RmsFundLU","v_1");
influxQueryWrapper.select("Pq_RmsFundLU", "v_1");
//2-50次 线电压谐波有效值
influxQueryWrapper.samePrefixAndSuffix("Pq_HarmLUV_", "v_", HarmonicTimesUtil.harmonicTimesList(2, 50, 1));
}

View File

@@ -167,6 +167,11 @@ public class RelationDataVImpl extends MppServiceImpl<RStatDataVRelationMapper,
return Collections.emptyList();
}
@Override
public Boolean excludeZeroData(LineCountEvaluateParam lineParam) {
return null;
}
private List<DataVDto> quality(List<DataVDto> list, LineCountEvaluateParam lineParam) {
List<DataVDto> result = new ArrayList<>();
Map<String, List<DataVDto>> lineMap = list.stream().collect(Collectors.groupingBy(DataVDto::getLineId));