diff --git a/jsowell-admin/src/test/java/SpringBootTestController.java b/jsowell-admin/src/test/java/SpringBootTestController.java index 83695399b..c3a961e44 100644 --- a/jsowell-admin/src/test/java/SpringBootTestController.java +++ b/jsowell-admin/src/test/java/SpringBootTestController.java @@ -16,6 +16,7 @@ import com.jsowell.common.core.redis.RedisCache; import com.jsowell.common.enums.ykc.OrderStatusEnum; import com.jsowell.common.exception.BusinessException; import com.jsowell.common.util.*; +import com.jsowell.common.util.http.HttpUtils; import com.jsowell.common.util.id.SnUtils; import com.jsowell.common.util.id.SnowflakeIdWorker; import com.jsowell.common.util.ip.AddressUtils; @@ -36,6 +37,7 @@ import com.jsowell.service.MemberService; import com.jsowell.service.OrderService; import com.jsowell.service.PileRemoteService; import com.jsowell.service.PileService; +import com.jsowell.thirdparty.lianlian.common.CommonResult; import com.jsowell.thirdparty.lianlian.dto.CommonParamsDTO; import com.jsowell.thirdparty.lianlian.service.LianLianService; import com.jsowell.thirdparty.lianlian.util.Cryptos; @@ -230,21 +232,21 @@ public class SpringBootTestController { // String token = lianLianService.getToken("", "MA1JLFUU8", "fGwLsxW1HdzLw7jp"); // System.out.println("token:" + token); - String operatorId = "I4XLPQPV"; + String operatorId = "425010765"; String operatorSecret = "3DSBTWHVIC6KVCKI"; // 请求data - Map data = new HashMap<>(); - data.put("OperatorID", operatorId); - data.put("OperatorSecret", operatorSecret); - String dataJson = JSONUtil.toJsonStr(data); + // Map data = new HashMap<>(); + // data.put("OperatorID", operatorId); + // data.put("OperatorSecret", operatorSecret); + // String dataJson = JSONUtil.toJsonStr(data); - // JSONObject json = new JSONObject(); + JSONObject json = new JSONObject(); // json.put("StationIDs", com.google.common.collect.Lists.newArrayList("1", "2")); - // json.put("StationID", "2"); - // json.put("StartTime", "2023-02-01"); - // json.put("EndTime", "2023-06-01"); + json.put("LastQueryTime", "2023-05-29 10:00:00"); + json.put("PageNo", 1); + json.put("PageSize", 10); - // String dataJson = JSONObject.toJSONString(json); + String dataJson = JSONObject.toJSONString(json); // 加密 byte[] encryptText = Cryptos.aesEncrypt(dataJson.getBytes("UTF-8"), operatorSecret.getBytes(), operatorSecret.getBytes()); @@ -268,17 +270,21 @@ public class SpringBootTestController { // dto.setSeq("0001"); // dto.setSig(sig); // Map map = lianLianService.generateToken(dto); + QueryStationInfoDTO dto = new QueryStationInfoDTO(); + dto.setOperatorId(operatorId); + Map map = lianLianService.query_stations_info(dto); // String data1 = map.get("Data"); - // // 解密data - // String data1 = "JudlP17tnYuQc2zwOzmjJAb9hgghIymefG5v3ZzSOlOzRL6QcXMa5C5dy8acL2ZWEw5DOc0D3G2qSLsqBCZ9ft/8akGVLL0N4keLV9ipS2REJx1dvm1m4l9ONIP9czNeDTxUsS0b1aCkkxgn7OVYD+ch+yLH/3dMATb32aEjggGY31lu/S2vB+f2aO+icJ2EyAkakB8Huowb3ancZVs/sxCFbVZUmUyo6WEyLtfcn3moKwD52CWoECRgK7lUjBs3F8VKcMT/dTeSKEgZM3Z7/wrEzljKL4519XKyL2lYgJ3h/ewFDRZcnTIJAWskfiKnacZF7yZUTYj13h+sI9wrYmgT2ScqDCQVUI40gDnpewU="; + // 解密data + // String data1 = "JudlP17tnYuQc2zwOzmjJAb9hgghIymefG5v3ZzSOlPDh5+bJHIedsYzKMD56tHlmlg6Cb7vG+o6KjMSSpn1fyqBH3UVaEFF7uEc+lOuEc9c1vUzq20vBQ7N3EpDKqVBKjZbOezMsKYaCX7Br8XTsCYT8VCQui/np3cn+phi3VC+0s1coNxBX7xoEDZ7iuPjPoSWL7g3J0uOw2SoGaIdBQG3eTxaZJ5L+vBmuDF0pEXgazTMnuKml1mx1QHkig2F7h/ILT0VEKVXWMmmogYgiBk5ItO0DyzRl+ASb184gOhYGo82GJmWRiXrAXmceCiSNvTGg6aL26imIGKkJNfOx9/9mTqjGvy6kzxvWJ29PBU="; // byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(data1), // operatorSecret.getBytes(), operatorSecret.getBytes()); // String dataStr = new String(plainText, "UTF-8"); // Map resultMap = (Map) JSON.parse(dataStr); + // // String token = resultMap.get("AccessToken"); + // // System.out.println("解密后token:" + token); - // LianLianPushStationInfoDTO dto1 = LianLianPushStationInfoDTO.builder() // .OperatorID("MA1JLFUU8") // .DataSecret("HVicnbRZbhPdIdpF") @@ -322,6 +328,23 @@ public class SpringBootTestController { // String token = JWTUtils.createToken(operatorId, operatorSecret, ttlMillis); // System.out.println(JWTUtils.checkThirdPartyToken(token)); + JSONObject jsonObject1 = new JSONObject(map); + jsonObject1.put("OperatorID", "425010765"); + jsonObject1.put("Data", "Ntu99RpveEOm2VUNq6RpD7OuOPXRbNxMOPmaBl67nkLk0nD/VmhipdSpq/Qfswhe1o55YMT+3Z7e6xe3fiJA3cZcvetxOEUF6sjvKLRq2rU="); + jsonObject1.put("TimeStamp", "20230530090132"); + jsonObject1.put("Seq", "0001"); + jsonObject1.put("Sig", "1568D2D35B245A0205B33D0EF92E7981"); + + String jsonString = JSONObject.toJSONString(jsonObject1); + + String result = HttpUtils.sendPostContentType("http://localhost:8080/LianLian/v1/query_stations_info", jsonString, "application/json"); + JSONObject object = JSONObject.parseObject(result); + String data1 = (String) object.get("data"); + // 解密data + byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(data1), + operatorSecret.getBytes(), operatorSecret.getBytes()); + String dataStr = new String(plainText, "UTF-8"); + Map resultMap = (Map) JSON.parse(dataStr); } diff --git a/jsowell-common/src/main/java/com/jsowell/common/util/http/HttpUtils.java b/jsowell-common/src/main/java/com/jsowell/common/util/http/HttpUtils.java index 279afdb69..57ae0dc9d 100644 --- a/jsowell-common/src/main/java/com/jsowell/common/util/http/HttpUtils.java +++ b/jsowell-common/src/main/java/com/jsowell/common/util/http/HttpUtils.java @@ -172,6 +172,7 @@ public class HttpUtils { conn.setRequestProperty("connection", "Keep-Alive"); conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); conn.setRequestProperty("Accept-Charset", "utf-8"); + // conn.setRequestProperty("Authorization", "eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI0MjUwMTA3NjUiLCJpYXQiOjE2ODU0MjM3ODMsInN1YiI6IjNEU0JUV0hWSUM2S1ZDS0kiLCJleHAiOjY4Njk0MjM3ODN9.nU-6QNNBp0dcz65_lT-yVAoESZFUHmOwZpoqsKVNspQ"); conn.setRequestProperty("Content-Type", contentType); conn.setDoOutput(true); conn.setDoInput(true); diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/impl/LianLianServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/impl/LianLianServiceImpl.java index bd9baa23d..3de1e1e2d 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/impl/LianLianServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/impl/LianLianServiceImpl.java @@ -269,17 +269,21 @@ public class LianLianServiceImpl implements LianLianService { resultList.add(stationInfo); } - - LianLianPageResponse pageResponse = LianLianPageResponse.builder() - .PageNo(pageInfo.getPageNum()) - .PageCount(pageInfo.getPages()) - .ItemSize(resultList.size()) - .list(resultList) - .build(); + Map map = new LinkedHashMap<>(); + map.put("PageNo", pageInfo.getPageNum()); + map.put("PageCount", pageInfo.getPages()); + map.put("ItemSize", resultList.size()); + map.put("StationInfos", resultList); + // LianLianPageResponse pageResponse = LianLianPageResponse.builder() + // .PageNo(pageInfo.getPageNum()) + // .PageCount(pageInfo.getPages()) + // .ItemSize(resultList.size()) + // .list(resultList) + // .build(); // 加密 Map resultMap = Maps.newLinkedHashMap(); // 加密数据 - byte[] encryptText = Cryptos.aesEncrypt(JSONObject.toJSONString(pageResponse).getBytes(), + byte[] encryptText = Cryptos.aesEncrypt(JSONObject.toJSONString(map).getBytes(), configInfo.getOperatorSecret().getBytes(), configInfo.getDataSecretIv().getBytes()); String encryptData = Encodes.encodeBase64(encryptText); @@ -361,16 +365,19 @@ public class LianLianServiceImpl implements LianLianService { int total = StationStatusInfos.size(); int pages = PageUtil.totalPage(total, pageSize); - LianLianPageResponse response = LianLianPageResponse.builder() - .PageCount(pages) - .PageNo(pageNum) - .list(collect) - .ItemSize(total) - .build(); + Map map = new LinkedHashMap<>(); + map.put("Total", total); + map.put("StationStatusInfos", collect); + // LianLianPageResponse response = LianLianPageResponse.builder() + // .PageCount(pages) + // .PageNo(pageNum) + // .list(collect) + // .ItemSize(total) + // .build(); // 加密 Map resultMap = Maps.newLinkedHashMap(); // 加密数据 - byte[] encryptText = Cryptos.aesEncrypt(JSONObject.toJSONString(response).getBytes(), + byte[] encryptText = Cryptos.aesEncrypt(JSONObject.toJSONString(map).getBytes(), configInfo.getOperatorSecret().getBytes(), configInfo.getDataSecretIv().getBytes()); String encryptData = Encodes.encodeBase64(encryptText);