From db9bf7a442714ffa8cbe030cdf3db67bd534c601 Mon Sep 17 00:00:00 2001 From: jiazx0107@163.com <jiazx0107@163.com> Date: 星期六, 18 十一月 2023 14:28:46 +0800 Subject: [PATCH] 增加HTTP地磅协议实现 --- src/main/java/com/fzzy/protocol/weightyh/GatewaySyncWeightImplHttp.java | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/fzzy/protocol/weightyh/GatewaySyncWeightImplHttp.java b/src/main/java/com/fzzy/protocol/weightyh/GatewaySyncWeightImplHttp.java index de1317f..24ec86f 100644 --- a/src/main/java/com/fzzy/protocol/weightyh/GatewaySyncWeightImplHttp.java +++ b/src/main/java/com/fzzy/protocol/weightyh/GatewaySyncWeightImplHttp.java @@ -50,23 +50,23 @@ log.debug("--HTTP-WEIGHT-璇锋眰杩斿洖--{}", responseText); - String respJson; JSONObject resp; + String jsonStr; //璇存槑鏄疛SONP鏍煎紡-jsonpCallback({"content":""}) if (responseText.indexOf("jsonpCallback") >= 0) { - respJson = responseText.substring(responseText.indexOf("(") + 1, responseText.length() - 1); - resp = JSONObject.parseObject(respJson); - resp.put("code", 200); + jsonStr = responseText.substring(responseText.indexOf("(") + 1, responseText.length() - 1); + resp = JSONObject.parseObject(jsonStr); + resp.put("code", "200"); } else { - respJson = responseText; - resp = JSONObject.parseObject(respJson); + jsonStr = responseText; + resp = JSONObject.parseObject(jsonStr); } - if (200 == (Integer) resp.get("code")) { + if ("200".equals(resp.get("code"))) { if (null == resp.get("content") || "".equals(resp.get("content"))) { reqData.setWeight(0.0); } else { - reqData.setWeight((Double) resp.get("content")); + reqData.setWeight(Double.valueOf(resp.get("content")+"")); } } @@ -75,7 +75,7 @@ gatewayRemoteManager.getDeviceReportService(device.getPushProtocol()).reportWeightData(reqData); } } catch (Exception e) { - log.error("--------------鍦扮-HTTP鍗忚鎵ц寮傚父----{}", e.getMessage()); + log.error("--------------鍦扮-HTTP鍗忚鎵ц寮傚父----{}", e); } return new BaseResp(500, "鍚庡彴鎵ц澶辫触"); } -- Gitblit v1.9.3