1.界面二次值转换为一次值

2.bug调整
This commit is contained in:
xy
2024-08-14 21:08:49 +08:00
parent 2f1e899be7
commit 3b0525143b
3 changed files with 40 additions and 89 deletions

View File

@@ -44,5 +44,6 @@ public class EnergyBaseParam implements Serializable {
@ApiModelProperty("searchValue")
private String searchValue;
@ApiModelProperty("dataLevel")
private String dataLevel;
}

View File

@@ -1,7 +1,6 @@
package com.njcn.csdevice.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -49,14 +48,11 @@ import com.njcn.system.api.CsStatisticalSetFeignClient;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.api.EleEvtFeignClient;
import com.njcn.system.api.EpdFeignClient;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.pojo.po.DictData;
import com.njcn.system.pojo.po.EleEpdPqd;
import com.njcn.system.pojo.po.EleEvtParm;
import com.njcn.system.pojo.vo.CsStatisticalSetVO;
import com.njcn.system.pojo.vo.EleEpdPqdListVO;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -65,15 +61,12 @@ import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static com.njcn.csdevice.constant.DataParam.overlimitsGroup;
/**
* <p>
* 数据分组表 服务实现类
@@ -159,62 +152,16 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
StatisticalDataDTO statisticalDataDTO = commonService.getLineRtData(lineId,influxDbParamUtil.getTableNameByClassId(eleEpdPqd.getClassId()),item.getName(),item.getPhase(),item.getStatMethod(),influxDbParamUtil.getClDidByLineId(lineId));
if (Objects.nonNull(statisticalDataDTO)) {
vo.setTime(statisticalDataDTO.getTime());
}
if (Objects.isNull(dataLevel)) {
if (Objects.nonNull(statisticalDataDTO)) {
vo.setDataValue(BigDecimal.valueOf(statisticalDataDTO.getValue()).setScale(4, RoundingMode.UP).doubleValue());
//判断监测点类型 针对治理设备 模块数据是一次值、电能质量设备是二次值
if (csLinePO.getClDid() != 0 && Objects.equals("Primary",dataLevel) && ObjectUtil.isNotNull(eleEpdPqd.getPrimaryFormula())) {
double secondaryData = secondaryToPrimary(eleEpdPqd.getPrimaryFormula(), statisticalDataDTO.getValue(), csLinePO.getPtRatio(), csLinePO.getCtRatio());
vo.setDataValue(BigDecimal.valueOf(secondaryData).setScale(4, RoundingMode.UP).doubleValue());
} else {
vo.setDataValue(3.1415926);
vo.setDataValue(BigDecimal.valueOf(statisticalDataDTO.getValue()).setScale(4, RoundingMode.UP).doubleValue());
}
} else {
if ("Primary".equals(dataLevel)) {
if (Objects.nonNull(statisticalDataDTO)) {
vo.setDataValue(BigDecimal.valueOf(statisticalDataDTO.getValue()).setScale(4, RoundingMode.UP).doubleValue());
} else {
vo.setDataValue(3.1415926);
}
} else {
if (Objects.nonNull(statisticalDataDTO)) {
if (ObjectUtil.isNotNull(eleEpdPqd.getPrimaryFormula())) {
double secondaryData = secondaryToPrimary(eleEpdPqd.getPrimaryFormula(), statisticalDataDTO.getValue(), csLinePO.getPtRatio(), csLinePO.getCtRatio());
vo.setDataValue(BigDecimal.valueOf(secondaryData).setScale(4, RoundingMode.UP).doubleValue());
} else {
vo.setDataValue(BigDecimal.valueOf(statisticalDataDTO.getValue()).setScale(4, RoundingMode.UP).doubleValue());
}
} else {
vo.setDataValue(3.1415926);
}
}
vo.setDataValue(3.1415926);
}
// if (Objects.isNull(dataLevel)){
// if (!Objects.isNull(statisticalDataDTO)){
// vo.setTime(statisticalDataDTO.getTime());
// vo.setDataValue(BigDecimal.valueOf(statisticalDataDTO.getValue()).setScale(4, RoundingMode.UP).doubleValue());
// } else {
// vo.setDataValue(3.1415926);
// }
// } else {
// if (Objects.equals(dataLevel,"Primary")) {
// if (!Objects.isNull(statisticalDataDTO)){
// vo.setTime(statisticalDataDTO.getTime());
// vo.setDataValue(BigDecimal.valueOf(statisticalDataDTO.getValue()).setScale(4, RoundingMode.UP).doubleValue());
// } else {
// vo.setDataValue(3.1415926);
// }
// } else {
// if (!Objects.isNull(statisticalDataDTO)){
// vo.setTime(statisticalDataDTO.getTime());
// if (ObjectUtil.isNotNull(eleEpdPqd.getPrimaryFormula())) {
// double secondaryData = secondaryToPrimary(eleEpdPqd.getPrimaryFormula(),statisticalDataDTO.getValue(),csLinePO.getPtRatio(),csLinePO.getCtRatio());
// vo.setDataValue(BigDecimal.valueOf(secondaryData).setScale(4, RoundingMode.UP).doubleValue());
// } else {
// vo.setDataValue(BigDecimal.valueOf(statisticalDataDTO.getValue()).setScale(4, RoundingMode.UP).doubleValue());
// }
// } else {
// vo.setDataValue(3.1415926);
// }
// }
// }
arrayList.add(vo);
}
if (CollectionUtil.isNotEmpty(arrayList)){
@@ -245,23 +192,37 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
List<String> group = groupList.stream().map(DataGroupTemplateVO::getId).collect(Collectors.toList());
//获取当前组的所有指标项
List<EnergyTemplateVO> list = csDataArrayMapper.getArrayByGroup(group);
//获取所有字典指标
List<EleEpdPqd> epdPqdList = epdFeignClient.selectByIds(list.stream().map(EnergyTemplateVO::getDataId).distinct().collect(Collectors.toList())).getData();
Map<String, EleEpdPqd> eventTypeMap = epdPqdList.stream().collect(Collectors.toMap(EleEpdPqd::getId, Function.identity()));
//根据lineId获取监测点pt、ct变比
CsLinePO po = csLineFeignClient.queryLineById(Collections.singletonList(energyBaseParam.getLineId())).getData().get(0);
for (EnergyTemplateVO item : list) {
EnergyTemplateVO vo = new EnergyTemplateVO();
BeanUtils.copyProperties(item,vo);
EleEpdPqd eleEpdPqd = epdFeignClient.selectById(item.getDataId()).getData();
EleEpdPqd eleEpdPqd = eventTypeMap.get(item.getDataId());
vo.setClassId(eleEpdPqd.getClassId());
vo.setUnit(eleEpdPqd.getUnit());
StatisticalDataDTO statisticalDataDTO = commonService.getLineHistoryData(energyBaseParam.getLineId(),influxDbParamUtil.getTableNameByClassId(eleEpdPqd.getClassId()),item.getName(),energyBaseParam.getStartTime(),energyBaseParam.getEndTime(),influxDbParamUtil.getClDidByLineId(energyBaseParam.getLineId()));
if (!Objects.isNull(statisticalDataDTO)){
vo.setMaxValue(BigDecimal.valueOf(statisticalDataDTO.getMaxValue()).setScale(4, RoundingMode.UP).doubleValue());
vo.setMinValue(BigDecimal.valueOf(statisticalDataDTO.getMinValue()).setScale(4, RoundingMode.UP).doubleValue());
vo.setAvgValue(BigDecimal.valueOf(statisticalDataDTO.getAvgValue()).setScale(4, RoundingMode.UP).doubleValue());
StatisticalDataDTO statisticalDataDTO = commonService.getLineHistoryData(energyBaseParam.getLineId(),influxDbParamUtil.getTableNameByClassId(eleEpdPqd.getClassId()),item.getName(),energyBaseParam.getStartTime() + " 00:00:00",energyBaseParam.getEndTime() + " 23:59:59",influxDbParamUtil.getClDidByLineId(energyBaseParam.getLineId()));
if (Objects.nonNull(statisticalDataDTO)) {
vo.setTime(statisticalDataDTO.getTime());
//判断监测点类型 针对治理设备 模块数据是一次值、电能质量设备是二次值
if (po.getClDid() != 0 && Objects.equals("Primary",energyBaseParam.getDataLevel()) && ObjectUtil.isNotNull(eleEpdPqd.getPrimaryFormula())) {
double secondaryData1 = secondaryToPrimary(eleEpdPqd.getPrimaryFormula(), statisticalDataDTO.getMaxValue(), po.getPtRatio(), po.getCtRatio());
double secondaryData2 = secondaryToPrimary(eleEpdPqd.getPrimaryFormula(), statisticalDataDTO.getMinValue(), po.getPtRatio(), po.getCtRatio());
double secondaryData3 = secondaryToPrimary(eleEpdPqd.getPrimaryFormula(), statisticalDataDTO.getAvgValue(), po.getPtRatio(), po.getCtRatio());
vo.setMaxValue(BigDecimal.valueOf(secondaryData1).setScale(4, RoundingMode.UP).doubleValue());
vo.setMinValue(BigDecimal.valueOf(secondaryData2).setScale(4, RoundingMode.UP).doubleValue());
vo.setAvgValue(BigDecimal.valueOf(secondaryData3).setScale(4, RoundingMode.UP).doubleValue());
} else {
vo.setMaxValue(BigDecimal.valueOf(statisticalDataDTO.getMaxValue()).setScale(4, RoundingMode.UP).doubleValue());
vo.setMinValue(BigDecimal.valueOf(statisticalDataDTO.getMinValue()).setScale(4, RoundingMode.UP).doubleValue());
vo.setAvgValue(BigDecimal.valueOf(statisticalDataDTO.getAvgValue()).setScale(4, RoundingMode.UP).doubleValue());
}
} else {
vo.setMaxValue(3.1415956);
vo.setMinValue(3.1415956);
vo.setAvgValue(3.1415956);
}
arrayList.add(vo);
}