Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
FrontEndProcessor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
CrossProvincialPlatform
FrontEndProcessor
Commits
c8c6ea27
Commit
c8c6ea27
authored
May 28, 2021
by
华润
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
跨省单位开户公积金服务接口
parent
f3e26f73
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
90 additions
and
24 deletions
+90
-24
pom.xml
pom.xml
+20
-0
src/main/java/net/cdkj/gjj/adapter/controller/ProvidentFundServicesController.java
...j/adapter/controller/ProvidentFundServicesController.java
+33
-11
src/main/java/net/cdkj/gjj/adapter/controller/TokenAcquisitionController.java
...kj/gjj/adapter/controller/TokenAcquisitionController.java
+37
-13
No files found.
pom.xml
View file @
c8c6ea27
...
...
@@ -54,6 +54,26 @@
<artifactId>
ojdbc7
</artifactId>
<version>
12.1.0.1.0
</version>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpcore
</artifactId>
<version>
4.4.13
</version>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpcore
</artifactId>
<version>
4.3
</version>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpcore
</artifactId>
<version>
4.4.5
</version>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpclient
</artifactId>
<version>
4.5.13
</version>
</dependency>
</dependencies>
...
...
src/main/java/net/cdkj/gjj/adapter/controller/ProvidentFundServicesController.java
View file @
c8c6ea27
...
...
@@ -16,6 +16,8 @@ import java.util.ArrayList;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.zip.GZIPInputStream
;
import
static
net
.
cdkj
.
gjj
.
adapter
.
domain
.
GzipUtil
.
unzipString
;
import
static
net
.
cdkj
.
gjj
.
adapter
.
domain
.
GzipUtil
.
zipString
;
...
...
@@ -53,6 +55,7 @@ public class ProvidentFundServicesController {
//-----------------------------------------------------
String
token
=
null
;
token
=
huoqutoken
();
//调用获取token的方法
System
.
out
.
println
(
token
);
// System.out.println("内置机传给前置机的json数据:"+str);
System
.
out
.
println
(
"zip压缩处理之前要发送给第三方的公积金系统服务报文:"
+
str
);
// String s = zipString(str);//进行zip压缩
...
...
@@ -78,6 +81,8 @@ public class ProvidentFundServicesController {
conn
.
setRequestProperty
(
"Connection"
,
"Keep-Alive"
);
// 设置文件类型:
conn
.
setRequestProperty
(
"Content-Type"
,
"application/json"
);
conn
.
setRequestProperty
(
"accept"
,
"*/*"
);
conn
.
setRequestProperty
(
"Accept-Encoding"
,
"gzip, deflate, br"
);
// 设置文件字符集:
conn
.
setRequestProperty
(
"Charset"
,
"UTF-8"
);
// 转换为字节数组
...
...
@@ -99,10 +104,17 @@ public class ProvidentFundServicesController {
sb
.
append
(
readLine
);
}
responseReader
.
close
();
// GZIPInputStream gzis = new GZIPInputStream(is);
// InputStreamReader reader = new InputStreamReader(gzis);
// BufferedReader br = new BufferedReader(reader);
// String temp;
// while ((temp = br.readLine()) != null) {
// sb.append(temp);
// }
System
.
out
.
println
(
"公积金服务第三方返回的zip压缩过的报文:"
+
sb
.
toString
());
String
s1
=
unzipString
(
sb
.
toString
());
//将第三方返回的压缩过的json字符串解压缩
System
.
out
.
println
(
"公积金服务第三方返回的zip解压缩之后的报文:"
+
s
1
);
return
s
1
;
//
String s1 = unzipString(sb.toString());//将第三方返回的压缩过的json字符串解压缩
System
.
out
.
println
(
"公积金服务第三方返回的zip解压缩之后的报文:"
+
s
b
.
toString
()
);
return
s
b
.
toString
()
;
}
else
{
System
.
out
.
println
(
"请求失败!!!"
);
}
...
...
@@ -329,6 +341,7 @@ public class ProvidentFundServicesController {
@ResponseBody
@PostMapping
(
"BusinessProcessing"
)
public
static
String
BusinessProcessing
(
HttpServletRequest
request
)
{
System
.
out
.
println
(
"继续调前置机的进度第二个接口"
);
//-----------------------------------------------------
StringBuffer
json
=
new
StringBuffer
();
String
line
=
null
;
...
...
@@ -371,6 +384,8 @@ public class ProvidentFundServicesController {
conn
.
setRequestProperty
(
"Connection"
,
"Keep-Alive"
);
// 设置文件类型:
conn
.
setRequestProperty
(
"Content-Type"
,
"application/json"
);
conn
.
setRequestProperty
(
"accept"
,
"*/*"
);
conn
.
setRequestProperty
(
"Accept-Encoding"
,
"gzip, deflate, br"
);
// 设置文件字符集:
conn
.
setRequestProperty
(
"Charset"
,
"UTF-8"
);
// 转换为字节数组
...
...
@@ -386,16 +401,23 @@ public class ProvidentFundServicesController {
if
(
HttpURLConnection
.
HTTP_OK
==
conn
.
getResponseCode
())
{
// 请求返回的数据
InputStream
is
=
conn
.
getInputStream
();
String
readLine
=
new
String
();
BufferedReader
responseReader
=
new
BufferedReader
(
new
InputStreamReader
(
is
,
"UTF-8"
));
while
((
readLine
=
responseReader
.
readLine
())
!=
null
)
{
sb
.
append
(
readLine
);
// String readLine = new String();
// BufferedReader responseReader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
// while ((readLine = responseReader.readLine()) != null) {
// sb.append(readLine);
// }
// responseReader.close();
GZIPInputStream
gzis
=
new
GZIPInputStream
(
is
);
InputStreamReader
reader
=
new
InputStreamReader
(
gzis
);
BufferedReader
br
=
new
BufferedReader
(
reader
);
String
temp
;
while
((
temp
=
br
.
readLine
())
!=
null
)
{
sb
.
append
(
temp
);
}
responseReader
.
close
();
System
.
out
.
println
(
"第三方返回的zip压缩过的进度结果报文:"
+
sb
.
toString
());
String
s1
=
unzipString
(
sb
.
toString
());
//将第三方返回的压缩过的json字符串解压缩
System
.
out
.
println
(
"第三方返回的zip解压缩之后的进度结果报文:"
+
s
1
);
return
s
1
;
//
String s1 = unzipString(sb.toString());//将第三方返回的压缩过的json字符串解压缩
System
.
out
.
println
(
"第三方返回的zip解压缩之后的进度结果报文:"
+
s
b
.
toString
()
);
return
s
b
.
toString
()
;
}
else
{
System
.
out
.
println
(
"请求失败!!!"
);
}
...
...
src/main/java/net/cdkj/gjj/adapter/controller/TokenAcquisitionController.java
View file @
c8c6ea27
...
...
@@ -6,8 +6,12 @@ import org.springframework.web.bind.annotation.*;
import
java.io.*
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
static
net
.
cdkj
.
gjj
.
adapter
.
domain
.
GzipUtil
.
zipString
;
import
static
net
.
cdkj
.
gjj
.
adapter
.
domain
.
GzipUtil
.
unzipString
;
import
java.io.IOException
;
import
java.util.zip.GZIPInputStream
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
static
net
.
cdkj
.
gjj
.
adapter
.
domain
.
GzipUtil
.*;
/**
...
...
@@ -40,8 +44,8 @@ public class TokenAcquisitionController {
OutputStream
out
=
null
;
try
{
// 创建url 资源
//
URL url = new URL("https://scjg.hubei.gov.cn/sjzt/api/oauth2/token");//正式第三方地址
URL
url
=
new
URL
(
"http://127.0.0.1:8080/FrontEndProcessor/FrontEndProcessor/token2"
);
//测试第三方地址
URL
url
=
new
URL
(
"https://scjg.hubei.gov.cn/sjzt/api/oauth2/token"
);
//正式第三方地址
//
URL url = new URL("http://127.0.0.1:8080/FrontEndProcessor/FrontEndProcessor/token2");//测试第三方地址
// 创建http 连接
conn
=
(
HttpURLConnection
)
url
.
openConnection
();
// 设置允许输出
...
...
@@ -54,6 +58,8 @@ public class TokenAcquisitionController {
conn
.
setRequestMethod
(
"POST"
);
// 设置维持长连接
conn
.
setRequestProperty
(
"Connection"
,
"Keep-Alive"
);
conn
.
setRequestProperty
(
"accept"
,
"*/*"
);
conn
.
setRequestProperty
(
"Accept-Encoding"
,
"gzip, deflate, br"
);
// 设置文件类型:
conn
.
setRequestProperty
(
"Content-Type"
,
"application/json"
);
// 设置文件字符集:
...
...
@@ -69,18 +75,24 @@ public class TokenAcquisitionController {
out
.
write
(
data
);
// 请求返回的状态
if
(
HttpURLConnection
.
HTTP_OK
==
conn
.
getResponseCode
())
{
// 请求返回的数据
//
// 请求返回的数据
InputStream
is
=
conn
.
getInputStream
();
String
readLine
=
new
String
();
BufferedReader
responseReader
=
new
BufferedReader
(
new
InputStreamReader
(
is
,
"UTF-8"
));
while
((
readLine
=
responseReader
.
readLine
())
!=
null
)
{
sb
.
append
(
readLine
);
// String readLine = new String();
// BufferedReader responseReader = new BufferedReader(new InputStreamReader(is,"UTF-8"));
// while ((readLine = responseReader.readLine()) != null) {
// sb.append(readLine);
// }
GZIPInputStream
gzis
=
new
GZIPInputStream
(
is
);
InputStreamReader
reader
=
new
InputStreamReader
(
gzis
);
BufferedReader
br
=
new
BufferedReader
(
reader
);
String
temp
;
while
((
temp
=
br
.
readLine
())
!=
null
)
{
sb
.
append
(
temp
);
}
responseReader
.
close
();
System
.
out
.
println
(
"鉴权参数第三方返回的zip压缩过的报文:"
+
sb
.
toString
());
String
s1
=
unzipString
(
sb
.
toString
());
//将第三方返回的压缩过的json字符串解压缩
System
.
out
.
println
(
"鉴权参数第三方返回的zip解压缩之后的报文:"
+
s
1
);
return
s
1
;
//
String s1 = unzipString(sb.toString());//将第三方返回的压缩过的json字符串解压缩
System
.
out
.
println
(
"鉴权参数第三方返回的zip解压缩之后的报文:"
+
s
b
.
toString
()
);
return
s
b
.
toString
()
;
}
else
{
System
.
out
.
println
(
"请求失败!!!"
);
}
...
...
@@ -141,4 +153,16 @@ public class TokenAcquisitionController {
String
s1
=
unzipString
(
s
);
//进行zip解压缩
System
.
out
.
println
(
"解压缩处理之后的json字符串:"
+
s1
);
}
/**
* 程序中访问http数据接口
*/
@ResponseBody
@PostMapping
(
"testjson"
)
public
static
String
getURLContent
()
{
return
null
;
}
}
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