Jiaqi.xu

Merge branch 'master' of E:\iClear-api with conflicts.

1 package com.erry.iclear.dateInterface; 1 package com.erry.iclear.dateInterface;
2 2
3 +
4 +import com.alibaba.fastjson.JSONObject;
5 +import com.arronlong.httpclientutil.HttpClientUtil;
6 +import com.arronlong.httpclientutil.builder.HCB;
7 +import com.arronlong.httpclientutil.common.HttpConfig;
8 +import com.arronlong.httpclientutil.common.HttpHeader;
9 +import com.arronlong.httpclientutil.common.SSLs;
10 +import com.arronlong.httpclientutil.exception.HttpProcessException;
11 +import com.erry.iclear.dateInterface.api.request.ConsignmentCode;
12 +import com.erry.iclear.dateInterface.util.SHA256Util;
13 +import com.google.gson.Gson;
14 +import org.apache.http.Header;
3 import org.junit.Test; 15 import org.junit.Test;
4 import org.junit.runner.RunWith; 16 import org.junit.runner.RunWith;
5 import org.springframework.boot.test.context.SpringBootTest; 17 import org.springframework.boot.test.context.SpringBootTest;
...@@ -7,14 +19,74 @@ import org.springframework.test.context.ActiveProfiles; ...@@ -7,14 +19,74 @@ import org.springframework.test.context.ActiveProfiles;
7 import org.springframework.test.context.junit4.SpringRunner; 19 import org.springframework.test.context.junit4.SpringRunner;
8 import org.springframework.test.context.web.WebAppConfiguration; 20 import org.springframework.test.context.web.WebAppConfiguration;
9 21
22 +import java.util.*;
23 +
10 @RunWith(SpringRunner.class) 24 @RunWith(SpringRunner.class)
11 @SpringBootTest 25 @SpringBootTest
12 @WebAppConfiguration 26 @WebAppConfiguration
13 @ActiveProfiles("dev") 27 @ActiveProfiles("dev")
14 class IClearApiApplicationTests { 28 class IClearApiApplicationTests {
15 29
16 - @Test 30 +
17 - public void contextLoads() { 31 + public static void main(String[] args) throws HttpProcessException {
32 + Gson gson = new Gson();
33 + String str = "{\"consignmentCode\":\"" +
34 + "201907105," +
35 + "202018092," +
36 + "202108026," +
37 + "192770847591," +
38 + "201907099," +
39 + "202017062," +
40 + "770194186721," +
41 + "201907109," +
42 + "201907092," +
43 + "201907096," +
44 + "201907103," +
45 + "201907093," +
46 + "774439601," +
47 + "774439602," +
48 + "201907097," +
49 + "281382086345," +
50 + "202108100," +
51 + "192770847477," +
52 + "192770847478," +
53 + "149148215190\"}";
54 +
55 +// String str = "{\"consignmentCode\":\"110000011\"}";
56 + String timeStamp = "1634697153697";
57 + //String timeStamp = "1624263798669";
58 + System.out.println(new Date(Long.valueOf(timeStamp)));
59 + //String token = SHA256Util.getSHA256String("IDE" + "iClearExport" + "b92131f03f19a348" + timeStamp);
60 + String token = SHA256Util.getSHA256String("BASF" + "iClearExportC" + "6db193cb4165a71b" + timeStamp);
61 + System.out.println(token);
62 +
63 + Header[] headers = HttpHeader.custom()
64 + .other("Content-Type", "application/json")
65 + .other("Appid", "BASF")
66 + .other("appKey", "iClearExportC")
67 + .other("TimeStamp", timeStamp)
68 + .other("token", "2D9F60B9ACE7A559CF1C21F34D543522F3520C7FF0F4A94FEC5A9700BC8589B8")
69 + .build();
70 +
71 + HCB hcb = HCB.custom()
72 + .timeout(20000)
73 + .pool(100, 10)
74 + .sslpv(SSLs.SSLProtocolVersion.TLSv1_2)
75 + .ssl()
76 + .retry(3);
77 +
78 + //String url = "https://40.73.78.157:8780/customs/sendMawb";
79 + String url = "https://40.73.78.157:8780/basf/selectDecListBasf";
80 + //String url = "https://40.73.78.157:8780/basf/selectChmListBasf";
81 +
82 + HttpConfig config = HttpConfig.custom()
83 + .headers(headers)
84 + .url(url)
85 + .encoding("utf-8")
86 + .client(hcb.build())
87 +// .json(new Gson().toJson(createMawb()));
88 + .json(str);
89 + System.out.println(HttpClientUtil.post(config));
18 } 90 }
19 91
20 } 92 }
......
...@@ -7,6 +7,8 @@ import com.erry.iclear.dateInterface.util.HttpUtils; ...@@ -7,6 +7,8 @@ import com.erry.iclear.dateInterface.util.HttpUtils;
7 import com.erry.iclear.dateInterface.util.JsonToJava; 7 import com.erry.iclear.dateInterface.util.JsonToJava;
8 import org.junit.Test; 8 import org.junit.Test;
9 import org.springframework.beans.factory.annotation.Value; 9 import org.springframework.beans.factory.annotation.Value;
10 +
11 +import java.text.SimpleDateFormat;
10 import java.util.HashMap; 12 import java.util.HashMap;
11 import java.util.Map; 13 import java.util.Map;
12 14
...@@ -50,7 +52,7 @@ public class TokenTest extends IClearApiApplicationTests { ...@@ -50,7 +52,7 @@ public class TokenTest extends IClearApiApplicationTests {
50 System.out.println(rs); 52 System.out.println(rs);
51 } 53 }
52 54
53 - public static void main(String[] args) throws Exception{ 55 + /* public static void main(String[] args) throws Exception{
54 String url = "https://apictm.iclrccd-fedex.com/login"; 56 String url = "https://apictm.iclrccd-fedex.com/login";
55 Map<String,String> map = new HashMap<String,String>(); 57 Map<String,String> map = new HashMap<String,String>();
56 map.put("username", "iclear_export_prod"); 58 map.put("username", "iclear_export_prod");
...@@ -66,7 +68,9 @@ public class TokenTest extends IClearApiApplicationTests { ...@@ -66,7 +68,9 @@ public class TokenTest extends IClearApiApplicationTests {
66 map.put("token","eyJhbGciOiJSUzI1NiJ9.eyJleHBpcmVBdCI6MTY0Njg4MDc3NzY0NSwidXNlcklkIjoiaWNsZWFyX2V4cG9ydF9wcm9kIn0.fey8YVWL0wcxvCUMQR-ePyCXIh9AdoztIixtcYgGjtaUCxO3VVf9Jmut3ZVVelxigvTDzv-Iz097R2fgBSOBzStICTZGqxmRV7Av6R41HCTTQ8BL6aSPle2QszSkTt5T95cYiFYSv9CHmxSKBU_MrJk5WhCJb5XOAmWmdV94McFWTBi1oTIjVfgiczu0pzgA1berR1lfUIEDVEUxUoduVARzwUcDDljq0pf-rPhpAj-Iqbhc4fint4Th-BlO6Rg4ZWYB08-3Id9krl92TMJJ_rXMrhbna6833r8PcpdbXIFPkuopbrv9GL1Ds_vWL7Sd5BTSYtMRn2ku0GhAP6GNPg"); 68 map.put("token","eyJhbGciOiJSUzI1NiJ9.eyJleHBpcmVBdCI6MTY0Njg4MDc3NzY0NSwidXNlcklkIjoiaWNsZWFyX2V4cG9ydF9wcm9kIn0.fey8YVWL0wcxvCUMQR-ePyCXIh9AdoztIixtcYgGjtaUCxO3VVf9Jmut3ZVVelxigvTDzv-Iz097R2fgBSOBzStICTZGqxmRV7Av6R41HCTTQ8BL6aSPle2QszSkTt5T95cYiFYSv9CHmxSKBU_MrJk5WhCJb5XOAmWmdV94McFWTBi1oTIjVfgiczu0pzgA1berR1lfUIEDVEUxUoduVARzwUcDDljq0pf-rPhpAj-Iqbhc4fint4Th-BlO6Rg4ZWYB08-3Id9krl92TMJJ_rXMrhbna6833r8PcpdbXIFPkuopbrv9GL1Ds_vWL7Sd5BTSYtMRn2ku0GhAP6GNPg");
67 String rs = httpUtils.doPost(url,map); 69 String rs = httpUtils.doPost(url,map);
68 System.out.println(rs); 70 System.out.println(rs);
69 - } 71 + }*/
70 72
71 private static HttpUtils httpUtils = new HttpUtils(); 73 private static HttpUtils httpUtils = new HttpUtils();
74 +
75 +
72 } 76 }
......