From bb2eca7eadbdf858df665eb876726cd1ee913e3e Mon Sep 17 00:00:00 2001 From: bin Date: Fri, 15 Jan 2021 03:11:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E9=80=81=E6=8A=A5=E6=96=87=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E8=BD=AC=E4=B9=89=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ssjl/zhaobiao/guizhou/controller/IotController.java | 5 ++++- .../java/com/ssjl/zhaobiao/guizhou/utils/GZHttpUtil.java | 2 ++ .../com/ssjl/zhaobiao/guizhou/CenterApplicationTests.java | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/ssjl/zhaobiao/guizhou/controller/IotController.java b/src/main/java/com/ssjl/zhaobiao/guizhou/controller/IotController.java index 7b254c7..04df23e 100644 --- a/src/main/java/com/ssjl/zhaobiao/guizhou/controller/IotController.java +++ b/src/main/java/com/ssjl/zhaobiao/guizhou/controller/IotController.java @@ -144,8 +144,11 @@ public class IotController { req.setIndex(GZUtil.getMessageIndex()); req.setStatus(GZRequestStatus.RESPONSE_ALL); req.setContent(askLocation); +// System.out.println(ByteUtil.bytesToHexString(req.toByte())); + log.info(imei + ",上报开机信息," + ByteUtil.bytesToHexString(req.toByte())); byte[] res = httpUtil.send(imei, "", req); - System.out.println(ByteUtil.bytesToHexString(res)); + log.info(imei + ",上报开机信息返回," + ByteUtil.bytesToHexString(res)); +// System.out.println(ByteUtil.bytesToHexString(res)); // 调用IOTAPI激活设备 log.info(imei + "激活设备"); diff --git a/src/main/java/com/ssjl/zhaobiao/guizhou/utils/GZHttpUtil.java b/src/main/java/com/ssjl/zhaobiao/guizhou/utils/GZHttpUtil.java index 866a912..33d9081 100644 --- a/src/main/java/com/ssjl/zhaobiao/guizhou/utils/GZHttpUtil.java +++ b/src/main/java/com/ssjl/zhaobiao/guizhou/utils/GZHttpUtil.java @@ -23,6 +23,7 @@ public class GZHttpUtil { public byte[] send(String imei, String phone, GZRequest req) throws IOException { Headers headers = new Headers.Builder().add("meid-id", imei).add("imsi-id", phone).build(); byte[] b = req.toByte(); + b = GZUtil.encode(b); try { byte[] res = httpUtil.postBytes(url, b, headers); return res; @@ -45,6 +46,7 @@ public class GZHttpUtil { public byte[] send(String imei, String phone, GZResponse req) throws IOException { Headers headers = new Headers.Builder().add("meid-id", imei).add("imsi-id", phone).build(); byte[] b = req.toBytes(); + b = GZUtil.encode(b); try { byte[] res = httpUtil.postBytes(url, b, headers); return res; diff --git a/src/test/java/com/ssjl/zhaobiao/guizhou/CenterApplicationTests.java b/src/test/java/com/ssjl/zhaobiao/guizhou/CenterApplicationTests.java index 576887d..fe709de 100644 --- a/src/test/java/com/ssjl/zhaobiao/guizhou/CenterApplicationTests.java +++ b/src/test/java/com/ssjl/zhaobiao/guizhou/CenterApplicationTests.java @@ -187,7 +187,7 @@ class CenterApplicationTests { } @Test public void test2(){ - String str = "52303432363131353031313b543b555430312e343b565450453430313b5874656c706f3b5931383636343237323734333b5a5450453339302c50434241302e32412e4431302c41492e302e302e322e443130"; + String str = "6572726f72206c656e"; byte[] b = ByteUtil.hexToByteArray(str); System.out.println(new String(b)); }