Commit 1fb419ac authored by 郑建's avatar 郑建

删掉tidb的使用

parent 2e3d1a7e
......@@ -38,39 +38,39 @@ public class TidbDataSourceConfig {
@Value("${tidb.config-location}")
private String configLocation;
@Autowired
private TidbDataSourceProperties tidbDataSourceProperties;
// @Autowired
// private TidbDataSourceProperties tidbDataSourceProperties;
@Bean(name = "tidbDataSource")
public DataSource tidbDataSource() {
HikariConfig config = new HikariConfig();
config.setJdbcUrl(tidbDataSourceProperties.getJdbcUrl());
log.info("TIDB数据库地址:{}", tidbDataSourceProperties.getJdbcUrl());
config.setPassword(tidbDataSourceProperties.getPassword());
config.setUsername(tidbDataSourceProperties.getUsername());
config.setMaximumPoolSize(tidbDataSourceProperties.getMaxPoolSize());
config.setMinimumIdle(tidbDataSourceProperties.getMinPoolSize());
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
return new HikariDataSource(config);
}
// @Bean(name = "tidbDataSource")
// public DataSource tidbDataSource() {
// HikariConfig config = new HikariConfig();
// config.setJdbcUrl(tidbDataSourceProperties.getJdbcUrl());
// log.info("TIDB数据库地址:{}", tidbDataSourceProperties.getJdbcUrl());
// config.setPassword(tidbDataSourceProperties.getPassword());
// config.setUsername(tidbDataSourceProperties.getUsername());
// config.setMaximumPoolSize(tidbDataSourceProperties.getMaxPoolSize());
// config.setMinimumIdle(tidbDataSourceProperties.getMinPoolSize());
// config.addDataSourceProperty("cachePrepStmts", "true");
// config.addDataSourceProperty("prepStmtCacheSize", "250");
// config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
// return new HikariDataSource(config);
// }
@Bean(name = "tidbSqlSessionFactory")
public SqlSessionFactory tidbSqlSessionFactory(@Qualifier("tidbDataSource") DataSource tidbDataSource) throws Exception {
final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(tidbDataSource);
sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver()
.getResources(mapperLocations));
sessionFactory.setTypeAliasesPackage(typeAliasesPackage);
sessionFactory.setConfigLocation(new PathMatchingResourcePatternResolver()
.getResource(configLocation));
return sessionFactory.getObject();
}
@Bean(name = "tidbSqlSessionTemplate")
public SqlSessionTemplate tidbSqlSessionTemplate(@Qualifier("tidbSqlSessionFactory") SqlSessionFactory tidbSqlSessionFactory) throws Exception {
return new SqlSessionTemplate(tidbSqlSessionFactory, ExecutorType.BATCH);
}
// @Bean(name = "tidbSqlSessionFactory")
// public SqlSessionFactory tidbSqlSessionFactory(@Qualifier("tidbDataSource") DataSource tidbDataSource) throws Exception {
// final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
// sessionFactory.setDataSource(tidbDataSource);
// sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver()
// .getResources(mapperLocations));
// sessionFactory.setTypeAliasesPackage(typeAliasesPackage);
// sessionFactory.setConfigLocation(new PathMatchingResourcePatternResolver()
// .getResource(configLocation));
// return sessionFactory.getObject();
// }
//
// @Bean(name = "tidbSqlSessionTemplate")
// public SqlSessionTemplate tidbSqlSessionTemplate(@Qualifier("tidbSqlSessionFactory") SqlSessionFactory tidbSqlSessionFactory) throws Exception {
// return new SqlSessionTemplate(tidbSqlSessionFactory, ExecutorType.BATCH);
// }
}
......@@ -28,19 +28,6 @@ public class BlackListImportManagerController {
@Autowired
private IThirdPartBlackListManagerService iThirdPartBlackListManagerService;
@RequestMapping("/phone_black_list_import_by_month")
public GlobalResponse phoneBlackListImportByMonth(String startTime, String endTime) {
log.info("方法phoneBlackListImportByMonth入参, startTime: {} , endTime: {} ", startTime, endTime);
return iBlackListImportManagerService.blackListPhoneImport(startTime, endTime);
}
@RequestMapping("/id_no_black_list_import_by_month")
public GlobalResponse idNoBlackListImportByMonth(String startTime, String endTime){
log.info("方法idNoBlackListImportByMonth入参, startTime: {} , endTime: {} ", startTime, endTime);
return iBlackListImportManagerService.blackListIdCardImport(startTime, endTime);
}
/**
* -----------------------------------------------------------------------------<br>
* 描 述: 三方数据源项目,命中外部黑名单,调该接口写入黑名单库 <br>
......
......@@ -10,11 +10,11 @@ import java.util.List;
* @Author fengjunkai
* @Date 2019-08-01 15:22
*/
@Repository
public interface BlackListQueryTidbMapper {
List<BlackListQueryTidbVo0> findBlackListPhoneByTime(BlackListQueryTidbParam0 blackListQueryTidbParam0);
List<BlackListQueryTidbVo0> findBlackListIdCardByTime(BlackListQueryTidbParam0 blackListQueryTidbParam0);
}
//@Repository
//public interface BlackListQueryTidbMapper {
//
// List<BlackListQueryTidbVo0> findBlackListPhoneByTime(BlackListQueryTidbParam0 blackListQueryTidbParam0);
//
// List<BlackListQueryTidbVo0> findBlackListIdCardByTime(BlackListQueryTidbParam0 blackListQueryTidbParam0);
//
//}
......@@ -9,7 +9,5 @@ import cn.quantgroup.qgblservice.response.GlobalResponse;
@Deprecated
public interface IBlackListImportService {
public GlobalResponse blackListPhoneImport(String startTime, String endTime);
public GlobalResponse blackListIdCardImport(String startTime, String endTime);
}
......@@ -17,14 +17,6 @@ public interface IBlackListManagerService {
public GlobalResponse manualImportBlackList(String sourcePath);
// public Map<String,Object> importBlacklistByExcel(MultipartFile file) throws IOException;
@Deprecated
public void blackListPhoneHistoryManagerByMonth(String startTime, String endTime);
@Deprecated
public void blackListIdCardHistoryManagerByMonth(String startTime, String endTime);
@Deprecated
public void blackListPhoneManagerByDay(String startTime, String endTime);
......
......@@ -25,79 +25,7 @@ public class BlackListImportServiceImpl implements IBlackListImportService {
@Autowired
private IBlackListManagerService iBlackListManagerService;
/**
* 手机关联三要素黑名单导入新表
*
* @param startTime
* @param endTime
* @return
*/
@Async
@Override
public GlobalResponse blackListPhoneImport(String startTime, String endTime) {
LocalDateTime erlyDate = LocalDateTime.parse(ERLY_DATE);
String phoneBreakDate = LocalDateTime.parse(PHONE_BREAK_DATE).format(DateTimeFormatter.ISO_DATE);
for (int i = 0; i < 100; i++) {
try {
endTime = erlyDate.plusMonths(i + 1).format(DateTimeFormatter.ISO_DATE);
startTime = erlyDate.plusMonths(i).format(DateTimeFormatter.ISO_DATE);
if (phoneBreakDate.equalsIgnoreCase(startTime)) {
break;
}
iBlackListManagerService.blackListPhoneHistoryManagerByMonth(startTime, endTime);
} catch (Exception e) {
log.error("手机号整合导入黑名单新表异常, startTime: {} , endTime: {} ", startTime, endTime, e);
}
}
log.info("手机号整合导入新表完毕");
return GlobalResponse.success("手机号关联三要素导入黑名单新表完毕");
}
/**
* 身份证关联三要素导入黑名单新表
*
* @param startTime
* @param endTime
* @return
*/
@Async
@Override
public GlobalResponse blackListIdCardImport(String startTime, String endTime) {
LocalDateTime erlyDate = LocalDateTime.parse(ERLY_DATE);
String phoneBreakDate = LocalDateTime.parse(PHONE_BREAK_DATE).format(DateTimeFormatter.ISO_DATE);
for (int i = 0; i < 100; i++) {
try {
startTime = erlyDate.plusMonths(i).format(DateTimeFormatter.ISO_DATE);
endTime = erlyDate.plusMonths(i + 1).format(DateTimeFormatter.ISO_DATE);
if (phoneBreakDate.equalsIgnoreCase(startTime)) {
break;
}
iBlackListManagerService.blackListIdCardHistoryManagerByMonth(startTime, endTime);
} catch (Exception e) {
log.error("身份证号整合导入黑名单新表异常, startTime: {} , endTime: {} ", startTime, endTime, e);
}
}
log.info("身份证号整合导入新表完毕");
return GlobalResponse.success("身份证号关联三要素导入黑名单新表完毕");
}
}
......@@ -4,7 +4,6 @@ import cn.quantgroup.qgblservice.constant.Constant;
import cn.quantgroup.qgblservice.repository.mybatis.entity.tidb.BlackListQueryTidbParam0;
import cn.quantgroup.qgblservice.repository.mybatis.entity.tidb.BlackListQueryTidbVo0;
import cn.quantgroup.qgblservice.repository.mybatis.entity.xyqbuser.XyqbUser;
import cn.quantgroup.qgblservice.repository.mybatis.mapper.tidb.BlackListQueryTidbMapper;
import cn.quantgroup.qgblservice.response.GlobalResponse;
import cn.quantgroup.qgblservice.service.IBlackListManagerService;
import cn.quantgroup.qgblservice.service.IBlackListUpdateThreeEleService;
......@@ -35,8 +34,6 @@ import java.util.concurrent.TimeUnit;
@Service
public class BlackListManagerServiceImpl implements IBlackListManagerService {
@Autowired
private BlackListQueryTidbMapper blackListQueryTidbMapper;
@Autowired
private JdbcTemplate blackListJdbcTemplate;
@Autowired
......@@ -45,9 +42,6 @@ public class BlackListManagerServiceImpl implements IBlackListManagerService {
private JdbcTemplate xyqbUserJdbcTemplate;
@Autowired
private IBlackListUpdateThreeEleService iBlackListUpdateThreeEleService;
@Autowired
private BlackListQueryTidbMapper blackListQueryMapper;
@Autowired
private ExcelUtil excelUtil;
@Async
......@@ -182,31 +176,8 @@ public class BlackListManagerServiceImpl implements IBlackListManagerService {
// return result;
// }
@Override
public void blackListPhoneHistoryManagerByMonth(String startTime, String endTime) {
List<BlackListQueryTidbVo0> blackListQueryTidbVo0s = blackListQueryTidbMapper.findBlackListPhoneByTime(BlackListQueryTidbParam0.builder().startTime(startTime).endTime(endTime).build());
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_MONTH);
log.info("{} - {} 手机号黑名单(month)关联三要素导入完成, 结果大小: {} , 入库大小: {} , 耗时: {} ", startTime, endTime, blackListQueryTidbVo0s.size(), batchExecuteResult, stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
}
}
@Override
public void blackListIdCardHistoryManagerByMonth(String startTime, String endTime) {
List<BlackListQueryTidbVo0> blackListQueryTidbVo0s = blackListQueryTidbMapper.findBlackListIdCardByTime(BlackListQueryTidbParam0.builder().startTime(startTime).endTime(endTime).build());
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_MONTH);
log.info("{} - {} 身份证号黑名单(month)关联三要素导入完成, 结果大小: {} , 入库大小: {} , 耗时: {} ", startTime, endTime, blackListQueryTidbVo0s.size(), batchExecuteResult, stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
}
}
@Override
public void blackListPhoneManagerByDay(String startTime, String endTime) {
......
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