HttpClientTest.java
13.1 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
package com.erry.iclear.dateInterface;
import com.arronlong.httpclientutil.HttpClientUtil;
import com.arronlong.httpclientutil.builder.HCB;
import com.arronlong.httpclientutil.common.HttpConfig;
import com.arronlong.httpclientutil.common.HttpHeader;
import com.arronlong.httpclientutil.common.HttpResult;
import com.arronlong.httpclientutil.common.SSLs;
import com.arronlong.httpclientutil.exception.HttpProcessException;
import com.erry.iclear.dateInterface.api.request.Basfc;
import com.erry.iclear.dateInterface.api.request.BasfcDetail;
import com.erry.iclear.dateInterface.api.request.Mawb;
import com.erry.iclear.dateInterface.api.request.MawbDetail;
import com.erry.iclear.dateInterface.util.SHA256Util;
import com.google.gson.Gson;
import org.apache.http.client.HttpClient;
import org.apache.http.Header;
import java.io.FileNotFoundException;
import java.math.BigDecimal;
import java.util.*;
public class HttpClientTest {
public static void main(String[] args) throws HttpProcessException, FileNotFoundException {
// System.out.println(HttpClientUtil.get(HttpConfig.custom().url("https://40.73.78.157:8780/system/healthCheck")));
//System.out.println(HttpClientUtil.post(HttpConfig.custom().url("https://40.73.78.157:8780/customs/sendMawbBasf")));
//String masbJson ="{\"ieFlag\":\"I\",\"type\":\" 0\",\"agentCode\":\"1111980005\",\"agentName\":\"联邦快递\",\"billNo\":\"774597567332\",\"contrNo\":\"3006635555/3006636664\",\"customMaster\":\"0207\",\"cutMode\":\"1\",\"declTrnRel\":\"0\",\"distinatePort\":\"DEU000\",\"ediId\":\"1\",\"feeCurr\":\"EUR\",\"feeMark\":\"3\",\"feeRate\":110.9,\"grossWet\":4.6,\"iePort\":\"0207\",\"insurCurr\":\"EUR\",\"insurMark\":\"\",\"insurRate\":0.74,\"netWt\":32,\"ownerCode\":\"9112011660\",\"ownerName\":\"西门子电气传动有限公司\",\"packNo\":1,\"tradeCountry\":\"USA\",\"tradeMode\":\"0110\",\"tradeCode\":\"9112011660\",\"trafMode\":\"5\",\"tradeName\":\"西门子电气传动有限公司\",\"transMode\":\"1\",\"wrapType\":\"23\",\"tradeCodeScc\":\"91120116600587482L\",\"ownerCodeScc\":\"91120116600587482L\",\"tradeAreaCode\":\"DEU\",\"entyPortCode\":\"110101\",\"goodsPlace\":\"\",\"declareName\":\"Jimmy shen\",\"overseasConsigneeEname\":\"PRYSMIAN KABEL UND SYSTEME GMBH\",\"mawbDetailList\":[{\"detailId\":\"495\",\"classMark\":\"\",\"codeTS\":\"8504409999\",\"declPrice\":3365,\"declTotal\":3365,\"dutyMode\":\"1\",\"exgNo\":\"\",\"exgVersion\":\"\",\"firstUnit\":\"007\",\"firstQty\":1,\"originCountry\":\"CHN\",\"secondUnit\":\"035\",\"secondQty\":1,\"tradeCurr\":\"EUR\",\"useTo\":\"03\",\"destinationCountry\":\"DEU\",\"ciqCode\":\"\",\"destCode\":\"110102\",\"districtCode\":\"11010\",\"gno\":1,\"gname\":\"其他未列名静止式变流器\",\"gmodel\":\"4|0|控制电机用|240KW|西门子/SIEMENS|6RA8081-6GV62-0AA0|||\",\"gqty\":1,\"gunit\":\"007\"},{\"detailId\":\"496\",\"classMark\":\"\",\"codeTS\":\"8504409999\",\"declPrice\":9369,\"declTotal\":9369,\"dutyMode\":\"1\",\"exgNo\":\"\",\"exgVersion\":\"\",\"firstUnit\":\"007\",\"firstQty\":3,\"originCountry\":\"CHN\",\"secondUnit\":\"035\",\"secondQty\":1,\"tradeCurr\":\"EUR\",\"useTo\":\"03\",\"destinationCountry\":\"DEU\",\"ciqCode\":\"\",\"destCode\":\"110102\",\"districtCode\":\"11010\",\"gno\":2,\"gname\":\"其他未列名静止式变流器\",\"gmodel\":\"4|0|控制电机用|36KW|西门子/SIEMENS|6RA8081-6GV62-0BB0|||\",\"gqty\":3,\"gunit\":\"007\"}]}";
String basfJson = "{\"consignmentCode\":\"287598603852\",\"consignmentId\":221121505595,\"consType\":\"C\",\"sender\":\"巴斯夫(中国)有限公司\",\"shipperCustomsCode\":\"3122241734\",\"shipperSCC\":\"913100007109210071\",\"operateUnitName\":\"巴斯夫(中国)有限公司\",\"operateUnitCode\":\"3122241734\",\"operateSCC\":\"913100007109210071\",\"EANNo\":\"\",\"consignmentList\":[{\"consignmentDetailId\":83013414,\"skuCode\":\"3909500000\",\"skuName\":\"热塑性聚氨酯弹性体\",\"model\":\"品名:热塑性聚氨酯弹性体|品牌类型:0|出口享惠情况:0|外观[形状;透明度;颜色等]:热塑性聚氨酯99-100%|成分含量:多元醇70-90%,异氰酸酯0-20%,其他二元醇0-10%|单体单元的种类和比例:非塑料再生料|底料来源[再生料、瓶片料、新料、副牌料]:DEVELOPMENT|品牌[中文或外文名称]:ELASTOLLAN|型号:见合同|签约日期:制造聚氨酯塑料用|用途:|GTIN:|CAS:|其他[非必报要素,请根据实际情况填报]:|\",\"knockdownNumber\":40.0000,\"knockdownUnit\":\"035\",\"qtyLegalFirst\":40.0000,\"unitLegalFirst\":\"NULL\",\"qtyLegalSecond\":40.0000,\"unitLegalSecond\":\"NULL\",\"declaredAmount\":1200.0,\"currency\":\"USD\",\"declaredWeight\":40.0000}]}";
//String basfJson = "{\"consignmentCode\":\"796565081410\",\"consignmentId\":221112408858,\"consType\":\"C\",\"sender\":\"巴斯夫新材料有限公司\",\"shipperCustomsCode\":\"3122240631\",\"shipperSCC\":\"91310115607299125B\",\"operateUnitName\":\"巴斯夫新材料有限公司\",\"operateUnitCode\":\"3122240631\",\"operateSCC\":\"91310115607299125B\",\"EANNo\":\"\",\"consignmentList\":[{\"consignmentDetailId\":30787356,\"skuCode\":\"3402900090\",\"skuName\":\"表面活性剂制品 683 LT\",\"model\":\"1|0|表面活性剂,用于化工技术工业的原材料|非零售包装|异丙基苯磺酸钠5-15%,低聚D-吡喃葡糖C10-16-烷基苷25-50%,水40-60%|巴斯夫Glucopon|683 LT\",\"knockdownNumber\":0.5000,\"knockdownUnit\":\"035\",\"qtyLegalFirst\":0.5000,\"unitLegalFirst\":\"035\",\"qtyLegalSecond\":null,\"unitLegalSecond\":null,\"declaredAmount\":2.5,\"currency\":\"USD\",\"declaredWeight\":0.5000}]}";
//String basfJson = "{\"consignmentCode\":\"794650129680\",\"consignmentId\":220062201115,\"consType\":\"C\",\"sender\":\"巴斯夫植物保护(江苏)有限公司\",\"shipperCustomsCode\":\"3206946236\",\"shipperSCC\":\"913206230645013066\",\"operateUnitName\":\"巴斯夫植物保护(江苏)有限公司\",\"operateUnitCode\":\"3206946236\",\"operateSCC\":\"913206230645013066\",\"EANNo\":\"\",\"consignmentList\":[{\"consignmentDetailId\":50285469,\"skuCode\":\"2926909090\",\"skuName\":\"丙腈水溶液\",\"model\":\"0|0|||\",\"knockdownNumber\":2.0000,\"knockdownUnit\":\"035\",\"qtyLegalFirst\":2.0000,\"unitLegalFirst\":\"035\",\"qtyLegalSecond\":null,\"unitLegalSecond\":null,\"declaredAmount\":23.0000,\"currency\":\"USD\",\"declaredWeight\":2.0000}]}";
String timeStamp = "1638254683000";
//String timeStamp = "1624263798669";
System.out.println(new Date(Long.valueOf(timeStamp)));
//String token = SHA256Util.getSHA256String("IDE" + "iClearExport" + "b92131f03f19a348" + timeStamp);
String token = SHA256Util.getSHA256String("BASF" + "iClearExportC" + "6db193cb4165a71b" + timeStamp);
System.out.println(token);
Header[] headers = HttpHeader.custom()
.other("Content-Type", "application/json")
//.other("Appid", "IDE")
//.other("appKey", "iClearExport")
.other("Appid", "BASF")
.other("appKey", "iClearExportC")
.other("TimeStamp", timeStamp)
.other("token", token)
.build();
HCB hcb = HCB.custom()
.timeout(20000)
.pool(100, 10)
.sslpv(SSLs.SSLProtocolVersion.TLSv1_2)
.ssl()
.retry(3);
//String url = "https://40.73.78.157:8780/customs/sendMawb";
String url = "https://127.0.0.1:8780/basf/sendMawbBasf";
HttpConfig config = HttpConfig.custom()
.headers(headers)
.url(url)
.encoding("utf-8")
.client(hcb.build())
// .json(new Gson().toJson(createMawb()));
.json(basfJson);
System.out.println("111111111111111111111111111111111111111111111");
System.out.println(HttpClientUtil.post(config));
}
public static Mawb createMawb() {
MawbDetail d1 = new MawbDetail();
d1.setDetailId("202105210784-1");
d1.setClassMark("");
d1.setCodeTS("69125472");
d1.setDeclPrice(BigDecimal.valueOf(111.123));
d1.setDeclTotal(BigDecimal.valueOf(788));
d1.setDutyMode("1");
d1.setExgNo("");
d1.setExgVersion("");
d1.setFirstUnit("035");
d1.setFirstQty(11);
d1.setGunit("007");
d1.setGmodel("商品规格、型号");
d1.setGname("餐桌");
d1.setGno("1");
d1.setGqty(BigDecimal.valueOf(1.88));
d1.setOriginCountry("US");
d1.setSecondUnit("007");
d1.setSecondQty(2);
d1.setTradeCurr("USD");
d1.setUseTo("");
d1.setWorkUsd(null);
d1.setDestinationCountry("CN");
d1.setCiqCode("");
d1.setDeclGoodsEname("");
d1.setDestCode("");
d1.setDistrictCode("4408W");
MawbDetail d2 = new MawbDetail();
d2.setDetailId("202105210784-2");
d2.setClassMark("");
d2.setCodeTS("69125472");
d2.setDeclPrice(BigDecimal.valueOf(45.72));
d2.setDeclTotal(BigDecimal.valueOf(33));
d2.setDutyMode("1");
d2.setExgNo("");
d2.setExgVersion("");
d2.setFirstUnit("035");
d2.setFirstQty(11);
d2.setGunit("007");
d2.setGmodel("商品规格、型号");
d2.setGname("餐桌");
d2.setGno("2");
d2.setGqty(BigDecimal.valueOf(22.88));
d2.setOriginCountry("US");
d2.setSecondUnit("007");
d2.setSecondQty(3);
d2.setTradeCurr("USD");
d2.setUseTo("");
d2.setWorkUsd(null);
d2.setDestinationCountry("CN");
d2.setCiqCode("");
d2.setDeclGoodsEname("");
d2.setDestCode("");
d2.setDistrictCode("4408W");
List<MawbDetail> mawbDetailList = new ArrayList<MawbDetail>();
mawbDetailList.add(d1);
mawbDetailList.add(d2);
Mawb mawb = new Mawb();
mawb.setIeFlag("E");
mawb.setType("EX");
mawb.setAgentCode("1111980005");
mawb.setAgentName("联邦快递(中国)有限公司");
mawb.setBillNo("202105210784");
mawb.setContrNo("NO.565733");
mawb.setCustomMaster("0101");
mawb.setCutMode("101");
mawb.setDeclTrnRel("0");
mawb.setDistinatePort("ASM000");
mawb.setEdiId("001");
mawb.setEntryId("25512456");
mawb.setFeeCurr("USD");
mawb.setFeeMark("3");
mawb.setFeeRate(BigDecimal.valueOf(100.58));
mawb.setGrossWet(BigDecimal.valueOf(500));
mawb.setIePort("0101");
mawb.setInputerName("");
mawb.setInsurCurr("MOP");
mawb.setInsurMark("3");
mawb.setInsurRate(BigDecimal.valueOf(23.44));
mawb.setManualNo("备案号");
mawb.setNetWt(BigDecimal.valueOf(80));
mawb.setOtherCurr("USD");
mawb.setOtherRate(BigDecimal.valueOf(10));
mawb.setOtherMark("");
mawb.setOwnerCode("Z321654987");
mawb.setOwnerName("上海保险");
mawb.setPackNo(1);
mawb.setPreEntryId("");
mawb.setTradeCountry("US");
mawb.setTradeMode("110");
mawb.setTradeCode("Z321654987");
mawb.setTrafMode("1");
mawb.setTradeName("上海铢怡国际货物运输代理有限公司");
mawb.setTransMode("3");
mawb.setWrapType("22");
mawb.setTradeCodeScc("A74125896321456987");
mawb.setOwnerCodeScc("A74125896321456987");
mawb.setTradeAreaCode("US");
mawb.setMarkNo("N/M");
mawb.setEntyPortCode("310302");
mawb.setGoodsPlace("");
mawb.setDeclareName("张安");
mawb.setOverseasConsignorCode("Z785421");
mawb.setOverseasConsigneeCode("Z785421");
mawb.setOverseasConsigneeEname("出口时必填收件人公司名(原)");
mawb.setMawbDetailList(mawbDetailList);
return mawb;
}
private Basfc createNewBasf(){
List<BasfcDetail> basfcDetailList = new ArrayList<>();
BasfcDetail basfcDetail = new BasfcDetail();
basfcDetail.setConsignmentDetailId(123L);
basfcDetail.setSkuCode("29262000");
basfcDetail.setSkuName("210908001测试");
basfcDetail.setModel("0|0|1|1||||||||");
basfcDetail.setUnitLegalFirst("035");
basfcDetail.setQtyLegalFirst(BigDecimal.valueOf(1));
basfcDetail.setKnockdownUnit("035");
basfcDetail.setKnockdownNumber(BigDecimal.valueOf(1));
basfcDetail.setUnitLegalSecond("007");
basfcDetail.setQtyLegalSecond(BigDecimal.valueOf(1));
basfcDetail.setDeclaredAmount(BigDecimal.valueOf(1));
basfcDetail.setCurrency("USD");
basfcDetail.setDeclaredWeight(BigDecimal.valueOf(1));
basfcDetailList.add(basfcDetail);
Basfc basfc = new Basfc();
basfc.setConsignmentCode("210908003");
basfc.setConsignmentId(1L);
basfc.setConsType("C");
basfc.setSender("天津知行博创科技有限公司");
basfc.setShipperCustomsCode("11119608L9");
basfc.setShipperSCC("123456789012345678");
basfc.setOperateUnitName("天津丰铭佳业科贸有限公司");
basfc.setOperateUnitCode("");
basfc.setOperateSCC("");
basfc.setEanNo("1");
basfc.setConsignmentList(basfcDetailList);
return basfc;
}
}