From c5a4733debc9c2fe0c75f73e0c31cc9c9d4c560c Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期二, 15 七月 2025 11:39:39 +0800
Subject: [PATCH] 硬件数据推送
---
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/util/KsolarUtils.java | 18 +++++++++++++-----
1 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/util/KsolarUtils.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/util/KsolarUtils.java
index eb3cf11..06ab4ac 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/util/KsolarUtils.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/util/KsolarUtils.java
@@ -199,6 +199,7 @@
* @return
*/
public static String getElectricity(){
+ String valueTotal = "0";
String value = "0";
HttpRequest post = HttpRequest.post("https://www.zsdcloud.cn:8443/openApi/equipment/select.action");
post.form("token", accessToken);
@@ -215,16 +216,23 @@
}
String string1 = jsonObject.getString("result");
JSONObject jsonObject1 = JSONObject.parseObject(string1);
- String realInfo = jsonObject1.getString("realInfo");
+ String realInfo = jsonObject1.getString("childList");
JSONArray jsonArray = JSONArray.parseArray(realInfo);
for (Object o : jsonArray) {
JSONObject jsonObject2 = JSONObject.parseObject(o.toString());
- if(jsonObject2.get("Name").toString().equals("累积日充电量")){
- value= jsonObject2.get("Value").toString();
- break;
+ String string2 = jsonObject2.get("valueList").toString();
+ JSONArray jsonArray1 = JSONArray.parseArray(string2);
+ for (Object o1 : jsonArray1) {
+ JSONObject jsonObject3 = JSONObject.parseObject(o1.toString());
+ if(jsonObject3.get("Name").toString().equals("系统累计充电量")){
+ valueTotal= jsonObject3.get("Value").toString();
+ }
+ if(jsonObject3.get("Name").toString().equals("系统累计放电量")){
+ value= jsonObject3.get("Value").toString();
+ }
}
}
- return value;
+ return valueTotal+"_"+value;
}
public static void main(String[] args) throws Exception {
String electricity = getElectricity();
--
Gitblit v1.7.1