Commit b5af60f1 authored by data爬虫-冯 军凯's avatar data爬虫-冯 军凯

黑名单添加内部渠道和三方数据源黑名单等级更新功能

parent 84181606
......@@ -14,7 +14,7 @@ public class Constant {
public static String BLACK_LIST_NEW_BATCH_INSERT_BLACK_THREE_ELE_LIST_SQL = "insert ignore into black_list_new (`uuid`, `name`, `phone_no`, `id_no`, `major_type`, `type`, `total_overdue_days`, `max_overdue_days`, `black_level`, `join_black_reason`, `created_at`, `updated_at`) values(?,?,?,?,?,?,?,?,?,?,?,?)";
public static String BLACK_LIST_NEW_QUERY_BY_UNIQUE_KEY_SQL = "select * from black_list_new where phone_no = '%s' and name = '%s' and id_no = '%s' and type = '%s';";
public static String BLACK_LIST_NEW_UPDATE_DISABLE_BY_RECORD_ID_SQL = "update black_list_new set status = false, updated_at = '%s' where id = %s;";
public static String BLACK_LIST_NEW_UPDATE_THREE_ELE_SQL = "update black_list_new set uuid = '%s', name = '%s', phone_no = '%s' , id_no = '%s' where id = %s;";
public static String BLACK_LIST_NEW_UPDATE_THREE_ELE_AND_BLACK_LEVEL_SQL = "update black_list_new set uuid = '%s', name = '%s', phone_no = '%s' , id_no = '%s', black_level = '%s' where id = %s;";
public static String BLACK_LIST_NEW_UPDATE_BLACK_LIST_LEVEL_SQL = "update black_list_new set black_level = '%s' where id = %s;";
public static String BLACK_LIST_NEW_INSERT_THIRD_PART_BLACK_LIST_SQL = "insert into `black_list_new` (`uuid`, `name`, `phone_no`, `id_no`, `major_type`, `type`, `black_level`, `join_black_reason`, `created_at`, `updated_at`) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
public static String BLACK_LIST_NEW_UPDATE_FIRST_OR_MAX_OVERDUE_DAYS_SQL = "update black_list_new set total_overdue_days = ? , max_overdue_days = ?, updated_at = ? where id = ?";
......@@ -23,7 +23,7 @@ public class Constant {
public static String BLACK_LIST_NEW_QUERY_BY_IDNO_SQL = "select * from black_list_new where id_no = '%s' and status = true;";
public static String BLACK_LIST_NEW_QUERY_BY_PHONENO_IDNO_SQL = "select * from black_list_new where phone_no = '%s' and id_no = '%s' and status = true;";
public static String BLACK_LIST_NEW_QUERY_BY_THREE_ELE_SQL = "select * from black_list_new where phone_no = '%s' and id_no = '%s' and name = '%s' and status = true;";
public static String BLACK_LIST_NEW_QUERY_BY_IDNO_OR_PHONENO_SQL = "select * from black_list_new where phone_no = '%s' or id_no = '%s' and status = true;";
public static String BLACK_LIST_NEW_QUERY_BY_IDNO_OR_PHONENO_SQL = "select * from black_list_new where phone_no = '%s' or id_no = '%s'";
public static String BLACK_LIST_NEW_QUERY_BY_UUID_SQL = "select * from black_list_new where uuid = '%s' and status = true;";
public static String XYQB_QUERY_USER_LOAN_OVERDUE_15DAY_SQL = "select a.user_id id, now() created_at, now() updated_at, 1 major_type, 1 type, '逾期15+' join_black_reason, null total_overdue_days, null max_overdue_days, '1' status, 'A1' black_level from repayment_plan a left join loan_application_manifest_history d on a.loan_application_history_id=d.loan_application_history_id where a.deadline<=DATE_SUB(CURDATE(),INTERVAL 15 day) and a.deadline>DATE_SUB(CURDATE(),INTERVAL 20 day) and a.repayment_status not in (3,4) and d.transaction_status in (2,5);";
......
......@@ -111,98 +111,98 @@ public class BlackListManagerServiceImpl implements IBlackListManagerService {
@Override
public void blackListPhoneManagerByDay(String startTime, String endTime) {
List<BlackListQueryTidbVo0> blackListQueryTidbVo0s = blackListQueryTidbMapper.findBlackListPhoneByTime(BlackListQueryTidbParam0.builder().startTime(startTime).endTime(endTime).build());
for (int i = 0; i < blackListQueryTidbVo0s.size(); i++) {
BlackListQueryTidbVo0 blackListQueryTidbVo0 = blackListQueryTidbVo0s.get(i);
List<BlackListQueryTidbVo0> blackListByPhones = blackListQueryMapper.findBlackListByPhone(BlackListQueryByThreeEleParam0.builder().phone(blackListQueryTidbVo0.getPhoneNo()).build());
updateOrNo(blackListByPhones, blackListQueryTidbVo0, Constant.BATCH_TYPE.BATCH_PHONES_DAYS);
}
if (CollectionUtils.isNotEmpty(blackListQueryTidbVo0s)) {
Stopwatch stopwatch = Stopwatch.createStarted();
int batchExecuteResult = JdbcExecuters.blackListImportBatchExecute(blackListQueryTidbVo0s, Constant.SQL.BLACK_LIST_NEW_BATCH_INSERT_BLACK_THREE_ELE_LIST_SQL, blackListJdbcTemplate, Constant.BATCH_TYPE.BATCH_PHONES_DAYS);
log.info("{} - {} 手机号黑名单(day)关联三要素导入完成, 结果大小: {} , 入库大小: {} , 耗时: {} ", startTime, endTime, blackListQueryTidbVo0s.size(), batchExecuteResult, stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
}
// List<BlackListQueryTidbVo0> blackListQueryTidbVo0s = blackListQueryTidbMapper.findBlackListPhoneByTime(BlackListQueryTidbParam0.builder().startTime(startTime).endTime(endTime).build());
//
// for (int i = 0; i < blackListQueryTidbVo0s.size(); i++) {
//
// BlackListQueryTidbVo0 blackListQueryTidbVo0 = blackListQueryTidbVo0s.get(i);
// List<BlackListQueryTidbVo0> blackListByPhones = blackListQueryMapper.findBlackListByPhone(BlackListQueryByThreeEleParam0.builder().phone(blackListQueryTidbVo0.getPhoneNo()).build());
//
// updateOrNo(blackListByPhones, blackListQueryTidbVo0, Constant.BATCH_TYPE.BATCH_PHONES_DAYS);
//
// }
//
// if (CollectionUtils.isNotEmpty(blackListQueryTidbVo0s)) {
// Stopwatch stopwatch = Stopwatch.createStarted();
// int batchExecuteResult = JdbcExecuters.blackListImportBatchExecute(blackListQueryTidbVo0s, Constant.SQL.BLACK_LIST_NEW_BATCH_INSERT_BLACK_THREE_ELE_LIST_SQL, blackListJdbcTemplate, Constant.BATCH_TYPE.BATCH_PHONES_DAYS);
// log.info("{} - {} 手机号黑名单(day)关联三要素导入完成, 结果大小: {} , 入库大小: {} , 耗时: {} ", startTime, endTime, blackListQueryTidbVo0s.size(), batchExecuteResult, stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
// }
}
@Override
public void blackListIdCardManagerByDay(String startTime, String endTime) {
List<BlackListQueryTidbVo0> blackListQueryTidbVo0s = blackListQueryTidbMapper.findBlackListIdCardByTime(BlackListQueryTidbParam0.builder().startTime(startTime).endTime(endTime).build());
for (int i = 0; i < blackListQueryTidbVo0s.size(); i++) {
BlackListQueryTidbVo0 blackListQueryTidbVo0 = blackListQueryTidbVo0s.get(i);
List<BlackListQueryTidbVo0> blackListByIdcards = blackListQueryMapper.findBlackListByIdcard(BlackListQueryByThreeEleParam0.builder().phone(blackListQueryTidbVo0.getIdNo()).build());
updateOrNo(blackListByIdcards, blackListQueryTidbVo0, Constant.BATCH_TYPE.BATCH_IDCARDS_DAYS);
}
if (CollectionUtils.isNotEmpty(blackListQueryTidbVo0s)) {
Stopwatch stopwatch = Stopwatch.createStarted();
int batchExecuteResult = JdbcExecuters.blackListImportBatchExecute(blackListQueryTidbVo0s, Constant.SQL.BLACK_LIST_NEW_BATCH_INSERT_BLACK_THREE_ELE_LIST_SQL, blackListJdbcTemplate, Constant.BATCH_TYPE.BATCH_IDCARDS_DAYS);
log.info("{} - {} 身份证号黑名单(day)关联三要素导入完成, 结果大小: {} , 入库大小: {} , 耗时: {} ", startTime, endTime, blackListQueryTidbVo0s.size(), batchExecuteResult, stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
}
}
public void updateOrNo(List<BlackListQueryTidbVo0> blackListByPhones, BlackListQueryTidbVo0 blackListQueryTidbVo0, String type) {
for (int j = 0; j < blackListByPhones.size(); j++) {
try {
BlackListQueryTidbVo0 blackListByPhone = blackListByPhones.get(j);
String name = blackListByPhone.getName();
String idNo = blackListByPhone.getIdNo();
String uuid = blackListByPhone.getUuid();
String phoneNo = blackListByPhone.getPhoneNo();
if (StringUtils.isAnyBlank(name, idNo, uuid, phoneNo)
&& StringUtils.isNotBlank(blackListQueryTidbVo0.getUuid())
&& StringUtils.isNotBlank(blackListQueryTidbVo0.getIdNo())
&& StringUtils.isNotBlank(blackListQueryTidbVo0.getName())
&& StringUtils.isNotBlank(blackListQueryTidbVo0.getPhoneNo())) {
if (StringUtils.isBlank(phoneNo) && StringUtils.isNotBlank(blackListQueryTidbVo0.getPhoneNo())) {
blackListByPhone.setPhoneNo(blackListQueryTidbVo0.getPhoneNo());
}
if (StringUtils.isBlank(name) && StringUtils.isNotBlank(blackListQueryTidbVo0.getName())) {
blackListByPhone.setName(blackListQueryTidbVo0.getName());
}
if (StringUtils.isBlank(idNo) && StringUtils.isNotBlank(blackListQueryTidbVo0.getIdNo())) {
blackListByPhone.setIdNo(blackListQueryTidbVo0.getIdNo());
}
if (StringUtils.isBlank(uuid) && StringUtils.isNotBlank(blackListQueryTidbVo0.getUuid())) {
blackListByPhone.setUuid(blackListQueryTidbVo0.getUuid());
}
List<BlackListQueryTidbVo0> blackListQueryTidbVo0s = blackListJdbcTemplate.query(String.format(Constant.SQL.BLACK_LIST_NEW_QUERY_BY_UNIQUE_KEY_SQL,
blackListQueryTidbVo0.getPhoneNo(), blackListQueryTidbVo0.getName(), blackListQueryTidbVo0.getIdNo(), blackListQueryTidbVo0.getType()), new BeanPropertyRowMapper<>(BlackListQueryTidbVo0.class));
if (CollectionUtils.isNotEmpty(blackListQueryTidbVo0s)) {
blackListJdbcTemplate.update(String.format(Constant.SQL.BLACK_LIST_NEW_UPDATE_DISABLE_BY_RECORD_ID_SQL, blackListByPhone.getUpdatedAt(), blackListByPhone.getId()));
log.info("{} 黑名单禁用", type);
} else {
blackListJdbcTemplate.update(String.format(Constant.SQL.BLACK_LIST_NEW_UPDATE_THREE_ELE_SQL, blackListByPhone.getUuid(), blackListByPhone.getName(), blackListByPhone.getPhoneNo(), blackListByPhone.getIdNo(), blackListByPhone.getId()));
log.info("{} 黑名单更新缺失三要素", type);
}
}
} catch (Exception e) {
log.error("{} 黑名单单条更新异常", type, e);
}
}
}
// List<BlackListQueryTidbVo0> blackListQueryTidbVo0s = blackListQueryTidbMapper.findBlackListIdCardByTime(BlackListQueryTidbParam0.builder().startTime(startTime).endTime(endTime).build());
//
// for (int i = 0; i < blackListQueryTidbVo0s.size(); i++) {
//
// BlackListQueryTidbVo0 blackListQueryTidbVo0 = blackListQueryTidbVo0s.get(i);
// List<BlackListQueryTidbVo0> blackListByIdcards = blackListQueryMapper.findBlackListByIdcard(BlackListQueryByThreeEleParam0.builder().phone(blackListQueryTidbVo0.getIdNo()).build());
//
// updateOrNo(blackListByIdcards, blackListQueryTidbVo0, Constant.BATCH_TYPE.BATCH_IDCARDS_DAYS);
//
// }
//
// if (CollectionUtils.isNotEmpty(blackListQueryTidbVo0s)) {
// Stopwatch stopwatch = Stopwatch.createStarted();
// int batchExecuteResult = JdbcExecuters.blackListImportBatchExecute(blackListQueryTidbVo0s, Constant.SQL.BLACK_LIST_NEW_BATCH_INSERT_BLACK_THREE_ELE_LIST_SQL, blackListJdbcTemplate, Constant.BATCH_TYPE.BATCH_IDCARDS_DAYS);
// log.info("{} - {} 身份证号黑名单(day)关联三要素导入完成, 结果大小: {} , 入库大小: {} , 耗时: {} ", startTime, endTime, blackListQueryTidbVo0s.size(), batchExecuteResult, stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
// }
}
// public void updateOrNo(List<BlackListQueryTidbVo0> blackListByPhones, BlackListQueryTidbVo0 blackListQueryTidbVo0, String type) {
//
// for (int j = 0; j < blackListByPhones.size(); j++) {
//
// try {
// BlackListQueryTidbVo0 blackListByPhone = blackListByPhones.get(j);
// String name = blackListByPhone.getName();
// String idNo = blackListByPhone.getIdNo();
// String uuid = blackListByPhone.getUuid();
// String phoneNo = blackListByPhone.getPhoneNo();
//
// if (StringUtils.isAnyBlank(name, idNo, uuid, phoneNo)
// && StringUtils.isNotBlank(blackListQueryTidbVo0.getUuid())
// && StringUtils.isNotBlank(blackListQueryTidbVo0.getIdNo())
// && StringUtils.isNotBlank(blackListQueryTidbVo0.getName())
// && StringUtils.isNotBlank(blackListQueryTidbVo0.getPhoneNo())) {
//
// if (StringUtils.isBlank(phoneNo) && StringUtils.isNotBlank(blackListQueryTidbVo0.getPhoneNo())) {
// blackListByPhone.setPhoneNo(blackListQueryTidbVo0.getPhoneNo());
// }
//
// if (StringUtils.isBlank(name) && StringUtils.isNotBlank(blackListQueryTidbVo0.getName())) {
// blackListByPhone.setName(blackListQueryTidbVo0.getName());
// }
//
// if (StringUtils.isBlank(idNo) && StringUtils.isNotBlank(blackListQueryTidbVo0.getIdNo())) {
// blackListByPhone.setIdNo(blackListQueryTidbVo0.getIdNo());
// }
//
// if (StringUtils.isBlank(uuid) && StringUtils.isNotBlank(blackListQueryTidbVo0.getUuid())) {
// blackListByPhone.setUuid(blackListQueryTidbVo0.getUuid());
// }
//
// List<BlackListQueryTidbVo0> blackListQueryTidbVo0s = blackListJdbcTemplate.query(String.format(Constant.SQL.BLACK_LIST_NEW_QUERY_BY_UNIQUE_KEY_SQL,
// blackListQueryTidbVo0.getPhoneNo(), blackListQueryTidbVo0.getName(), blackListQueryTidbVo0.getIdNo(), blackListQueryTidbVo0.getType()), new BeanPropertyRowMapper<>(BlackListQueryTidbVo0.class));
//
// if (CollectionUtils.isNotEmpty(blackListQueryTidbVo0s)) {
// blackListJdbcTemplate.update(String.format(Constant.SQL.BLACK_LIST_NEW_UPDATE_DISABLE_BY_RECORD_ID_SQL, blackListByPhone.getUpdatedAt(), blackListByPhone.getId()));
// log.info("{} 黑名单禁用", type);
// } else {
// blackListJdbcTemplate.update(String.format(Constant.SQL.BLACK_LIST_NEW_UPDATE_THREE_ELE_SQL, blackListByPhone.getUuid(), blackListByPhone.getName(), blackListByPhone.getPhoneNo(), blackListByPhone.getIdNo(), blackListByPhone.getId()));
// log.info("{} 黑名单更新缺失三要素", type);
// }
//
// }
// } catch (Exception e) {
// log.error("{} 黑名单单条更新异常", type, e);
// }
//
// }
//
// }
}
......@@ -78,7 +78,7 @@ public class BlackListQueryManagerServiceImpl implements IBlackListQueryManagerS
return GlobalResponse.error("查询黑名单异常");
}
public List<BlackListQueryTidbVo0> getBlackListData(String queryBlackListSql, String queryUserIdSql, String uuid, String name, String phoneNo, String idNo, String type) {
public List<BlackListQueryTidbVo0> getBlackListData(String queryBlackListSql, String queryUserIdSql, String uuid, String name, String phoneNo, String idNo, String type) { //TODO 身份证或者手机号查询过滤掉status=false的
Stopwatch stopwatch = Stopwatch.createStarted();
List<BlackListQueryTidbVo0> queryListBlackListByPhoneNos = blackListJdbcTemplate.query(queryBlackListSql, new BeanPropertyRowMapper<>(BlackListQueryTidbVo0.class));
log.info("用户黑名单查询结果, uuid: {} , name: {} , phoneNo: {} , idNo: {} , type: {} , result: {} ", uuid, name, phoneNo, idNo, type, JSON.toJSONString(queryListBlackListByPhoneNos));
......@@ -97,7 +97,7 @@ public class BlackListQueryManagerServiceImpl implements IBlackListQueryManagerS
queryListBlackListByPhoneNos.stream().filter(o -> Timestamp.valueOf(
LocalDateTime.now().minusYears(channelBlackListExpireConfigMap.get(o.getType())).format(DateTimeFormatter.ofPattern(Constant.DAYE_FORMAT.YYYY_MM_DD_HH_MM_SS))
).getTime() - o.getCreatedAt().getTime() < 0).forEach(blackListQueryTidbVo0 -> {
).getTime() - o.getCreatedAt().getTime() < 0 && o.isStatus()).forEach(blackListQueryTidbVo0 -> {
if (CollectionUtils.isNotEmpty(totalOverdueDaysList)) {
Object totalOverdueDays = totalOverdueDaysList.get(0).get(Constant.PARAM.TOTAL_OVERDUE_DAYS);
......@@ -121,7 +121,7 @@ public class BlackListQueryManagerServiceImpl implements IBlackListQueryManagerS
queryListBlackListByPhoneNos.stream().filter(o -> Timestamp.valueOf(
LocalDateTime.now().minusYears(channelBlackListExpireConfigMap.get(o.getType())).format(DateTimeFormatter.ofPattern(Constant.DAYE_FORMAT.YYYY_MM_DD_HH_MM_SS))
).getTime() - o.getCreatedAt().getTime() < 0).forEach(blackListQueryTidbVo0 -> {
).getTime() - o.getCreatedAt().getTime() < 0 && o.isStatus()).forEach(blackListQueryTidbVo0 -> {
Timestamp updatedAt = new Timestamp(System.currentTimeMillis());
String updatedAtStr = updatedAt.toLocalDateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
......
......@@ -40,7 +40,7 @@ public class BlackListUpdateThreeEleServiceImpl implements IBlackListUpdateThree
for (int j = 0; j < query.size(); j++) {
BlackListQueryTidbVo0 blackListQueryTidbVo01 = query.get(j);
if (StringUtils.isAnyBlank(blackListQueryTidbVo01.getUuid(), blackListQueryTidbVo01.getName(), blackListQueryTidbVo01.getPhoneNo(), blackListQueryTidbVo01.getIdNo())) {
if (StringUtils.isAnyBlank(blackListQueryTidbVo01.getUuid(), blackListQueryTidbVo01.getName(), blackListQueryTidbVo01.getPhoneNo(), blackListQueryTidbVo01.getIdNo()) && blackListQueryTidbVo01.isStatus()) {
if (StringUtils.isBlank(blackListQueryTidbVo01.getUuid()) && StringUtils.isNotBlank(blackListQueryTidbVo0.getUuid())) {
blackListQueryTidbVo01.setUuid(blackListQueryTidbVo0.getUuid());
......@@ -65,14 +65,11 @@ public class BlackListUpdateThreeEleServiceImpl implements IBlackListUpdateThree
blackListQueryTidbVo01.setUpdatedAt(new Timestamp(System.currentTimeMillis()));
blackListJdbcTemplate.update(String.format(Constant.SQL.BLACK_LIST_NEW_UPDATE_DISABLE_BY_RECORD_ID_SQL, blackListQueryTidbVo01.getUpdatedAt(), blackListQueryTidbVo01.getId()));
} else {
blackListJdbcTemplate.update(String.format(Constant.SQL.BLACK_LIST_NEW_UPDATE_THREE_ELE_SQL, blackListQueryTidbVo0.getUuid(), blackListQueryTidbVo0.getName(), blackListQueryTidbVo0.getPhoneNo(), blackListQueryTidbVo0.getIdNo(), blackListQueryTidbVo01.getId()));
BlackListUtils.getOrUpdateBlackListLevel(blackListQueryTidbVo01, type);
blackListJdbcTemplate.update(String.format(Constant.SQL.BLACK_LIST_NEW_UPDATE_THREE_ELE_AND_BLACK_LEVEL_SQL, blackListQueryTidbVo0.getUuid(), blackListQueryTidbVo0.getName(), blackListQueryTidbVo0.getPhoneNo(), blackListQueryTidbVo0.getIdNo(), blackListQueryTidbVo01.getId()));
}
}
if(type.equals(Constant.PARAM.BLACK_LIST_INNER_PART)){
BlackListUtils.getOrUpdateBlackListLevel(blackListQueryTidbVo0, Constant.PARAM.BLACK_LIST_INNER_PART);
blackListJdbcTemplate.update(String.format(Constant.SQL.BLACK_LIST_NEW_UPDATE_BLACK_LIST_LEVEL_SQL, blackListQueryTidbVo0.getBlackLevel(), blackListQueryTidbVo0.getId()));
}
}
}catch(Exception e){
log.error("更新黑名单三要素异常{} ", type, e);
......
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