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

黑灰名单2020.04.28_01

parent 4e6f0984
......@@ -10,6 +10,8 @@ public class Constant {
public static String BLACK_LIST_NEW_QUERY_THIRD_PART_BLACK_LIST_CONFIG_SQL = "select * from third_part_black_list_config where status = true;";
public static String BLACK_LIST_NEW_QUERY_CHANNEL_BLACK_LIST_EXPIRE_CONFIG_SQL = "select * from black_list_channel_expire_config where status = true";
public static String BLACK_GREY_LIST_REASON_CONFIG_SQL = "select * from black_grey_list_reason_config where status = true;";
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`, `phone_no_md5`, `id_no_md5`) 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';";
......
......@@ -17,7 +17,7 @@ public class ConstantBlackGrey {
public static class SQL {
public static String XYQB_QUERY_XianJinDai_15DAY = "SELECT c.uuid, d.name, d.phone_no, d.id_no, " +
"now() created_at, now() updated_at, '1' black_type, '1' type, '1' join_black_reason, NULL max_overdue_days, NULL total_overdue_days, NULL remark " +
"now() created_at, now() updated_at, '1' black_type, '1' type, 'B_001' reason_code, NULL max_overdue_days, NULL total_overdue_days, NULL remark " +
"FROM repayment_plan a " +
" LEFT JOIN loan_application_manifest_history b ON a.loan_application_history_id = b.loan_application_history_id " +
" LEFT JOIN `user` c ON a.user_id = c.id " +
......@@ -38,19 +38,12 @@ public class ConstantBlackGrey {
"AND a.repay_date>DATE_SUB(CURDATE(),INTERVAL 20 day);";
public static String XYQBUSER_QUERY_VCC_15DAY = "SELECT c.uuid, d.name, d.phone_no, d.id_no, " +
" now() created_at, now() updated_at, '1' black_type, '10' type, '2' join_black_reason, NULL max_overdue_days, NULL total_overdue_days, NULL remark " +
" now() created_at, now() updated_at, '1' black_type, '10' type, 'B_002' reason_code, NULL max_overdue_days, NULL total_overdue_days, NULL remark " +
" FROM `user` c " +
" LEFT JOIN user_detail d ON c.id = d.user_id " +
"WHERE c.id IN (##IN_USER_ID##);";
//分页查询结果表黑名单
public static String BL_QUERY_BLACKLIST_RESULT_BY_LIMIT = "SELECT r.* " +
" FROM black_grey_list_result r " +
" INNER JOIN ( " +
" SELECT br.r_id FROM black_grey_list_result br " +
" where br.black_type='1' " +
" ORDER BY br.r_id LIMIT ?, ? " +
") AS page USING(r_id); ";
public static String BL_QUERY_BLACKLIST_RESULT_MAX_ID = " SELECT max(id) as 'maxId' FROM black_grey_list_result r WHERE r.black_type='1';";
public static String BL_QUERY_BLACKLIST_RESULT_BY_LIMIT_ID = " SELECT ##r.*## " +
" FROM black_grey_list_result r " +
......
package cn.quantgroup.qgblservice.model.blacklist;
import lombok.Data;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* -----------------------------------------------------------------------------<br>
* 类描述: 加入黑灰名单原因配置表 black_grey_list_reason_config <br>
* 创建人: yanhui.Hao <br>
* 创建时间: 2020.04.28 15:43 <br>
* 公司: 北京众信利民信息技术有限公司 <br>
* -----------------------------------------------------------------------------
*/
@Data
public class BlackGreyListReasonConfig implements Serializable {
private Long id;
private String blackType;
private String type;
private String reasonCode;
private String reasonExplain;
private boolean status;
private Timestamp createdAt;
private Timestamp updatedAt;
}
package cn.quantgroup.qgblservice.repository.mybatis.entity.blacklist;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
......@@ -67,7 +68,8 @@ public class BlackGreyListResult implements Serializable {
return typesSet;
}
public static List<ReasonsVo> reasonsToList(String oldJsonStr, String newReason, String newType){
@Deprecated
public static List<ReasonsVo> reasonsToList_old(String oldJsonStr, String newReason, String newType){
List<ReasonsVo> reasonList = null;
try {
if(StringUtils.isNotEmpty(oldJsonStr)) {
......@@ -102,8 +104,8 @@ public class BlackGreyListResult implements Serializable {
return reasonList;
}
public static List<ReasonsVo> reasonsToList2(String oldJsonStr, String newReason, String newType){
//在历史reason的json基础上追加
public static List<ReasonsVo> reasonsToList(String oldJsonStr, String newReasonCode, String newType){
List<ReasonsVo> reasonList = null;
try {
if(StringUtils.isNotEmpty(oldJsonStr)) {
......@@ -117,8 +119,8 @@ public class BlackGreyListResult implements Serializable {
reasonList = new ArrayList<ReasonsVo>();
}
//ReasonsVo数值长度最多保存6条,大于6条的丢弃掉历史最老的
int maxLeng = 6;
//`reasons` varchar(1024) 最多保存18条ReasonsVo,不能无限追加,大于18条的丢弃掉历史最老的
int maxLeng = 18;
int size = reasonList.size();
if(size >= maxLeng){
//把ReasonsVo按照时间从小到大排列
......@@ -140,10 +142,11 @@ public class BlackGreyListResult implements Serializable {
for(int i=0; i < maxLeng-1; i++){
tmpList.add(reasonList.get(size-1-i));
}
reasonList = tmpList;
}
ReasonsVo newObj = new ReasonsVo();
newObj.setReason(newReason);
newObj.setReason(newReasonCode);
newObj.setType(newType);
newObj.setUtcTime(System.currentTimeMillis());
reasonList.add(newObj);
......@@ -151,6 +154,12 @@ public class BlackGreyListResult implements Serializable {
}
/* public static void main(String[] args) {
String oldJsonStr = "[{\"reason\":\"G_001\",\"type\":\"1\",\"utcTime\":1570550400000},{\"reason\":\"G_001\",\"type\":\"2\",\"utcTime\":1587128783310},{\"reason\":\"G_001\",\"type\":\"10\",\"utcTime\":1587128790628}]";
List<ReasonsVo> reasonsToList = BlackGreyListResult.reasonsToList(oldJsonStr, "G_999", "99");
System.out.println(JSON.toJSONString(reasonsToList));
}*/
......
......@@ -33,7 +33,7 @@ public class TmpBlackGreyList implements Serializable {
private String blackType;
private String type;
private String joinBlackReason;
//private String joinBlackReason;
private String maxOverdueDays;
private String totalOverdueDays;
......@@ -44,5 +44,7 @@ public class TmpBlackGreyList implements Serializable {
@JsonIgnore
private Timestamp updatedAt;
private String reasonCode;
private String reasonExplain;
}
......@@ -38,7 +38,7 @@ public class TmpBlackGreyListRowMapper implements RowMapper<TmpBlackGreyList> {
bean.setIdNo(rs.getString("id_no"));
bean.setBlackType(rs.getString("black_type"));
bean.setType(rs.getString("type"));
bean.setJoinBlackReason(rs.getString("join_black_reason"));
bean.setReasonCode(rs.getString("reason_code"));
bean.setMaxOverdueDays(rs.getString("max_overdue_days"));
bean.setTotalOverdueDays(rs.getString("total_overdue_days"));
bean.setCreatedAt(rs.getTimestamp("created_at"));
......
......@@ -26,10 +26,11 @@
<result column="idNo" jdbcType="VARCHAR" property="id_no"/>
<result column="type" jdbcType="VARCHAR" property="type"/>
<result column="reasonCode" jdbcType="VARCHAR" property="reason_code"/>
<!--<result column="reasonExplain" jdbcType="VARCHAR" property="reason_explain"/>-->
<result column="totalOverdueDays" jdbcType="VARCHAR" property="total_overdue_days"/>
<result column="maxOverdueDays" jdbcType="VARCHAR" property="max_overdue_days"/>
<result column="status" jdbcType="INTEGER" property="status"/>
<result column="remark" jdbcType="VARCHAR" property="remark"/>
<!-- <result column="remark" jdbcType="VARCHAR" property="remark"/>-->
<result column="createdAt" jdbcType="TIMESTAMP" property="created_at"/>
<result column="updatedAt" jdbcType="TIMESTAMP" property="updated_at"/>
</resultMap>
......@@ -62,11 +63,13 @@
<select id="findBGLResultByRid" parameterType="java.lang.String" resultMap="BlackGreyListResultMap">
select * from black_grey_list_result where r_id = #{rId, jdbcType=VARCHAR} ;
select id, r_id, uuid, name, phone_no, id_no, phone_no_md5, id_no_md5, black_type, types, reasons, created_at, updated_at
from black_grey_list_result where r_id = #{rId, jdbcType=VARCHAR} ;
</select>
<select id="findBlackGreyListResult" parameterType="cn.quantgroup.qgblservice.repository.mybatis.entity.blacklist.BlackGreyListQueryVo" resultMap="BlackGreyListResultMap">
select * from black_grey_list_result
select id, r_id, uuid, name, phone_no, id_no, phone_no_md5, id_no_md5, black_type, types, reasons, created_at, updated_at
from black_grey_list_result
<trim prefix="where" prefixOverrides="and">
<if test="rId != null">
and r_id = #{rId,jdbcType=VARCHAR}
......@@ -91,7 +94,8 @@
</select>
<select id="findBlackGreyListResultBy3YS" parameterType="cn.quantgroup.qgblservice.repository.mybatis.entity.blacklist.BlackGreyListQueryVo" resultMap="BlackGreyListResultMap">
select * from black_grey_list_result
select id, r_id, uuid, name, phone_no, id_no, phone_no_md5, id_no_md5, black_type, types, reasons, created_at, updated_at
from black_grey_list_result
where
<choose>
<when test = "phoneNo == null">
......@@ -122,7 +126,7 @@
</select>
<select id="findBlackGreyListDetails" parameterType="cn.quantgroup.qgblservice.repository.mybatis.entity.blacklist.BlackGreyListQueryVo" resultMap="BlackGreyListDetailsMap">
select id, r_id, name, phone_no, id_no, type, reason_code, max_overdue_days, total_overdue_days, status, remark, created_at, updated_at
select id, r_id, name, phone_no, id_no, type, reason_code, max_overdue_days, total_overdue_days, status, created_at, updated_at
from black_grey_list_details
<trim prefix="where" prefixOverrides="and">
<if test="rId != null">
......@@ -153,7 +157,7 @@
</select>
<select id="findBlackGreyListDetailsBy3YS" parameterType="cn.quantgroup.qgblservice.repository.mybatis.entity.blacklist.BlackGreyListQueryVo" resultMap="BlackGreyListDetailsMap">
select id, r_id, name, phone_no, id_no, type, reason_code, max_overdue_days, total_overdue_days, status, remark, created_at, updated_at
select id, r_id, name, phone_no, id_no, type, reason_code, max_overdue_days, total_overdue_days, status, created_at, updated_at
from black_grey_list_details
where
<choose>
......@@ -217,7 +221,6 @@
</select>
<insert id="insertBlackGreyListResult"
parameterType="cn.quantgroup.qgblservice.repository.mybatis.entity.blacklist.BlackGreyListResult">
insert ignore into black_grey_list_result (`r_id`, `uuid`, `name`, `phone_no`, `id_no`, `phone_no_md5`, `id_no_md5`, `black_type`, `types`, `reasons`, `created_at`, `updated_at`)
......@@ -235,23 +238,6 @@
#{maxOverdueDays, jdbcType=VARCHAR}, #{totalOverdueDays, jdbcType=VARCHAR}, #{status, jdbcType=INTEGER}, #{remark, jdbcType=VARCHAR}, #{createdAt, jdbcType=VARCHAR}, #{updatedAt, jdbcType=VARCHAR})
</insert>
<!--<insert id="insertBatch"
parameterType="cn.quantgroup.qgblservice.repository.mybatis.entity.tidb.BlackListQueryTidbVo0">
insert into black_list_new (`uuid`, `name`, `phone_no`, `id_no`, `major_type`, `type`, `total_overdue_days`,
`max_overdue_days`, `black_level`)
values
<foreach collection="list" item="item" separator=",">
(#{uuid, jdbcType=VARCHAR},
#{name, jdbcType=VARCHAR},
#{phone_no, jdbcType=VARCHAR},
#{id_no, jdbcType=VARCHAR},
#{major_type, jdbcType=VARCHAR},
#{type, jdbcType=VARCHAR},
#{total_overdue_days, jdbcType=VARCHAR},
#{max_overdue_days, jdbcType=VARCHAR},
#{black_level, jdbcType=VARCHAR})
</foreach>
</insert>-->
<update id="updateBlackGreyListResult" parameterType="cn.quantgroup.qgblservice.repository.mybatis.entity.blacklist.BlackGreyListResult">
update black_grey_list_result
......@@ -266,7 +252,6 @@
</update>
<update id="updateDetailsStatusByparams" parameterType="cn.quantgroup.qgblservice.repository.mybatis.entity.blacklist.DetailsUpdate">
/*update black_grey_list_details set status = ?, updated_at = ? where r_id = ? AND status =10 AND type IN ('1','2','10')*/
update black_grey_list_details
set status = #{status,jdbcType=INTEGER}, updated_at = #{updatedAt,jdbcType=VARCHAR}
where
......
......@@ -198,8 +198,8 @@ public class BlackToGreyListParallel implements ParallelComputingProcess<BlackGr
//可以有多个type,说明至少有一个逾期还没还清,就不能转出黑名单
is_grey_result = false;
}else if(detailsVo.getStatus().intValue()==10){
//Set<String> typeSet = BlackGreyListResult.typesToSet(blackResult.getTypes(), rJoinDVo.getType());
reasonsList = BlackGreyListResult.reasonsToList(blackResult.getReasons(), "6", detailsVo.getType());
//G_002 发生过15天以上逾期已经结清的客户,从黑名单转标记为灰名单
reasonsList = BlackGreyListResult.reasonsToList(blackResult.getReasons(), "G_002", detailsVo.getType());
}
}
......
package cn.quantgroup.qgblservice.service.impl;
import cn.quantgroup.qgblservice.constant.Constant;
import cn.quantgroup.qgblservice.model.blacklist.BlackGreyListReasonConfig;
import cn.quantgroup.qgblservice.model.blacklist.ThirdPartBlackListConfigVo0;
import cn.quantgroup.qgblservice.repository.mybatis.entity.blacklist.BlackGreyListDetails;
import cn.quantgroup.qgblservice.repository.mybatis.entity.blacklist.BlackGreyListQueryVo;
......@@ -50,6 +51,12 @@ public class ThirdPartBlackListServiceImpl implements IThirdPartBlackListManager
private static Map<String, String> thirdPartBlackListCacheConfigMap = new ConcurrentHashMap<>();
private static Map<String, String> thirdPartBlackListMap = new ConcurrentHashMap<>();
//2020.04.28 根据黑灰名单开源type,获取加入黑灰名单原因code
public static Map<String, String> getReasonCodeByTypeMap = new ConcurrentHashMap<>();
//2020.04.28 加入黑灰名单原因code,获取原因中文描述
public static Map<String, String> getReasonExplainByReasonCodeMap = new ConcurrentHashMap<>();
@Autowired
private BlackGreyListMapper blackGreyListMapper;
......@@ -126,9 +133,12 @@ public class ThirdPartBlackListServiceImpl implements IThirdPartBlackListManager
List<ThirdPartBlackListConfigVo0> thirdPartBlackListConfigVo0s = blackListJdbcTemplate.query(Constant.SQL.BLACK_LIST_NEW_QUERY_THIRD_PART_BLACK_LIST_CONFIG_SQL, new BeanPropertyRowMapper<>(ThirdPartBlackListConfigVo0.class));
thirdPartBlackListCacheConfigMap = thirdPartBlackListConfigVo0s.stream().collect(Collectors.toMap(ThirdPartBlackListConfigVo0::getChannelType, ThirdPartBlackListConfigVo0::getType));
thirdPartBlackListMap = thirdPartBlackListConfigVo0s.stream().collect(Collectors.toMap(ThirdPartBlackListConfigVo0::getChannelType, ThirdPartBlackListConfigVo0::getName));
log.info("加载三方数据源黑名单配置完成, result: {} ", JSON.toJSONString(thirdPartBlackListCacheConfigMap));
List<BlackGreyListReasonConfig> blackGreyListReasonConfigList = blackListJdbcTemplate.query(Constant.SQL.BLACK_GREY_LIST_REASON_CONFIG_SQL, new BeanPropertyRowMapper<>(BlackGreyListReasonConfig.class));
getReasonCodeByTypeMap = blackGreyListReasonConfigList.stream().collect(Collectors.toMap(BlackGreyListReasonConfig::getType, BlackGreyListReasonConfig::getReasonCode));
getReasonExplainByReasonCodeMap = blackGreyListReasonConfigList.stream().collect(Collectors.toMap(BlackGreyListReasonConfig::getReasonCode, BlackGreyListReasonConfig::getReasonExplain));
log.info("加载三方数据源黑灰名单原因配置完成, map: {} ", JSON.toJSONString(getReasonCodeByTypeMap));
}
@Override
......@@ -136,17 +146,18 @@ public class ThirdPartBlackListServiceImpl implements IThirdPartBlackListManager
//2020.04.26 历史黑名单继续写入,暂时未线下
try {
log.info("历史黑名单继续写入, uuid: {} , name: {} , phoneNo: {} , idCard: {} , type: {} ", uuid, name, phoneNo, idCard, type);
saveThirdPartBlackList(uuid, name, phoneNo, idCard, type);
}catch (Exception e){
log.error("保存历史黑名单异常", e);
}
//根据三方数据源urlType获取黑灰名单来源type
String typeCode = thirdPartBlackListCacheConfigMap.get(type);
String joinBlackReason = thirdPartBlackListMap.get(type);
if(StringUtils.isEmpty(typeCode)){
log.error("插入黑灰名单时-未匹配到typeCode! uuid: {} , name: {} , phoneNo: {} , idCard: {} , type: {} ", uuid, name, phoneNo, idCard, type);
String reasonCode = getReasonCodeByTypeMap.get(type);
String reasonExplain = getReasonExplainByReasonCodeMap.get(reasonCode);
if(org.apache.commons.lang3.StringUtils.isAnyEmpty(typeCode, reasonCode, reasonExplain)){
log.error("插入黑灰名单时-未匹配到typeCode或reason! uuid: {} , name: {} , phoneNo: {} , idCard: {} , type: {} ", uuid, name, phoneNo, idCard, type);
return GlobalResponse.error("参数type未匹配到typeCode!");
}
BlackGreyListQueryVo queryResultParam = BlackGreyListQueryVo.builder().name(name).idNo(idCard).phoneNo(phoneNo)
......@@ -161,7 +172,8 @@ public class ThirdPartBlackListServiceImpl implements IThirdPartBlackListManager
TmpBlackGreyList blackGreyObj = new TmpBlackGreyList();
blackGreyObj.setBlackType("2");//灰名单
blackGreyObj.setType(typeCode);
//blackGreyObj.setJoinBlackReason(array[6].trim());
blackGreyObj.setReasonCode(reasonCode);
blackGreyObj.setReasonExplain(reasonExplain);
if(StringUtils.isNotEmpty(uuid)){
blackGreyObj.setUuid(uuid);
......@@ -184,7 +196,7 @@ public class ThirdPartBlackListServiceImpl implements IThirdPartBlackListManager
blackGreyList.add(blackGreyObj);
int saveOkCount = blackGreyListService.saveBlackGreyListByJdbc(blackGreyList);
return GlobalResponse.success("保存成功"+saveOkCount+"条");
return GlobalResponse.success("保存黑灰名单成功"+saveOkCount+"条");
} catch (SQLException e) {
log.error("保存黑灰名单数据异常", e);
}
......
......@@ -89,7 +89,7 @@ public class ReadOrWriteTxt {
List<String> lineList = new ArrayList<String>();
try {
FileInputStream fileInputStream = new FileInputStream(file);
InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "GBK");
InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream);
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
StringBuffer sb = new StringBuffer();
......
......@@ -187,7 +187,7 @@ public class JdbcExecuters {
ps.setString(7, vo.getIdNoMd5());
ps.setString(8, vo.getBlackType());
ps.setString(9, vo.getType());
ps.setString(10, vo.getJoinBlackReason());
ps.setString(10, vo.getReasonCode());
ps.setString(11, vo.getMaxOverdueDays());
ps.setString(12, vo.getTotalOverdueDays());
ps.setTimestamp(13, vo.getCreatedAt());
......
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