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

导入黑名单fix

parent 862b506c
......@@ -70,8 +70,8 @@ public class BlackListSourceConfig {
return sessionFactory.getObject();
}
@Bean(name = "blackListSqlSessionTemplate")
public SqlSessionTemplate qgBlSqlSessionTemplate(@Qualifier("blackListSqlSessionFactory") SqlSessionFactory sqlSessionFactory) throws Exception {
@Bean(name = "blackListJdbcTemplate")
public SqlSessionTemplate blackListJdbcTemplate(@Qualifier("blackListSqlSessionFactory") SqlSessionFactory sqlSessionFactory) throws Exception {
return new SqlSessionTemplate(sqlSessionFactory);
}
......
......@@ -8,12 +8,23 @@ public class Constant {
public static class SQL{
public static final String BATCH_INSERT_BLACK_THREE_ELE_LIST_SQL = "insert ignore into black_list_new (`uuid`, `name`, `phone_no`, `id_no`, `major_type`, `type`, `first_overdue_days`, `max_overdue_days`, `black_level`, `created_at`, `updated_at`) values(?,?,?,?,?,?,?,?,?,?,?)";
public static final String BATCH_INSERT_BLACK_PHONE_LIST_SQL = "insert ignore into phone_black_list_new (`uuid`, `name`, `phone_no`, `id_no`, `major_type`, `type`, `first_overdue_days`, `max_overdue_days`, `black_level`, `created_at`, `updated_at`) values(?,?,?,?,?,?,?,?,?,?,?)";
public static final String QUERY_BLACKLIST_SQL = "select * from black_list_new where phone_no = '%s';";
public static String BATCH_INSERT_BLACK_THREE_ELE_LIST_SQL = "insert ignore into black_list_new (`uuid`, `name`, `phone_no`, `id_no`, `major_type`, `type`, `first_overdue_days`, `max_overdue_days`, `black_level`, `belongs_type`, `created_at`, `updated_at`) values(?,?,?,?,?,?,?,?,?,?,?,?)";
public static String 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 UPDATE_BY_RECORD_ID_SQL = "update black_list_new set status = 0, created_at = '%s', updated_at = '%s' where id = %s;";
public static String 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 UPDATE_THIRD_PART_BLACK_LIST_SQL = "update black_list_new set uuid = '%s', name = '%s', phone_no = '%s', id_no = '%s', updated_at = '%s' where id = %s;";
public static final String BATCH_INSERT_BLACK_IDCARD_LIST_SQL = "";
public static String INSERT_THIRD_PART_BLACK_LIST_SQL = "insert into `black_list_new` (`uuid`, `name`, `phone_no`, `id_no`, `major_type`, `type`, `black_level`, `belongs_type`, `created_at`, `updated_at`) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
public static String QUERY_THIRD_PART_BLACK_LIST_CONFIG = "select * from third_part_black_list_config where status = true;";
}
public static class BATCH_TYPE{
public static final String BATCH_PHONES_MONTH = "BATCH_PHONES_MONTH";
public static final String BATCH_IDCARDS_MONTH = "BATCH_IDCARDS_MONTH";
public static final String BATCH_PHONES_DAYS = "BATCH_PHONES_DAYS";
public static final String BATCH_IDCARDS_DAYS = "BATCH_IDCARDS_DAYS";
}
}
......@@ -2,6 +2,8 @@ package cn.quantgroup.qgblservice.controller;
import cn.quantgroup.qgblservice.response.GlobalResponse;
import cn.quantgroup.qgblservice.service.IBlackListImportService;
import cn.quantgroup.qgblservice.service.IBlackListManagerService;
import cn.quantgroup.qgblservice.service.IThirdPartBlackListManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -19,19 +21,37 @@ public class BlackListImportManagerController {
@Autowired
private IBlackListImportService iBlackListImportManagerService;
@Autowired
private IBlackListManagerService iBlackListManagerService;
@Autowired
private IThirdPartBlackListManagerService iThirdPartBlackListManagerService;
@RequestMapping("/phone_black_list_import_by_month")
public GlobalResponse phoneBlackListImportByMonth(String startTime, String endTime) {
return iBlackListImportManagerService.blackListPhoneImport(startTime, endTime);
}
@RequestMapping("/id_no_black_list_import_by_month")
public GlobalResponse idNoBlackListImportByMonth(String startTime, String endTime){
return iBlackListImportManagerService.blackListIdCardImport(startTime, endTime);
}
@RequestMapping("/third_part_black_list")
public GlobalResponse thirdPartBlackList(String uuid, String name, String phoneNo, String idCard, String type){
return iThirdPartBlackListManagerService.saveThirdPartBlackList(uuid, name, phoneNo, idCard, type);
}
@RequestMapping("/phone_black_list_test")
public GlobalResponse phoneBlackListTest(String startTime, String endTime){
iBlackListManagerService.blackListPhoneManagerByDay(startTime, endTime);
return GlobalResponse.success();
}
@RequestMapping("/idcard_black_list_test")
public GlobalResponse idcardBlackListTest(String startTime, String endTime){
iBlackListManagerService.blackListIdCardManagerByDay(startTime, endTime);
return GlobalResponse.success();
}
}
package cn.quantgroup.qgblservice.model.blacklist;
import lombok.Data;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @Author fengjunkai
* @Date 2019-08-12 17:49
*/
@Data
public class ThirdPartBlackListConfigVo0 implements Serializable {
private Long id;
private String type;
private String name;
private String channelType;
private boolean status;
private Timestamp createdAt;
private Timestamp updatedAt;
}
......@@ -3,6 +3,7 @@ package cn.quantgroup.qgblservice.repository.mybatis.entity;
import cn.quantgroup.qgblservice.utils.CommonBeanUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.SingleColumnRowMapper;
import java.io.Serializable;
import java.lang.reflect.ParameterizedType;
......@@ -15,13 +16,11 @@ import java.sql.SQLException;
*/
public class BaseEntity<T> implements RowMapper<T>, Comparable<T>, Serializable {
public static final long serialVersionUID = 1L;
@Override
public int compareTo(T o) {
return 0;
}
@SuppressWarnings("unchecked")
@Override
public T mapRow(ResultSet rs, int rowNum) throws SQLException {
Class<T> tClass=(Class<T>)((ParameterizedType)getClass().getGenericSuperclass()).getActualTypeArguments()[0];
......
package cn.quantgroup.qgblservice.repository.mybatis.entity.tidb;
import cn.quantgroup.qgblservice.repository.mybatis.entity.BaseEntity;
import lombok.Data;
import java.io.Serializable;
......@@ -11,9 +10,9 @@ import java.sql.Timestamp;
* @Date 2019-07-31 19:36
*/
@Data
public class BlackListQueryTidbVo0 extends BaseEntity<BlackListQueryTidbVo0> implements Serializable {
public class BlackListQueryTidbVo0 implements Serializable {
private static final long serialVersionUID = -3763596487278973104L;
private static final long serialVersionUID = 3504867579864272343L;
private long id;
private String uuid;
......@@ -25,6 +24,7 @@ public class BlackListQueryTidbVo0 extends BaseEntity<BlackListQueryTidbVo0> imp
private String firstOverdueDays;
private String maxOverdueDays;
private String blackLevel;
private String belongsType;
private boolean status;
private Timestamp createdAt;
private Timestamp updatedAt;
......
......@@ -57,11 +57,11 @@
</select>
<select id="findBlackListByPhone" parameterType="cn.quantgroup.qgblservice.repository.mybatis.entity.tidb.BlackListQueryByThreeEleParam0" resultMap="BaseResultMap">
select * from black_list_new where phone_no = #{phone, jdbcType=VARCHAR}
select * from black_list_new where phone_no = #{phone, jdbcType=VARCHAR} and status = true;
</select>
<select id="findBlackListByIdcard" parameterType="cn.quantgroup.qgblservice.repository.mybatis.entity.tidb.BlackListQueryByThreeEleParam0" resultMap="BaseResultMap">
select * from black_list_new where phone_no = #{id_no, jdbcType=VARCHAR}
select * from black_list_new where phone_no = #{id_no, jdbcType=VARCHAR} and status = true;
</select>
<update id="updateThreeElementsById" parameterType="cn.quantgroup.qgblservice.repository.mybatis.entity.tidb.BlackListQueryTidbVo0">
......@@ -70,8 +70,8 @@
<if test="uuid!=null">uuid = #{uuid,jdbcType=VARCHAR},</if>
<if test="name!=null">name = #{name,jdbcType=VARCHAR},</if>
<if test="phoneNo!=null">phone_no = #{phoneNo,jdbcType=VARCHAR},</if>
<if test="idNo!=null">id_no = #{idNo,jdbcType=VARCHAR},</if>
where id = #{id}
<if test="idNo!=null">id_no = #{idNo,jdbcType=VARCHAR}</if>
where id = #{id} and status = true;
</set>
</update>
......
......@@ -26,6 +26,7 @@
,c.name name
,a.phone phone_no
,c.id_no id_no
,'0' belongs_type
,a.createDate created_at
,a.createDate updated_at
,case when a.type&lt;=99 and a.type>=1 then '1'
......@@ -64,6 +65,7 @@
,a.realName name
,b.phone_no phone_no
,a.idcard id_no
,'1' belongs_type
,a.createDate created_at
,a.createDate updated_at
,case when a.type&lt;=99 and a.type>=1 then '1'
......
package cn.quantgroup.qgblservice.response;
import lombok.Data;
/**
* 统一输出实体
*
* @Author fengjunkai
* @Date 2019-07-31 17:22
*/
@Data
public class GlobalResponse {
private int code;
......
package cn.quantgroup.qgblservice.service;
import cn.quantgroup.qgblservice.response.GlobalResponse;
/**
* @Author fengjunkai
* @Date 2019-08-12 17:24
*/
public interface IThirdPartBlackListManagerService {
public GlobalResponse saveThirdPartBlackList(String uuid, String name, String phoneNo, String idCard, String type);
}
......@@ -48,8 +48,8 @@ public class BlackListImportServiceImpl implements IBlackListImportService {
try {
startTime = erlyDate.plusMonths(i).format(DateTimeFormatter.ISO_DATE);
endTime = erlyDate.plusMonths(i + 1).format(DateTimeFormatter.ISO_DATE);
startTime = erlyDate.plusMonths(i).format(DateTimeFormatter.ISO_DATE);
if (phoneBreakDate.equalsIgnoreCase(startTime)) {
break;
......
package cn.quantgroup.qgblservice.service.impl;
import cn.quantgroup.qgblservice.constant.Constant;
import cn.quantgroup.qgblservice.repository.mybatis.entity.tidb.BlackListQueryByThreeEleParam0;
import cn.quantgroup.qgblservice.repository.mybatis.entity.tidb.BlackListQueryTidbParam0;
import cn.quantgroup.qgblservice.repository.mybatis.entity.tidb.BlackListQueryTidbVo0;
import cn.quantgroup.qgblservice.repository.mybatis.mapper.blacklist.BlackListQueryMapper;
......@@ -10,11 +11,15 @@ import cn.quantgroup.qgblservice.utils.jdbc.JdbcExecuters;
import com.google.common.base.Stopwatch;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
/**
......@@ -45,8 +50,8 @@ public class BlackListManagerServiceImpl implements IBlackListManagerService {
if (CollectionUtils.isNotEmpty(blackListQueryTidbVo0s)) {
Stopwatch stopwatch = Stopwatch.createStarted();
int batchExecuteResult = JdbcExecuters.batchExecute(blackListQueryTidbVo0s, Constant.SQL.BATCH_INSERT_BLACK_THREE_ELE_LIST_SQL, blackListJdbcTemplate);
log.info("{} - {} 手机号黑名单关联三要素导入完成, 结果大小: {} , 入库大小: {} , 耗时: {} ", startTime, endTime, blackListQueryTidbVo0s.size(), batchExecuteResult, stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
int batchExecuteResult = JdbcExecuters.batchExecute(blackListQueryTidbVo0s, Constant.SQL.BATCH_INSERT_BLACK_THREE_ELE_LIST_SQL, blackListJdbcTemplate, Constant.BATCH_TYPE.BATCH_PHONES_MONTH);
log.info("{} - {} 手机号黑名单(month)关联三要素导入完成, 结果大小: {} , 入库大小: {} , 耗时: {} ", startTime, endTime, blackListQueryTidbVo0s.size(), batchExecuteResult, stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
}
}
......@@ -64,8 +69,8 @@ public class BlackListManagerServiceImpl implements IBlackListManagerService {
if (CollectionUtils.isNotEmpty(blackListQueryTidbVo0s)) {
Stopwatch stopwatch = Stopwatch.createStarted();
int batchExecuteResult = JdbcExecuters.batchExecute(blackListQueryTidbVo0s, Constant.SQL.BATCH_INSERT_BLACK_THREE_ELE_LIST_SQL, blackListJdbcTemplate);
log.info("{} - {} 身份证号黑名单关联三要素导入完成, 结果大小: {} , 入库大小: {} , 耗时: {} ", startTime, endTime, blackListQueryTidbVo0s.size(), batchExecuteResult, stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
int batchExecuteResult = JdbcExecuters.batchExecute(blackListQueryTidbVo0s, Constant.SQL.BATCH_INSERT_BLACK_THREE_ELE_LIST_SQL, blackListJdbcTemplate, Constant.BATCH_TYPE.BATCH_IDCARDS_MONTH);
log.info("{} - {} 身份证号黑名单(month)关联三要素导入完成, 结果大小: {} , 入库大小: {} , 耗时: {} ", startTime, endTime, blackListQueryTidbVo0s.size(), batchExecuteResult, stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
}
}
......@@ -74,6 +79,20 @@ public class BlackListManagerServiceImpl implements IBlackListManagerService {
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.batchExecute(blackListQueryTidbVo0s, Constant.SQL.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));
}
}
......@@ -82,6 +101,79 @@ public class BlackListManagerServiceImpl implements IBlackListManagerService {
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.batchExecute(blackListQueryTidbVo0s, Constant.SQL.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));
}
}
/**
* blackListQueryTidbVo0 三要素+uuid都不为空的时候采取更新数据库中对应三要素缺失的记录
*
* @param blackListByPhones
* @param blackListQueryTidbVo0
*/
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.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.UPDATE_BY_RECORD_ID_SQL, blackListByPhone.getCreatedAt(), blackListByPhone.getUpdatedAt(), blackListByPhone.getId()));
log.info("{} 黑名单禁用", type);
}else{
blackListJdbcTemplate.update(String.format(Constant.SQL.UPDATE_THREE_ELE_SQL, blackListByPhone.getUuid(), blackListByPhone.getName(), blackListByPhone.getPhoneNo(), blackListByPhone.getIdNo(), blackListByPhone.getId()));
log.info("{} 黑名单更新缺失三要素", type);
}
}
} catch (Exception e) {
log.error("{} 黑名单单条更新异常", type, e);
}
}
}
......
package cn.quantgroup.qgblservice.service.impl;
import cn.quantgroup.qgblservice.constant.Constant;
import cn.quantgroup.qgblservice.model.blacklist.ThirdPartBlackListConfigVo0;
import cn.quantgroup.qgblservice.repository.mybatis.entity.tidb.BlackListQueryTidbVo0;
import cn.quantgroup.qgblservice.response.GlobalResponse;
import cn.quantgroup.qgblservice.service.IThirdPartBlackListManagerService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.sql.Timestamp;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
/**
* 三方数据源黑名单管理保存
*
* @Author fengjunkai
* @Date 2019-08-12 17:25
*/
@Slf4j
@Service
public class ThirdPartBlackListServiceImpl implements IThirdPartBlackListManagerService {
@Autowired
private JdbcTemplate blackListJdbcTemplate;
private static Map<String, String> thirdPartBlackListCacheConfigMap = new ConcurrentHashMap<>();
@Override
public GlobalResponse saveThirdPartBlackList(String uuid, String name, String phoneNo, String idCard, String type) {
try {
List<BlackListQueryTidbVo0> blackListQueryTidbVo0s = blackListJdbcTemplate.query(String.format(Constant.SQL.QUERY_BY_UNIQUE_KEY_SQL,
phoneNo, name, idCard, thirdPartBlackListCacheConfigMap.get(type)), new BeanPropertyRowMapper<>(BlackListQueryTidbVo0.class));
if (CollectionUtils.isNotEmpty(blackListQueryTidbVo0s)) {
for (int i = 0; i < blackListQueryTidbVo0s.size(); i++) {
BlackListQueryTidbVo0 blackListQueryTidbVo0 = blackListQueryTidbVo0s.get(i);
blackListQueryTidbVo0.setUpdatedAt(new Timestamp(System.currentTimeMillis()));
blackListJdbcTemplate.update(String.format(Constant.SQL.UPDATE_THIRD_PART_BLACK_LIST_SQL,
blackListQueryTidbVo0.getUuid(), blackListQueryTidbVo0.getName(), blackListQueryTidbVo0.getPhoneNo(), blackListQueryTidbVo0.getIdNo(), blackListQueryTidbVo0.getUpdatedAt(), blackListQueryTidbVo0.getId()));
}
} else {
saveThirdPartBlackListJdbc(uuid, name, phoneNo, idCard, type);
}
return GlobalResponse.success("保存成功");
} catch (Exception e) {
log.error("保存三方数据源黑名单异常, uuid: {} , name: {} , phoneNo: {} , idCard: {} ", uuid, name, phoneNo, idCard, e);
}
return GlobalResponse.error("保存异常");
}
public void saveThirdPartBlackListJdbc(String uuid, String name, String phoneNo, String idCard, String type) {
Object param[] = new Object[10];
param[0] = uuid;
param[1] = name;
param[2] = phoneNo;
param[3] = idCard;
param[4] = "3";
param[5] = thirdPartBlackListCacheConfigMap.get(type);
param[6] = "C2";
param[7] = "3";
param[8] = new Timestamp(System.currentTimeMillis());
param[9] = new Timestamp(System.currentTimeMillis());
blackListJdbcTemplate.update(Constant.SQL.INSERT_THIRD_PART_BLACK_LIST_SQL, param);
}
@PostConstruct
public void initThirdPartBlackListConfig() {
List<ThirdPartBlackListConfigVo0> thirdPartBlackListConfigVo0s = blackListJdbcTemplate.query(Constant.SQL.QUERY_THIRD_PART_BLACK_LIST_CONFIG, new BeanPropertyRowMapper<>(ThirdPartBlackListConfigVo0.class));
thirdPartBlackListCacheConfigMap = thirdPartBlackListConfigVo0s.stream().collect(Collectors.toMap(ThirdPartBlackListConfigVo0::getChannelType, ThirdPartBlackListConfigVo0::getType));
}
}
......@@ -17,7 +17,7 @@ public class JdbcExecuters {
private static final Logger log = LoggerFactory.getLogger(JdbcExecuters.class);
public static int batchExecute(List<BlackListQueryTidbVo0> blackListQueryTidbVo0s, String sql, JdbcTemplate jdbcTemplate) {
public static int batchExecute(List<BlackListQueryTidbVo0> blackListQueryTidbVo0s, String sql, JdbcTemplate jdbcTemplate, String type) {
Connection conn = null;
PreparedStatement ps = null;
AtomicInteger atomicInteger = new AtomicInteger();
......@@ -38,8 +38,9 @@ public class JdbcExecuters {
ps.setString(7, blackListQueryTidbVo0.getFirstOverdueDays());
ps.setString(8, blackListQueryTidbVo0.getMaxOverdueDays());
ps.setString(9, blackListQueryTidbVo0.getBlackLevel());
ps.setTimestamp(10, blackListQueryTidbVo0.getCreatedAt());
ps.setTimestamp(11, blackListQueryTidbVo0.getUpdatedAt());
ps.setString(10, blackListQueryTidbVo0.getBelongsType());
ps.setTimestamp(11, blackListQueryTidbVo0.getCreatedAt());
ps.setTimestamp(12, blackListQueryTidbVo0.getUpdatedAt());
ps.addBatch();
atomicInteger.getAndIncrement();
......@@ -55,7 +56,7 @@ public class JdbcExecuters {
conn.commit();
} catch (Exception e) {
log.error("清洗数据批量插入数据异常", e);
log.error("{} 批量插入数据异常", type, e);
} finally {
close(conn, ps, null);
}
......@@ -78,7 +79,7 @@ public class JdbcExecuters {
if (conn != null)
conn.close();
} catch (SQLException e) {
log.error("清洗数据关闭jdbc资源异常", e);
log.error("关闭jdbc资源异常", 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