diff --git a/shapelight-admin/pom.xml b/shapelight-admin/pom.xml index d06f150..74dab09 100644 --- a/shapelight-admin/pom.xml +++ b/shapelight-admin/pom.xml @@ -181,6 +181,12 @@ + + cn.hutool + hutool-all + 5.7.16 + + diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/xian/service/XaApi.java b/shapelight-admin/src/main/java/net/shapelight/modules/xian/service/XaApi.java index 5d45c6a..4290f38 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/xian/service/XaApi.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/xian/service/XaApi.java @@ -1,5 +1,6 @@ package net.shapelight.modules.xian.service; +import cn.hutool.http.HttpUtil; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; @@ -95,7 +96,7 @@ public class XaApi { * @param secre * @return */ - public static String httpPOSTJson(String url, String json, String serviceId, String serviceValue, String appid, String secre, String tranId) { + public static String httpPOSTJsonOld(String url, String json, String serviceId, String serviceValue, String appid, String secre, String tranId) { String data = ""; HttpURLConnection conn = null; try { @@ -169,6 +170,30 @@ public class XaApi { } + public static String httpPOSTJson(String url, String json, String serviceId, String serviceValue, String appid, String secre, String tranId) { +// String data = ""; + + String currdate = new SimpleDateFormat("yyyyMMdd").format(new Date()); + String token = XaUtils.md5(appid + secre + currdate + json.replaceAll("\r\n", "")); + Map map=new HashMap(); + map.put("appid",appid); + map.put("token",token); + map.put("tranId",tranId);//可固定这么写 + map.put("serviceId",serviceId); + map.put("serviceValue",serviceValue); + map.put("versionCode",""); + map.put("User-Agent","Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)"); + String body = HttpUtil.createPost(url).headerMap(map, true).body(json).execute().body(); + try{ + body = URLDecoder.decode(body, "UTF-8"); + return body; + }catch (UnsupportedEncodingException e){ + log.error("解码返回结果失败:原始数据:"+body); + return ""; + } + } + + public static void syncRoom() { String appid = "1297164778041095"; String appsecret = "22971647780410956329716477804109";