Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
8
8timerapiv200
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
8timerv2
8timerapiv200
Commits
b1ad7b73
Commit
b1ad7b73
authored
Apr 21, 2022
by
翁国栋
Committed by
284718418@qq.com
Mar 30, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
导入保单查询保单状态
parent
32509fd3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
51 deletions
+61
-51
src/main/java/cn/timer/api/utils/HttpUtils.java
+39
-51
src/main/resources/application-dev.yml
+19
-0
src/main/resources/application-test.yml
+3
-0
No files found.
src/main/java/cn/timer/api/utils/HttpUtils.java
View file @
b1ad7b73
package
cn
.
timer
.
api
.
utils
;
package
cn
.
timer
.
api
.
utils
;
import
java.io.*
;
import
java.io.*
;
import
java.net.ConnectException
;
import
java.net.*
;
import
java.net.SocketTimeoutException
;
import
java.net.URL
;
import
java.net.URLConnection
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.charset.StandardCharsets
;
import
java.security.cert.X509Certificate
;
import
java.security.cert.X509Certificate
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -16,6 +13,12 @@ import javax.net.ssl.TrustManager;
...
@@ -16,6 +13,12 @@ import javax.net.ssl.TrustManager;
import
javax.net.ssl.X509TrustManager
;
import
javax.net.ssl.X509TrustManager
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.HttpGet
;
import
org.apache.http.client.utils.URIBuilder
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.HttpClients
;
import
org.apache.http.util.EntityUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -37,59 +40,44 @@ public class HttpUtils
...
@@ -37,59 +40,44 @@ public class HttpUtils
* @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
* @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
* @return 所代表远程资源的响应结果
* @return 所代表远程资源的响应结果
*/
*/
public
static
String
sendGet
(
String
url
,
String
param
)
public
static
String
sendGet
(
String
url
,
Map
<
String
,
String
>
param
)
{
{
// 创建Httpclient对象
StringBuilder
result
=
new
StringBuilder
();
CloseableHttpClient
httpclient
=
HttpClients
.
createDefault
();
BufferedReader
in
=
null
;
try
String
resultString
=
""
;
{
CloseableHttpResponse
response
=
null
;
String
urlNameString
=
url
+
"?"
+
param
;
try
{
log
.
info
(
"sendGet - {}"
,
urlNameString
);
// 创建uri
URL
realUrl
=
new
URL
(
urlNameString
);
URIBuilder
builder
=
new
URIBuilder
(
url
);
HttpsURLConnection
connection
=
(
HttpsURLConnection
)
realUrl
.
openConnection
();
if
(
param
!=
null
)
{
connection
.
setRequestProperty
(
"accept"
,
"*/*"
);
for
(
String
key
:
param
.
keySet
())
{
connection
.
setRequestProperty
(
"connection"
,
"Keep-Alive"
);
builder
.
addParameter
(
key
,
param
.
get
(
key
));
connection
.
setRequestProperty
(
"User-Agent"
,
"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36)"
);
connection
.
connect
();
in
=
new
BufferedReader
(
new
InputStreamReader
(
connection
.
getInputStream
()));
String
line
;
while
((
line
=
in
.
readLine
())
!=
null
)
{
result
.
append
(
line
);
}
log
.
info
(
"recv - {}"
,
result
);
}
catch
(
ConnectException
e
)
{
log
.
error
(
"调用HttpUtils.sendGet ConnectException, url="
+
url
+
",param="
+
param
,
e
);
}
catch
(
SocketTimeoutException
e
)
{
log
.
error
(
"调用HttpUtils.sendGet SocketTimeoutException, url="
+
url
+
",param="
+
param
,
e
);
}
}
catch
(
IOException
e
)
{
log
.
error
(
"调用HttpUtils.sendGet IOException, url="
+
url
+
",param="
+
param
,
e
);
}
}
catch
(
Exception
e
)
URI
uri
=
builder
.
build
();
{
log
.
error
(
"调用HttpsUtil.sendGet Exception, url="
+
url
+
",param="
+
param
,
e
);
// 创建http GET请求
}
HttpGet
httpGet
=
new
HttpGet
(
uri
);
finally
{
// 执行请求
try
response
=
httpclient
.
execute
(
httpGet
);
{
// 判断返回状态是否为200
if
(
in
!=
null
)
if
(
response
.
getStatusLine
().
getStatusCode
()
==
200
)
{
{
resultString
=
EntityUtils
.
toString
(
response
.
getEntity
(),
"UTF-8"
);
in
.
close
();
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
try
{
if
(
response
!=
null
)
{
response
.
close
();
}
}
catch
(
Exception
ex
)
httpclient
.
close
();
{
}
catch
(
IOException
e
)
{
log
.
error
(
"调用in.close Exception, url="
+
url
+
",param="
+
param
,
ex
);
e
.
printStackTrace
(
);
}
}
}
}
return
result
.
toString
()
;
return
result
String
;
}
}
/**
/**
...
...
src/main/resources/application-dev.yml
View file @
b1ad7b73
...
@@ -244,6 +244,9 @@ insure:
...
@@ -244,6 +244,9 @@ insure:
secret
:
'
acb329868c31d5b3ba03de40dac13dd9'
secret
:
'
acb329868c31d5b3ba03de40dac13dd9'
uploadUrl
:
'
http://sandbox.portal.unistar-ins.com/service/Home/Index/fileUpload'
uploadUrl
:
'
http://sandbox.portal.unistar-ins.com/service/Home/Index/fileUpload'
insuredUrl
:
'
http://sandbox.portal.unistar-ins.com/mall/Home/Index/createQuotePolicy'
insuredUrl
:
'
http://sandbox.portal.unistar-ins.com/mall/Home/Index/createQuotePolicy'
#查询保单信息
policyDetail
:
'
http://sandbox.portal.unistar-ins.com/issuing/Home/Index/policy'
#保全
#保全
appidq
:
'
1000115041006006938'
appidq
:
'
1000115041006006938'
secretq
:
'
6ba1bf4aa0bd14368c95ff0b9934a17b'
secretq
:
'
6ba1bf4aa0bd14368c95ff0b9934a17b'
...
@@ -252,3 +255,19 @@ insure:
...
@@ -252,3 +255,19 @@ insure:
# base_api_url
# base_api_url
BASE_API_URL
:
'
http://test-8timer-api.youlingrc.com'
BASE_API_URL
:
'
http://test-8timer-api.youlingrc.com'
#sftp 配置
sftp
:
client
:
protocol
:
'
sftp'
host
:
'
120.78.162.177'
port
:
'
22'
username
:
'
root'
password
:
'
fksdlfjs(*&&%HGgjfkdjsfhksh9781283KFHFFGHghhndbv##2@'
root
:
'
/home'
sessionStrictHostKeyChecking
:
'
no'
sessionConnectTimeout
:
'
15000'
channelConnectedTimeout
:
'
15000'
serverUrl
:
'
https://test-img.8timer.cn'
targetPath
:
'
/disk'
reservedName
:
false
src/main/resources/application-test.yml
View file @
b1ad7b73
...
@@ -244,6 +244,9 @@ insure:
...
@@ -244,6 +244,9 @@ insure:
secret
:
'
acb329868c31d5b3ba03de40dac13dd9'
secret
:
'
acb329868c31d5b3ba03de40dac13dd9'
uploadUrl
:
'
http://sandbox.portal.unistar-ins.com/service/Home/Index/fileUpload'
uploadUrl
:
'
http://sandbox.portal.unistar-ins.com/service/Home/Index/fileUpload'
insuredUrl
:
'
http://sandbox.portal.unistar-ins.com/mall/Home/Index/createQuotePolicy'
insuredUrl
:
'
http://sandbox.portal.unistar-ins.com/mall/Home/Index/createQuotePolicy'
#查询保单信息
policyDetail
:
'
http://sandbox.portal.unistar-ins.com/issuing/Home/Index/policy'
#保全
#保全
appidq
:
'
1000115041006006938'
appidq
:
'
1000115041006006938'
secretq
:
'
6ba1bf4aa0bd14368c95ff0b9934a17b'
secretq
:
'
6ba1bf4aa0bd14368c95ff0b9934a17b'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment