diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/LinePostionParam.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/LinePostionParam.java index 61508ae..ee1bb6b 100644 --- a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/LinePostionParam.java +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/LinePostionParam.java @@ -14,5 +14,7 @@ import java.util.List; */ @Data public class LinePostionParam { + /*拓扑图id*/ + private String id; private List pointList; } diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/project/LineTopologyDiagramController.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/project/LineTopologyDiagramController.java index b689a87..b9114f0 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/project/LineTopologyDiagramController.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/project/LineTopologyDiagramController.java @@ -90,7 +90,7 @@ public class LineTopologyDiagramController extends BaseController { @ApiImplicitParam(name = "linePostionParam", value = "监测点拓扑图数据集", required = true) public HttpResult auditList(@RequestBody LinePostionParam linePostionParam){ String methodDescribe = getMethodDescribe("auditList"); - appLineTopologyDiagramService.auditList(linePostionParam.getPointList()); + appLineTopologyDiagramService.auditList(linePostionParam); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); } diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/AppLineTopologyDiagramService.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/AppLineTopologyDiagramService.java index ca2e8c1..a17d4dd 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/AppLineTopologyDiagramService.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/AppLineTopologyDiagramService.java @@ -1,6 +1,7 @@ package com.njcn.csdevice.service; import com.baomidou.mybatisplus.extension.service.IService; +import com.njcn.csdevice.pojo.param.LinePostionParam; import com.njcn.csdevice.pojo.po.AppLineTopologyDiagramPO; import com.njcn.csdevice.pojo.vo.AppLineTopologyDiagramVO; import com.njcn.csdevice.pojo.vo.AppTopologyDiagramVO; @@ -24,5 +25,5 @@ public interface AppLineTopologyDiagramService extends IService queryByTopoId(String id); - void auditList(List list); + void auditList(LinePostionParam linePostionParam); } diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/AppLineTopologyDiagramServiceImpl.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/AppLineTopologyDiagramServiceImpl.java index e910d8d..ae7af69 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/AppLineTopologyDiagramServiceImpl.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/AppLineTopologyDiagramServiceImpl.java @@ -7,6 +7,7 @@ import com.njcn.common.pojo.exception.BusinessException; import com.njcn.csdevice.mapper.AppLineTopologyDiagramMapper; import com.njcn.csdevice.mapper.CsLedgerMapper; import com.njcn.csdevice.pojo.param.AppTopologyDiagramQueryParm; +import com.njcn.csdevice.pojo.param.LinePostionParam; import com.njcn.csdevice.pojo.po.AppLineTopologyDiagramPO; import com.njcn.csdevice.pojo.po.CsLedger; import com.njcn.csdevice.pojo.po.CsLinePO; @@ -81,11 +82,13 @@ public class AppLineTopologyDiagramServiceImpl extends ServiceImpl list) { - list.forEach(temp->{ + public void auditList(LinePostionParam linePostionParam) { + + + linePostionParam.getPointList().forEach(temp->{ this.lambdaUpdate().eq(AppLineTopologyDiagramPO::getId,temp.getId()). eq(AppLineTopologyDiagramPO::getLineId,temp.getLineId()).set(AppLineTopologyDiagramPO::getLat,temp.getLat()). - set(AppLineTopologyDiagramPO::getLng,temp.getLng()).update(); + set(AppLineTopologyDiagramPO::getLng,temp.getLng()).set(AppLineTopologyDiagramPO::getId,linePostionParam.getId()).update(); }); } } diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/handler/MqttMessageHandler.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/handler/MqttMessageHandler.java index 174d999..60d5f75 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/handler/MqttMessageHandler.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/handler/MqttMessageHandler.java @@ -15,6 +15,7 @@ import com.njcn.system.api.CsStatisticalSetFeignClient; import com.njcn.system.pojo.po.EleEpdPqd; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; import org.eclipse.paho.client.mqttv3.MqttMessage; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Component; @@ -42,7 +43,7 @@ public class MqttMessageHandler { private final ILineTargetService lineTargetService; private final CsStatisticalSetFeignClient csStatisticalSetFeignClient; private final StableDataService stableDataService; - private final DecimalFormat df = new DecimalFormat("#0.00"); + private final DecimalFormat df = new DecimalFormat("#0.000"); /** * 实时数据应答 */ @@ -64,12 +65,27 @@ public class MqttMessageHandler { //1.查询拓扑图配置的指标:拓扑图扑图配置:7677f94c749dedaff30f911949cbd724 List data = csStatisticalSetFeignClient.queryStatisticalSelect("7677f94c749dedaff30f911949cbd724").getData(); data.forEach(temp->{ + if(Objects.nonNull(temp.getHarmStart())&&Objects.nonNull(temp.getHarmEnd())){ + for (int i = temp.getHarmStart(); i < temp.getHarmEnd()+1; i++) { + CommonStatisticalQueryParam commonStatisticalQueryParam = new CommonStatisticalQueryParam(); + commonStatisticalQueryParam.setDevId(devId); + commonStatisticalQueryParam.setStatisticalId(temp.getId()); + commonStatisticalQueryParam.setValueType("avg"); + commonStatisticalQueryParam.setFrequency(i+""); + List thdDataVOS = stableDataService.queryFisrtCommonStatistical(commonStatisticalQueryParam); + tempList.addAll(thdDataVOS); + } + + + }else { CommonStatisticalQueryParam commonStatisticalQueryParam = new CommonStatisticalQueryParam(); commonStatisticalQueryParam.setDevId(devId); commonStatisticalQueryParam.setStatisticalId(temp.getId()); commonStatisticalQueryParam.setValueType("avg"); List thdDataVOS = stableDataService.queryFisrtCommonStatistical(commonStatisticalQueryParam); tempList.addAll(thdDataVOS); + } + }); //过滤M相 List m = tempList.stream().filter(temp -> Objects.equals(temp.getPhase(), "M")).collect(Collectors.toList()); @@ -82,7 +98,7 @@ public class MqttMessageHandler { }); }); //过滤谐波电流,谐波电压畸变率求平均值 - List thdI = tempList.stream().filter(temp -> Objects.equals(temp.getStatisticalName(), "ThdPhI(%)")).collect(Collectors.toList()); + List thdI = tempList.stream().filter(temp -> Objects.equals(temp.getStatisticalName(), "Pq_ThdU(%)")).collect(Collectors.toList()); Map> collect = thdI.stream().collect(Collectors.groupingBy(ThdDataVO::getLineId)); collect.forEach((k,v)->{ if(!CollectionUtil.isEmpty(v)){ @@ -96,7 +112,7 @@ public class MqttMessageHandler { } }); - List thdV = tempList.stream().filter(temp -> Objects.equals(temp.getStatisticalName(), "ThdPhV(%)")).collect(Collectors.toList()); + List thdV = tempList.stream().filter(temp -> Objects.equals(temp.getStatisticalName(), "Pq_ThdI(%)")).collect(Collectors.toList()); Map> collect1 = thdV.stream().collect(Collectors.groupingBy(ThdDataVO::getLineId)); collect1.forEach((k,v)->{ if(!CollectionUtil.isEmpty(v)){ @@ -109,6 +125,32 @@ public class MqttMessageHandler { } }); + List apfThdI = tempList.stream().filter(temp -> Objects.equals(temp.getStatisticalName(), "Apf_ThdA_Load(%)")).collect(Collectors.toList()); + Map> collect3 = apfThdI.stream().collect(Collectors.groupingBy(ThdDataVO::getLineId)); + collect3.forEach((k,v)->{ + if(!CollectionUtil.isEmpty(v)){ + double asDouble = v.stream().mapToDouble(ThdDataVO::getStatisticalData).average().getAsDouble(); + ThdDataVO thdDataVO = new ThdDataVO(); + BeanUtils.copyProperties(v.get(0),thdDataVO); + thdDataVO.setStatisticalData(Double.valueOf(df.format(asDouble))); + thdDataVO.setPhase("avg"); + result.add(thdDataVO); + + } + }); + List apfThdISys = tempList.stream().filter(temp -> Objects.equals(temp.getStatisticalName(), "Apf_ThdA_Sys(%)")).collect(Collectors.toList()); + Map> collect4 = apfThdISys.stream().collect(Collectors.groupingBy(ThdDataVO::getLineId)); + collect4.forEach((k,v)->{ + if(!CollectionUtil.isEmpty(v)){ + double asDouble = v.stream().mapToDouble(ThdDataVO::getStatisticalData).average().getAsDouble(); + ThdDataVO thdDataVO = new ThdDataVO(); + BeanUtils.copyProperties(v.get(0),thdDataVO); + thdDataVO.setStatisticalData(Double.valueOf(df.format(asDouble))); + thdDataVO.setPhase("avg"); + result.add(thdDataVO); + + } + }); List notM = tempList.stream().filter(temp -> !Objects.equals(temp.getPhase(), "M")).collect(Collectors.toList()); diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/StableDataServiceImpl.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/StableDataServiceImpl.java index c78a6bb..b35de94 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/StableDataServiceImpl.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/StableDataServiceImpl.java @@ -25,6 +25,7 @@ import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.math.RoundingMode; +import java.text.DecimalFormat; import java.time.ZoneId; import java.util.ArrayList; import java.util.List; @@ -49,6 +50,7 @@ public class StableDataServiceImpl implements StableDataService { private final CsLedgerFeignClient csLedgerFeignClient; private final EpdFeignClient epdFeignClient; private final CommonService commonService; + private final DecimalFormat df = new DecimalFormat("#0.0000"); @Override public List queryThdData(String devId, String statisticalName) { @@ -174,21 +176,29 @@ public class StableDataServiceImpl implements StableDataService { EleEpdPqd data = epdFeignClient.selectById(commonStatisticalQueryParam.getStatisticalId()).getData(); Optional.ofNullable(data).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.ELEEPDPQD_DATA_ERROR)); - String frequency = Optional.ofNullable(commonStatisticalQueryParam.getFrequency()).orElse(""); - + String frequency =""; + if(Objects.isNull(commonStatisticalQueryParam.getFrequency())){ + frequency =""; + }else { + frequency = "_"+commonStatisticalQueryParam.getFrequency(); + } List deviceRtData = commonService.getDeviceRtData(collect, data.getClassId(), data.getName()+frequency, data.getPhase(), commonStatisticalQueryParam.getValueType()); List finalCsLinePOList = csLinePOList; + String finalFrequency = frequency; List collect1 = deviceRtData.stream().map(temp -> { ThdDataVO vo = new ThdDataVO(); vo.setLineId(temp.getLineId()); - vo.setPhase(temp.getPhaseType()); + /*AB相映射A,BA相映射B,CA-》C*/ + + vo.setPhase(phaseReflection(temp.getPhaseType())); String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition(); vo.setPosition(position); vo.setTime(temp.getTime().atZone(ZoneId.systemDefault()).toLocalDateTime()); vo.setStatMethod(temp.getValueType()); - vo.setStatisticalData(BigDecimal.valueOf(temp.getValue()).setScale(4, RoundingMode.UP).doubleValue()); + vo.setStatisticalData(Double.valueOf(df.format(temp.getValue()))); vo.setStatisticalIndex(data.getId()); - vo.setStatisticalName(data.getName()+"("+data.getUnit()+")"); + vo.setStatisticalName(data.getName()+ finalFrequency +"("+data.getUnit()+")"); + vo.setAnotherName(data.getShowName()); return vo; }).collect(Collectors.toList()); @@ -219,7 +229,7 @@ public class StableDataServiceImpl implements StableDataService { vo.setPosition(position); vo.setTime(temp.getTime().atZone(ZoneId.systemDefault()).toLocalDateTime()); vo.setStatMethod(temp.getValueType()); - vo.setStatisticalData(BigDecimal.valueOf(temp.getValue()).setScale(4, RoundingMode.UP).doubleValue()); + vo.setStatisticalData(Double.valueOf(df.format(temp.getValue()))); vo.setStatisticalIndex(data.getId()); return vo; }).collect(Collectors.toList()); @@ -256,7 +266,7 @@ public class StableDataServiceImpl implements StableDataService { vo.setPosition(position); vo.setTime(temp.getTime().atZone(ZoneId.systemDefault()).toLocalDateTime()); vo.setStatMethod(temp.getValueType()); - vo.setStatisticalData(BigDecimal.valueOf(temp.getValue()).setScale(4, RoundingMode.UP).doubleValue()); + vo.setStatisticalData(Double.valueOf(df.format(temp.getValue()))); vo.setStatisticalIndex(data.getId()); return vo; }).collect(Collectors.toList()); @@ -264,4 +274,17 @@ public class StableDataServiceImpl implements StableDataService { return collect1; } + private String phaseReflection(String phase){ + switch (phase) { + case "AB": + return "A"; + case "BC": + return "B"; + case "CA": + return "C"; + default: + return phase; + } + } + }