Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qg-bl-service
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
data-spider
qg-bl-service
Commits
e2e34483
Commit
e2e34483
authored
Apr 29, 2020
by
郝彦辉
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2020.04.29黑灰名单数据更新增加钉钉通知
parent
10fd2d1e
Changes
11
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
1731 additions
and
39 deletions
+1731
-39
BlackGreyListJob.java
...quantgroup/qgblservice/job/blimport/BlackGreyListJob.java
+11
-6
BlackGreyListServiceImpl.java
...up/qgblservice/service/impl/BlackGreyListServiceImpl.java
+23
-12
BlackToGreyListParallel.java
...oup/qgblservice/service/impl/BlackToGreyListParallel.java
+54
-7
ThirdPartBlackListServiceImpl.java
...blservice/service/impl/ThirdPartBlackListServiceImpl.java
+5
-0
UpdateBlackListOverdueDayParallel.java
...rvice/service/impl/UpdateBlackListOverdueDayParallel.java
+55
-14
DingException.java
.../quantgroup/qgblservice/utils/dingding/DingException.java
+47
-0
DingTalk.java
...va/cn/quantgroup/qgblservice/utils/dingding/DingTalk.java
+154
-0
HttpRequestUtil.java
...cn/quantgroup/qgblservice/utils/http/HttpRequestUtil.java
+1185
-0
QGException.java
...ava/cn/quantgroup/qgblservice/utils/http/QGException.java
+116
-0
QGExceptionType.java
...cn/quantgroup/qgblservice/utils/http/QGExceptionType.java
+61
-0
RiskHttpResponse.java
...n/quantgroup/qgblservice/utils/http/RiskHttpResponse.java
+20
-0
No files found.
src/main/java/cn/quantgroup/qgblservice/job/blimport/BlackGreyListJob.java
View file @
e2e34483
package
cn
.
quantgroup
.
qgblservice
.
job
.
blimport
;
package
cn
.
quantgroup
.
qgblservice
.
job
.
blimport
;
import
cn.quantgroup.qgblservice.constant.Constant
;
import
cn.quantgroup.qgblservice.constant.ConstantBlackGrey
;
import
cn.quantgroup.qgblservice.constant.ConstantBlackGrey
;
import
cn.quantgroup.qgblservice.service.IBlackGreyListService
;
import
cn.quantgroup.qgblservice.service.IBlackGreyListService
;
import
cn.quantgroup.qgblservice.
service.IBlackListManagerService
;
import
cn.quantgroup.qgblservice.
utils.dingding.DingTalk
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -34,6 +33,8 @@ public class BlackGreyListJob {
...
@@ -34,6 +33,8 @@ public class BlackGreyListJob {
@Autowired
@Autowired
private
IBlackGreyListService
blackGreyListService
;
private
IBlackGreyListService
blackGreyListService
;
@Autowired
private
DingTalk
dingTalk
;
private
Boolean
increment
(
String
key
){
private
Boolean
increment
(
String
key
){
Long
increment
=
redisTemplate
.
opsForValue
().
increment
(
key
,
1
);
Long
increment
=
redisTemplate
.
opsForValue
().
increment
(
key
,
1
);
...
@@ -81,7 +82,7 @@ public class BlackGreyListJob {
...
@@ -81,7 +82,7 @@ public class BlackGreyListJob {
if
(
increment
(
ConstantBlackGrey
.
REDIS_KEY
.
JOB_ADD_BLACK_LIST_INCREMENT_KEY
)){
if
(
increment
(
ConstantBlackGrey
.
REDIS_KEY
.
JOB_ADD_BLACK_LIST_INCREMENT_KEY
)){
redisTemplate
.
expire
(
ConstantBlackGrey
.
REDIS_KEY
.
JOB_ADD_BLACK_LIST_INCREMENT_KEY
,
10
,
TimeUnit
.
SECONDS
);
redisTemplate
.
expire
(
ConstantBlackGrey
.
REDIS_KEY
.
JOB_ADD_BLACK_LIST_INCREMENT_KEY
,
10
,
TimeUnit
.
SECONDS
);
//yyyy-MM-dd
//yyyy-MM-dd
String
todayNyr
=
LocalDateTime
.
now
().
format
(
DateTimeFormatter
.
ISO_DATE
_TIME
);
String
todayNyr
=
LocalDateTime
.
now
().
format
(
DateTimeFormatter
.
ISO_DATE
);
long
statUtc
=
0L
;
long
statUtc
=
0L
;
//1、导入-现金分期15+逾期黑名单 约耗时65866.ms
//1、导入-现金分期15+逾期黑名单 约耗时65866.ms
...
@@ -94,6 +95,7 @@ public class BlackGreyListJob {
...
@@ -94,6 +95,7 @@ public class BlackGreyListJob {
log
.
error
(
todayNyr
+
", 每天执行新增现金分期15+逾期黑名单异常"
,
e
);
log
.
error
(
todayNyr
+
", 每天执行新增现金分期15+逾期黑名单异常"
,
e
);
}
finally
{
}
finally
{
log
.
info
(
todayNyr
+
", 每天执行新增现金分期15+逾期黑名单结束, Msg: {} , 总耗时: {} "
,
xianJinDai
,
(
System
.
currentTimeMillis
()-
statUtc
)+
".ms"
);
log
.
info
(
todayNyr
+
", 每天执行新增现金分期15+逾期黑名单结束, Msg: {} , 总耗时: {} "
,
xianJinDai
,
(
System
.
currentTimeMillis
()-
statUtc
)+
".ms"
);
dingTalk
.
talkByWebHook
(
DingTalk
.
WEBHOOK_BLACKGREY
,
"Info"
,
DingTalk
.
TITLETAGS_BLACKGREY
,
"导入"
+
todayNyr
+
"现金贷黑名单结束"
,
xianJinDai
);
}
}
//2、导入-Vcc15+逾期黑名单 约耗时14369.ms
//2、导入-Vcc15+逾期黑名单 约耗时14369.ms
...
@@ -106,10 +108,11 @@ public class BlackGreyListJob {
...
@@ -106,10 +108,11 @@ public class BlackGreyListJob {
log
.
error
(
todayNyr
+
", 每天执行新增Vcc15+逾期黑名单异常"
,
e
);
log
.
error
(
todayNyr
+
", 每天执行新增Vcc15+逾期黑名单异常"
,
e
);
}
finally
{
}
finally
{
log
.
info
(
todayNyr
+
", 每天执行新增Vcc15+逾期黑名单结束, Msg: {} , 总耗时: {} "
,
vcc
,
(
System
.
currentTimeMillis
()-
statUtc
)+
".ms"
);
log
.
info
(
todayNyr
+
", 每天执行新增Vcc15+逾期黑名单结束, Msg: {} , 总耗时: {} "
,
vcc
,
(
System
.
currentTimeMillis
()-
statUtc
)+
".ms"
);
dingTalk
.
talkByWebHook
(
DingTalk
.
WEBHOOK_BLACKGREY
,
"Info"
,
DingTalk
.
TITLETAGS_BLACKGREY
,
"导入"
+
todayNyr
+
"VCC黑名单结束"
,
vcc
);
}
}
//3、将逾期已还清黑名单转灰名单 耗时1206283.ms 约20分钟
//3、将逾期已还清黑名单转灰名单 耗时1206283.ms 约20分钟
1588550
String
removeBlackToGrey
=
null
;
String
removeBlackToGrey
=
null
;
try
{
try
{
statUtc
=
System
.
currentTimeMillis
();
statUtc
=
System
.
currentTimeMillis
();
...
@@ -119,6 +122,7 @@ public class BlackGreyListJob {
...
@@ -119,6 +122,7 @@ public class BlackGreyListJob {
log
.
error
(
todayNyr
+
", 每天执行将逾期已还清黑名单转灰名单异常"
,
e
);
log
.
error
(
todayNyr
+
", 每天执行将逾期已还清黑名单转灰名单异常"
,
e
);
}
finally
{
}
finally
{
log
.
info
(
todayNyr
+
", 每天执行将逾期已还清黑名单转灰名单结束, Msg: {} , 总耗时: {} "
,
removeBlackToGrey
,
(
System
.
currentTimeMillis
()-
statUtc
)+
".ms"
);
log
.
info
(
todayNyr
+
", 每天执行将逾期已还清黑名单转灰名单结束, Msg: {} , 总耗时: {} "
,
removeBlackToGrey
,
(
System
.
currentTimeMillis
()-
statUtc
)+
".ms"
);
dingTalk
.
talkByWebHook
(
DingTalk
.
WEBHOOK_BLACKGREY
,
"Info"
,
DingTalk
.
TITLETAGS_BLACKGREY
,
"转移"
+
todayNyr
+
"黑名单转灰名单结束"
,
removeBlackToGrey
);
}
}
...
@@ -198,7 +202,7 @@ public class BlackGreyListJob {
...
@@ -198,7 +202,7 @@ public class BlackGreyListJob {
//判断是否有执行
//判断是否有执行
if
(
getRedisValStr
(
ConstantBlackGrey
.
REDIS_KEY
.
SIGN_IS_RUN_UPDATE_BLACK_OVERDUEDAY_KEY
))
{
if
(
getRedisValStr
(
ConstantBlackGrey
.
REDIS_KEY
.
SIGN_IS_RUN_UPDATE_BLACK_OVERDUEDAY_KEY
))
{
//yyyy-MM-dd
//yyyy-MM-dd
String
todayNyr
=
LocalDateTime
.
now
().
format
(
DateTimeFormatter
.
ISO_DATE
_TIME
);
String
todayNyr
=
LocalDateTime
.
now
().
format
(
DateTimeFormatter
.
ISO_DATE
);
long
statUtc
=
System
.
currentTimeMillis
();
long
statUtc
=
System
.
currentTimeMillis
();
String
updateBLOverdueDay
=
null
;
String
updateBLOverdueDay
=
null
;
...
@@ -206,13 +210,14 @@ public class BlackGreyListJob {
...
@@ -206,13 +210,14 @@ public class BlackGreyListJob {
//删掉执行标记
//删掉执行标记
redisTemplate
.
delete
(
ConstantBlackGrey
.
REDIS_KEY
.
SIGN_IS_RUN_UPDATE_BLACK_OVERDUEDAY_KEY
);
redisTemplate
.
delete
(
ConstantBlackGrey
.
REDIS_KEY
.
SIGN_IS_RUN_UPDATE_BLACK_OVERDUEDAY_KEY
);
//耗时3807471.ms 约64分钟,
//耗时3807471.ms 约64分钟,
3648346.ms
updateBLOverdueDay
=
blackGreyListService
.
updateBlackListOverdueDay
();
updateBLOverdueDay
=
blackGreyListService
.
updateBlackListOverdueDay
();
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
log
.
error
(
todayNyr
+
", 每天执行更新黑名单最大逾期天数和累计逾期天数异常"
,
e
);
log
.
error
(
todayNyr
+
", 每天执行更新黑名单最大逾期天数和累计逾期天数异常"
,
e
);
}
finally
{
}
finally
{
redisTemplate
.
delete
(
ConstantBlackGrey
.
REDIS_KEY
.
SIGN_IS_RUN_UPDATE_BLACK_OVERDUEDAY_KEY
);
redisTemplate
.
delete
(
ConstantBlackGrey
.
REDIS_KEY
.
SIGN_IS_RUN_UPDATE_BLACK_OVERDUEDAY_KEY
);
log
.
info
(
todayNyr
+
", 每天执行更新黑名单最大逾期天数和累计逾期天结束, Msg: {} , 总耗时: {} "
,
updateBLOverdueDay
,
(
System
.
currentTimeMillis
()-
statUtc
)+
".ms"
);
log
.
info
(
todayNyr
+
", 每天执行更新黑名单最大逾期天数和累计逾期天结束, Msg: {} , 总耗时: {} "
,
updateBLOverdueDay
,
(
System
.
currentTimeMillis
()-
statUtc
)+
".ms"
);
dingTalk
.
talkByWebHook
(
DingTalk
.
WEBHOOK_BLACKGREY
,
"Info"
,
DingTalk
.
TITLETAGS_BLACKGREY
,
"更新"
+
todayNyr
+
"黑名单最大逾期天数和累计逾期天结束"
,
updateBLOverdueDay
);
}
}
}
}
...
...
src/main/java/cn/quantgroup/qgblservice/service/impl/BlackGreyListServiceImpl.java
View file @
e2e34483
...
@@ -516,7 +516,8 @@ public class BlackGreyListServiceImpl implements IBlackGreyListService {
...
@@ -516,7 +516,8 @@ public class BlackGreyListServiceImpl implements IBlackGreyListService {
public
String
importXianJinDaiBlackGreyList
()
{
public
String
importXianJinDaiBlackGreyList
()
{
Stopwatch
queryStopwatch
=
Stopwatch
.
createStarted
();
Stopwatch
queryStopwatch
=
Stopwatch
.
createStarted
();
List
<
TmpBlackGreyList
>
xjdBlackGreyList
=
xyqbJdbcTemplate
.
query
(
ConstantBlackGrey
.
SQL
.
XYQB_QUERY_XianJinDai_15DAY
,
new
BeanPropertyRowMapper
<>(
TmpBlackGreyList
.
class
));
List
<
TmpBlackGreyList
>
xjdBlackGreyList
=
xyqbJdbcTemplate
.
query
(
ConstantBlackGrey
.
SQL
.
XYQB_QUERY_XianJinDai_15DAY
,
new
BeanPropertyRowMapper
<>(
TmpBlackGreyList
.
class
));
log
.
info
(
"每天执行-现金分期15+逾期用户黑名单-查询结束, listSize: {} , 耗时: {} "
,
xjdBlackGreyList
.
size
(),
queryStopwatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
));
long
queryCost
=
queryStopwatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
);
log
.
info
(
"每天执行-现金分期15+逾期用户黑名单-查询结束, listSize: {} , 耗时: {} "
,
xjdBlackGreyList
.
size
(),
queryCost
);
Stopwatch
checkStopwatch
=
Stopwatch
.
createStarted
();
Stopwatch
checkStopwatch
=
Stopwatch
.
createStarted
();
List
<
TmpBlackGreyList
>
newIncreasedList
=
new
ArrayList
<>();
List
<
TmpBlackGreyList
>
newIncreasedList
=
new
ArrayList
<>();
...
@@ -553,10 +554,11 @@ public class BlackGreyListServiceImpl implements IBlackGreyListService {
...
@@ -553,10 +554,11 @@ public class BlackGreyListServiceImpl implements IBlackGreyListService {
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
}
log
.
info
(
"每天执行-现金分期15+逾期用户黑名单-插入结束, listSize: {} , details_haveCount: {} , newIncreasedList: {} , saveOkCount: {} , 耗时: {} "
,
xjdBlackGreyList
.
size
(),
details_haveCount
.
get
(),
newIncreasedList
.
size
(),
saveOkCount
,
saveStopwatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
));
long
saveCost
=
saveStopwatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
);
log
.
info
(
"每天执行-现金分期15+逾期用户黑名单-插入结束, listSize: {} , details_haveCount: {} , newIncreasedList: {} , saveOkCount: {} , 耗时: {} "
,
xjdBlackGreyList
.
size
(),
details_haveCount
.
get
(),
newIncreasedList
.
size
(),
saveOkCount
,
saveCost
);
String
resMsgTemp
=
"新增黑名单(现金分期15+逾期) 查询 %d条,
明细表已存在 %d条, 需要插入 %d条, 插入成功 %d条
;"
;
String
resMsgTemp
=
"新增黑名单(现金分期15+逾期) 查询 %d条,
查询耗时 %d.毫秒, 明细表已存在 %d条, 需要插入 %d条, 插入成功 %d条, 插入耗时 %d毫秒
;"
;
return
String
.
format
(
resMsgTemp
,
xjdBlackGreyList
.
size
(),
details_haveCount
.
get
(),
newIncreasedList
.
size
(),
saveOkCoun
t
);
return
String
.
format
(
resMsgTemp
,
xjdBlackGreyList
.
size
(),
queryCost
,
details_haveCount
.
get
(),
newIncreasedList
.
size
(),
saveOkCount
,
saveCos
t
);
}
}
...
@@ -580,7 +582,8 @@ public class BlackGreyListServiceImpl implements IBlackGreyListService {
...
@@ -580,7 +582,8 @@ public class BlackGreyListServiceImpl implements IBlackGreyListService {
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
log
.
error
(
"每天执行-vcc逾期15+用户黑名单-查询acsdb用户userId异常!"
,
e
);
log
.
error
(
"每天执行-vcc逾期15+用户黑名单-查询acsdb用户userId异常!"
,
e
);
}
}
log
.
info
(
"每天执行-vcc逾期15+用户黑名单-查询acsdb用户userId结束, vccUserIdList: {} , 耗时: {} "
,
(
vccUserIdList
!=
null
?
vccUserIdList
.
size
():
"null"
),
queryStopwatch1
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
));
long
queryCost
=
queryStopwatch1
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
);
log
.
info
(
"每天执行-vcc逾期15+用户黑名单-查询acsdb用户userId结束, vccUserIdList: {} , 耗时: {} "
,
(
vccUserIdList
!=
null
?
vccUserIdList
.
size
():
"null"
),
queryCost
);
Stopwatch
queryStopwatch2
=
Stopwatch
.
createStarted
();
Stopwatch
queryStopwatch2
=
Stopwatch
.
createStarted
();
List
<
TmpBlackGreyList
>
vccBlackGreyList
=
new
ArrayList
<
TmpBlackGreyList
>();
List
<
TmpBlackGreyList
>
vccBlackGreyList
=
new
ArrayList
<
TmpBlackGreyList
>();
...
@@ -663,10 +666,11 @@ public class BlackGreyListServiceImpl implements IBlackGreyListService {
...
@@ -663,10 +666,11 @@ public class BlackGreyListServiceImpl implements IBlackGreyListService {
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
}
log
.
info
(
"每天执行-vcc逾期15+用户黑名单-插入结束, vccBlackGreyList: {} , details_haveCount: {} , newIncreasedList: {} , saveOkCount: {} , 耗时: {} "
,
vccBlackGreyList
.
size
(),
details_haveCount
.
get
(),
newIncreasedList
.
size
(),
saveOkCount
,
saveStopwatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
));
long
saveCost
=
saveStopwatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
);
log
.
info
(
"每天执行-vcc逾期15+用户黑名单-插入结束, vccBlackGreyList: {} , details_haveCount: {} , newIncreasedList: {} , saveOkCount: {} , 耗时: {} "
,
vccBlackGreyList
.
size
(),
details_haveCount
.
get
(),
newIncreasedList
.
size
(),
saveOkCount
,
saveCost
);
String
resMsgTemp
=
"新增黑名单(vcc逾期15+逾期) 查询 %d条,
明细表已存在 %d条, 需要插入 %d条, 插入成功 %d条
;"
;
String
resMsgTemp
=
"新增黑名单(vcc逾期15+逾期) 查询 %d条,
查询耗时 %d毫秒, 明细表已存在 %d条, 需要插入 %d条, 插入成功 %d条, 插入耗时 %d毫秒
;"
;
return
String
.
format
(
resMsgTemp
,
vccBlackGreyList
.
size
(),
details_haveCount
.
get
(),
newIncreasedList
.
size
(),
saveOkCoun
t
);
return
String
.
format
(
resMsgTemp
,
vccBlackGreyList
.
size
(),
queryCost
,
details_haveCount
.
get
(),
newIncreasedList
.
size
(),
saveOkCount
,
saveCos
t
);
}
}
/*@Override
/*@Override
...
@@ -798,9 +802,12 @@ public class BlackGreyListServiceImpl implements IBlackGreyListService {
...
@@ -798,9 +802,12 @@ public class BlackGreyListServiceImpl implements IBlackGreyListService {
//批量 逾期已还清黑名单>>转灰名单
//批量 逾期已还清黑名单>>转灰名单
if
(
blackListResults
!=
null
&&
blackListResults
.
size
()
>
0
){
if
(
blackListResults
!=
null
&&
blackListResults
.
size
()
>
0
){
return
blackToGreyListParallel
.
removeBlackToGrey
(
blackListResults
);
String
resMsg1
=
"黑名单转灰名单查询 "
+
blackListResults
.
size
()+
"条, 查询耗时 "
+(
System
.
currentTimeMillis
()-
startTime
)+
"毫秒, "
;
String
resMsg2
=
blackToGreyListParallel
.
removeBlackToGrey
(
blackListResults
);
return
resMsg1
+
resMsg2
;
}
else
{
return
"黑名单转灰名单查询 0条, 查询耗时 "
+(
System
.
currentTimeMillis
()-
startTime
)+
"毫秒, 跳过转移!"
;
}
}
return
null
;
}
}
...
@@ -914,9 +921,13 @@ public class BlackGreyListServiceImpl implements IBlackGreyListService {
...
@@ -914,9 +921,13 @@ public class BlackGreyListServiceImpl implements IBlackGreyListService {
//批量更新黑名单>>逾期天数
//批量更新黑名单>>逾期天数
if
(
blackListResults
!=
null
&&
blackListResults
.
size
()
>
0
){
if
(
blackListResults
!=
null
&&
blackListResults
.
size
()
>
0
){
return
updateBlackListOverdueDayParallel
.
runUpdate
(
blackListResults
);
String
resMsg1
=
"更新黑名单逾期天数查询 "
+
blackListResults
.
size
()+
"条, 查询耗时 "
+(
System
.
currentTimeMillis
()-
startTime
)+
"毫秒, "
;
String
resMsg2
=
updateBlackListOverdueDayParallel
.
runUpdate
(
blackListResults
);
return
resMsg1
+
resMsg2
;
}
else
{
return
"更新黑名单逾期天数查询 0条, 查询耗时 "
+(
System
.
currentTimeMillis
()-
startTime
)+
"毫秒, 跳过更新!"
;
}
}
return
null
;
}
}
}
}
src/main/java/cn/quantgroup/qgblservice/service/impl/BlackToGreyListParallel.java
View file @
e2e34483
...
@@ -70,15 +70,51 @@ public class BlackToGreyListParallel implements ParallelComputingProcess<BlackGr
...
@@ -70,15 +70,51 @@ public class BlackToGreyListParallel implements ParallelComputingProcess<BlackGr
p
.
processForThread
(
tmpQueryList
,
this
,
THREAD_COUNT
,
optSet
);
p
.
processForThread
(
tmpQueryList
,
this
,
THREAD_COUNT
,
optSet
);
//并行框架执行结果
//并行框架执行结果
if
(
optSet
.
size
()
>
0
)
{
//并行框架执行异常
Set
<
String
>
resultSet
=
new
HashSet
<>();
log
.
info
(
log_inf
+
"-removeBlackToGrey黑名单转灰名单执行结束-部分失败, cost: {} <<<<<< process optSet size: {} , json: {} "
,
(
System
.
currentTimeMillis
()-
startProcess
),
optSet
.
size
(),
JSONObject
.
toJSONString
(
optSet
));
Map
<
String
,
String
>
dingTalkMap
=
new
HashMap
<>();
for
(
String
logInfo
:
optSet
){
if
(
logInfo
.
startsWith
(
"dingTalk_CPU_"
)){
//dingTalk_CPU_1:type_11=1,uuid_isNull=2,update_r_count=3,update_d_count=4,err_count=5
String
[]
tmpArray
=
logInfo
.
split
(
":"
);
dingTalkMap
.
put
(
tmpArray
[
0
],
tmpArray
[
1
]);
}
else
{
resultSet
.
add
(
logInfo
);
}
}
//判断,输出日志
if
(
resultSet
.
size
()
>
0
)
{
//并行框架执行异常
log
.
info
(
log_inf
+
"-removeBlackToGrey黑名单转灰名单执行结束-部分失败, cost: {} <<<<<< process resultSet size: {} , json: {} "
,
(
System
.
currentTimeMillis
()-
startProcess
),
resultSet
.
size
(),
JSONObject
.
toJSONString
(
resultSet
));
}
else
{
}
else
{
//执行成功
//执行成功
log
.
info
(
log_inf
+
"-removeBlackToGrey黑名单转灰名单执行结束-成功, cost: {} <<<<<< process is OK!"
,
(
System
.
currentTimeMillis
()
-
startProcess
));
log
.
info
(
log_inf
+
"-removeBlackToGrey黑名单转灰名单执行结束-成功, cost: {} <<<<<< process is OK!"
,
(
System
.
currentTimeMillis
()
-
startProcess
));
}
}
String
resMsgTemp
=
"总共 %d条, 执行成功 %d条, 失败 %d条;"
;
return
String
.
format
(
resMsgTemp
,
listSize
,
listSize
-
optSet
.
size
(),
optSet
.
size
());
//拼接构建钉钉通知的信息
int
type_11
=
0
,
uuid_isNull
=
0
,
update_r_count
=
0
,
update_d_count
=
0
,
err_count
=
0
;
try
{
//type_11=1,uuid_isNull=2,update_r_count=3,update_d_count=4,err_count=5
for
(
Map
.
Entry
<
String
,
String
>
entry:
dingTalkMap
.
entrySet
()){
String
context
=
entry
.
getValue
();
String
[]
tmpArry
=
context
.
trim
().
split
(
","
);
try
{
type_11
+=
Integer
.
parseInt
(
tmpArry
[
0
].
split
(
"="
)[
1
].
trim
());
uuid_isNull
+=
Integer
.
parseInt
(
tmpArry
[
1
].
split
(
"="
)[
1
].
trim
());
update_r_count
+=
Integer
.
parseInt
(
tmpArry
[
2
].
split
(
"="
)[
1
].
trim
());
update_d_count
+=
Integer
.
parseInt
(
tmpArry
[
3
].
split
(
"="
)[
1
].
trim
());
err_count
+=
Integer
.
parseInt
(
tmpArry
[
4
].
split
(
"="
)[
1
].
trim
());
}
catch
(
Exception
e
){
log
.
error
(
"黑名单转灰名单拼接钉钉告警信息,Integer转换异常"
,
e
);
}
}
}
catch
(
Exception
e
){
log
.
error
(
"黑名单转灰名单拼接钉钉告警信息异常"
,
e
);
}
String
resMsgTemp
=
"总共 %d条, type11 %d条, uuid为空 %d条, 结果表更新 %d条, 明细表更新 %d条, 失败 %d条, 处理耗时 %d分钟;"
;
return
String
.
format
(
resMsgTemp
,
listSize
,
type_11
,
uuid_isNull
,
update_r_count
,
update_d_count
,
err_count
,
(
int
)(
System
.
currentTimeMillis
()-
startProcess
)/
1000
/
60
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
log_inf
+
"-removeBlackToGrey黑名单转灰名单执行异常."
,
e
);
log
.
error
(
log_inf
+
"-removeBlackToGrey黑名单转灰名单执行异常."
,
e
);
}
}
...
@@ -95,6 +131,7 @@ public class BlackToGreyListParallel implements ParallelComputingProcess<BlackGr
...
@@ -95,6 +131,7 @@ public class BlackToGreyListParallel implements ParallelComputingProcess<BlackGr
AtomicInteger
err_count
=
new
AtomicInteger
();
AtomicInteger
err_count
=
new
AtomicInteger
();
AtomicInteger
uuid_isNull_count
=
new
AtomicInteger
();
AtomicInteger
type_11
=
new
AtomicInteger
();
AtomicInteger
type_11
=
new
AtomicInteger
();
AtomicInteger
update_d_count
=
new
AtomicInteger
();
AtomicInteger
update_d_count
=
new
AtomicInteger
();
AtomicInteger
update_r_count
=
new
AtomicInteger
();
AtomicInteger
update_r_count
=
new
AtomicInteger
();
...
@@ -247,14 +284,17 @@ public class BlackToGreyListParallel implements ParallelComputingProcess<BlackGr
...
@@ -247,14 +284,17 @@ public class BlackToGreyListParallel implements ParallelComputingProcess<BlackGr
log
.
error
(
log_inf
+
"黑名单转灰名单执行异常process() threadId:"
+
threadId
,
e
);
log
.
error
(
log_inf
+
"黑名单转灰名单执行异常process() threadId:"
+
threadId
,
e
);
}
}
}
else
{
}
else
{
err
_count
.
getAndIncrement
();
uuid_isNull
_count
.
getAndIncrement
();
optSet
.
add
(
"uuid空:"
+
rId
);
optSet
.
add
(
"uuid空:"
+
rId
);
log
.
error
(
"查询逾期黑名单是否已还清-发现uuid为空, threadId_{} , r_Id: {} , uuid: {} , blackType: {} "
,
threadId
,
rId
,
uuid
,
blackResult
.
getBlackType
());
log
.
error
(
"查询逾期黑名单是否已还清-发现uuid为空, threadId_{} , r_Id: {} , uuid: {} , blackType: {} "
,
threadId
,
rId
,
uuid
,
blackResult
.
getBlackType
());
}
}
}
}
log
.
info
(
log_inf
+
"黑名单转灰名单process处理结束CPU_{} , this_list_size: {} , type_11: {} , update_r_count: {} , update_d_count: {} , 失败: {} , 耗时: {} "
,
log
.
info
(
log_inf
+
"黑名单转灰名单process处理结束CPU_{} , this_list_size: {} , type_11: {} , uuid_isNull_count: {} , update_r_count: {} , update_d_count: {} , 失败: {} , 耗时: {} "
,
threadId
,
list_size
,
type_11
.
get
(),
update_r_count
.
get
(),
update_d_count
.
get
(),
err_count
.
get
(),
(
System
.
currentTimeMillis
()-
start
));
threadId
,
list_size
,
type_11
.
get
(),
uuid_isNull_count
.
get
(),
update_r_count
.
get
(),
update_d_count
.
get
(),
err_count
.
get
(),
(
System
.
currentTimeMillis
()-
start
));
String
dingTalk
=
"type_11="
+
type_11
.
get
()+
",uuid_isNull="
+
uuid_isNull_count
.
get
()+
",update_r_count="
+
update_r_count
.
get
()+
",update_d_count="
+
update_d_count
.
get
()+
",err_count="
+
err_count
.
get
();
optSet
.
add
(
"dingTalk_CPU_"
+
threadId
+
":"
+
dingTalk
);
}
}
...
@@ -495,4 +535,11 @@ public class BlackToGreyListParallel implements ParallelComputingProcess<BlackGr
...
@@ -495,4 +535,11 @@ public class BlackToGreyListParallel implements ParallelComputingProcess<BlackGr
return
0
;
return
0
;
}
}
public
static
void
main
(
String
[]
args
)
{
String
dingTalk
=
"dingTalk_CPU_1:type_11=1,uuid_isNull=2,update_r_count=3,update_d_count=4,err_count=5"
;
String
[]
tmpArry
=
dingTalk
.
split
(
":"
);
String
[]
tmpArry2
=
tmpArry
[
1
].
split
(
","
);
String
[]
tmpArry3
=
tmpArry2
[
0
].
split
(
"="
);
}
}
}
src/main/java/cn/quantgroup/qgblservice/service/impl/ThirdPartBlackListServiceImpl.java
View file @
e2e34483
...
@@ -14,6 +14,7 @@ import cn.quantgroup.qgblservice.service.IBlackListUpdateThreeEleService;
...
@@ -14,6 +14,7 @@ import cn.quantgroup.qgblservice.service.IBlackListUpdateThreeEleService;
import
cn.quantgroup.qgblservice.service.IThirdPartBlackListManagerService
;
import
cn.quantgroup.qgblservice.service.IThirdPartBlackListManagerService
;
import
cn.quantgroup.qgblservice.utils.MD5Util
;
import
cn.quantgroup.qgblservice.utils.MD5Util
;
import
cn.quantgroup.qgblservice.utils.blacklist.BlackListUtils
;
import
cn.quantgroup.qgblservice.utils.blacklist.BlackListUtils
;
import
cn.quantgroup.qgblservice.utils.dingding.DingTalk
;
import
com.alibaba.fastjson.JSON
;
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
;
...
@@ -63,6 +64,9 @@ public class ThirdPartBlackListServiceImpl implements IThirdPartBlackListManager
...
@@ -63,6 +64,9 @@ public class ThirdPartBlackListServiceImpl implements IThirdPartBlackListManager
@Autowired
@Autowired
private
IBlackGreyListService
blackGreyListService
;
private
IBlackGreyListService
blackGreyListService
;
@Autowired
private
DingTalk
dingTalk
;
@Override
@Override
public
GlobalResponse
saveThirdPartBlackList
(
String
uuid
,
String
name
,
String
phoneNo
,
String
idCard
,
String
type
)
{
public
GlobalResponse
saveThirdPartBlackList
(
String
uuid
,
String
name
,
String
phoneNo
,
String
idCard
,
String
type
)
{
...
@@ -159,6 +163,7 @@ public class ThirdPartBlackListServiceImpl implements IThirdPartBlackListManager
...
@@ -159,6 +163,7 @@ public class ThirdPartBlackListServiceImpl implements IThirdPartBlackListManager
log
.
info
(
"插入黑灰名单入参, uuid: {} , name: {} , phoneNo: {} , idCard: {} , type: {} , typeCode: {} , reasonCode: {} , reasonExplain: {} "
,
uuid
,
name
,
phoneNo
,
idCard
,
type
,
typeCode
,
reasonCode
,
reasonExplain
);
log
.
info
(
"插入黑灰名单入参, uuid: {} , name: {} , phoneNo: {} , idCard: {} , type: {} , typeCode: {} , reasonCode: {} , reasonExplain: {} "
,
uuid
,
name
,
phoneNo
,
idCard
,
type
,
typeCode
,
reasonCode
,
reasonExplain
);
if
(
org
.
apache
.
commons
.
lang3
.
StringUtils
.
isAnyEmpty
(
typeCode
,
reasonCode
,
reasonExplain
)){
if
(
org
.
apache
.
commons
.
lang3
.
StringUtils
.
isAnyEmpty
(
typeCode
,
reasonCode
,
reasonExplain
)){
log
.
error
(
"插入黑灰名单时-未匹配到typeCode或reason! uuid: {} , name: {} , phoneNo: {} , idCard: {} , type: {} "
,
uuid
,
name
,
phoneNo
,
idCard
,
type
);
log
.
error
(
"插入黑灰名单时-未匹配到typeCode或reason! uuid: {} , name: {} , phoneNo: {} , idCard: {} , type: {} "
,
uuid
,
name
,
phoneNo
,
idCard
,
type
);
dingTalk
.
talkByWebHook
(
DingTalk
.
WEBHOOK_BLACKGREY
,
"ERROR"
,
DingTalk
.
TITLETAGS_BLACKGREY
,
"三方数据源进来的灰名单插入失败"
,
"根据urlType:"
+
type
+
"未匹配到typeCode或reason! ["
+
uuid
+
", "
+
name
+
", "
+
phoneNo
+
", "
+
idCard
+
"]"
);
return
GlobalResponse
.
error
(
"参数type未匹配到typeCode!"
);
return
GlobalResponse
.
error
(
"参数type未匹配到typeCode!"
);
}
}
BlackGreyListQueryVo
queryResultParam
=
BlackGreyListQueryVo
.
builder
().
name
(
name
).
idNo
(
idCard
).
phoneNo
(
phoneNo
)
BlackGreyListQueryVo
queryResultParam
=
BlackGreyListQueryVo
.
builder
().
name
(
name
).
idNo
(
idCard
).
phoneNo
(
phoneNo
)
...
...
src/main/java/cn/quantgroup/qgblservice/service/impl/UpdateBlackListOverdueDayParallel.java
View file @
e2e34483
...
@@ -71,15 +71,50 @@ public class UpdateBlackListOverdueDayParallel implements ParallelComputingProce
...
@@ -71,15 +71,50 @@ public class UpdateBlackListOverdueDayParallel implements ParallelComputingProce
p
.
processForThread
(
tmpQueryList
,
this
,
THREAD_COUNT
,
optSet
);
p
.
processForThread
(
tmpQueryList
,
this
,
THREAD_COUNT
,
optSet
);
//并行框架执行结果
//并行框架执行结果
if
(
optSet
.
size
()
>
0
)
{
//并行框架执行异常
Set
<
String
>
resultSet
=
new
HashSet
<>();
log
.
info
(
log_inf
+
"-runUpdate更新逾期天数执行结束-部分失败, cost: {} <<<<<< process optSet size: {} , json: {} "
,
(
System
.
currentTimeMillis
()-
startProcess
),
optSet
.
size
(),
JSONObject
.
toJSONString
(
optSet
));
Map
<
String
,
String
>
dingTalkMap
=
new
HashMap
<>();
for
(
String
logInfo
:
optSet
){
if
(
logInfo
.
startsWith
(
"dingTalk_CPU_"
)){
//dingTalk_CPU_1:type_11=1,uuid_isNull=2,update_r_count=3,update_d_count=4,err_count=5
String
[]
tmpArray
=
logInfo
.
split
(
":"
);
dingTalkMap
.
put
(
tmpArray
[
0
],
tmpArray
[
1
]);
}
else
{
resultSet
.
add
(
logInfo
);
}
}
//判断,输出日志
if
(
resultSet
.
size
()
>
0
)
{
//并行框架执行异常
log
.
info
(
log_inf
+
"-runUpdate更新逾期天数执行结束-部分失败, cost: {} <<<<<< process resultSet size: {} , json: {} "
,
(
System
.
currentTimeMillis
()-
startProcess
),
resultSet
.
size
(),
JSONObject
.
toJSONString
(
resultSet
));
}
else
{
}
else
{
//执行成功
//执行成功
log
.
info
(
log_inf
+
"-runUpdate更新逾期天数执行结束-成功, cost: {} <<<<<< process is OK!"
,
(
System
.
currentTimeMillis
()
-
startProcess
));
log
.
info
(
log_inf
+
"-runUpdate更新逾期天数执行结束-成功, cost: {} <<<<<< process is OK!"
,
(
System
.
currentTimeMillis
()
-
startProcess
));
}
}
String
resMsgTemp
=
"更新逾期天数总共 %d条, 执行成功 %d条, 失败 %d条;"
;
//拼接构建钉钉通知的信息
return
String
.
format
(
resMsgTemp
,
listSize
,
listSize
-
optSet
.
size
(),
optSet
.
size
());
int
type_11
=
0
,
uuid_isNull
=
0
,
update_r_count
=
0
,
update_d_count
=
0
,
err_count
=
0
;
try
{
//type_11=1,uuid_isNull=2,update_r_count=3,update_d_count=4,err_count=5
for
(
Map
.
Entry
<
String
,
String
>
entry:
dingTalkMap
.
entrySet
()){
String
context
=
entry
.
getValue
();
String
[]
tmpArry
=
context
.
trim
().
split
(
","
);
try
{
type_11
+=
Integer
.
parseInt
(
tmpArry
[
0
].
split
(
"="
)[
1
].
trim
());
uuid_isNull
+=
Integer
.
parseInt
(
tmpArry
[
1
].
split
(
"="
)[
1
].
trim
());
update_r_count
+=
Integer
.
parseInt
(
tmpArry
[
2
].
split
(
"="
)[
1
].
trim
());
update_d_count
+=
Integer
.
parseInt
(
tmpArry
[
3
].
split
(
"="
)[
1
].
trim
());
err_count
+=
Integer
.
parseInt
(
tmpArry
[
4
].
split
(
"="
)[
1
].
trim
());
}
catch
(
Exception
e
){
log
.
error
(
"更新逾期天数拼接钉钉告警信息,Integer转换异常"
,
e
);
}
}
}
catch
(
Exception
e
){
log
.
error
(
"更新逾期天数拼接钉钉告警信息异常"
,
e
);
}
String
resMsgTemp
=
"总共 %d条, type11 %d条, uuid为空 %d条, 结果表更新 %d条, 明细表更新 %d条, 失败 %d条, 处理耗时 %d分钟;"
;
return
String
.
format
(
resMsgTemp
,
listSize
,
type_11
,
uuid_isNull
,
update_r_count
,
update_d_count
,
err_count
,
(
int
)(
System
.
currentTimeMillis
()-
startProcess
)/
1000
/
60
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
log_inf
+
"-runUpdate更新逾期天数执行异常."
,
e
);
log
.
error
(
log_inf
+
"-runUpdate更新逾期天数执行异常."
,
e
);
}
}
...
@@ -94,11 +129,11 @@ public class UpdateBlackListOverdueDayParallel implements ParallelComputingProce
...
@@ -94,11 +129,11 @@ public class UpdateBlackListOverdueDayParallel implements ParallelComputingProce
String
dateName
=
ConstantBlackGrey
.
PARAM
.
DF_YMD
.
format
(
Calendar
.
getInstance
().
getTime
());
String
dateName
=
ConstantBlackGrey
.
PARAM
.
DF_YMD
.
format
(
Calendar
.
getInstance
().
getTime
());
int
list_size
=
blackResultList
.
size
();
int
list_size
=
blackResultList
.
size
();
AtomicInteger
ok_count
=
new
AtomicInteger
();
AtomicInteger
err_count
=
new
AtomicInteger
();
AtomicInteger
err_count
=
new
AtomicInteger
();
AtomicInteger
uuid_isNull_count
=
new
AtomicInteger
();
AtomicInteger
type_11
=
new
AtomicInteger
();
AtomicInteger
type_11
=
new
AtomicInteger
();
AtomicInteger
update_d_count
=
new
AtomicInteger
();
AtomicInteger
update_count
=
new
AtomicInteger
();
AtomicInteger
update_
r_
count
=
new
AtomicInteger
();
int
index
=
0
;
int
index
=
0
;
for
(
BlackGreyListResult
blackResult
:
blackResultList
)
{
for
(
BlackGreyListResult
blackResult
:
blackResultList
)
{
...
@@ -146,7 +181,7 @@ public class UpdateBlackListOverdueDayParallel implements ParallelComputingProce
...
@@ -146,7 +181,7 @@ public class UpdateBlackListOverdueDayParallel implements ParallelComputingProce
int
update
=
updateOverdueDay
(
overdueDays
,
detailsVo
,
"现金贷"
);
int
update
=
updateOverdueDay
(
overdueDays
,
detailsVo
,
"现金贷"
);
if
(
update
>
0
){
if
(
update
>
0
){
details_is_update
=
true
;
details_is_update
=
true
;
update_count
.
getAndAdd
(
update
);
update_
d_
count
.
getAndAdd
(
update
);
}
}
}
}
...
@@ -173,7 +208,7 @@ public class UpdateBlackListOverdueDayParallel implements ParallelComputingProce
...
@@ -173,7 +208,7 @@ public class UpdateBlackListOverdueDayParallel implements ParallelComputingProce
int
update
=
updateOverdueDay
(
overdueDays
,
detailsVo
,
"白条"
);
int
update
=
updateOverdueDay
(
overdueDays
,
detailsVo
,
"白条"
);
if
(
update
>
0
){
if
(
update
>
0
){
details_is_update
=
true
;
details_is_update
=
true
;
update_count
.
getAndAdd
(
update
);
update_
d_
count
.
getAndAdd
(
update
);
}
}
}
}
...
@@ -203,7 +238,7 @@ public class UpdateBlackListOverdueDayParallel implements ParallelComputingProce
...
@@ -203,7 +238,7 @@ public class UpdateBlackListOverdueDayParallel implements ParallelComputingProce
int
update
=
updateOverdueDay
(
overdueDays
,
detailsVo
,
"白条"
);
int
update
=
updateOverdueDay
(
overdueDays
,
detailsVo
,
"白条"
);
if
(
update
>
0
){
if
(
update
>
0
){
details_is_update
=
true
;
details_is_update
=
true
;
update_count
.
getAndAdd
(
update
);
update_
d_
count
.
getAndAdd
(
update
);
}
}
}
}
}
else
{
}
else
{
...
@@ -218,8 +253,10 @@ public class UpdateBlackListOverdueDayParallel implements ParallelComputingProce
...
@@ -218,8 +253,10 @@ public class UpdateBlackListOverdueDayParallel implements ParallelComputingProce
//如果明细表有修改,更新一下结果表修改时间
//如果明细表有修改,更新一下结果表修改时间
if
(
details_is_update
){
if
(
details_is_update
){
//更新结果表
//更新结果表
updateResultUpdatedAt
(
blackResult
.
getRId
());
int
update_r
=
updateResultUpdatedAt
(
blackResult
.
getRId
());
ok_count
.
getAndIncrement
();
if
(
update_r
>
0
){
update_r_count
.
getAndIncrement
();
}
}
}
}
else
{
}
else
{
...
@@ -234,13 +271,17 @@ public class UpdateBlackListOverdueDayParallel implements ParallelComputingProce
...
@@ -234,13 +271,17 @@ public class UpdateBlackListOverdueDayParallel implements ParallelComputingProce
log
.
error
(
log_inf
+
"更新黑名单逾期天执行异常process() threadId:"
+
threadId
,
e
);
log
.
error
(
log_inf
+
"更新黑名单逾期天执行异常process() threadId:"
+
threadId
,
e
);
}
}
}
else
{
}
else
{
err
_count
.
getAndIncrement
();
uuid_isNull
_count
.
getAndIncrement
();
optSet
.
add
(
"uuid空:"
+
rId
);
optSet
.
add
(
"uuid空:"
+
rId
);
log
.
error
(
"查询黑名单逾期天-发现uuid为空, threadId_{} , r_Id: {} , uuid: {} , blackType: {} "
,
threadId
,
rId
,
uuid
,
blackResult
.
getBlackType
());
log
.
error
(
"查询黑名单逾期天-发现uuid为空, threadId_{} , r_Id: {} , uuid: {} , blackType: {} "
,
threadId
,
rId
,
uuid
,
blackResult
.
getBlackType
());
}
}
}
}
log
.
info
(
log_inf
+
"更新黑名单逾期天数process处理结束CPU_{} , this_list_size: {} , ok_count: {} , err_count: {} , type_11: {} , update_count: {} , 耗时: {} "
,
threadId
,
list_size
,
ok_count
.
get
(),
err_count
.
get
(),
type_11
.
get
(),
update_count
.
get
(),
(
System
.
currentTimeMillis
()-
start
));
log
.
info
(
log_inf
+
"更新黑名单逾期天数process处理结束CPU_{} , this_list_size: {} , type_11: {} , uuid_isNull_count: {} , update_r_count: {} , update_d_count: {} , 失败: {} , 耗时: {} "
,
threadId
,
list_size
,
type_11
.
get
(),
uuid_isNull_count
.
get
(),
update_r_count
.
get
(),
update_d_count
.
get
(),
err_count
.
get
(),
(
System
.
currentTimeMillis
()-
start
));
String
dingTalk
=
"type_11="
+
type_11
.
get
()+
",uuid_isNull="
+
uuid_isNull_count
.
get
()+
",update_r_count="
+
update_r_count
.
get
()+
",update_d_count="
+
update_d_count
.
get
()+
",err_count="
+
err_count
.
get
();
optSet
.
add
(
"dingTalk_CPU_"
+
threadId
+
":"
+
dingTalk
);
}
}
...
...
src/main/java/cn/quantgroup/qgblservice/utils/dingding/DingException.java
0 → 100644
View file @
e2e34483
package
cn
.
quantgroup
.
qgblservice
.
utils
.
dingding
;
import
java.io.PrintWriter
;
import
java.io.StringWriter
;
/**
* @author :dongjianhua
* @date :Created in 2019/11/4 10:38
* @description:异常类
* @modified By:
* @version: 1.0
*/
public
class
DingException
extends
RuntimeException
{
//提醒标题
public
String
alarm
;
//堆栈信息 或者报错信息
public
String
message
;
public
DingException
(
String
exMsg
)
{
alarm
=
exMsg
;
}
public
DingException
(
String
exMsg
,
String
message
)
{
super
(
message
,
null
);
alarm
=
exMsg
;
this
.
message
=
message
;
}
public
DingException
(
String
exMsg
,
Exception
e
)
{
super
(
e
);
alarm
=
exMsg
;
message
=
getStackTrace
(
e
);
}
public
static
String
getStackTrace
(
Throwable
t
)
{
StringWriter
sw
=
new
StringWriter
();
PrintWriter
pw
=
new
PrintWriter
(
sw
);
try
{
t
.
printStackTrace
(
pw
);
return
sw
.
toString
();
}
finally
{
pw
.
close
();
}
}
}
src/main/java/cn/quantgroup/qgblservice/utils/dingding/DingTalk.java
0 → 100644
View file @
e2e34483
package
cn
.
quantgroup
.
qgblservice
.
utils
.
dingding
;
import
cn.quantgroup.qgblservice.utils.http.HttpRequestUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang.BooleanUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Component
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* -----------------------------------------------------------------------------<br>
* 类描述: 黑灰名单数据插入更新 钉钉提醒 <br>
* 创建人: yanhui.Hao <br>
* 创建时间: 2020.04.29 14:45 <br>
* 公司: 北京众信利民信息技术有限公司 <br>
* -----------------------------------------------------------------------------
*/
@Component
@Slf4j
public
class
DingTalk
{
//@Autowired
//private IHttpService iHttpService;
@Value
(
"${isDebug}"
)
private
Boolean
isDebug
;
public
static
final
String
talkUri
=
"https://alertserv-dataservice.quantgroup.cn/common/alert/dingtalk"
;
//黑灰名单 钉钉机器人
public
static
final
String
WEBHOOK_BLACKGREY
=
"https://oapi.dingtalk.com/robot/send?access_token=959647751bda08896d69b570393d788d16b2307a50d127d6b6c6e284148aef0f"
;
public
static
final
String
TITLETAGS_BLACKGREY
=
"黑灰名单"
;
/**
* -----------------------------------------------------------------------------<br>
* 描 述: 正常去情况下钉钉通知 <br>
* 创建人: yanhui.Hao <br>
* 创建时间: 2020.04.29 15:31 <br>
* 最后修改人: <br>
* 最后修改时间: 2020.04.29 15:31 <br>
* 入参说明: <br>
* 出参说明: <br>
* -----------------------------------------------------------------------------
*/
@Async
public
void
talkByWebHook
(
String
webHook
,
String
alarmLevel
,
String
titleTags
,
String
titleMsg
,
String
contentMsg
)
{
if
(
BooleanUtils
.
isTrue
(
isDebug
))
{
log
.
info
(
"测试环境下不钉钉通知, webHook: {} , alarmLevel: {} , titleTags: {} , titleMsg: {} , contentMsg: {} "
,
webHook
,
alarmLevel
,
titleTags
,
titleMsg
,
contentMsg
);
return
;
}
try
{
if
(
StringUtils
.
isEmpty
(
webHook
)){
log
.
error
(
"钉钉日常通知接口调用失败, webHook参数不能为空!"
);
return
;
}
Map
<
String
,
String
>
param
=
new
HashMap
<>();
param
.
put
(
"webhook"
,
webHook
);
param
.
put
(
"alarmLevel"
,
alarmLevel
);
//"Warn"
param
.
put
(
"msgTitle"
,
titleTags
+
":"
+
titleMsg
);
param
.
put
(
"msgContent"
,
contentMsg
);
//String resp = iHttpService.post(talkUri, param);
String
resp
=
HttpRequestUtil
.
doPost
(
talkUri
,
param
,
"dingtalk"
);
log
.
info
(
"钉钉日常通知接口调用结束, resp: {} "
,
resp
);
}
catch
(
Exception
e
){
log
.
error
(
"钉钉日常通知接口调用异常! "
,
e
);
}
}
/**
* -----------------------------------------------------------------------------<br>
* 描 述: 异常情况下钉钉通知 <br>
* 创建人: yanhui.Hao <br>
* 创建时间: 2020.04.29 15:32 <br>
* 最后修改人: <br>
* 最后修改时间: 2020.04.29 15:32 <br>
* 入参说明: <br>
* 出参说明: <br>
* -----------------------------------------------------------------------------
*/
@Async
public
void
talkByWebHook
(
String
webHook
,
String
alarmLevel
,
String
titleTags
,
String
titleMsg
,
Exception
ex
)
{
if
(
BooleanUtils
.
isTrue
(
isDebug
))
{
log
.
info
(
"测试环境下不钉钉通知, webHook: {} , alarmLevel: {} , titleTags: {} , titleMsg: {} , contentMsg: {} "
,
webHook
,
alarmLevel
,
titleTags
,
titleMsg
,
ex
.
toString
());
return
;
}
try
{
if
(
StringUtils
.
isEmpty
(
webHook
)){
log
.
error
(
"钉钉日常通知接口调用失败, webHook参数不能为空!"
);
return
;
}
Map
<
String
,
String
>
param
=
new
HashMap
<>();
param
.
put
(
"webhook"
,
webHook
);
param
.
put
(
"alarmLevel"
,
alarmLevel
);
//"Warn"
param
.
put
(
"msgTitle"
,
titleTags
+
":"
+
titleMsg
);
String
msg
=
ex
.
getMessage
();
if
(
StringUtils
.
isBlank
(
msg
)){
msg
=
ex
.
toString
();
}
param
.
put
(
"msgContent"
,
msg
);
//String resp = iHttpService.post(talkUri, param);
String
resp
=
HttpRequestUtil
.
doPost
(
talkUri
,
param
,
"dingtalk"
);
log
.
info
(
"钉钉日常通知接口调用结束, resp: {} "
,
resp
);
}
catch
(
Exception
e
){
log
.
error
(
"钉钉日常通知接口调用异常! "
,
e
);
}
}
/**
* -----------------------------------------------------------------------------<br>
* 描 述: @某某的通知 <br>
* 创建人: yanhui.Hao <br>
* 创建时间: 2020.04.29 15:36 <br>
* 最后修改人: <br>
* 最后修改时间: 2020.04.29 15:36 <br>
* 入参说明: <br>
* 出参说明: <br>
* -----------------------------------------------------------------------------
*/
@Async
public
void
talk_ToUser
(
String
webHook
,
String
alarmLevel
,
String
titleTags
,
String
titleMsg
,
String
contentMsg
)
{
if
(
BooleanUtils
.
isTrue
(
isDebug
))
{
log
.
info
(
"测试环境下不钉钉通知, webHook: {} , alarmLevel: {} , titleTags: {} , titleMsg: {} , contentMsg: {} "
,
webHook
,
alarmLevel
,
titleTags
,
titleMsg
,
contentMsg
);
return
;
}
try
{
Map
<
String
,
String
>
param
=
new
HashMap
<>();
param
.
put
(
"webhook"
,
webHook
);
param
.
put
(
"alarmLevel"
,
alarmLevel
);
param
.
put
(
"msgTitle"
,
titleTags
+
" :"
+
titleMsg
);
param
.
put
(
"msgContent"
,
contentMsg
);
param
.
put
(
"toUsers"
,
"18010105506"
);
//String resp = iHttpService.post(talkUri, param);
String
resp
=
HttpRequestUtil
.
doPost
(
talkUri
,
param
,
"dingtalk"
);
log
.
info
(
"钉钉报警接口调用结束, resp: {} "
,
resp
);
}
catch
(
Exception
e
){
log
.
warn
(
"钉钉报警接口调用异常! "
,
e
);
}
}
}
src/main/java/cn/quantgroup/qgblservice/utils/http/HttpRequestUtil.java
0 → 100644
View file @
e2e34483
This diff is collapsed.
Click to expand it.
src/main/java/cn/quantgroup/qgblservice/utils/http/QGException.java
0 → 100644
View file @
e2e34483
/*
* Copyright 2014-present Miyou tech inc. All Rights Reserved.
*/
package
cn
.
quantgroup
.
qgblservice
.
utils
.
http
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.net.SocketTimeoutException
;
import
java.util.Arrays
;
import
static
cn
.
quantgroup
.
qgblservice
.
utils
.
http
.
QGExceptionType
.
COMMON_SERVER_ERROR
;
import
static
cn
.
quantgroup
.
qgblservice
.
utils
.
http
.
QGExceptionType
.
COMMON_THIRD_PARTY_TIMEOUT
;
public
class
QGException
extends
RuntimeException
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
QGException
.
class
);
public
QGExceptionType
qgExceptionType
;
public
boolean
isToastFormat
=
false
;
public
String
detail
;
public
QGException
(
String
detail
,
QGExceptionType
qgExceptionType
,
Object
...
args
)
{
super
(
detail
);
try
{
if
(
StringUtils
.
isNoneBlank
(
qgExceptionType
.
frontEndToastTemplate
))
{
isToastFormat
=
true
;
initException
(
String
.
format
(
qgExceptionType
.
frontEndToastTemplate
,
args
),
qgExceptionType
);
}
else
{
initException
(
qgExceptionType
);
}
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"format front end toast err, "
+
qgExceptionType
+
", args: "
+
Arrays
.
toString
(
args
),
e
);
initException
(
COMMON_SERVER_ERROR
);
}
}
public
QGException
(
QGExceptionType
qgExceptionType
,
Object
...
args
)
{
super
(
qgExceptionType
.
text
);
try
{
if
(
StringUtils
.
isNoneBlank
(
qgExceptionType
.
frontEndToastTemplate
))
{
isToastFormat
=
true
;
initException
(
String
.
format
(
qgExceptionType
.
frontEndToastTemplate
,
args
),
qgExceptionType
);
}
else
{
initException
(
qgExceptionType
);
}
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"format front end toast err, "
+
qgExceptionType
+
", args: "
+
Arrays
.
toString
(
args
),
e
);
initException
(
COMMON_SERVER_ERROR
);
}
}
public
QGException
(
String
detail
,
Throwable
cause
,
QGExceptionType
qgExceptionType
)
{
super
(
detail
,
cause
);
this
.
initException
(
detail
,
qgExceptionType
);
}
public
QGException
(
String
detail
,
QGExceptionType
qgExceptionType
)
{
super
(
detail
);
initException
(
detail
,
qgExceptionType
);
}
public
QGException
(
QGExceptionType
qgExceptionType
)
{
super
(
qgExceptionType
.
text
);
initException
(
qgExceptionType
);
}
public
QGException
(
Throwable
cause
,
QGExceptionType
qgExceptionType
,
Object
...
args
)
{
super
(
qgExceptionType
.
text
,
cause
);
try
{
if
(
StringUtils
.
isNoneBlank
(
qgExceptionType
.
frontEndToastTemplate
))
{
isToastFormat
=
true
;
initException
(
String
.
format
(
qgExceptionType
.
frontEndToastTemplate
,
args
),
qgExceptionType
);
}
else
{
initException
(
qgExceptionType
);
}
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"format front end toast err, "
+
qgExceptionType
+
", args: "
+
Arrays
.
toString
(
args
),
e
);
initException
(
COMMON_SERVER_ERROR
);
}
}
public
static
QGException
wrap
(
Throwable
e
)
{
return
wrap
(
e
,
COMMON_SERVER_ERROR
);
}
public
static
QGException
wrap
(
Throwable
e
,
QGExceptionType
exceptionType
)
{
if
(
e
instanceof
QGException
)
{
return
(
QGException
)
e
;
}
if
(
e
instanceof
SocketTimeoutException
)
return
new
QGException
(
COMMON_THIRD_PARTY_TIMEOUT
);
return
new
QGException
(
e
,
exceptionType
);
}
public
static
QGException
wrap
(
Throwable
e
,
QGExceptionType
exceptionType
,
Object
...
args
)
{
if
(
e
instanceof
QGException
)
{
return
(
QGException
)
e
;
}
if
(
e
instanceof
SocketTimeoutException
)
return
new
QGException
(
COMMON_THIRD_PARTY_TIMEOUT
);
return
new
QGException
(
e
,
exceptionType
,
args
);
}
private
void
initException
(
QGExceptionType
QGExceptionType
)
{
this
.
initException
(
QGExceptionType
.
text
,
QGExceptionType
);
}
private
void
initException
(
String
detail
,
QGExceptionType
QGExceptionType
)
{
this
.
qgExceptionType
=
QGExceptionType
;
this
.
detail
=
detail
;
}
}
\ No newline at end of file
src/main/java/cn/quantgroup/qgblservice/utils/http/QGExceptionType.java
0 → 100644
View file @
e2e34483
/*
* Copyright 2014-present Miyou tech inc. All Rights Reserved.
*/
package
cn
.
quantgroup
.
qgblservice
.
utils
.
http
;
import
lombok.extern.slf4j.Slf4j
;
/**
* 系统使用Exception来进行Error Code处理。如果LogType为Error,
* 代表这种Error不应该返回给客户端,应该统一打印出服务器端错误;
* 如果是WARNING的话,就将对应的Exception Text返回给客户端。
*/
@Slf4j
public
enum
QGExceptionType
{
COMMON_SERVER_ERROR
(
1001
,
"系统异常,请稍后再试"
),
COMMON_ILLEGAL_STATE
(
1002
,
"断言错误"
),
COMMON_ILLEGAL_PARAM_TOAST
(
1003
,
"参数异常"
,
"%s"
),
COMMON_AUTH_ERROR
(
1004
,
"系统异常,请稍后再试"
),
COMMON_ILLEGAL_PARAM
(
1010
,
"参数异常"
),
COMMON_THIRD_PARTY_TIMEOUT
(
1011
,
"第三方服务超时"
),
COMMON_INVALID_PARAM
(
1012
,
"参数错误"
),
COMMON_ID_INVALID
(
1013
,
"id数据非法"
),
COMMON_STRING_PARAM_GREATER_THAN_LENGTH
(
1014
,
"参数的长度过长"
,
"%s的长度不能大于%s"
),
COMMON_STRING_PARAM_IS_ALL_NULL
(
1015
,
"参数不能为空"
,
"%s不能为空"
),
COMMON_STRING_PARAM_IS_NULL
(
1016
,
"参数不能同时为空"
,
"%s不能同时为空"
),
COMMON_THIRD_PARTY_ERROR
(
1017
,
"第三方服务报错"
,
"第三方服务报错,错误编码:%s,错误提示:%s"
),
COMMON_THIRD_PART_CALL_EXCEPTION
(
3001
,
"第三方服务调用异常"
,
"异常信息:%s"
),
;
public
int
code
;
public
String
text
;
public
String
frontEndToastTemplate
;
QGExceptionType
(
int
code
,
String
text
)
{
this
.
code
=
code
;
this
.
text
=
text
;
this
.
frontEndToastTemplate
=
text
;
}
QGExceptionType
(
int
code
,
String
text
,
String
frontEndToastTemplate
)
{
this
.
code
=
code
;
this
.
text
=
text
;
this
.
frontEndToastTemplate
=
frontEndToastTemplate
;
}
public
static
QGExceptionType
fromCode
(
int
code
)
{
for
(
QGExceptionType
exceptionType
:
QGExceptionType
.
values
())
{
if
(
exceptionType
.
code
==
code
)
{
return
exceptionType
;
}
}
return
null
;
}
@Override
public
String
toString
()
{
return
"error_code: "
+
code
+
", text: "
+
text
+
", frontEndToastTemplate: "
+
frontEndToastTemplate
;
}
}
src/main/java/cn/quantgroup/qgblservice/utils/http/RiskHttpResponse.java
0 → 100644
View file @
e2e34483
package
cn
.
quantgroup
.
qgblservice
.
utils
.
http
;
import
com.alibaba.fastjson.JSONObject
;
import
lombok.Data
;
/**
* Created by suh on 2017/12/18.
*/
@Data
public
class
RiskHttpResponse
{
private
int
code
;
private
JSONObject
jsonObject
;
public
RiskHttpResponse
(
JSONObject
jsonObject
,
int
code
){
this
.
jsonObject
=
jsonObject
;
this
.
code
=
code
;
}
public
RiskHttpResponse
(){}
}
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