From 805fb9a0af29ef930a61ab1ec17deaf12a15c698 Mon Sep 17 00:00:00 2001
From: wuzeyu <1223318623@qq.com>
Date: 星期四, 24 十月 2024 17:33:12 +0800
Subject: [PATCH] 优化代码 获取地图中心坐标
---
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/CommandSv.java | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/CommandSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/CommandSv.java
index 289bacb..6118669 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/CommandSv.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/CommandSv.java
@@ -104,14 +104,16 @@
JSONObject response = (JSONObject) JSON.toJSON(sendCom2Mw(com));
if(response != null && response.getString("code").equals("0001")) {
JSONObject attachment = response.getJSONObject("content").getJSONObject("attachment").getJSONObject("onLineMap");
- HashMap<String, Boolean> onLineMap = JSON.parseObject(attachment.toJSONString(), HashMap.class);
JSONArray jsonArray = new JSONArray();
- for (Map.Entry<String, Boolean> entry : onLineMap.entrySet()) {
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("rtuAddr", entry.getKey());
- jsonObject.put("isOnLine", entry.getValue());
- jsonArray.add(jsonObject);
+ if(attachment != null) {
+ HashMap<String, Boolean> onLineMap = JSON.parseObject(attachment.toJSONString(), HashMap.class);
+ for (Map.Entry<String, Boolean> entry : onLineMap.entrySet()) {
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put("rtuAddr", entry.getKey());
+ jsonObject.put("isOnLine", entry.getValue());
+ jsonArray.add(jsonObject);
+ }
}
System.out.println(jsonArray.toJSONString());
--
Gitblit v1.8.0