1.监测点表新增两个字段
2.无线bug提交
This commit is contained in:
@@ -53,6 +53,12 @@
|
|||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.njcn</groupId>
|
||||||
|
<artifactId>common-device-biz</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package com.njcn.csdevice.api;
|
||||||
|
|
||||||
|
import com.njcn.common.pojo.constant.ServerInfo;
|
||||||
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
|
import com.njcn.csdevice.api.fallback.CsCommTerminalFeignClientFallbackFactory;
|
||||||
|
import com.njcn.csdevice.api.fallback.CsDeviceUserClientFallbackFactory;
|
||||||
|
import com.njcn.csdevice.pojo.po.CsDeviceUserPO;
|
||||||
|
import com.njcn.device.biz.pojo.po.PqsDeviceUnit;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xy
|
||||||
|
*/
|
||||||
|
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/commTerminal", fallbackFactory = CsCommTerminalFeignClientFallbackFactory.class,contextId = "deviceUser")
|
||||||
|
public interface CsCommTerminalFeignClient {
|
||||||
|
|
||||||
|
@GetMapping("lineUnitDetail")
|
||||||
|
HttpResult<PqsDeviceUnit> lineUnitDetail(@RequestParam("lineId") String lineId);
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ import com.njcn.csdevice.pojo.po.CsDataSet;
|
|||||||
import com.njcn.csdevice.pojo.vo.LineTargetVO;
|
import com.njcn.csdevice.pojo.vo.LineTargetVO;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -27,4 +28,8 @@ public interface DataSetFeignClient {
|
|||||||
@PostMapping("/getModuleDataSet")
|
@PostMapping("/getModuleDataSet")
|
||||||
HttpResult<List<CsDataSet>> getModuleDataSet(@RequestParam("modelId") String modelId);
|
HttpResult<List<CsDataSet>> getModuleDataSet(@RequestParam("modelId") String modelId);
|
||||||
|
|
||||||
|
@PostMapping("/getDataSetBySetIds")
|
||||||
|
HttpResult<List<CsDataSet>> getDataSetBySetIds(@RequestBody List<String> lineIds);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package com.njcn.csdevice.api.fallback;
|
||||||
|
|
||||||
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
|
import com.njcn.csdevice.api.CsCommTerminalFeignClient;
|
||||||
|
import com.njcn.device.biz.pojo.po.PqsDeviceUnit;
|
||||||
|
import feign.hystrix.FallbackFactory;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xy
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class CsCommTerminalFeignClientFallbackFactory implements FallbackFactory<CsCommTerminalFeignClient> {
|
||||||
|
@Override
|
||||||
|
public CsCommTerminalFeignClient create(Throwable cause) {
|
||||||
|
//判断抛出异常是否为解码器抛出的业务异常
|
||||||
|
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||||
|
if (cause.getCause() instanceof BusinessException) {
|
||||||
|
BusinessException businessException = (BusinessException) cause.getCause();
|
||||||
|
}
|
||||||
|
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||||
|
return new CsCommTerminalFeignClient() {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpResult<PqsDeviceUnit> lineUnitDetail(String lineId) {
|
||||||
|
log.error("{}异常,降级处理,异常为:{}","查询分组",cause.toString());
|
||||||
|
throw new BusinessException(finalExceptionEnum);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -50,6 +50,12 @@ public class DataSetFeignClientFallbackFactory implements FallbackFactory<DataSe
|
|||||||
log.error("{}异常,降级处理,异常为:{}","获取子模块数据集",cause.toString());
|
log.error("{}异常,降级处理,异常为:{}","获取子模块数据集",cause.toString());
|
||||||
throw new BusinessException(finalExceptionEnum);
|
throw new BusinessException(finalExceptionEnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpResult<List<CsDataSet>> getDataSetBySetIds(List<String> lineIds) {
|
||||||
|
log.error("{}异常,降级处理,异常为:{}","根据数据集ids获取数据集",cause.toString());
|
||||||
|
throw new BusinessException(finalExceptionEnum);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,16 @@ public class CsLinePO extends BaseEntity {
|
|||||||
@TableField(value = "`position`")
|
@TableField(value = "`position`")
|
||||||
private String position;
|
private String position;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据集id
|
||||||
|
*/
|
||||||
|
private String dataSetId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模板id
|
||||||
|
*/
|
||||||
|
private String dataModelId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 电压等级
|
* 电压等级
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
package com.njcn.csdevice.utils;
|
package com.njcn.csdevice.utils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 类的介绍:用来将二次值转成一次值
|
* 类的介绍:
|
||||||
* @author xuyang
|
* @author xuyang
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
*/
|
*/
|
||||||
public class DataChangeUtil {
|
public class DataChangeUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用来将二次值转成一次值
|
||||||
|
*/
|
||||||
public static double secondaryToPrimary(String formula, Double data,Double pt, Double ct) {
|
public static double secondaryToPrimary(String formula, Double data,Double pt, Double ct) {
|
||||||
switch (formula) {
|
switch (formula) {
|
||||||
case "*PT":
|
case "*PT":
|
||||||
@@ -23,4 +26,24 @@ public class DataChangeUtil {
|
|||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用来将一次值转成二次值
|
||||||
|
*/
|
||||||
|
public static double primaryToSecondary(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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -163,11 +163,7 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.njcn</groupId>
|
|
||||||
<artifactId>common-device-biz</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|||||||
@@ -16,10 +16,7 @@ import io.swagger.annotations.ApiImplicitParams;
|
|||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -76,5 +73,15 @@ public class CsDataSetController extends BaseController {
|
|||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/getDataSetBySetIds")
|
||||||
|
@ApiOperation("根据测点获取数据集")
|
||||||
|
@ApiImplicitParam(name = "lineIds", value = "监测点ids", required = true)
|
||||||
|
public HttpResult<List<CsDataSet>> getDataSetBySetIds(@RequestBody List<String> lineIds){
|
||||||
|
String methodDescribe = getMethodDescribe("getDataSetBySetIds");
|
||||||
|
List<CsDataSet> list = csDataSetService.getDataSetBySetIds(lineIds);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import java.util.Objects;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Api(tags = "通用台账查询")
|
@Api(tags = "通用台账查询")
|
||||||
public class CommTerminalController extends BaseController {
|
public class CsCommTerminalController extends BaseController {
|
||||||
|
|
||||||
private final PqsDeviceUnitMapper pqsDeviceUnitMapper;
|
private final PqsDeviceUnitMapper pqsDeviceUnitMapper;
|
||||||
|
|
||||||
@@ -45,4 +45,11 @@ public interface ICsDataSetService extends IService<CsDataSet> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<CsDataSet> getModuleDataSet(String modelId);
|
List<CsDataSet> getModuleDataSet(String modelId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据测点id获取数据集
|
||||||
|
* @param setIds 监测点id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<CsDataSet> getDataSetBySetIds(List<String> setIds);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import com.njcn.csdevice.service.ICsDataSetService;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -41,4 +42,9 @@ public class CsDataSetServiceImpl extends ServiceImpl<CsDataSetMapper, CsDataSet
|
|||||||
return this.lambdaQuery().eq(CsDataSet::getPid,modelId).ne(CsDataSet::getClDev,0).list();
|
return this.lambdaQuery().eq(CsDataSet::getPid,modelId).ne(CsDataSet::getClDev,0).list();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CsDataSet> getDataSetBySetIds(List<String> setIds) {
|
||||||
|
return this.lambdaQuery().in(CsDataSet::getId,setIds).list();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,12 @@ import cn.hutool.core.date.DatePattern;
|
|||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
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.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
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.pojo.exception.BusinessException;
|
||||||
import com.njcn.common.utils.PubUtils;
|
import com.njcn.common.utils.PubUtils;
|
||||||
import com.njcn.csdevice.api.CsLineFeignClient;
|
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.constant.DataParam;
|
||||||
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
||||||
import com.njcn.csdevice.enums.LineBaseEnum;
|
import com.njcn.csdevice.enums.LineBaseEnum;
|
||||||
import com.njcn.csdevice.mapper.CsDataArrayMapper;
|
import com.njcn.csdevice.mapper.*;
|
||||||
import com.njcn.csdevice.mapper.CsGroArrMapper;
|
|
||||||
import com.njcn.csdevice.mapper.CsGroupMapper;
|
|
||||||
import com.njcn.csdevice.mapper.OverlimitMapper;
|
|
||||||
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
||||||
import com.njcn.csdevice.pojo.param.EnergyBaseParam;
|
import com.njcn.csdevice.pojo.param.EnergyBaseParam;
|
||||||
import com.njcn.csdevice.pojo.po.CsDataArray;
|
import com.njcn.csdevice.pojo.po.*;
|
||||||
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.vo.CsGroupVO;
|
import com.njcn.csdevice.pojo.vo.CsGroupVO;
|
||||||
import com.njcn.csdevice.pojo.vo.DataGroupEventVO;
|
import com.njcn.csdevice.pojo.vo.DataGroupEventVO;
|
||||||
import com.njcn.csdevice.pojo.vo.DataGroupTemplateVO;
|
import com.njcn.csdevice.pojo.vo.DataGroupTemplateVO;
|
||||||
import com.njcn.csdevice.pojo.vo.EnergyTemplateVO;
|
import com.njcn.csdevice.pojo.vo.EnergyTemplateVO;
|
||||||
|
import com.njcn.csdevice.service.CsDevModelRelationService;
|
||||||
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;
|
||||||
@@ -110,6 +107,8 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
|||||||
|
|
||||||
private final OverlimitMapper overlimitMapper;
|
private final OverlimitMapper overlimitMapper;
|
||||||
|
|
||||||
|
private final CsDataSetMapper csDataSetMapper;
|
||||||
|
|
||||||
private final EventFeignClient eventFeignClient;
|
private final EventFeignClient eventFeignClient;
|
||||||
|
|
||||||
private final InfluxDbParamUtil influxDbParamUtil;
|
private final InfluxDbParamUtil influxDbParamUtil;
|
||||||
@@ -155,6 +154,10 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
|||||||
getUnit(list,epdPqdList,groupList,dataLevel);
|
getUnit(list,epdPqdList,groupList,dataLevel);
|
||||||
//根据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);
|
||||||
|
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) {
|
for (EnergyTemplateVO item : list) {
|
||||||
EnergyTemplateVO vo = new EnergyTemplateVO();
|
EnergyTemplateVO vo = new EnergyTemplateVO();
|
||||||
@@ -166,12 +169,17 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
|||||||
if (Objects.nonNull(statisticalDataDTO)) {
|
if (Objects.nonNull(statisticalDataDTO)) {
|
||||||
vo.setTime(statisticalDataDTO.getTime());
|
vo.setTime(statisticalDataDTO.getTime());
|
||||||
//判断监测点类型 针对治理设备 模块数据是一次值、电能质量设备是二次值
|
//判断监测点类型 针对治理设备 模块数据是一次值、电能质量设备是二次值
|
||||||
if (csLinePO.getClDid() != 0 && Objects.equals("Primary",dataLevel) && ObjectUtil.isNotNull(eleEpdPqd.getPrimaryFormula())) {
|
if (ObjectUtil.isNotNull(eleEpdPqd.getPrimaryFormula()) && !Objects.equals(csDataSet.getDataLevel(),dataLevel)) {
|
||||||
double secondaryData = DataChangeUtil.secondaryToPrimary(eleEpdPqd.getPrimaryFormula(), statisticalDataDTO.getValue(), csLinePO.getPtRatio(), csLinePO.getCtRatio());
|
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())) {
|
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 {
|
} 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 {
|
} else {
|
||||||
if (changePower(vo.getAnotherName())) {
|
if (changePower(vo.getAnotherName())) {
|
||||||
@@ -222,6 +230,11 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
|||||||
getUnit(list,epdPqdList,groupList,energyBaseParam.getDataLevel());
|
getUnit(list,epdPqdList,groupList,energyBaseParam.getDataLevel());
|
||||||
//根据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);
|
||||||
|
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) {
|
for (EnergyTemplateVO item : list) {
|
||||||
EnergyTemplateVO vo = new EnergyTemplateVO();
|
EnergyTemplateVO vo = new EnergyTemplateVO();
|
||||||
BeanUtils.copyProperties(item,vo);
|
BeanUtils.copyProperties(item,vo);
|
||||||
@@ -235,10 +248,20 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
|||||||
if (Objects.nonNull(statisticalDataDTO)) {
|
if (Objects.nonNull(statisticalDataDTO)) {
|
||||||
vo.setTime(statisticalDataDTO.getTime());
|
vo.setTime(statisticalDataDTO.getTime());
|
||||||
//判断监测点类型 针对治理设备 模块数据是一次值、电能质量设备是二次值
|
//判断监测点类型 针对治理设备 模块数据是一次值、电能质量设备是二次值
|
||||||
if (po.getClDid() != 0 && Objects.equals("Primary",energyBaseParam.getDataLevel()) && ObjectUtil.isNotNull(eleEpdPqd.getPrimaryFormula())) {
|
if (ObjectUtil.isNotNull(eleEpdPqd.getPrimaryFormula()) && !Objects.equals(csDataSet.getDataLevel(),energyBaseParam.getDataLevel()) ) {
|
||||||
double secondaryData1 = DataChangeUtil.secondaryToPrimary(eleEpdPqd.getPrimaryFormula(), statisticalDataDTO.getMaxValue(), po.getPtRatio(), po.getCtRatio());
|
double secondaryData1;
|
||||||
double secondaryData2 = DataChangeUtil.secondaryToPrimary(eleEpdPqd.getPrimaryFormula(), statisticalDataDTO.getMinValue(), po.getPtRatio(), po.getCtRatio());
|
double secondaryData2;
|
||||||
double secondaryData3 = DataChangeUtil.secondaryToPrimary(eleEpdPqd.getPrimaryFormula(), statisticalDataDTO.getAvgValue(), po.getPtRatio(), po.getCtRatio());
|
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())) {
|
if (changePower(vo.getAnotherName())) {
|
||||||
vo.setMaxValue(Double.valueOf(df.format(BigDecimal.valueOf(secondaryData1/1000).setScale(2, RoundingMode.HALF_UP).doubleValue())));
|
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())));
|
vo.setMinValue(Double.valueOf(df.format(BigDecimal.valueOf(secondaryData2/1000).setScale(2, RoundingMode.HALF_UP).doubleValue())));
|
||||||
|
|||||||
@@ -1,11 +1,17 @@
|
|||||||
package com.njcn.csharmonic.service.impl;
|
package com.njcn.csharmonic.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.csdevice.api.CsLedgerFeignClient;
|
import com.njcn.csdevice.api.CsLedgerFeignClient;
|
||||||
import com.njcn.csdevice.api.CsLineFeignClient;
|
import com.njcn.csdevice.api.CsLineFeignClient;
|
||||||
|
import com.njcn.csdevice.api.DataSetFeignClient;
|
||||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||||
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
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.CsDataSet;
|
||||||
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.csdevice.utils.DataChangeUtil;
|
||||||
@@ -49,6 +55,8 @@ public class DeviceDataTrendServiceImpl implements DeviceDataTrendService {
|
|||||||
private final EquipmentFeignClient equipmentFeignClient;
|
private final EquipmentFeignClient equipmentFeignClient;
|
||||||
private final InfluxDbParamUtil influxDbParamUtil;
|
private final InfluxDbParamUtil influxDbParamUtil;
|
||||||
private final EpdFeignClient epdFeignClient;
|
private final EpdFeignClient epdFeignClient;
|
||||||
|
private final DataSetFeignClient dataSetFeignClient;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<List<ThdDataVO>> queryDataTrend(DevicDataTrendQueryParam devicDataTrendQueryParam) {
|
public List<List<ThdDataVO>> queryDataTrend(DevicDataTrendQueryParam devicDataTrendQueryParam) {
|
||||||
List<List<ThdDataVO>> result = new ArrayList<>();
|
List<List<ThdDataVO>> result = new ArrayList<>();
|
||||||
@@ -62,7 +70,10 @@ public class DeviceDataTrendServiceImpl implements DeviceDataTrendService {
|
|||||||
List<CsEquipmentDeliveryDTO> data1 = equipmentFeignClient.queryDeviceById(Stream.of((data == null || data.isEmpty()) ? devicDataTrendQueryParam.getDevId() : data.get(0).getPid()).collect(Collectors.toList())).getData();
|
List<CsEquipmentDeliveryDTO> data1 = equipmentFeignClient.queryDeviceById(Stream.of((data == null || data.isEmpty()) ? devicDataTrendQueryParam.getDevId() : data.get(0).getPid()).collect(Collectors.toList())).getData();
|
||||||
//根据lineId获取监测点pt、ct变比
|
//根据lineId获取监测点pt、ct变比
|
||||||
CsLinePO linePo = csLineFeignClient.queryLineById(Collections.singletonList(devicDataTrendQueryParam.getLineId())).getData().get(0);
|
CsLinePO linePo = csLineFeignClient.queryLineById(Collections.singletonList(devicDataTrendQueryParam.getLineId())).getData().get(0);
|
||||||
|
List<CsDataSet> csDataSetList = dataSetFeignClient.getDataSetBySetIds(Stream.of(linePo.getDataSetId()).collect(Collectors.toList())).getData();
|
||||||
|
if(CollUtil.isEmpty(csDataSetList) || StrUtil.isBlank(csDataSetList.get(0).getDataLevel())){
|
||||||
|
throw new BusinessException("当前测点数据集主要信息缺失,请联系管理员排查(测点表里面数据集id缺失)");
|
||||||
|
}
|
||||||
devicDataTrendQueryParam.getStatisticalParams().forEach(temp->{
|
devicDataTrendQueryParam.getStatisticalParams().forEach(temp->{
|
||||||
CommonQueryParam commonQueryParam = new CommonQueryParam();
|
CommonQueryParam commonQueryParam = new CommonQueryParam();
|
||||||
commonQueryParam.setLineId(devicDataTrendQueryParam.getLineId());
|
commonQueryParam.setLineId(devicDataTrendQueryParam.getLineId());
|
||||||
@@ -83,19 +94,21 @@ public class DeviceDataTrendServiceImpl implements DeviceDataTrendService {
|
|||||||
vo.setTime(statisticalDataDTO.getTime());
|
vo.setTime(statisticalDataDTO.getTime());
|
||||||
vo.setStatMethod(statisticalDataDTO.getValueType());
|
vo.setStatMethod(statisticalDataDTO.getValueType());
|
||||||
//判断监测点类型 针对治理设备 模块数据是一次值、电能质量设备是二次值
|
//判断监测点类型 针对治理设备 模块数据是一次值、电能质量设备是二次值
|
||||||
if (linePo.getClDid() != 0 && Objects.equals(devicDataTrendQueryParam.getDataLevel(),"Primary") && ObjectUtil.isNotNull(epdPqd.getPrimaryFormula())) {
|
double value;
|
||||||
double secondaryData = DataChangeUtil.secondaryToPrimary(epdPqd.getPrimaryFormula(), statisticalDataDTO.getValue(), linePo.getPtRatio(), linePo.getCtRatio());
|
if (ObjectUtil.isNotNull(epdPqd.getPrimaryFormula()) && !Objects.equals(devicDataTrendQueryParam.getDataLevel(),csDataSetList.get(0).getDataLevel())) {
|
||||||
if (changePower(epdPqd.getShowName())) {
|
if("Primary".equals(csDataSetList.get(0).getDataLevel())){
|
||||||
secondaryData = secondaryData/1000;
|
value = DataChangeUtil.primaryToSecondary(epdPqd.getPrimaryFormula(), statisticalDataDTO.getValue(), linePo.getPtRatio(), linePo.getCtRatio());
|
||||||
|
}else {
|
||||||
|
value = DataChangeUtil.secondaryToPrimary(epdPqd.getPrimaryFormula(), statisticalDataDTO.getValue(), linePo.getPtRatio(), linePo.getCtRatio());
|
||||||
}
|
}
|
||||||
vo.setStatisticalData(BigDecimal.valueOf(secondaryData).setScale(4, RoundingMode.HALF_UP).doubleValue());
|
|
||||||
} else {
|
} else {
|
||||||
Double temVal = statisticalDataDTO.getValue();
|
value= statisticalDataDTO.getValue();
|
||||||
|
}
|
||||||
if (changePower(epdPqd.getShowName())) {
|
if (changePower(epdPqd.getShowName())) {
|
||||||
temVal = temVal/1000;
|
value = value/1000;
|
||||||
}
|
|
||||||
vo.setStatisticalData(BigDecimal.valueOf(temVal).setScale(4, RoundingMode.HALF_UP).doubleValue());
|
|
||||||
}
|
}
|
||||||
|
vo.setStatisticalData(BigDecimal.valueOf(value).setScale(4, RoundingMode.HALF_UP).doubleValue());
|
||||||
|
|
||||||
vo.setStatisticalIndex(temp.getDataId());
|
vo.setStatisticalIndex(temp.getDataId());
|
||||||
vo.setStatisticalName(temp.getName());
|
vo.setStatisticalName(temp.getName());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user