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

黑名单增加手机号/身份证号MD5查询功能

parent 349cb206
......@@ -11,12 +11,14 @@ 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_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_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';";
public static String BLACK_LIST_NEW_QUERY_BY_UNIQUE_KEY_SQL2_MD5 = "select * from black_list_new where phone_no = '%s' and name = '%s' and id_no = '%s' and type = '%s' and phone_no_md5 = '%s' and id_no_md5 = '%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_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_THREE_ELE_AND_BLACK_LEVEL_SQL = "update black_list_new set uuid = '%s', name = '%s', phone_no = '%s' , id_no = '%s', black_level = '%s', phone_no_md5 = '%s', id_no_md5 = '%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_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`,`phone_no_md5`,`id_no_md5`) 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 = ?";
public static String BLACK_LIST_NEW_QUERY_BY_PHONENO_SQL = "select * from black_list_new where phone_no = '%s' and status = true;";
......@@ -25,6 +27,12 @@ public class Constant {
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'";
public static String BLACK_LIST_NEW_QUERY_BY_UUID_SQL = "select * from black_list_new where uuid = '%s' and status = true;";
public static String BLACK_LIST_NEW_QUERY_BY_PHONENOMD5_SQL = "select * from black_list_new where phone_no_md5 = '%s' and status = true;";
public static String BLACK_LIST_NEW_QUERY_BY_IDNOMD5_SQL = "select * from black_list_new where id_no_md5 = '%s' and status = true;";
public static String BLACK_LIST_NEW_QUERY_BY_PHONENOMD5_AND_IDNOMD5_SQL = "select * from black_list_new where phone_no_md5 = '%s' and id_no_md5 = '%s' and status = true;";
public static String BLACK_LIST_NEW_QUERY_BY_PHONENOMD5_OR_IDNOMD5_SQL = "select * from black_list_new where phone_no_md5 = '%s' or id_no_md5 = '%s';";
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);";
// public static String XYQB_QUERY_USER_FIRST_TERM_OVERDUE_SQL = "select if(repayment_status=3,DATEDIFF(repaid_at,deadline)+1,DATEDIFF(CURDATE(),deadline)+1) total_overdue_days from repayment_plan where user_id in (%s) and deadline<=CURDATE() and (repayment_status not in (3,4) or (repayment_status=3 and repaid_at>=deadline)) order by deadline desc limit 1;";
......@@ -41,6 +49,8 @@ public class Constant {
public static String BLACK_LIST_NEW_QUERY_BY_IDNO_SQL2 = "select * from black_list_new where id_no = '%s' and created_at < '%s' and status = true;";
public static String BLACK_LIST_NEW_QUERY_BY_PHONENO_SQL2 = "select * from black_list_new where phone_no = '%s' and created_at < '%s' and status = true;";
public static String BLACK_LIST_NEW_UPDATE_PHONENOMD5_AND_IDNOMD5_SQL = "update black_list_new set `phone_no_md5`=? ,`id_no_md5`=? where `id`=? ";
}
public static class BATCH_TYPE {
......@@ -49,6 +59,9 @@ public class Constant {
public static final String BATCH_PHONES_DAYS = "BATCH_PHONES_DAYS";
public static final String BATCH_IDCARDS_DAYS = "BATCH_IDCARDS_DAYS";
public static final String BATCH_UPDATE_OVERDUE_DAYS = "BATCH_UPDATE_OVERDUE_DAYS";
/** 手动批量更新phone_no_md5,id_no_md5字段*/
public static final String BATCH_PHONESMD5_AND_IDNOMD5_MANUAL = "BATCH_PHONESMD5_AND_IDNOMD5_MANUAL";
}
public static class PARAM {
......
......@@ -28,7 +28,7 @@ public class BlackListCacheManagerController {
public GlobalResponse reloadThirdCacheConfig(){
try{
iThirdPartBlackListManagerService.initThirdPartBlackListConfig();
log.info("更新三方数据源缓存配置成功"); //日志
log.info("更新三方数据源缓存配置成功");
return GlobalResponse.success("更新三方数据源缓存配置成功");
}catch(Exception e){
log.error("更新三方数据源缓存配置异常", e);
......
......@@ -29,9 +29,10 @@ public class BlackListQueryManagerController {
* @创建人 yanhui.Hao
* @创建时间 2019.09.10
*/
@RequestMapping("/queryDateBack")
/* @RequestMapping("/queryDateBack")
public GlobalResponse queryDateBack(String filePath,String titleNames, String haveTitle, String queryType){
return iBlackListQueryManagerService.queryDateBack(filePath,titleNames,haveTitle,queryType);
}
}*/
//to moved BlackListToolsManagerController.compareByExcel()...
}
package cn.quantgroup.qgblservice.controller;
import cn.quantgroup.qgblservice.response.GlobalResponse;
import cn.quantgroup.qgblservice.service.IBlackListToolsManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* -----------------------------------------------------------------------------<br>
* 描述: 黑名单表操作工具类<br>
* 作者:yanhui.Hao <br>
* 时间:2019.09.19 <br>
* 授权: (C) Copyright (c) 2017 <br>
* 公司: 北京众信利民信息技术有限公司 <br>
* -----------------------------------------------------------------------------
*/
@RestController
@RequestMapping("/tools")
public class BlackListToolsManagerController {
@Autowired
private IBlackListToolsManagerService iBlackListToolsManagerService;
/**
* @param filePath 原文件地址
* @param titleNames 表格的头部标题,已逗号分隔
* @param haveTitle 非必传,默认true;是否有标题列
* @param byColumnName 查询类别,目前可以传idcard或mobile;name暂不支持
* @param columnDataType 非必传,默认空“明文数据”,或可传值"MD5";Excel表格里的byColumn数据类别
* @return
*/
@RequestMapping("/compareByExcel")
public GlobalResponse compareByExcel(String filePath,String titleNames, String haveTitle, String byColumnName,String columnDataType){
return iBlackListToolsManagerService.compareByExcel(filePath,titleNames,haveTitle,byColumnName,columnDataType);
}
/**
* @param privateKey 私钥
* @param operatType 操作类型,支持all,byId,byCreatUtc
* @param idArray operatType=byId时必传,多个以逗号分隔
* @param gtCreatUtc operatType=byCreatUtc时必传
* @return
*/
@RequestMapping("/buildMd5Tools")
public GlobalResponse buildMd5Tools(String privateKey,String operatType, String idArray, String gtCreatUtc){
return iBlackListToolsManagerService.buildMd5Tools(privateKey,operatType,idArray,gtCreatUtc);
}
}
......@@ -35,4 +35,10 @@ public class BlackListQueryTidbVo0 implements Serializable {
private String joinBlackTime;
private String blackUpdatedTime;
/**phoneNo md5加密*/
private String phoneNoMd5;
/**idNo md5加密*/
private String idNoMd5;
}
......@@ -12,6 +12,6 @@ public interface IBlackListQueryManagerService {
public void initChannelBlackListExpireConfig();
public GlobalResponse queryDateBack(String filePath, String titleNames,String haveTitle, String queryType);
//public GlobalResponse queryDateBack(String filePath, String titleNames,String haveTitle, String queryType);
}
package cn.quantgroup.qgblservice.service;
import cn.quantgroup.qgblservice.response.GlobalResponse;
/**
* -----------------------------------------------------------------------------<br>
* 描述: <br>
* 作者:yanhui.Hao <br>
* 时间:2019.09.19 <br>
* 授权: (C) Copyright (c) 2017 <br>
* 公司: 北京众信利民信息技术有限公司 <br>
* -----------------------------------------------------------------------------
*/
public interface IBlackListToolsManagerService {
/**
* 描述: 用户Excel表格数据和black_list_new黑名单比对 <br/>
* 参数: [filePath, titleNames, haveTitle, byColumnName,columnDataType] <br/>
* 返回值: cn.quantgroup.qgblservice.response.GlobalResponse <br/>
* 创建人: yanhui.Hao <br/>
* 创建时间: 2019.09.10 <br/>
*/
public GlobalResponse compareByExcel(String filePath, String titleNames, String haveTitle, String byColumnName,String columnDataType);
/**
* 描述: 手动更新black_list_new黑名单表手机号&身份证号md5字段 <br/>
* 参数: [filePath, titleNames, haveTitle, queryType] <br/>
* 返回值: cn.quantgroup.qgblservice.response.GlobalResponse <br/>
* 创建人: yanhui.Hao <br/>
* 创建时间: 2019.09.10 <br/>
*/
public GlobalResponse buildMd5Tools(String privateKey, String operatType, String idArray, String gtCreatUtc);
}
......@@ -3,6 +3,7 @@ package cn.quantgroup.qgblservice.service.impl;
import cn.quantgroup.qgblservice.constant.Constant;
import cn.quantgroup.qgblservice.repository.mybatis.entity.tidb.BlackListQueryTidbVo0;
import cn.quantgroup.qgblservice.service.IBlackListUpdateThreeEleService;
import cn.quantgroup.qgblservice.utils.MD5Util;
import cn.quantgroup.qgblservice.utils.blacklist.BlackListUtils;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
......@@ -41,7 +42,8 @@ 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()) && blackListQueryTidbVo01.isStatus()) {
if (StringUtils.isAnyBlank(blackListQueryTidbVo01.getUuid(), blackListQueryTidbVo01.getName(), blackListQueryTidbVo01.getPhoneNo(), blackListQueryTidbVo01.getIdNo(),blackListQueryTidbVo01.getPhoneNoMd5(),blackListQueryTidbVo01.getIdNoMd5())
&& blackListQueryTidbVo01.isStatus()) {
if (StringUtils.isBlank(blackListQueryTidbVo01.getUuid()) && StringUtils.isNotBlank(blackListQueryTidbVo0.getUuid())) {
blackListQueryTidbVo01.setUuid(blackListQueryTidbVo0.getUuid());
......@@ -59,16 +61,34 @@ public class BlackListUpdateThreeEleServiceImpl implements IBlackListUpdateThree
blackListQueryTidbVo01.setIdNo(blackListQueryTidbVo0.getIdNo());
}
//modify 2019.09.20 增加phone_no_md5、id_no_md5
String idCard_md5 = null,phoneNo_md5=null;
if(StringUtils.isNotBlank(blackListQueryTidbVo0.getIdNo())){
idCard_md5 = MD5Util.getMD5Digest(blackListQueryTidbVo0.getIdNo());
}
if(StringUtils.isNotBlank(blackListQueryTidbVo0.getPhoneNo())){
phoneNo_md5 = MD5Util.getMD5Digest(blackListQueryTidbVo0.getPhoneNo());
}
//如果为空,则赋值
if(StringUtils.isBlank(blackListQueryTidbVo01.getIdNoMd5()) && StringUtils.isNotBlank(blackListQueryTidbVo0.getIdNo())){
blackListQueryTidbVo01.setIdNoMd5(idCard_md5);
}
if(StringUtils.isBlank(blackListQueryTidbVo01.getPhoneNoMd5()) && StringUtils.isNotBlank(blackListQueryTidbVo0.getPhoneNo())){
blackListQueryTidbVo01.setPhoneNoMd5(phoneNo_md5);
}
try{
List<BlackListQueryTidbVo0> blackListQueryTidbVo0sByUniqueKey = blackListJdbcTemplate.query(String.format(Constant.SQL.BLACK_LIST_NEW_QUERY_BY_UNIQUE_KEY_SQL,
blackListQueryTidbVo0.getPhoneNo(), blackListQueryTidbVo0.getName(), blackListQueryTidbVo0.getIdNo(), blackListQueryTidbVo01.getType()), new BeanPropertyRowMapper<>(BlackListQueryTidbVo0.class));
//List<BlackListQueryTidbVo0> blackListQueryTidbVo0sByUniqueKey = blackListJdbcTemplate.query(String.format(Constant.SQL.BLACK_LIST_NEW_QUERY_BY_UNIQUE_KEY_SQL, blackListQueryTidbVo0.getPhoneNo(), blackListQueryTidbVo0.getName(), blackListQueryTidbVo0.getIdNo(), blackListQueryTidbVo01.getType()), new BeanPropertyRowMapper<>(BlackListQueryTidbVo0.class));
List<BlackListQueryTidbVo0> blackListQueryTidbVo0sByUniqueKey = blackListJdbcTemplate.query(String.format(Constant.SQL.BLACK_LIST_NEW_QUERY_BY_UNIQUE_KEY_SQL2_MD5, blackListQueryTidbVo0.getPhoneNo(), blackListQueryTidbVo0.getName(), blackListQueryTidbVo0.getIdNo(), blackListQueryTidbVo01.getType(),
phoneNo_md5,idCard_md5), new BeanPropertyRowMapper<>(BlackListQueryTidbVo0.class));
if (CollectionUtils.isNotEmpty(blackListQueryTidbVo0sByUniqueKey)) {
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 {
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()));
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.getBlackLevel(), phoneNo_md5,idCard_md5, blackListQueryTidbVo01.getId()));
}
}catch(Exception e){
log.error("更新单条黑名单三要素异常, uploadData: {} , queryData: {} ", JSON.toJSONString(blackListQueryTidbVo01), JSON.toJSONString(blackListQueryTidbVo0), e);
......
......@@ -6,10 +6,12 @@ import cn.quantgroup.qgblservice.repository.mybatis.entity.tidb.BlackListQueryTi
import cn.quantgroup.qgblservice.response.GlobalResponse;
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 com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
......@@ -76,7 +78,7 @@ public class ThirdPartBlackListServiceImpl implements IThirdPartBlackListManager
public void saveThirdPartBlackListJdbc(String uuid, String name, String phoneNo, String idCard, String type) {
Object param[] = new Object[10];
Object param[] = new Object[12];
param[0] = uuid;
param[1] = name;
param[2] = phoneNo;
......@@ -87,6 +89,17 @@ public class ThirdPartBlackListServiceImpl implements IThirdPartBlackListManager
param[7] = thirdPartBlackListMap.get(type);
param[8] = new Timestamp(System.currentTimeMillis());
param[9] = new Timestamp(System.currentTimeMillis());
//modify 2019.09.20 增加phone_no_md5、id_no_md5
String phoneNo_md5 = null, idCard_md5 = null;
if(StringUtils.isNotEmpty(phoneNo)){
phoneNo_md5 = MD5Util.getMD5Digest(phoneNo);
}
if(StringUtils.isNotEmpty(idCard)){
idCard_md5 = MD5Util.getMD5Digest(idCard);
}
param[10] = phoneNo_md5;
param[11] = idCard_md5;
blackListJdbcTemplate.update(Constant.SQL.BLACK_LIST_NEW_INSERT_THIRD_PART_BLACK_LIST_SQL, param);
}
......
package cn.quantgroup.qgblservice.utils;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class MD5Util {
private static ThreadLocal<MessageDigest> messageDigestHolder = new ThreadLocal();
static final char[] hexDigits = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
public MD5Util() {
}
public static String getMd5(String plainText) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(plainText.getBytes());
byte b[] = md.digest();
int i;
StringBuffer buf = new StringBuffer("");
for (int offset = 0; offset < b.length; offset++) {
i = b[offset];
if (i < 0)
i += 256;
if (i < 16)
buf.append("0");
buf.append(Integer.toHexString(i));
}
// 32位加密
return buf.toString();
// 16位的加密
// return buf.toString().substring(8, 24);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
return null;
}
}
public static String getMD5Format(String data) {
try {
MessageDigest e = (MessageDigest) messageDigestHolder.get();
if (e == null) {
e = MessageDigest.getInstance("MD5");
messageDigestHolder.set(e);
}
e.update(data.getBytes());
byte[] b = e.digest();
String digestHexStr = "";
for (int i = 0; i < 16; ++i) {
digestHexStr = digestHexStr + byteHEX(b[i]);
}
return digestHexStr;
} catch (Exception var5) {
System.out.println(var5);
return null;
}
}
public static String getMD5Format(byte[] data) {
try {
MessageDigest e = (MessageDigest) messageDigestHolder.get();
if (e == null) {
e = MessageDigest.getInstance("MD5");
messageDigestHolder.set(e);
}
e.update(data);
byte[] b = e.digest();
String digestHexStr = "";
for (int i = 0; i < 16; ++i) {
digestHexStr = digestHexStr + byteHEX(b[i]);
}
return digestHexStr;
} catch (Exception var5) {
return null;
}
}
private static String byteHEX(byte ib) {
char[] ob = new char[]{hexDigits[ib >>> 4 & 15], hexDigits[ib & 15]};
String s = new String(ob);
return s;
}
static {
try {
MessageDigest e = MessageDigest.getInstance("MD5");
messageDigestHolder.set(e);
} catch (NoSuchAlgorithmException var1) {
System.out.println(var1);
}
}
public static String getMD5Digest(String msg) {
try {
MessageDigest md5 = (MessageDigest) messageDigestHolder.get();
if (md5 == null) {
md5 = MessageDigest.getInstance("MD5");
messageDigestHolder.set(md5);
}
byte[] byteArray=null;
byteArray=msg.getBytes();
byte[] md5Bytes=md5.digest(byteArray);
StringBuffer hexValue=new StringBuffer();
for(int i=0; i < md5Bytes.length; i++) {
int val=((int)md5Bytes[i]) & 0xff;
if(val < 16)
hexValue.append("0");
hexValue.append(Integer.toHexString(val));
}
return hexValue.toString();
} catch (Exception var5) {
System.out.println(var5);
return null;
}
}
}
package cn.quantgroup.qgblservice.utils.jdbc;
import cn.quantgroup.qgblservice.repository.mybatis.entity.tidb.BlackListQueryTidbVo0;
import cn.quantgroup.qgblservice.utils.MD5Util;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.JdbcTemplate;
......@@ -42,6 +44,18 @@ public class JdbcExecuters {
ps.setTimestamp(11, blackListQueryTidbVo0.getCreatedAt());
ps.setTimestamp(12, blackListQueryTidbVo0.getUpdatedAt());
//modify 2019.09.20 增加phone_no_md5、id_no_md5
String phoneNo_md5 = null, idCard_md5 = null;
if(StringUtils.isNotEmpty(blackListQueryTidbVo0.getPhoneNo())){
phoneNo_md5 = MD5Util.getMD5Digest(blackListQueryTidbVo0.getPhoneNo());
}
if(StringUtils.isNotEmpty(blackListQueryTidbVo0.getIdNo())){
idCard_md5 = MD5Util.getMD5Digest(blackListQueryTidbVo0.getIdNo());
}
ps.setString(13,phoneNo_md5);
ps.setString(14,idCard_md5);
ps.addBatch();
atomicInteger.getAndIncrement();
......@@ -96,12 +110,58 @@ public class JdbcExecuters {
} catch (Exception e) {
log.error("{} 批量插入数据异常", type, e);
return 0;
} finally {
close(conn, ps, null);
}
return atomicInteger.get();
}
/**
* 描述: 根据用户id批量修改 phone_no_md5,id_no_md5 <br/>
* 参数: [blackListQueryTidbVo0s, sql, jdbcTemplate, type] <br/>
* 返回值: int <br/>
* 创建人: yanhui.Hao <br/>
* 创建时间: 2019.09.19 <br/>
*/
public static int blackListUpdateMd5BatchExecute(List<BlackListQueryTidbVo0> blackListQueryTidbVo0s, String sql, JdbcTemplate jdbcTemplate, String type) {
Connection conn = null;
PreparedStatement ps = null;
AtomicInteger atomicInteger = new AtomicInteger();
try {
conn = jdbcTemplate.getDataSource().getConnection();
ps = conn.prepareStatement(sql);
conn.setAutoCommit(false);
//update black_list_new set phone_no_md5='111' ,id_no_md5='111' where id=111;
for (int i = 0; i < blackListQueryTidbVo0s.size(); i++) {
BlackListQueryTidbVo0 blackListbean = blackListQueryTidbVo0s.get(i);
ps.setString(1, blackListbean.getPhoneNoMd5());
ps.setString(2, blackListbean.getIdNoMd5());
ps.setLong(3, blackListbean.getId());
ps.addBatch();
atomicInteger.getAndIncrement();
if (i > 0 && i % 500 == 0) {
ps.executeBatch();
conn.commit();
ps.clearBatch();
}
}
ps.executeBatch();
conn.commit();
} catch (Exception e) {
log.error("{} 批量修改数据异常", type, e);
} finally {
close(conn, ps, null);
}
return atomicInteger.get();
}
/**
* 关闭资源
*
......
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