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
e6c20717
Commit
e6c20717
authored
Jan 08, 2022
by
陈宏杰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
老数据脱敏
parent
d665b8dc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
2 deletions
+67
-2
BaiHangDataDisposeController.java
...group/report/controller/BaiHangDataDisposeController.java
+10
-0
BaiHangDataDisposeService.java
...oup/report/service/baihang/BaiHangDataDisposeService.java
+55
-0
BaiHangFileReportService.java
...roup/report/service/baihang/BaiHangFileReportService.java
+2
-2
No files found.
src/main/java/cn/quantgroup/report/controller/BaiHangDataDisposeController.java
View file @
e6c20717
...
@@ -25,4 +25,14 @@ public class BaiHangDataDisposeController {
...
@@ -25,4 +25,14 @@ public class BaiHangDataDisposeController {
}
}
}
}
@PostMapping
(
"/encryptFieldAndCreateFile"
)
public
String
encryptFieldAndCreateFile
(
String
sourceCollectFileName
,
String
sourceFilePath
,
String
targetFilePath
){
try
{
baiHangDataDisposeService
.
encryptFieldAndCreateFile
(
sourceCollectFileName
,
sourceFilePath
,
targetFilePath
);
return
"SUCCESS"
;
}
catch
(
Exception
e
){
return
e
.
getMessage
();
}
}
}
}
src/main/java/cn/quantgroup/report/service/baihang/BaiHangDataDisposeService.java
View file @
e6c20717
...
@@ -3,8 +3,11 @@ package cn.quantgroup.report.service.baihang;
...
@@ -3,8 +3,11 @@ package cn.quantgroup.report.service.baihang;
import
cn.hutool.core.io.IoUtil
;
import
cn.hutool.core.io.IoUtil
;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.json.JSONUtil
;
import
cn.quantgroup.report.domain.baihang.ApplyLoanInfoZhuDai
;
import
cn.quantgroup.report.domain.baihang.ApplyLoanInfoZhuDai
;
import
cn.quantgroup.report.domain.baihang.LoanInfoZhuDaiVo
;
import
cn.quantgroup.report.domain.baihang.RepaymentInfoZhuDai
;
import
cn.quantgroup.report.mapper.master.ApplyLoanInfoZhuDaiMapper
;
import
cn.quantgroup.report.mapper.master.ApplyLoanInfoZhuDaiMapper
;
import
cn.quantgroup.report.utils.DateUtils
;
import
cn.quantgroup.report.utils.DateUtils
;
import
com.alibaba.fastjson.JSON
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.io.FileUtils
;
...
@@ -29,6 +32,8 @@ public class BaiHangDataDisposeService {
...
@@ -29,6 +32,8 @@ public class BaiHangDataDisposeService {
private
static
final
String
HOST_PATH
=
"/home/quant_group/reportFile/"
;
private
static
final
String
HOST_PATH
=
"/home/quant_group/reportFile/"
;
private
static
final
Integer
INITIAL_CAPACITY
=
5000
;
@Autowired
@Autowired
private
BaiHangFileReportService
baiHangFileReportService
;
private
BaiHangFileReportService
baiHangFileReportService
;
@Autowired
@Autowired
...
@@ -74,4 +79,54 @@ public class BaiHangDataDisposeService {
...
@@ -74,4 +79,54 @@ public class BaiHangDataDisposeService {
}
}
}
}
@Async
public
void
encryptFieldAndCreateFile
(
String
sourceCollectFileName
,
String
sourceFilePath
,
String
targetFilePath
)
throws
Exception
{
File
collectFile
=
new
File
(
sourceFilePath
+
sourceCollectFileName
);
File
subFile
=
null
;
String
dataStr
=
null
,
contentStr
=
null
;
BufferedReader
bis
=
null
;
LoanInfoZhuDaiVo
loanInfoZhuDaiVo
=
null
;
RepaymentInfoZhuDai
repaymentInfoZhuDai
=
null
;
List
<
String
>
reportList
=
null
;
List
<
String
>
fileNameList
=
FileUtils
.
readLines
(
collectFile
,
"utf-8"
);
for
(
String
fileName
:
fileNameList
)
{
if
(
StringUtils
.
isNotBlank
(
fileName
))
{
reportList
=
new
ArrayList
<>(
INITIAL_CAPACITY
);
subFile
=
new
File
(
sourceFilePath
+
fileName
.
replace
(
"-R.cry"
,
".txt"
));
bis
=
new
BufferedReader
(
new
FileReader
(
subFile
));
while
(
null
!=
(
dataStr
=
bis
.
readLine
()))
{
if
(
StringUtils
.
isNotBlank
(
dataStr
))
{
if
(
StringUtils
.
equalsAny
(
dataStr
,
"#applyInfo"
,
"#singleLoanAccountInfo"
,
"#singleLoanRepayInfo"
))
{
contentStr
=
dataStr
;
}
else
{
if
(
dataStr
.
equals
(
"#applyInfo"
))
{
}
else
if
(
dataStr
.
equals
(
"#singleLoanAccountInfo"
))
{
loanInfoZhuDaiVo
=
JSONUtil
.
toBean
(
dataStr
,
LoanInfoZhuDaiVo
.
class
);
loanInfoZhuDaiVo
.
setName
(
baiHangFileReportService
.
sensitiveFilter
(
loanInfoZhuDaiVo
.
getName
()));
loanInfoZhuDaiVo
.
setPid
(
baiHangFileReportService
.
sensitiveFilter
(
loanInfoZhuDaiVo
.
getPid
()));
loanInfoZhuDaiVo
.
setMobile
(
baiHangFileReportService
.
sensitiveFilter
(
loanInfoZhuDaiVo
.
getMobile
()));
contentStr
=
JSON
.
toJSONString
(
loanInfoZhuDaiVo
);
}
else
if
(
dataStr
.
equals
(
"#singleLoanRepayInfo"
))
{
repaymentInfoZhuDai
=
JSONUtil
.
toBean
(
dataStr
,
RepaymentInfoZhuDai
.
class
);
repaymentInfoZhuDai
.
setName
(
baiHangFileReportService
.
sensitiveFilter
(
repaymentInfoZhuDai
.
getName
()));
repaymentInfoZhuDai
.
setPid
(
baiHangFileReportService
.
sensitiveFilter
(
repaymentInfoZhuDai
.
getPid
()));
repaymentInfoZhuDai
.
setMobile
(
baiHangFileReportService
.
sensitiveFilter
(
repaymentInfoZhuDai
.
getMobile
()));
contentStr
=
JSON
.
toJSONString
(
repaymentInfoZhuDai
);
}
}
reportList
.
add
(
contentStr
);
}
}
File
file
=
new
File
(
targetFilePath
+
fileName
.
replace
(
"-R.cry"
,
".txt"
));
FileUtils
.
writeLines
(
file
,
reportList
);
if
(
reportList
.
size
()>
1
)
{
baiHangFileReportService
.
createFile
(
file
.
getAbsolutePath
());
}
}
}
IoUtil
.
close
(
bis
);
log
.
info
(
"encryptFieldAndCreateFile数据处理完成,集合文件名 {}"
,
sourceCollectFileName
);
}
}
}
src/main/java/cn/quantgroup/report/service/baihang/BaiHangFileReportService.java
View file @
e6c20717
...
@@ -502,7 +502,7 @@ public class BaiHangFileReportService {
...
@@ -502,7 +502,7 @@ public class BaiHangFileReportService {
* 根据传入的文件路径将加密后的文件生成到 {@link BaiHangFileReportService#HOST_PATH}中
* 根据传入的文件路径将加密后的文件生成到 {@link BaiHangFileReportService#HOST_PATH}中
* @param filePath 需要加密的文件路径
* @param filePath 需要加密的文件路径
*/
*/
p
rivate
stat
ic
String
createFile
(
String
filePath
){
p
ubl
ic
String
createFile
(
String
filePath
){
String
encryptFileName
=
null
;
String
encryptFileName
=
null
;
log
.
info
(
"创建加密文件,明文文件路径 {}"
,
filePath
);
log
.
info
(
"创建加密文件,明文文件路径 {}"
,
filePath
);
File
host
=
new
File
(
HOST_PATH
);
File
host
=
new
File
(
HOST_PATH
);
...
@@ -531,7 +531,7 @@ public class BaiHangFileReportService {
...
@@ -531,7 +531,7 @@ public class BaiHangFileReportService {
return
encryptFileName
;
return
encryptFileName
;
}
}
p
rivate
String
sensitiveFilter
(
String
s
){
p
ublic
String
sensitiveFilter
(
String
s
){
if
(
isDebug
){
if
(
isDebug
){
if
(
StringUtils
.
isNumeric
(
s
)
||
s
.
contains
(
"X"
)
||
s
.
contains
(
"x"
)){
if
(
StringUtils
.
isNumeric
(
s
)
||
s
.
contains
(
"X"
)
||
s
.
contains
(
"x"
)){
return
s
.
substring
(
0
,
s
.
length
()-
4
)+
"0000"
;
return
s
.
substring
(
0
,
s
.
length
()-
4
)+
"0000"
;
...
...
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