From 988bbb6fe92380ba992a146ed94df2d8973a4edb Mon Sep 17 00:00:00 2001 From: liujie <1793218484@qq.com> Date: 星期四, 10 七月 2025 16:48:47 +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