数据添加单位显示
This commit is contained in:
@@ -0,0 +1,26 @@
|
|||||||
|
package com.njcn.csdevice.utils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类的介绍:用来将二次值转成一次值
|
||||||
|
* @author xuyang
|
||||||
|
* @version 1.0.0
|
||||||
|
*/
|
||||||
|
public class DataChangeUtil {
|
||||||
|
|
||||||
|
public static double secondaryToPrimary(String formula, Double data,Double pt, Double ct) {
|
||||||
|
switch (formula) {
|
||||||
|
case "*PT":
|
||||||
|
data = data * pt;
|
||||||
|
break;
|
||||||
|
case "*CT":
|
||||||
|
data = data * ct;
|
||||||
|
break;
|
||||||
|
case "*PT*CT":
|
||||||
|
data = data * pt * ct;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -30,6 +30,7 @@ import com.njcn.csdevice.pojo.vo.EnergyTemplateVO;
|
|||||||
import com.njcn.csdevice.service.ICsDataArrayService;
|
import com.njcn.csdevice.service.ICsDataArrayService;
|
||||||
import com.njcn.csdevice.service.ICsGroupService;
|
import com.njcn.csdevice.service.ICsGroupService;
|
||||||
import com.njcn.csdevice.util.InfluxDbParamUtil;
|
import com.njcn.csdevice.util.InfluxDbParamUtil;
|
||||||
|
import com.njcn.csdevice.utils.DataChangeUtil;
|
||||||
import com.njcn.csharmonic.param.CommonStatisticalQueryParam;
|
import com.njcn.csharmonic.param.CommonStatisticalQueryParam;
|
||||||
import com.njcn.csharmonic.pojo.vo.ThdDataTdVO;
|
import com.njcn.csharmonic.pojo.vo.ThdDataTdVO;
|
||||||
import com.njcn.csharmonic.pojo.vo.ThdDataVO;
|
import com.njcn.csharmonic.pojo.vo.ThdDataVO;
|
||||||
@@ -113,6 +114,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
|||||||
|
|
||||||
private final InfluxDbParamUtil influxDbParamUtil;
|
private final InfluxDbParamUtil influxDbParamUtil;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public List<CsGroupVO> getGroupData(String dataSet) {
|
public List<CsGroupVO> getGroupData(String dataSet) {
|
||||||
@@ -128,6 +130,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPage<DataGroupTemplateVO> getDeviceRtData(String id, Integer pageNum, Integer pageSize, String lineId, String searchValue, String dataLevel) {
|
public IPage<DataGroupTemplateVO> getDeviceRtData(String id, Integer pageNum, Integer pageSize, String lineId, String searchValue, String dataLevel) {
|
||||||
IPage<DataGroupTemplateVO> pageTurn = new Page<>();
|
IPage<DataGroupTemplateVO> pageTurn = new Page<>();
|
||||||
@@ -141,6 +144,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
|||||||
//获取所有字典指标
|
//获取所有字典指标
|
||||||
List<EleEpdPqd> epdPqdList = epdFeignClient.selectByIds(list.stream().map(EnergyTemplateVO::getDataId).distinct().collect(Collectors.toList())).getData();
|
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()));
|
Map<String, EleEpdPqd> eventTypeMap = epdPqdList.stream().collect(Collectors.toMap(EleEpdPqd::getId, Function.identity()));
|
||||||
|
getUnit(list,epdPqdList,groupList);
|
||||||
//根据lineId获取监测点pt、ct变比
|
//根据lineId获取监测点pt、ct变比
|
||||||
CsLinePO csLinePO = csLineFeignClient.queryLineById(Collections.singletonList(lineId)).getData().get(0);
|
CsLinePO csLinePO = csLineFeignClient.queryLineById(Collections.singletonList(lineId)).getData().get(0);
|
||||||
for (EnergyTemplateVO item : list) {
|
for (EnergyTemplateVO item : list) {
|
||||||
@@ -154,7 +158,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
|||||||
vo.setTime(statisticalDataDTO.getTime());
|
vo.setTime(statisticalDataDTO.getTime());
|
||||||
//判断监测点类型 针对治理设备 模块数据是一次值、电能质量设备是二次值
|
//判断监测点类型 针对治理设备 模块数据是一次值、电能质量设备是二次值
|
||||||
if (csLinePO.getClDid() != 0 && Objects.equals("Primary",dataLevel) && ObjectUtil.isNotNull(eleEpdPqd.getPrimaryFormula())) {
|
if (csLinePO.getClDid() != 0 && Objects.equals("Primary",dataLevel) && ObjectUtil.isNotNull(eleEpdPqd.getPrimaryFormula())) {
|
||||||
double secondaryData = secondaryToPrimary(eleEpdPqd.getPrimaryFormula(), statisticalDataDTO.getValue(), csLinePO.getPtRatio(), csLinePO.getCtRatio());
|
double secondaryData = DataChangeUtil.secondaryToPrimary(eleEpdPqd.getPrimaryFormula(), statisticalDataDTO.getValue(), csLinePO.getPtRatio(), csLinePO.getCtRatio());
|
||||||
vo.setDataValue(BigDecimal.valueOf(secondaryData).setScale(4, RoundingMode.HALF_UP).doubleValue());
|
vo.setDataValue(BigDecimal.valueOf(secondaryData).setScale(4, RoundingMode.HALF_UP).doubleValue());
|
||||||
} else {
|
} else {
|
||||||
vo.setDataValue(BigDecimal.valueOf(statisticalDataDTO.getValue()).setScale(4, RoundingMode.HALF_UP).doubleValue());
|
vo.setDataValue(BigDecimal.valueOf(statisticalDataDTO.getValue()).setScale(4, RoundingMode.HALF_UP).doubleValue());
|
||||||
@@ -195,12 +199,16 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
|||||||
//获取所有字典指标
|
//获取所有字典指标
|
||||||
List<EleEpdPqd> epdPqdList = epdFeignClient.selectByIds(list.stream().map(EnergyTemplateVO::getDataId).distinct().collect(Collectors.toList())).getData();
|
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()));
|
Map<String, EleEpdPqd> eventTypeMap = epdPqdList.stream().collect(Collectors.toMap(EleEpdPqd::getId, Function.identity()));
|
||||||
|
getUnit(list,epdPqdList,groupList);
|
||||||
//根据lineId获取监测点pt、ct变比
|
//根据lineId获取监测点pt、ct变比
|
||||||
CsLinePO po = csLineFeignClient.queryLineById(Collections.singletonList(energyBaseParam.getLineId())).getData().get(0);
|
CsLinePO po = csLineFeignClient.queryLineById(Collections.singletonList(energyBaseParam.getLineId())).getData().get(0);
|
||||||
for (EnergyTemplateVO item : list) {
|
for (EnergyTemplateVO item : list) {
|
||||||
EnergyTemplateVO vo = new EnergyTemplateVO();
|
EnergyTemplateVO vo = new EnergyTemplateVO();
|
||||||
BeanUtils.copyProperties(item,vo);
|
BeanUtils.copyProperties(item,vo);
|
||||||
EleEpdPqd eleEpdPqd = eventTypeMap.get(item.getDataId());
|
EleEpdPqd eleEpdPqd = eventTypeMap.get(item.getDataId());
|
||||||
|
if (Objects.nonNull(eleEpdPqd.getUnit())){
|
||||||
|
vo.setAnotherName(vo.getAnotherName()+"("+eleEpdPqd.getUnit()+")");
|
||||||
|
}
|
||||||
vo.setClassId(eleEpdPqd.getClassId());
|
vo.setClassId(eleEpdPqd.getClassId());
|
||||||
vo.setUnit(eleEpdPqd.getUnit());
|
vo.setUnit(eleEpdPqd.getUnit());
|
||||||
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()));
|
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()));
|
||||||
@@ -208,9 +216,9 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
|||||||
vo.setTime(statisticalDataDTO.getTime());
|
vo.setTime(statisticalDataDTO.getTime());
|
||||||
//判断监测点类型 针对治理设备 模块数据是一次值、电能质量设备是二次值
|
//判断监测点类型 针对治理设备 模块数据是一次值、电能质量设备是二次值
|
||||||
if (po.getClDid() != 0 && Objects.equals("Primary",energyBaseParam.getDataLevel()) && ObjectUtil.isNotNull(eleEpdPqd.getPrimaryFormula())) {
|
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 secondaryData1 = DataChangeUtil.secondaryToPrimary(eleEpdPqd.getPrimaryFormula(), statisticalDataDTO.getMaxValue(), po.getPtRatio(), po.getCtRatio());
|
||||||
double secondaryData2 = secondaryToPrimary(eleEpdPqd.getPrimaryFormula(), statisticalDataDTO.getMinValue(), po.getPtRatio(), po.getCtRatio());
|
double secondaryData2 = DataChangeUtil.secondaryToPrimary(eleEpdPqd.getPrimaryFormula(), statisticalDataDTO.getMinValue(), po.getPtRatio(), po.getCtRatio());
|
||||||
double secondaryData3 = secondaryToPrimary(eleEpdPqd.getPrimaryFormula(), statisticalDataDTO.getAvgValue(), po.getPtRatio(), po.getCtRatio());
|
double secondaryData3 = DataChangeUtil.secondaryToPrimary(eleEpdPqd.getPrimaryFormula(), statisticalDataDTO.getAvgValue(), po.getPtRatio(), po.getCtRatio());
|
||||||
vo.setMaxValue(BigDecimal.valueOf(secondaryData1).setScale(4, RoundingMode.HALF_UP).doubleValue());
|
vo.setMaxValue(BigDecimal.valueOf(secondaryData1).setScale(4, RoundingMode.HALF_UP).doubleValue());
|
||||||
vo.setMinValue(BigDecimal.valueOf(secondaryData2).setScale(4, RoundingMode.HALF_UP).doubleValue());
|
vo.setMinValue(BigDecimal.valueOf(secondaryData2).setScale(4, RoundingMode.HALF_UP).doubleValue());
|
||||||
vo.setAvgValue(BigDecimal.valueOf(secondaryData3).setScale(4, RoundingMode.HALF_UP).doubleValue());
|
vo.setAvgValue(BigDecimal.valueOf(secondaryData3).setScale(4, RoundingMode.HALF_UP).doubleValue());
|
||||||
@@ -683,27 +691,35 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
//单位处理
|
||||||
* 二次值换算成一次值
|
public void getUnit(List<EnergyTemplateVO> energyTemplates, List<EleEpdPqd> eleEpdPqds, List<DataGroupTemplateVO> dataGroupTemplates) {
|
||||||
*/
|
// 使用Map来存储EleEpdPqd的ID和Unit,以便快速查找
|
||||||
public double secondaryToPrimary(String formula, Double data,Double pt, Double ct) {
|
Map<String, String> unitMap = new HashMap<>();
|
||||||
switch (formula) {
|
for (EleEpdPqd item : eleEpdPqds) {
|
||||||
case "*PT":
|
unitMap.put(item.getId(), item.getUnit());
|
||||||
data = data * pt;
|
}
|
||||||
break;
|
|
||||||
case "*CT":
|
// 遍历EnergyTemplateVO,设置Unit
|
||||||
data = data * ct;
|
for (EnergyTemplateVO energyTemplate : energyTemplates) {
|
||||||
break;
|
String unit = unitMap.get(energyTemplate.getDataId());
|
||||||
case "*PT*CT/1000":
|
if (unit != null) {
|
||||||
data = data * pt * ct / 1000;
|
energyTemplate.setUnit(unit);
|
||||||
break;
|
}
|
||||||
case "*PT/1000":
|
}
|
||||||
data = data * pt / 1000;
|
|
||||||
break;
|
// 使用Map来存储DataGroupTemplateVO的ID和对应的EnergyTemplateVO(如果存在)
|
||||||
default:
|
Map<String, EnergyTemplateVO> energyTemplateMap = new HashMap<>();
|
||||||
break;
|
for (EnergyTemplateVO energyTemplate : energyTemplates) {
|
||||||
|
energyTemplateMap.put(energyTemplate.getPid(), energyTemplate);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 遍历DataGroupTemplateVO,更新Name
|
||||||
|
for (DataGroupTemplateVO dataGroupTemplate : dataGroupTemplates) {
|
||||||
|
EnergyTemplateVO energyTemplate = energyTemplateMap.get(dataGroupTemplate.getId());
|
||||||
|
if (energyTemplate != null && energyTemplate.getUnit() != null) {
|
||||||
|
dataGroupTemplate.setName(dataGroupTemplate.getName() + "(" + energyTemplate.getUnit() + ")");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
|||||||
import com.njcn.csdevice.pojo.dto.LineParamDTO;
|
import com.njcn.csdevice.pojo.dto.LineParamDTO;
|
||||||
import com.njcn.csdevice.pojo.po.CsLedger;
|
import com.njcn.csdevice.pojo.po.CsLedger;
|
||||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||||
|
import com.njcn.csdevice.utils.DataChangeUtil;
|
||||||
import com.njcn.csharmonic.param.DevicDataTrendQueryParam;
|
import com.njcn.csharmonic.param.DevicDataTrendQueryParam;
|
||||||
import com.njcn.csharmonic.pojo.vo.ThdDataVO;
|
import com.njcn.csharmonic.pojo.vo.ThdDataVO;
|
||||||
import com.njcn.csharmonic.service.DeviceDataTrendService;
|
import com.njcn.csharmonic.service.DeviceDataTrendService;
|
||||||
@@ -81,7 +82,7 @@ public class DeviceDataTrendServiceImpl implements DeviceDataTrendService {
|
|||||||
vo.setStatMethod(statisticalDataDTO.getValueType());
|
vo.setStatMethod(statisticalDataDTO.getValueType());
|
||||||
//判断监测点类型 针对治理设备 模块数据是一次值、电能质量设备是二次值
|
//判断监测点类型 针对治理设备 模块数据是一次值、电能质量设备是二次值
|
||||||
if (linePo.getClDid() != 0 && Objects.equals(devicDataTrendQueryParam.getDataLevel(),"Primary") && ObjectUtil.isNotNull(epdPqd.getPrimaryFormula())) {
|
if (linePo.getClDid() != 0 && Objects.equals(devicDataTrendQueryParam.getDataLevel(),"Primary") && ObjectUtil.isNotNull(epdPqd.getPrimaryFormula())) {
|
||||||
double secondaryData = secondaryToPrimary(epdPqd.getPrimaryFormula(), statisticalDataDTO.getValue(), linePo.getPtRatio(), linePo.getCtRatio());
|
double secondaryData = DataChangeUtil.secondaryToPrimary(epdPqd.getPrimaryFormula(), statisticalDataDTO.getValue(), linePo.getPtRatio(), linePo.getCtRatio());
|
||||||
vo.setStatisticalData(BigDecimal.valueOf(secondaryData).setScale(4, RoundingMode.HALF_UP).doubleValue());
|
vo.setStatisticalData(BigDecimal.valueOf(secondaryData).setScale(4, RoundingMode.HALF_UP).doubleValue());
|
||||||
} else {
|
} else {
|
||||||
vo.setStatisticalData(BigDecimal.valueOf(statisticalDataDTO.getValue()).setScale(4, RoundingMode.HALF_UP).doubleValue());
|
vo.setStatisticalData(BigDecimal.valueOf(statisticalDataDTO.getValue()).setScale(4, RoundingMode.HALF_UP).doubleValue());
|
||||||
@@ -96,27 +97,4 @@ public class DeviceDataTrendServiceImpl implements DeviceDataTrendService {
|
|||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 二次值换算成一次值
|
|
||||||
*/
|
|
||||||
public double secondaryToPrimary(String formula, Double data,Double pt, Double ct) {
|
|
||||||
switch (formula) {
|
|
||||||
case "*PT":
|
|
||||||
data = data * pt;
|
|
||||||
break;
|
|
||||||
case "*CT":
|
|
||||||
data = data * ct;
|
|
||||||
break;
|
|
||||||
case "*PT*CT/1000":
|
|
||||||
data = data * pt * ct / 1000;
|
|
||||||
break;
|
|
||||||
case "*PT/1000":
|
|
||||||
data = data * pt / 1000;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user