Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hls-support-rlwx
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
rl
hls-support-rlwx
Commits
1494b56d
Commit
1494b56d
authored
Oct 24, 2024
by
胡建龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[add] qcc interface
parent
872bdf11
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
250 additions
and
1 deletion
+250
-1
Lm005HclcMapper.java
...n/java/com/hand/app/esignHclc/mapper/Lm005HclcMapper.java
+7
-0
QccRequestsController.java
...a/com/hand/app/qcc/controllers/QccRequestsController.java
+35
-0
IQccRequestsService.java
...in/java/com/hand/app/qcc/service/IQccRequestsService.java
+12
-0
QccRequestsServiceImpl.java
...com/hand/app/qcc/service/impl/QccRequestsServiceImpl.java
+173
-0
Lm005HclcMapper.xml
...c/main/resources/app/esignHclc/mapper/Lm005HclcMapper.xml
+18
-0
config.properties
core/src/main/resources/config.properties
+5
-1
No files found.
core/src/main/java/com/hand/app/esignHclc/mapper/Lm005HclcMapper.java
View file @
1494b56d
...
@@ -2,6 +2,11 @@ package com.hand.app.esignHclc.mapper;
...
@@ -2,6 +2,11 @@ package com.hand.app.esignHclc.mapper;
import
com.hand.app.esignHclc.dto.Lm005Hclc
;
import
com.hand.app.esignHclc.dto.Lm005Hclc
;
import
com.hand.hap.mybatis.common.Mapper
;
import
com.hand.hap.mybatis.common.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* Created with IntelliJ IDEA.
* Created with IntelliJ IDEA.
...
@@ -10,5 +15,7 @@ import com.hand.hap.mybatis.common.Mapper;
...
@@ -10,5 +15,7 @@ import com.hand.hap.mybatis.common.Mapper;
* Time: 9:08
* Time: 9:08
*/
*/
public
interface
Lm005HclcMapper
extends
Mapper
<
Lm005Hclc
>
{
public
interface
Lm005HclcMapper
extends
Mapper
<
Lm005Hclc
>
{
HashMap
<
String
,
Object
>
selectOneByCtino
(
@Param
(
"ctino"
)
String
ctino
);
void
updateByCtino
(
@Param
(
"ctino"
)
String
ctino
,
@Param
(
"regcap"
)
String
regcap
);
}
}
core/src/main/java/com/hand/app/qcc/controllers/QccRequestsController.java
0 → 100644
View file @
1494b56d
package
com
.
hand
.
app
.
qcc
.
controllers
;
import
com.hand.app.qcc.service.IQccRequestsService
;
import
com.hand.hap.core.IRequest
;
import
com.hand.hap.system.controllers.BaseController
;
import
org.json.JSONObject
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
javax.servlet.http.HttpServletRequest
;
@Controller
@RequestMapping
(
value
=
{
"/r/api"
,
"/"
})
public
class
QccRequestsController
extends
BaseController
{
@Autowired
private
IQccRequestsService
service
;
/**
* 中登网融资租赁-登记入口
**/
@RequestMapping
(
value
=
"/qcc/service/query"
)
@ResponseBody
public
JSONObject
initRegister
(
HttpServletRequest
request
,
@RequestBody
(
required
=
true
)
JSONObject
params
)
{
IRequest
requestContext
=
createRequestContext
(
request
);
return
service
.
qccQueryService
(
requestContext
,
params
);
}
}
\ No newline at end of file
core/src/main/java/com/hand/app/qcc/service/IQccRequestsService.java
0 → 100644
View file @
1494b56d
package
com
.
hand
.
app
.
qcc
.
service
;
import
com.hand.hap.core.IRequest
;
import
com.hand.hap.core.ProxySelf
;
import
org.json.JSONObject
;
public
interface
IQccRequestsService
extends
ProxySelf
<
IQccRequestsService
>{
JSONObject
qccQueryService
(
IRequest
request
,
JSONObject
params
);
}
\ No newline at end of file
core/src/main/java/com/hand/app/qcc/service/impl/QccRequestsServiceImpl.java
0 → 100644
View file @
1494b56d
package
com
.
hand
.
app
.
qcc
.
service
.
impl
;
import
com.hand.app.esignHclc.dto.Lm005Hclc
;
import
com.hand.app.esignHclc.mapper.Lm005HclcMapper
;
import
com.hand.app.qcc.service.IQccRequestsService
;
import
com.hand.app.zhongDengWang.dto.HlsWsRequests
;
import
com.hand.app.zhongDengWang.mapper.HlsWsRequestsMapper
;
import
com.hand.hap.core.IRequest
;
import
org.apache.commons.codec.digest.DigestUtils
;
import
org.json.JSONObject
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
static
java
.
lang
.
System
.
out
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.regex.Pattern
;
import
org.apache.http.client.methods.HttpHead
;
import
org.json.JSONException
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
@Service
public
class
QccRequestsServiceImpl
implements
IQccRequestsService
{
@Autowired
HlsWsRequestsMapper
hlsWsRequestsMapper
;
@Autowired
private
Lm005HclcMapper
lm005HclcMapper
;
@Value
(
"${qcc.api.app.key}"
)
private
String
appkey
;
@Value
(
"${qcc.api.secret.key}"
)
private
String
secretKey
;
@Value
(
"${qcc.api.url}"
)
private
String
reqInterName
;
@Override
public
JSONObject
qccQueryService
(
IRequest
request
,
JSONObject
params
)
{
String
status
;
String
ctino
=
params
.
getString
(
"keyword"
);
String
reqUri
=
reqInterName
.
concat
(
"?key="
).
concat
(
appkey
).
concat
(
"&keyword="
).
concat
(
ctino
);
String
tokenJson
=
getJson
(
reqUri
,
ctino
);
status
=
FormartJson
(
tokenJson
,
"Status"
);
if
(!
HttpCodeRegex
.
isAbnornalRequest
(
status
))
{
PrettyPrintJson
(
tokenJson
);
}
updateLm005Hclc
(
tokenJson
,
ctino
);
return
new
JSONObject
(
tokenJson
);
}
private
void
updateLm005Hclc
(
String
tokenJson
,
String
ctino
)
{
// List<Map<String, Object>> maps = lm005HclcMapper.selectOneByCtino(ctino);
String
registCapi
=
FormartJson
(
tokenJson
,
"RegistCapi"
);
if
(
Objects
.
nonNull
(
registCapi
))
{
lm005HclcMapper
.
updateByCtino
(
ctino
,
registCapi
);
}
}
private
String
getJson
(
String
url
,
String
paramStr
)
{
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"keyword"
,
paramStr
);
HlsWsRequests
hlsWsRequests
=
createRequestLog
(
url
,
json
.
toString
());
String
dataJson
=
null
;
try
{
dataJson
=
sendGetRequest
(
url
);
setResData
(
hlsWsRequests
,
dataJson
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
setErrData
(
hlsWsRequests
,
e
);
}
hlsWsRequestsMapper
.
updateByPrimaryKeySelective
(
hlsWsRequests
);
return
dataJson
;
}
private
String
sendGetRequest
(
String
url
)
throws
IOException
{
String
[]
autherHeader
=
RandomAuthentHeader
();
URL
urlObj
=
new
URL
(
url
);
HttpURLConnection
connection
=
(
HttpURLConnection
)
urlObj
.
openConnection
();
connection
.
setRequestMethod
(
"GET"
);
connection
.
setRequestProperty
(
"Content-Type"
,
"application/json"
);
connection
.
setRequestProperty
(
"Token"
,
autherHeader
[
0
]);
connection
.
setRequestProperty
(
"Timespan"
,
autherHeader
[
1
]);
connection
.
setDoOutput
(
true
);
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
connection
.
getInputStream
()));
String
inputLine
;
StringBuilder
responseBody
=
new
StringBuilder
();
while
((
inputLine
=
in
.
readLine
())
!=
null
)
{
responseBody
.
append
(
inputLine
);
}
in
.
close
();
connection
.
disconnect
();
return
responseBody
.
toString
();
}
// 获取返回码 Res Code
static
class
HttpCodeRegex
{
private
static
final
String
ABNORMAL_REGIX
=
"(101)|(102)"
;
private
static
final
Pattern
pattern
=
Pattern
.
compile
(
ABNORMAL_REGIX
);
protected
static
boolean
isAbnornalRequest
(
final
String
status
)
{
return
pattern
.
matcher
(
status
).
matches
();
}
}
// 获取Auth Code
private
String
[]
RandomAuthentHeader
()
{
String
timeSpan
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
String
[]
authentHeaders
=
new
String
[]
{
DigestUtils
.
md5Hex
(
appkey
.
concat
(
timeSpan
).
concat
(
secretKey
)).
toUpperCase
(),
timeSpan
};
return
authentHeaders
;
}
// 解析JSON
private
String
FormartJson
(
String
jsonString
,
String
key
)
throws
JSONException
{
JSONObject
jObject
=
new
JSONObject
(
jsonString
);
return
(
String
)
jObject
.
get
(
key
);
}
// 日志保存
private
HlsWsRequests
createRequestLog
(
String
url
,
String
requestClob
)
{
HlsWsRequests
hlsWsRequests
=
new
HlsWsRequests
();
hlsWsRequests
.
setRequestDate
(
new
Date
());
hlsWsRequests
.
setRequestWsdlUrl
(
url
);
hlsWsRequests
.
setFunctionName
(
"QCC_QUERY"
);
hlsWsRequests
.
setRequestJson
(
requestClob
);
hlsWsRequests
.
setStatusDate
(
new
Date
());
hlsWsRequests
.
setParameterType
(
"json"
);
hlsWsRequestsMapper
.
insertSelective
(
hlsWsRequests
);
return
hlsWsRequests
;
}
// 设置信息
public
void
setResData
(
HlsWsRequests
hlsWsRequests
,
String
resData
)
{
hlsWsRequests
.
setReturnStatus
(
"S"
);
hlsWsRequests
.
setResponseJson
(
resData
);
hlsWsRequests
.
setResponsedDate
(
new
Date
());
}
// 设置错误信息
public
void
setErrData
(
HlsWsRequests
hlsWsRequests
,
Exception
e
)
{
hlsWsRequests
.
setReturnStatus
(
"F"
);
hlsWsRequests
.
setResponsedDate
(
new
Date
());
hlsWsRequests
.
setResponseJson
(
e
.
getMessage
());
}
// pretty print 返回值
protected
static
void
PrettyPrintJson
(
String
jsonString
)
throws
JSONException
{
try
{
ObjectMapper
mapper
=
new
ObjectMapper
();
Object
obj
=
mapper
.
readValue
(
jsonString
,
Object
.
class
);
String
indented
=
mapper
.
writerWithDefaultPrettyPrinter
().
writeValueAsString
(
obj
);
out
.
println
(
indented
);
}
catch
(
JsonProcessingException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
\ No newline at end of file
core/src/main/resources/app/esignHclc/mapper/Lm005HclcMapper.xml
0 → 100644
View file @
1494b56d
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.hand.app.esignHclc.mapper.Lm005HclcMapper"
>
<select
id=
"selectOneByCtino"
resultType=
"java.util.HashMap"
>
select ctino, webcustomercd, regcap from lm005_hclc
where ctino = #{ctino,javaType=VARCHAR}
</select>
<update
id=
"updateByCtino"
>
update lm005_hclc
set regcap = nvl(#{regcap,javaType=VARCHAR}, -1)
where ctino = #{ctino,javaType=VARCHAR}
</update>
</mapper>
\ No newline at end of file
core/src/main/resources/config.properties
View file @
1494b56d
...
@@ -153,3 +153,7 @@ cup.mer.id=739412105210001
...
@@ -153,3 +153,7 @@ cup.mer.id=739412105210001
cup.upload.file.path
=
E:
\\
HCLC_FTP
\\
CUP_OUT
\\
cup.upload.file.path
=
E:
\\
HCLC_FTP
\\
CUP_OUT
\\
cup.download.file.path
=
E:
\\
HCLC_FTP
\\
CUP_IN
\\
cup.download.file.path
=
E:
\\
HCLC_FTP
\\
CUP_IN
\\
cup.init.file.path
=
D:
\\
app
\\
apache-tomcat-app
\\
key
\\
cup.init.file.path
=
D:
\\
app
\\
apache-tomcat-app
\\
key
\\
qcc.api.url
=
https://api.qichacha.com/ECIV4/GetBasicDetailsByName
qcc.api.app.key
=
appkey
qcc.api.secret.key
=
secretKey
\ No newline at end of file
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