Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
baihang-report
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
data-spider
baihang-report
Commits
44d05d95
Commit
44d05d95
authored
Jun 04, 2021
by
郑建
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加文件报送生成文件接口
parent
9e0ccc01
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
293 additions
and
101 deletions
+293
-101
ManualToolController.java
...cn/quantgroup/report/controller/ManualToolController.java
+5
-40
QuantGroupZhuDaiReportToBaiHang.java
...uantgroup/report/job/QuantGroupZhuDaiReportToBaiHang.java
+1
-1
LoanInfoMapper.java
...a/cn/quantgroup/report/mapper/baihang/LoanInfoMapper.java
+0
-1
RepaymentLoanInfoMapper.java
...tgroup/report/mapper/baihang/RepaymentLoanInfoMapper.java
+1
-2
BaiHangFileReportService.java
...roup/report/service/baihang/BaiHangFileReportService.java
+270
-0
BaiHangZhuDaiService.java
...antgroup/report/service/baihang/BaiHangZhuDaiService.java
+16
-57
No files found.
src/main/java/cn/quantgroup/report/controller/ManualToolController.java
View file @
44d05d95
package
cn
.
quantgroup
.
report
.
controller
;
package
cn
.
quantgroup
.
report
.
controller
;
import
cn.quantgroup.report.response.GlobalResponse
;
import
cn.quantgroup.report.response.GlobalResponse
;
import
cn.quantgroup.report.service.baihang.BaiHangFileReportService
;
import
cn.quantgroup.report.service.baihang.BaiHangZhuDaiService
;
import
cn.quantgroup.report.service.baihang.BaiHangZhuDaiService
;
import
cn.quantgroup.report.service.common.CommonQueryService
;
import
cn.quantgroup.report.service.common.CommonQueryService
;
import
cn.quantgroup.report.service.manualTool.CleanningTransactionLogService
;
import
cn.quantgroup.report.service.manualTool.CleanningTransactionLogService
;
...
@@ -29,11 +30,10 @@ public class ManualToolController {
...
@@ -29,11 +30,10 @@ public class ManualToolController {
@Autowired
@Autowired
BaiHangZhuDaiService
zhuDaiService
;
BaiHangZhuDaiService
zhuDaiService
;
@Autowired
private
CommonQueryService
queryService
;
@Autowired
@Autowired
private
CleanningTransactionLogService
cleanningTransactionLogService
;
private
CleanningTransactionLogService
cleanningTransactionLogService
;
@Autowired
private
BaiHangFileReportService
fileReportService
;
@RequestMapping
(
"/send/baihang"
)
@RequestMapping
(
"/send/baihang"
)
...
@@ -159,43 +159,8 @@ public class ManualToolController {
...
@@ -159,43 +159,8 @@ public class ManualToolController {
}
}
@RequestMapping
(
"/createFile"
)
@RequestMapping
(
"/createFile"
)
public
void
testD2Repost
(){
public
void
testD2Repost
(
String
type
,
String
startDate
,
String
endDate
){
Stopwatch
stopwatch
=
Stopwatch
.
createStarted
();
fileReportService
.
createReportFile
(
type
,
startDate
+
"T00:00:00"
,
endDate
+
"T00:00:00"
);
D2
();
log
.
info
(
"跑了 {}"
,
stopwatch
.
elapsed
(
TimeUnit
.
MILLISECONDS
));
}
//2020-07-01
private
void
D2
(){
String
startTime
=
"2020-06-12"
,
endTime
=
"2020-07-01"
;
Date
startDate
;
Date
endDate
=
DateUtils
.
parseDate
(
"yyyy-MM-dd"
,
endTime
);
while
(
endDate
.
getTime
()
<
System
.
currentTimeMillis
()){
log
.
info
(
"开始报送D2----- {} -- {}"
,
startTime
,
endTime
);
zhuDaiService
.
apiSend
(
"D2"
,
startTime
+
"T00:00:00"
,
endTime
+
"T00:00:00"
);
log
.
info
(
"报送D2结束----- {} -- {}"
,
startTime
,
endTime
);
startDate
=
new
Date
(
endDate
.
getTime
());
endDate
=
org
.
apache
.
commons
.
lang3
.
time
.
DateUtils
.
addMonths
(
endDate
,
1
);
startTime
=
DateUtils
.
formatDate
(
startDate
,
"yyyy-MM-dd"
);
endTime
=
DateUtils
.
formatDate
(
endDate
,
"yyyy-MM-dd"
);
}
}
}
private
void
D3
(){
String
startTime
=
"2020-06-12"
,
endTime
=
"2020-07-01"
;
Date
startDate
;
Date
endDate
=
DateUtils
.
parseDate
(
"yyyy-MM-dd"
,
endTime
);
while
(
endDate
.
getTime
()
<
System
.
currentTimeMillis
()){
log
.
info
(
"开始报送D3----- {} -- {}"
,
startTime
,
endTime
);
zhuDaiService
.
apiSend
(
"D3"
,
startTime
+
"T00:00:00"
,
endTime
+
"T00:00:00"
);
log
.
info
(
"报送D3结束----- {} -- {}"
,
startTime
,
endTime
);
startDate
=
new
Date
(
endDate
.
getTime
());
endDate
=
org
.
apache
.
commons
.
lang3
.
time
.
DateUtils
.
addDays
(
endDate
,
10
);
startTime
=
DateUtils
.
formatDate
(
startDate
,
"yyyy-MM-dd"
);
endTime
=
DateUtils
.
formatDate
(
endDate
,
"yyyy-MM-dd"
);
}
}
}
}
src/main/java/cn/quantgroup/report/job/QuantGroupZhuDaiReportToBaiHang.java
View file @
44d05d95
...
@@ -45,7 +45,7 @@ public class QuantGroupZhuDaiReportToBaiHang {
...
@@ -45,7 +45,7 @@ public class QuantGroupZhuDaiReportToBaiHang {
// @Async
// @Async
//@Scheduled(cron = "0 0 05 * * ?")
//@Scheduled(cron = "0 0 05 * * ?")
//
@Scheduled(cron = "0 0 03 * * ?")
@Scheduled
(
cron
=
"0 0 03 * * ?"
)
public
void
startZhuDaiReport
(){
public
void
startZhuDaiReport
(){
if
(
increment
()){
if
(
increment
()){
redisTemplate
.
expire
(
Constant
.
QG_ZHU_DAI_REPORT_LOCK_KEY
,
10
,
TimeUnit
.
SECONDS
);
redisTemplate
.
expire
(
Constant
.
QG_ZHU_DAI_REPORT_LOCK_KEY
,
10
,
TimeUnit
.
SECONDS
);
...
...
src/main/java/cn/quantgroup/report/mapper/baihang/LoanInfoMapper.java
View file @
44d05d95
...
@@ -59,7 +59,6 @@ public interface LoanInfoMapper {
...
@@ -59,7 +59,6 @@ public interface LoanInfoMapper {
* 创建人: yanhui.Hao <br/>
* 创建人: yanhui.Hao <br/>
* 创建时间: 2019.10.23 <br/>
* 创建时间: 2019.10.23 <br/>
*/
*/
@Deprecated
List
<
LoanInfoZhuDai
>
queryStockLoanInfoZhuDai
(
BaiHangTimeRecord
baiHangTimeRecord
);
List
<
LoanInfoZhuDai
>
queryStockLoanInfoZhuDai
(
BaiHangTimeRecord
baiHangTimeRecord
);
...
...
src/main/java/cn/quantgroup/report/mapper/baihang/RepaymentLoanInfoMapper.java
View file @
44d05d95
...
@@ -32,7 +32,7 @@ public interface RepaymentLoanInfoMapper {
...
@@ -32,7 +32,7 @@ public interface RepaymentLoanInfoMapper {
* 创建人: yanhui.Hao <br/>
* 创建人: yanhui.Hao <br/>
* 创建时间: 2019.10.23 <br/>
* 创建时间: 2019.10.23 <br/>
*/
*/
@Deprecated
List
<
RepaymentInfoZhuDai
>
queryStockRepayMentInfoOverdueZhuDai
(
BaiHangTimeRecord
baiHangTimeRecord
);
List
<
RepaymentInfoZhuDai
>
queryStockRepayMentInfoOverdueZhuDai
(
BaiHangTimeRecord
baiHangTimeRecord
);
...
@@ -43,7 +43,6 @@ public interface RepaymentLoanInfoMapper {
...
@@ -43,7 +43,6 @@ public interface RepaymentLoanInfoMapper {
* 创建人: yanhui.Hao <br/>
* 创建人: yanhui.Hao <br/>
* 创建时间: 2019.10.23 <br/>
* 创建时间: 2019.10.23 <br/>
*/
*/
@Deprecated
List
<
RepaymentInfoZhuDai
>
queryStockRepayMentInfoZhuDai
(
BaiHangTimeRecord
baiHangTimeRecord
);
List
<
RepaymentInfoZhuDai
>
queryStockRepayMentInfoZhuDai
(
BaiHangTimeRecord
baiHangTimeRecord
);
...
...
src/main/java/cn/quantgroup/report/service/baihang/BaiHangFileReportService.java
0 → 100644
View file @
44d05d95
package
cn
.
quantgroup
.
report
.
service
.
baihang
;
import
cn.quantgroup.report.domain.baihang.*
;
import
cn.quantgroup.report.error.QGException
;
import
cn.quantgroup.report.mapper.baihang.ApplyLoanInfoMapper
;
import
cn.quantgroup.report.mapper.baihang.LoanInfoMapper
;
import
cn.quantgroup.report.mapper.baihang.RepaymentLoanInfoMapper
;
import
cn.quantgroup.report.mapper.master.LoanInfoDbMapper
;
import
cn.quantgroup.report.mapper.master.RepaymentLoanInfoDbMapper
;
import
cn.quantgroup.report.service.baihang.client.BhFileCreditApiClient
;
import
cn.quantgroup.report.service.baihang.request.FileUploadRequest
;
import
cn.quantgroup.report.service.baihang.response.FileUploadResponse
;
import
cn.quantgroup.report.service.http.IHttpService
;
import
cn.quantgroup.report.utils.DateUtils
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.common.base.Stopwatch
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Service
;
import
java.io.File
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.UUID
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
static
cn
.
quantgroup
.
report
.
error
.
QGExceptionType
.
COMMON_ILLEGAL_PARAM_TOAST
;
/**
* @author jian.zheng
* @date 2021/6/4 - 15:23
**/
@Slf4j
@Service
public
class
BaiHangFileReportService
{
@Value
(
"${isDebug}"
)
private
Boolean
isDebug
;
@Autowired
public
ApplyLoanInfoMapper
applyLoanInfoMapper
;
@Autowired
public
IHttpService
iHttpService
;
@Autowired
public
LoanInfoMapper
loanInfoMapper
;
@Autowired
public
RepaymentLoanInfoMapper
repaymentLoanInfoMapper
;
@Autowired
public
LoanInfoDbMapper
loanInfoDbMapper
;
@Autowired
public
RepaymentLoanInfoDbMapper
repaymentLoanInfoDbMapper
;
private
static
final
String
HOST_PATH
=
"/home/quantgroup/reportFile/"
;
/**
* 创建报送文件 通常用于存量报送
* @param type 报送类型 A1:申请信息 D2:放款信息 D3:还款信息
* @param startDate 报送区间的开始时间 格式:"2019-05-07T00:00:00"
* @param endDate 报送区间的截止时间 格式:"2019-05-07T00:00:00"
*/
public
void
createReportFile
(
String
type
,
String
startDate
,
String
endDate
)
{
if
(
StringUtils
.
isAnyBlank
(
type
,
startDate
,
endDate
))
{
throw
new
QGException
(
COMMON_ILLEGAL_PARAM_TOAST
,
"存在为空参数"
);
}
if
(
startDate
.
length
()
!=
19
||
endDate
.
length
()
!=
19
||
!
startDate
.
contains
(
"T"
)
||
!
endDate
.
contains
(
"T"
))
{
log
.
warn
(
"日期格式有误, startDate : {} , endDate : {} "
,
startDate
,
endDate
);
throw
new
QGException
(
COMMON_ILLEGAL_PARAM_TOAST
,
"日期格式错误"
);
}
String
starTime
=
LocalDateTime
.
parse
(
startDate
).
format
(
DateTimeFormatter
.
ISO_DATE
);
String
endTime
=
LocalDateTime
.
parse
(
endDate
).
format
(
DateTimeFormatter
.
ISO_DATE
);
if
(
"A1"
.
equalsIgnoreCase
(
type
))
{
reportA1
(
starTime
,
endTime
);
}
else
if
(
"D2"
.
equalsIgnoreCase
(
type
))
{
reportD2
(
starTime
,
endTime
);
}
else
if
(
"D3"
.
equalsIgnoreCase
(
type
))
{
reportD3
(
starTime
,
endTime
);
}
else
{
throw
new
QGException
(
COMMON_ILLEGAL_PARAM_TOAST
,
"报送类型不正确"
);
}
}
/**
* 贷款申请信息(A1) 暂时不支持A1报送
* @param starTime 开始时间
* @param endTime 截止时间
*/
@Async
public
void
reportA1
(
String
starTime
,
String
endTime
){
throw
new
QGException
(
COMMON_ILLEGAL_PARAM_TOAST
,
"报送类型暂不支持"
);
}
/**
* 非循环贷款账户数据信息(D2)
* @param starTime 开始时间
* @param endTime 截至时间
*/
@Async
public
void
reportD2
(
String
starTime
,
String
endTime
)
{
Stopwatch
stopwatch
=
Stopwatch
.
createStarted
();
try
{
List
<
LoanInfoZhuDai
>
loanInfozdList
=
loanInfoMapper
.
queryStockLoanInfoZhuDai
(
BaiHangTimeRecord
.
builder
().
startTime
(
starTime
).
endTime
(
endTime
).
build
());
int
listSize
=
loanInfozdList
!=
null
?
loanInfozdList
.
size
()
:
0
;
log
.
info
(
"百行-助贷放款数据查询结束, listSize : {} , startTime: {} , endTime: {} , 耗时 : {} "
,
listSize
,
starTime
,
endTime
,
stopwatch
.
elapsed
(
TimeUnit
.
MILLISECONDS
));
AtomicInteger
atomicInteger
=
new
AtomicInteger
();
Stopwatch
sendWatch
=
Stopwatch
.
createStarted
();
List
<
String
>
reportList
=
new
ArrayList
<>();
reportList
.
add
(
"#singleLoanAccountInfo"
);
for
(
int
i
=
0
;
i
<
loanInfozdList
.
size
();
i
++)
{
LoanInfoZhuDai
loanInfo
=
loanInfozdList
.
get
(
i
);
String
id
=
""
;
try
{
String
loanInfoReqId
=
loanInfo
.
getReqID
();
List
<
String
>
targetRepaymentDayList
=
loanInfoMapper
.
findTargetRepaymentDayList
(
loanInfoReqId
);
if
(
targetRepaymentDayList
!=
null
&&
targetRepaymentDayList
.
size
()
>
0
)
{
loanInfo
.
setTargetRepayDateList
(
String
.
join
(
","
,
targetRepaymentDayList
));
log
.
info
(
"比较还款总期数&账单日列表totalTerm="
+
loanInfo
.
getTotalTerm
()
+
",targetRepaymentDayList size="
+
targetRepaymentDayList
.
size
());
}
else
{
log
.
warn
(
"比较还款总期数&账单日列表totalTerm="
+
loanInfo
.
getTotalTerm
()
+
",targetRepaymentDayList is null."
);
}
UUID
loanInfoId
=
UUID
.
randomUUID
();
id
=
loanInfoId
.
toString
().
replaceAll
(
"-"
,
""
);
try
{
LoanInfoZhuDai
record
=
new
LoanInfoZhuDai
();
BeanUtils
.
copyProperties
(
loanInfo
,
record
);
record
.
setRecordId
(
id
);
loanInfoDbMapper
.
saveLoanInfoRecordLog
(
record
);
}
catch
(
Exception
e
)
{
log
.
error
(
"量化派助贷TO百行报送-放款申请保存记录失败"
,
e
);
}
String
jsonStr
=
JSONObject
.
toJSONString
(
loanInfo
);
LoanInfoZhuDaiVo
loanInfoVo
=
JSONObject
.
parseObject
(
jsonStr
,
LoanInfoZhuDaiVo
.
class
);
FinTechAgencyBusinessZhuDai
finTechAgencyBusiness
=
JSONObject
.
parseObject
(
jsonStr
,
FinTechAgencyBusinessZhuDai
.
class
);
loanInfoVo
.
setFinTechAgencyBusiness
(
finTechAgencyBusiness
);
loanInfoVo
.
setReqID
(
id
);
loanInfoVo
.
setName
(
sensitiveFilter
(
loanInfo
.
getName
()));
loanInfoVo
.
setPid
(
sensitiveFilter
(
loanInfo
.
getPid
()));
loanInfoVo
.
setMobile
(
sensitiveFilter
(
loanInfo
.
getMobile
()));
if
(
DateUtils
.
parseDate
(
"yyyy-MM-dd'T'HH:mm:ss"
,
loanInfoVo
.
getIssueDate
()).
getTime
()
<
DateUtils
.
parseDate
(
"yyyy-MM-dd'T'HH:mm:ss"
,
loanInfoVo
.
getAccountOpenDate
()).
getTime
()){
loanInfoVo
.
setAccountOpenDate
(
loanInfoVo
.
getIssueDate
());
loanInfoVo
.
setApplyDate
(
loanInfoVo
.
getIssueDate
());
}
reportList
.
add
(
JSON
.
toJSONString
(
loanInfoVo
));
atomicInteger
.
getAndIncrement
();
}
catch
(
Exception
e
)
{
log
.
error
(
"量化派助贷TO百行报送-放款信息异常, recordId: {} , loanId: {} "
,
id
,
loanInfo
.
getLoanId
(),
e
);
}
}
File
file
=
new
File
(
"D3-3S\\量子数科科技有限公司_D2_"
+
endTime
.
split
(
"T"
)[
0
].
replaceAll
(
"-"
,
""
)+
"_0002"
+
".txt"
);
FileUtils
.
writeLines
(
file
,
reportList
);
createFile
(
file
.
getName
());
log
.
info
(
"量化派助贷TO百行报送-放款申请完成, 实际大小: {} , 报送成功大小: {} , 耗时: {} "
,
loanInfozdList
.
size
(),
atomicInteger
.
get
(),
sendWatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
));
}
catch
(
Exception
e
)
{
log
.
error
(
"量化派助贷TO百行报送-异常"
,
e
);
}
}
/**
* 非循环贷款贷后数据信息(D3)
* @param startTime 开始时间
* @param endTime 截止时间
*/
@Async
public
void
reportD3
(
String
startTime
,
String
endTime
)
{
for
(
int
j
=
0
;
j
<
2
;
j
++)
{
List
<
String
>
reportList
=
new
ArrayList
<>();
reportList
.
add
(
"#singleLoanRepayInfo"
);
Stopwatch
sendWatch
=
Stopwatch
.
createStarted
();
try
{
List
<
RepaymentInfoZhuDai
>
repaymentLoanInfos
=
null
;
if
(
j
==
0
)
{
Stopwatch
stopwatch
=
Stopwatch
.
createStarted
();
repaymentLoanInfos
=
repaymentLoanInfoMapper
.
queryStockRepayMentInfoZhuDai
(
BaiHangTimeRecord
.
builder
().
startTime
(
startTime
).
endTime
(
endTime
).
build
());
log
.
info
(
"百行-助贷还款查询结束, startTime: {} , endTime: {} , 大小: {} , 耗时: {} "
,
startTime
,
endTime
,
repaymentLoanInfos
.
size
(),
(
stopwatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
)
/
1000
)
+
".s"
);
}
else
{
Stopwatch
stopwatch
=
Stopwatch
.
createStarted
();
repaymentLoanInfos
=
repaymentLoanInfoMapper
.
queryStockRepayMentInfoOverdueZhuDai
(
BaiHangTimeRecord
.
builder
().
startTime
(
startTime
).
endTime
(
endTime
).
build
());
log
.
info
(
"百行-助贷还款查询逾期结束, startTime: {} , endTime: {} , 大小: {} , 耗时: {} "
,
startTime
,
endTime
,
repaymentLoanInfos
.
size
(),
(
stopwatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
)
/
1000
)
+
".s"
);
}
AtomicInteger
atomicInteger
=
new
AtomicInteger
();
for
(
int
i
=
0
;
i
<
repaymentLoanInfos
.
size
();
i
++)
{
RepaymentInfoZhuDai
repaymentLoanInfo
=
repaymentLoanInfos
.
get
(
i
);
String
id
=
""
;
try
{
RepaymentInfoZhuDai
repaymentLoanInfo1
=
repaymentLoanInfoDbMapper
.
findLastOne
(
BaiHangRepayment
.
builder
().
loanId
(
repaymentLoanInfo
.
getLoanId
()).
termNo
(
repaymentLoanInfo
.
getTermNo
()).
build
());
if
(
j
>
0
&&
Objects
.
nonNull
(
repaymentLoanInfo1
))
{
log
.
info
(
"量化派助贷TO百行报送-实时还款逾期跳过报送, startTime: {} , endTime: {} , bean: {} "
,
startTime
,
endTime
,
JSON
.
toJSONString
(
repaymentLoanInfo1
));
continue
;
}
id
=
UUID
.
randomUUID
().
toString
().
replaceAll
(
"-"
,
""
);
try
{
RepaymentInfoZhuDai
record
=
new
RepaymentInfoZhuDai
();
BeanUtils
.
copyProperties
(
repaymentLoanInfo
,
record
);
record
.
setRecordId
(
id
);
repaymentLoanInfoDbMapper
.
saveRepaymentLoanInfoLog
(
record
);
}
catch
(
Exception
e
)
{
log
.
error
(
"量化派助贷TO百行报送-实时还款保存记录异常"
,
e
);
}
repaymentLoanInfo
.
setReqID
(
id
);
repaymentLoanInfo
.
setName
(
sensitiveFilter
(
repaymentLoanInfo
.
getName
()));
repaymentLoanInfo
.
setPid
(
sensitiveFilter
(
repaymentLoanInfo
.
getPid
()));
repaymentLoanInfo
.
setMobile
(
sensitiveFilter
(
repaymentLoanInfo
.
getMobile
()));
atomicInteger
.
getAndIncrement
();
reportList
.
add
(
JSON
.
toJSONString
(
repaymentLoanInfo
));
}
catch
(
Exception
e
)
{
log
.
error
(
"量化派助贷TO百行报送-还款信息异常, recordId: {} , loanId: {} "
,
id
,
repaymentLoanInfo
.
getLoanId
(),
e
);
}
}
File
file
=
new
File
(
"D3-3S\\量子数科科技有限公司_D3_"
+
endTime
.
split
(
"T"
)[
0
].
replaceAll
(
"-"
,
""
)+
"_"
+
"0003"
+
".txt"
);
FileUtils
.
writeLines
(
file
,
reportList
);
createFile
(
file
.
getName
());
log
.
info
(
"量化派助贷TO百行报送-还款申请完成 J: {} , 开始时间: {} , 结束时间: {} , 实际大小: {} , 报送成功大小: {} , 耗时: {} "
,
j
,
startTime
,
endTime
,
repaymentLoanInfos
.
size
(),
atomicInteger
.
get
(),
sendWatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
));
}
catch
(
Exception
e
)
{
log
.
error
(
"量化派助贷TO百行报送-异常 J: {} , 开始时间: {} , 结束时间: {} "
,
j
,
startTime
,
endTime
,
e
);
}
}
}
/**
* 根据传入的文件路径将加密后的文件生成到 {@link BaiHangFileReportService#HOST_PATH}中
* @param filePath 需要加密的文件路径
*/
private
static
void
createFile
(
String
filePath
){
File
host
=
new
File
(
HOST_PATH
);
if
(!
host
.
exists
()){
host
.
mkdir
();
}
//AES密钥(机构自行设置)
String
aesKey
=
"fc4c1cbca5a46840f60"
;
FileUploadRequest
req
=
new
FileUploadRequest
();
//设置未作压缩加密前的原始数据文件路径
req
.
setDataFile
(
filePath
);
//设置压缩加密后的密文文件输出路径(为空表示与原始数据文件同目录)
req
.
setTargetFilePath
(
HOST_PATH
);
BhFileCreditApiClient
client
=
new
BhFileCreditApiClient
();
//初始化设置AES密钥和RSA公钥
client
.
init
(
BaiHangZhuDaiService
.
getBaihangZDPublickey
(),
aesKey
);
//执行压缩加密操作
FileUploadResponse
response
=
client
.
execute
(
req
);
if
(
response
.
isSuccess
){
System
.
out
.
println
(
"zip And encrypt success;fileName = "
+
response
.
getEncryptFilePath
()
+
response
.
getEncryptFileName
());
}
else
{
System
.
out
.
println
(
"zip And encrypt fail;errorMessage = "
+
response
.
getErrorMessage
());
}
}
private
String
sensitiveFilter
(
String
s
){
if
(
isDebug
){
if
(
StringUtils
.
isNumeric
(
s
)
||
s
.
contains
(
"X"
)
||
s
.
contains
(
"x"
)){
return
s
.
substring
(
0
,
s
.
length
()-
4
)+
"0000"
;
}
else
{
return
s
.
charAt
(
0
)+
"零"
;
}
}
else
{
return
s
;
}
}
}
src/main/java/cn/quantgroup/report/service/baihang/BaiHangZhuDaiService.java
View file @
44d05d95
...
@@ -135,8 +135,11 @@ public class BaiHangZhuDaiService {
...
@@ -135,8 +135,11 @@ public class BaiHangZhuDaiService {
private
static
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd'T'HH:mm:ss"
);
private
static
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd'T'HH:mm:ss"
);
private
static
String
PUBLIC_KEY_PATH
;
@Autowired
@Autowired
private
JdbcTemplate
riskDatasourceJdbcTemplate
;
private
JdbcTemplate
riskDatasourceJdbcTemplate
;
@Value
(
"${isDebug}"
)
private
Boolean
isDebug
;
//众信利民助贷报送的资方id
//众信利民助贷报送的资方id
private
static
Integer
[]
fundingCorpIds
={
420
,
520
,
580
,
650
,
670
,
810
,
240
,
640
,
700
,
1080
,
100040
,
1030
,
100030
};
//"420,520,580,650,670,810,240,640,700"
private
static
Integer
[]
fundingCorpIds
={
420
,
520
,
580
,
650
,
670
,
810
,
240
,
640
,
700
,
1080
,
100040
,
1030
,
100030
};
//"420,520,580,650,670,810,240,640,700"
...
@@ -147,10 +150,10 @@ public class BaiHangZhuDaiService {
...
@@ -147,10 +150,10 @@ public class BaiHangZhuDaiService {
@PostConstruct
@PostConstruct
public
void
init
()
{
public
void
init
()
{
try
{
try
{
long
log_stUtc1
=
System
.
currentTimeMillis
();
long
log_stUtc1
=
System
.
currentTimeMillis
();
baihang_zhudai_publickey
=
BHRSAUtils
.
readRSAPublicKey
(
"/baihang/rsa_public_key.pem"
);
PUBLIC_KEY_PATH
=
isDebug
?
"/baihang/rsa_public_key_test.pem"
:
"/baihang/rsa_public_key.pem"
;
baihang_zhudai_publickey
=
BHRSAUtils
.
readRSAPublicKey
(
PUBLIC_KEY_PATH
);
log
.
info
(
"初始化百行助贷PublicKey实例完成, 耗时: {} "
,
System
.
currentTimeMillis
()
-
log_stUtc1
);
log
.
info
(
"初始化百行助贷PublicKey实例完成, 耗时: {} "
,
System
.
currentTimeMillis
()
-
log_stUtc1
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"初始化百行助贷PublicKey实例"
,
e
);
log
.
error
(
"初始化百行助贷PublicKey实例"
,
e
);
...
@@ -160,7 +163,7 @@ public class BaiHangZhuDaiService {
...
@@ -160,7 +163,7 @@ public class BaiHangZhuDaiService {
public
static
PublicKey
getBaihangZDPublickey
()
{
public
static
PublicKey
getBaihangZDPublickey
()
{
if
(
baihang_zhudai_publickey
==
null
)
{
if
(
baihang_zhudai_publickey
==
null
)
{
try
{
try
{
baihang_zhudai_publickey
=
BHRSAUtils
.
readRSAPublicKey
(
"/baihang/rsa_public_key.pem"
);
baihang_zhudai_publickey
=
BHRSAUtils
.
readRSAPublicKey
(
PUBLIC_KEY_PATH
);
log
.
info
(
"初始化百行助贷PublicKey实例完成"
);
log
.
info
(
"初始化百行助贷PublicKey实例完成"
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"初始化百行助贷PublicKey实例"
,
e
);
log
.
error
(
"初始化百行助贷PublicKey实例"
,
e
);
...
@@ -1986,51 +1989,8 @@ public class BaiHangZhuDaiService {
...
@@ -1986,51 +1989,8 @@ public class BaiHangZhuDaiService {
if
(
logBeanList
.
size
()
==
1
)
{
if
(
logBeanList
.
size
()
==
1
)
{
logBean
=
logBeanList
.
get
(
0
);
logBean
=
logBeanList
.
get
(
0
);
}
else
{
}
else
{
/* List<RepaymentLoanInfoLog> logBeanList_2 = new ArrayList<>();
for(RepaymentLoanInfoLog log : logBeanList){
if("M".equals(log.getOpCode())){
logBeanList_2.add(log);
}
}
if(logBeanList_2.size()==1){
logBean = logBeanList_2.get(0);
}else {
//M的方式
if(logBeanList_2.size()>1){
Collections.sort(logBeanList_2, new Comparator<RepaymentLoanInfoLog>() {
public int compare(RepaymentLoanInfoLog o1, RepaymentLoanInfoLog o2) {
//按时间进行降序排列
if (o1.getUpdatedAt().getTime() > o2.getUpdatedAt().getTime()) {
return -1;
}
if (o1.getUpdatedAt().getTime() == o2.getUpdatedAt().getTime()) {
return 0;
}
return 1;
}
});
logBean = logBeanList_2.get(0);
}
//A的方式
else{
Collections.sort(logBeanList, new Comparator<RepaymentLoanInfoLog>() {
public int compare(RepaymentLoanInfoLog o1, RepaymentLoanInfoLog o2) {
//按时间进行降序排列
if (o1.getUpdatedAt().getTime() > o2.getUpdatedAt().getTime()) {
return -1;
}
if (o1.getUpdatedAt().getTime() == o2.getUpdatedAt().getTime()) {
return 0;
}
return 1;
}
});
logBean = logBeanList.get(0);
}
}*/
Collections
.
sort
(
logBeanList
,
new
Comparator
<
RepaymentLoanInfoLog
>()
{
Collections
.
sort
(
logBeanList
,
new
Comparator
<
RepaymentLoanInfoLog
>()
{
@Override
public
int
compare
(
RepaymentLoanInfoLog
o1
,
RepaymentLoanInfoLog
o2
)
{
public
int
compare
(
RepaymentLoanInfoLog
o1
,
RepaymentLoanInfoLog
o2
)
{
//按时间进行降序排列
//按时间进行降序排列
if
(
o1
.
getUpdatedAt
().
getTime
()
>
o2
.
getUpdatedAt
().
getTime
())
{
if
(
o1
.
getUpdatedAt
().
getTime
()
>
o2
.
getUpdatedAt
().
getTime
())
{
...
@@ -2084,6 +2044,7 @@ public class BaiHangZhuDaiService {
...
@@ -2084,6 +2044,7 @@ public class BaiHangZhuDaiService {
logBean_jq
=
logBeanList_jq
.
get
(
0
);
logBean_jq
=
logBeanList_jq
.
get
(
0
);
}
else
{
}
else
{
Collections
.
sort
(
logBeanList_jq
,
new
Comparator
<
RepaymentLoanInfoLog
>()
{
Collections
.
sort
(
logBeanList_jq
,
new
Comparator
<
RepaymentLoanInfoLog
>()
{
@Override
public
int
compare
(
RepaymentLoanInfoLog
o1
,
RepaymentLoanInfoLog
o2
)
{
public
int
compare
(
RepaymentLoanInfoLog
o1
,
RepaymentLoanInfoLog
o2
)
{
//按时间进行降序排列
//按时间进行降序排列
if
(
o1
.
getUpdatedAt
().
getTime
()
>
o2
.
getUpdatedAt
().
getTime
())
{
if
(
o1
.
getUpdatedAt
().
getTime
()
>
o2
.
getUpdatedAt
().
getTime
())
{
...
@@ -2149,7 +2110,7 @@ public class BaiHangZhuDaiService {
...
@@ -2149,7 +2110,7 @@ public class BaiHangZhuDaiService {
//相同不用报送
//相同不用报送
if
(
s_hisStr
.
equals
(
s_newStr
))
{
if
(
s_hisStr
.
equals
(
s_newStr
))
{
repaymentLoanInfo
.
setUploadTs
(
uploadTs_2
);
repaymentLoanInfo
.
setUploadTs
(
uploadTs_2
);
this
.
wirteFile
(
writeFilePath
+
file_
+
"_XT.txt"
,
JSON
.
toJSONString
(
repaymentLoanInfo
)
+
"\r\n"
);
wirteFile
(
writeFilePath
+
file_
+
"_XT.txt"
,
JSON
.
toJSONString
(
repaymentLoanInfo
)
+
"\r\n"
);
}
else
{
}
else
{
//不同,需要报送
//不同,需要报送
log
.
info
(
"查询比较两次报送数据不相同, 修改以M报送, filePath: {} , loanId: {} , termNo: {} , logBean: {} , 数据log_run: {} , "
,
file_
,
loanId
,
termNo
,
JSON
.
toJSONString
(
logBean
),
hisStr
.
toString
()
+
"|"
+
newStr
.
toString
());
log
.
info
(
"查询比较两次报送数据不相同, 修改以M报送, filePath: {} , loanId: {} , termNo: {} , logBean: {} , 数据log_run: {} , "
,
file_
,
loanId
,
termNo
,
JSON
.
toJSONString
(
logBean
),
hisStr
.
toString
()
+
"|"
+
newStr
.
toString
());
...
@@ -2178,9 +2139,9 @@ public class BaiHangZhuDaiService {
...
@@ -2178,9 +2139,9 @@ public class BaiHangZhuDaiService {
if
(
log_history_reqID
!=
null
&&
log_history_reqID
.
length
()
>
1
)
{
if
(
log_history_reqID
!=
null
&&
log_history_reqID
.
length
()
>
1
)
{
repaymentLoanInfo
.
setRecordId
(
log_history_reqID
);
repaymentLoanInfo
.
setRecordId
(
log_history_reqID
);
this
.
wirteFile
(
writeFilePath
+
file_
+
"_M.txt"
,
JSON
.
toJSONString
(
repaymentLoanInfo
)
+
"\r\n"
);
wirteFile
(
writeFilePath
+
file_
+
"_M.txt"
,
JSON
.
toJSONString
(
repaymentLoanInfo
)
+
"\r\n"
);
}
else
{
}
else
{
this
.
wirteFile
(
writeFilePath
+
file_
+
"_M_notfind_log_history_reqID.txt"
,
JSON
.
toJSONString
(
repaymentLoanInfo
)
+
"\r\n"
);
wirteFile
(
writeFilePath
+
file_
+
"_M_notfind_log_history_reqID.txt"
,
JSON
.
toJSONString
(
repaymentLoanInfo
)
+
"\r\n"
);
}
}
}
}
...
@@ -2189,8 +2150,6 @@ public class BaiHangZhuDaiService {
...
@@ -2189,8 +2150,6 @@ public class BaiHangZhuDaiService {
log
.
warn
(
"根据参数查询报送日志筛选数据为空, 新增以A报送, filePath: {} , loanId: {} , termNo: {} "
,
filePath
,
loanId
,
termNo
);
log
.
warn
(
"根据参数查询报送日志筛选数据为空, 新增以A报送, filePath: {} , loanId: {} , termNo: {} "
,
filePath
,
loanId
,
termNo
);
repaymentLoanInfo
.
setOpCode
(
"A"
);
repaymentLoanInfo
.
setOpCode
(
"A"
);
//repaymentLoanInfo.setRecordId(UUID.randomUUID().toString().replaceAll("-", ""));
LocalDateTime
nowTime
=
LocalDateTime
.
now
();
LocalDateTime
nowTime
=
LocalDateTime
.
now
();
repaymentLoanInfo
.
setUploadTs
(
nowTime
.
format
(
formatter
));
repaymentLoanInfo
.
setUploadTs
(
nowTime
.
format
(
formatter
));
...
@@ -2211,7 +2170,7 @@ public class BaiHangZhuDaiService {
...
@@ -2211,7 +2170,7 @@ public class BaiHangZhuDaiService {
}
}
}
}
this
.
wirteFile
(
writeFilePath
+
file_
+
"_A.txt"
,
JSON
.
toJSONString
(
repaymentLoanInfo
)
+
"\r\n"
);
wirteFile
(
writeFilePath
+
file_
+
"_A.txt"
,
JSON
.
toJSONString
(
repaymentLoanInfo
)
+
"\r\n"
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -2274,9 +2233,9 @@ public class BaiHangZhuDaiService {
...
@@ -2274,9 +2233,9 @@ public class BaiHangZhuDaiService {
if
(
StringUtils
.
isEmpty
(
repaymentLoanInfo
.
getRecordId
()))
{
if
(
StringUtils
.
isEmpty
(
repaymentLoanInfo
.
getRecordId
()))
{
repaymentLoanInfo
.
setRecordId
(
UUID
.
randomUUID
().
toString
().
replaceAll
(
"-"
,
""
));
repaymentLoanInfo
.
setRecordId
(
UUID
.
randomUUID
().
toString
().
replaceAll
(
"-"
,
""
));
}
}
this
.
wirteFile
(
writeFilePath
+
file_
+
"_ok.txt"
,
JSON
.
toJSONString
(
repaymentLoanInfo
)
+
"\r\n"
);
wirteFile
(
writeFilePath
+
file_
+
"_ok.txt"
,
JSON
.
toJSONString
(
repaymentLoanInfo
)
+
"\r\n"
);
}
else
{
}
else
{
this
.
wirteFile
(
writeFilePath
+
file_
+
"_isEmpty.txt"
,
JSON
.
toJSONString
(
repaymentLoanInfo
)
+
"\r\n"
);
wirteFile
(
writeFilePath
+
file_
+
"_isEmpty.txt"
,
JSON
.
toJSONString
(
repaymentLoanInfo
)
+
"\r\n"
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"在到d2中查询d3数据异常, loanId: {} "
,
repaymentLoanInfo
.
getLoanId
(),
e
);
log
.
error
(
"在到d2中查询d3数据异常, loanId: {} "
,
repaymentLoanInfo
.
getLoanId
(),
e
);
...
@@ -2320,7 +2279,7 @@ public class BaiHangZhuDaiService {
...
@@ -2320,7 +2279,7 @@ public class BaiHangZhuDaiService {
repaymentLoanInfo
.
setReqID
(
repaymentLoanInfo
.
getRecordId
());
repaymentLoanInfo
.
setReqID
(
repaymentLoanInfo
.
getRecordId
());
repaymentLoanInfo
.
setRecordId
(
null
);
repaymentLoanInfo
.
setRecordId
(
null
);
this
.
wirteFile
(
writeFilePath
,
JSON
.
toJSONString
(
repaymentLoanInfo
)
+
"\r\n"
);
wirteFile
(
writeFilePath
,
JSON
.
toJSONString
(
repaymentLoanInfo
)
+
"\r\n"
);
saveCount
++;
saveCount
++;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"保存还款数据记录失败, fileName: {} , DATA: {} , 第i: {} "
,
filePath
,
strJson
,
i
,
e
);
log
.
error
(
"保存还款数据记录失败, fileName: {} , DATA: {} , 第i: {} "
,
filePath
,
strJson
,
i
,
e
);
...
@@ -2357,7 +2316,7 @@ public class BaiHangZhuDaiService {
...
@@ -2357,7 +2316,7 @@ public class BaiHangZhuDaiService {
}
}
RepaymentInfoZhuDai
repaymentLoanInfo
=
new
Gson
().
fromJson
(
strJson
,
new
TypeToken
<
RepaymentInfoZhuDai
>()
{
RepaymentInfoZhuDai
repaymentLoanInfo
=
new
Gson
().
fromJson
(
strJson
,
new
TypeToken
<
RepaymentInfoZhuDai
>()
{
}.
getType
());
}.
getType
());
this
.
wirteFile
(
writeFilePath
,
JSON
.
toJSONString
(
repaymentLoanInfo
)
+
"\r\n"
);
wirteFile
(
writeFilePath
,
JSON
.
toJSONString
(
repaymentLoanInfo
)
+
"\r\n"
);
saveCount
++;
saveCount
++;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"d3_build2写数据记录失败, fileName: {} , DATA: {} , 第i: {} "
,
filePath
,
strJson
,
i
,
e
);
log
.
error
(
"d3_build2写数据记录失败, fileName: {} , DATA: {} , 第i: {} "
,
filePath
,
strJson
,
i
,
e
);
...
...
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