diff --git a/cs-harmonic/cs-harmonic-api/pom.xml b/cs-harmonic/cs-harmonic-api/pom.xml
index e6e9e54..43aa50d 100644
--- a/cs-harmonic/cs-harmonic-api/pom.xml
+++ b/cs-harmonic/cs-harmonic-api/pom.xml
@@ -13,6 +13,27 @@
cs-harmonic-api
+
+
+ com.njcn
+ common-core
+ ${project.version}
+
+
+ com.njcn
+ common-db
+ ${project.version}
+
+
+ org.projectlombok
+ lombok
+
+
+ com.njcn
+ common-microservice
+ ${project.version}
+
+
UTF-8
8
diff --git a/cs-harmonic/cs-harmonic-api/src/main/java/pojo/param/ThdDataQueryParm.java b/cs-harmonic/cs-harmonic-api/src/main/java/pojo/param/ThdDataQueryParm.java
new file mode 100644
index 0000000..d97d9c2
--- /dev/null
+++ b/cs-harmonic/cs-harmonic-api/src/main/java/pojo/param/ThdDataQueryParm.java
@@ -0,0 +1,45 @@
+package pojo.param;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * Description:
+ * Date: 2023/5/16 16:25【需求编号】
+ *
+ * @author clam
+ * @version V1.0.0
+ */
+@Data
+public class ThdDataQueryParm {
+
+
+ private String devId;
+
+ private String statisticalName;
+
+
+ /**
+ * 开始时间
+ */
+ @ApiModelProperty(value = "开始时间")
+ @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
+ @NotNull(message="开始时间不能为空!")
+ private String startTime;
+
+ /**
+ * 结束时间
+ */
+ @ApiModelProperty(value = "结束时间")
+ @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
+ @NotNull(message="结束时间不能为空!")
+ private String endTime;
+
+
+}
\ No newline at end of file
diff --git a/cs-harmonic/cs-harmonic-api/src/main/java/pojo/vo/ThdDataVO.java b/cs-harmonic/cs-harmonic-api/src/main/java/pojo/vo/ThdDataVO.java
new file mode 100644
index 0000000..c77ad2b
--- /dev/null
+++ b/cs-harmonic/cs-harmonic-api/src/main/java/pojo/vo/ThdDataVO.java
@@ -0,0 +1,34 @@
+package pojo.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.time.LocalDateTime;
+
+/**
+ * Description:
+ * Date: 2023/5/18 9:14【需求编号】
+ *
+ * @author clam
+ * @version V1.0.0
+ */
+@Data
+public class ThdDataVO {
+ @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
+ private LocalDateTime time;
+ private String LineId;
+ private String position;
+
+ private String Phase;
+ private String StatMethod;
+
+ private String statisticalIndex;
+ private String statisticalName;
+
+
+ private Double statisticalData;
+
+
+}
diff --git a/cs-harmonic/cs-harmonic-boot/pom.xml b/cs-harmonic/cs-harmonic-boot/pom.xml
index b9e3c84..41b1995 100644
--- a/cs-harmonic/cs-harmonic-boot/pom.xml
+++ b/cs-harmonic/cs-harmonic-boot/pom.xml
@@ -40,6 +40,34 @@
common-db
${project.version}
+
+ com.njcn
+ pqs-influx
+ 0.0.1-SNAPSHOT
+
+
+
+ com.squareup.okhttp3
+ okhttp
+ 4.9.0
+
+
+ com.squareup.okhttp3
+ logging-interceptor
+ 4.9.0
+
+
+ com.njcn
+ cs-harmonic-api
+ 1.0.0
+ compile
+
+
+ com.njcn
+ cs-device-api
+ 1.0.0
+ compile
+
diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/harmonic/CsHarmonicBootApplication.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/harmonic/CsHarmonicBootApplication.java
index 8c3e65a..b0febfc 100644
--- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/harmonic/CsHarmonicBootApplication.java
+++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/harmonic/CsHarmonicBootApplication.java
@@ -5,6 +5,7 @@ import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
+import org.springframework.context.annotation.DependsOn;
/**
@@ -16,6 +17,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
@MapperScan("com.njcn.**.mapper")
@EnableFeignClients(basePackages = "com.njcn")
@SpringBootApplication(scanBasePackages = "com.njcn")
+@DependsOn("proxyMapperRegister")
public class CsHarmonicBootApplication {
public static void main(String[] args) {
diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/harmonic/controller/StableDataController.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/harmonic/controller/StableDataController.java
new file mode 100644
index 0000000..77a7165
--- /dev/null
+++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/harmonic/controller/StableDataController.java
@@ -0,0 +1,86 @@
+package com.njcn.harmonic.controller;
+
+import com.njcn.common.pojo.annotation.OperateInfo;
+import com.njcn.common.pojo.enums.common.LogEnum;
+import com.njcn.common.pojo.enums.response.CommonResponseEnum;
+import com.njcn.common.pojo.response.HttpResult;
+import com.njcn.common.utils.HttpResultUtil;
+import com.njcn.harmonic.service.StableDataService;
+import com.njcn.web.controller.BaseController;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+import pojo.param.ThdDataQueryParm;
+import pojo.vo.ThdDataVO;
+
+import java.util.List;
+
+/**
+ * Description:
+ * Date: 2023/5/18 8:51【需求编号】
+ *
+ * @author clam
+ * @version V1.0.0
+ */
+@Slf4j
+@RestController
+@RequestMapping("/stable")
+@Api(tags = "稳态数据展示")
+@AllArgsConstructor
+public class StableDataController extends BaseController {
+
+ private final StableDataService stableDataService;
+
+ @OperateInfo(info = LogEnum.BUSINESS_COMMON)
+ @PostMapping("/queryFisrtThdData")
+ @ApiOperation("查询谐波畸变率实时数据")
+ @ApiImplicitParams({
+ @ApiImplicitParam(name = "devId", value = "设备id", required = true),
+ @ApiImplicitParam(name = "statisticalName", value = "统计指标name", required = true)
+ })
+ public HttpResult> queryFisrtThdData(@RequestParam("devId") String devId, @RequestParam("statisticalName") String statisticalName) {
+ String methodDescribe = getMethodDescribe("queryThdData");
+ List list = stableDataService.queryThdData(devId, statisticalName);
+ return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
+ }
+
+ @OperateInfo(info = LogEnum.BUSINESS_COMMON)
+ @PostMapping("/queryThdDataByTime")
+ @ApiOperation("查询时间段内谐波畸变率")
+ @ApiImplicitParam(name = "thdDataQueryParm", value = "查询参数", required = true)
+ public HttpResult> queryThdDataByTime(@RequestBody @Validated ThdDataQueryParm thdDataQueryParm) {
+ String methodDescribe = getMethodDescribe("queryThdDataByTime");
+ List list = stableDataService.queryThdDataByTime(thdDataQueryParm);
+ return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
+
+ }
+
+ @OperateInfo(info = LogEnum.BUSINESS_COMMON)
+ @PostMapping("/queryFisrtThdContent")
+ @ApiOperation("查询谐波含量实时数据")
+ @ApiImplicitParams({
+ @ApiImplicitParam(name = "devId", value = "设备id", required = true),
+ @ApiImplicitParam(name = "statisticalName", value = "统计指标name", required = true)
+ })
+ public HttpResult> queryFisrtThdContent(@RequestParam("devId") String devId, @RequestParam("statisticalName") String statisticalName) {
+ String methodDescribe = getMethodDescribe("queryFisrtThdContent");
+ List list = stableDataService.queryFisrtThdContent(devId, statisticalName);
+ return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
+ }
+
+ @OperateInfo(info = LogEnum.BUSINESS_COMMON)
+ @PostMapping("/queryThdContentByTime")
+ @ApiOperation("查询时间段内谐波畸变率")
+ @ApiImplicitParam(name = "thdDataQueryParm", value = "查询参数", required = true)
+ public HttpResult> queryThdContentByTime(@RequestBody @Validated ThdDataQueryParm thdDataQueryParm) {
+ String methodDescribe = getMethodDescribe("queryThdContentByTime");
+ List list = stableDataService.queryThdContentByTime(thdDataQueryParm);
+ return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
+
+ }
+}
\ No newline at end of file
diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/harmonic/service/StableDataService.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/harmonic/service/StableDataService.java
new file mode 100644
index 0000000..0776a2b
--- /dev/null
+++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/harmonic/service/StableDataService.java
@@ -0,0 +1,31 @@
+package com.njcn.harmonic.service;
+
+
+
+import pojo.param.ThdDataQueryParm;
+import pojo.vo.ThdDataVO;
+
+import java.util.List;
+
+/**
+ * Description:
+ * Date: 2023/5/18 14:39【需求编号】
+ *
+ * @author clam
+ * @version V1.0.0
+ */
+public interface StableDataService {
+ List queryThdData(String devId, String statisticalName);
+ /**
+ * @Description: 查询时间段内谐波畸变率
+ * @Param:
+ * @return: java.util.List
+ * @Author: clam
+ * @Date: 2023/5/23
+ */
+ List queryThdDataByTime(ThdDataQueryParm thdDataQueryParm);
+
+ List queryFisrtThdContent(String devId, String statisticalName);
+
+ List queryThdContentByTime(ThdDataQueryParm thdDataQueryParm);
+}
diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/StableDataServiceImpl.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/StableDataServiceImpl.java
new file mode 100644
index 0000000..53d2c01
--- /dev/null
+++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/StableDataServiceImpl.java
@@ -0,0 +1,157 @@
+package com.njcn.harmonic.service.impl;
+
+import com.alibaba.nacos.client.naming.utils.CollectionUtils;
+
+import com.njcn.common.pojo.exception.BusinessException;
+import com.njcn.csdevice.constant.DataParam;
+import com.njcn.csdevice.enums.AlgorithmResponseEnum;
+import com.njcn.csdevice.pojo.po.CsLinePO;
+import com.njcn.csdevice.utils.ReflectUtils;
+import com.njcn.harmonic.service.StableDataService;
+
+import lombok.RequiredArgsConstructor;
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Service;
+import pojo.param.ThdDataQueryParm;
+import pojo.vo.ThdDataVO;
+
+import java.time.ZoneId;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+/**
+ * Description:
+ * Date: 2023/5/18 14:39【需求编号】
+ *
+ * @author clam
+ * @version V1.0.0
+ */
+@Service
+@RequiredArgsConstructor
+public class StableDataServiceImpl implements StableDataService {
+
+ private final CsLinePOService csLinePOService;
+ private final PowerQualityService powerQualityService;
+ private final HarmonicRatioService harmonicRatioService;
+
+ @Override
+ public List queryThdData(String devId, String statisticalName) {
+ List thdDataVOList = new ArrayList<>();
+ List csLinePOList = csLinePOService.queryByDevId(devId);
+ Optional.ofNullable(csLinePOList).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.LINE_DATA_ERROR));
+ List collect = csLinePOList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
+ List firstPowerQuality = powerQualityService.getFirstPowerQuality(collect, statisticalName);
+
+ csLinePOList.forEach(temp->{
+ DataParam.phases.forEach(phase->{
+ DataParam.statMethods.forEach(method -> {
+ ThdDataVO thdDataVO = new ThdDataVO();
+ thdDataVO.setLineId(temp.getLineId());
+ thdDataVO.setPosition(temp.getPosition());
+ thdDataVO.setStatisticalName(statisticalName);
+ thdDataVO.setPhase(phase);
+ thdDataVO.setStatMethod(method);
+ Double statisticalValue = 0.00;
+ List collect1 = firstPowerQuality.stream().filter(powerQualityData -> Objects.equals(powerQualityData.getPhase(), phase) &&
+ Objects.equals(powerQualityData.getStatMethod(), method)
+ ).collect(Collectors.toList());
+ if(!CollectionUtils.isEmpty(collect1)){
+ statisticalValue= (Double) ReflectUtils.getValue(collect1.get(0), statisticalName);
+ }
+ thdDataVO.setStatisticalData(statisticalValue);
+ thdDataVOList.add(thdDataVO);
+ });
+ });
+
+ });
+
+ return thdDataVOList;
+ }
+
+ @Override
+ public List queryThdDataByTime(ThdDataQueryParm thdDataQueryParm) {
+ List thdDataVOList = new ArrayList<>();
+ List csLinePOList = csLinePOService.queryByDevId(thdDataQueryParm.getDevId());
+ Optional.ofNullable(csLinePOList).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.LINE_DATA_ERROR));
+ List collect = csLinePOList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
+ List firstPowerQuality = powerQualityService.getPowerQuality(collect, thdDataQueryParm.getStatisticalName(), thdDataQueryParm.getStartTime(), thdDataQueryParm.getEndTime());
+
+ csLinePOList.forEach(temp->{
+ DataParam.phases.forEach(phase->{
+ DataParam.statMethods.forEach(method -> {
+ ThdDataVO thdDataVO = new ThdDataVO();
+ thdDataVO.setLineId(temp.getLineId());
+ thdDataVO.setPosition(temp.getPosition());
+ thdDataVO.setStatisticalName(thdDataQueryParm.getStatisticalName());
+ thdDataVO.setPhase(phase);
+ thdDataVO.setStatMethod(method);
+ Double statisticalValue = 0.00;
+ List collect1 = firstPowerQuality.stream().filter(powerQualityData -> Objects.equals(powerQualityData.getPhase(), phase) &&
+ Objects.equals(powerQualityData.getStatMethod(), method)
+ ).collect(Collectors.toList());
+ if(!CollectionUtils.isEmpty(collect1)){
+ statisticalValue= (Double) ReflectUtils.getValue(collect1.get(0), thdDataQueryParm.getStatisticalName());
+ }
+ thdDataVO.setStatisticalData(statisticalValue);
+ thdDataVOList.add(thdDataVO);
+ });
+ });
+
+ });
+
+ return thdDataVOList;
+ }
+
+ @Override
+ public List queryFisrtThdContent(String devId, String statisticalName) {
+ List thdDataVOList = new ArrayList<>();
+ List csLinePOList = csLinePOService.queryByDevId(devId);
+ Optional.ofNullable(csLinePOList).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.LINE_DATA_ERROR));
+ List collect = csLinePOList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
+ List harmonicRatioList = haronicRatioService.getFirstHaronicRatio(collect, statisticalName);
+ harmonicRatioList.forEach(temp->{
+ ThdDataVO thdDataVO = new ThdDataVO();
+ BeanUtils.copyProperties(temp,thdDataVO);
+ thdDataVO.setStatisticalName(statisticalName);
+ thdDataVO.setTime(temp.getTime().atZone(ZoneId.systemDefault()).toLocalDateTime());
+ String position = csLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), thdDataVO.getLineId())).collect(Collectors.toList()).get(0).getPosition();
+ thdDataVO.setPosition(position);
+ Double statisticalValue = 0.00;
+ statisticalValue= (Double) ReflectUtils.getValue(temp, statisticalName);
+ thdDataVO.setStatisticalData(statisticalValue);
+
+ thdDataVOList.add(thdDataVO);
+
+ });
+
+ return thdDataVOList;
+ }
+
+ @Override
+ public List queryThdContentByTime(ThdDataQueryParm thdDataQueryParm) {
+ List thdDataVOList = new ArrayList<>();
+ List csLinePOList = csLinePOService.queryByDevId(thdDataQueryParm.getDevId());
+ Optional.ofNullable(csLinePOList).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.LINE_DATA_ERROR));
+ List collect = csLinePOList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
+ List harmonicRatioList = haronicRatioService.getHaronicRatio(collect, thdDataQueryParm.getStatisticalName(),thdDataQueryParm.getStartTime(), thdDataQueryParm.getEndTime());
+ harmonicRatioList.forEach(temp->{
+ ThdDataVO thdDataVO = new ThdDataVO();
+ BeanUtils.copyProperties(temp,thdDataVO);
+ thdDataVO.setStatisticalName(thdDataQueryParm.getStatisticalName());
+ thdDataVO.setTime(temp.getTime().atZone(ZoneId.systemDefault()).toLocalDateTime());
+ String position = csLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), thdDataVO.getLineId())).collect(Collectors.toList()).get(0).getPosition();
+ thdDataVO.setPosition(position);
+ Double statisticalValue = 0.00;
+ statisticalValue= (Double) ReflectUtils.getValue(temp, thdDataQueryParm.getStatisticalName());
+ thdDataVO.setStatisticalData(statisticalValue);
+
+ thdDataVOList.add(thdDataVO);
+
+ });
+
+ return thdDataVOList;
+ }
+}