wei.zhou

提交代码

...@@ -85,7 +85,11 @@ ...@@ -85,7 +85,11 @@
85 </dependency> 85 </dependency>
86 86
87 87
88 - 88 + <dependency>
89 + <groupId>com.arronlong</groupId>
90 + <artifactId>httpclientutil</artifactId>
91 + <version>1.0.4</version>
92 + </dependency>
89 </dependencies> 93 </dependencies>
90 94
91 <profiles> 95 <profiles>
......
1 +
2 +
3 +打包命令
4 +mvn clean package -Dmaven.test.skip=true -Pdev
5 +
6 +
7 +
8 +启动命令
9 +java -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=128m -Xms1024m -Xmx1024m -Xmn256m -Xss256k -XX:SurvivorRatio=5 -XX:+UseConcMarkSweepGC -jar jar包路径
10 +
11 +jstat -gc pid
12 +jmap -heap pid
...@@ -37,6 +37,7 @@ public class AppInfoService { ...@@ -37,6 +37,7 @@ public class AppInfoService {
37 */ 37 */
38 public void initAppInfo() { 38 public void initAppInfo() {
39 try { 39 try {
40 + Constant.appIdSecurityCache.clear();
40 List<AppInfo> appInfoList = this.getAllEnableAppInfo(); 41 List<AppInfo> appInfoList = this.getAllEnableAppInfo();
41 for (AppInfo appInfo : appInfoList) { 42 for (AppInfo appInfo : appInfoList) {
42 HashMap<String, String> appkeyMap = new HashMap<String, String>(); 43 HashMap<String, String> appkeyMap = new HashMap<String, String>();
......
...@@ -34,9 +34,9 @@ public class ChmCarryPortService { ...@@ -34,9 +34,9 @@ public class ChmCarryPortService {
34 */ 34 */
35 public void initChmCarryPort() { 35 public void initChmCarryPort() {
36 try { 36 try {
37 + Constant.chmCarryPortCache.clear();
37 List<ChmCarryPort> appInfoList = this.findAllChmCarryPort(); 38 List<ChmCarryPort> appInfoList = this.findAllChmCarryPort();
38 for (ChmCarryPort chmCarryPort : appInfoList) { 39 for (ChmCarryPort chmCarryPort : appInfoList) {
39 -
40 Constant.chmCarryPortCache.put(chmCarryPort.getPcCode(), chmCarryPort); 40 Constant.chmCarryPortCache.put(chmCarryPort.getPcCode(), chmCarryPort);
41 } 41 }
42 } catch (Exception e) { 42 } catch (Exception e) {
......
...@@ -39,6 +39,7 @@ public class DictionaryEntriesService { ...@@ -39,6 +39,7 @@ public class DictionaryEntriesService {
39 */ 39 */
40 public void initDictionaryEntries() { 40 public void initDictionaryEntries() {
41 try { 41 try {
42 + Constant.dictionaryEntriesCache.clear();
42 List<DictionaryEntries> dictionaryEntriesList = this.getAllDictionaryEntries(); 43 List<DictionaryEntries> dictionaryEntriesList = this.getAllDictionaryEntries();
43 for (DictionaryEntries dictionaryEntries : dictionaryEntriesList) { 44 for (DictionaryEntries dictionaryEntries : dictionaryEntriesList) {
44 if(Objects.equals(dictionaryEntries.getDictCode(),"ClinchType")){ 45 if(Objects.equals(dictionaryEntries.getDictCode(),"ClinchType")){
......
...@@ -38,6 +38,7 @@ public class DomesticDestinationMappingService { ...@@ -38,6 +38,7 @@ public class DomesticDestinationMappingService {
38 */ 38 */
39 public void initDomesticDestinationMapping() { 39 public void initDomesticDestinationMapping() {
40 try { 40 try {
41 + Constant.domesticDestinationMappingCache.clear();
41 List<DomesticDestinationMapping> domList = this.findAllDomesticDestinationMapping(); 42 List<DomesticDestinationMapping> domList = this.findAllDomesticDestinationMapping();
42 for (DomesticDestinationMapping dom : domList) { 43 for (DomesticDestinationMapping dom : domList) {
43 Constant.domesticDestinationMappingCache.put(dom.getDistrictCode(), dom); 44 Constant.domesticDestinationMappingCache.put(dom.getDistrictCode(), dom);
......
...@@ -41,6 +41,7 @@ public class OrigplacecodeMappingService { ...@@ -41,6 +41,7 @@ public class OrigplacecodeMappingService {
41 */ 41 */
42 public void initOrigplacecodeMapping() { 42 public void initOrigplacecodeMapping() {
43 try { 43 try {
44 + Constant.origplacecodeMappingCache.clear();
44 List<OrigplacecodeMapping> domList = this.findAllOrigplacecodeMapping(); 45 List<OrigplacecodeMapping> domList = this.findAllOrigplacecodeMapping();
45 for (OrigplacecodeMapping dom : domList) { 46 for (OrigplacecodeMapping dom : domList) {
46 Constant.origplacecodeMappingCache.put(dom.getOrigplaceCode(), dom); 47 Constant.origplacecodeMappingCache.put(dom.getOrigplaceCode(), dom);
......
1 +package com.erry.iclear.dateInterface;
2 +
3 +import com.arronlong.httpclientutil.HttpClientUtil;
4 +import com.arronlong.httpclientutil.builder.HCB;
5 +import com.arronlong.httpclientutil.common.HttpConfig;
6 +import com.arronlong.httpclientutil.common.HttpHeader;
7 +import com.arronlong.httpclientutil.common.HttpResult;
8 +import com.arronlong.httpclientutil.common.SSLs;
9 +import com.arronlong.httpclientutil.exception.HttpProcessException;
10 +import com.erry.iclear.dateInterface.api.request.Mawb;
11 +import com.erry.iclear.dateInterface.api.request.MawbDetail;
12 +import com.erry.iclear.dateInterface.util.SHA256Util;
13 +import com.google.gson.Gson;
14 +import org.apache.http.client.HttpClient;
15 +import org.apache.http.Header;
16 +import java.io.FileNotFoundException;
17 +import java.math.BigDecimal;
18 +import java.util.*;
19 +
20 +public class HttpClientTest {
21 + public static void main(String[] args) throws HttpProcessException, FileNotFoundException {
22 +// System.out.println(HttpClientUtil.get(HttpConfig.custom().url("https://40.73.78.157:8780/system/healthCheck")));
23 +// System.out.println(HttpClientUtil.post(HttpConfig.custom().url("https://40.73.78.157:8780/customs/sendMawb")));
24 +
25 + String timeStamp = "1623920478192";
26 + //String timeStamp = "1624263798669";
27 + System.out.println(new Date(Long.valueOf(timeStamp)));
28 + String token=SHA256Util.getSHA256String("IDE"+"iClearExport"+"b92131f03f19a348"+timeStamp);
29 + System.out.println(token);
30 +
31 +
32 +
33 + Header[] headers = HttpHeader.custom()
34 + .other("Content-Type", "application/json")
35 + .other("Appid", "IDE")
36 + .other("appKey", "iClearExport")
37 + .other("TimeStamp", timeStamp)
38 + .other("token", token)
39 + .build();
40 +
41 + //插件式配置生成HttpClient时所需参数(超时、连接池、ssl、重试)
42 + HCB hcb = HCB.custom()
43 + .timeout(3000) //超时
44 + .pool(100, 10) //启用连接池,每个路由最大创建10个链接,总连接数限制为100个
45 + .sslpv(SSLs.SSLProtocolVersion.TLSv1_2) //设置ssl版本号,默认SSLv3,也可以调用sslpv("TLSv1.2")
46 + .ssl() //https,支持自定义ssl证书路径和密码,ssl(String keyStorePath, String keyStorepass)
47 + .retry(5) //重试5次
48 + ;
49 +
50 + HttpClient client = hcb.build();
51 +
52 + Map<String, Object> map = new HashMap<String, Object>();
53 + map.put("mawb", createMawb());
54 + //map.put("key2", "value2");
55 +
56 +
57 + Mawb mawb = createMawb();
58 +
59 + Gson gson = new Gson();
60 + String request =gson.toJson(mawb);
61 + //插件式配置请求参数(网址、请求参数、编码、client)
62 + String url="https://40.73.78.157:8780/customs/sendMawb";
63 + HttpConfig config = HttpConfig.custom()
64 + .headers(headers) //设置headers,不需要时则无需设置
65 + .url(url) //设置请求的url
66 + //.map(map) //设置请求参数,没有则无需设置
67 + .encoding("utf-8") //设置请求和返回编码,默认就是Charset.defaultCharset()
68 + .client(client) //如果只是简单使用,无需设置,会自动获取默认的一个client对象
69 + //.inenc("utf-8") //设置请求编码,如果请求返回一直,不需要再单独设置
70 + //.inenc("utf-8") //设置返回编码,如果请求返回一直,不需要再单独设置
71 + .json(request) //json方式请求的话,就不用设置map方法,当然二者可以共用。
72 + //.context(HttpCookies.custom().getContext()) //设置cookie,用于完成携带cookie的操作
73 + //.out(new FileOutputStream("保存地址")) //下载的话,设置这个方法,否则不要设置
74 + //.files(new String[]{"d:/1.txt","d:/2.txt"}) //上传的话,传递文件路径,一般还需map配置,设置服务器保存路径
75 + ;
76 +
77 +
78 + //使用方式:
79 + //System.out.println(HttpClientUtil.get(config));
80 + System.out.println(HttpClientUtil.post(config));
81 +
82 + //HttpClientUtil.down(config); //下载,需要调用config.out(fileOutputStream对象)
83 + //HttpClientUtil.upload(config); //上传,需要调用config.files(文件路径数组)
84 +
85 + //如果指向看是否访问正常
86 + //String result3 = HttpClientUtil.head(config); // 返回Http协议号+状态码
87 + //int statusCode = HttpClientUtil.status(config);//返回状态码
88 +
89 + //[新增方法]sendAndGetResp,可以返回原生的HttpResponse对象,
90 + //同时返回常用的几类对象:result、header、StatusLine、StatusCode
91 +// HttpResult respResult = HttpClientUtil.sendAndGetResp(config);
92 +// System.out.println("返回结果:\n"+respResult.getResult());
93 +// System.out.println("返回resp-header:"+respResult.getRespHeaders());//可以遍历
94 +// System.out.println("返回具体resp-header:"+respResult.getHeaders("Date"));
95 +// System.out.println("返回StatusLine对象:"+respResult.getStatusLine());
96 +// System.out.println("返回StatusCode:"+respResult.getStatusCode());
97 +// System.out.println("返回HttpResponse对象)(可自行处理):"+respResult.getResp());
98 +
99 + }
100 +
101 +
102 + public static Mawb createMawb(){
103 +
104 + MawbDetail d1 = new MawbDetail();
105 + d1.setClassMark("");
106 + d1.setCodeTS("69125472");
107 + d1.setDeclPrice(BigDecimal.valueOf(111.123));
108 + d1.setDeclTotal(BigDecimal.valueOf(788));
109 + d1.setDutyMode("1");
110 + d1.setExgNo("");
111 + d1.setExgVersion("");
112 + d1.setFirstUnit("035");
113 + d1.setFirstQty(11);
114 + d1.setGunit("007");
115 + d1.setGmodel("商品规格、型号");
116 + d1.setGname("餐桌");
117 + d1.setGno("1");
118 + d1.setGqty(BigDecimal.valueOf(1.88));
119 + d1.setOriginCountry("US");
120 + d1.setSecondUnit("007");
121 + d1.setSecondQty(2);
122 + d1.setTradeCurr("USD");
123 + d1.setUseTo("");
124 + d1.setWorkUsd(null);
125 + d1.setDestinationCountry("CN");
126 + d1.setCiqCode("");
127 + d1.setDeclGoodsEname("");
128 + d1.setDestCode("");
129 + d1.setDistrictCode("4408W");
130 +
131 +
132 + MawbDetail d2 = new MawbDetail();
133 + d2.setClassMark("");
134 + d2.setCodeTS("69125472");
135 + d2.setDeclPrice(BigDecimal.valueOf(45.72));
136 + d2.setDeclTotal(BigDecimal.valueOf(33));
137 + d2.setDutyMode("1");
138 + d2.setExgNo("");
139 + d2.setExgVersion("");
140 + d2.setFirstUnit("035");
141 + d2.setFirstQty(11);
142 + d2.setGunit("007");
143 + d2.setGmodel("商品规格、型号");
144 + d2.setGname("餐桌");
145 + d2.setGno("2");
146 + d2.setGqty(BigDecimal.valueOf(22.88));
147 + d2.setOriginCountry("US");
148 + d2.setSecondUnit("007");
149 + d2.setSecondQty(3);
150 + d2.setTradeCurr("USD");
151 + d2.setUseTo("");
152 + d2.setWorkUsd(null);
153 + d2.setDestinationCountry("CN");
154 + d2.setCiqCode("");
155 + d2.setDeclGoodsEname("");
156 + d2.setDestCode("");
157 + d2.setDistrictCode("4408W");
158 +
159 +
160 +
161 + List<MawbDetail> mawbDetailList = new ArrayList<MawbDetail>();
162 + mawbDetailList.add(d1);
163 + mawbDetailList.add(d2);
164 +
165 +
166 +
167 +
168 + Mawb mawb = new Mawb();
169 + mawb.setIEFlag("E");
170 + mawb.setType("EX");
171 + mawb.setAgentCode("1111980005");
172 + mawb.setAgentName("联邦快递(中国)有限公司");
173 + mawb.setBillNo("202105210784");
174 + mawb.setContrNo("NO.565733");
175 + mawb.setCustomMaster("0101");
176 + mawb.setCutMode("101");
177 + mawb.setDeclTrnRel("0");
178 + mawb.setDistinatePort("ASM000");
179 + mawb.setEdiId("001");
180 + mawb.setEntryId("25512456");
181 + mawb.setFeeCurr("USD");
182 + mawb.setFeeMark("3");
183 + mawb.setFeeRate(BigDecimal.valueOf(100.58));
184 + mawb.setGrossWet(500);
185 + mawb.setIEPort("0101");
186 + mawb.setInputerName("");
187 + mawb.setInsurCurr("MOP");
188 + mawb.setInsurMark("3");
189 + mawb.setInsurRate(BigDecimal.valueOf(23.44));
190 + mawb.setManualNo("备案号");
191 + mawb.setNetWt(BigDecimal.valueOf(80));
192 + mawb.setOtherCurr("USD");
193 + mawb.setOtherRate(BigDecimal.valueOf(10));
194 + mawb.setOtherMark("");
195 + mawb.setOwnerCode("Z321654987");
196 + mawb.setOwnerName("上海保险");
197 + mawb.setPackNo(1);
198 + mawb.setPreEntryId("");
199 + mawb.setTradeCountry("US");
200 + mawb.setTradeMode("110");
201 + mawb.setTradeCode("Z321654987");
202 + mawb.setTrafMode("1");
203 + mawb.setTradeName("上海铢怡国际货物运输代理有限公司");
204 + mawb.setTransMode("3");
205 + mawb.setWrapType("22");
206 + mawb.setTradeCodeScc("A74125896321456987");
207 + mawb.setOwnerCodeScc("A74125896321456987");
208 + mawb.setTradeAreaCode("US");
209 + mawb.setMarkNo("N/M");
210 + mawb.setEntyPortCode("310302");
211 + mawb.setGoodsPlace("");
212 + mawb.setDeclareName("张安");
213 + mawb.setOverseasConsignorCode("Z785421");
214 + mawb.setOverseasConsigneeCode("Z785421");
215 + mawb.setOverseasConsigneeEname("出口时必填收件人公司名(原)");
216 + mawb.setMawbDetailList(mawbDetailList);
217 +
218 + return mawb;
219 + }
220 +
221 +
222 +
223 +
224 +
225 +
226 +
227 +
228 +
229 +
230 +}