DownloadTests.java
2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package cn.com.glsx.test;
import cn.com.glsx.admin.modules.model.param.TrackInfoBo;
import cn.com.glsx.admin.modules.utils.GopUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.glsx.plat.common.utils.HttpUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import java.util.TreeMap;
@Slf4j
public class DownloadTests {
// public static void main(String[] args) {
// String url = "https://eshield.didihu.com.cn/trialdrive/trialdrivereport/export?year=2021&month=10";
// TreeMap<String, Object> tparams = new TreeMap<>();
// tparams.put("Authorization", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwYXlsb2FkTWFwIjp7ImJlbG9uZyI6IjEiLCJhcHBsaWNhdGlvbiI6Imdsc3gtbmUtc2hpZWxkLXVzZXJjZW50ZXIiLCJjbGF6eiI6ImNvbS5nbHN4LnBsYXQuand0LmJhc2UuQ29tSnd0VXNlciIsInVzZXJJZCI6IjEiLCJhY2NvdW50IjoiYWRtaW4iLCJ0ZW5hbnQiOiIxIiwiand0SWQiOiJnbHN4LW5lLXNoaWVsZC11c2VyY2VudGVyOmY3OTNlMDliLThmMzktNGNiMi1iMGZlLWMwNGI4NTFkOWNlY19KV1QtU0VTU0lPTi0xIn0sInN1YiI6ImFkbWluIiwiZXhwIjoxNjM2MTIwMTYzLCJpYXQiOjE2MzYwOTEzNjMsImp0aSI6Imdsc3gtbmUtc2hpZWxkLXVzZXJjZW50ZXI6Zjc5M2UwOWItOGYzOS00Y2IyLWIwZmUtYzA0Yjg1MWQ5Y2VjX0pXVC1TRVNTSU9OLTEifQ.bJQoooeAoY1axhGGHUY5PRL-0evi2A6HzCzAcqXrR8k");
// String result = HttpUtils.get(url, tparams);
// JSONObject resultObj = JSONObject.parseObject(result);
// }
public static void main(String[] args) {
String url = "http://e-shield.didihu.com.cn/otsi/api/device/getInfoBySn";
String appKet = "XWAA";
String appSecret = "0ABABBFB901DDAB831B0EBCA17A602E4";
TreeMap<String, Object> tparams = new TreeMap<>();
tparams.put("appKey", appKet);
tparams.put("sn", "1710202944");
//加密得到sign
String sign = GopUtil.sign(tparams, appSecret);
tparams.put("sign", sign);
String result = HttpUtils.get(url, tparams);
System.out.println("result = " + result);
JSONObject resultObj = JSONObject.parseObject(result);
if (resultObj == null) {
System.out.println("remote getInfoBysn result is null");
}
String returnCode = resultObj.getString("returnCode");
String message = resultObj.getString("message");
if (StringUtils.isBlank(returnCode) || !"0".equals(returnCode)) {
System.out.println("remote getInfoBysn fail! returnCode:" + returnCode + "; message:" + message);
}
String data = resultObj.getString("data");
if (StringUtils.isBlank(data)) {
System.out.println(data);
return;
}
TrackInfoBo trackInfoBo = JSONObject.parseObject(data, TrackInfoBo.class);
System.out.println("trackInfoBo = " + JSON.toJSONString(trackInfoBo));
}
}