diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/EnergyBaseParam.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/EnergyBaseParam.java
index a815f63..45bd058 100644
--- a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/EnergyBaseParam.java
+++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/EnergyBaseParam.java
@@ -44,5 +44,6 @@ public class EnergyBaseParam implements Serializable {
@ApiModelProperty("searchValue")
private String searchValue;
-
+ @ApiModelProperty("dataLevel")
+ private String dataLevel;
}
diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsGroupServiceImpl.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsGroupServiceImpl.java
index 8aa3006..97caddb 100644
--- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsGroupServiceImpl.java
+++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsGroupServiceImpl.java
@@ -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;
-
/**
*
* 数据分组表 服务实现类
@@ -159,62 +152,16 @@ public class CsGroupServiceImpl extends ServiceImpl 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 impl
List group = groupList.stream().map(DataGroupTemplateVO::getId).collect(Collectors.toList());
//获取当前组的所有指标项
List list = csDataArrayMapper.getArrayByGroup(group);
+ //获取所有字典指标
+ List epdPqdList = epdFeignClient.selectByIds(list.stream().map(EnergyTemplateVO::getDataId).distinct().collect(Collectors.toList())).getData();
+ Map 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);
}
diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/DeviceDataTrendServiceImpl.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/DeviceDataTrendServiceImpl.java
index e51ad18..e03284d 100644
--- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/DeviceDataTrendServiceImpl.java
+++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/DeviceDataTrendServiceImpl.java
@@ -1,16 +1,13 @@
package com.njcn.csharmonic.service.impl;
-import com.njcn.common.pojo.exception.BusinessException;
+import cn.hutool.core.util.ObjectUtil;
import com.njcn.csdevice.api.CsLedgerFeignClient;
import com.njcn.csdevice.api.CsLineFeignClient;
-import com.njcn.csdevice.api.DataArrayFeignClient;
import com.njcn.csdevice.api.EquipmentFeignClient;
-import com.njcn.csdevice.enums.AlgorithmResponseEnum;
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
import com.njcn.csdevice.pojo.dto.LineParamDTO;
import com.njcn.csdevice.pojo.po.CsLedger;
import com.njcn.csdevice.pojo.po.CsLinePO;
-import com.njcn.csdevice.pojo.vo.EnergyTemplateVO;
import com.njcn.csharmonic.param.DevicDataTrendQueryParam;
import com.njcn.csharmonic.pojo.vo.ThdDataVO;
import com.njcn.csharmonic.service.DeviceDataTrendService;
@@ -18,10 +15,7 @@ import com.njcn.csharmonic.util.InfluxDbParamUtil;
import com.njcn.influx.pojo.bo.CommonQueryParam;
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
import com.njcn.influx.service.CommonService;
-import com.njcn.system.api.DicDataFeignClient;
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 lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@@ -29,8 +23,10 @@ import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.math.RoundingMode;
-import java.time.ZoneId;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -47,7 +43,6 @@ public class DeviceDataTrendServiceImpl implements DeviceDataTrendService {
private final CommonService commonService;
private final CsLedgerFeignClient csLedgerFeignClient;
private final CsLineFeignClient csLineFeignClient;
- private final DicDataFeignClient dicDataFeignClient;
private final EquipmentFeignClient equipmentFeignClient;
private final InfluxDbParamUtil influxDbParamUtil;
private final EpdFeignClient epdFeignClient;
@@ -63,7 +58,7 @@ public class DeviceDataTrendServiceImpl implements DeviceDataTrendService {
List data = csLedgerFeignClient.queryLine(lineParamDTO).getData();
List data1 = equipmentFeignClient.queryDeviceById(Stream.of((data == null || data.isEmpty()) ? devicDataTrendQueryParam.getDevId() : data.get(0).getPid()).collect(Collectors.toList())).getData();
//根据lineId获取监测点pt、ct变比
- CsLinePO csLinePO = csLineFeignClient.queryLineById(Collections.singletonList(devicDataTrendQueryParam.getLineId())).getData().get(0);
+ CsLinePO linePo = csLineFeignClient.queryLineById(Collections.singletonList(devicDataTrendQueryParam.getLineId())).getData().get(0);
devicDataTrendQueryParam.getStatisticalParams().forEach(temp->{
CommonQueryParam commonQueryParam = new CommonQueryParam();
@@ -76,9 +71,7 @@ public class DeviceDataTrendServiceImpl implements DeviceDataTrendService {
commonQueryParam.setDataType( temp.getStatMethod());
commonQueryParam.setProcess(data1.get(0).getProcess()+"");
commonQueryParam.setClDid(influxDbParamUtil.getClDidByLineId(devicDataTrendQueryParam.getLineId()));
-
EleEpdPqd epdPqd = epdFeignClient.selectByIds(Collections.singletonList(temp.getDataId())).getData().get(0);
-
List deviceRtData = commonService.getDeviceRtDataByTime(Stream.of(commonQueryParam).collect(Collectors.toList()));
List collect1 = deviceRtData.stream().map(statisticalDataDTO -> {
ThdDataVO vo = new ThdDataVO();
@@ -86,14 +79,10 @@ public class DeviceDataTrendServiceImpl implements DeviceDataTrendService {
vo.setPhase(statisticalDataDTO.getPhaseType());
vo.setTime(statisticalDataDTO.getTime());
vo.setStatMethod(statisticalDataDTO.getValueType());
- //对二次值做转换
- if (Objects.equals(devicDataTrendQueryParam.getDataLevel(),"Secondary")) {
- if (!Objects.isNull(epdPqd.getPrimaryFormula())) {
- double secondaryData = secondaryToPrimary(epdPqd.getPrimaryFormula(), statisticalDataDTO.getValue(), csLinePO.getPtRatio(), csLinePO.getCtRatio());
- vo.setStatisticalData(BigDecimal.valueOf(secondaryData).setScale(4, RoundingMode.UP).doubleValue());
- } else {
- vo.setStatisticalData(BigDecimal.valueOf(statisticalDataDTO.getValue()).setScale(4, RoundingMode.UP).doubleValue());
- }
+ //判断监测点类型 针对治理设备 模块数据是一次值、电能质量设备是二次值
+ if (linePo.getClDid() != 0 && Objects.equals(devicDataTrendQueryParam.getDataLevel(),"Primary") && ObjectUtil.isNotNull(epdPqd.getPrimaryFormula())) {
+ double secondaryData = secondaryToPrimary(epdPqd.getPrimaryFormula(), statisticalDataDTO.getValue(), linePo.getPtRatio(), linePo.getCtRatio());
+ vo.setStatisticalData(BigDecimal.valueOf(secondaryData).setScale(4, RoundingMode.UP).doubleValue());
} else {
vo.setStatisticalData(BigDecimal.valueOf(statisticalDataDTO.getValue()).setScale(4, RoundingMode.UP).doubleValue());
}