Merge remote-tracking branch 'origin/master'
# Conflicts: # cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsLedgerServiceImpl.java
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
b.id projectId,
|
||||
b.name projectName,
|
||||
c.id equipmentId,
|
||||
c.ndid nDid,
|
||||
c.name equipmentName,
|
||||
c.create_time createTime,
|
||||
c.run_status,
|
||||
|
||||
@@ -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);
|
||||
|
||||
/**
|
||||
* 获取装置时间范围内的历史数据
|
||||
|
||||
@@ -107,7 +107,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
}
|
||||
CsEquipmentDeliveryPO csEquipmentDeliveryPo = new CsEquipmentDeliveryPO();
|
||||
BeanUtils.copyProperties (csEquipmentDeliveryAddParm,csEquipmentDeliveryPo);
|
||||
csEquipmentDeliveryPo.setStatus ("1");
|
||||
csEquipmentDeliveryPo.setStatus (1);
|
||||
csEquipmentDeliveryPo.setRunStatus(1);
|
||||
String code = dictTreeFeignClient.queryById(csEquipmentDeliveryAddParm.getDevType()).getData().getCode();
|
||||
if (Objects.equals(DicDataEnum.PORTABLE.getCode(),code)) {
|
||||
@@ -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
|
||||
@@ -471,7 +473,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
String path = this.createPath(temp.getNdid());
|
||||
csEquipmentDeliveryPO.setMac(path);
|
||||
csEquipmentDeliveryPO.setRunStatus(1);
|
||||
csEquipmentDeliveryPO.setStatus("1");
|
||||
csEquipmentDeliveryPO.setStatus(1);
|
||||
csEquipmentDeliveryPO.setProcess(2);
|
||||
|
||||
CsEquipmentProcessPO csEquipmentProcess = new CsEquipmentProcessPO();
|
||||
@@ -546,8 +548,8 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
public void testCompletion(String deviceId,Integer type,String remark) {
|
||||
CsEquipmentDeliveryPO one = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getId, deviceId).one();
|
||||
this.lambdaUpdate().eq(CsEquipmentDeliveryPO::getId,deviceId).
|
||||
// set(CsEquipmentDeliveryPO::getStatus,1).
|
||||
// set(CsEquipmentDeliveryPO::getRunStatus,2).
|
||||
set(CsEquipmentDeliveryPO::getStatus,1).
|
||||
set(CsEquipmentDeliveryPO::getRunStatus,1).
|
||||
set(CsEquipmentDeliveryPO::getProcess,type+1).update();
|
||||
this.delete(deviceId);
|
||||
List<CsEquipmentProcessPO> list = csEquipmentProcessPOService.lambdaQuery().eq(CsEquipmentProcessPO::getDevId, one.getNdid()).
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
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;
|
||||
@@ -48,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;
|
||||
@@ -64,14 +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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 数据分组表 服务实现类
|
||||
@@ -134,7 +129,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,16 +138,27 @@ 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());
|
||||
//判断监测点类型 针对治理设备 模块数据是一次值、电能质量设备是二次值
|
||||
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(BigDecimal.valueOf(statisticalDataDTO.getValue()).setScale(4, RoundingMode.UP).doubleValue());
|
||||
}
|
||||
} else {
|
||||
vo.setDataValue(3.1415926);
|
||||
}
|
||||
@@ -186,23 +192,37 @@ 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 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);
|
||||
}
|
||||
@@ -663,6 +683,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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -84,33 +84,16 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
List<String> device = roleEngineerDevService.getDevice();
|
||||
engineeringList = allList.stream().filter(item->roleengineer.contains(item.getId())).collect(Collectors.toList());
|
||||
|
||||
// if (Objects.equals(RequestUtil.getUsername(),"root") || Objects.equals(RequestUtil.getUsername(),"njcnser")){
|
||||
// engineeringList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.ENGINEERING_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
|
||||
// } else {
|
||||
// List<CsEngineeringPO> engineering = csEngineeringUserService.getEngineeringByUser();
|
||||
// engineeringList = allList.stream().filter(item->engineering.stream().map(CsEngineeringPO::getId).collect(Collectors.toList()).contains(item.getId())).collect(Collectors.toList());
|
||||
// }
|
||||
List<CsLedgerVO> projectList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
|
||||
// List<CsLedgerVO> deviceList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.DEVICE_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
|
||||
List<CsLedgerVO> deviceList = allList.stream().filter(item -> device.contains(item.getId())).
|
||||
map(
|
||||
peek(
|
||||
temp->{
|
||||
CsEquipmentDeliveryPO csEquipmentDeliveryPO = csEquipmentDeliveryMapper.selectById(temp.getId());
|
||||
temp.setComFlag(csEquipmentDeliveryPO.getRunStatus());
|
||||
return temp;
|
||||
}
|
||||
).
|
||||
sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
|
||||
|
||||
List<CsLedgerVO> lineList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.LINE_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
|
||||
// List<String> collect = lineList.stream().map(CsLedgerVO::getId).collect(Collectors.toList());
|
||||
// List<CsLinePO> csLinePOS = csLinePOService.listByIds(collect);
|
||||
// List<CsLinePO> collect1 = csLinePOS.stream().filter(temp -> Objects.equals(temp.getPosition(), areaId)).collect(Collectors.toList());
|
||||
// List<String> collect2 = collect1.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
|
||||
// lineList = lineList.stream().filter(temp -> collect2.contains(temp.getId())).collect(Collectors.toList());
|
||||
|
||||
|
||||
List<CsLedgerVO> finalLineList = lineList;
|
||||
List<CsLedgerVO> finalLineList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.LINE_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
|
||||
checkDevSetData(deviceList);
|
||||
deviceList.forEach(dev -> dev.setChildren(getChildren(dev, finalLineList)));
|
||||
projectList.forEach(pro -> pro.setChildren(getChildren(pro, deviceList)));
|
||||
@@ -341,8 +324,12 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
* 获取子节点
|
||||
*/
|
||||
public List<CsLedgerVO> getChildren(CsLedgerVO item, List<CsLedgerVO> all) {
|
||||
return all.stream().filter(allItem -> allItem.getPid().equals(item.getId())).collect(Collectors.toList());
|
||||
return all.stream()
|
||||
.filter(allItem -> allItem.getPid().equals(item.getId()))
|
||||
.peek(child -> child.setComFlag(item.getComFlag()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public String getAreaById(String id){
|
||||
|
||||
String areaName =redisUtil.getStringByKey (id);
|
||||
|
||||
Reference in New Issue
Block a user