二次值转换为一次值

This commit is contained in:
xy
2024-08-14 14:04:41 +08:00
parent 703a145bb3
commit 2f1e899be7
8 changed files with 152 additions and 21 deletions

View File

@@ -61,10 +61,11 @@ public class CsGroupController extends BaseController {
@ApiImplicitParam(name = "pageSize", value = "页面尺寸", required = true),
@ApiImplicitParam(name = "lineId", value = "监测点id", required = true),
@ApiImplicitParam(name = "searchValue", value = "搜索值", required = true),
@ApiImplicitParam(name = "dataLevel", value = "数据标志", required = true)
})
public HttpResult<IPage<DataGroupTemplateVO>> getDeviceRtData(@RequestParam("id") String id, @RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize, @RequestParam(value = "lineId")String lineId, @RequestParam(value = "searchValue") String searchValue){
public HttpResult<IPage<DataGroupTemplateVO>> getDeviceRtData(@RequestParam("id") String id, @RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize, @RequestParam(value = "lineId")String lineId, @RequestParam(value = "searchValue") String searchValue, @RequestParam(value = "dataLevel",required = false) String dataLevel){
String methodDescribe = getMethodDescribe("getDeviceRtData");
IPage<DataGroupTemplateVO> list = csGroupService.getDeviceRtData(id, pageNum, pageSize,lineId,searchValue);
IPage<DataGroupTemplateVO> list = csGroupService.getDeviceRtData(id, pageNum, pageSize,lineId,searchValue,dataLevel);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}

View File

@@ -34,7 +34,7 @@ public interface ICsGroupService extends IService<CsGroup> {
* 获取装置分组后的实时数据
* @return
*/
IPage<DataGroupTemplateVO> getDeviceRtData(String id, Integer pageNum, Integer pageSize, String lineId, String searchValue);
IPage<DataGroupTemplateVO> getDeviceRtData(String id, Integer pageNum, Integer pageSize, String lineId, String searchValue, String dataLevel);
/**
* 获取装置时间范围内的历史数据

View File

@@ -349,6 +349,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
dataSetVO.setName(item.getAnotherName());
dataSetVO.setType("rt");
dataSetList.add(dataSetVO);
deviceManagerVo.setDataLevel(item.getDataLevel());
if (Objects.equals(type, "history")) {
//历史数据tab
DeviceManagerVO.DataSetVO dataSetVo2 = new DeviceManagerVO.DataSetVO();
@@ -356,6 +357,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
dataSetVo2.setName("历史" + item.getAnotherName());
dataSetVo2.setType("history");
dataSetList.add(dataSetVo2);
deviceManagerVo.setDataLevel(item.getDataLevel());
//下面这些tab仅仅只限于设备监控的便携式设备才会有
if(DataParam.portableDevType.equals(csEquipmentDeliveryPo.getDevType())){
//趋势数据tab

View File

@@ -3,6 +3,7 @@ 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;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -67,6 +68,7 @@ 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;
@@ -134,7 +136,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
}
@Override
public IPage<DataGroupTemplateVO> getDeviceRtData(String id, Integer pageNum, Integer pageSize, String lineId, String searchValue) {
public IPage<DataGroupTemplateVO> getDeviceRtData(String id, Integer pageNum, Integer pageSize, String lineId, String searchValue, String dataLevel) {
IPage<DataGroupTemplateVO> pageTurn = new Page<>();
List<EnergyTemplateVO> arrayList = new ArrayList<>();
IPage<DataGroupTemplateVO> pageRes = csGroupMapper.getGroupDataList(new Page<>(pageNum, pageSize),id,searchValue);
@@ -143,19 +145,76 @@ 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 csLinePO = csLineFeignClient.queryLineById(Collections.singletonList(lineId)).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.getLineRtData(lineId,influxDbParamUtil.getTableNameByClassId(eleEpdPqd.getClassId()),item.getName(),item.getPhase(),item.getStatMethod(),influxDbParamUtil.getClDidByLineId(lineId));
if (!Objects.isNull(statisticalDataDTO)){
if (Objects.nonNull(statisticalDataDTO)) {
vo.setTime(statisticalDataDTO.getTime());
vo.setDataValue(BigDecimal.valueOf(statisticalDataDTO.getValue()).setScale(4, RoundingMode.UP).doubleValue());
} else {
vo.setDataValue(3.1415926);
}
if (Objects.isNull(dataLevel)) {
if (Objects.nonNull(statisticalDataDTO)) {
vo.setDataValue(BigDecimal.valueOf(statisticalDataDTO.getValue()).setScale(4, RoundingMode.UP).doubleValue());
} else {
vo.setDataValue(3.1415926);
}
} 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);
}
}
}
// 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)){
@@ -663,6 +722,27 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
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;
}
}