From 82e5d6c8e265faa2cc4b3c2e681b05cb2f814932 Mon Sep 17 00:00:00 2001 From: xy <748613696@qq.com> Date: Sat, 9 May 2026 14:20:25 +0800 Subject: [PATCH] =?UTF-8?q?refactor(data):=20=E4=BC=98=E5=8C=96=E8=B0=90?= =?UTF-8?q?=E6=B3=A2=E5=92=8C=E9=97=B4=E8=B0=90=E6=B3=A2=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E4=B8=80=E4=BA=8C=E6=AC=A1=E5=80=BC=E5=A4=84=E7=90=86=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/DataServiceImpl.java | 134 ++++++++++++++++-- 1 file changed, 123 insertions(+), 11 deletions(-) diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/DataServiceImpl.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/DataServiceImpl.java index 1629e27..7a43620 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/DataServiceImpl.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/DataServiceImpl.java @@ -115,10 +115,10 @@ public class DataServiceImpl implements IDataService { finalResult.add(vo); } } else if (Objects.equals(item2.getHarmStart(),2)) { - List harmList = getHarmData(item2,param.getLineId()); + List harmList = getHarmData(item2,param.getLineId(),param.getDataLevel(),csDataSet.getDataLevel(),pt,ct); finalResult.addAll(harmList); } else if (Objects.equals(item2.getHarmStart(),1)) { - List inuharmList = getInuHarmData(item2,param.getLineId()); + List inuharmList = getInuHarmData(item2,param.getLineId(),param.getDataLevel(),csDataSet.getDataLevel(),pt,ct); finalResult.addAll(inuharmList); } }); @@ -568,7 +568,7 @@ public class DataServiceImpl implements IDataService { re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue() / ct; break; case "*PT*CT": - re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue() / pt / ct / 1000; + re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue() / pt / ct * 1000; break; default: re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue(); @@ -594,46 +594,158 @@ public class DataServiceImpl implements IDataService { } //谐波数据 - public List getHarmData(EleEpdPqd item2, String lineId) { + public List getHarmData(EleEpdPqd item2, String lineId, String dataLevel, String csDataSetLevel, Double pt, Double ct) { List list = new ArrayList<>(); for (int i = item2.getHarmStart(); i <= item2.getHarmEnd(); i++) { RealTimeDataVo vo = new RealTimeDataVo(); vo.setId(item2.getId()); vo.setName(item2.getName().concat("_").concat(Integer.toString(i))); StatisticalDataDTO statisticalDataDTO = commonService.getLineRtData(lineId,influxDbParamUtil.getTableNameByClassId(item2.getClassId()),item2.getName().concat("_").concat(Integer.toString(i)),item2.getPhase(),"avg",influxDbParamUtil.getClDidByLineId(lineId)); + double re; + String unit; + if (Objects.equals("Primary",dataLevel)) { + if (Objects.equals("Primary",csDataSetLevel)) { + re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue(); + unit = item2.getUnit(); + } else { + if(Objects.nonNull(item2.getPrimaryFormula())){ + switch (item2.getPrimaryFormula()) { + case "*PT": + re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue() * pt / 1000; + unit = "k" + item2.getUnit(); + break; + case "*CT": + re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue() * ct; + unit = item2.getUnit(); + break; + case "*PT*CT": + re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue() * pt * ct / 1000; + unit = "k" + item2.getUnit(); + break; + default: + re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue(); + unit = item2.getUnit(); + break; + } + }else { + re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue(); + unit = item2.getUnit(); + } + } + } else { + if (Objects.equals("Primary",csDataSetLevel)) { + if(Objects.nonNull(item2.getPrimaryFormula())) { + switch (item2.getPrimaryFormula()) { + case "*PT": + re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue() / pt; + break; + case "*CT": + re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue() / ct; + break; + case "*PT*CT": + re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue() / pt / ct * 1000; + break; + default: + re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue(); + break; + } + }else { + re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue(); + } + } else { + re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue(); + } + unit = item2.getUnit(); + } if (Objects.isNull(statisticalDataDTO)) { vo.setAvgValue(3.14159); } else { vo.setTime(statisticalDataDTO.getTime()); - vo.setAvgValue(Double.valueOf(df.format(statisticalDataDTO.getValue()))); + vo.setAvgValue(Double.valueOf(df.format(re))); } vo.setPhase(item2.getPhase()); - vo.setOtherName(i + "次" + "(" + item2.getUnit() + ")"); + vo.setOtherName(i + "次" + "(" + unit + ")"); vo.setSort(item2.getSort()); - vo.setUnit(item2.getUnit()); + vo.setUnit(unit); list.add(vo); } return list; } //间谐波数据 - public List getInuHarmData(EleEpdPqd item2, String lineId) { + public List getInuHarmData(EleEpdPqd item2, String lineId, String dataLevel, String csDataSetLevel, Double pt, Double ct) { List list = new ArrayList<>(); for (int i = item2.getHarmStart(); i <= item2.getHarmEnd(); i++) { RealTimeDataVo vo = new RealTimeDataVo(); vo.setId(item2.getId()); vo.setName(item2.getName().concat("_").concat(Integer.toString(i))); StatisticalDataDTO statisticalDataDTO = commonService.getLineRtData(lineId,influxDbParamUtil.getTableNameByClassId(item2.getClassId()),item2.getName().concat("_").concat(Integer.toString(i)),item2.getPhase(),"avg",influxDbParamUtil.getClDidByLineId(lineId)); + double re; + String unit; + if (Objects.equals("Primary",dataLevel)) { + if (Objects.equals("Primary",csDataSetLevel)) { + re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue(); + unit = item2.getUnit(); + } else { + if(Objects.nonNull(item2.getPrimaryFormula())){ + switch (item2.getPrimaryFormula()) { + case "*PT": + re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue() * pt / 1000; + unit = "k" + item2.getUnit(); + break; + case "*CT": + re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue() * ct; + unit = item2.getUnit(); + break; + case "*PT*CT": + re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue() * pt * ct / 1000; + unit = "k" + item2.getUnit(); + break; + default: + re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue(); + unit = item2.getUnit(); + break; + } + }else { + re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue(); + unit = item2.getUnit(); + } + } + } else { + if (Objects.equals("Primary",csDataSetLevel)) { + if(Objects.nonNull(item2.getPrimaryFormula())) { + switch (item2.getPrimaryFormula()) { + case "*PT": + re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue() / pt; + break; + case "*CT": + re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue() / ct; + break; + case "*PT*CT": + re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue() / pt / ct * 1000; + break; + default: + re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue(); + break; + } + }else { + re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue(); + } + } else { + re = Objects.isNull(statisticalDataDTO) ? 3.14159 : statisticalDataDTO.getValue(); + } + unit = item2.getUnit(); + } if (Objects.isNull(statisticalDataDTO)) { vo.setAvgValue(3.14159); } else { vo.setTime(statisticalDataDTO.getTime()); - vo.setAvgValue(Double.valueOf(df.format(statisticalDataDTO.getValue()))); + vo.setAvgValue(Double.valueOf(df.format(re))); } vo.setPhase(item2.getPhase()); - vo.setOtherName((i-0.5) + "次" + "(" + item2.getUnit() + ")"); + vo.setOtherName((i-0.5) + "次" + "(" + unit + ")"); vo.setSort(item2.getSort()); - vo.setUnit(item2.getUnit()); + vo.setUnit(unit); list.add(vo); } return list;