修改一次值二次值bug

This commit is contained in:
hzj
2024-12-18 16:23:54 +08:00
parent 6f38ddf068
commit 86d21f984c

View File

@@ -455,108 +455,154 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
//格式化前端参数
formatQueryParamList(commonStatisticalQueryParam);
if(commonStatisticalQueryParam.getList() != null && !commonStatisticalQueryParam.getList().isEmpty()){
for (CommonStatisticalQueryParam param : commonStatisticalQueryParam.getList()){
if(param.getStatisticalId() == null){
continue;
for (CommonStatisticalQueryParam param : commonStatisticalQueryParam.getList()){
if(param.getStatisticalId() == null){
continue;
}
List<EleEpdPqd> eleEpdPqds = csStatisticalSetFeignClient.queryStatisticalSelect(param.getStatisticalId()).getData();
for(WlRecord wl : data){
List<CsLinePO> finalCsLinePOList = csLineFeignClient.queryLineById(Arrays.asList(wl.getLineId())).getData();
CsDataSet csDataSet = csDataSetMapper.selectOne(new LambdaQueryWrapper<CsDataSet>().eq(CsDataSet::getId,finalCsLinePOList.get(0).getDataSetId()));
if(StrUtil.isBlank(csDataSet.getDataLevel())){
throw new BusinessException("当前测点数据集主要信息缺失,请联系管理员排查(测点表里面数据集id缺失)");
}
List<EleEpdPqd> eleEpdPqds = csStatisticalSetFeignClient.queryStatisticalSelect(param.getStatisticalId()).getData();
for(WlRecord wl : data){
List<CsLinePO> finalCsLinePOList = csLineFeignClient.queryLineById(Arrays.asList(wl.getLineId())).getData();
CsDataSet csDataSet = csDataSetMapper.selectOne(new LambdaQueryWrapper<CsDataSet>().eq(CsDataSet::getId,finalCsLinePOList.get(0).getDataSetId()));
if(StrUtil.isBlank(csDataSet.getDataLevel())){
throw new BusinessException("当前测点数据集主要信息缺失,请联系管理员排查(测点表里面数据集id缺失)");
}
Double ct = Double.valueOf(wlRecord.getCt())/wlRecord.getCt1();
Double pt =Double.valueOf(wlRecord.getPt())/wlRecord.getPt1();
Double ct = Double.valueOf(wlRecord.getCt())/wlRecord.getCt1();
Double pt =Double.valueOf(wlRecord.getPt())/wlRecord.getPt1();
List<CsEquipmentDeliveryDTO> data1 = equipmentFeignClient.queryDeviceById(Stream.of(wl.getDevId()).collect(Collectors.toList())).getData();
eleEpdPqds.forEach(epdPqd->{
List<CommonQueryParam> commonQueryParams = finalCsLinePOList.stream().map(temp -> {
CommonQueryParam commonQueryParam = new CommonQueryParam();
commonQueryParam.setLineId(temp.getLineId());
commonQueryParam.setTableName(influxDbParamUtil.getTableNameByClassId(epdPqd.getClassId()));
commonQueryParam.setColumnName(epdPqd.getName()+ (param.getFrequency() == null ? "":"_"+param.getFrequency()));
commonQueryParam.setPhasic(epdPqd.getPhase());
commonQueryParam.setStartTime(LocalDateTimeUtil.format(wl.getStartTime(), DateTimeFormatter.ofPattern(DataParam.timeFormat)));
commonQueryParam.setEndTime(LocalDateTimeUtil.format(wl.getEndTime(), DateTimeFormatter.ofPattern(DataParam.timeFormat)));
commonQueryParam.setDataType(commonStatisticalQueryParam.getValueType());
commonQueryParam.setProcess(data1.get(0).getProcess()+"");
commonQueryParam.setClDid(influxDbParamUtil.getClDidByLineId(temp.getLineId()));
return commonQueryParam;
}).collect(Collectors.toList());
List<StatisticalDataDTO> deviceRtData = commonService.getDeviceRtDataByTime(commonQueryParams);
//此处设空时为了有多段时将线条断开前端显示
if(!CollectionUtils.isEmpty(deviceRtData)){
deviceRtData.get(deviceRtData.size()-1).setValue(null);
}
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
String unit;
ThdDataVO vo = new ThdDataVO();
vo.setLineId(temp.getLineId());
vo.setPhase(Objects.equals("M",temp.getPhaseType())?null:temp.getPhaseType());
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
vo.setPosition(position);
vo.setTime(temp.getTime());
vo.setStatMethod(temp.getValueType());
if(temp.getValue()!=null) {
double re;
if (Objects.equals("Primary",commonStatisticalQueryParam.getDataLevel())) {
if (Objects.equals("Primary",csDataSet.getDataLevel())) {
vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
unit = epdPqd.getUnit();
} else {
if (HarmonicConstant.POWER_LIST.contains(epdPqd.getShowName())) {
re = DataChangeUtil.secondaryToPrimary(epdPqd.getPrimaryFormula(), temp.getValue(), pt, ct) / 1000;
vo.setStatisticalData(Double.valueOf(df.format(re)));
unit = "k" + epdPqd.getUnit();
} else {
vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
unit = epdPqd.getUnit();
}
}
} else {
if (Objects.equals("Primary",csDataSet.getDataLevel())) {
if (HarmonicConstant.POWER_LIST.contains(epdPqd.getShowName())) {
re = DataChangeUtil.primaryToSecondary(epdPqd.getPrimaryFormula(), temp.getValue(), pt, ct);
vo.setStatisticalData(Double.valueOf(df.format(re)));
} else {
vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
}
} else {
vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
}
List<CsEquipmentDeliveryDTO> data1 = equipmentFeignClient.queryDeviceById(Stream.of(wl.getDevId()).collect(Collectors.toList())).getData();
eleEpdPqds.forEach(epdPqd->{
List<CommonQueryParam> commonQueryParams = finalCsLinePOList.stream().map(temp -> {
CommonQueryParam commonQueryParam = new CommonQueryParam();
commonQueryParam.setLineId(temp.getLineId());
commonQueryParam.setTableName(influxDbParamUtil.getTableNameByClassId(epdPqd.getClassId()));
commonQueryParam.setColumnName(epdPqd.getName()+ (param.getFrequency() == null ? "":"_"+param.getFrequency()));
commonQueryParam.setPhasic(epdPqd.getPhase());
commonQueryParam.setStartTime(LocalDateTimeUtil.format(wl.getStartTime(), DateTimeFormatter.ofPattern(DataParam.timeFormat)));
commonQueryParam.setEndTime(LocalDateTimeUtil.format(wl.getEndTime(), DateTimeFormatter.ofPattern(DataParam.timeFormat)));
commonQueryParam.setDataType(commonStatisticalQueryParam.getValueType());
commonQueryParam.setProcess(data1.get(0).getProcess()+"");
commonQueryParam.setClDid(influxDbParamUtil.getClDidByLineId(temp.getLineId()));
return commonQueryParam;
}).collect(Collectors.toList());
List<StatisticalDataDTO> deviceRtData = commonService.getDeviceRtDataByTime(commonQueryParams);
//此处设空时为了有多段时将线条断开前端显示
if(!CollectionUtils.isEmpty(deviceRtData)){
deviceRtData.get(deviceRtData.size()-1).setValue(null);
}
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
String unit;
ThdDataVO vo = new ThdDataVO();
vo.setLineId(temp.getLineId());
vo.setPhase(Objects.equals("M",temp.getPhaseType())?null:temp.getPhaseType());
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
vo.setPosition(position);
vo.setTime(temp.getTime());
vo.setStatMethod(temp.getValueType());
if(temp.getValue()!=null) {
double re = 0;
if (Objects.equals("Primary",commonStatisticalQueryParam.getDataLevel())) {
if (Objects.equals("Primary",csDataSet.getDataLevel())) {
vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
unit = epdPqd.getUnit();
} else {
if(Objects.nonNull(epdPqd.getPrimaryFormula())){
switch (epdPqd.getPrimaryFormula()) {
case "*PT":
re = temp.getValue() * pt / 1000;
unit = "k" + epdPqd.getUnit();
break;
case "*CT":
re = temp.getValue() * ct;
unit = epdPqd.getUnit();
break;
case "*PT*CT":
re = temp.getValue() * pt * ct / 1000;
unit = "k" + epdPqd.getUnit();
break;
default:
re = temp.getValue();
unit = epdPqd.getUnit();
break;
}
vo.setStatisticalData(Double.valueOf(df.format(re)));
}else {
re = temp.getValue();
unit = epdPqd.getUnit();
vo.setStatisticalData(Double.valueOf(df.format(re)));
}
}
} else {
vo.setStatisticalData(null);
if (Objects.equals("Primary",commonStatisticalQueryParam.getDataLevel())) {
if (Objects.equals("Primary",csDataSet.getDataLevel())) {
unit = epdPqd.getUnit();
} else {
if (HarmonicConstant.POWER_LIST.contains(epdPqd.getShowName())) {
unit = "k" + epdPqd.getUnit();
} else {
unit = epdPqd.getUnit();
if (Objects.equals("Primary",csDataSet.getDataLevel())) {
if(Objects.nonNull(epdPqd.getPrimaryFormula())){
switch (epdPqd.getPrimaryFormula()) {
case "*PT":
re = temp.getValue() / pt;
break;
case "*CT":
re = temp.getValue() / ct;
break;
case "*PT*CT":
re = temp.getValue() / pt / ct;
break;
default:
re = temp.getValue();
break;
}
vo.setStatisticalData(Double.valueOf(df.format(re)));
}else {
re = temp.getValue();
vo.setStatisticalData(Double.valueOf(df.format(re)));
}
} else {
unit = epdPqd.getUnit();
vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
}
unit = epdPqd.getUnit();
}
vo.setUnit(unit);
vo.setStatisticalIndex(epdPqd.getId());
vo.setStatisticalName(epdPqd.getName());
vo.setAnotherName(epdPqd.getShowName());
return vo;
}).collect(Collectors.toList());
result.addAll(collect1);
});
}
} else {
vo.setStatisticalData(null);
if (Objects.equals("Primary",commonStatisticalQueryParam.getDataLevel())) {
if (Objects.equals("Primary",csDataSet.getDataLevel())) {
unit = epdPqd.getUnit();
} else {
if(Objects.nonNull(epdPqd.getPrimaryFormula())){
switch (epdPqd.getPrimaryFormula()) {
case "*PT":
unit = "k" + epdPqd.getUnit();
break;
case "*CT":
unit = epdPqd.getUnit();
break;
case "*PT*CT":
unit = "k" + epdPqd.getUnit();
break;
default:
unit = epdPqd.getUnit();
break;
}
}else {
unit = epdPqd.getUnit();
}
}
} else {
unit = epdPqd.getUnit();
}
}
vo.setUnit(unit);
vo.setStatisticalIndex(epdPqd.getId());
vo.setStatisticalName(epdPqd.getName());
vo.setAnotherName(epdPqd.getShowName());
return vo;
}).collect(Collectors.toList());
result.addAll(collect1);
});
}
}
}
return result;
}
@Override
public WlRecord findDevBaseData(WlRecordParam.Record param) {
LambdaQueryWrapper<WlRecord> lambdaQueryWrapper = new LambdaQueryWrapper<>();