Toggle navigation
Toggle navigation
This project
Loading...
Sign in
wei.zhou
/
iClear-api
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
wei.zhou
2021-06-25 11:51:06 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a90faded492a1edf899b11ca37491db0acc29d47
a90faded
1 parent
b183fa6e
提交代码
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
252 additions
and
2 deletions
pom.xml
readme.txt
src/main/java/com/erry/iclear/dateInterface/service/AppInfoService.java
src/main/java/com/erry/iclear/dateInterface/service/ChmCarryPortService.java
src/main/java/com/erry/iclear/dateInterface/service/DictionaryEntriesService.java
src/main/java/com/erry/iclear/dateInterface/service/DomesticDestinationMappingService.java
src/main/java/com/erry/iclear/dateInterface/service/OrigplacecodeMappingService.java
src/test/java/com/erry/iclear/dateInterface/HttpClientTest.java
pom.xml
View file @
a90fade
...
...
@@ -85,7 +85,11 @@
</dependency>
<dependency>
<groupId>
com.arronlong
</groupId>
<artifactId>
httpclientutil
</artifactId>
<version>
1.0.4
</version>
</dependency>
</dependencies>
<profiles>
...
...
readme.txt
0 → 100644
View file @
a90fade
打包命令
mvn clean package -Dmaven.test.skip=true -Pdev
启动命令
java -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=128m -Xms1024m -Xmx1024m -Xmn256m -Xss256k -XX:SurvivorRatio=5 -XX:+UseConcMarkSweepGC -jar jar包路径
jstat -gc pid
jmap -heap pid
src/main/java/com/erry/iclear/dateInterface/service/AppInfoService.java
View file @
a90fade
...
...
@@ -37,6 +37,7 @@ public class AppInfoService {
*/
public
void
initAppInfo
()
{
try
{
Constant
.
appIdSecurityCache
.
clear
();
List
<
AppInfo
>
appInfoList
=
this
.
getAllEnableAppInfo
();
for
(
AppInfo
appInfo
:
appInfoList
)
{
HashMap
<
String
,
String
>
appkeyMap
=
new
HashMap
<
String
,
String
>();
...
...
src/main/java/com/erry/iclear/dateInterface/service/ChmCarryPortService.java
View file @
a90fade
...
...
@@ -34,9 +34,9 @@ public class ChmCarryPortService {
*/
public
void
initChmCarryPort
()
{
try
{
Constant
.
chmCarryPortCache
.
clear
();
List
<
ChmCarryPort
>
appInfoList
=
this
.
findAllChmCarryPort
();
for
(
ChmCarryPort
chmCarryPort
:
appInfoList
)
{
Constant
.
chmCarryPortCache
.
put
(
chmCarryPort
.
getPcCode
(),
chmCarryPort
);
}
}
catch
(
Exception
e
)
{
...
...
src/main/java/com/erry/iclear/dateInterface/service/DictionaryEntriesService.java
View file @
a90fade
...
...
@@ -39,6 +39,7 @@ public class DictionaryEntriesService {
*/
public
void
initDictionaryEntries
()
{
try
{
Constant
.
dictionaryEntriesCache
.
clear
();
List
<
DictionaryEntries
>
dictionaryEntriesList
=
this
.
getAllDictionaryEntries
();
for
(
DictionaryEntries
dictionaryEntries
:
dictionaryEntriesList
)
{
if
(
Objects
.
equals
(
dictionaryEntries
.
getDictCode
(),
"ClinchType"
)){
...
...
src/main/java/com/erry/iclear/dateInterface/service/DomesticDestinationMappingService.java
View file @
a90fade
...
...
@@ -38,6 +38,7 @@ public class DomesticDestinationMappingService {
*/
public
void
initDomesticDestinationMapping
()
{
try
{
Constant
.
domesticDestinationMappingCache
.
clear
();
List
<
DomesticDestinationMapping
>
domList
=
this
.
findAllDomesticDestinationMapping
();
for
(
DomesticDestinationMapping
dom
:
domList
)
{
Constant
.
domesticDestinationMappingCache
.
put
(
dom
.
getDistrictCode
(),
dom
);
...
...
src/main/java/com/erry/iclear/dateInterface/service/OrigplacecodeMappingService.java
View file @
a90fade
...
...
@@ -41,6 +41,7 @@ public class OrigplacecodeMappingService {
*/
public
void
initOrigplacecodeMapping
()
{
try
{
Constant
.
origplacecodeMappingCache
.
clear
();
List
<
OrigplacecodeMapping
>
domList
=
this
.
findAllOrigplacecodeMapping
();
for
(
OrigplacecodeMapping
dom
:
domList
)
{
Constant
.
origplacecodeMappingCache
.
put
(
dom
.
getOrigplaceCode
(),
dom
);
...
...
src/test/java/com/erry/iclear/dateInterface/HttpClientTest.java
0 → 100644
View file @
a90fade
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.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/sendMawb")));
String
timeStamp
=
"1623920478192"
;
//String timeStamp = "1624263798669";
System
.
out
.
println
(
new
Date
(
Long
.
valueOf
(
timeStamp
)));
String
token
=
SHA256Util
.
getSHA256String
(
"IDE"
+
"iClearExport"
+
"b92131f03f19a348"
+
timeStamp
);
System
.
out
.
println
(
token
);
Header
[]
headers
=
HttpHeader
.
custom
()
.
other
(
"Content-Type"
,
"application/json"
)
.
other
(
"Appid"
,
"IDE"
)
.
other
(
"appKey"
,
"iClearExport"
)
.
other
(
"TimeStamp"
,
timeStamp
)
.
other
(
"token"
,
token
)
.
build
();
//插件式配置生成HttpClient时所需参数(超时、连接池、ssl、重试)
HCB
hcb
=
HCB
.
custom
()
.
timeout
(
3000
)
//超时
.
pool
(
100
,
10
)
//启用连接池,每个路由最大创建10个链接,总连接数限制为100个
.
sslpv
(
SSLs
.
SSLProtocolVersion
.
TLSv1_2
)
//设置ssl版本号,默认SSLv3,也可以调用sslpv("TLSv1.2")
.
ssl
()
//https,支持自定义ssl证书路径和密码,ssl(String keyStorePath, String keyStorepass)
.
retry
(
5
)
//重试5次
;
HttpClient
client
=
hcb
.
build
();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
"mawb"
,
createMawb
());
//map.put("key2", "value2");
Mawb
mawb
=
createMawb
();
Gson
gson
=
new
Gson
();
String
request
=
gson
.
toJson
(
mawb
);
//插件式配置请求参数(网址、请求参数、编码、client)
String
url
=
"https://40.73.78.157:8780/customs/sendMawb"
;
HttpConfig
config
=
HttpConfig
.
custom
()
.
headers
(
headers
)
//设置headers,不需要时则无需设置
.
url
(
url
)
//设置请求的url
//.map(map) //设置请求参数,没有则无需设置
.
encoding
(
"utf-8"
)
//设置请求和返回编码,默认就是Charset.defaultCharset()
.
client
(
client
)
//如果只是简单使用,无需设置,会自动获取默认的一个client对象
//.inenc("utf-8") //设置请求编码,如果请求返回一直,不需要再单独设置
//.inenc("utf-8") //设置返回编码,如果请求返回一直,不需要再单独设置
.
json
(
request
)
//json方式请求的话,就不用设置map方法,当然二者可以共用。
//.context(HttpCookies.custom().getContext()) //设置cookie,用于完成携带cookie的操作
//.out(new FileOutputStream("保存地址")) //下载的话,设置这个方法,否则不要设置
//.files(new String[]{"d:/1.txt","d:/2.txt"}) //上传的话,传递文件路径,一般还需map配置,设置服务器保存路径
;
//使用方式:
//System.out.println(HttpClientUtil.get(config));
System
.
out
.
println
(
HttpClientUtil
.
post
(
config
));
//HttpClientUtil.down(config); //下载,需要调用config.out(fileOutputStream对象)
//HttpClientUtil.upload(config); //上传,需要调用config.files(文件路径数组)
//如果指向看是否访问正常
//String result3 = HttpClientUtil.head(config); // 返回Http协议号+状态码
//int statusCode = HttpClientUtil.status(config);//返回状态码
//[新增方法]sendAndGetResp,可以返回原生的HttpResponse对象,
//同时返回常用的几类对象:result、header、StatusLine、StatusCode
// HttpResult respResult = HttpClientUtil.sendAndGetResp(config);
// System.out.println("返回结果:\n"+respResult.getResult());
// System.out.println("返回resp-header:"+respResult.getRespHeaders());//可以遍历
// System.out.println("返回具体resp-header:"+respResult.getHeaders("Date"));
// System.out.println("返回StatusLine对象:"+respResult.getStatusLine());
// System.out.println("返回StatusCode:"+respResult.getStatusCode());
// System.out.println("返回HttpResponse对象)(可自行处理):"+respResult.getResp());
}
public
static
Mawb
createMawb
(){
MawbDetail
d1
=
new
MawbDetail
();
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
.
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
(
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
;
}
}
Please
register
or
login
to post a comment