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
78278dd8
Commit
78278dd8
authored
May 21, 2021
by
华润
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
跨省单位开户公积金服务接口
parent
37ccd284
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
342 additions
and
89 deletions
+342
-89
src/main/java/net/cdkj/gjj/adapter/controller/ProvidentFundServicesController.java
...j/adapter/controller/ProvidentFundServicesController.java
+144
-89
src/main/java/net/cdkj/gjj/adapter/domain/UnitAccountOpeningInformation.java
...dkj/gjj/adapter/domain/UnitAccountOpeningInformation.java
+198
-0
No files found.
src/main/java/net/cdkj/gjj/adapter/controller/ProvidentFundServicesController.java
View file @
78278dd8
...
@@ -2,8 +2,6 @@ package net.cdkj.gjj.adapter.controller;
...
@@ -2,8 +2,6 @@ package net.cdkj.gjj.adapter.controller;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
net.cdkj.gjj.adapter.domain.Json
;
import
net.cdkj.gjj.adapter.domain.TimeExpiredPoolCache
;
import
net.cdkj.gjj.adapter.domain.UnitAccountOpeningInformation
;
import
net.cdkj.gjj.adapter.domain.UnitAccountOpeningInformation
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
@@ -13,6 +11,9 @@ import org.springframework.web.bind.annotation.RestController;
...
@@ -13,6 +11,9 @@ import org.springframework.web.bind.annotation.RestController;
import
java.io.*
;
import
java.io.*
;
import
java.net.HttpURLConnection
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.net.URL
;
import
java.sql.CallableStatement
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Calendar
;
...
@@ -37,87 +38,83 @@ public class ProvidentFundServicesController {
...
@@ -37,87 +38,83 @@ public class ProvidentFundServicesController {
*/
*/
@ResponseBody
@ResponseBody
@PostMapping
(
"ProvidentFundServices"
)
@PostMapping
(
"ProvidentFundServices"
)
public
String
ProvidentFundServices
()
{
public
static
String
ProvidentFundServices
()
{
String
token
=
null
;
String
token
=
null
;
token
=
CacheDemoController
.
getToken
();
token
=
huoqutoken
();
//调用获取token的方法
if
(!
""
.
equals
(
token
)&&
token
!=
null
){
//若token未过期,则用内存中的token
JSONObject
jsonObject
=
new
JSONObject
();
String
resp
=
null
;
jsonObject
.
put
(
"startTime"
,
currenttime
(
0
));
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"endTime"
,
currenttime
(
24
));
jsonObject
.
put
(
"startTime"
,
currenttime
(
0
));
jsonObject
.
put
(
"app_id"
,
"xxxxx"
);
jsonObject
.
put
(
"endTime"
,
currenttime
(
24
));
jsonObject
.
put
(
"app_secret"
,
"xxxxx"
);
jsonObject
.
put
(
"app_id"
,
"xxxxx"
);
String
str
=
jsonObject
.
toString
();
jsonObject
.
put
(
"app_secret"
,
"xxxxx"
);
// String str = jsonstr;
String
str
=
jsonObject
.
toString
();
System
.
out
.
println
(
"zip压缩处理之前要发送给第三方的报文:"
+
str
);
System
.
out
.
println
(
"zip压缩处理之前要发送给第三方的报文:"
+
str
);
String
s
=
zipString
(
str
);
//进行zip压缩
String
s
=
zipString
(
str
);
//进行zip压缩
System
.
out
.
println
(
"zip压缩处理之后发送给第三方的报文:"
+
s
);
System
.
out
.
println
(
"zip压缩处理之后发送给第三方的报文:"
+
s
);
StringBuffer
sb
=
new
StringBuffer
();
StringBuffer
sb
=
new
StringBuffer
();
HttpURLConnection
conn
=
null
;
HttpURLConnection
conn
=
null
;
OutputStream
out
=
null
;
OutputStream
out
=
null
;
try
{
try
{
// 创建url 资源
// 创建url 资源
// URL url = new URL("https://scjg.hubei.gov.cn/sjzt/api/dx/e39a08e0a52b413897f9d23359540b27/GJJ?access_token="+token);//正式第三方地址
// URL url = new URL("https://scjg.hubei.gov.cn/sjzt/api/dx/e39a08e0a52b413897f9d23359540b27/GJJ?access_token="+token);//正式第三方地址
URL
url
=
new
URL
(
"http://127.0.0.1:8080/FrontEndProcessor/FrontEndProcessor/ProvidentFundServices2?access_token="
+
token
);
//测试第三方地址
URL
url
=
new
URL
(
"http://127.0.0.1:8080/FrontEndProcessor/FrontEndProcessor/ProvidentFundServices2?access_token="
+
token
);
//测试第三方地址
// 创建http 连接
// 创建http 连接
conn
=
(
HttpURLConnection
)
url
.
openConnection
();
conn
=
(
HttpURLConnection
)
url
.
openConnection
();
// 设置允许输出
// 设置允许输出
conn
.
setDoOutput
(
true
);
conn
.
setDoOutput
(
true
);
// 设置允许输入
// 设置允许输入
conn
.
setDoInput
(
true
);
conn
.
setDoInput
(
true
);
// 设置不使用缓存
// 设置不使用缓存
conn
.
setUseCaches
(
false
);
conn
.
setUseCaches
(
false
);
// 设置传递方式
// 设置传递方式
conn
.
setRequestMethod
(
"POST"
);
conn
.
setRequestMethod
(
"POST"
);
// 设置维持长连接
// 设置维持长连接
conn
.
setRequestProperty
(
"Connection"
,
"Keep-Alive"
);
conn
.
setRequestProperty
(
"Connection"
,
"Keep-Alive"
);
// 设置文件类型:
// 设置文件类型:
conn
.
setRequestProperty
(
"Content-Type"
,
"application/json"
);
conn
.
setRequestProperty
(
"Content-Type"
,
"application/json"
);
// 设置文件字符集:
// 设置文件字符集:
conn
.
setRequestProperty
(
"Charset"
,
"UTF-8"
);
conn
.
setRequestProperty
(
"Charset"
,
"UTF-8"
);
// 转换为字节数组
// 转换为字节数组
byte
[]
data
=
(
str
).
getBytes
(
"UTF-8"
);
byte
[]
data
=
(
str
).
getBytes
(
"UTF-8"
);
// 设置文件长度
// 设置文件长度
conn
.
setRequestProperty
(
"Content-Length"
,
String
.
valueOf
(
data
.
length
));
conn
.
setRequestProperty
(
"Content-Length"
,
String
.
valueOf
(
data
.
length
));
// 开始连接请求
// 开始连接请求
conn
.
connect
();
conn
.
connect
();
//创建写入流,写入请求的字符串
//创建写入流,写入请求的字符串
out
=
new
DataOutputStream
(
conn
.
getOutputStream
());
out
=
new
DataOutputStream
(
conn
.
getOutputStream
());
out
.
write
(
data
);
out
.
write
(
data
);
// 请求返回的状态
// 请求返回的状态
if
(
HttpURLConnection
.
HTTP_OK
==
conn
.
getResponseCode
())
{
if
(
HttpURLConnection
.
HTTP_OK
==
conn
.
getResponseCode
())
{
// 请求返回的数据
// 请求返回的数据
InputStream
is
=
conn
.
getInputStream
();
InputStream
is
=
conn
.
getInputStream
();
String
readLine
=
new
String
();
String
readLine
=
new
String
();
BufferedReader
responseReader
=
new
BufferedReader
(
new
InputStreamReader
(
is
,
"UTF-8"
));
BufferedReader
responseReader
=
new
BufferedReader
(
new
InputStreamReader
(
is
,
"UTF-8"
));
while
((
readLine
=
responseReader
.
readLine
())
!=
null
)
{
while
((
readLine
=
responseReader
.
readLine
())
!=
null
)
{
sb
.
append
(
readLine
);
sb
.
append
(
readLine
);
}
responseReader
.
close
();
System
.
out
.
println
(
"第三方返回的zip压缩过的报文:"
+
sb
.
toString
());
String
s1
=
unzipString
(
sb
.
toString
());
//将第三方返回的压缩过的json字符串解压缩
System
.
out
.
println
(
"第三方返回的zip解压缩之后的报文:"
+
s1
);
return
s1
;
}
else
{
System
.
out
.
println
(
"请求失败!!!"
);
}
}
}
catch
(
IOException
e
)
{
responseReader
.
close
();
e
.
printStackTrace
();
System
.
out
.
println
(
"第三方返回的zip压缩过的报文:"
+
sb
.
toString
());
}
finally
{
String
s1
=
unzipString
(
sb
.
toString
());
//将第三方返回的压缩过的json字符串解压缩
if
(
out
!=
null
)
{
System
.
out
.
println
(
"第三方返回的zip解压缩之后的报文:"
+
s1
);
try
{
return
s1
;
out
.
flush
();
}
else
{
out
.
close
();
System
.
out
.
println
(
"请求失败!!!"
);
}
catch
(
IOException
e
)
{
}
}
}
catch
(
IOException
e
)
{
}
e
.
printStackTrace
();
if
(
conn
!=
null
)
{
}
finally
{
conn
.
disconnect
();
if
(
out
!=
null
)
{
try
{
out
.
flush
();
out
.
close
();
}
catch
(
IOException
e
)
{
}
}
}
}
}
else
{
//若token已过期,则重新调用鉴权认证接口获取token存入内存中
if
(
conn
!=
null
)
{
CacheDemoController
.
saveToken
();
conn
.
disconnect
();
token
=
CacheDemoController
.
getToken
();
}
}
}
return
null
;
return
null
;
}
}
...
@@ -134,25 +131,31 @@ public class ProvidentFundServicesController {
...
@@ -134,25 +131,31 @@ public class ProvidentFundServicesController {
JSONObject
jsonObject
=
new
JSONObject
();
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"code"
,
0
);
jsonObject
.
put
(
"code"
,
0
);
jsonObject
.
put
(
"message"
,
"数据交换成功"
);
jsonObject
.
put
(
"message"
,
"数据交换成功"
);
List
<
UnitAccountOpeningInformation
>
data
=
new
ArrayList
<>();
List
<
UnitAccountOpeningInformation
>
data
=
new
ArrayList
<>();
UnitAccountOpeningInformation
openingInformation
=
new
UnitAccountOpeningInformation
();
UnitAccountOpeningInformation
openingInformation
=
new
UnitAccountOpeningInformation
();
openingInformation
.
setBusId
(
"332090874"
);
openingInformation
.
setBusId
(
"332090874"
);
openingInformation
.
setUscc
(
"914205007146986237"
);
openingInformation
.
setEntName
(
"湖北稻花香酒业股份有限公司"
);
data
.
add
(
openingInformation
);
data
.
add
(
openingInformation
);
jsonObject
.
put
(
"data"
,
data
);
jsonObject
.
put
(
"data"
,
data
);
String
str
=
jsonObject
.
toString
();
String
str
=
jsonObject
.
toString
();
return
jsonObject
.
toString
();
String
s
=
zipString
(
str
);
//进行zip压缩
// System.out.println(s);
// String s1 = unzipString(s);//解压缩
// System.out.println(s1);
return
s
;
}
}
/**
/**
* 获取当天零点零分零秒的时间戳和当天24点的时间戳
* 获取当天零点零分零秒的时间戳和当天24点的时间戳
*
* @return
* @return
*/
*/
@ResponseBody
@ResponseBody
@PostMapping
(
"currentime"
)
@PostMapping
(
"currentime"
)
public
static
String
currenttime
(
int
type
){
public
static
String
currenttime
(
int
type
)
{
String
time
=
null
;
String
time
=
null
;
if
(
type
==
0
)
{
if
(
type
==
0
)
{
// 获取当天零点零分零秒的时间戳
// 获取当天零点零分零秒的时间戳
Calendar
curentDay
=
Calendar
.
getInstance
();
Calendar
curentDay
=
Calendar
.
getInstance
();
curentDay
.
setTime
(
new
Date
());
curentDay
.
setTime
(
new
Date
());
...
@@ -160,9 +163,9 @@ public class ProvidentFundServicesController {
...
@@ -160,9 +163,9 @@ public class ProvidentFundServicesController {
curentDay
.
set
(
Calendar
.
MINUTE
,
0
);
curentDay
.
set
(
Calendar
.
MINUTE
,
0
);
curentDay
.
set
(
Calendar
.
SECOND
,
0
);
curentDay
.
set
(
Calendar
.
SECOND
,
0
);
SimpleDateFormat
df2
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
SimpleDateFormat
df2
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
time
=
df2
.
format
(
curentDay
.
getTime
().
getTime
());
time
=
df2
.
format
(
curentDay
.
getTime
().
getTime
());
System
.
out
.
println
(
time
);
System
.
out
.
println
(
time
);
}
else
if
(
type
==
24
)
{
}
else
if
(
type
==
24
)
{
// 获取当天24点零分零秒的时间戳,即第二天零点时间
// 获取当天24点零分零秒的时间戳,即第二天零点时间
Calendar
curentDay
=
Calendar
.
getInstance
();
Calendar
curentDay
=
Calendar
.
getInstance
();
curentDay
.
setTime
(
new
Date
());
curentDay
.
setTime
(
new
Date
());
...
@@ -170,10 +173,62 @@ public class ProvidentFundServicesController {
...
@@ -170,10 +173,62 @@ public class ProvidentFundServicesController {
curentDay
.
set
(
Calendar
.
MINUTE
,
0
);
curentDay
.
set
(
Calendar
.
MINUTE
,
0
);
curentDay
.
set
(
Calendar
.
SECOND
,
0
);
curentDay
.
set
(
Calendar
.
SECOND
,
0
);
SimpleDateFormat
df2
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
SimpleDateFormat
df2
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
time
=
df2
.
format
(
curentDay
.
getTime
().
getTime
());
time
=
df2
.
format
(
curentDay
.
getTime
().
getTime
());
System
.
out
.
println
(
time
);
System
.
out
.
println
(
time
);
}
}
return
time
;
return
time
;
}
/**
* 获取token专用方法
*
* @return
*/
@ResponseBody
@PostMapping
(
"huoqutoken"
)
public
static
String
huoqutoken
()
{
String
token
=
null
;
token
=
CacheDemoController
.
getToken
();
//优先从内存中拿
if
(!
""
.
equals
(
token
)
&&
token
!=
null
)
{
//若token未过期,则用内存中的token
}
else
{
//若token已过期,则重新调用鉴权认证接口获取token存入内存中
CacheDemoController
.
saveToken
();
token
=
CacheDemoController
.
getToken
();
}
return
token
;
}
/**
* 将从第三方拿到的单位开户的json信息通过调用oracle存储过程传给数据库处理
*
* @return
*/
@ResponseBody
@PostMapping
(
"getuniAccounInfom"
)
public
static
UnitAccountOpeningInformation
getuniAccounInfom
()
throws
Exception
{
String
jsoninfom
=
ProvidentFundServices
();
JSONObject
jsonObj
=
JSONObject
.
parseObject
(
jsoninfom
);
String
str
=
jsonObj
.
get
(
"data"
).
toString
();
String
str1
=
str
.
replace
(
"["
,
""
);
String
str2
=
str1
.
replace
(
"]"
,
""
);
UnitAccountOpeningInformation
uniInfom
=
JSONObject
.
parseObject
(
str2
,
UnitAccountOpeningInformation
.
class
);
System
.
out
.
println
(
uniInfom
);
//加载数据库驱动
Class
.
forName
(
"oracle.jdbc.driver.OracleDriver"
);
//得到Connection连接
Connection
connection
=
DriverManager
.
getConnection
(
"jdbc:oracle:thin:@192.168.101.194:1521:zfgjj"
,
"HG2020"
,
"HG2020"
);
//得到预编译的Statement对象
CallableStatement
pstm
=
connection
.
prepareCall
(
"{call JGJ_KSYW_DWKH.DWKH_SL(?,?)}"
);
//给参数赋值
pstm
.
setObject
(
1
,
uniInfom
);
//执行数据库查询操作
pstm
.
execute
();
//输出结果[第二个参数]
System
.
out
.
println
(
pstm
.
getObject
(
2
));
//释放资源
pstm
.
close
();
connection
.
close
();
return
uniInfom
;
}
}
}
}
src/main/java/net/cdkj/gjj/adapter/domain/UnitAccountOpeningInformation.java
View file @
78278dd8
package
net.cdkj.gjj.adapter.domain
;
package
net.cdkj.gjj.adapter.domain
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
java.util.Objects
;
import
java.util.Objects
;
/**
/**
* 单位开户信息对象
* 单位开户信息对象
*/
*/
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
public
class
UnitAccountOpeningInformation
{
public
class
UnitAccountOpeningInformation
{
private
String
busId
;
private
String
busId
;
private
String
uscc
;
private
String
entName
;
private
String
dom
;
private
String
estDate
;
private
String
lerep
;
private
String
cerType
;
private
String
cerNo
;
private
String
operatorName
;
private
String
operatorCerNo
;
private
String
operatorPhone
;
private
String
oplocdistrict
;
private
String
unitNature
;
private
String
economicType
;
private
String
industryphy
;
private
String
unitPayDay
;
private
String
unitDepPro
;
private
String
personalDepPro
;
public
String
getBusId
()
{
public
String
getBusId
()
{
return
busId
;
return
busId
;
}
}
...
@@ -16,4 +54,164 @@ public class UnitAccountOpeningInformation {
...
@@ -16,4 +54,164 @@ public class UnitAccountOpeningInformation {
public
void
setBusId
(
String
busId
)
{
public
void
setBusId
(
String
busId
)
{
this
.
busId
=
busId
;
this
.
busId
=
busId
;
}
}
public
String
getUscc
()
{
return
uscc
;
}
public
void
setUscc
(
String
uscc
)
{
this
.
uscc
=
uscc
;
}
public
String
getEntName
()
{
return
entName
;
}
public
void
setEntName
(
String
entName
)
{
this
.
entName
=
entName
;
}
public
String
getDom
()
{
return
dom
;
}
public
void
setDom
(
String
dom
)
{
this
.
dom
=
dom
;
}
public
String
getEstDate
()
{
return
estDate
;
}
public
void
setEstDate
(
String
estDate
)
{
this
.
estDate
=
estDate
;
}
public
String
getLerep
()
{
return
lerep
;
}
public
void
setLerep
(
String
lerep
)
{
this
.
lerep
=
lerep
;
}
public
String
getCerType
()
{
return
cerType
;
}
public
void
setCerType
(
String
cerType
)
{
this
.
cerType
=
cerType
;
}
public
String
getCerNo
()
{
return
cerNo
;
}
public
void
setCerNo
(
String
cerNo
)
{
this
.
cerNo
=
cerNo
;
}
public
String
getOperatorName
()
{
return
operatorName
;
}
public
void
setOperatorName
(
String
operatorName
)
{
this
.
operatorName
=
operatorName
;
}
public
String
getOperatorCerNo
()
{
return
operatorCerNo
;
}
public
void
setOperatorCerNo
(
String
operatorCerNo
)
{
this
.
operatorCerNo
=
operatorCerNo
;
}
public
String
getOperatorPhone
()
{
return
operatorPhone
;
}
public
void
setOperatorPhone
(
String
operatorPhone
)
{
this
.
operatorPhone
=
operatorPhone
;
}
public
String
getOplocdistrict
()
{
return
oplocdistrict
;
}
public
void
setOplocdistrict
(
String
oplocdistrict
)
{
this
.
oplocdistrict
=
oplocdistrict
;
}
public
String
getUnitNature
()
{
return
unitNature
;
}
public
void
setUnitNature
(
String
unitNature
)
{
this
.
unitNature
=
unitNature
;
}
public
String
getEconomicType
()
{
return
economicType
;
}
public
void
setEconomicType
(
String
economicType
)
{
this
.
economicType
=
economicType
;
}
public
String
getIndustryphy
()
{
return
industryphy
;
}
public
void
setIndustryphy
(
String
industryphy
)
{
this
.
industryphy
=
industryphy
;
}
public
String
getUnitPayDay
()
{
return
unitPayDay
;
}
public
void
setUnitPayDay
(
String
unitPayDay
)
{
this
.
unitPayDay
=
unitPayDay
;
}
public
String
getUnitDepPro
()
{
return
unitDepPro
;
}
public
void
setUnitDepPro
(
String
unitDepPro
)
{
this
.
unitDepPro
=
unitDepPro
;
}
public
String
getPersonalDepPro
()
{
return
personalDepPro
;
}
public
void
setPersonalDepPro
(
String
personalDepPro
)
{
this
.
personalDepPro
=
personalDepPro
;
}
@Override
public
String
toString
()
{
return
"UnitAccountOpeningInformation{"
+
"busId='"
+
busId
+
'\''
+
", uscc='"
+
uscc
+
'\''
+
", entName='"
+
entName
+
'\''
+
", dom='"
+
dom
+
'\''
+
", estDate='"
+
estDate
+
'\''
+
", lerep='"
+
lerep
+
'\''
+
", cerType='"
+
cerType
+
'\''
+
", cerNo='"
+
cerNo
+
'\''
+
", operatorName='"
+
operatorName
+
'\''
+
", operatorCerNo='"
+
operatorCerNo
+
'\''
+
", operatorPhone='"
+
operatorPhone
+
'\''
+
", oplocdistrict='"
+
oplocdistrict
+
'\''
+
", unitNature='"
+
unitNature
+
'\''
+
", economicType='"
+
economicType
+
'\''
+
", industryphy='"
+
industryphy
+
'\''
+
", unitPayDay='"
+
unitPayDay
+
'\''
+
", unitDepPro='"
+
unitDepPro
+
'\''
+
", personalDepPro='"
+
personalDepPro
+
'\''
+
'}'
;
}
}
}
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