From 4248245ce426dfe605c1cfbbd3e92b8b9e54c2b2 Mon Sep 17 00:00:00 2001
From: zhaiqm <1132477033@qq.com>
Date: Wed, 30 Aug 2023 10:50:09 +0800
Subject: [PATCH] =?UTF-8?q?@=E7=94=B5=E7=AB=99=E8=BF=90=E8=A1=8C=E6=95=B0?=
=?UTF-8?q?=E6=8D=AE@=E7=BF=9F=E5=8D=83=E6=B0=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
hzims-service-api/dam-safety-api/pom.xml | 6 ++
.../hzims/damsafety/feign/IWrpSectionBClient.java | 5 +
.../hzims/damsafety/feign/WrpSectionBClient.java | 10 ++
hzims-service/digital-twin-display/pom.xml | 5 +-
.../twindisplay/controller/BaseInfoController.java | 20 +++-
.../service/IDigitalBaseInfoService.java | 10 ++
.../service/impl/DigitalBaseInfoServiceImpl.java | 111 +++++++++++++++++++--
7 files changed, 156 insertions(+), 11 deletions(-)
diff --git a/hzims-service-api/dam-safety-api/pom.xml b/hzims-service-api/dam-safety-api/pom.xml
index ad10528..6d4ee93 100644
--- a/hzims-service-api/dam-safety-api/pom.xml
+++ b/hzims-service-api/dam-safety-api/pom.xml
@@ -3,6 +3,12 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
+
+
+ com.hnac.hzinfo.data
+ hzinfo-data-sdk
+
+
com.hnac.hzims
hzims-service-api
diff --git a/hzims-service-api/dam-safety-api/src/main/java/com/hnac/hzims/damsafety/feign/IWrpSectionBClient.java b/hzims-service-api/dam-safety-api/src/main/java/com/hnac/hzims/damsafety/feign/IWrpSectionBClient.java
index 081a64c..874e072 100644
--- a/hzims-service-api/dam-safety-api/src/main/java/com/hnac/hzims/damsafety/feign/IWrpSectionBClient.java
+++ b/hzims-service-api/dam-safety-api/src/main/java/com/hnac/hzims/damsafety/feign/IWrpSectionBClient.java
@@ -1,6 +1,7 @@
package com.hnac.hzims.damsafety.feign;
import com.hnac.hzims.damsafety.vo.WrpSectionBVO;
+import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData;
import org.springblade.core.tool.api.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
@@ -15,6 +16,7 @@ import java.util.Map;
public interface IWrpSectionBClient {
String API_PREFIX = "/wrpSectionBClient";
String LIST = API_PREFIX + "/list";
+ String GET_REAL_DATA = API_PREFIX + "/getRealData";
/**
* 获取断面列表
@@ -23,4 +25,7 @@ public interface IWrpSectionBClient {
*/
@GetMapping(LIST)
R> list(Map param);
+
+ @GetMapping(GET_REAL_DATA)
+ R> getRealData(String deviceCode);
}
diff --git a/hzims-service/dam-safety/src/main/java/com/hnac/hzims/damsafety/feign/WrpSectionBClient.java b/hzims-service/dam-safety/src/main/java/com/hnac/hzims/damsafety/feign/WrpSectionBClient.java
index fa703eb..4e1916a 100644
--- a/hzims-service/dam-safety/src/main/java/com/hnac/hzims/damsafety/feign/WrpSectionBClient.java
+++ b/hzims-service/dam-safety/src/main/java/com/hnac/hzims/damsafety/feign/WrpSectionBClient.java
@@ -2,10 +2,12 @@ package com.hnac.hzims.damsafety.feign;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hnac.hzims.damsafety.entity.WrpSectionB;
+import com.hnac.hzims.damsafety.service.IDamSafetyDataService;
import com.hnac.hzims.damsafety.service.IWrpSectionBService;
import com.hnac.hzims.damsafety.util.ParamUtil;
import com.hnac.hzims.damsafety.vo.WrpSectionBVO;
import com.hnac.hzims.damsafety.wrapper.WrpSectionBWrapper;
+import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData;
import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
@@ -19,10 +21,18 @@ public class WrpSectionBClient implements IWrpSectionBClient {
@Autowired
private IWrpSectionBService wrpSectionBService;
+ @Autowired
+ private IDamSafetyDataService damSafetyDataService;
+
@Override
public R> list(Map param) {
LambdaQueryWrapper wrapper= ParamUtil.conditionWrpSectionB(param);
List list = wrpSectionBService.list(wrapper);
return R.data(WrpSectionBWrapper.build().listVO(list));
}
+
+ @Override
+ public R> getRealData(String deviceCode) {
+ return R.data(damSafetyDataService.getRealData(deviceCode));
+ }
}
diff --git a/hzims-service/digital-twin-display/pom.xml b/hzims-service/digital-twin-display/pom.xml
index 7cd795d..af85fc2 100644
--- a/hzims-service/digital-twin-display/pom.xml
+++ b/hzims-service/digital-twin-display/pom.xml
@@ -67,12 +67,11 @@
${hzims.project.version}
-
-
+
com.hnac.hzims
diff --git a/hzims-service/digital-twin-display/src/main/java/com/hnac/hzims/twindisplay/controller/BaseInfoController.java b/hzims-service/digital-twin-display/src/main/java/com/hnac/hzims/twindisplay/controller/BaseInfoController.java
index f3027fd..e5893f6 100644
--- a/hzims-service/digital-twin-display/src/main/java/com/hnac/hzims/twindisplay/controller/BaseInfoController.java
+++ b/hzims-service/digital-twin-display/src/main/java/com/hnac/hzims/twindisplay/controller/BaseInfoController.java
@@ -49,9 +49,11 @@ public class BaseInfoController {
@ApiOperation(notes = "获取设备实时信息接口", value = "获取设备实时信息接口")
@RequestMapping(value = "/getRealData", method = RequestMethod.GET)
- public R getRealData(String deviceCode){
+ public Map getRealData(String deviceCode){
+ Map result = new HashMap<>();
List data = digitalBaseInfoService.getRealData(deviceCode);
- return R.data(data,"查询成功");
+ result.put(deviceCode, data);
+ return result;
}
@ApiOperation(notes = "获取降雨量信息", value = "获取降雨量信息")
@@ -60,4 +62,18 @@ public class BaseInfoController {
public Map> getRainFallInfo(String year,String location) {
return digitalBaseInfoService.getRainFallInfo(year,location);
}
+
+ @ApiOperation(notes = "获取电站发电运行信息", value = "获取电站发电运行信息")
+ @RequestMapping(value = "/getPowerStationHisInfo", method = RequestMethod.GET)
+ public Map getPowerStationHisInfo(String deviceCode){
+ //有功功率属性名
+ String activePower = "activePower";
+ //无功功率属性名
+ String reactivePower = "reactivePower";
+ //发电量
+ String power = "power";
+ Map data = digitalBaseInfoService.getPowerStationHisInfo(deviceCode,activePower,reactivePower,power);
+
+ return data;
+ }
}
diff --git a/hzims-service/digital-twin-display/src/main/java/com/hnac/hzims/twindisplay/service/IDigitalBaseInfoService.java b/hzims-service/digital-twin-display/src/main/java/com/hnac/hzims/twindisplay/service/IDigitalBaseInfoService.java
index bf8ba4d..514c751 100644
--- a/hzims-service/digital-twin-display/src/main/java/com/hnac/hzims/twindisplay/service/IDigitalBaseInfoService.java
+++ b/hzims-service/digital-twin-display/src/main/java/com/hnac/hzims/twindisplay/service/IDigitalBaseInfoService.java
@@ -44,4 +44,14 @@ public interface IDigitalBaseInfoService {
* @return
*/
Map> getRainFallInfo(String year, String location);
+
+ /**
+ * 获取电站发电运行信息
+ * @param deviceCode
+ * @param activePower
+ * @param reactivePower
+ * @param power
+ * @return
+ */
+ Map getPowerStationHisInfo(String deviceCode, String activePower, String reactivePower, String power);
}
diff --git a/hzims-service/digital-twin-display/src/main/java/com/hnac/hzims/twindisplay/service/impl/DigitalBaseInfoServiceImpl.java b/hzims-service/digital-twin-display/src/main/java/com/hnac/hzims/twindisplay/service/impl/DigitalBaseInfoServiceImpl.java
index efd85a8..db70c87 100644
--- a/hzims-service/digital-twin-display/src/main/java/com/hnac/hzims/twindisplay/service/impl/DigitalBaseInfoServiceImpl.java
+++ b/hzims-service/digital-twin-display/src/main/java/com/hnac/hzims/twindisplay/service/impl/DigitalBaseInfoServiceImpl.java
@@ -1,12 +1,18 @@
package com.hnac.hzims.twindisplay.service.impl;
+import com.hnac.hzims.damsafety.feign.IWrpSectionBClient;
import com.hnac.hzims.hzimsweather.feign.IHeWeatherWeatherClient;
import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherNowResponse;
import com.hnac.hzims.hzimsweather.vo.RainFallCountByMonthVo;
import com.hnac.hzims.twindisplay.service.IDigitalBaseInfoService;
import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient;
import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData;
+import com.hnac.hzinfo.datasearch.analyse.po.AnalyseCodeByAnalyseDataPO;
+import com.hnac.hzinfo.datasearch.analyse.po.AnalyzeDataConditionPO;
+import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeDataConditionVO;
import com.hnac.hzinfo.datasearch.real.po.RealDataSearchPO;
+import com.hnac.hzinfo.sdk.analyse.AnalyseDataSearchClient;
+import com.hnac.hzinfo.sdk.core.response.Result;
import lombok.RequiredArgsConstructor;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil;
@@ -16,6 +22,9 @@ import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
import java.util.*;
@Service
@@ -24,9 +33,11 @@ public class DigitalBaseInfoServiceImpl implements IDigitalBaseInfoService {
private final IHeWeatherWeatherClient heWeatherWeatherClient;
- private final IAnalyseDataSearchClient analyseDataSearchClient;
+ private final IAnalyseDataSearchClient ianalyseDataSearchClient;
- //private final IWrpSectionBClient wrpSectionBClient;
+ private final IWrpSectionBClient wrpSectionBClient;
+
+ private final AnalyseDataSearchClient analyseDataSearchClient;
@Override
public Map getDateInfo() {
@@ -65,7 +76,7 @@ public class DigitalBaseInfoServiceImpl implements IDigitalBaseInfoService {
List signages = Collections.singletonList(signage);
realData.setSignages(signages);
// 调用fegin接口查询实时数据
- R> R = analyseDataSearchClient.getRealDataByAnalyzeCode(realData);
+ R> R = ianalyseDataSearchClient.getRealDataByAnalyzeCode(realData);
if(!R.isSuccess() || CollectionUtil.isEmpty(R.getData())){
return 0.0;
}
@@ -83,12 +94,11 @@ public class DigitalBaseInfoServiceImpl implements IDigitalBaseInfoService {
@Override
public List getRealData(String deviceCode) {
- /*R> realData = wrpSectionBClient.getRealData(deviceCode);
+ R> realData = wrpSectionBClient.getRealData(deviceCode);
if(!realData.isSuccess() || CollectionUtil.isEmpty(realData.getData())){
return null;
}
- return realData.getData();*/
- return null;
+ return realData.getData();
}
@Override
@@ -100,5 +110,94 @@ public class DigitalBaseInfoServiceImpl implements IDigitalBaseInfoService {
return result.getData();
}
+ @Override
+ public Map getPowerStationHisInfo(String deviceCode, String activePower, String reactivePower, String power) {
+ R> realData = wrpSectionBClient.getRealData(deviceCode);
+
+ Map result = new HashMap<>();
+ if(realData.isSuccess() && CollectionUtil.isNotEmpty(realData.getData())){
+ List datas = realData.getData();
+ datas.stream().forEach(data -> {
+ if (activePower.equals(data.getSignage())) {
+ //有功功率
+ result.put(activePower, data.getValue());
+ }
+ if (reactivePower.equals(data.getSignage())) {
+ //无功功率
+ result.put(reactivePower, data.getValue());
+ }
+ });
+ }
+
+ //当前年的第一天 2023-1-1
+ LocalDate year = LocalDate.now().withDayOfYear(1);
+ //当前月的第一天 2023-8-1
+ LocalDate month = LocalDate.now().withDayOfMonth(1);
+ //当天 2023-8-29
+ LocalDate day = LocalDate.now();
+ LocalTime startTime = LocalTime.MIN;
+
+
+ LocalDateTime end = LocalDateTime.now();
+
+ //年累计
+ LocalDateTime start = LocalDateTime.of(year, startTime);
+ AnalyseCodeByAnalyseDataPO poForYear = getPowerByParam(deviceCode, start, end, 4, 6, 1);
+ Result> listForYear = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(poForYear);
+
+ //月累计
+ start = LocalDateTime.of(month, startTime);
+ AnalyseCodeByAnalyseDataPO poForMonth = getPowerByParam(deviceCode, start, end, 4, 5, 1);
+ Result> listForMonth = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(poForMonth);
+
+ //日累计
+ start = LocalDateTime.of(day, startTime);
+ AnalyseCodeByAnalyseDataPO poForDay = getPowerByParam(deviceCode, start, end, 4, 4, 1);
+ Result> listForDay = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(poForDay);
+
+ //日发电计划完成率
+ result.put("dayPowerRate",null);
+ //月发电计划完成率
+ result.put("monthPowerRate",null);
+ //日累计发电量
+ result.put("dayPowerSum",null);
+ //月累计发电量
+ result.put("monthPowerSum",null);
+ //年累计发电量
+ result.put("yearPowerSum",null);
+ return result;
+ }
+
+ /**
+ * 根据入参查询设备信息
+ * @param deviceCode 设备编号
+ * @param start 开始时间
+ * @param end 结束时间
+ * @param accessRules 取数规则0=最早值、1=最大值、2=最小值、3=平均值、4=(累计值/和值)、5=(变化值/差值) 6=最新值
+ * @param saveTimeType 周期类型: 0-> s(秒) 1->m(分) 2->h(小时) 3->d(天) 4->w(周) 5->n(自然月) 6->y(自然年)
+ * @param timeInterval 间隔时间
+ * @return
+ */
+ public AnalyseCodeByAnalyseDataPO getPowerByParam(String deviceCode, LocalDateTime start, LocalDateTime end,
+ Integer accessRules, Integer saveTimeType, Integer timeInterval) {
+ AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO();
+ po.setDeviceCode(deviceCode);
+
+ List signboardConditions = new ArrayList<>();
+ AnalyzeDataConditionPO conditionPO = new AnalyzeDataConditionPO();
+
+ conditionPO.setBeginTime(start);
+ conditionPO.setEndTime(end);
+ conditionPO.setSignages(deviceCode);
+// conditionPO.setKeepFigures(3);
+ conditionPO.setAccessRules(accessRules);
+ conditionPO.setSaveTimeType(saveTimeType);
+ conditionPO.setTimeInterval(timeInterval);
+ conditionPO.setFull(1);
+ signboardConditions.add(conditionPO);
+ po.setSignboardConditions(signboardConditions);
+ return po;
+ }
+
}