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
a1c81687
Commit
a1c81687
authored
Dec 20, 2022
by
5359
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加异常处理和初始化代码处理
parent
c57b51d2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
89 additions
and
57 deletions
+89
-57
PingAnServiceImpl.java
...a/com/hand/app/pingAn/service/impl/PingAnServiceImpl.java
+89
-57
No files found.
core/src/main/java/com/hand/app/pingAn/service/impl/PingAnServiceImpl.java
View file @
a1c81687
...
@@ -25,6 +25,8 @@ import com.hand.hap.system.dto.ResponseData;
...
@@ -25,6 +25,8 @@ import com.hand.hap.system.dto.ResponseData;
import
com.pingan.openbank.api.sdk.client.ApiClient
;
import
com.pingan.openbank.api.sdk.client.ApiClient
;
import
com.pingan.openbank.api.sdk.common.http.HttpResult
;
import
com.pingan.openbank.api.sdk.common.http.HttpResult
;
import
com.pingan.openbank.api.sdk.entity.*
;
import
com.pingan.openbank.api.sdk.entity.*
;
import
com.pingan.openbank.api.sdk.exception.OpenBankSdkException
;
import
com.pingan.openbank.api.sdk.exception.OpenBankSdkException
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
...
@@ -50,7 +52,11 @@ public class PingAnServiceImpl implements PingAnService {
...
@@ -50,7 +52,11 @@ public class PingAnServiceImpl implements PingAnService {
private
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
private
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
private
static
JSONObject
baseReqBody
=
new
JSONObject
();
private
static
Properties
pro
=
null
;
private
static
Properties
pro
=
null
;
private
static
Calendar
cal
=
null
;
private
static
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"yyyyMMddHHmmssSSS"
);
static
{
static
{
String
path
=
Thread
.
currentThread
().
getContextClassLoader
().
getResource
(
""
).
getPath
().
substring
(
1
);
String
path
=
Thread
.
currentThread
().
getContextClassLoader
().
getResource
(
""
).
getPath
().
substring
(
1
);
...
@@ -58,7 +64,11 @@ public class PingAnServiceImpl implements PingAnService {
...
@@ -58,7 +64,11 @@ public class PingAnServiceImpl implements PingAnService {
if
(
Objects
.
isNull
(
pro
))
{
if
(
Objects
.
isNull
(
pro
))
{
LoggerFactory
.
getLogger
(
HclcCmbPolyServiceImpl
.
class
).
error
(
"配置文件初始化异常"
);
LoggerFactory
.
getLogger
(
HclcCmbPolyServiceImpl
.
class
).
error
(
"配置文件初始化异常"
);
}
}
baseReqBody
.
put
(
"MrchCode"
,
pro
.
getProperty
(
"MrchCode"
));
baseReqBody
.
put
(
"MainAccount"
,
pro
.
getProperty
(
"AcctNo"
));
}
}
/**
/**
* @param interfaceName
* @param interfaceName
* @param params
* @param params
...
@@ -67,55 +77,66 @@ public class PingAnServiceImpl implements PingAnService {
...
@@ -67,55 +77,66 @@ public class PingAnServiceImpl implements PingAnService {
@Override
@Override
public
JSONObject
invoke
(
String
interfaceName
,
JSONObject
params
)
{
public
JSONObject
invoke
(
String
interfaceName
,
JSONObject
params
)
{
JSONObject
responseData
=
new
JSONObject
();
JSONObject
responseData
=
new
JSONObject
();
JSONObject
requestBody
=
ApiUtils
.
getBaseReqBody
();
// JSONObject requestBody = ApiUtils.getBaseReqBody();
JSONObject
requestBody
=
baseReqBody
.
clone
();
cal
=
Calendar
.
getInstance
();
String
today
=
df
.
format
(
cal
.
getTime
());
requestBody
.
put
(
"CnsmrSeqNo"
,
today
+
"000"
);
requestBody
.
putAll
(
params
);
requestBody
.
putAll
(
params
);
/*插入接口日志表*/
/*插入接口日志表*/
HlsWsRequests
hlsWsRequests
=
new
HlsWsRequests
();
HlsWsRequests
hlsWsRequests
=
new
HlsWsRequests
();
hlsWsRequests
=
createRequestLog
(
pro
.
getProperty
(
"baseUrl"
)+
"/V1.0/"
+
interfaceName
,
requestBody
.
toJSONString
(),
1L
);
hlsWsRequests
=
createRequestLog
(
pro
.
getProperty
(
"baseUrl"
)
+
"/V1.0/"
+
interfaceName
,
requestBody
.
toJSONString
(),
1L
);
HttpResult
result
=
ApiUtils
.
invoke
(
interfaceName
,
requestBody
);
try
{
if
(
Objects
.
nonNull
(
result
))
{
HttpResult
result
=
ApiUtils
.
invoke
(
interfaceName
,
requestBody
);
// 通信成功
if
(
Objects
.
nonNull
(
result
))
{
if
(
"200"
.
equals
(
result
.
getCode
()
+
""
))
{
// 通信成功
JSONObject
res
=
JSONObject
.
parseObject
(
result
.
getData
());
if
(
"200"
.
equals
(
result
.
getCode
()
+
""
))
{
switch
(
interfaceName
)
{
JSONObject
res
=
JSONObject
.
parseObject
(
result
.
getData
());
case
"bedl/SubAcctMaintenance"
:
switch
(
interfaceName
)
{
hlsWsRequests
.
setFunctionName
(
"pingAn_SubAcctMaintenance"
);
case
"bedl/SubAcctMaintenance"
:
break
;
hlsWsRequests
.
setFunctionName
(
"pingAn_SubAcctMaintenance"
);
case
"bedl/InquiryIntoTheCurrentDetailsOfMainSubaccountAccountTwo"
:
break
;
hlsWsRequests
.
setFunctionName
(
"pingAn_recentDetailQuery"
);
case
"bedl/InquiryIntoTheCurrentDetailsOfMainSubaccountAccountTwo"
:
break
;
hlsWsRequests
.
setFunctionName
(
"pingAn_recentDetailQuery"
);
case
"bedl/DetailReportQueryNew"
:
break
;
hlsWsRequests
.
setFunctionName
(
"pingAn_DetailReportQueryNew"
);
case
"bedl/DetailReportQueryNew"
:
break
;
hlsWsRequests
.
setFunctionName
(
"pingAn_DetailReportQueryNew"
);
}
break
;
responseData
.
put
(
"data"
,
res
);
// 具体业务是否请求成功判定,目前观察成功请求可能没有Code值
if
(
"000000"
.
equals
(
res
.
getString
(
"Code"
))
||
Objects
.
isNull
(
res
.
getString
(
"Code"
))){
if
(
"bedl/DetailReportQueryNew"
.
equals
(
interfaceName
)){
dowloadDetailFile
(
res
);
}
}
hlsWsRequests
.
setReturnStatus
(
"s"
);
responseData
.
put
(
"data"
,
res
);
responseData
.
put
(
Constants
.
RESP_CODE
,
"0000"
);
// 具体业务是否请求成功判定,目前观察成功请求可能没有Code值
responseData
.
put
(
"respMsg"
,
"请求成功"
);
if
(
"000000"
.
equals
(
res
.
getString
(
"Code"
))
||
Objects
.
isNull
(
res
.
getString
(
"Code"
)))
{
}
else
{
if
(
"bedl/DetailReportQueryNew"
.
equals
(
interfaceName
))
{
//粗略的报错 如:"Message":"业务处理失败(通讯成功)","Code":"E50000"
dowloadDetailFile
(
res
);
responseData
.
put
(
Constants
.
RESP_CODE
,
res
.
getString
(
"Code"
));
}
responseData
.
put
(
Constants
.
RESP_MSG
,
res
.
getString
(
"Message"
));
hlsWsRequests
.
setReturnStatus
(
"s"
);
if
(
Objects
.
nonNull
(
res
.
getJSONArray
(
"Errors"
))){
responseData
.
put
(
Constants
.
RESP_CODE
,
"0000"
);
//详情报错 如:"ErrorCode":"CE3887","ErrorMessage":":[CE3887]清分台账编码[30206688123456]记录已存在
responseData
.
put
(
"respMsg"
,
"请求成功"
);
responseData
.
put
(
Constants
.
RESP_CODE
,
res
.
getJSONArray
(
"Errors"
).
getJSONObject
(
0
).
getString
(
"ErrorCode"
));
}
else
{
responseData
.
put
(
Constants
.
RESP_MSG
,
res
.
getJSONArray
(
"Errors"
).
getJSONObject
(
0
).
getString
(
"ErrorMessage"
));
//粗略的报错 如:"Message":"业务处理失败(通讯成功)","Code":"E50000"
responseData
.
put
(
Constants
.
RESP_CODE
,
res
.
getString
(
"Code"
));
responseData
.
put
(
Constants
.
RESP_MSG
,
res
.
getString
(
"Message"
));
if
(
Objects
.
nonNull
(
res
.
getJSONArray
(
"Errors"
)))
{
//详情报错 如:"ErrorCode":"CE3887","ErrorMessage":":[CE3887]清分台账编码[30206688123456]记录已存在
responseData
.
put
(
Constants
.
RESP_CODE
,
res
.
getJSONArray
(
"Errors"
).
getJSONObject
(
0
).
getString
(
"ErrorCode"
));
responseData
.
put
(
Constants
.
RESP_MSG
,
res
.
getJSONArray
(
"Errors"
).
getJSONObject
(
0
).
getString
(
"ErrorMessage"
));
}
}
}
}
else
{
//请求失败
hlsWsRequests
.
setReturnStatus
(
"f"
);
JSONObject
errRes
=
JSONObject
.
parseObject
(
result
.
getData
());
responseData
.
put
(
Constants
.
RESP_CODE
,
result
.
getCode
());
responseData
.
put
(
Constants
.
RESP_MSG
,
"请求失败"
);
}
}
}
else
{
hlsWsRequests
.
setResponseJson
(
result
.
getData
());
//请求失败
hlsWsRequests
.
setResponsedDate
(
new
Date
());
hlsWsRequests
.
setReturnStatus
(
"f"
);
JSONObject
errRes
=
JSONObject
.
parseObject
(
result
.
getData
());
responseData
.
put
(
Constants
.
RESP_CODE
,
result
.
getCode
());
responseData
.
put
(
Constants
.
RESP_MSG
,
"请求失败"
);
}
}
hlsWsRequests
.
setResponseJson
(
result
.
getData
());
}
catch
(
OpenBankSdkException
e
)
{
hlsWsRequests
.
setResponsedDate
(
new
Date
());
hlsWsRequests
.
setReturnStatus
(
"E"
);
responseData
.
put
(
Constants
.
RESP_CODE
,
e
.
getCode
());
responseData
.
put
(
Constants
.
RESP_MSG
,
e
.
getMessage
());
}
}
//更新日志
//更新日志
hlsWsRequestsMapper
.
updateByPrimaryKeySelective
(
hlsWsRequests
);
hlsWsRequestsMapper
.
updateByPrimaryKeySelective
(
hlsWsRequests
);
...
@@ -123,16 +144,16 @@ public class PingAnServiceImpl implements PingAnService {
...
@@ -123,16 +144,16 @@ public class PingAnServiceImpl implements PingAnService {
}
}
public
ResponseData
detailNotify
(
IRequest
iRequest
,
JSONObject
data
){
public
ResponseData
detailNotify
(
IRequest
iRequest
,
JSONObject
data
)
{
ResponseData
responseData
=
new
ResponseData
();
ResponseData
responseData
=
new
ResponseData
();
if
(
Objects
.
nonNull
(
data
)
&&
data
.
size
()
>
0
){
if
(
Objects
.
nonNull
(
data
)
&&
data
.
size
()
>
0
)
{
// 存表
// 存表
HlsEbankCcbTransaction
hlsEbankCcbTransaction
=
saveTransaction
(
iRequest
,
data
);
HlsEbankCcbTransaction
hlsEbankCcbTransaction
=
saveTransaction
(
iRequest
,
data
);
// 调用系统的接口服务,推送通知数据
// 调用系统的接口服务,推送通知数据
postNotify
(
JSONObject
.
toJSONString
(
hlsEbankCcbTransaction
));
postNotify
(
JSONObject
.
toJSONString
(
hlsEbankCcbTransaction
));
responseData
.
setSuccess
(
true
);
responseData
.
setSuccess
(
true
);
responseData
.
setMessage
(
"接收成功"
);
responseData
.
setMessage
(
"接收成功"
);
}
else
{
}
else
{
responseData
.
setSuccess
(
false
);
responseData
.
setSuccess
(
false
);
responseData
.
setMessage
(
"接收失败"
);
responseData
.
setMessage
(
"接收失败"
);
}
}
...
@@ -186,15 +207,25 @@ public class PingAnServiceImpl implements PingAnService {
...
@@ -186,15 +207,25 @@ public class PingAnServiceImpl implements PingAnService {
private
HlsEbankCcbTransaction
saveTransaction
(
IRequest
iRequest
,
JSONObject
data
)
{
private
HlsEbankCcbTransaction
saveTransaction
(
IRequest
iRequest
,
JSONObject
data
)
{
HlsEbankCcbTransaction
ccbTransaction
=
new
HlsEbankCcbTransaction
();
HlsEbankCcbTransaction
ccbTransaction
=
new
HlsEbankCcbTransaction
();
ccbTransaction
.
setStatus
(
"SUCCESS"
);
ccbTransaction
.
setNewDate
(
new
Date
());
ccbTransaction
.
setSuccessDate
(
new
Date
());
ccbTransaction
.
setAmount
(
data
.
getDouble
(
"STT_VCH_AMT"
));
ccbTransaction
.
setCount
(
1L
);
ccbTransaction
.
setReturnCode
(
"SUCCESS"
);
ccbTransaction
.
setReturnMsg
(
"交易成功"
);
ccbTransaction
.
setBankType
(
"PAB"
);
ccbTransaction
.
setMerId
(
ApiUtils
.
AcctNo
);
ccbTransaction
.
setMerId
(
ApiUtils
.
AcctNo
);
ccbTransaction
.
setSttVchCardNo
(
data
.
getString
(
"STT_VCH_CARD_NO"
));
ccbTransaction
.
setSttAcDate
(
data
.
getString
(
"STT_AC_DATE"
));
ccbTransaction
.
setTranDate
(
data
.
getString
(
"STT_TR_TIME"
));
ccbTransaction
.
setMerOrderNo
(
data
.
getString
(
"STT_CONSUMER_SEQ_NO"
));
ccbTransaction
.
setMerOrderNo
(
data
.
getString
(
"STT_CONSUMER_SEQ_NO"
));
ccbTransaction
.
setVersion
(
data
.
getString
(
"STT_AC_DATE"
));
ccbTransaction
.
setTranDate
(
data
.
getString
(
"STT_TR_TIME"
));
ccbTransaction
.
setTranType
(
data
.
getString
(
"STT_VCH_SIGN"
));
/*订单状态接收成功*/
ccbTransaction
.
setOrderStatus
(
"R"
);
ccbTransaction
.
setCmbOrderId
(
data
.
getString
(
"STT_JRN_NO"
));
ccbTransaction
.
setCmbOrderId
(
data
.
getString
(
"STT_JRN_NO"
));
ccbTransaction
.
setSttVchCardNo
(
data
.
getString
(
"STT_VCH_CARD_NO"
));
ccbTransaction
.
setSttAcDate
(
data
.
getString
(
"STT_AC_DATE"
));
ccbTransaction
.
setSttVchSeqNo
(
data
.
getString
(
"STT_VCH_SEQ_NO"
));
ccbTransaction
.
setSttVchSeqNo
(
data
.
getString
(
"STT_VCH_SEQ_NO"
));
ccbTransaction
.
setTranType
(
data
.
getString
(
"STT_VCH_SIGN"
));
ccbTransaction
.
setAmount
(
data
.
getDouble
(
"STT_VCH_AMT"
));
ccbTransaction
.
setSttAmtRmb
(
data
.
getDouble
(
"STT_AMT_RMB"
));
ccbTransaction
.
setSttAmtRmb
(
data
.
getDouble
(
"STT_AMT_RMB"
));
ccbTransaction
.
setSttVchBal
(
data
.
getDouble
(
"STT_VCH_BAL"
));
ccbTransaction
.
setSttVchBal
(
data
.
getDouble
(
"STT_VCH_BAL"
));
ccbTransaction
.
setSttVchRcvAcNo
(
data
.
getString
(
"STT_VCH_RCV_AC_NO"
));
ccbTransaction
.
setSttVchRcvAcNo
(
data
.
getString
(
"STT_VCH_RCV_AC_NO"
));
...
@@ -208,7 +239,7 @@ public class PingAnServiceImpl implements PingAnService {
...
@@ -208,7 +239,7 @@ public class PingAnServiceImpl implements PingAnService {
}
}
//下载回单文件
//下载回单文件
private
void
dowloadDetailFile
(
JSONObject
data
){
private
void
dowloadDetailFile
(
JSONObject
data
)
{
JSONArray
arr
=
data
.
getJSONArray
(
"list"
);
JSONArray
arr
=
data
.
getJSONArray
(
"list"
);
//转换成orderFile对象
//转换成orderFile对象
if
(
Objects
.
nonNull
(
arr
))
{
if
(
Objects
.
nonNull
(
arr
))
{
...
@@ -226,6 +257,7 @@ public class PingAnServiceImpl implements PingAnService {
...
@@ -226,6 +257,7 @@ public class PingAnServiceImpl implements PingAnService {
/**
/**
* 近期明细查询
* 近期明细查询
*
* @param interfaceName
* @param interfaceName
* @param params
* @param params
* @return
* @return
...
@@ -234,15 +266,15 @@ public class PingAnServiceImpl implements PingAnService {
...
@@ -234,15 +266,15 @@ public class PingAnServiceImpl implements PingAnService {
JSONObject
responseData
=
new
JSONObject
();
JSONObject
responseData
=
new
JSONObject
();
int
pageNo
=
0
;
int
pageNo
=
0
;
String
isEnd
=
"N"
;
String
isEnd
=
"N"
;
while
(
"N"
.
equalsIgnoreCase
(
isEnd
))
{
while
(
"N"
.
equalsIgnoreCase
(
isEnd
))
{
params
.
put
(
"PageNo"
,++
pageNo
);
params
.
put
(
"PageNo"
,
++
pageNo
);
JSONObject
res
=
invoke
(
interfaceName
,
params
);
JSONObject
res
=
invoke
(
interfaceName
,
params
);
isEnd
=
res
.
getString
(
"isEnd"
);
isEnd
=
res
.
getString
(
"isEnd"
);
// 对当前查询到的数据进行存表
// 对当前查询到的数据进行存表
JSONObject
data
=
res
.
getJSONObject
(
"data"
);
JSONObject
data
=
res
.
getJSONObject
(
"data"
);
JSONArray
arr
=
data
.
getJSONArray
(
"list"
);
JSONArray
arr
=
data
.
getJSONArray
(
"list"
);
if
(
Objects
.
nonNull
(
arr
)){
if
(
Objects
.
nonNull
(
arr
))
{
batchSaveTransactionByC00602
(
iRequest
,
arr
);
batchSaveTransactionByC00602
(
iRequest
,
arr
);
}
}
}
}
responseData
.
put
(
Constants
.
RESP_CODE
,
"0000"
);
responseData
.
put
(
Constants
.
RESP_CODE
,
"0000"
);
...
@@ -257,7 +289,7 @@ public class PingAnServiceImpl implements PingAnService {
...
@@ -257,7 +289,7 @@ public class PingAnServiceImpl implements PingAnService {
ccbTransaction
.
setCmbOrderId
(
data
.
getString
(
"JournalNo"
));
ccbTransaction
.
setCmbOrderId
(
data
.
getString
(
"JournalNo"
));
ccbTransaction
.
setTranType
(
data
.
getString
(
"DCFlag"
));
ccbTransaction
.
setTranType
(
data
.
getString
(
"DCFlag"
));
int
exist
=
hlsEbankCcbTransactionMapper
.
queryByCmbOrderId
(
ccbTransaction
);
int
exist
=
hlsEbankCcbTransactionMapper
.
queryByCmbOrderId
(
ccbTransaction
);
if
(
exist
==
0
){
if
(
exist
==
0
)
{
ccbTransaction
.
setMerId
(
ApiUtils
.
AcctNo
);
ccbTransaction
.
setMerId
(
ApiUtils
.
AcctNo
);
ccbTransaction
.
setSttVchCardNo
(
data
.
getString
(
"SubAccount"
));
ccbTransaction
.
setSttVchCardNo
(
data
.
getString
(
"SubAccount"
));
ccbTransaction
.
setSttAcDate
(
data
.
getString
(
"AccountDate"
));
ccbTransaction
.
setSttAcDate
(
data
.
getString
(
"AccountDate"
));
...
...
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