|
|
|
|
@@ -5,10 +5,12 @@ import cn.hutool.core.date.DatePattern;
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
|
|
|
|
import com.njcn.common.pojo.exception.BusinessException;
|
|
|
|
|
import com.njcn.common.utils.PubUtils;
|
|
|
|
|
import com.njcn.csdevice.api.CsLineFeignClient;
|
|
|
|
|
@@ -16,20 +18,15 @@ import com.njcn.csdevice.api.EquipmentFeignClient;
|
|
|
|
|
import com.njcn.csdevice.constant.DataParam;
|
|
|
|
|
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
|
|
|
|
import com.njcn.csdevice.enums.LineBaseEnum;
|
|
|
|
|
import com.njcn.csdevice.mapper.CsDataArrayMapper;
|
|
|
|
|
import com.njcn.csdevice.mapper.CsGroArrMapper;
|
|
|
|
|
import com.njcn.csdevice.mapper.CsGroupMapper;
|
|
|
|
|
import com.njcn.csdevice.mapper.OverlimitMapper;
|
|
|
|
|
import com.njcn.csdevice.mapper.*;
|
|
|
|
|
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
|
|
|
|
import com.njcn.csdevice.pojo.param.EnergyBaseParam;
|
|
|
|
|
import com.njcn.csdevice.pojo.po.CsDataArray;
|
|
|
|
|
import com.njcn.csdevice.pojo.po.CsGroArr;
|
|
|
|
|
import com.njcn.csdevice.pojo.po.CsGroup;
|
|
|
|
|
import com.njcn.csdevice.pojo.po.CsLinePO;
|
|
|
|
|
import com.njcn.csdevice.pojo.po.*;
|
|
|
|
|
import com.njcn.csdevice.pojo.vo.CsGroupVO;
|
|
|
|
|
import com.njcn.csdevice.pojo.vo.DataGroupEventVO;
|
|
|
|
|
import com.njcn.csdevice.pojo.vo.DataGroupTemplateVO;
|
|
|
|
|
import com.njcn.csdevice.pojo.vo.EnergyTemplateVO;
|
|
|
|
|
import com.njcn.csdevice.service.CsDevModelRelationService;
|
|
|
|
|
import com.njcn.csdevice.service.ICsDataArrayService;
|
|
|
|
|
import com.njcn.csdevice.service.ICsGroupService;
|
|
|
|
|
import com.njcn.csdevice.util.InfluxDbParamUtil;
|
|
|
|
|
@@ -110,6 +107,8 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
|
|
|
|
|
|
|
|
|
private final OverlimitMapper overlimitMapper;
|
|
|
|
|
|
|
|
|
|
private final CsDataSetMapper csDataSetMapper;
|
|
|
|
|
|
|
|
|
|
private final EventFeignClient eventFeignClient;
|
|
|
|
|
|
|
|
|
|
private final InfluxDbParamUtil influxDbParamUtil;
|
|
|
|
|
@@ -155,6 +154,10 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
|
|
|
|
getUnit(list,epdPqdList,groupList,dataLevel);
|
|
|
|
|
//根据lineId获取监测点pt、ct变比
|
|
|
|
|
CsLinePO csLinePO = csLineFeignClient.queryLineById(Collections.singletonList(lineId)).getData().get(0);
|
|
|
|
|
CsDataSet csDataSet = csDataSetMapper.selectOne(new LambdaQueryWrapper<CsDataSet>().eq(CsDataSet::getId,csLinePO.getDataSetId()));
|
|
|
|
|
if(Objects.isNull(csDataSet) || StrUtil.isBlank(csDataSet.getDataLevel())){
|
|
|
|
|
throw new BusinessException("当前测点数据集主要信息缺失,请联系管理员排查(测点表里面数据集id缺失)");
|
|
|
|
|
}
|
|
|
|
|
//获取测点模板
|
|
|
|
|
for (EnergyTemplateVO item : list) {
|
|
|
|
|
EnergyTemplateVO vo = new EnergyTemplateVO();
|
|
|
|
|
@@ -166,12 +169,17 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
|
|
|
|
if (Objects.nonNull(statisticalDataDTO)) {
|
|
|
|
|
vo.setTime(statisticalDataDTO.getTime());
|
|
|
|
|
//判断监测点类型 针对治理设备 模块数据是一次值、电能质量设备是二次值
|
|
|
|
|
if (csLinePO.getClDid() != 0 && Objects.equals("Primary",dataLevel) && ObjectUtil.isNotNull(eleEpdPqd.getPrimaryFormula())) {
|
|
|
|
|
double secondaryData = DataChangeUtil.secondaryToPrimary(eleEpdPqd.getPrimaryFormula(), statisticalDataDTO.getValue(), csLinePO.getPtRatio(), csLinePO.getCtRatio());
|
|
|
|
|
if (ObjectUtil.isNotNull(eleEpdPqd.getPrimaryFormula()) && !Objects.equals(csDataSet.getDataLevel(),dataLevel)) {
|
|
|
|
|
double re;
|
|
|
|
|
if("Primary".equals(csDataSet.getDataLevel())){
|
|
|
|
|
re = DataChangeUtil.primaryToSecondary(eleEpdPqd.getPrimaryFormula(), statisticalDataDTO.getValue(), csLinePO.getPtRatio(), csLinePO.getCtRatio());
|
|
|
|
|
}else {
|
|
|
|
|
re = DataChangeUtil.secondaryToPrimary(eleEpdPqd.getPrimaryFormula(), statisticalDataDTO.getValue(), csLinePO.getPtRatio(), csLinePO.getCtRatio());
|
|
|
|
|
}
|
|
|
|
|
if (changePower(vo.getAnotherName())) {
|
|
|
|
|
vo.setDataValue(Double.valueOf(df.format(BigDecimal.valueOf(secondaryData / 1000).setScale(2, RoundingMode.HALF_UP).doubleValue())));
|
|
|
|
|
vo.setDataValue(Double.valueOf(df.format(BigDecimal.valueOf(re / 1000).setScale(2, RoundingMode.HALF_UP).doubleValue())));
|
|
|
|
|
} else {
|
|
|
|
|
vo.setDataValue(Double.valueOf(df.format(BigDecimal.valueOf(secondaryData).setScale(2, RoundingMode.HALF_UP).doubleValue())));
|
|
|
|
|
vo.setDataValue(Double.valueOf(df.format(BigDecimal.valueOf(re).setScale(2, RoundingMode.HALF_UP).doubleValue())));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (changePower(vo.getAnotherName())) {
|
|
|
|
|
@@ -222,6 +230,11 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
|
|
|
|
getUnit(list,epdPqdList,groupList,energyBaseParam.getDataLevel());
|
|
|
|
|
//根据lineId获取监测点pt、ct变比
|
|
|
|
|
CsLinePO po = csLineFeignClient.queryLineById(Collections.singletonList(energyBaseParam.getLineId())).getData().get(0);
|
|
|
|
|
CsDataSet csDataSet = csDataSetMapper.selectOne(new LambdaQueryWrapper<CsDataSet>().eq(CsDataSet::getId,po.getDataSetId()));
|
|
|
|
|
if(Objects.isNull(csDataSet) || StrUtil.isBlank(csDataSet.getDataLevel())){
|
|
|
|
|
throw new BusinessException("当前测点数据集主要信息缺失,请联系管理员排查(测点表里面数据集id缺失)");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (EnergyTemplateVO item : list) {
|
|
|
|
|
EnergyTemplateVO vo = new EnergyTemplateVO();
|
|
|
|
|
BeanUtils.copyProperties(item,vo);
|
|
|
|
|
@@ -235,10 +248,20 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
|
|
|
|
if (Objects.nonNull(statisticalDataDTO)) {
|
|
|
|
|
vo.setTime(statisticalDataDTO.getTime());
|
|
|
|
|
//判断监测点类型 针对治理设备 模块数据是一次值、电能质量设备是二次值
|
|
|
|
|
if (po.getClDid() != 0 && Objects.equals("Primary",energyBaseParam.getDataLevel()) && ObjectUtil.isNotNull(eleEpdPqd.getPrimaryFormula())) {
|
|
|
|
|
double secondaryData1 = DataChangeUtil.secondaryToPrimary(eleEpdPqd.getPrimaryFormula(), statisticalDataDTO.getMaxValue(), po.getPtRatio(), po.getCtRatio());
|
|
|
|
|
double secondaryData2 = DataChangeUtil.secondaryToPrimary(eleEpdPqd.getPrimaryFormula(), statisticalDataDTO.getMinValue(), po.getPtRatio(), po.getCtRatio());
|
|
|
|
|
double secondaryData3 = DataChangeUtil.secondaryToPrimary(eleEpdPqd.getPrimaryFormula(), statisticalDataDTO.getAvgValue(), po.getPtRatio(), po.getCtRatio());
|
|
|
|
|
if (ObjectUtil.isNotNull(eleEpdPqd.getPrimaryFormula()) && !Objects.equals(csDataSet.getDataLevel(),energyBaseParam.getDataLevel()) ) {
|
|
|
|
|
double secondaryData1;
|
|
|
|
|
double secondaryData2;
|
|
|
|
|
double secondaryData3;
|
|
|
|
|
if("Primary".equals(csDataSet.getDataLevel())){
|
|
|
|
|
secondaryData1 = DataChangeUtil.primaryToSecondary(eleEpdPqd.getPrimaryFormula(), statisticalDataDTO.getMaxValue(), po.getPtRatio(), po.getCtRatio());
|
|
|
|
|
secondaryData2 = DataChangeUtil.primaryToSecondary(eleEpdPqd.getPrimaryFormula(), statisticalDataDTO.getMinValue(), po.getPtRatio(), po.getCtRatio());
|
|
|
|
|
secondaryData3 = DataChangeUtil.primaryToSecondary(eleEpdPqd.getPrimaryFormula(), statisticalDataDTO.getAvgValue(), po.getPtRatio(), po.getCtRatio());
|
|
|
|
|
}else {
|
|
|
|
|
secondaryData1 = DataChangeUtil.secondaryToPrimary(eleEpdPqd.getPrimaryFormula(), statisticalDataDTO.getMaxValue(), po.getPtRatio(), po.getCtRatio());
|
|
|
|
|
secondaryData2 = DataChangeUtil.secondaryToPrimary(eleEpdPqd.getPrimaryFormula(), statisticalDataDTO.getMinValue(), po.getPtRatio(), po.getCtRatio());
|
|
|
|
|
secondaryData3 = DataChangeUtil.secondaryToPrimary(eleEpdPqd.getPrimaryFormula(), statisticalDataDTO.getAvgValue(), po.getPtRatio(), po.getCtRatio());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (changePower(vo.getAnotherName())) {
|
|
|
|
|
vo.setMaxValue(Double.valueOf(df.format(BigDecimal.valueOf(secondaryData1/1000).setScale(2, RoundingMode.HALF_UP).doubleValue())));
|
|
|
|
|
vo.setMinValue(Double.valueOf(df.format(BigDecimal.valueOf(secondaryData2/1000).setScale(2, RoundingMode.HALF_UP).doubleValue())));
|
|
|
|
|
|