Commit e2e34483 authored by 郝彦辉's avatar 郝彦辉

2020.04.29黑灰名单数据更新增加钉钉通知

parent 10fd2d1e
package cn.quantgroup.qgblservice.job.blimport;
import cn.quantgroup.qgblservice.constant.Constant;
import cn.quantgroup.qgblservice.constant.ConstantBlackGrey;
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 org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -34,6 +33,8 @@ public class BlackGreyListJob {
@Autowired
private IBlackGreyListService blackGreyListService;
@Autowired
private DingTalk dingTalk;
private Boolean increment(String key){
Long increment = redisTemplate.opsForValue().increment(key, 1);
......@@ -81,7 +82,7 @@ public class BlackGreyListJob {
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);
//yyyy-MM-dd
String todayNyr = LocalDateTime.now().format(DateTimeFormatter.ISO_DATE_TIME);
String todayNyr = LocalDateTime.now().format(DateTimeFormatter.ISO_DATE);
long statUtc = 0L;
//1、导入-现金分期15+逾期黑名单 约耗时65866.ms
......@@ -94,6 +95,7 @@ public class BlackGreyListJob {
log.error(todayNyr+", 每天执行新增现金分期15+逾期黑名单异常", e);
}finally {
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
......@@ -106,10 +108,11 @@ public class BlackGreyListJob {
log.error(todayNyr+", 每天执行新增Vcc15+逾期黑名单异常", e);
}finally {
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;
try {
statUtc = System.currentTimeMillis();
......@@ -119,6 +122,7 @@ public class BlackGreyListJob {
log.error(todayNyr+", 每天执行将逾期已还清黑名单转灰名单异常", e);
}finally {
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 {
//判断是否有执行
if (getRedisValStr(ConstantBlackGrey.REDIS_KEY.SIGN_IS_RUN_UPDATE_BLACK_OVERDUEDAY_KEY)) {
//yyyy-MM-dd
String todayNyr = LocalDateTime.now().format(DateTimeFormatter.ISO_DATE_TIME);
String todayNyr = LocalDateTime.now().format(DateTimeFormatter.ISO_DATE);
long statUtc = System.currentTimeMillis();
String updateBLOverdueDay = null;
......@@ -206,13 +210,14 @@ public class BlackGreyListJob {
//删掉执行标记
redisTemplate.delete(ConstantBlackGrey.REDIS_KEY.SIGN_IS_RUN_UPDATE_BLACK_OVERDUEDAY_KEY);
//耗时3807471.ms 约64分钟,
//耗时3807471.ms 约64分钟, 3648346.ms
updateBLOverdueDay = blackGreyListService.updateBlackListOverdueDay();
}catch (Exception e){
log.error(todayNyr+", 每天执行更新黑名单最大逾期天数和累计逾期天数异常", e);
}finally {
redisTemplate.delete(ConstantBlackGrey.REDIS_KEY.SIGN_IS_RUN_UPDATE_BLACK_OVERDUEDAY_KEY);
log.info(todayNyr+", 每天执行更新黑名单最大逾期天数和累计逾期天结束, Msg: {} , 总耗时: {} ", updateBLOverdueDay, (System.currentTimeMillis()-statUtc)+".ms");
dingTalk.talkByWebHook(DingTalk.WEBHOOK_BLACKGREY, "Info", DingTalk.TITLETAGS_BLACKGREY, "更新"+todayNyr+"黑名单最大逾期天数和累计逾期天结束", updateBLOverdueDay);
}
}
......
......@@ -516,7 +516,8 @@ public class BlackGreyListServiceImpl implements IBlackGreyListService {
public String importXianJinDaiBlackGreyList() {
Stopwatch queryStopwatch = Stopwatch.createStarted();
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();
List<TmpBlackGreyList> newIncreasedList = new ArrayList<>();
......@@ -553,10 +554,11 @@ public class BlackGreyListServiceImpl implements IBlackGreyListService {
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条;";
return String.format(resMsgTemp, xjdBlackGreyList.size(), details_haveCount.get(), newIncreasedList.size(), saveOkCount);
String resMsgTemp = "新增黑名单(现金分期15+逾期) 查询 %d条, 查询耗时 %d.毫秒, 明细表已存在 %d条, 需要插入 %d条, 插入成功 %d条, 插入耗时 %d毫秒;";
return String.format(resMsgTemp, xjdBlackGreyList.size(), queryCost, details_haveCount.get(), newIncreasedList.size(), saveOkCount, saveCost);
}
......@@ -580,7 +582,8 @@ public class BlackGreyListServiceImpl implements IBlackGreyListService {
}catch (Exception 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();
List<TmpBlackGreyList> vccBlackGreyList = new ArrayList<TmpBlackGreyList>();
......@@ -663,10 +666,11 @@ public class BlackGreyListServiceImpl implements IBlackGreyListService {
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条;";
return String.format(resMsgTemp, vccBlackGreyList.size(), details_haveCount.get(), newIncreasedList.size(), saveOkCount);
String resMsgTemp = "新增黑名单(vcc逾期15+逾期) 查询 %d条, 查询耗时 %d毫秒, 明细表已存在 %d条, 需要插入 %d条, 插入成功 %d条, 插入耗时 %d毫秒;";
return String.format(resMsgTemp, vccBlackGreyList.size(), queryCost, details_haveCount.get(), newIncreasedList.size(), saveOkCount, saveCost);
}
/*@Override
......@@ -798,9 +802,12 @@ public class BlackGreyListServiceImpl implements IBlackGreyListService {
//批量 逾期已还清黑名单>>转灰名单
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 {
//批量更新黑名单>>逾期天数
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;
}
}
......@@ -70,15 +70,51 @@ public class BlackToGreyListParallel implements ParallelComputingProcess<BlackGr
p.processForThread(tmpQueryList, this, THREAD_COUNT, optSet);
//并行框架执行结果
if (optSet.size() > 0) {//并行框架执行异常
log.info(log_inf + "-removeBlackToGrey黑名单转灰名单执行结束-部分失败, cost: {} <<<<<< process optSet size: {} , json: {} ", (System.currentTimeMillis()-startProcess), optSet.size(), JSONObject.toJSONString(optSet));
Set<String> resultSet = new HashSet<>();
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 {
//执行成功
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) {
log.error(log_inf +"-removeBlackToGrey黑名单转灰名单执行异常.", e);
}
......@@ -95,6 +131,7 @@ public class BlackToGreyListParallel implements ParallelComputingProcess<BlackGr
AtomicInteger err_count = new AtomicInteger();
AtomicInteger uuid_isNull_count = new AtomicInteger();
AtomicInteger type_11 = new AtomicInteger();
AtomicInteger update_d_count = new AtomicInteger();
AtomicInteger update_r_count = new AtomicInteger();
......@@ -247,14 +284,17 @@ public class BlackToGreyListParallel implements ParallelComputingProcess<BlackGr
log.error(log_inf + "黑名单转灰名单执行异常process() threadId:" + threadId, e);
}
}else {
err_count.getAndIncrement();
uuid_isNull_count.getAndIncrement();
optSet.add("uuid空:" + rId);
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: {} , 失败: {} , 耗时: {} ",
threadId, list_size, type_11.get(), update_r_count.get(), update_d_count.get(), err_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);
}
......@@ -495,4 +535,11 @@ public class BlackToGreyListParallel implements ParallelComputingProcess<BlackGr
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("=");
}
}
......@@ -14,6 +14,7 @@ import cn.quantgroup.qgblservice.service.IBlackListUpdateThreeEleService;
import cn.quantgroup.qgblservice.service.IThirdPartBlackListManagerService;
import cn.quantgroup.qgblservice.utils.MD5Util;
import cn.quantgroup.qgblservice.utils.blacklist.BlackListUtils;
import cn.quantgroup.qgblservice.utils.dingding.DingTalk;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
......@@ -63,6 +64,9 @@ public class ThirdPartBlackListServiceImpl implements IThirdPartBlackListManager
@Autowired
private IBlackGreyListService blackGreyListService;
@Autowired
private DingTalk dingTalk;
@Override
public GlobalResponse saveThirdPartBlackList(String uuid, String name, String phoneNo, String idCard, String type) {
......@@ -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);
if(org.apache.commons.lang3.StringUtils.isAnyEmpty(typeCode, reasonCode, reasonExplain)){
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!");
}
BlackGreyListQueryVo queryResultParam = BlackGreyListQueryVo.builder().name(name).idNo(idCard).phoneNo(phoneNo)
......
......@@ -71,15 +71,50 @@ public class UpdateBlackListOverdueDayParallel implements ParallelComputingProce
p.processForThread(tmpQueryList, this, THREAD_COUNT, optSet);
//并行框架执行结果
if (optSet.size() > 0) {//并行框架执行异常
log.info(log_inf + "-runUpdate更新逾期天数执行结束-部分失败, cost: {} <<<<<< process optSet size: {} , json: {} ", (System.currentTimeMillis()-startProcess), optSet.size(), JSONObject.toJSONString(optSet));
Set<String> resultSet = new HashSet<>();
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 {
//执行成功
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) {
log.error(log_inf +"-runUpdate更新逾期天数执行异常.", e);
}
......@@ -94,11 +129,11 @@ public class UpdateBlackListOverdueDayParallel implements ParallelComputingProce
String dateName = ConstantBlackGrey.PARAM.DF_YMD.format(Calendar.getInstance().getTime());
int list_size = blackResultList.size();
AtomicInteger ok_count = new AtomicInteger();
AtomicInteger err_count = new AtomicInteger();
AtomicInteger uuid_isNull_count = new AtomicInteger();
AtomicInteger type_11 = new AtomicInteger();
AtomicInteger update_count = new AtomicInteger();
AtomicInteger update_d_count = new AtomicInteger();
AtomicInteger update_r_count = new AtomicInteger();
int index = 0;
for (BlackGreyListResult blackResult : blackResultList) {
......@@ -146,7 +181,7 @@ public class UpdateBlackListOverdueDayParallel implements ParallelComputingProce
int update = updateOverdueDay(overdueDays, detailsVo, "现金贷");
if(update>0){
details_is_update = true;
update_count.getAndAdd(update);
update_d_count.getAndAdd(update);
}
}
......@@ -173,7 +208,7 @@ public class UpdateBlackListOverdueDayParallel implements ParallelComputingProce
int update = updateOverdueDay(overdueDays, detailsVo, "白条");
if(update>0){
details_is_update = true;
update_count.getAndAdd(update);
update_d_count.getAndAdd(update);
}
}
......@@ -203,7 +238,7 @@ public class UpdateBlackListOverdueDayParallel implements ParallelComputingProce
int update = updateOverdueDay(overdueDays, detailsVo, "白条");
if(update>0){
details_is_update = true;
update_count.getAndAdd(update);
update_d_count.getAndAdd(update);
}
}
}else{
......@@ -218,8 +253,10 @@ public class UpdateBlackListOverdueDayParallel implements ParallelComputingProce
//如果明细表有修改,更新一下结果表修改时间
if(details_is_update){
//更新结果表
updateResultUpdatedAt(blackResult.getRId());
ok_count.getAndIncrement();
int update_r = updateResultUpdatedAt(blackResult.getRId());
if(update_r>0){
update_r_count.getAndIncrement();
}
}
}else {
......@@ -234,13 +271,17 @@ public class UpdateBlackListOverdueDayParallel implements ParallelComputingProce
log.error(log_inf + "更新黑名单逾期天执行异常process() threadId:" + threadId, e);
}
}else {
err_count.getAndIncrement();
uuid_isNull_count.getAndIncrement();
optSet.add("uuid空:" + rId);
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);
}
......
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();
}
}
}
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);
}
}
}
/*
* 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
/*
* 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;
}
}
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(){}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment