Commit 4de7b501 authored by 郝彦辉's avatar 郝彦辉

提交2020.06.10

parent 6008d4f6
......@@ -281,6 +281,20 @@
<artifactId>spring-cloud-starter-eureka-server</artifactId>
</dependency>
<!-- quantgroup jar -->
<dependency>
<groupId>com.lkb.data</groupId>
<artifactId>lkb-data-service</artifactId>
<version>1.7.8.4-3c-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<dependencyManagement>
......
......@@ -6,11 +6,10 @@ package cn.quantgroup.report.config.aop;
import cn.quantgroup.report.cmpt.CommonAlarmCmpt;
import cn.quantgroup.report.cmpt.MonitorCmpt;
import cn.quantgroup.report.constant.TransactionCodeEnum;
import cn.quantgroup.report.response.TransactionResult;
import cn.quantgroup.report.service.thirdpartymonitor.ThirdpartyApiMonitorService;
import cn.quantgroup.report.utils.StringUtil;
import cn.quantgroup.report.enums.RequestUrlType;
import cn.quantgroup.report.response.GlobalResponse;
import cn.quantgroup.report.response.TransactionResult;
import cn.quantgroup.report.utils.StringUtil;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
......@@ -42,8 +41,8 @@ public class MonitorAspect {
protected static ExecutorService dbLogPool = new ThreadPoolExecutor(20,50,200, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
@Autowired
private ThirdpartyApiMonitorService thirdpartyApiMonitorService;
//@Autowired
//private ThirdpartyApiMonitorService thirdpartyApiMonitorService;
@Autowired
private CommonAlarmCmpt iMonitorAlarmService;
......@@ -137,13 +136,13 @@ public class MonitorAspect {
RequestUrlType urlType = transactionResult.getUrlType();
TransactionCodeEnum tansactionCode = transactionResult.getTansactionCode();
if(StringUtils.isNotBlank(response.getUuid())) {
thirdpartyApiMonitorService.saveTransactionLog(urlType, transactionId, response.getUuid(), tansactionCode);
//thirdpartyApiMonitorService.saveTransactionLog(urlType, transactionId, response.getUuid(), tansactionCode);
} else if(StringUtils.isNotBlank(response.getIdentity())) {
thirdpartyApiMonitorService.saveTransactionLogByIdentifyNumber(urlType, transactionId, response.getIdentity(), tansactionCode);
//thirdpartyApiMonitorService.saveTransactionLogByIdentifyNumber(urlType, transactionId, response.getIdentity(), tansactionCode);
}else if(StringUtils.isNotBlank(response.getPhone())) {
thirdpartyApiMonitorService.saveTransactionLogByPhone(urlType, transactionId, response.getPhone(), tansactionCode);
//thirdpartyApiMonitorService.saveTransactionLogByPhone(urlType, transactionId, response.getPhone(), tansactionCode);
} else {
thirdpartyApiMonitorService.saveTransactionLog(urlType, transactionId, null, tansactionCode);
//thirdpartyApiMonitorService.saveTransactionLog(urlType, transactionId, null, tansactionCode);
}
}
}
......
package cn.quantgroup.report.config.datasource.history;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Primary;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import javax.sql.DataSource;
@Import(XyqbHistoryDataSourcePreperties.class)
@Configuration
@Slf4j
@MapperScan(basePackages = XyqbHistoryDataSourceConfig.PACKAGE, sqlSessionFactoryRef = "xyqbHistorySqlSessionFactory")
public class XyqbHistoryDataSourceConfig {
static final String PACKAGE = "cn.quantgroup.report.mapper.history";
//@Value("${baihang.mapper-locations}")
private String mapperLocations = "classpath:cn/quantgroup/report/mapper/history/*.xml";
//@Value("${baihang.type-aliases-package}")
private String typeAliasesPackage = "cn.quantgroup.report.mapper.history";
@Value("${config-location}")
private String configLocation;
@Autowired
private XyqbHistoryDataSourcePreperties xyqbHistoryDataSourcePreperties;
@Bean(name = "xyqbHistoryDataSource")
public DataSource xyqbHistoryDataSource() {
HikariConfig config = new HikariConfig();
config.setJdbcUrl(xyqbHistoryDataSourcePreperties.getJdbcUrl());
log.info("xyqb历史数据库地址:{}", xyqbHistoryDataSourcePreperties.getJdbcUrl());
config.setPassword(xyqbHistoryDataSourcePreperties.getPassword());
config.setUsername(xyqbHistoryDataSourcePreperties.getUsername());
config.setMaximumPoolSize(xyqbHistoryDataSourcePreperties.getMaxPoolSize());
config.setMinimumIdle(xyqbHistoryDataSourcePreperties.getMinPoolSize());
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
return new HikariDataSource(config);
}
@Bean(name = "xyqbHistoryTransactionManager")
public DataSourceTransactionManager xyqbHistoryTransactionManager(@Qualifier("xyqbHistoryDataSource") DataSource xyqbHistoryDataSource) {
return new DataSourceTransactionManager(xyqbHistoryDataSource);
}
/* @Bean(name = "xyqbHistorySqlSessionFactory")
public SqlSessionFactory xyqbHistorySqlSessionFactory(@Qualifier("xyqbHistoryDataSource") DataSource xyqbHistoryDataSource) throws Exception {
final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(xyqbHistoryDataSource);
sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver()
.getResources(mapperLocations));
sessionFactory.setTypeAliasesPackage(typeAliasesPackage);
sessionFactory.setConfigLocation(new PathMatchingResourcePatternResolver()
.getResource(configLocation));
return sessionFactory.getObject();
}*/
/*
@Bean(name = "xyqbHistorySqlSessionTemplate")
public SqlSessionTemplate xyqbHistorySqlSessionTemplate(@Qualifier("xyqbHistorySqlSessionFactory") SqlSessionFactory xyqbHistorySqlSessionFactory) throws Exception {
return new SqlSessionTemplate(xyqbHistorySqlSessionFactory);
}*/
@Bean(name = "xyqbHistoryJdbcTemplate")
public JdbcTemplate primaryJdbcTemplate(@Qualifier("xyqbHistoryDataSource") DataSource dataSource) {
return new JdbcTemplate(dataSource);
}
}
package cn.quantgroup.report.config.datasource.history;
import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
@Setter
@Getter
@Configuration
public class XyqbHistoryDataSourcePreperties {
@Value("${db.driver}")
private String driverClass;
@Value("${baihang.db.minPoolSize}")
private int minPoolSize;
@Value("${baihang.db.maxPoolSize}")
private int maxPoolSize;
//@Value("${data.source.baihang.jdbcUrl}")
//private String jdbcUrl="jdbc:mysql://172.20.6.29:4010/rc_real_time_data_pool?useUnicode=true&characterEncoding=UTF8&useSSL=false";
private String jdbcUrl = "jdbc:mysql://172.20.6.21:4010/rc_real_time_data_pool?useUnicode=true&characterEncoding=UTF8&useSSL=false";
//@Value("${data.source.baihang.username}")
private String username="xyqb_history_w";
//@Value("${data.source.baihang.password}")
private String password="KDb18asPu6iEz5lg";
}
package cn.quantgroup.report.config.datasource.master;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Primary;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import javax.sql.DataSource;
/**
* Desc:
* User: HaiNan.Wang
* Date: 2017/5/2
*/
@Import(RiskDatasourceProperties.class)
@Configuration
@MapperScan(basePackages = RiskDataSourceConfig.PACKAGE, sqlSessionFactoryRef = "masterSqlSessionFactory")
public class RiskDataSourceConfig {
static final String PACKAGE = "cn.quantgroup.report.mapper.master";
@Value("${master.mapper-locations}")
private String mapperLocations;
@Value("${master.type-aliases-package}")
private String typeAliasesPackage;
@Value("${config-location}")
private String configLocation;
@Value("${db.driver:com.mysql.jdbc.Driver}")
private String driverClass;
@Autowired
private RiskDatasourceProperties repaymentPlanProperties;
@Bean(name = "masterDataSource")
public DataSource masterDataSource() {
HikariConfig config = new HikariConfig();
config.setJdbcUrl(repaymentPlanProperties.getRiskDatasourceJdbcUrl());
config.setPassword(repaymentPlanProperties.getRiskDatasourcePassword());
config.setUsername(repaymentPlanProperties.getRiskDatasourceUsername());
config.setMaximumPoolSize(repaymentPlanProperties.getMaxPoolSize());
config.setMinimumIdle(repaymentPlanProperties.getMinPoolSize());
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
return new HikariDataSource(config);
}
@Bean(name = "masterTransactionManager")
public DataSourceTransactionManager repaymentPlanDataSourceTransactionManager(@Qualifier("masterDataSource") DataSource dataSource) {
return new DataSourceTransactionManager(dataSource);
}
@Bean(name = "masterSqlSessionFactory")
public SqlSessionFactory masterSqlSessionFactory(@Qualifier("masterDataSource") DataSource masterDataSource) throws Exception {
final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(masterDataSource);
sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver()
.getResources(mapperLocations));
sessionFactory.setTypeAliasesPackage(typeAliasesPackage);
sessionFactory.setConfigLocation(new PathMatchingResourcePatternResolver()
.getResource(configLocation));
return sessionFactory.getObject();
}
@Bean(name = "masterSqlSessionTemplate")
public SqlSessionTemplate masterSqlSessionTemplate(@Qualifier("masterSqlSessionFactory") SqlSessionFactory sqlSessionFactory) throws Exception {
return new SqlSessionTemplate(sqlSessionFactory);
}
@Bean(name = "riskDatasourceJdbcTemplate")
public JdbcTemplate primaryJdbcTemplate(@Qualifier("masterDataSource") DataSource dataSource) {
return new JdbcTemplate(dataSource);
}
}
package cn.quantgroup.report.config.datasource.master;
import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
/**
* Desc:
* User: HaiNan.Wang
* Date: 2017/5/2
*/
@Getter
@Setter
@Configuration
public class RiskDatasourceProperties {
@Value("${db.driver}")
private String driverClass;
@Value("${db.minPoolSize}")
private int minPoolSize;
@Value("${db.maxPoolSize}")
private int maxPoolSize;
/**
* repaymentplan
*/
@Value("${db.risk_datasource.url}")
private String riskDatasourceJdbcUrl;
@Value("${db.risk_datasource.username}")
private String riskDatasourceUsername;
@Value("${db.risk_datasource.password}")
private String riskDatasourcePassword;
}
package cn.quantgroup.report.config.datasource.tidbrisk;
package cn.quantgroup.report.config.datasource.renhang;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
......@@ -28,51 +28,51 @@ import javax.sql.DataSource;
* 公司: 北京众信利民信息技术有限公司 <br>
* -----------------------------------------------------------------------------
*/
@Import(TidbRiskDatasourceProperties.class)
@Import(RenHangDatasourceProperties.class)
@Configuration
@Slf4j
@MapperScan(basePackages = TidbRiskDataSourceConfig.PACKAGE, sqlSessionFactoryRef = "tidbRiskSqlSessionFactory")
public class TidbRiskDataSourceConfig {
@MapperScan(basePackages = RenHangDataSourceConfig.PACKAGE, sqlSessionFactoryRef = "renhangSqlSessionFactory")
public class RenHangDataSourceConfig {
static final String PACKAGE = "cn.quantgroup.report.mapper.tidbrisk";
static final String PACKAGE = "cn.quantgroup.report.mapper.renhang";
//@Value("${tidb.risk_datasource.mapper-locations}")
private String mapperLocations="classpath:cn/quantgroup/report/mapper/tidbrisk/*.xml";//resources *.xml
@Value("${renhang.rc_sync_guangda.mapper-locations}")
private String mapperLocations; //="classpath:cn/quantgroup/report/mapper/tidbrisk/*.xml";//resources *.xml
//@Value("${tidb.risk_datasource.type-aliases-package}")
private String typeAliasesPackage="cn.quantgroup.report.domain.tidbrisk";//实体pojo
@Value("${renhang.rc_sync_guangda.type-aliases-package}")
private String typeAliasesPackage; //="cn.quantgroup.report.domain.tidbrisk";//实体pojo
@Value("${config-location}")
private String configLocation;
@Autowired
private TidbRiskDatasourceProperties tidbRiskDatasourceProperties;
private RenHangDatasourceProperties renhangDatasourceProperties;
@Bean(name = "tidbRiskDataSource")
public DataSource tidbRiskDataSource() {
@Bean(name = "renhangDataSource")
public DataSource renhangDataSource() {
HikariConfig config = new HikariConfig();
log.info("tidb.risk_datasource数据库地址:{}",tidbRiskDatasourceProperties.getTidbRiskDatasourceJdbcUrl());
config.setJdbcUrl(tidbRiskDatasourceProperties.getTidbRiskDatasourceJdbcUrl());
config.setPassword(tidbRiskDatasourceProperties.getTidbRiskDatasourcePassword());
config.setUsername(tidbRiskDatasourceProperties.getTidbRiskDatasourceUsername());
config.setMaximumPoolSize(tidbRiskDatasourceProperties.getMaxPoolSize());
config.setMinimumIdle(tidbRiskDatasourceProperties.getMinPoolSize());
log.info("rc_sync_guangda数据库地址:{}",renhangDatasourceProperties.getDatasourceJdbcUrl());
config.setJdbcUrl(renhangDatasourceProperties.getDatasourceJdbcUrl());
config.setPassword(renhangDatasourceProperties.getDatasourcePassword());
config.setUsername(renhangDatasourceProperties.getDatasourceUsername());
config.setMaximumPoolSize(renhangDatasourceProperties.getMaxPoolSize());
config.setMinimumIdle(renhangDatasourceProperties.getMinPoolSize());
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
return new HikariDataSource(config);
}
@Bean(name = "tidbRiskTransactionManager")
public DataSourceTransactionManager tidbRiskTransactionManager(@Qualifier("tidbRiskDataSource") DataSource dataSource) {
@Bean(name = "renhangTransactionManager")
public DataSourceTransactionManager renhangTransactionManager(@Qualifier("renhangDataSource") DataSource dataSource) {
return new DataSourceTransactionManager(dataSource);
}
@Bean(name = "tidbRiskSqlSessionFactory")
public SqlSessionFactory tidbRiskSqlSessionFactory(@Qualifier("tidbRiskDataSource") DataSource tidbRiskDataSource) throws Exception {
@Bean(name = "renhangSqlSessionFactory")
public SqlSessionFactory renhangSqlSessionFactory(@Qualifier("renhangDataSource") DataSource renhangDataSource) throws Exception {
final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(tidbRiskDataSource);
sessionFactory.setDataSource(renhangDataSource);
sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver()
.getResources(mapperLocations));
sessionFactory.setTypeAliasesPackage(typeAliasesPackage);
......@@ -81,13 +81,13 @@ public class TidbRiskDataSourceConfig {
return sessionFactory.getObject();
}
@Bean(name = "tidbRiskSqlSessionTemplate")
public SqlSessionTemplate tidbRiskSqlSessionTemplate(@Qualifier("tidbRiskSqlSessionFactory") SqlSessionFactory sqlSessionFactory) throws Exception {
@Bean(name = "renhangSqlSessionTemplate")
public SqlSessionTemplate renhangSqlSessionTemplate(@Qualifier("renhangSqlSessionFactory") SqlSessionFactory sqlSessionFactory) throws Exception {
return new SqlSessionTemplate(sqlSessionFactory);
}
@Bean(name = "tidbRiskJdbcTemplate")
public JdbcTemplate tidbRiskJdbcTemplate(@Qualifier("tidbRiskDataSource") DataSource dataSource) {
@Bean(name = "renhangJdbcTemplate")
public JdbcTemplate tidbRiskJdbcTemplate(@Qualifier("renhangDataSource") DataSource dataSource) {
return new JdbcTemplate(dataSource);
}
......
package cn.quantgroup.report.config.datasource.tidbrisk;
package cn.quantgroup.report.config.datasource.renhang;
import lombok.Getter;
import lombok.Setter;
......@@ -18,7 +18,8 @@ import org.springframework.context.annotation.Configuration;
@Getter
@Setter
@Configuration
public class TidbRiskDatasourceProperties {
public class RenHangDatasourceProperties {
@Value("${db.driver}")
private String driverClass;
......@@ -27,20 +28,17 @@ public class TidbRiskDatasourceProperties {
@Value("${db.maxPoolSize}")
private int maxPoolSize;
/**
* tidb.risk_datasource
*/
@Value("${db.tidb.risk_datasource.fullurl}")
private String tidbRiskDatasourceJdbcUrl;
//private String tidbRiskDatasourceJdbcUrl="jdbc:mysql://fengkong-tidb.quantgroups.com:4010/risk_datasource?useUnicode=true&characterEncoding=UTF8";
@Value("${db.tidb.risk_datasource.username}")
private String tidbRiskDatasourceUsername;
//private String tidbRiskDatasourceUsername="risk_datasource_w";
@Value("${db.tidb.risk_datasource.password}")
private String tidbRiskDatasourcePassword;
//private String tidbRiskDatasourcePassword="50GjQLd6hUOSeTMB";
@Value("${db.renhang.rc_sync_guangda.fullurl}")
private String datasourceJdbcUrl;
@Value("${db.renhang.rc_sync_guangda.username}")
private String datasourceUsername;
@Value("${db.renhang.rc_sync_guangda.password}")
private String datasourcePassword;
}
package cn.quantgroup.report.controller;
import cn.quantgroup.report.response.GlobalResponse;
import cn.quantgroup.report.service.cache.CacheService;
import cn.quantgroup.report.service.DataSourceCacheConfigService;
import cn.quantgroup.report.service.common.CommonQueryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@RequestMapping(value = "/cache")
public class CacheController {
@Autowired
private CacheService cacheService;
@Autowired
private DataSourceCacheConfigService cacheConfigService;
@Autowired
private CommonQueryService commonQueryService;
@Autowired
private RedisTemplate redisTemplate;
@RequestMapping("/clear_huadao_token")
public GlobalResponse clearHuadaoToken(){
try{
redisTemplate.delete("NEW_HUADAO_QUERY_TOKEN_KEY");
log.info("清除华道缓存token成功");
return GlobalResponse.generate("清除华道缓存token成功");
}catch(Exception e){
log.info("清除华道缓存token异常");
return GlobalResponse.generate("清除华道缓存token异常");
}
}
@RequestMapping("/get_huadao_token")
public GlobalResponse getHuadaoToken(){
try{
String token = String.valueOf(redisTemplate.opsForValue().get("NEW_HUADAO_QUERY_TOKEN_KEY"));
log.info("获取华道缓存token结果, token : {} ", token);
return GlobalResponse.generate(token);
}catch(Exception e){
log.info("获取华道缓存token异常");
return GlobalResponse.generate("获取华道缓存token异常");
}
}
@RequestMapping("/reload")
public GlobalResponse reload(){
try{
cacheConfigService.init();
log.info("刷新数据源缓存时间完成");
return GlobalResponse.generate("Ok");
}catch(Exception e){
log.info("刷新数据源缓存时间异常", e);
return GlobalResponse.generate(e.getMessage());
}
}
@RequestMapping("/config/clear")
public GlobalResponse clearConfigCache(String configName) {
try{
cacheService.clearCache(configName);
log.info("刷新缓存配置成功, configName: {} ", configName);
return GlobalResponse.generate("OK");
}catch (Exception e){
log.error("刷新缓存异常, {} , {} , {} ", configName, e.getMessage(), e);
return GlobalResponse.generate(e.getMessage());
}
}
@RequestMapping("/lock/clear")
public GlobalResponse clearLock(String lockName) {
try{
cacheService.clearLock(lockName);
return GlobalResponse.generate("OK");
}catch (Exception e){
log.error("{}", e.getMessage(), e);
return GlobalResponse.generate(e.getMessage());
}
}
}
package cn.quantgroup.report.controller;
import cn.quantgroup.report.response.GlobalResponse;
import cn.quantgroup.report.service.common.CommonQueryService;
import cn.quantgroup.report.service.manualTool.CleanningTransactionLogService;
import cn.quantgroup.report.service.manualTool.ManualToolService;
import com.alibaba.fastjson.JSON;
import com.google.common.collect.ImmutableMap;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -21,41 +18,7 @@ public class ManualToolController {
@Autowired
private ManualToolService manualToolService;
@Autowired
private CommonQueryService queryService;
@Autowired
private CleanningTransactionLogService cleanningTransactionLogService;
@RequestMapping("/send/baihang")
public String sendBaihang(String p1,String p2,String p3,String p4,String p5,String secretKey, String isSend,String errorCode, String isProduct, String sendIncludeType) {
try{
Map<String,String> resultMap = manualToolService.sendBaiHangData(p1,p2,p3,p4,p5,secretKey,isSend,errorCode, isProduct, sendIncludeType);
return JSON.toJSONString(resultMap);
}catch (Exception e){
log.error("众信利民助贷模式To百行征信手动报送异常, {} , {} ", e.getMessage(), e);
return "众信利民助贷模式To百行征信手动报送异常";
}
}
/**
* 描述: 放款信息 D2 <br/>
* 参数: [jsonFile] <br/>
* 返回值: GlobalResponse <br/>
* 创建人: yanhui.Hao <br/>
* 创建时间: 2019.09.27 <br/>
*/
@RequestMapping("/build/d2")
public GlobalResponse buildLoanInfoD2(String jsonFile) {
try{
return manualToolService.buildLoanInfoD2(jsonFile);
}catch (Exception e){
log.error("百行征信手动报送异常, {} , {} ", e.getMessage(), e);
return GlobalResponse.generate(e.getMessage());
}
}
@RequestMapping("/dealWithExcelData")
......@@ -83,53 +46,7 @@ public class ManualToolController {
return "调用结束";
}
@RequestMapping("/d2_saveLog")
public String d2_saveLog(String d2JsonFileName,String reqIdFileName,String no_reqId_start, String isHaveRecordId){
manualToolService.d2_saveLog(d2JsonFileName,reqIdFileName,no_reqId_start,isHaveRecordId);
return "d2_saveLog调用结束";
}
@RequestMapping("/d3_saveLog")
public String d3_saveLog(String d3FilePath, String d3JsonFileNames, String reqIdLogName, String no_reqId_start, String isHaveRecordId){
manualToolService.d3_saveLog(d3FilePath,d3JsonFileNames,reqIdLogName,no_reqId_start,isHaveRecordId);
return "d3_saveLog调用结束";
}
@RequestMapping("/synCallRecordNew")
public String synCallRecordNew(String newYnrTime,String isExecuteOnce){
cleanningTransactionLogService.synCallRecordNew(newYnrTime,isExecuteOnce);
return "synCallRecordNew调度完成";
}
@RequestMapping("/checkCallRecordCF")
public String checkCallRecordCF(String newYnrTime,String isExecuteOnce){
cleanningTransactionLogService.checkCallRecordCF(newYnrTime,isExecuteOnce);
return "checkCallRecordCF调度完成";
}
@RequestMapping("/checkTransactionLogCF")
public String checkTransactionLogCF(String newYnrTime,String isExecuteOnce){
cleanningTransactionLogService.checkTransactionLogCF(newYnrTime,isExecuteOnce);
return "checkTransactionLogCF调度完成";
}
@RequestMapping("/checkCallRecordCFByTransactionLog")
public String checkCallRecordCFByTransactionLog(String newYnrTime,String isExecuteOnce){
cleanningTransactionLogService.checkCallRecordCFByTransactionLog(newYnrTime,isExecuteOnce);
return "checkCallRecordCFByTransactionLog调度完成";
}
@RequestMapping("/checkCallRecordCFByTransactionLog2")
public String checkCallRecordCFByTransactionLog2(String newYnrTime,String isExecuteOnce){
cleanningTransactionLogService.checkCallRecordCFByTransactionLog2(newYnrTime,isExecuteOnce);
return "checkCallRecordCFByTransactionLog2调度完成";
}
@RequestMapping("/deleteTidbCallRecordCF")
public String deleteTidbCallRecordCF(String cfFileName, String bakFileName){
cleanningTransactionLogService.deleteTidbCallRecordCF(cfFileName,bakFileName);
return "deleteTidbCallRecordCF调度完成";
}
@RequestMapping("/deleteRedisKey")
public Map<String,Object> deleteRedisKey(String key1, String key2, String key3){
......
package cn.quantgroup.report.controller.external;
import cn.quantgroup.report.job.SynLoanInfoHistoryTask;
import cn.quantgroup.report.response.GlobalResponse;
import cn.quantgroup.report.service.baihang.BaiHangZhuDaiService;
import cn.quantgroup.report.service.manualTool.ManualToolService;
import cn.quantgroup.report.utils.ReadOrWriteTxt;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.File;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
/**
* -----------------------------------------------------------------------------<br>
* 描述: 北京众信利民信息技术有限公司 助贷模式To百行征信报送<br>
* 作者:yanhui.Hao <br>
* 时间:2019.11.20 <br>
* 授权: (C) Copyright (c) 2017 <br>
* 公司: 北京众信利民信息技术有限公司 <br>
* -----------------------------------------------------------------------------
*/
@RestController
@RequestMapping("/zhudai/re_send")
public class ExZhuDaiBaiHangReSendController {
private static final Logger log = LoggerFactory.getLogger(ExZhuDaiBaiHangReSendController.class);
@Autowired
BaiHangZhuDaiService baiHangZhuDaiService;
@Autowired
private SynLoanInfoHistoryTask synLoanInfoHistoryTask;
@Autowired
private ManualToolService manualToolService;
@RequestMapping("/manual/synTable/historyAndplan")
public String historyAndplan(String p3,String secretKey){
if(manualToolService.checkSecretKey(p3,secretKey)){
//增量同步history和plan表数据
synLoanInfoHistoryTask.syn_historyAndplan_by_id();
return "historyAndplan任务调度完成";
}else{
return "historyAndplan任务调度失败,参数错误";
}
}
//存量整理公共方法
@RequestMapping("/manual/build/zhuDaiStockSyn")
public String zhuDaiStockSyn(String type, String startDate, String noEndDate, String d3Type,String isNotHaveReqID) {
//d3Type=0 还款,type=1 逾期
if (StringUtils.isAnyBlank(type, startDate, noEndDate)) {
return "参数为空";
}
startDate=startDate+"T00:00:00";
noEndDate = noEndDate+"T00:00:00";
baiHangZhuDaiService.zhuDaiStockSyn(type, startDate, noEndDate, d3Type,isNotHaveReqID);
return "请求type=" + type + ",startDate=" + startDate + ",noEndDate=" + noEndDate + ",调度结束";
}
//存量异步整理停止方法
@RequestMapping("/manual/build/zhuDaiStockStop")
public String zhuDaiStockStop(String type,String value) {
if (StringUtils.isAnyBlank(type)) {
return "参数为空";
}
boolean val = false;
if(StringUtils.isNotBlank(value) && "true".equals(value)){
val = true;
}
return baiHangZhuDaiService.zhuDaiStockStop(type,val);
}
//文件报送压缩加密、解密
@RequestMapping("/manual/dealWithFileCry")
public String dealWithFileCry(String filePath, String type) {
try {
//"2019-05-07T00:00:00"
if (StringUtils.isAnyBlank(filePath,type)) {
return "参数为空";
}
if ("zip".equalsIgnoreCase(type)) {
return baiHangZhuDaiService.fileUploadClient(filePath);
} else if ("unzip".equalsIgnoreCase(type)) {
return baiHangZhuDaiService.fileUploadValidationClient(filePath);
} else {
return "其他未知类型type=" + type;
}
} catch (Exception e) {
log.error("dealWithFileCry异常, {} , {} ", e.getMessage(), e);
return e.getMessage();
}
}
//---------------------------------------------------------------------
/**
* 描述: 手动重新报送部分申请A1逻辑问题数据 <br/>
* 参数: [] <br/>
* 返回值: cn.quantgroup.report.response.GlobalResponse <br/>
* 创建人: yanhui.Hao <br/>
* 创建时间: 2019.10.29 <br/>
*/
@RequestMapping("/manual/buquan/mainApplySend")
public String mainApplySend(){
try{
return baiHangZhuDaiService.sendHandApplyToBaiHang(true,null);
//return GlobalResponse.generate("百行征信助贷模式手动报送D2数据成功");
}catch(Exception e){
log.error("众信利民助贷模式手动报送A1申请异常", e);
//return GlobalResponse.generate("百行征信助贷模式手动报送A1数据失败");
return "众信利民助贷模式手动报送A1数据失败";
}
}
/**
* 描述: 手动重新报送部分放款D2逻辑问题数据 <br/>
* 参数: [] <br/>
* 返回值: cn.quantgroup.report.response.GlobalResponse <br/>
* 创建人: yanhui.Hao <br/>
* 创建时间: 2019.10.29 <br/>
*/
@RequestMapping("/manual/buquan/mainLoanInfoSend")
public String mainLoanInfoSend(String isSaveLogBean){
try{
return baiHangZhuDaiService.sendHandLoaInfoReportToBaiHang2(true,null,isSaveLogBean);
//return GlobalResponse.generate("百行征信助贷模式手动报送D2数据成功");
}catch(Exception e){
log.error("众信利民助贷模式手动报送D2放款异常", e);
//return GlobalResponse.generate("百行征信助贷模式手动报送D2数据失败");
return "众信利民助贷模式手动报送D2数据失败";
}
}
/**
* 描述: 手动报送部分还款D3逻辑问题数据 <br/>
* 参数: [] <br/>
* 返回值: cn.quantgroup.report.response.GlobalResponse <br/>
* 创建人: yanhui.Hao <br/>
* 创建时间: 2019.10.29 <br/>
*/
@RequestMapping("/manual/buquan/mainRepaymentLoanInfo")
public String mainRepaymentLoanInfo(){
try{
return baiHangZhuDaiService.sendHandRepaymentReportToBaiHang1(true,null);
//return GlobalResponse.generate("百行征信助贷模式手动报送D3数据成功");
}catch(Exception e){
log.error("众信利民助贷模式手动报送D3还款异常", e);
//return GlobalResponse.generate("百行征信助贷模式手动报送D3数据失败");
return "众信利民助贷模式手动报送D3还款数据失败";
}
}
/**
* 描述: 因数据同步失败,根据报送时间天,手动调用,报送一整天所有数据 <br/>
* 参数: [] <br/>
* 返回值: cn.quantgroup.report.response.GlobalResponse <br/>
* 创建人: yanhui.Hao <br/>
* 创建时间: 2019.10.29 <br/>
*/
@RequestMapping("/manual/scheduledSend")
public String scheduledSend(String type, String startDate, String endDate) {
try {
//"2019-05-07T00:00:00"
if (StringUtils.isAnyBlank(type, startDate, endDate)) {
return "参数为空";
}
if (startDate.length() != 19 || endDate.length() != 19 || !startDate.contains("T") || !endDate.contains("T")) {
log.warn("日期格式有误, startDate : {} , endDate : {} ", startDate, endDate);
return "日期格式有误";
}
String startnyr = LocalDateTime.parse(startDate).format(DateTimeFormatter.ISO_DATE);
String endnyr = LocalDateTime.parse(endDate).format(DateTimeFormatter.ISO_DATE);
if ("A1".equalsIgnoreCase(type)) {
//贷款申请信息(A1)
baiHangZhuDaiService.sendZhuDaiApplyToBaiHang(startnyr, endnyr);
} else if ("D2".equalsIgnoreCase(type)) {
//非循环贷款账户数据信息(D2)
baiHangZhuDaiService.sendZhuDaiLoanToBaiHang(startnyr, endnyr);
} else if ("D3".equalsIgnoreCase(type)) {
//非循环贷款贷后数据信息(D3)
baiHangZhuDaiService.sendZhuDaiRepaymentToBaiHang(startnyr, endnyr);
} else {
return "其他未知类型type=" + type;
}
} catch (Exception e) {
log.error("dataTuoMin异常, {} , {} ", e.getMessage(), e);
return e.getMessage();
}
return type + "手动报送结束";
}
//---------------------------------------------------------------------------
//test1.场景测试 数据进行脱敏
/* @RequestMapping("/test/dataTuoMin")
public String dataTuoMin(String type,String jsonFilePath) {
try{
return baiHangZhuDaiService.dataTuoMin(type,jsonFilePath);
}catch (Exception e){
log.error("dataTuoMin异常, {} , {} ", e.getMessage(), e);
return e.getMessage();
}
}*/
//test2.接口测试 手动调用
@RequestMapping("/test/apiSend")
public String apiSend(String type,String startDate, String endDate) {
try{
return baiHangZhuDaiService.apiSend(type,startDate,endDate);
}catch (Exception e){
log.error("dataTuoMin异常, {} , {} ", e.getMessage(), e);
return e.getMessage();
}
}
//test
@RequestMapping("/test/bulidD3")
public String bulidD3(String type,String jsonFile) {
try{
return baiHangZhuDaiService.build_stockRepayMentInfoZhuDai(jsonFile);
}catch (Exception e){
log.error("bulidD3异常, {} , {} ", e.getMessage(), e);
return e.getMessage();
}
}
//test
@RequestMapping("/test/bulidD2")
public GlobalResponse bulidD2(String jsonFile){
try{
String sourceStr = FileUtils.readFileToString(new File(jsonFile), "utf-8");
JSONObject sourceJson = JSON.parseObject(sourceStr);
JSONArray recordsJsonArr = sourceJson.getJSONArray("RECORDS");
List<String> lineList = new ArrayList<>(recordsJsonArr.size());
for(int i=0; i<recordsJsonArr.size(); i++){
lineList.add(recordsJsonArr.get(i).toString());
}
baiHangZhuDaiService.sendHandLoaInfoReportToBaiHang(false,lineList);
return GlobalResponse.generate("百行征信助贷模式手动报送D2数据成功");
}catch(Exception e){
log.error("百行征信助贷模式报送放款异常", e);
return GlobalResponse.generate("百行征信助贷模式手动报送D2数据失败");
}
}
//test
@RequestMapping("/test/bulidA1")
public GlobalResponse bulidA1(String jsonFile){
try{
List<String> lineList = ReadOrWriteTxt.readTxtList("D:\\用户目录\\Downloads\\A1_M.txt");
System.out.println("lineList:"+lineList.size());
baiHangZhuDaiService.build_A1(lineList);
return GlobalResponse.generate("百行征信助贷模式手动报送D2数据成功");
}catch(Exception e){
log.error("百行征信助贷模式报送放款异常", e);
return GlobalResponse.generate("百行征信助贷模式手动报送D2数据失败");
}
}
}
package cn.quantgroup.report.domain.master;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.math.BigDecimal;
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AccountPO implements Serializable{
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column account.id
*
* @mbg.generated
*/
private Integer id;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column account.source_name
*
* @mbg.generated
*/
private String sourceName;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column account.blance
*
* @mbg.generated
*/
private BigDecimal blance;
private BigDecimal thershold;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column account.status
*
* @mbg.generated
*/
private String status;
}
\ No newline at end of file
package cn.quantgroup.report.domain.master;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ApiRequestLogPO implements Serializable{
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column api_request_log_201805.id
*
* @mbg.generated
*/
private Long id;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column api_request_log_201805.url_type
*
* @mbg.generated
*/
private String urlType;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column api_request_log_201805.res_code
*
* @mbg.generated
*/
private String resCode;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column api_request_log_201805.res_msg
*
* @mbg.generated
*/
private String resMsg;
private String hitFlag;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column api_request_log_201805.time_elapse
*
* @mbg.generated
*/
private Integer timeElapse;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column api_request_log_201805.create_time
*
* @mbg.generated
*/
private Date createTime;
/**
* yyyymm --- 201805
*/
private String suffix;
}
\ No newline at end of file
package cn.quantgroup.report.domain.master;
import lombok.Data;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @Author fengjunkai
*/
@Data
public class CallRecord1 implements Serializable {
private static final long serialVersionUID = 3380282142711506937L;
private String transactionId;
private String uuid;
private String urlType;
private String code;
private Timestamp created_at;
private Timestamp updated_at;
}
package cn.quantgroup.report.domain.master;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
* Created by suh on 2018/3/28.
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CommonWithBillingApiRequestEvent {
private String userId;
private Date timeCreated;
private String responseCode;
private String responseMessage;
private Integer mills;
private String requestUrlType;
private String isBilling;
}
package cn.quantgroup.report.domain.master;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CostRecordPO implements Serializable {
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column cost_record.id
*
* @mbg.generated
*/
private Integer id;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column cost_record.source_name
*
* @mbg.generated
*/
private String sourceName;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column cost_record.url_type
*
* @mbg.generated
*/
private String urlType;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column cost_record.invoke_times
*
* @mbg.generated
*/
private Integer invokeTimes;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column cost_record.cost
*
* @mbg.generated
*/
private BigDecimal cost;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column cost_record.balance
*
* @mbg.generated
*/
private BigDecimal balance;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column cost_record.create_time
*
* @mbg.generated
*/
private Date createTime;
/**
* yyyymm --- 201805
*/
private String suffix;
}
\ No newline at end of file
package cn.quantgroup.report.domain.master;
import lombok.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
@Builder
@Data
@Getter
@AllArgsConstructor
@NoArgsConstructor
public class DataPriceConfigPO implements Serializable {
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column data_price_config.id
*
* @mbg.generated
*/
private Integer id;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column data_price_config.source_name
*
* @mbg.generated
*/
private String sourceName;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column data_price_config.data_type
*
* @mbg.generated
*/
private String dataType;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column data_price_config.url_type
*
* @mbg.generated
*/
private String urlType;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column data_price_config.price
*
* @mbg.generated
*/
private BigDecimal price;
private Integer frequency;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column data_price_config.status
*
* @mbg.generated
*/
private String status;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column data_price_config.create_time
*
* @mbg.generated
*/
private Date createTime;
}
\ No newline at end of file
package cn.quantgroup.report.domain.master;
import lombok.Data;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @Author fengjunkai
* @Date 2019-06-19 14:07
*/
@Data
public class DataSourceCacheConfig implements Serializable {
private static final long serialVersionUID = -8145976034591357518L;
private String productType;
private String productName;
private Integer productCacheTime;
private Integer productTestCacheTime;
private String dataSourceName;
}
package cn.quantgroup.report.domain.master;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* -----------------------------------------------------------------------------<br>
* 描述: 三方数据源项目通过uuid白名单将返回500的转换成400配置表 <br>
* 作者:yanhui.Hao <br>
* 时间:2019.10.22 <br>
* 授权: (C) Copyright (c) 2017 <br>
* 公司: 北京众信利民信息技术有限公司 <br>
* -----------------------------------------------------------------------------
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class DsSpecialUserHandle {
private Long id;//主键id
private String methodName;//三方数据源实际方法名
private String serviceName;//三方数据源实际service名称
private String uuid;//用户的uuid
private Boolean enable; //数据是否可用, 默认1 true
}
package cn.quantgroup.report.domain.master;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
* Created by suh on 2018/3/28.
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ElevenBeiApiRequestEvent {
private String identity;
private Date timeCreated;
private String responseCode;
private String responseMessage;
private Integer mills;
private String requestUrlType;
private String isBilling;
}
package cn.quantgroup.report.domain.master;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.util.Date;
@Data
@NoArgsConstructor
public class IntelliCreditLoanIssue {
private Long id;
private String name;
private String pid;
private String mobile;
private String loanType;
private Long accountOpenDate;
private Long applyDate;
private Long issueDate;
private BigDecimal loanAmount;
private Long loanId;
private Integer totalTerm;
private Long firstRepaymentDate;
private Integer termPeriod;
private Integer planCount;
private Integer status;
private Date timeCreated;
private String device;
@Builder
public IntelliCreditLoanIssue(Long id, String name, String pid, String mobile, String loanType, Long accountOpenDate, Long applyDate, Long issueDate, BigDecimal loanAmount, Long loanId, Integer totalTerm, Long firstRepaymentDate, Integer termPeriod, Integer planCount, Integer status, String device) {
this.name = name;
this.pid = pid;
this.mobile = mobile;
this.loanType = loanType;
this.accountOpenDate = accountOpenDate;
this.applyDate = applyDate;
this.issueDate = issueDate == null ? 0l : issueDate;
this.loanAmount = loanAmount == null ? BigDecimal.ZERO : loanAmount;
this.loanId = loanId;
this.totalTerm = totalTerm == null ? 0 : totalTerm;
this.firstRepaymentDate = firstRepaymentDate == null ? 0 : firstRepaymentDate;
this.termPeriod = termPeriod == null ? 0 : termPeriod;
this.planCount = planCount == null ? 0 : planCount;
this.status = status;
this.timeCreated = new Date();
this.device = device;
}
}
\ No newline at end of file
package cn.quantgroup.report.domain.master;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class IntelliCreditLoanTrace {
private Long id;
private Long loanId;
private Long repaymentPlanId;
private Integer termNo;
private String termStatus;
private Long targetRepaymentDate;
private Long realRepaymentDate;
private BigDecimal targetRepayment;
private BigDecimal realRepayment;
private Long statusConfirmAt;
private String overdueStatus;
private Integer status;
}
\ No newline at end of file
package cn.quantgroup.report.domain.master;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
@Data
@NoArgsConstructor
public class IntelliCreditRequestEvent {
private Long id;
private String uuid;
private Date timeCreated;
private Integer httpCode;
private String responseMessage;
private Integer mills;
@Builder
public IntelliCreditRequestEvent(Long id, String uuid, Integer httpCode, String responseMessage, Integer mills) {
this.uuid = uuid;
this.id = id;
this.httpCode = httpCode;
this.responseMessage = responseMessage;
this.mills = mills;
this.timeCreated = new Date();
}
}
\ No newline at end of file
package cn.quantgroup.report.domain.master;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class JdApiRequestEvent {
private Long id;
private String uuid;
private Date timeCreated;
private String responseCode;
private String responseMessage;
private String businessCode;
private Integer mills;
private String requestUrlType;
}
\ No newline at end of file
package cn.quantgroup.report.domain.master;
import lombok.Data;
import java.io.Serializable;
/**
* -----------------------------------------------------------------------------<br>
* 描述: 百行报送逾期还款白名单表 <br>
* 作者:yanhui.Hao <br>
* 时间:2020.02.05 <br>
* 授权: (C) Copyright (c) 2017 <br>
* 公司: 北京众信利民信息技术有限公司 <br>
* -----------------------------------------------------------------------------
*/
@Data
//@Builder
public class RepaymentLoanWhiteList implements Serializable {
private static final long serialVersionUID = 8722959335665582382L;
private Long id;
private String pid;
private String mobile;
private String loanId; //贷款ID
private Integer type; //报送业务类型(1:广达小贷;2:众信利民助贷)
private Integer enable; //是否可用,0:不可用;1:可用
private String createdAt;
}
package cn.quantgroup.report.domain.master;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
* Created by suh on 2018/2/11.
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class UnionPayApiRequestEvent {
private String bankCardNo;
private Date timeCreated;
private Integer mills;
private String businessCode;
private String requestUrlType;
}
package cn.quantgroup.report.domain.renhang;
import java.io.Serializable;
import lombok.Builder;
import lombok.Data;
@Data
@Builder
public class IdCardA implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
private String name;
private String gender;//性别 男/女
private String nation;//民族
private String birthday;//出生日期 格式 :1990.02.14
private String citizen_id;//身份证号
private String address;
public IdCardA(String name, String gender, String nation, String birthday, String citizen_id, String address) {
super();
this.name = name;
this.gender = gender;
this.nation = nation;
this.birthday = birthday;
this.citizen_id = citizen_id;
this.address = address;
}
public IdCardA() {
}
}
package cn.quantgroup.report.domain.renhang;
import java.io.Serializable;
import lombok.Builder;
import lombok.Data;
@Data
@Builder
public class IdCardB implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
private String agency;//签发机关
private String valid_date_begin;//有效日期之起始日期 格式:20131022
private String valid_date_end;//有效日期之结束日期 格式:20231022
public IdCardB(String agency,String valid_date_begin,String valid_date_end) {
super();
this.agency = agency;
this.valid_date_begin = valid_date_begin;
this.valid_date_end = valid_date_end;
}
public IdCardB(){
}
}
package cn.quantgroup.report.domain.master;
package cn.quantgroup.report.domain.renhang;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.net.ntp.TimeStamp;
import java.io.Serializable;
import java.util.Date;
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TransactionLogPO implements Serializable {
public class User implements Serializable{
private static final long serialVersionUID = 1L;
private String transactionId;
private Long id;
private String phoneNo;
private String password;
private String registeredFrom; //channel.id
private String uuid;
private String urlType;
private Integer enable; //'是否可用'
private Integer code;
private TimeStamp createdAt;
private Date timeCreated;
private TimeStamp updatedAt;
}
package cn.quantgroup.report.domain.renhang;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.net.ntp.TimeStamp;
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class UserOcrVo implements Serializable{
private static final long serialVersionUID = 1L;
private Long id;
private String uuid;
private String name;
private String gender;//性别 男/女
private String nation;//民族
private String birthday;//出生日期 格式 :1990.02.14
private String citizenId;//身份证号
private String address;
private String agency;//签发机关
private String validDateBegin;//有效日期之起始日期 格式:20131022
private String validDateEnd;//有效日期之结束日期 格式:20231022
private TimeStamp createdAt;
private TimeStamp updatedAt;
}
package cn.quantgroup.report.domain.tidbrisk;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
/**
* -----------------------------------------------------------------------------<br>
* 描述: 调用日志实体bean <br>
* 作者:yanhui.Hao <br>
* 时间:2019.12.30 <br>
* 授权: (C) Copyright (c) 2017 <br>
* 公司: 北京众信利民信息技术有限公司 <br>
* -----------------------------------------------------------------------------
*/
@Setter
@Getter
@Builder
public class CallRecord2 {
private String channelType;//数据源调用批次号
private String requestUrl;//数据源调用批次号
private String channelId;//渠道号, 融360-333, 国美-159843
private String transactionId;//数据源调用批次号
private String uuid;//用户uuid
private String urlType;//数据源, QCloud43Md5AntiFraud-腾讯43版反欺诈模型分
private Integer code;//1001:请求成功且命中;1002:请求成功且未命中;1003:请求失败;1004:命中HBase;
//private String createdAt;//创建时间
}
package cn.quantgroup.report.domain.tidbrisk;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* -----------------------------------------------------------------------------<br>
* 描述: 调用日志实体bean <br>
* 作者:yanhui.Hao <br>
* 时间:2019.12.30 <br>
* 授权: (C) Copyright (c) 2017 <br>
* 公司: 北京众信利民信息技术有限公司 <br>
* -----------------------------------------------------------------------------
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CallRecord3 implements Serializable {
private String channelType;//数据源调用批次号
private String requestUrl;//数据源调用批次号
private String channelId;//渠道号, 融360-333, 国美-159843
private String transactionId;//数据源调用批次号
private String uuid;//用户uuid
private String urlType;//数据源, QCloud43Md5AntiFraud-腾讯43版反欺诈模型分
private Integer code;//1001:请求成功且命中;1002:请求成功且未命中;1003:请求失败;1004:命中HBase;
private Timestamp createdAt;
private Timestamp updatedAt;
private Long id;
}
package cn.quantgroup.report.job;
import cn.quantgroup.report.service.baihang.BaiHangZhuDaiService;
import cn.quantgroup.report.service.baihang.constant.Constant;
import cn.quantgroup.report.utils.dingtalk.DingTalk;
import com.google.common.base.Stopwatch;
......@@ -9,7 +8,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
......@@ -36,18 +34,17 @@ public class QuantGroupZhuDaiReportToBaiHang {
@Autowired
private RedisTemplate<String,String> redisTemplate;
@Autowired
/* @Autowired
private BaiHangZhuDaiService baiHangZhuDaiService;
*/
@Autowired
private SynLoanInfoHistoryTask synLoanInfoHistoryTask;
@Autowired
private DingTalk dingTalk;
@Async
//@Scheduled(cron = "0 0 05 * * ?")
public void startZhuDaiReport(){
/* public void startZhuDaiReport(){
if(increment()){
redisTemplate.expire(Constant.QG_ZHU_DAI_REPORT_LOCK_KEY, 10, TimeUnit.SECONDS);
......@@ -93,7 +90,7 @@ public class QuantGroupZhuDaiReportToBaiHang {
log.error("量化派-助贷模式报送贷款信息失败, 原因是同步历史表数据返回false, 请尽快人工处理, newTime: {} ", LocalDateTime.now());
}
}
}
}*/
public Boolean increment(){
......
package cn.quantgroup.report.job;
import cn.quantgroup.report.service.baihang.BaiHangZhuDaiService;
import cn.quantgroup.report.service.manualTool.ManualToolService;
import cn.quantgroup.report.utils.dingtalk.DingTalk;
import com.alibaba.fastjson.JSONObject;
import com.google.common.base.Stopwatch;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Enumeration;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
* -----------------------------------------------------------------------------<br>
* 描述: 一些繁琐的日正常工作task<br>
* 作者:yanhui.Hao <br>
* 时间:2020.03.11 <br>
* 授权: (C) Copyright (c) 2017 <br>
* 公司: 北京众信利民信息技术有限公司 <br>
* -----------------------------------------------------------------------------
*/
@Component
public class RoutineWorkTask {
private static final Logger log = LoggerFactory.getLogger(RoutineWorkTask.class);
@Autowired
private RedisTemplate<String, String> redisTemplate;
@Autowired
private DingTalk dingTalk;
@Autowired
private ManualToolService manualToolService;
@Autowired
BaiHangZhuDaiService baiHangZhuDaiService;
/**
* 百行报送工程RoutineWorkTask锁key
*/
public static final String ROUTINE_WORK_BH_LOCK_KEY_1 = "ROUTINE_WORK_BH_LOCK_KEY_1";
public static final String ROUTINE_WORK_BH_LOCK_KEY_2 = "ROUTINE_WORK_BH_LOCK_KEY_2";
public static final String ZXLM_A1_INTERFACE_SEND = "ZXLM_A1_INTERFACE_SEND";
public static final String ZXLM_D2_INTERFACE_SEND = "ZXLM_D2_INTERFACE_SEND";
public static final String ZXLM_D3_INTERFACE_SEND = "ZXLM_D3_INTERFACE_SEND";
//百行反馈日志(今天反馈日志是昨天05:00报送的),但最近百行反馈日志一直延迟,-1代表向前推一天,既昨天
@Value("${baihang.backLog.delay.day}")
public String BACKLOG_DELAY_DAY;
@Async
//@Scheduled(cron = "0 0 18 * * ?")
public void downloadLog() {
//if (increment(ROUTINE_WORK_BH_LOCK_KEY_1)) {
// redisTemplate.expire(ROUTINE_WORK_BH_LOCK_KEY_1, 10, TimeUnit.SECONDS);
String ip = getServerIp();
if (StringUtils.isNotEmpty(ip) && (StringUtils.equalsAnyIgnoreCase(ip, "172.21.10.8", "172.17.0.122"))) {
Stopwatch stopwatch = Stopwatch.createStarted();
//yyyyMMdd
//2020.03.19 本来今天查看今天的反馈日志(今天反馈日志是昨天05:00报送的),但最近百行反馈日志一直延迟1天
String newDatenyr = getNewDatenyr();
log.info("下载(众信利民助贷)百行反馈日志开始>>>>>>>>, newTime: {} , newDatenyr: {} ", LocalDateTime.now(), newDatenyr);
//指定只有172.21.10.8服务器
//String downloadUrl = "http://172.21.10.8:9021/manualtool/send/baihang?key=b5140fb2-2c85-4b5a-abcf-3e97528014db";
String p1 = "L0hNMklnTjNPenA1aDdqSHpreld1UT09";
String p2 = "UTg1UFN4SjN3TThuVXFIVEFUUFR0QT09";
String p3 = "Mm12NTBKU1JkVFE3MjlCK3RnZTNRdz09";
String p4 = "MmJJMzNUQVRMSXQ4V3VDbUswZGNlUT09";
String p5 = newDatenyr;
String secretKey = "UY1I5dHb3iq/DtEAm1f3yu7emYzlSvpFNPkxpOMSegqYJ08M2drTtNiqLyaxjbERWR0yS5CHPKpHwGjTXWHP3DEEDfXX4LhRtmiN1LIpZPdl87YWpDJ1qg07EN671JcY406oPbh7KsHFO0I0B32Hee1iZanKL4tzqmgF4dvsUNs=";
String isSend = "false";//不自动报送
String sendIncludeType = "D2,D3";//不不自动报送,该参数没有用
String isProduct = "true";
String errorCode = "D3_035,";//以后发现其他错误code,可以追加
try {
Stopwatch stopwatch1 = Stopwatch.createStarted();
Map<String, String> resultMap = manualToolService.sendBaiHangData(p1, p2, p3, p4, p5, secretKey, isSend, errorCode, isProduct, sendIncludeType);
log.info("下载&处理众信利民助贷反馈日志结束, result: {} , 耗时: {} ", JSONObject.toJSONString(resultMap), stopwatch1.stop().elapsed(TimeUnit.MILLISECONDS));
if (resultMap != null) {
String success = resultMap.get("success");
String alarm = resultMap.get("alarm");
String isEmpty = resultMap.get("isEmpty");
if (StringUtils.isNotEmpty(success)) {
if (StringUtils.isNotEmpty(isEmpty)) {
//dingTalk.talk("Info", "下载&处理" + newDatenyr + "(ZXLM助贷)百行反馈日志结束", success);
if(StringUtils.isNotEmpty(alarm)){
//Thread.sleep(500);
dingTalk.talk_ToUser("下载"+newDatenyr+"(ZXLM助贷)百行反馈主日志文件不存在", "下载反馈主日志文件不存在,请注意确认或和百行联系!");
}else{
dingTalk.talk("Info", "下载&处理" + newDatenyr + "(ZXLM助贷)百行反馈日志结束——[OK]", success);
}
log.info("下载(众信利民助贷)百行反馈日志结束<<<<<<<<, newDatenyr: {}, 耗时: {} ", newDatenyr, stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
return;
} else {
dingTalk.talk("Info", "下载&处理" + newDatenyr + "(ZXLM助贷)百行反馈日志结束", success + "——[10分钟后将会自动重新报送,若有问题请及时停止!]");
String json_sq_A1 = resultMap.get("json_sq_A1");
if (StringUtils.isNotEmpty(json_sq_A1) && "true".equals(json_sq_A1)) {
setRedisValStr(ZXLM_A1_INTERFACE_SEND);
}
String json_fk_D2 = resultMap.get("json_fk_D2");
if (StringUtils.isNotEmpty(json_fk_D2) && "true".equals(json_fk_D2)) {
setRedisValStr(ZXLM_D2_INTERFACE_SEND);
}
String json_hk_D3 = resultMap.get("json_hk_D3");
if (StringUtils.isNotEmpty(json_hk_D3) && "true".equals(json_hk_D3)) {
setRedisValStr(ZXLM_D3_INTERFACE_SEND);
}
log.info("下载(众信利民助贷)百行反馈日志结束<<<<<<<<, newDatenyr: {}, 耗时: {} ", newDatenyr, stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
return;
}
}
}
} catch (Exception e) {
log.error("下载(众信利民助贷)百行反馈日志异常<<<<<<<<, newDatenyr: {} ", newDatenyr, e);
//dingTalk.talk("Error", "下载&处理(ZXLM助贷)百行反馈日志系统异常", "(" + newDatenyr + ") 异常信息:" + e.toString());
dingTalk.talk_ToUser("下载&处理(ZXLM助贷)百行反馈日志系统异常", "(" + newDatenyr + ") 日常处理ZXLM助贷反馈日志系统异常,请尽快手动处理!!!");
return;
}
dingTalk.talk_ToUser("下载(众信利民助贷)百行反馈日志未知异常", "下载 (" + newDatenyr + ") 反馈日志失败,请尽快手动处理!");
log.info("下载(众信利民助贷)百行反馈日志结束<<<<<<<<, newDatenyr: {}, 耗时: {} ", newDatenyr, stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
}
}
@Async
//@Scheduled(cron = "0 10 18 * * ?")
public void sendBaoSong() {
//if (increment(ROUTINE_WORK_BH_LOCK_KEY_2)) {
// redisTemplate.expire(ROUTINE_WORK_BH_LOCK_KEY_2, 10, TimeUnit.SECONDS);
String ip = getServerIp();
if (StringUtils.isNotEmpty(ip) && (StringUtils.equalsAnyIgnoreCase(ip, "172.21.10.8", "172.17.0.122"))) {
Stopwatch stopwatch = Stopwatch.createStarted();
//yyyyMMdd
String newDatenyr = getNewDatenyr();
//指定只有172.21.10.8服务器 172.21.10.8:9021
//String send_A1_url = "http://172.21.10.8:9021/zhudai/re_send/manual/buquan/mainApplySend?key=b5140fb2-2c85-4b5a-abcf-3e97528014db";
//String send_D2_url = "http://172.21.10.8:9021/zhudai/re_send/manual/buquan/mainLoanInfoSend?key=b5140fb2-2c85-4b5a-abcf-3e97528014db";
//String send_D3_url = "http://172.21.10.8:9021/zhudai/re_send/manual/buquan/mainRepaymentLoanInfo?key=b5140fb2-2c85-4b5a-abcf-3e97528014db";
log.info("众信利民助贷-百行重新报送开始>>>>>>>>, newTime: {} , newDatenyr: {} ", LocalDateTime.now(), newDatenyr);
if (getRedisValStr(ZXLM_A1_INTERFACE_SEND)) {
try {
redisTemplate.delete(ZXLM_A1_INTERFACE_SEND);
String result = baiHangZhuDaiService.sendHandApplyToBaiHang(true, null);
log.info("众信利民助贷-百行重新报送A1结束, newTime: {} , newDatenyr: {} , result: {} ", LocalDateTime.now(), newDatenyr, result);
dingTalk.talk("Info", "ZXLM助贷-重新报送 A1 结束", "(" + newDatenyr + ")" + result);
Thread.sleep(3 * 1000);//3秒
} catch (Exception e) {
log.error("(众信利民助贷)重新报送A1异常, newTime: {} , newDatenyr: {} ", LocalDateTime.now(), newDatenyr, e);
dingTalk.talk_ToUser("ZXLM助贷-重新报送 A1 异常", "(" + newDatenyr + ") A1报送异常,请尽快查看处理!");
}
}
if (getRedisValStr(ZXLM_D2_INTERFACE_SEND)) {
try {
redisTemplate.delete(ZXLM_D2_INTERFACE_SEND);
String result = baiHangZhuDaiService.sendHandLoaInfoReportToBaiHang2(true, null, "true");
log.info("众信利民助贷-百行重新报送D2结束, newTime: {} , newDatenyr: {} , result: {} ", LocalDateTime.now(), newDatenyr, result);
dingTalk.talk("Info", "ZXLM助贷-重新报送 D2 结束", "(" + newDatenyr + ")" + result);
Thread.sleep(10 * 1000);//10秒
} catch (Exception e) {
log.error("(众信利民助贷)重新报送D2异常, newTime: {} , newDatenyr: {} ", LocalDateTime.now(), newDatenyr, e);
dingTalk.talk_ToUser("ZXLM助贷-重新报送 D2 异常", "(" + newDatenyr + ") D2报送异常,请尽快查看处理!");
}
}
if (getRedisValStr(ZXLM_D3_INTERFACE_SEND)) {
try {
redisTemplate.delete(ZXLM_D3_INTERFACE_SEND);
String result = baiHangZhuDaiService.sendHandRepaymentReportToBaiHang1(true, null);
log.info("众信利民助贷-百行重新报送D3结束, newTime: {} , newDatenyr: {} , result: {} ", LocalDateTime.now(), newDatenyr, result);
dingTalk.talk("Info", "ZXLM助贷-重新报送 D3 结束", "(" + newDatenyr + ")" + result);
} catch (Exception e) {
log.error("(众信利民助贷)重新报送D3异常, newTime: {} , newDatenyr: {} ", LocalDateTime.now(), newDatenyr, e);
dingTalk.talk_ToUser("ZXLM助贷-重新报送 D3 异常", "(" + newDatenyr + ") D3报送异常,请尽快查看处理!");
}
}
log.info("众信利民助贷-百行重新报送结束<<<<<<<<, newDatenyr: {}, 耗时: {} ", newDatenyr, stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
}
}
private Boolean increment(String key) {
Long increment = redisTemplate.opsForValue().increment(key, 1);
return increment <= 1;
}
private void setRedisValStr(String key) {
try {
redisTemplate.opsForValue().set(key, "true", 15, TimeUnit.MINUTES);
} catch (Exception e) {
log.error("Redis中set值异常, key: {} ", key, e);
}
}
private boolean getRedisValStr(String key) {
String value = null;
try {
value = redisTemplate.opsForValue().get(key);
} catch (Exception e) {
log.error("Redis中get值异常, key: {} ", key, e);
}
if (StringUtils.isNotEmpty(value) && "true".equals(value)) {
return true;
} else {
return false;
}
}
private static String getServerIp() {
try {
Enumeration<NetworkInterface> allNetInterfaces = NetworkInterface.getNetworkInterfaces();
while (allNetInterfaces.hasMoreElements()) {
NetworkInterface netInterface = (NetworkInterface) allNetInterfaces.nextElement();
Enumeration<InetAddress> addresses = netInterface.getInetAddresses();
while (addresses.hasMoreElements()) {
InetAddress ip = (InetAddress) addresses.nextElement();
if (ip != null
&& ip instanceof Inet4Address
&& !ip.isLoopbackAddress() // loopback地址即本机地址,IPv4的loopback范围是127.0.0.0 ~ 127.255.255.255
&& ip.getHostAddress().indexOf(":") == -1) {
log.info("本机的IP = " + ip.getHostAddress());
return ip.getHostAddress();
}
}
}
} catch (Exception e) {
log.error("获取本地ip异常", e);
}
return null;
}
private String getNewDatenyr() {
int bakDay = 0;
if (StringUtils.isNotBlank(BACKLOG_DELAY_DAY)) {
try {
bakDay = Integer.parseInt(BACKLOG_DELAY_DAY);
} catch (Exception e) {
log.error("数字转换异常, BACKLOG_DELAY_DAY: {} ", BACKLOG_DELAY_DAY, e);
}
}
//yyyy-MM-dd
String newDatenyr = null;
if (bakDay != 0) {
newDatenyr = LocalDateTime.now().plusDays(bakDay).format(DateTimeFormatter.ISO_DATE);
} else {
newDatenyr = LocalDateTime.now().format(DateTimeFormatter.ISO_DATE);
}
newDatenyr = newDatenyr.replace("-", "");
return newDatenyr;
}
}
package cn.quantgroup.report.job;
import cn.quantgroup.report.constant.BaiHangHistoryConstant;
import cn.quantgroup.report.service.baihang.constant.Constant;
import cn.quantgroup.report.utils.dingtalk.DingTalk;
import com.google.common.base.Stopwatch;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* -----------------------------------------------------------------------------<br>
* 描述: 量化派助贷模式(非循环贷) -
* (贷款申请/放款/还款(逾期)三类实时批量数据)-To百行报送<br>
* 每日凌晨5点报送 <br>
* 作者:yanhui.Hao <br>
* 时间:2019.10.25 <br>
* 授权: (C) Copyright (c) 2017 <br>
* 公司: 北京众信利民信息技术有限公司 <br>
* -----------------------------------------------------------------------------
*/
@Component
public class SynLoanInfoHistoryTask {
private static final Logger log = LoggerFactory.getLogger(SynLoanInfoHistoryTask.class);
@Autowired
private RedisTemplate<String,String> redisTemplate;
@Autowired
private JdbcTemplate xyqbHistoryJdbcTemplate;
@Autowired
private DingTalk dingTalk;
private static AtomicBoolean SYN_Stop = new AtomicBoolean(false);
@Async
/*@Scheduled(cron = "0 0 05 * * ?")*/ //2019.11.15 15:25
public void startHistoryDateCopy(){
if(increment()){
redisTemplate.expire(Constant.XYQB_HISTORY_DAI_REPORT_LOCK_KEY, 10, TimeUnit.SECONDS);
Stopwatch stopwatch = Stopwatch.createStarted();
//yyyy-MM-dd
//String startnyr = LocalDateTime.now().plusDays(-1).format(DateTimeFormatter.ISO_DATE);
//String endnyr = LocalDateTime.now().format(DateTimeFormatter.ISO_DATE);
log.info("量化派-同步表xyqb_i_loan_application_manifest_history数据开始, newTime: {} ", LocalDateTime.now());
//将xyqb_i_loan_application_manifest_history表的数据,同步到xyqb_i_repayment_plan_bak
//syn_history_by_CreatedAt();
//将xyqb_i_repayment_plan表的数据,同步到xyqb_i_loan_a_m_history_bak
//syn_plan_by_CreatedAt();
syn_historyAndplan_by_id();
////syn_history_p2p_bak();
////syn_plan_p2p_bak();
log.info("量化派-同步表xyqb_i_loan_application_manifest_history数据结束, endTime: {}, 耗时: {} ", LocalDateTime.now(), stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
}
}
private Boolean increment(){
Long increment = redisTemplate.opsForValue().increment(Constant.XYQB_HISTORY_DAI_REPORT_LOCK_KEY, 1);
return increment <= 1;
}
@Deprecated
private void syn_history_by_CreatedAt(){
LocalDateTime erlyDate = LocalDateTime.parse("2016-08-23T00:00:00");//2016-08-23T16:29:10
LocalDateTime endDate = LocalDateTime.parse("2019-11-01T00:00:00");//2019-11-11 12:32:08
int counter = 0;
while (true) {
Stopwatch startwatch = Stopwatch.createStarted();
if (SYN_Stop.get()) {
log.error("同步xyqb_i_loan_application_manifest_history数据查询STOP, D3_Stop: {} , endTime: {} ", SYN_Stop.get(), erlyDate.plusDays(counter).format(DateTimeFormatter.ISO_DATE));
break;
}
counter++;
if (erlyDate.plusDays(counter).compareTo(endDate) > 0) {
break;
}
String starTime = erlyDate.plusDays(counter - 1).format(DateTimeFormatter.ISO_DATE);
String endTime = erlyDate.plusDays(counter).format(DateTimeFormatter.ISO_DATE);
try {
String tmp_sql = BaiHangHistoryConstant.SQL_COMMONE_TEMPLATE_HISTORY;
tmp_sql = tmp_sql.replace("##STARTTIME##",starTime);
tmp_sql = tmp_sql.replace("##ENDTIME##",endTime);
int upCount = xyqbHistoryJdbcTemplate.update(tmp_sql);
log.info("同步xyqb_i_loan_application_manifest_history数据结束,startTime: {} , 耗时:{} , updateCount: {} ", starTime, startwatch.stop().elapsed(TimeUnit.MILLISECONDS)+".ms", upCount);
}catch (Exception e){
log.error("同步xyqb_i_loan_application_manifest_history数据异常, startTime: {} , endTime: {} , counter: {} ", starTime, endTime,counter, e);
}
}
}
@Deprecated
private void syn_plan_by_CreatedAt(){
LocalDateTime erlyDate = LocalDateTime.parse("2016-08-23T00:00:00");//2016-08-23T16:29:10
LocalDateTime endDate = LocalDateTime.parse("2019-11-01T00:00:00");//2019-11-11 12:32:08
int counter = 0;
while (true) {
Stopwatch startwatch = Stopwatch.createStarted();
if (SYN_Stop.get()) {
log.error("同步xyqb_i_repayment_plan数据查询STOP, D3_Stop: {} , endTime: {} ", SYN_Stop.get(), erlyDate.plusDays(counter).format(DateTimeFormatter.ISO_DATE));
break;
}
counter++;
if (erlyDate.plusDays(counter).compareTo(endDate) > 0) {
break;
}
String starTime = erlyDate.plusDays(counter - 1).format(DateTimeFormatter.ISO_DATE);
String endTime = erlyDate.plusDays(counter).format(DateTimeFormatter.ISO_DATE);
try {
String tmp_sql = BaiHangHistoryConstant.SQL_COMMONE_TEMPLATE_PLAN;
tmp_sql = tmp_sql.replace("##STARTTIME##",starTime);
tmp_sql = tmp_sql.replace("##ENDTIME##",endTime);
int upCount = xyqbHistoryJdbcTemplate.update(tmp_sql);
log.info("同步xyqb_i_repayment_plan数据结束,startTime: {} , 耗时:{} , updateCount: {} ", starTime, startwatch.stop().elapsed(TimeUnit.MILLISECONDS)+".ms", upCount);
}catch (Exception e){
log.error("同步xyqb_i_repayment_plan数据异常, startTime: {} , endTime: {} , counter: {} ", starTime, endTime,counter, e);
}
}
}
private boolean syn_history_by_id(long bakMaxId,long newMaxId){
String count_sql = BaiHangHistoryConstant.SQL_COMMONE_TEMPLATE_HISTORY_SYN_COUNT;
count_sql = count_sql.replace("##BAKMAXID##",""+bakMaxId);
count_sql = count_sql.replace("##NEWMAXID##",""+newMaxId);//防止查询的过程中再增长
Integer count = xyqbHistoryJdbcTemplate.queryForObject(count_sql,Integer.class);
if(count==null){
log.error("表xyqb_i_loan_application_manifest_history查询增量count为Null.");
dingTalk.talk("Warn","同步[借款清单]数据失败","查询增量count为Null,请尽快处理!"+" bakMaxId: "+bakMaxId+", newMaxId: "+newMaxId);
dingTalk.talk_ToUser("借款清单同步失败", "同步[借款清单]表查询增量count为Null,停止T+1报送!发现问题,请及时处理!");
return false;
}
//小于2万条,可以commit
if(count.intValue() <= BaiHangHistoryConstant.MAX_COMMIT_COUT){
Stopwatch startwatch = Stopwatch.createStarted();
String inset_sql = BaiHangHistoryConstant.SQL_COMMONE_TEMPLATE_HISTORY_SYN_DATA;
inset_sql = inset_sql.replace("##STARTID##",""+bakMaxId);
int update = xyqbHistoryJdbcTemplate.update(inset_sql);
log.info("增量同步xyqb_i_loan_application_manifest_history表结束, bakMaxId: {} , count: {} , 插入条数: {} , 耗时: {} ", bakMaxId, count, update, startwatch.stop().elapsed(TimeUnit.MILLISECONDS)+".ms");
dingTalk.talk("Info","同步[借款清单]数据成功","实际条数: "+update +", bakMaxId: "+bakMaxId+", newMaxId: "+newMaxId);
return true;
}else{
//大于2万条会报事务太长,需要分页插入
int id_limit_count = (int) (newMaxId - bakMaxId);
int page = id_limit_count / BaiHangHistoryConstant.MAX_COMMIT_COUT;
int mode = id_limit_count % BaiHangHistoryConstant.MAX_COMMIT_COUT;
if(mode!=0){
page = page+1;
}
int totalUpdate = 0;
for (int p=0 ; p < page; p++){
Stopwatch startwatch = Stopwatch.createStarted();
long startId = bakMaxId + p * BaiHangHistoryConstant.MAX_COMMIT_COUT;
long endId = bakMaxId + (p+1) * BaiHangHistoryConstant.MAX_COMMIT_COUT;
if( endId > newMaxId){
endId = newMaxId;
}
String tmpInsertSql = BaiHangHistoryConstant.SQL_COMMONE_TEMPLATE_HISTORY_SYN_DATA;
tmpInsertSql = tmpInsertSql.replace("##STARTID##",""+startId);
tmpInsertSql = tmpInsertSql + (" AND b.id <="+endId+" ;");
int update = xyqbHistoryJdbcTemplate.update(tmpInsertSql);
totalUpdate+=update;
log.info("增量同步xyqb_i_loan_application_manifest_history表页数page["+p+"], startId: {} , endId: {} , 插入条数: {} , 耗时: {} ", startId, endId, update, startwatch.stop().elapsed(TimeUnit.MILLISECONDS)+".ms");
}
log.info("增量同步xyqb_i_loan_application_manifest_history表结束, bakMaxId: {} , newMaxId: {} , ID差: {} , count: {} , totalUpdate: {} , page: {} , mode: {} ", bakMaxId, newMaxId, (newMaxId-bakMaxId), count, totalUpdate, page, mode);
if(totalUpdate==count){
dingTalk.talk("Info","同步[借款清单]数据成功","实际条数(分页): "+totalUpdate+", bakMaxId: "+bakMaxId+", newMaxId: "+newMaxId);
return true;
}else{
dingTalk.talk("Warn","同步[借款清单]数据失败","查询条数: "+count+",实际条数="+totalUpdate+", bakMaxId: "+bakMaxId+", newMaxId: "+newMaxId);
dingTalk.talk_ToUser("借款清单同步异常", "同步[借款清单]数据失败,停止T+1报送!发现问题,请及时处理!");
return false;
}
}
}
private boolean syn_plan_by_id(long bakMaxId,long newMaxId){
String count_sql = BaiHangHistoryConstant.SQL_COMMONE_TEMPLATE_PLAN_SYN_COUNT;
count_sql = count_sql.replace("##BAKMAXID##",""+bakMaxId);
count_sql = count_sql.replace("##NEWMAXID##",""+newMaxId);//防止查询的过程中再增长
Integer count = xyqbHistoryJdbcTemplate.queryForObject(count_sql,Integer.class);
if(count==null){
log.error("表xyqb_i_repayment_plan查询增量count为Null.");
dingTalk.talk("Warn","同步[还款计划]数据失败","查询增量count为Null,请尽快处理!" + ", bakMaxId: "+bakMaxId+", newMaxId: "+newMaxId);
dingTalk.talk_ToUser("还款计划同步失败", "同步[还款计划]表查询增量count为Null,停止T+1报送!发现问题,请及时处理!");
return false;
}
//小于2万条,可以commit
if(count.intValue() <= BaiHangHistoryConstant.MAX_COMMIT_COUT){
Stopwatch startwatch = Stopwatch.createStarted();
String inset_sql = BaiHangHistoryConstant.SQL_COMMONE_TEMPLATE_PLAN_SYN_DATA;
inset_sql = inset_sql.replace("##STARTID##",""+bakMaxId);
int update = xyqbHistoryJdbcTemplate.update(inset_sql);
log.info("增量同步xyqb_i_repayment_plan表结束, bakMaxId: {} , count: {} , 插入条数: {} , 耗时: {} ", bakMaxId, count, update, startwatch.stop().elapsed(TimeUnit.MILLISECONDS)+".ms");
dingTalk.talk("Info","同步[还款计划]数据成功","实际条数: "+update +", bakMaxId: "+bakMaxId+", newMaxId: "+newMaxId);
return true;
}else{
//大于2万条会报事务太长,需要分页插入
//xyqb_i_repayment_plan表目前发现有24期的,也就是说xyqb_i_loan_a_m_history_bak关联最大会出现24条
int PLAN_MAX_COMMIT_COUT = BaiHangHistoryConstant.MAX_COMMIT_COUT / 24;
int id_limit_count = (int) (newMaxId - bakMaxId);
int page = id_limit_count / PLAN_MAX_COMMIT_COUT;
int mode = id_limit_count % PLAN_MAX_COMMIT_COUT;
if(mode!=0){
page = page+1;
}
int totalUpdate = 0;
for (int p=0 ; p < page; p++){
Stopwatch startwatch = Stopwatch.createStarted();
long startId = bakMaxId + p * PLAN_MAX_COMMIT_COUT;
long endId = bakMaxId + (p+1) * PLAN_MAX_COMMIT_COUT;
if( endId > newMaxId){
endId = newMaxId;
}
String tmpInsertSql = BaiHangHistoryConstant.SQL_COMMONE_TEMPLATE_PLAN_SYN_DATA;
tmpInsertSql = tmpInsertSql.replace("##STARTID##",""+startId);
tmpInsertSql = tmpInsertSql + (" AND b.id <="+endId+" ;");
int update = xyqbHistoryJdbcTemplate.update(tmpInsertSql);
totalUpdate+=update;
log.info("增量同步xyqb_i_repayment_plan表页数page["+p+"], startId: {} , endId: {} , 插入条数: {} , 耗时: {} ", startId, endId, update, startwatch.stop().elapsed(TimeUnit.MILLISECONDS)+".ms");
}
log.info("增量同步xyqb_i_repayment_plan表结束, bakMaxId: {} , newMaxId: {} , ID差: {} , count: {} , totalUpdate: {} , page: {} , mode: {} ", bakMaxId, newMaxId, (newMaxId-bakMaxId), count, totalUpdate, page, mode);
if(totalUpdate==count){
dingTalk.talk("Info","同步[还款计划]数据成功","实际条数(分页): "+totalUpdate + ", bakMaxId: "+bakMaxId+", newMaxId: "+newMaxId);
return true;
}else{
dingTalk.talk("Warn","同步[还款计划]数据失败","查询条数: "+count+",实际条数="+totalUpdate + ", bakMaxId: "+bakMaxId+", newMaxId: "+newMaxId);
dingTalk.talk_ToUser("还款计划同步异常", "同步[还款计划]数据失败,停止T+1报送!发现问题,请及时处理!");
return false;
}
}
}
public boolean syn_historyAndplan_by_id(){
Stopwatch startwatch = Stopwatch.createStarted();
try {
String tmp_sql1 = BaiHangHistoryConstant.SQL_COMMONE_TEMPLATE_HISTORY_BAK_MAX_ID;
Long bakMaxId = xyqbHistoryJdbcTemplate.queryForObject(tmp_sql1,Long.class);
String tmp_sql2 = BaiHangHistoryConstant.SQL_COMMONE_TEMPLATE_HISTORY_MAX_ID;
Long newMaxId = xyqbHistoryJdbcTemplate.queryForObject(tmp_sql2,Long.class);
//2019.11.15 13:37 bakMaxId: 1857710 , newMaxId: 13732716 , count: 1062175 , 差:11875006 , 总插入条数: 1062174 , page: 594
//bakMaxId = 1857710L;
//newMaxId = 13732716L;
if(bakMaxId!=null && bakMaxId.longValue() >= 0L && newMaxId!=null && newMaxId.longValue() >= 0L){
//同步到xyqb_i_loan_a_m_history_bak表-------------------------------
boolean table_history = syn_history_by_id(bakMaxId.longValue(), newMaxId.longValue());
if(table_history){
//同步到xyqb_i_repayment_plan_bak表
boolean table_plan = syn_plan_by_id(bakMaxId.longValue(), newMaxId.longValue());
if(table_plan){
log.info("ALL增量同步history&plan表数据结束, nowTime: {} ", LocalDateTime.now(), startwatch.stop().elapsed(TimeUnit.MILLISECONDS)+".ms");
return true;
}else{
log.error("All增量同步[xyqb_i_repayment_plan_bak]表数据失败,请尽快处理! nowTime: {} , bakMaxId: {} , newMaxId: {} ",LocalDateTime.now(), bakMaxId, newMaxId);
////dingTalk.talk("Warn","同步[还款计划]数据失败","同步xyqb_i_repayment_plan_bak表数据失败,请尽快处理! newMaxId:"+newMaxId+",newMaxId="+newMaxId);
}
}else{
log.error("增量同步[xyqb_i_loan_a_m_history_bak]表数据失败,请尽快处理! nowTime: {} , bakMaxId: {} , newMaxId: {} ",LocalDateTime.now(), bakMaxId, newMaxId);
////dingTalk.talk("Warn","同步[借款清单]数据失败","同步xyqb_i_loan_a_m_history_bak表数据失败,请尽快处理! newMaxId:"+newMaxId+",newMaxId="+newMaxId);
}
//-------------------------------
}else {
log.error("增量同步xyqb_i_repayment_plan数据-历史id为空,停止同步! nowTime: {} , bakMaxId: {} , newMaxId: {} ",LocalDateTime.now(), bakMaxId, newMaxId);
dingTalk.talk("Warn","同步临时表数据失败","查询数据历史bakMaxId或newMaxId为空.");
dingTalk.talk_ToUser("数据同步异常2", "查询数据历史bakMaxId或newMaxId为空,停止T+1报送!发现问题,请及时处理!");
}
}catch (Exception e){
log.error("增量同步history和plan表数据异常, nowTime: {} ", LocalDateTime.now(), e);
dingTalk.talk("Error","同步history和plan表数据异常",e);
dingTalk.talk_ToUser("数据同步异常1", "同步history和plan表数据异常,停止T+1报送!发现问题,请及时处理!");
}
return false;
}
/**
* 描述: 将xyqb_i_loan_application_manifest_history表的数据
* 同步到xyqb_i_loan_a_m_history_p2p_bak表<br/>
* 参数: [] <br/>
* 返回值: boolean <br/>
* 创建人: yanhui.Hao <br/>
* 创建时间: 2019.12.17 <br/>
*/
private void syn_history_p2p_bak(){
LocalDateTime erlyDate = LocalDateTime.parse("2016-11-01T00:00:00");
LocalDateTime endDate = LocalDateTime.parse("2019-01-01T00:00:00");
int counter = 0;
while (true) {
Stopwatch startwatch = Stopwatch.createStarted();
counter++;
if (erlyDate.plusDays(counter).compareTo(endDate) > 0) {
break;
}
String starTime = erlyDate.plusDays(counter - 1).format(DateTimeFormatter.ISO_DATE);
String endTime = erlyDate.plusDays(counter).format(DateTimeFormatter.ISO_DATE);
try {
String tmp_sql = BaiHangHistoryConstant.SQL_TEMPLATE_HISTORY_P2P;
tmp_sql = tmp_sql.replace("##STARTTIME##",starTime);
tmp_sql = tmp_sql.replace("##ENDTIME##",endTime);
int upCount = xyqbHistoryJdbcTemplate.update(tmp_sql);
log.info("同步xyqb_i_loan_a_m_history_p2p_bak数据结束, startTime: {} , 耗时: {} , updateCount: {} ", starTime, startwatch.stop().elapsed(TimeUnit.MILLISECONDS)+".ms", upCount);
}catch (Exception e){
log.error("同步xyqb_i_loan_a_m_history_p2p_bak数据异常, startTime: {} , endTime: {} , counter: {} ", starTime, endTime,counter, e);
}
}
}
/**
* 描述: 将xyqb_i_repayment_plan表的数据同步到xyqb_i_repayment_plan_p2p_bak表 <br/>
* 参数: [] <br/>
* 返回值: void <br/>
* 创建人: yanhui.Hao <br/>
* 创建时间: 2019.12.17 <br/>
*/
private void syn_plan_p2p_bak(){
LocalDateTime erlyDate = LocalDateTime.parse("2016-11-01T00:00:00");
LocalDateTime endDate = LocalDateTime.parse("2019-10-25T00:00:00");
int counter = 0;
while (true) {
Stopwatch startwatch = Stopwatch.createStarted();
counter++;
if (erlyDate.plusDays(counter).compareTo(endDate) > 0) {
break;
}
String starTime = erlyDate.plusDays(counter - 1).format(DateTimeFormatter.ISO_DATE);
String endTime = erlyDate.plusDays(counter).format(DateTimeFormatter.ISO_DATE);
try {
String tmp_sql = BaiHangHistoryConstant.SQL_TEMPLATE_PLAN_P2P;
tmp_sql = tmp_sql.replace("##STARTTIME##",starTime);
tmp_sql = tmp_sql.replace("##ENDTIME##",endTime);
int upCount = xyqbHistoryJdbcTemplate.update(tmp_sql);
log.info("同步xyqb_i_repayment_plan_p2p_bak数据结束, startTime: {} , 耗时: {} , updateCount: {} ", starTime, startwatch.stop().elapsed(TimeUnit.MILLISECONDS)+".ms", upCount);
}catch (Exception e){
log.error("同步xyqb_i_repayment_plan_p2p_bak数据异常, startTime: {} , endTime: {} , counter: {} ", starTime, endTime,counter, e);
}
}
}
}
package cn.quantgroup.report.mapper.master;
import cn.quantgroup.report.domain.master.AccountPO;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface AccountPOMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table account
*
* @mbg.generated
*/
int insert(AccountPO record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table account
*
* @mbg.generated
*/
int insertSelective(AccountPO record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table account
*
* @mbg.generated
*/
List<AccountPO> selectByExample(AccountPO example);
void updateByParams(AccountPO example);
}
\ No newline at end of file
package cn.quantgroup.report.mapper.master;
import cn.quantgroup.report.domain.master.ApiRequestLogPO;
import org.springframework.stereotype.Repository;
@Repository
public interface ApiRequestLogPOMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table api_request_log_201805
*
* @mbg.generated
*/
int insert(ApiRequestLogPO record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table api_request_log_201805
*
* @mbg.generated
*/
int insertSelective(ApiRequestLogPO record);
}
\ No newline at end of file
package cn.quantgroup.report.mapper.master;
import cn.quantgroup.report.domain.baihang.ApplyLoanInfo;
import cn.quantgroup.report.domain.baihang.ApplyLoanInfoZhuDai;
import cn.quantgroup.report.domain.baihang.LoanInfoZhuDai;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* 贷款申请信息查询mapper
*
* @Author fengjunkai
* @Date 2019-03-26 15:25
*/
@Repository
public interface ApplyLoanInfoDbMapper {
void saveApplyLoanInfoRecordLog(ApplyLoanInfo applyLoanInfo);
List<ApplyLoanInfo> findAll();
/**
* 描述: 根据loan_application_history_id查询手动报送的申请bean <br/>
* 参数: loanApplicationHistoryId <br/>
* 返回值: ApplyLoanInfoZhuDai <br/>
* 创建人: yanhui.Hao <br/>
* 创建时间: 2019.09.25 <br/>
*/
ApplyLoanInfoZhuDai findApplyInfoA1ByHistoryId(String loanApplicationHistoryId);
}
package cn.quantgroup.report.mapper.master;
import cn.quantgroup.report.domain.master.CommonWithBillingApiRequestEvent;
import org.springframework.stereotype.Repository;
/**
* Created by suh on 2017/11/6.
*/
@Repository
public interface CommonApiReqestEventMapper {
int insert(CommonWithBillingApiRequestEvent event);
}
package cn.quantgroup.report.mapper.master;
import cn.quantgroup.report.domain.master.CostRecordPO;
import org.springframework.stereotype.Repository;
@Repository
public interface CostRecordPOMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table cost_record
*
* @mbg.generated
*/
int insert(CostRecordPO record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table cost_record
*
* @mbg.generated
*/
int insertSelective(CostRecordPO record);
}
\ No newline at end of file
package cn.quantgroup.report.mapper.master;
import cn.quantgroup.report.domain.master.DataPriceConfigPO;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface DataPriceConfigPOMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table data_price_config
*
* @mbg.generated
*/
List<DataPriceConfigPO> queryByParams(DataPriceConfigPO dataPriceConfigPO);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table data_price_config
*
* @mbg.generated
*/
int insert(DataPriceConfigPO record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table data_price_config
*
* @mbg.generated
*/
int insertSelective(DataPriceConfigPO record);
}
\ No newline at end of file
package cn.quantgroup.report.mapper.master;
import cn.quantgroup.report.domain.master.DataSourceCacheConfig;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @Author fengjunkai
* @Date 2019-06-19 14:05
*/
@Repository
public interface DataSourceCacheConfigMapper {
List<DataSourceCacheConfig> findAllCacheConfig();
}
package cn.quantgroup.report.mapper.master;
import cn.quantgroup.report.domain.master.DsSpecialUserHandle;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* Created by suh on 2017/11/6.
*/
@Repository
public interface DsSpecialUserHandleMapper {
int insert(DsSpecialUserHandle event);
List<DsSpecialUserHandle> selectAllByEnable();
int updateNotEnableByParams(DsSpecialUserHandle record);
}
package cn.quantgroup.report.mapper.master;
import cn.quantgroup.report.domain.master.ElevenBeiApiRequestEvent;
import org.springframework.stereotype.Repository;
/**
* Created by suh on 2017/11/6.
*/
@Repository
public interface ElevenBeiApiReqestEventMapper {
int insert(ElevenBeiApiRequestEvent event);
}
package cn.quantgroup.report.mapper.master;
import cn.quantgroup.report.domain.master.IntelliCreditLoanIssue;
import java.util.List;
public interface IntelliCreditLoanIssueMapper {
int insert(IntelliCreditLoanIssue record);
int insertSelective(IntelliCreditLoanIssue record);
IntelliCreditLoanIssue selectByPrimaryKey(Long id);
List<IntelliCreditLoanIssue> selectUndoneByBeginId(Long id);
int updateByPrimaryKeySelective(IntelliCreditLoanIssue record);
int updateByPrimaryKeyWithBLOBs(IntelliCreditLoanIssue record);
int updateByPrimaryKey(IntelliCreditLoanIssue record);
}
\ No newline at end of file
package cn.quantgroup.report.mapper.master;
import cn.quantgroup.report.domain.master.IntelliCreditLoanTrace;
public interface IntelliCreditLoanTraceMapper {
int insert(IntelliCreditLoanTrace record);
int insertSelective(IntelliCreditLoanTrace record);
IntelliCreditLoanTrace selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(IntelliCreditLoanTrace record);
int updateByPrimaryKey(IntelliCreditLoanTrace record);
}
\ No newline at end of file
package cn.quantgroup.report.mapper.master;
import cn.quantgroup.report.domain.master.IntelliCreditRequestEvent;
import org.springframework.stereotype.Repository;
@Repository
public interface IntelliCreditRequestEventMapper {
int insert(IntelliCreditRequestEvent record);
int insertSelective(IntelliCreditRequestEvent record);
IntelliCreditRequestEvent selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(IntelliCreditRequestEvent record);
int updateByPrimaryKey(IntelliCreditRequestEvent record);
}
\ No newline at end of file
package cn.quantgroup.report.mapper.master;
import cn.quantgroup.report.domain.baihang.BaiHangUpDateRecord;
import cn.quantgroup.report.domain.baihang.LoanInfoZhuDai;
import org.springframework.stereotype.Repository;
/**
* -----------------------------------------------------------------------------<br>
* 描述: 放款信息查询 <br>
* 作者:yanhui.Hao <br>
* 时间:2019.11.06 <br>
* 授权: (C) Copyright (c) 2017 <br>
* 公司: 北京众信利民信息技术有限公司 <br>
* -----------------------------------------------------------------------------
*/
@Repository
public interface LoanInfoDbMapper {
void saveLoanInfoRecordLog(LoanInfoZhuDai loanInfo);
void updateCurrentRecordEnableFalce(BaiHangUpDateRecord baiHangUpDateRecord);
}
package cn.quantgroup.report.mapper.master;
import cn.quantgroup.report.domain.baihang.BaiHangRepayment;
import cn.quantgroup.report.domain.baihang.BaiHangUpDateRecord;
import cn.quantgroup.report.domain.baihang.RepaymentInfoZhuDai;
import cn.quantgroup.report.domain.baihang.RepaymentLoanInfoLog;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* -----------------------------------------------------------------------------<br>
* 描述: 还款信息查询 <br>
* 作者:yanhui.Hao <br>
* 时间:2019.11.06 <br>
* 授权: (C) Copyright (c) 2017 <br>
* 公司: 北京众信利民信息技术有限公司 <br>
* -----------------------------------------------------------------------------
*/
@Repository
public interface RepaymentLoanInfoDbMapper {
void saveRepaymentLoanInfoLog(RepaymentInfoZhuDai repaymentLoanInfo);
void updateCurrentRecordEnableFalse(BaiHangUpDateRecord baiHangUpDateRecord);
RepaymentInfoZhuDai findLastOne(BaiHangRepayment baiHangRepayment);
/**
* 描述: 根据recordId查询op_code=A的 <br/>
* 参数: <br/>
* 返回值: <br/>
* 创建人: yanhui.Hao <br/>
* 创建时间: 2019.09.24 <br/>
*/
List<RepaymentLoanInfoLog> findByD3RecordId(String[] recordIdArray);
}
package cn.quantgroup.report.mapper.master;
import cn.quantgroup.report.domain.master.RepaymentLoanWhiteList;
import org.springframework.stereotype.Repository;
import org.apache.ibatis.annotations.Param;
/**
* -----------------------------------------------------------------------------<br>
* 描述: 百行报送逾期还款白名单表 <br>
* 作者:yanhui.Hao <br>
* 时间:2020.02.05 <br>
* 授权: (C) Copyright (c) 2017 <br>
* 公司: 北京众信利民信息技术有限公司 <br>
* -----------------------------------------------------------------------------
*/
@Repository
public interface RepaymentLoanWhiteListMapper {
RepaymentLoanWhiteList findRepaymentLoanWhiteListOne(@Param("loanId")String loanId, @Param("type")int type);
}
package cn.quantgroup.report.mapper.master;
import cn.quantgroup.report.domain.master.TransactionLogPO;
import org.springframework.stereotype.Repository;
@Repository
public interface TransactionLogPOMapper {
int insert(TransactionLogPO transactionLogPO);
}
\ No newline at end of file
package cn.quantgroup.report.mapper.master;
import cn.quantgroup.report.domain.master.UnionPayApiRequestEvent;
import org.springframework.stereotype.Repository;
/**
* Created by suh on 2018/2/11.
*/
@Repository
public interface UnionPayApiRequestEventMapper {
int insert(UnionPayApiRequestEvent event);
}
package cn.quantgroup.report.mapper.renhang;
import cn.quantgroup.report.domain.renhang.User;
import cn.quantgroup.report.domain.renhang.UserOcrVo;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface UserMapper {
//查询日增用户,之前没有的
List<User> queryGrowingUser();
}
\ No newline at end of file
package cn.quantgroup.report.mapper.renhang;
import cn.quantgroup.report.domain.renhang.UserOcrVo;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface UserOcrMapper {
int insertUserOcr(UserOcrVo userOcr);
List<UserOcrVo> findUserOcr(UserOcrVo record);
}
\ No newline at end of file
package cn.quantgroup.report.mapper.tidbrisk;
import cn.quantgroup.report.domain.tidbrisk.CallRecord2;
import org.springframework.stereotype.Repository;
@Repository
public interface CallRecordMapper {
/**
* 描述: call_record表
* 迁移至fengkong-tidb.quantgroups.com的risk_datasource库<br/>
* 参数: <br/>
* 返回值: <br/>
* 创建人: yanhui.Hao <br/>
* 创建时间: 2019.12.30 <br/>
*/
int insertCallRecord(CallRecord2 callRecord);
}
\ No newline at end of file
package cn.quantgroup.report.service;
import cn.quantgroup.report.cmpt.MonitorCmpt;
import cn.quantgroup.report.enums.RequestUrlType;
import cn.quantgroup.report.service.thirdpartymonitor.ThirdpartyApiMonitorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -19,9 +17,6 @@ public class AbstractBaseService {
@Autowired
protected MonitorCmpt monitorCmpt;
@Autowired
protected DataSourceCacheConfigService cacheConfigService;
static {
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
if (pool != null) pool.shutdown();
......@@ -29,11 +24,11 @@ public class AbstractBaseService {
}));
}
protected void saveLog(ThirdpartyApiMonitorService thirdpartyApiMonitorService, RequestUrlType urlType, Long start, Long end, String buscode, String message, String hitFlag) {
/*protected void saveLog(ThirdpartyApiMonitorService thirdpartyApiMonitorService, RequestUrlType urlType, Long start, Long end, String buscode, String message, String hitFlag) {
final String code = buscode;
final String msg = message;
final int millsElapse = (int)(end-start);
final String flag = hitFlag;
pool.execute(()->thirdpartyApiMonitorService.saveLog(urlType, code, msg, flag, millsElapse));
}
}*/
}
package cn.quantgroup.report.service;
import cn.quantgroup.report.domain.master.DataSourceCacheConfig;
import cn.quantgroup.report.mapper.master.DataSourceCacheConfigMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
/**
* 数据源缓存配置
*
* @Author fengjunkai
* @Date 2019-06-19 14:53
*/
@Slf4j
@Service
public class DataSourceCacheConfigService {
private Map<String, Integer> allDataSourceCacheConfigMap = new ConcurrentHashMap();
private Map<String, Integer> allDataSourceTestCacheConfigMap = new ConcurrentHashMap();
@Autowired
private DataSourceCacheConfigMapper dataSourceCacheConfigMapper;
@PostConstruct
private void initDataSourceCacheConfig() {
init();
}
public void init() {
allDataSourceCacheConfigMap.clear();
allDataSourceTestCacheConfigMap.clear();
List<DataSourceCacheConfig> allCacheConfig = dataSourceCacheConfigMapper.findAllCacheConfig();
allDataSourceCacheConfigMap = allCacheConfig.stream().collect(Collectors.toMap(DataSourceCacheConfig::getProductType, DataSourceCacheConfig::getProductCacheTime));
allDataSourceTestCacheConfigMap = allCacheConfig.stream().collect(Collectors.toMap(DataSourceCacheConfig::getProductType, DataSourceCacheConfig::getProductTestCacheTime));
}
public Integer getCacheTime(String productType) {
Integer cacheTime = allDataSourceCacheConfigMap.get(productType);
return cacheTime == null ? 1 : cacheTime;
}
public Integer getTestCacheTime(String productType) {
Integer testCacheTime = allDataSourceTestCacheConfigMap.get(productType);
return testCacheTime == null ? 1 : testCacheTime;
}
}
......@@ -2,9 +2,12 @@ package cn.quantgroup.report.service.baihang;
import cn.quantgroup.report.service.AbstractBaseService;
import cn.quantgroup.report.service.CommonSuperService;
import cn.quantgroup.report.service.baihang.client.BhInterfaceCreditApiClient;
import cn.quantgroup.report.service.baihang.request.InterfaceUploadRequest;
import cn.quantgroup.report.service.baihang.response.InterfaceUploadResponse;
import cn.quantgroup.report.service.baihang.util.BHRSAUtils;
import cn.quantgroup.report.service.baihang.util.Base64;
import cn.quantgroup.report.service.http.IHttpService;
import cn.quantgroup.report.utils.IdUtils;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.ImmutableMap;
import lombok.extern.slf4j.Slf4j;
......@@ -12,7 +15,10 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.security.PublicKey;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
......@@ -39,6 +45,8 @@ public class BaiHangQueryService extends AbstractBaseService implements CommonSu
@Autowired
private IHttpService iHttpService;
private static PublicKey baihang_zhudai_publickey = null;
/**
* -----------------------------------------------------------------------------<br>
* 描 述: 百行个人征信报告(zxlm实体:贷前/贷中/贷后)查询公共方法 <br>
......@@ -73,9 +81,9 @@ public class BaiHangQueryService extends AbstractBaseService implements CommonSu
try {
JSONObject applyLoanInfo = new JSONObject();
applyLoanInfo.put("reqID", transactionId);//记录唯一标识
applyLoanInfo.put("name", BaiHangZhuDaiService.interfaceUploadClient(name));
applyLoanInfo.put("name", interfaceUploadClient(name));
applyLoanInfo.put("idType", 1);//证件类型
applyLoanInfo.put("pid", BaiHangZhuDaiService.interfaceUploadClient(identity));
applyLoanInfo.put("pid", interfaceUploadClient(identity));
applyLoanInfo.put("creditRptVersion", 1);//信用报告版本 1:机构简版
applyLoanInfo.put("queryReason", queryReason);//查询原因
if ("2".equals(queryReason) || "3".equals(queryReason)) {
......@@ -113,4 +121,34 @@ public class BaiHangQueryService extends AbstractBaseService implements CommonSu
return headerMap;
}
public static String interfaceUploadClient(String param) throws Exception {
InterfaceUploadRequest req = new InterfaceUploadRequest();
List<String> datas = new ArrayList<String>();
datas.add(param);
//设置待加密的原始数据集合
req.setData(datas);
BhInterfaceCreditApiClient client = new BhInterfaceCreditApiClient();
//初始化设置RSA公钥
client.init(getBaihangZDPublickey());
//执行加密操作
InterfaceUploadResponse response = client.execute(req);
if (response.isSuccess) {
List<String> data = response.getEncryptData();
return data.get(0);
}
throw new Exception();
}
private static PublicKey getBaihangZDPublickey(){
if(baihang_zhudai_publickey==null){
try{
baihang_zhudai_publickey = BHRSAUtils.readRSAPublicKey("/baihang/rsa_public_key.pem");
log.info("初始化百行助贷PublicKey实例完成");
}catch(Exception e){
log.error("初始化百行助贷PublicKey实例", e);
}
}
return baihang_zhudai_publickey;
}
}
package cn.quantgroup.report.service.manualTool;
import cn.quantgroup.report.domain.master.CallRecord1;
import cn.quantgroup.report.domain.master.TransactionLogPO;
import cn.quantgroup.report.domain.tidbrisk.CallRecord3;
import cn.quantgroup.report.utils.JdbcUtils;
import cn.quantgroup.report.utils.ReadOrWriteTxt;
import com.alibaba.fastjson.JSON;
import com.google.common.base.Stopwatch;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import javax.sql.DataSource;
import java.io.File;
import java.io.IOException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
/**
* -----------------------------------------------------------------------------<br>
* 描述: <br>
* 作者:yanhui.Hao <br>
* 时间:2019.12.31 <br>
* 授权: (C) Copyright (c) 2017 <br>
* 公司: 北京众信利民信息技术有限公司 <br>
* -----------------------------------------------------------------------------
*/
@Slf4j
@Service
public class CleanningTransactionLogService {
@Autowired
private JdbcTemplate riskDatasourceJdbcTemplate;
@Autowired
private JdbcTemplate tidbRiskJdbcTemplate;
@Autowired
@Qualifier("tidbRiskDataSource")
private DataSource tidbRiskDataSource;
/* @Resource(name = "tidbRiskDataSource")
private DataSource tidbRiskDataSource2;*/
public static void main(String[] args) {
// LocalDateTime now = LocalDateTime.now();
try {
Stopwatch stopwatch = Stopwatch.createStarted();
Map<String, String> map = new HashMap<>();
Map<String, String> map1 = new HashMap<>();
for (int i = 0; i < 500000; i++) {
map.put(new StringBuffer(String.valueOf(i)).append(String.valueOf(i)).append(String.valueOf(i)).append(String.valueOf(i)).toString(), String.valueOf(i));
}
for (int i = 0; i < 500000; i++) {
map1.put(new StringBuffer(String.valueOf(i)).append(String.valueOf(i)).append(String.valueOf(i)).append(String.valueOf(i)).toString(), String.valueOf(i));
}
System.out.println(stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
} catch (Exception e) {
e.printStackTrace();
}
}
/* @Async
public void start() {
try {
String tmpTime = "2019-11-23";
SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd");
LocalDateTime now = new Timestamp(simpleDateFormat1.parse(tmpTime).getTime()).toLocalDateTime();
for (int i = 0; i < 800; i++) {
String startTime = now.minusDays(i).format(DateTimeFormatter.ISO_DATE);
String endTime = now.minusDays(i + 1).format(DateTimeFormatter.ISO_DATE);
String sql = "select * from transaction_log where time_created > '" + endTime + "' and time_created < '" + startTime + "'";
Stopwatch queryStopwatch = Stopwatch.createStarted();
List<TransactionLogPO> transactionLogPOList = riskDatasourceJdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TransactionLogPO.class));
log.info("transactionLog查询数据结束, startTime: {} , endTime: {} , size: {} , sql: {} , 耗时: {} ", startTime, endTime, CollectionUtils.isEmpty(transactionLogPOList) ? 0 : transactionLogPOList.size(), sql, queryStopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
if (CollectionUtils.isEmpty(transactionLogPOList)) {
log.info("查询数据为空跳过");
continue;
}
Map<String, TransactionLogPO> transactionLogPOMap = new HashMap<>();
Map<String, CallRecord1> callRecord1Map = new HashMap<>();
Stopwatch stopwatch = Stopwatch.createStarted();
for (int tran = 0; tran < transactionLogPOList.size(); tran++) {
TransactionLogPO transactionLogPO = transactionLogPOList.get(tran);
String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(transactionLogPO.getTimeCreated());
String key = new StringBuffer(transactionLogPO.getTransactionId()).append(StringUtils.isNotBlank(transactionLogPO.getUuid()) ? transactionLogPO.getUuid() : "").append(transactionLogPO.getUrlType()).append(transactionLogPO.getCode()).append(format).toString();
// System.out.println(key);
transactionLogPOMap.put(key, transactionLogPO);
}
log.info("transactionLog 组装数据完成 查询大小: {} , 组装后大小: {} , 耗时: {} ", transactionLogPOList.size(), transactionLogPOMap.size(), stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
Stopwatch callRStopwatch = Stopwatch.createStarted();
String sql1 = "select * from call_record where created_at > '" + endTime + "' and created_at < '" + startTime + "' order by created_at desc;";
List<CallRecord1> queryResult = riskDatasourceJdbcTemplate.query(sql1, new BeanPropertyRowMapper<>(CallRecord1.class));
log.info("callRecord查询数据结束, startTime: {} , endTime: {} , size: {} , sql: {} , 耗时: {} ", startTime, endTime, CollectionUtils.isEmpty(queryResult) ? 0 : queryResult.size(), sql1, callRStopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
if (CollectionUtils.isNotEmpty(queryResult)) {
Stopwatch callStopwatch = Stopwatch.createStarted();
for (int call = 0; call < queryResult.size(); call++) {
CallRecord1 callRecord1 = queryResult.get(call);
String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(callRecord1.getCreated_at().getTime()));
String key = new StringBuffer(callRecord1.getTransactionId()).append(StringUtils.isNotBlank(callRecord1.getUuid()) ? callRecord1.getUuid() : "").append(callRecord1.getUrlType()).append(callRecord1.getCode()).append(format).toString();
callRecord1Map.put(key, callRecord1);
}
log.info("callRecord 组装数据完成 查询大小: {} , 组装后大小: {} , 耗时: {} ", queryResult.size(), callRecord1Map.size(), callStopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
Stopwatch delStopwatch = Stopwatch.createStarted();
Iterator<Map.Entry<String, TransactionLogPO>> iterator = transactionLogPOMap.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, TransactionLogPO> next = iterator.next();
String key = next.getKey();
if (callRecord1Map.containsKey(key)) {
iterator.remove();
}
}
log.info("去重 组装数据完成 查询大小: {} , 组装后大小: {} , 耗时: {} ", queryResult.size(), transactionLogPOMap.size(), delStopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
}
if (transactionLogPOMap.size()>0) {
List<CallRecord1> callRecord1s = new ArrayList<>();
Stopwatch stopwatch1222 = Stopwatch.createStarted();
transactionLogPOMap.forEach((k, v)->{
TransactionLogPO transactionLogPO = v;
CallRecord1 callRecord1 = new CallRecord1();
callRecord1.setCode(String.valueOf(transactionLogPO.getCode()));
callRecord1.setUrlType(transactionLogPO.getUrlType());
callRecord1.setTransactionId(transactionLogPO.getTransactionId());
callRecord1.setUuid(transactionLogPO.getUuid());
Timestamp time = new Timestamp(transactionLogPO.getTimeCreated().getTime());
callRecord1.setCreated_at(time);
callRecord1.setUpdated_at(time);
callRecord1s.add(callRecord1);
if (callRecord1s.size() > 0 && callRecord1s.size() % 1000 == 0) {
Stopwatch stopwatch1 = Stopwatch.createStarted();
JdbcUtils.prepareBatchUpdateExecuteTransactionid("INSERT INTO `call_record` (`transaction_id`, `uuid`, `url_type`, `code`, `created_at`, `updated_at`) VALUES (?, ?, ?, ?, ?, ?)", callRecord1s);
callRecord1s.clear();
log.info("插入数据完成, 耗时: {}", stopwatch1.stop().elapsed(TimeUnit.MILLISECONDS));
}
});
if (callRecord1s.size() > 0) {
JdbcUtils.prepareBatchUpdateExecuteTransactionid("INSERT INTO `call_record` (`transaction_id`, `uuid`, `url_type`, `code`, `created_at`, `updated_at`) VALUES (?, ?, ?, ?, ?, ?)", callRecord1s);
}
log.info("一天数据插入完成, 大小: {} , 耗时: {} ", transactionLogPOMap.size(), stopwatch1222.stop().elapsed(TimeUnit.MILLISECONDS));
}
}
log.info("完事");
} catch (Exception e) {
log.error("清洗数据异常", e);
}
}*/
// @Async
// public void start() {
//
// try {
// String tmpTime = "2019-12-21";
// SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd");
// LocalDateTime now = new Timestamp(simpleDateFormat1.parse(tmpTime).getTime()).toLocalDateTime();
// for (int i = 0; i < 800; i++) {
// String startTime = now.minusDays(i).format(DateTimeFormatter.ISO_DATE);
// String endTime = now.minusDays(i + 1).format(DateTimeFormatter.ISO_DATE);
// String sql = "select * from transaction_log where time_created > '"+ endTime +"' and time_created < '"+startTime+"'";
// Stopwatch queryStopwatch = Stopwatch.createStarted();
// List<TransactionLogPO> transactionLogPOList = riskDatasourceJdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TransactionLogPO.class));
// log.info("查询数据结束, startTime: {} , endTime: {} , size: {} , sql: {} , 耗时: {} ", startTime, endTime, CollectionUtils.isEmpty(transactionLogPOList)?0:transactionLogPOList.size(), sql, queryStopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
// if(CollectionUtils.isEmpty(transactionLogPOList)){
// log.info("查询数据为空跳过");
// continue;
// }
// Stopwatch oneStopwatch = Stopwatch.createStarted();
// List<CallRecord1> callRecord1s = new ArrayList<>();
// for (int j = 0; j < transactionLogPOList.size(); j++) {
// try{
// TransactionLogPO transactionLogPO = transactionLogPOList.get(j);
// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// String d = simpleDateFormat.format(transactionLogPO.getTimeCreated());
// String sql1 = "";
// if(StringUtils.isNotBlank(transactionLogPO.getUuid())){
// sql1 = "select * from call_record where transaction_id = '"+transactionLogPO.getTransactionId()+"' and uuid = '" + transactionLogPO.getUuid() + "' and url_type = '" + transactionLogPO.getUrlType() + "' and code = '" + transactionLogPO.getCode() + "' and created_at = '"+d+"';";
// }else{
// sql1 = "select * from call_record where transaction_id = '"+transactionLogPO.getTransactionId()+"' and url_type = '" + transactionLogPO.getUrlType() + "' and code = '" + transactionLogPO.getCode() + "' and created_at = '"+d+"';";;
// }
// List<CallRecord1> queryResult = riskDatasourceJdbcTemplate.query(sql1, new BeanPropertyRowMapper<>(CallRecord1.class));
// if(CollectionUtils.isEmpty(queryResult)){
//// log.info("查询结果不为空,重新插入 sql: {} , resutl: {} ", sql1, JSON.toJSONString(queryResult));
// CallRecord1 callRecord1 = new CallRecord1();
// callRecord1.setCode(String.valueOf(transactionLogPO.getCode()));
// callRecord1.setUrlType(transactionLogPO.getUrlType());
// callRecord1.setTransactionId(transactionLogPO.getTransactionId());
// callRecord1.setUuid(transactionLogPO.getUuid());
// Timestamp time = new Timestamp(transactionLogPO.getTimeCreated().getTime());
// callRecord1.setCreated_at(time);
// callRecord1.setUpdated_at(time);
//
// callRecord1s.add(callRecord1);
// if(callRecord1s.size()>0 && callRecord1s.size()%1000==0){
// Stopwatch stopwatch = Stopwatch.createStarted();
// JdbcUtils.prepareBatchUpdateExecuteTransactionid("INSERT INTO `call_record` (`transaction_id`, `uuid`, `url_type`, `code`, `created_at`, `updated_at`) VALUES (?, ?, ?, ?, ?, ?)", callRecord1s);
// callRecord1s.clear();
// log.info("插入数据完成, 耗时: {}", stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
// }
// }else{
// log.info("命中原有数据不插入");
// }
//
// }catch(Exception e){
// log.error("清洗插入callRecord异常", e);
// }
//
// }
// if(callRecord1s.size()>0){
// JdbcUtils.prepareBatchUpdateExecuteTransactionid("INSERT INTO `call_record` (`transaction_id`, `uuid`, `url_type`, `code`, `created_at`, `updated_at`) VALUES (?, ?, ?, ?, ?, ?)", callRecord1s);
// log.info("插入数据完成1, startTime: {} , endTime: {} , 大小: {} , 耗时: {} ", startTime, endTime, transactionLogPOList.size(), oneStopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
// }
//
// }
// log.info("完事");
// } catch (Exception e) {
// log.error("清洗数据异常", e);
// }
// }
/*
@Async
public void synCallRecord(String newYnrTime) {//yyyy-MM-dd
try {
SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd");
LocalDateTime now = new Timestamp(simpleDateFormat1.parse(newYnrTime).getTime()).toLocalDateTime();
//开始时间 2018-10-17 11:30:39
//结束时间 2019-12-31 10:36:34
//相差440天
for (int i = 0; i < 500; i++) {
String startTime = now.minusDays(i+1).format(DateTimeFormatter.ISO_DATE);
String endTime = now.minusDays(i).format(DateTimeFormatter.ISO_DATE);
String TRANSACTION_SQL = "select transaction_id, uuid, url_type, code, time_created " +
" from transaction_log where time_created >= '" + startTime + "' and time_created < '" + endTime + "'";
Stopwatch queryStopwatch = Stopwatch.createStarted();
List<TransactionLogPO> transactionLogPOList = riskDatasourceJdbcTemplate.query(TRANSACTION_SQL, new BeanPropertyRowMapper<>(TransactionLogPO.class));
log.info("transactionLog查询数据结束, startTime: {} , endTime: {} , size: {} , sql: {} , 耗时: {} ", startTime, endTime, CollectionUtils.isEmpty(transactionLogPOList) ? 0 : transactionLogPOList.size(), TRANSACTION_SQL, queryStopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
if (CollectionUtils.isEmpty(transactionLogPOList)) {
log.info("查询数据为空跳过, startTime: {} , endTime: {} ",startTime, endTime);
continue;
}
Map<String, TransactionLogPO> transactionLogPOMap = new HashMap<>();
Stopwatch stopwatch = Stopwatch.createStarted();
for (int tran = 0; tran < transactionLogPOList.size(); tran++) {
TransactionLogPO transactionLogPO = transactionLogPOList.get(tran);
String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(transactionLogPO.getTimeCreated());
String key = new StringBuffer(transactionLogPO.getTransactionId())
.append(StringUtils.isNotBlank(transactionLogPO.getUuid()) ? transactionLogPO.getUuid() : "")
.append(transactionLogPO.getUrlType())
.append(transactionLogPO.getCode())
.append(format).toString();
transactionLogPOMap.put(key, transactionLogPO);
}
log.info("transactionLog组装数据完成, startTime: {} , 查询大小: {} , 组装后大小: {} , 耗时: {} ", startTime, transactionLogPOList.size(), transactionLogPOMap.size(), stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
Stopwatch callRStopwatch = Stopwatch.createStarted();
String CALL_SQL = "select request_url, channel_type, channel_id, transaction_id, uuid, url_type, code, created_at, updated_at " +
" from call_record where created_at >= '" + startTime + "' and created_at < '" + endTime + "' order by created_at desc;";
List<CallRecord1> queryResult = riskDatasourceJdbcTemplate.query(CALL_SQL, new BeanPropertyRowMapper<>(CallRecord1.class));
log.info("callRecord查询数据结束, startTime: {} , endTime: {} , size: {} , sql: {} , 耗时: {} ", startTime, endTime, CollectionUtils.isEmpty(queryResult) ? 0 : queryResult.size(), CALL_SQL, callRStopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
Map<String, CallRecord1> callRecord1Map = new HashMap<>();
if (CollectionUtils.isNotEmpty(queryResult)) {
Stopwatch callStopwatch = Stopwatch.createStarted();
for (int call = 0; call < queryResult.size(); call++) {
CallRecord1 callRecord1 = queryResult.get(call);
String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(callRecord1.getCreated_at().getTime()));
String key = new StringBuffer(callRecord1.getTransactionId())
.append(StringUtils.isNotBlank(callRecord1.getUuid()) ? callRecord1.getUuid() : "")
.append(callRecord1.getUrlType())
.append(callRecord1.getCode())
.append(format).toString();
callRecord1Map.put(key, callRecord1);
}
log.info("callRecord组装数据完成, startTime: {} , 查询大小: {} , 组装后大小: {} , 耗时: {} ", startTime, queryResult.size(), callRecord1Map.size(), callStopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
Stopwatch delStopwatch = Stopwatch.createStarted();
Iterator<Map.Entry<String, TransactionLogPO>> iterator = transactionLogPOMap.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, TransactionLogPO> next = iterator.next();
String key = next.getKey();
if (callRecord1Map.containsKey(key)) {
iterator.remove();
}
}
log.info("去重组装数据完成, startTime: {} , callRecord查询大小: {} , 组装后transactionLogPOMap大小: {} , 耗时: {} ", startTime, queryResult.size(), transactionLogPOMap.size(), delStopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
}
if (transactionLogPOMap.size()>0) {
List<CallRecord1> callRecord1s = new ArrayList<>();
Stopwatch stopwatch1222 = Stopwatch.createStarted();
transactionLogPOMap.forEach((k, v)->{
TransactionLogPO transactionLogPO = v;
//c.request_url, c.channel_type, c.channel_id
CallRecord1 callRecord1 = new CallRecord1();
callRecord1.setCode(String.valueOf(transactionLogPO.getCode()));
callRecord1.setUrlType(transactionLogPO.getUrlType());
callRecord1.setTransactionId(transactionLogPO.getTransactionId());
callRecord1.setUuid(transactionLogPO.getUuid());
Timestamp time = new Timestamp(transactionLogPO.getTimeCreated().getTime());
callRecord1.setCreated_at(time);
callRecord1.setUpdated_at(time);
callRecord1s.add(callRecord1);
if (callRecord1s.size() > 0 && callRecord1s.size() % 1000 == 0) {
Stopwatch stopwatch1 = Stopwatch.createStarted();
JdbcUtils.prepareBatchUpdateExecuteTransactionid("INSERT INTO `call_record` (`transaction_id`, `uuid`, `url_type`, `code`, `created_at`, `updated_at`) VALUES (?, ?, ?, ?, ?, ?)", callRecord1s);
callRecord1s.clear();
log.info("插入数据完成, 耗时: {}", stopwatch1.stop().elapsed(TimeUnit.MILLISECONDS));
}
});
if (callRecord1s.size() > 0) {
JdbcUtils.prepareBatchUpdateExecuteTransactionid("INSERT INTO `call_record` (`transaction_id`, `uuid`, `url_type`, `code`, `created_at`, `updated_at`) VALUES (?, ?, ?, ?, ?, ?)", callRecord1s);
}
log.info("一天数据插入完成, 大小: {} , 耗时: {} ", transactionLogPOMap.size(), stopwatch1222.stop().elapsed(TimeUnit.MILLISECONDS));
}
}
log.info("完事");
} catch (Exception e) {
log.error("清洗数据异常", e);
}
}
*/
@Async
public void synCallRecordNew(String newYnrTime, String isExecuteOnce) {//yyyy-MM-dd
try {
boolean executeOnce = false;
if(StringUtils.isNotEmpty(isExecuteOnce) && "true".equals(isExecuteOnce)){
executeOnce = true;
}
SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd");
LocalDateTime now = new Timestamp(simpleDateFormat1.parse(newYnrTime).getTime()).toLocalDateTime();
//开始时间 2018-10-17 11:30:39
//结束时间 2019-12-31 10:36:34
//相差440天
for (int i = 0; i < 500; i++) {
String startTime = now.minusDays(i+1).format(DateTimeFormatter.ISO_DATE);
String endTime = now.minusDays(i).format(DateTimeFormatter.ISO_DATE);
String TRANSACTION_SQL = "select request_url, channel_type, channel_id, transaction_id, uuid, url_type, code, created_at, updated_at " +
" from call_record where created_at >= '" + startTime + "' and created_at < '" + endTime + "'";
Stopwatch queryStopwatch = Stopwatch.createStarted();
List<CallRecord3> transactionLogPOList = riskDatasourceJdbcTemplate.query(TRANSACTION_SQL, new BeanPropertyRowMapper<>(CallRecord3.class));
log.info("transactionLog查询数据结束, startTime: {} , endTime: {} , size: {} , sql: {} , 耗时: {} ", startTime, endTime, CollectionUtils.isEmpty(transactionLogPOList) ? 0 : transactionLogPOList.size(), TRANSACTION_SQL, queryStopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
if (CollectionUtils.isEmpty(transactionLogPOList)) {
log.info("查询数据为空跳过, startTime: {} , endTime: {} ",startTime, endTime);
continue;
}
Map<String, CallRecord3> transactionLogPOMap = new HashMap<>();
Stopwatch stopwatch = Stopwatch.createStarted();
for (int tran = 0; tran < transactionLogPOList.size(); tran++) {
CallRecord3 transactionLogPO = transactionLogPOList.get(tran);
String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(transactionLogPO.getCreatedAt());
String key = new StringBuffer(transactionLogPO.getTransactionId())
.append(StringUtils.isNotBlank(transactionLogPO.getUuid()) ? transactionLogPO.getUuid() : "")
.append(transactionLogPO.getUrlType())
.append(transactionLogPO.getCode())
.append(format).toString();
transactionLogPOMap.put(key, transactionLogPO);
}
log.info("transactionLog组装数据完成, startTime: {} , 查询大小: {} , 组装后大小: {} , 耗时: {} ", startTime, transactionLogPOList.size(), transactionLogPOMap.size(), stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
Stopwatch callRStopwatch = Stopwatch.createStarted();
String CALL_SQL = "select transaction_id, uuid, url_type, code, created_at " +
" from call_record where created_at >= '" + startTime + "' and created_at < '" + endTime + "' order by created_at desc;";
List<CallRecord1> queryResult = tidbRiskJdbcTemplate.query(CALL_SQL, new BeanPropertyRowMapper<>(CallRecord1.class));
log.info("callRecord查询数据结束, startTime: {} , endTime: {} , size: {} , sql: {} , 耗时: {} ", startTime, endTime, CollectionUtils.isEmpty(queryResult) ? 0 : queryResult.size(), CALL_SQL, callRStopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
Map<String, CallRecord1> callRecord1Map = new HashMap<>();
if (CollectionUtils.isNotEmpty(queryResult)) {
Stopwatch callStopwatch = Stopwatch.createStarted();
for (int call = 0; call < queryResult.size(); call++) {
CallRecord1 callRecord1 = queryResult.get(call);
String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(callRecord1.getCreated_at().getTime()));
String key = new StringBuffer(callRecord1.getTransactionId())
.append(StringUtils.isNotBlank(callRecord1.getUuid()) ? callRecord1.getUuid() : "")
.append(callRecord1.getUrlType())
.append(callRecord1.getCode())
.append(format).toString();
callRecord1Map.put(key, callRecord1);
}
log.info("callRecord组装数据完成, startTime: {} , 查询大小: {} , 组装后大小: {} , 耗时: {} ", startTime, queryResult.size(), callRecord1Map.size(), callStopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
Stopwatch delStopwatch = Stopwatch.createStarted();
Iterator<Map.Entry<String, CallRecord3>> iterator = transactionLogPOMap.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, CallRecord3> next = iterator.next();
String key = next.getKey();
if (callRecord1Map.containsKey(key)) {
iterator.remove();
}
}
log.info("去重组装数据完成, startTime: {} , callRecord查询大小: {} , 组装后transactionLogPOMap大小: {} , 耗时: {} ", startTime, queryResult.size(), transactionLogPOMap.size(), delStopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
}
if (transactionLogPOMap.size()>0) {
List<CallRecord3> callRecord3List = new ArrayList<>();
Stopwatch stopwatch1222 = Stopwatch.createStarted();
AtomicInteger pageNum = new AtomicInteger();
String INSERT_SQL = "INSERT INTO `call_record` (`request_url`, `channel_type`, `channel_id`, `transaction_id`, `uuid`, `url_type`, `code`, `created_at`, `updated_at`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) ";
transactionLogPOMap.forEach((k, v)->{
callRecord3List.add(v);
if (callRecord3List.size() > 0 && callRecord3List.size() % 1000 == 0) {
Stopwatch stopwatch1 = Stopwatch.createStarted();
JdbcUtils.batchUpdateExecuteCallRecord(tidbRiskDataSource,INSERT_SQL, callRecord3List);
callRecord3List.clear();
pageNum.getAndIncrement();
log.info("插入数据完成, pageNum: {} , 耗时: {} ", pageNum.get(), stopwatch1.stop().elapsed(TimeUnit.MILLISECONDS));
}
});
if (callRecord3List.size() > 0) {
JdbcUtils.batchUpdateExecuteCallRecord(tidbRiskDataSource,INSERT_SQL, callRecord3List);
pageNum.getAndIncrement();
}
log.info("一天数据插入完成, startTime: {} , pageNum: {} , 大小: {} , 耗时: {} ",startTime, pageNum.get(), transactionLogPOMap.size(), stopwatch1222.stop().elapsed(TimeUnit.MILLISECONDS));
}else{
log.info("一天数据插入完成, startTime: {} , transactionLogPOMap size is Empty!",startTime);
}
if(executeOnce){
log.info("一天数据插入完成, newYnrTime: {} , isExecuteOnce: {} , startTime: {} , endTime: {} ,",newYnrTime, isExecuteOnce, startTime, endTime);
break;
}
}
log.info("----All清洗数据结束----");
} catch (Exception e) {
log.error("清洗数据异常", e);
}
}
/**
* 描述: 检测tidb的call_record表数据是否有重复数据 <br/>
* 参数: [newYnrTime, isExecuteOnce] <br/>
* 返回值: void <br/>
* 创建人: yanhui.Hao <br/>
* 创建时间: 2020.01.02 <br/>
*/
@Async
public void checkCallRecordCF(String newYnrTime, String isExecuteOnce) { //yyyy-MM-dd
try {
boolean executeOnce = false;
if(StringUtils.isNotEmpty(isExecuteOnce) && "true".equals(isExecuteOnce)){
executeOnce = true;
}
SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd");
LocalDateTime now = new Timestamp(simpleDateFormat1.parse(newYnrTime).getTime()).toLocalDateTime();
//开始时间 2018-10-17 11:30:39
//结束时间 2019-12-31 10:36:34
//相差440天
for (int i = 0; i < 500; i++) {
String startTime = now.minusDays(i+1).format(DateTimeFormatter.ISO_DATE);
String endTime = now.minusDays(i).format(DateTimeFormatter.ISO_DATE);
Stopwatch callRStopwatch = Stopwatch.createStarted();
String CALL_SQL = "select transaction_id, uuid, url_type, code, created_at " +
" from call_record where created_at >= '" + startTime + "' and created_at < '" + endTime + "'";
List<CallRecord1> queryResult = tidbRiskJdbcTemplate.query(CALL_SQL, new BeanPropertyRowMapper<>(CallRecord1.class));
log.info("checkCallRecordCF检测重复callRecord查询数据结束, startTime: {} , endTime: {} , size: {} , sql: {} , 耗时: {} ", startTime, endTime, CollectionUtils.isEmpty(queryResult) ? 0 : queryResult.size(), CALL_SQL, callRStopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
Map<String, Integer> callRecord1Map = new HashMap<>();
if (CollectionUtils.isNotEmpty(queryResult)) {
Stopwatch callStopwatch = Stopwatch.createStarted();
for (int call = 0; call < queryResult.size(); call++) {
CallRecord1 callRecord1 = queryResult.get(call);
String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(callRecord1.getCreated_at().getTime()));
String key = new StringBuffer(callRecord1.getTransactionId()).append(",")
.append(StringUtils.isNotBlank(callRecord1.getUuid()) ? callRecord1.getUuid() : "").append(",")
.append(callRecord1.getUrlType()).append(",")
.append(callRecord1.getCode()).append(",")
.append(format).toString();
if(callRecord1Map.containsKey(key)){
callRecord1Map.put(key, callRecord1Map.get(key).intValue()+1);
}else{
callRecord1Map.put(key, 1);
}
}
log.info("checkCallRecordCF检测重复callRecord组装数据完成, startTime: {} , 查询List大小: {} , 组装后Map大小: {} , 耗时: {} ", startTime, queryResult.size(), callRecord1Map.size(), callStopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
Stopwatch delStopwatch = Stopwatch.createStarted();
Iterator<Map.Entry<String, Integer>> iterator = callRecord1Map.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, Integer> next = iterator.next();
String key = next.getKey();
Integer value = next.getValue();
if (value!=null && value.intValue() >1 ) {
log.info("checkCallRecordCF检测重复发现有重复数据, startTime: {} , 重复次数value: {} , key: {} ", startTime, value, key);
}else{
iterator.remove();
}
}
log.info("checkCallRecordCF检测重复数据结束, startTime: {} , 查询List大小: {} , 过滤后callRecord1Map大小: {} , 耗时: {} ", startTime, queryResult.size(), callRecord1Map.size(), delStopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
}
if(executeOnce){
log.info("checkCallRecordCF检测重复一天数据完成, newYnrTime: {} , isExecuteOnce: {} , startTime: {} , endTime: {} ,",newYnrTime, isExecuteOnce, startTime, endTime);
break;
}
}
log.info("----checkCallRecordCF---All检测重复数据结束----");
} catch (Exception e) {
log.error("checkCallRecordCF检测重复数据异常", e);
}
}
@Async
public void checkTransactionLogCF(String newYnrTime, String isExecuteOnce) { //yyyy-MM-dd
try {
boolean executeOnce = false;
if(StringUtils.isNotEmpty(isExecuteOnce) && "true".equals(isExecuteOnce)){
executeOnce = true;
}
SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd");
LocalDateTime now = new Timestamp(simpleDateFormat1.parse(newYnrTime).getTime()).toLocalDateTime();
//开始时间 2018-10-17 11:30:39
//结束时间 2019-12-31 10:36:34
//相差440天
for (int i = 0; i < 500; i++) {
String startTime = now.minusDays(i+1).format(DateTimeFormatter.ISO_DATE);
String endTime = now.minusDays(i).format(DateTimeFormatter.ISO_DATE);
Stopwatch callRStopwatch = Stopwatch.createStarted();
String CALL_SQL = "select transaction_id, uuid, url_type, code, time_created " +
" from transaction_log t where t.time_created >= '" + startTime + "' and t.time_created < '" + endTime + "'";
List<TransactionLogPO> queryResult = riskDatasourceJdbcTemplate.query(CALL_SQL, new BeanPropertyRowMapper<>(TransactionLogPO.class));
log.info("checkTransactionLogCF检测重复transaction_log查询数据结束, startTime: {} , endTime: {} , size: {} , sql: {} , 耗时: {} ", startTime, endTime, CollectionUtils.isEmpty(queryResult) ? 0 : queryResult.size(), CALL_SQL, callRStopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
Map<String, Integer> callRecord1Map = new HashMap<>();
if (CollectionUtils.isNotEmpty(queryResult)) {
Stopwatch callStopwatch = Stopwatch.createStarted();
for (int call = 0; call < queryResult.size(); call++) {
TransactionLogPO callRecord1 = queryResult.get(call);
String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(callRecord1.getTimeCreated());
String key = new StringBuffer(callRecord1.getTransactionId()).append(",")
.append(StringUtils.isNotBlank(callRecord1.getUuid()) ? callRecord1.getUuid() : "").append(",")
.append(callRecord1.getUrlType()).append(",")
.append(callRecord1.getCode()).append(",")
.append(format).toString();
if(callRecord1Map.containsKey(key)){
callRecord1Map.put(key, callRecord1Map.get(key).intValue()+1);
}else{
callRecord1Map.put(key, 1);
}
}
log.info("checkTransactionLogCF检测重复transaction组装数据完成, startTime: {} , 查询List大小: {} , 组装后Map大小: {} , 耗时: {} ", startTime, queryResult.size(), callRecord1Map.size(), callStopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
Stopwatch delStopwatch = Stopwatch.createStarted();
Iterator<Map.Entry<String, Integer>> iterator = callRecord1Map.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, Integer> next = iterator.next();
String key = next.getKey();
Integer value = next.getValue();
if (value!=null && value.intValue() >1 ) {
log.info("checkTransactionLogCF检测重复发现有重复数据, startTime: {} , 重复次数value: {} , key: {} ", startTime, value, key);
}else{
iterator.remove();
}
}
log.info("checkTransactionLogCF检测重复数据结束, startTime: {} , 查询List大小: {} , 过滤后transaction Map大小: {} , 耗时: {} ", startTime, queryResult.size(), callRecord1Map.size(), delStopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
}
if(executeOnce){
log.info("checkTransactionLogCF检测重复一天数据完成, newYnrTime: {} , isExecuteOnce: {} , startTime: {} , endTime: {} ,",newYnrTime, isExecuteOnce, startTime, endTime);
break;
}
}
log.info("----checkTransactionLogCF---All检测重复数据结束----");
} catch (Exception e) {
log.error("checkTransactionLogCF检测重复数据异常", e);
}
}
@Async
public void checkCallRecordCFByTransactionLog(String newYnrTime, String isExecuteOnce) {//yyyy-MM-dd
try {
boolean executeOnce = false;
if(StringUtils.isNotEmpty(isExecuteOnce) && "true".equals(isExecuteOnce)){
executeOnce = true;
}
SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd");
LocalDateTime now = new Timestamp(simpleDateFormat1.parse(newYnrTime).getTime()).toLocalDateTime();
//开始时间 2018-10-17 11:30:39
//结束时间 2019-12-31 10:36:34
//相差440天
for (int i = 0; i < 500; i++) {
String startTime = now.minusDays(i+1).format(DateTimeFormatter.ISO_DATE);
String endTime = now.minusDays(i).format(DateTimeFormatter.ISO_DATE);
String TRANSACTION_SQL = "select transaction_id, uuid, url_type, code, time_created " +
" from transaction_log where time_created >= '" + startTime + "' and time_created < '" + endTime + "'";
Stopwatch queryStopwatch = Stopwatch.createStarted();
List<TransactionLogPO> transactionLogPOList = riskDatasourceJdbcTemplate.query(TRANSACTION_SQL, new BeanPropertyRowMapper<>(TransactionLogPO.class));
log.info("transactionLog查询数据结束, startTime: {} , endTime: {} , size: {} , sql: {} , 耗时: {} ", startTime, endTime, CollectionUtils.isEmpty(transactionLogPOList) ? 0 : transactionLogPOList.size(), TRANSACTION_SQL, queryStopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
if (CollectionUtils.isEmpty(transactionLogPOList)) {
log.info("查询数据为空跳过, startTime: {} , endTime: {} ",startTime, endTime);
continue;
}
Map<String, TransactionLogPO> transactionLogPOMap = new HashMap<>();
Stopwatch stopwatch = Stopwatch.createStarted();
for (int tran = 0; tran < transactionLogPOList.size(); tran++) {
TransactionLogPO transactionLogPO = transactionLogPOList.get(tran);
String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(transactionLogPO.getTimeCreated());
String key = new StringBuffer(transactionLogPO.getTransactionId()).append(",")
.append(StringUtils.isNotBlank(transactionLogPO.getUuid()) ? transactionLogPO.getUuid() : "").append(",")
.append(transactionLogPO.getUrlType()).append(",")
.append(transactionLogPO.getCode()).append(",")
.append(format).toString();
transactionLogPOMap.put(key, transactionLogPO);
}
log.info("transactionLog组装数据完成, startTime: {} , 查询大小: {} , 组装后大小: {} , 耗时: {} ", startTime, transactionLogPOList.size(), transactionLogPOMap.size(), stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
Stopwatch callRStopwatch = Stopwatch.createStarted();
String CALL_SQL = "select transaction_id, uuid, url_type, code, created_at " +
" from call_record where created_at >= '" + startTime + "' and created_at < '" + endTime + "' order by created_at desc;";
List<CallRecord1> queryResult = tidbRiskJdbcTemplate.query(CALL_SQL, new BeanPropertyRowMapper<>(CallRecord1.class));
log.info("callRecord查询数据结束, startTime: {} , endTime: {} , size: {} , sql: {} , 耗时: {} ", startTime, endTime, CollectionUtils.isEmpty(queryResult) ? 0 : queryResult.size(), CALL_SQL, callRStopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
Map<String, CallRecord1> callRecord1Map = new HashMap<>();
if (CollectionUtils.isNotEmpty(queryResult)) {
Stopwatch callStopwatch = Stopwatch.createStarted();
for (int call = 0; call < queryResult.size(); call++) {
CallRecord1 callRecord1 = queryResult.get(call);
String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(callRecord1.getCreated_at().getTime()));
String key = new StringBuffer(callRecord1.getTransactionId()).append(",")
.append(StringUtils.isNotBlank(callRecord1.getUuid()) ? callRecord1.getUuid() : "").append(",")
.append(callRecord1.getUrlType()).append(",")
.append(callRecord1.getCode()).append(",")
.append(format).toString();
callRecord1Map.put(key, callRecord1);
}
log.info("callRecord组装数据完成, startTime: {} , 查询大小: {} , 组装后大小: {} , 耗时: {} ", startTime, queryResult.size(), callRecord1Map.size(), callStopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
Stopwatch delStopwatch = Stopwatch.createStarted();
Iterator<Map.Entry<String, TransactionLogPO>> iterator = transactionLogPOMap.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, TransactionLogPO> next = iterator.next();
String key = next.getKey();
if (callRecord1Map.containsKey(key)) {
iterator.remove();
}
}
log.info("去重组装数据完成, startTime: {} , callRecord查询大小: {} , 组装后transactionLogPOMap大小: {} , 耗时: {} ", startTime, queryResult.size(), transactionLogPOMap.size(), delStopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
}
if (transactionLogPOMap.size()>0) {
Stopwatch stopwatch1222 = Stopwatch.createStarted();
AtomicInteger countNum = new AtomicInteger();
transactionLogPOMap.forEach((k, v)->{
countNum.getAndIncrement();
log.info("检测transactionLogPOMap不为空, startTime: {} , ST: {} , mapkey: {} ",startTime, countNum.get(), k);
});
log.info("一天数据插入完成, startTime: {} , countNum: {} , Map大小: {} , 耗时: {} ",startTime, countNum.get(), transactionLogPOMap.size(), stopwatch1222.stop().elapsed(TimeUnit.MILLISECONDS));
}else{
log.info("一天数据插入完成, startTime: {} , transactionLogPOMap size is Empty!",startTime);
}
if(executeOnce){
log.info("一天数据插入完成, newYnrTime: {} , isExecuteOnce: {} , startTime: {} , endTime: {} ,",newYnrTime, isExecuteOnce, startTime, endTime);
break;
}
}
log.info("----All清洗数据结束----");
} catch (Exception e) {
log.error("清洗数据异常", e);
}
}
@Async
public void checkCallRecordCFByTransactionLog2(String newYnrTime, String isExecuteOnce) {//yyyy-MM-dd
try {
boolean executeOnce = false;
if(StringUtils.isNotEmpty(isExecuteOnce) && "true".equals(isExecuteOnce)){
executeOnce = true;
}
SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd");
LocalDateTime now = new Timestamp(simpleDateFormat1.parse(newYnrTime).getTime()).toLocalDateTime();
//开始时间 2018-10-17 11:30:39
//结束时间 2019-12-31 10:36:34
//相差440天
for (int i = 0; i < 500; i++) {
String startTime = now.minusDays(i+1).format(DateTimeFormatter.ISO_DATE);
String endTime = now.minusDays(i).format(DateTimeFormatter.ISO_DATE);
String TRANSACTION_SQL = "select transaction_id, uuid, url_type, code, time_created " +
" from transaction_log where time_created >= '" + startTime + "' and time_created < '" + endTime + "'";
Stopwatch queryStopwatch = Stopwatch.createStarted();
List<TransactionLogPO> transactionLogPOList = riskDatasourceJdbcTemplate.query(TRANSACTION_SQL, new BeanPropertyRowMapper<>(TransactionLogPO.class));
log.info("transactionLog查询数据结束CCFByT, startTime: {} , endTime: {} , size: {} , 耗时: {} ", startTime, endTime, CollectionUtils.isEmpty(transactionLogPOList) ? 0 : transactionLogPOList.size(), queryStopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
if (CollectionUtils.isEmpty(transactionLogPOList)) {
log.info("查询数据为空跳过CCFByT, startTime: {} , endTime: {} ",startTime, endTime);
continue;
}
Map<String, TransactionLogPO> transactionLogPOMap = new HashMap<>();
Stopwatch stopwatch = Stopwatch.createStarted();
for (int tran = 0; tran < transactionLogPOList.size(); tran++) {
TransactionLogPO transactionLogPO = transactionLogPOList.get(tran);
String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(transactionLogPO.getTimeCreated());
String key = new StringBuffer(transactionLogPO.getTransactionId()).append(",")
.append(StringUtils.isNotBlank(transactionLogPO.getUuid()) ? transactionLogPO.getUuid() : "").append(",")
.append(transactionLogPO.getUrlType()).append(",")
.append(transactionLogPO.getCode()).append(",")
.append(format).toString();
transactionLogPOMap.put(key, transactionLogPO);
}
log.info("transactionLog REMOVE数据完成CCFByT, startTime: {} , 查询大小: {} , 组装后大小: {} , 耗时: {} ", startTime, transactionLogPOList.size(), transactionLogPOMap.size(), stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
Stopwatch callRStopwatch = Stopwatch.createStarted();
String CALL_SQL = "select transaction_id, uuid, url_type, code, created_at " +
" from call_record where created_at >= '" + startTime + "' and created_at < '" + endTime + "' order by created_at desc;";
List<CallRecord1> queryResult = tidbRiskJdbcTemplate.query(CALL_SQL, new BeanPropertyRowMapper<>(CallRecord1.class));
log.info("callRecord查询数据结束CCFByT, startTime: {} , endTime: {} , size: {} , 耗时: {} ", startTime, endTime, CollectionUtils.isEmpty(queryResult) ? 0 : queryResult.size(), callRStopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
Map<String, CallRecord1> callRecord1Map = new HashMap<>();
if (CollectionUtils.isNotEmpty(queryResult)) {
Stopwatch callStopwatch = Stopwatch.createStarted();
for (int call = 0; call < queryResult.size(); call++) {
CallRecord1 callRecord1 = queryResult.get(call);
String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(callRecord1.getCreated_at().getTime()));
String key = new StringBuffer(callRecord1.getTransactionId()).append(",")
.append(StringUtils.isNotBlank(callRecord1.getUuid()) ? callRecord1.getUuid() : "").append(",")
.append(callRecord1.getUrlType()).append(",")
.append(callRecord1.getCode()).append(",")
.append(format).toString();
callRecord1Map.put(key, callRecord1);
}
log.info("callRecord组装数据完成CCFByT, startTime: {} , 查询大小: {} , 组装后大小: {} , 耗时: {} ", startTime, queryResult.size(), callRecord1Map.size(), callStopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
Stopwatch delStopwatch = Stopwatch.createStarted();
Iterator<Map.Entry<String, TransactionLogPO>> iterator = transactionLogPOMap.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, TransactionLogPO> next = iterator.next();
String key = next.getKey();
if (callRecord1Map.containsKey(key)) {
iterator.remove();
callRecord1Map.remove(key);
}
}
log.info("去相同据完成CCFByT, startTime: {} , callRecord1Map大小: {} , transactionLogPOMap大小: {} , 耗时: {} ", startTime, callRecord1Map.size(), transactionLogPOMap.size(), delStopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
}
String path = "/home/quant_group/baihang-report/logs/transaction_call/";
if (transactionLogPOMap.size()>0) {
Stopwatch stopwatch1222 = Stopwatch.createStarted();
AtomicInteger countNum = new AtomicInteger();
transactionLogPOMap.forEach((k, v)->{
countNum.getAndIncrement();
try {
FileUtils.write(new File(path +"transaction_start_"+startTime+".txt"), k+"\r\n", "UTF-8", true);
} catch (IOException e) {
e.printStackTrace();
}
});
log.info("写入transaction_log多出的数据结束CCFByT, startTime: {} , countNum: {} , Map大小: {} , 耗时: {} ",startTime, countNum.get(), transactionLogPOMap.size(), stopwatch1222.stop().elapsed(TimeUnit.MILLISECONDS));
}else{
log.info("写入transaction_log多出的数据结束CCFByT, startTime: {} , transactionLogPOMap size is Empty!",startTime);
}
if (callRecord1Map.size()>0) {
Stopwatch stopwatch3 = Stopwatch.createStarted();
AtomicInteger countNum3 = new AtomicInteger();
callRecord1Map.forEach((key, v)->{
countNum3.getAndIncrement();
try {
FileUtils.write(new File(path +"callRecord_start_"+startTime+".txt"), key+"\r\n", "UTF-8", true);
} catch (IOException e) {
e.printStackTrace();
}
});
log.info("写入call_record多出的数据结束CCFByT, startTime: {} , countNum: {} , Map大小: {} , 耗时: {} ",startTime, countNum3.get(), callRecord1Map.size(), stopwatch3.stop().elapsed(TimeUnit.MILLISECONDS));
}else{
log.info("写入call_record多出的数据结束CCFByT, startTime: {} , transactionLogPOMap size is Empty!",startTime);
}
if(executeOnce){
log.info("比较数据完成CCFByT, newYnrTime: {} , isExecuteOnce: {} , startTime: {} , endTime: {} ,",newYnrTime, isExecuteOnce, startTime, endTime);
break;
}
}
log.info("----All比较数据完成CCFByT----");
} catch (Exception e) {
log.error("比较数据异常CCFByT", e);
}
}
@Async
public void deleteTidbCallRecordCF(String cfFileName, String bakFileName) {
try {
List<String> tidbCallRecordCFList = ReadOrWriteTxt.readTxtList(cfFileName);
log.info("读取文件cfFileName: {} , tidbCallRecordCFList大小:{} ",cfFileName,tidbCallRecordCFList.size());
for (int i = 0; i < tidbCallRecordCFList.size(); i++) {
//ee86810a076d45d58a5d87d7cfc60e8f,032f14da-b905-4a1c-9c38-9db3dd0b1304,ZhiChengAFuAntiFraud,1004,2019-12-24 21:48:53
log.info("删除重复数据ST:"+i);
String[] arry = tidbCallRecordCFList.get(i).trim().split(",");
Stopwatch callRStopwatch = Stopwatch.createStarted();
String DELETE_CALL_SQL = "delete from call_record where id=##ID## AND transaction_id ='##TRANSACTION_ID##';";
String CALL_SQL = "select * from call_record where transaction_id ='" + arry[0] + "' and uuid ='" + arry[1] +"'"
+" and url_type ='" + arry[2] + "' and code ='" +arry[3]+ "'; ";
List<CallRecord3> queryResult = tidbRiskJdbcTemplate.query(CALL_SQL, new BeanPropertyRowMapper<>(CallRecord3.class));
int size = (queryResult!=null ? queryResult.size(): 0);
if(queryResult!=null && queryResult.size()==2){
CallRecord3 bean1 = queryResult.get(0);
CallRecord3 bean2 = queryResult.get(1);
int second = Math.abs(bean1.getCreatedAt().compareTo(bean2.getCreatedAt()));
if(second <=3){
if(StringUtils.isEmpty(bean1.getRequestUrl()) && StringUtils.isEmpty(bean1.getChannelId())
&& ( StringUtils.isNotEmpty(bean2.getRequestUrl()) || StringUtils.isNotEmpty(bean2.getChannelId())
|| StringUtils.isNotEmpty(bean2.getChannelType())
)){
String sql = DELETE_CALL_SQL.replace("##ID##", ""+bean1.getId());
sql = sql.replace("##TRANSACTION_ID##", bean1.getTransactionId());
try {
FileUtils.write(new File(bakFileName), JSON.toJSONString(bean1)+"\r\n", "UTF-8", true);
int update =tidbRiskJdbcTemplate.update(sql);
log.info("删除bean1成功, sql: {} ,update: {} ",sql,update);
} catch (Exception e) {
log.error("删除bean1数据是不, sql: {} ",sql, e);
}
}else if(StringUtils.isEmpty(bean2.getRequestUrl()) && StringUtils.isEmpty(bean2.getChannelId())
&& (StringUtils.isNotEmpty(bean1.getRequestUrl()) || StringUtils.isNotEmpty(bean1.getChannelId())
|| StringUtils.isNotEmpty(bean1.getChannelType())
)){
String sql = DELETE_CALL_SQL.replace("##ID##", ""+bean2.getId());
sql = sql.replace("##TRANSACTION_ID##", bean2.getTransactionId());
try {
FileUtils.write(new File(bakFileName), JSON.toJSONString(bean2)+"\r\n", "UTF-8", true);
int update = tidbRiskJdbcTemplate.update(sql);
log.info("删除bean2成功, sql: {} , update: {} ",sql,update);
} catch (Exception e) {
log.error("删除bean2数据是不, sql: {} ",sql, e);
}
}else {
log.info("查询call_record表,发现其他情况, param: {} , List: {} ", tidbCallRecordCFList.get(i), (queryResult!=null ? JSON.toJSONString(queryResult): "null") );
}
}else{
log.info("查询call_record表,相差时间大于3秒, param: {} , List: {} ", tidbCallRecordCFList.get(i), (queryResult!=null ? JSON.toJSONString(queryResult): "null") );
}
}else{
log.info("查询call_record表,list大小不为2, param: {} , size: {} , List: {} ", tidbCallRecordCFList.get(i), size, (queryResult!=null ? JSON.toJSONString(queryResult): "null") );
}
}
log.info("----删除bean数据完成----");
} catch (Exception e) {
log.error("删除bean数据异常", e);
}
}
}
package cn.quantgroup.report.service.manualTool;
import cn.quantgroup.report.config.aop.DistributedLock;
import cn.quantgroup.report.config.aop.Monitor;
import cn.quantgroup.report.config.aop.MonitorType;
import cn.quantgroup.report.domain.baihang.*;
import cn.quantgroup.report.mapper.baihang.LoanInfoMapper;
import cn.quantgroup.report.mapper.master.ApplyLoanInfoDbMapper;
import cn.quantgroup.report.mapper.master.LoanInfoDbMapper;
import cn.quantgroup.report.mapper.master.RepaymentLoanInfoDbMapper;
import cn.quantgroup.report.response.GlobalResponse;
import cn.quantgroup.report.service.CommonSuperService;
import cn.quantgroup.report.service.baihang.util.TuoMinUtils;
import cn.quantgroup.report.utils.ReadOrWriteTxt;
import cn.quantgroup.report.utils.commonutil.AesCrypto;
import cn.quantgroup.report.utils.commonutil.Base64;
import cn.quantgroup.report.utils.commonutil.MD5Util;
import cn.quantgroup.report.utils.commonutil.RSAEncrypt;
import cn.quantgroup.report.utils.http.HttpRequestUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Async;
......@@ -55,17 +44,6 @@ public class ManualToolService implements CommonSuperService {
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
@Autowired
private RepaymentLoanInfoDbMapper repaymentLoanInfoDbMapper;
@Autowired
private LoanInfoMapper loanInfoMapper;
@Autowired
private ApplyLoanInfoDbMapper applyLoanInfoDbMapper;
@Autowired
public LoanInfoDbMapper loanInfoDbMapper;
@Autowired
private RedisTemplate<String,String> redisTemplate;
......@@ -88,418 +66,7 @@ public class ManualToolService implements CommonSuperService {
RSA_PRIVATEKEY = readRSAPrivateKey("/manualTool/rsa_private_key.pem");
}
@Monitor({MonitorType.EXCEPTION, MonitorType.FEE, MonitorType.HIT, MonitorType.RESULT})
@DistributedLock
public Map<String,String> sendBaiHangData(String p1, String p2, String p3, String p4, String p5, String secretKey, String isSend,String errorCode, String isProduct, String sendIncludeType) {
Map<String,String> resultMap = new HashMap<>();
StringBuffer resultMsg = new StringBuffer();
log.info("ManualToolService.sendBaiHangData Start>>>>>>");
String base_path = "/home/quant_group/baihang-report/data";
String base_url = "http://172.21.10.8:9021/zhudai/re_send";
String A1_file ="/baihang/A1/data.txt";
String D2_file ="/baihang/D2/data.txt";
String D3_file ="/baihang/D3/data.txt";
String A1_url = "/manual/buquan/mainApplySend";
String D2_url = "/manual/buquan/mainLoanInfoSend";
String D3_url = "/manual/buquan/mainRepaymentLoanInfo";
String cNameWhiteListFile = base_path+"/baihang/changedName_loanId_whiteList.txt";
if (StringUtils.isBlank(RSA_PRIVATEKEY)) {
resultMap.put("error","参数错误1");
return resultMap;
}
if (StringUtils.isBlank(secretKey)) {
resultMap.put("error","参数错误2");
return resultMap;
}
if (StringUtils.isAnyBlank(p1, p2, p3)) {
resultMap.put("error","参数错误3");
return resultMap;
}
try {
String aes_key = RSAEncrypt.decrypt(secretKey, RSA_PRIVATEKEY);//"!QAZ@WSX3edc4rfv"
//p1:host, p2:name, p3:pass, p4:forword, p5:date, p6:根路径
//p1,p2,p3 做AES和base64加密
//p1为127.0.0.1时p4必须是ip,且和172.21.10.8的MDd一致校验
p1 = AesCrypto.decrypt(Base64.decode(p1.trim()), aes_key).trim();
if (!(MD5Util.verify48Md5(p1, P1_48MD5_01) || MD5Util.verify48Md5(p1, P1_48MD5_02))) {
resultMap.put("error","参数错误4");
return resultMap;
}
p2 = AesCrypto.decrypt(Base64.decode(p2.trim()), aes_key).trim();
if (!MD5Util.verify48Md5(p2, P2_48MD5)) {
resultMap.put("error","参数错误5");
return resultMap;
}
p3 = AesCrypto.decrypt(Base64.decode(p3.trim()), aes_key).trim();
if (!MD5Util.verify48Md5(p3, P3_48MD5)) {
resultMap.put("error","参数错误6");
return resultMap;
}
//不是127.0.0.1时,p4不能为空
//if (MD5Util.verify48Md5(p1, P1_48MD5_01)) {
if (StringUtils.isBlank(p4)) {
resultMap.put("error","参数错误7");
return resultMap;
} else {
p4 = AesCrypto.decrypt(Base64.decode(p4.trim()), aes_key).trim();
}
//}
} catch (Exception e) {
log.error("参数解析错误!", e);
resultMap.put("error","参数错误8");
return resultMap;
}
if (StringUtils.isEmpty(p5)) {
p5 = sdf.format(System.currentTimeMillis());
}
boolean httpSend = false;
if (StringUtils.isNotEmpty(isSend) && "true".equals(isSend)) {
httpSend = true;
}
boolean isProduct2 = false;
String char_n = "\n";
if (StringUtils.isNotEmpty(isProduct) && "true".equals(isProduct)) {
isProduct2 = true;
char_n = "\r\n";
}
String sendInclude_type = "A1,D2,D3";
if(StringUtils.isNotBlank(sendIncludeType)){
sendInclude_type = sendIncludeType;
}
if (StringUtils.isEmpty(errorCode)) {
/*"errorCode":"D2_009"
"errorCode":"D3_035"
"errorCode":"D3_036"
"errorCode":"D3_041"
"errorCode":"G_001"*/
errorCode = "D3_035";
}
//还款信息D3,opCode:A>>>M,多条信息就回车存多行,中间不用逗号
StringBuffer json_hk_D3 = new StringBuffer();
//放款信息D2,多条信息就回车存多行,中间不用逗号
StringBuffer json_fk_D2 = new StringBuffer();
//A1申请
StringBuffer json_sq_A1 = new StringBuffer();
try {
if (initShellConnect(executeCommand, p1, p2, p3)) {
//获取远程日志中reqID
String jsaonResult = getReqIdByRemoteLog(executeCommand, p4, p5, base_path);
if (StringUtils.isNotBlank(jsaonResult)) {
List<String> reqIDList = new ArrayList<>();
List<String> loanIdList = new ArrayList<String>();
//2020.05.22 第一次报完D2后,修改了姓名,导致D3中姓名和D2中不一致,百行回复这样的D3数据不用补报修复
Map<String, String> cNameLoanIdMap = new HashMap<>();
try{
List<String> changedNameList = ReadOrWriteTxt.readTxtList(cNameWhiteListFile);
if(changedNameList!=null && changedNameList.size()>0){
for (String context : changedNameList){
//LoanId|历史姓名|修改后姓名
String value = context.trim();
cNameLoanIdMap.put(value.split(",")[0], value);
}
}
}catch (Exception e){
log.error("读取报送D3时修改过姓名的用户loanId白名单异常!", e);
}
JSONArray jsonArray = JSONArray.parseArray(jsaonResult);
resultMsg.append("getReqIdByRemoteLog size=" + (jsonArray!=null ? jsonArray.size() : "null") );
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObj = jsonArray.getJSONObject(i);
boolean flag = false;
try{
JSONArray errorDetailArry = jsonObj.getJSONArray("errorDetail");
if(errorDetailArry!=null && errorDetailArry.size()>0){
JSONObject error = errorDetailArry.getJSONObject(0);
if(error.get("errorCode")!=null && errorCode.contains(error.getString("errorCode"))){ //D3_035,D3_036
flag = true;
reqIDList.add(jsonObj.getString("reqID"));
}
}
}catch (Exception e){
log.error("deal with reqIdByRemoteLog error!",e);
}finally {
if(!flag){
resultMsg.append(" |##OTHER ERRORCODE:" + jsonObj.toJSONString()+"##");
log.info("ManualToolService OTHER ERRORCODE:" + jsonObj.toJSONString());
}
}
}
resultMsg.append(" |reqIDList size=" + reqIDList.size() );
if (reqIDList.size() > 0) { //还款D3
String[] recordIdArray = reqIDList.toArray(new String[reqIDList.size()]);
log.info("RepaymentLoanInfoDbMapper getReqIdByRemoteLog reqID to D3:" + JSON.toJSONString(recordIdArray));
List<RepaymentLoanInfoLog> tmpLogList = repaymentLoanInfoDbMapper.findByD3RecordId(recordIdArray);
int cNameSize = 0;
boolean lengthIs0 = (json_hk_D3.length()==0);
//List<RepaymentInfoZhuDai> repaymentLoanInfoList = new ArrayList<>(tmpLogList.size());
for (RepaymentLoanInfoLog logBean : tmpLogList) {
//如果不在白名单里
if(!cNameLoanIdMap.containsKey(logBean.getLoanId())){
//查询d2使用
loanIdList.add(logBean.getLoanId());
RepaymentInfoZhuDai voBean = new RepaymentInfoZhuDai();
//添加了忽略username属性的赋值
//BeanUtils.copyProperties(book,book2,"username");
BeanUtils.copyProperties(logBean, voBean);
voBean.setOpCode("M");
if (voBean.getOverdueStatus() == null) {
voBean.setOverdueStatus("");
}
//repaymentLoanInfoList.add(voBean);
if(lengthIs0){
lengthIs0 = false;
json_hk_D3.append(JSONObject.toJSONString(voBean));
}else{
json_hk_D3.append(char_n);
json_hk_D3.append(JSONObject.toJSONString(voBean));
}
}else{
cNameSize++;
log.info("用户报送D3时修改姓名, 跳过补报, WhiteList: {} ", cNameLoanIdMap.get(logBean.getLoanId()));
}
}
resultMsg.append(" |D3 List size=" + tmpLogList.size());
resultMsg.append(" |D3 修改姓名跳过=" + cNameSize);
/* boolean lengthIs0 = (json_hk_D3.length()==0);
for (RepaymentInfoZhuDai vo : repaymentLoanInfoList){
if(lengthIs0){
lengthIs0 = false;
json_hk_D3.append(JSONObject.toJSONString(vo));
}else{
json_hk_D3.append(char_n);
json_hk_D3.append(JSONObject.toJSONString(vo));
}
}*/
}
if (loanIdList.size() > 0) { //放款D2 及 申请A1
List<LoanInfoZhuDai> loanInfoVoList = new ArrayList<LoanInfoZhuDai>();
String[] orderNoArray = loanIdList.toArray(new String[loanIdList.size()]);
List<String> loanApplicationHistoryIdList = loanInfoMapper.findHistoryIdByOrderNo(orderNoArray);
//查询D2
for (String historyId : loanApplicationHistoryIdList) {
LoanInfoZhuDai loanInfozd_tmp = loanInfoMapper.findLoanInfoD2ByHistoryId(historyId);
//TargetRepayDateList报送时会查
loanInfoVoList.add(loanInfozd_tmp);
}
resultMsg.append(" |D2 List size=" + loanInfoVoList.size());
if (loanInfoVoList.size() > 0) {
boolean lengthIs0 = (json_fk_D2.length()==0);
for (LoanInfoZhuDai vo : loanInfoVoList){
if(lengthIs0){
lengthIs0 = false;
json_fk_D2.append(JSONObject.toJSONString(vo));
}else{
json_fk_D2.append(char_n);
json_fk_D2.append(JSONObject.toJSONString(vo));
}
}
}
//查询A1
if(sendInclude_type.contentEquals("A1")){
List<ApplyLoanInfoZhuDai> applyInfoList = new ArrayList<>();
for (String historyId : loanApplicationHistoryIdList) {
ApplyLoanInfoZhuDai applyInfo = applyLoanInfoDbMapper.findApplyInfoA1ByHistoryId(historyId);
//邮箱有错误的就不传
if(!TuoMinUtils.checkEmail(applyInfo.getEmailAddress())){
applyInfo.setEmailAddress(null);
}
applyInfoList.add(applyInfo);
}
if(applyInfoList.size()>0){
boolean lengthIs0 = (json_sq_A1.length()==0);
for (ApplyLoanInfoZhuDai vo : applyInfoList){
if(lengthIs0){
lengthIs0 = false;
json_sq_A1.append(JSONObject.toJSONString(vo));
}else{
json_sq_A1.append(char_n);
json_sq_A1.append(JSONObject.toJSONString(vo));
}
}
resultMsg.append(" |A1 List size=" + applyInfoList.size());
}
}
}
resultMsg.append(" >>>> ");
//------------处理--------------
if (StringUtils.isNotBlank(json_sq_A1)) {
log.info("json_sq_A1 DATA:" + json_sq_A1.toString());
//A1的data.txt写入
if(isProduct2){
ReadOrWriteTxt.writeTxt(base_path + A1_file, json_sq_A1.toString());
log.info("RepaymentLoanInfoDbMapper.sendBaiHangData writ remote file (product By file)...baihang/A1/data.txt END.");
resultMsg.append(" |write A1 end.(product By file)");
}else{
String cmd_res = writeJsonFileOnRemote(executeCommand, base_path + A1_url, json_sq_A1.toString());
resultMsg.append("| write A1 end.(local By shell)");
}
resultMap.put("json_sq_A1", "true");
//掉A1手动报送接口
if (httpSend) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("key", "b5140fb2-2c85-4b5a-abcf-3e97528014db");
String http_res = HttpRequestUtil.mySelfDoGet(base_url + "/mainLoanInfoSend", params);
log.info("RepaymentLoanInfoDbMapper.sendBaiHangData http request A1>>>mainLoanInfoSend END,r:" + http_res);
resultMsg.append("|");
resultMsg.append(http_res);
}
}else{
resultMsg.append(" |申请A1 json_sq_A1 isEmpty.");
}
if (StringUtils.isNotBlank(json_fk_D2)) {
log.info("json_fk_D2 DATA:" + json_fk_D2.toString());
//D2的data.txt写入
if(isProduct2){
ReadOrWriteTxt.writeTxt(base_path + D2_file,json_fk_D2.toString());
log.info("RepaymentLoanInfoDbMapper.sendBaiHangData writ remote file (product By file)...baihang/D2/data.txt END.");
resultMsg.append(" |write D2 end.(product By file)");
}else{
String cmd_res = writeJsonFileOnRemote(executeCommand, base_path + D2_url, json_fk_D2.toString());
log.info("RepaymentLoanInfoDbMapper.sendBaiHangData writ remote file (local By shell)...baihang/D2/data.txt END,r:" + cmd_res);
resultMsg.append(" |write D2 end.(local By shell)");
}
resultMap.put("json_fk_D2", "true");
//掉D2手动报送接口
if (httpSend) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("key", "b5140fb2-2c85-4b5a-abcf-3e97528014db");
String http_res = HttpRequestUtil.mySelfDoGet(base_url + "/mainLoanInfoSend", params);
log.info("RepaymentLoanInfoDbMapper.sendBaiHangData http request D2>>>mainLoanInfoSend END,r:" + http_res);
resultMsg.append(" |");
resultMsg.append(http_res);
}
}else{
resultMsg.append(" |放款D2 json_fk_D2 isEmpty.");
}
if (StringUtils.isNotBlank(json_hk_D3)) {
log.info("json_hk_D3 DATA:" + json_hk_D3.toString());
//D3的data.txt写入
if(isProduct2){
ReadOrWriteTxt.writeTxt(base_path + D3_file, json_hk_D3.toString());
log.info("RepaymentLoanInfoDbMapper.sendBaiHangData writ remote file (product By file)...baihang/D3/data.txt END.");
resultMsg.append(" |write D3 end.(product By file)");
}else{
String cmd_res = writeJsonFileOnRemote(executeCommand, base_path + D3_url, json_hk_D3.toString());
log.info("RepaymentLoanInfoDbMapper.sendBaiHangData writ remote file (local By shell)...baihang/D3/data.txt END,r:" + cmd_res);
resultMsg.append(" |write D3 end.(local By shell)");
}
resultMap.put("json_hk_D3", "true");
//掉D3手动报送接口
if (httpSend) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("key", "b5140fb2-2c85-4b5a-abcf-3e97528014db");
String http_res = HttpRequestUtil.mySelfDoGet(base_url + "/mainRepaymentLoanInfo", params);
log.info("RepaymentLoanInfoDbMapper.sendBaiHangData http request D3>>>mainRepaymentLoanInfo END,r:" + http_res);
resultMsg.append(" |");
resultMsg.append(http_res);
}
}else {
resultMsg.append(" |还款D3 json_hk_D3 isEmpty.");
}
//退出登录
List<String> cmdList = new ArrayList<String>();
cmdList.add("echo '++CMD LAST++' \n\r");
cmdList.add("exit \n\r");
cmdList.add("exit \n\r");
executeCommand.execute(cmdList, false);
resultMap.put("success", resultMsg.toString());
return resultMap;
} else {
log.info("RepaymentLoanInfoDbMapper.getReqIdByRemoteLog redult isEmpty.");
resultMap.put("success","百行征信手动报送,获取日志为空");
resultMap.put("isEmpty","isEmpty");
boolean have_logFile = false;
try{
ArrayList<String> fileNameList = new ArrayList<>();
String logPath = base_path + "/" +p5;
getAllFileName(logPath, fileNameList);
if(fileNameList!=null && fileNameList.size()>0){
for (String name : fileNameList) {
log.info("目录: {} 下的文件包括: {}", logPath, name);
if(StringUtils.isNotEmpty(name) && name.endsWith(".log")
&& !name.endsWith("_logicerror.log") && !name.endsWith("_inputerror.log")){
have_logFile = true;
}
}
}
}catch (Exception e){
log.error("获取报送日志文件夹下文件异常, path: {} ", e);
}
if(!have_logFile){
resultMap.put("alarm","反馈日志主文件不存在,请注意确认");
}
return resultMap;
}
}
} catch (Exception e) {
log.error("ManualToolService.sendBaiHangData Error,", e);
resultMap.put("error", "百行征信手动报送异常"+e.getMessage());
return resultMap;
} finally {
if (executeCommand != null) {
executeCommand.ioclose();
executeCommand.closeChannelShell();
executeCommand = null;
}
try {
ShellUtils.LOCK.unlock();
} catch (IllegalMonitorStateException e) {
log.warn("锁已释放,无需重复释放." + e);
}
}
log.info("ManualToolService.sendBaiHangData All END<<<<<<");
resultMap.put("error","百行征信手动报送失败");
return resultMap;
}
/**
* 描述: 初始化 ShellUtils <br/>
......@@ -653,43 +220,6 @@ public class ManualToolService implements CommonSuperService {
@Monitor({MonitorType.EXCEPTION, MonitorType.FEE, MonitorType.HIT, MonitorType.RESULT})
@DistributedLock
public GlobalResponse buildLoanInfoD2(String jsonFile) {
StringBuffer resultMsg = new StringBuffer();
if(StringUtils.isEmpty(jsonFile)){
return new GlobalResponse("1000", "百行征信手动报送失败");
}
//jsonFile = "C:\\Users\\Administrator\\Desktop\\百行历史数据报送实时放款数据D2(历史百行征信报送).json";
String context = ReadOrWriteTxt.readTxt(jsonFile);
JSONObject jSONObject = JSON.parseObject(context);
JSONArray jsonArray = jSONObject.getJSONArray("RECORDS");
for (int i = 0; i < jsonArray.size() ; i++) {
JSONObject object = jsonArray.getJSONObject(i);
Object reqID = object.get("reqID");
if(reqID!=null){
List<String> list = loanInfoMapper.findTargetRepaymentDayList(reqID.toString());
if(list!=null && list.size()>0){
String[] strArry = list.toArray(new String[list.size()]);
object.put("targetRepayDateList",strArry);
}else{
object.put("targetRepayDateList",new String[0]);
}
}
}
String json_fk_D2 = JSONArray.toJSONString(jsonArray);
//json_fk_D2 = json_fk_D2.replace("[", "");
//json_fk_D2 = json_fk_D2.replace("]", "");
json_fk_D2 = json_fk_D2.replace("},", "}\n");
String writeName = jsonFile.substring(0,jsonFile.lastIndexOf("\\"))+"\\d2.txt";
ReadOrWriteTxt.writeTxt(writeName,json_fk_D2);
System.out.print("放款信息 D2 写入文件OK:"+writeName);
return new GlobalResponse("0", "放款信息 D2 写入文件OK:"+writeName);
}
public boolean checkSecretKey(String p3,String secretKey) {
......@@ -2000,200 +1530,7 @@ public class ManualToolService implements CommonSuperService {
System.out.println("build_key() D3 end.");
}
@Async
public void d2_saveLog(String d2JsonFileName,String reqIdFileName,String no_reqId_start, String isHaveRecordId) {
boolean haveReqID = false;
List<String> reqID_Str_List = null;
HashMap<String,String> reqID_Map = null;
try{
if(StringUtils.isNotEmpty(reqIdFileName)){
reqID_Str_List = ReadOrWriteTxt.readTxtList(reqIdFileName);
log.info("files reqID_Str_List size="+reqID_Str_List.size());
reqID_Map = new HashMap<>(reqID_Str_List.size());
String[] arry = null;
//oldReqID=30067778,newReqID=199bbec95c0b41178055f1c5164bd7fb
for(String str : reqID_Str_List){
if(str.length()<2){
continue;
}
arry = str.split("=");
reqID_Map.put(arry[2],arry[1].split(",")[0]);
}
haveReqID = true;
}
log.info("param haveReqID: {} , reqID_Str_List: {} , reqID_Map: {} ", haveReqID, (reqID_Str_List!=null ? reqID_Str_List.size() : "null"), (reqID_Map!=null ? reqID_Map.size() : "null"));
reqID_Str_List = null;
List<String> d2JsonList = ReadOrWriteTxt.readTxtList(d2JsonFileName);
log.info("files d2JsonList size="+d2JsonList.size());
int no_reqId = 0, saveCount=0;
if(StringUtils.isNotEmpty(no_reqId_start)){
no_reqId = Integer.parseInt(no_reqId_start);
}
boolean haveRecordId = false;
if(StringUtils.isNotEmpty(isHaveRecordId) && isHaveRecordId.equals("true")){
haveRecordId = true;
}
for(int i=0; i<d2JsonList.size(); i++){
String jsonStr = d2JsonList.get(i);
if(jsonStr.length()<30){
continue;
}
//LoanInfoZhuDaiVo loanInfo
JSONObject jsonObject = JSONObject.parseObject(jsonStr);
JSONObject business = jsonObject.getJSONObject("finTechAgencyBusiness");
FinTechAgencyBusinessZhuDai finTechAgencyBusiness = JSONObject.parseObject(business.toJSONString(), FinTechAgencyBusinessZhuDai.class);
LoanInfoZhuDai loanInfozd_tmp = JSONObject.parseObject(jsonStr, LoanInfoZhuDai.class);
loanInfozd_tmp.setInstitutionalFundingPartner(finTechAgencyBusiness.getInstitutionalFundingPartner());
loanInfozd_tmp.setInstitutionalFundingPartnerID(finTechAgencyBusiness.getInstitutionalFundingPartnerID());
loanInfozd_tmp.setRelationID(finTechAgencyBusiness.getRelationID());
loanInfozd_tmp.setInstitutionalFundingPartnerLoanID(finTechAgencyBusiness.getInstitutionalFundingPartnerLoanID());
loanInfozd_tmp.setOrderID(finTechAgencyBusiness.getOrderID());
loanInfozd_tmp.setPreCreditLimit(finTechAgencyBusiness.getPreCreditLimit());
if(!haveRecordId){
loanInfozd_tmp.setRecordId(loanInfozd_tmp.getReqID());
loanInfozd_tmp.setReqID(null);
}
if(haveReqID && reqID_Map.containsKey(loanInfozd_tmp.getRecordId())){
loanInfozd_tmp.setReqID(reqID_Map.get(loanInfozd_tmp.getRecordId()));
reqID_Map.remove(loanInfozd_tmp.getRecordId());
}
if(StringUtils.isEmpty(loanInfozd_tmp.getReqID())){
no_reqId++;
loanInfozd_tmp.setReqID("no_"+no_reqId);
}
try{
loanInfoDbMapper.saveLoanInfoRecordLog(loanInfozd_tmp);
saveCount++;
}catch(Exception e){
log.error("保存放款记录失败, DATA: {} ", jsonStr, e);
}
log.info("Build End:"+i);
}
log.info("All D2 LOG:保存放款记录结束, d2JsonList: {} , no_reqId: {} , saveCount: {} ",d2JsonList.size(),no_reqId,saveCount);
}catch (Exception e){
log.error("处理放款记录异常!", e);
}
}
@Async
public void d3_saveLog(String d3FilePath, String d3JsonFileNames, String reqIdLogName, String no_reqId_start, String isHaveRecordId) {
try{
boolean haveReqID = false;
List<String> reqID_Str_List = null;
HashMap<String,String> reqID_Map = null;
if(StringUtils.isNotEmpty(reqIdLogName)){
reqID_Str_List = ReadOrWriteTxt.readTxtList(reqIdLogName);
log.info("files reqID_Str_List size="+reqID_Str_List.size());
reqID_Map = new HashMap<>(reqID_Str_List.size());
String[] arry = null;
//oldReqID=30067778,newReqID=199bbec95c0b41178055f1c5164bd7fb
for(String str : reqID_Str_List){
if(str.length()<2){
continue;
}
arry = str.split("=");
reqID_Map.put(arry[2],arry[1].split(",")[0]);
}
haveReqID = true;
}
log.info("param haveReqID: {} , reqID_Str_List: {} , reqID_Map: {} ", haveReqID, (reqID_Str_List!=null ? reqID_Str_List.size() : "null"), (reqID_Map!=null ? reqID_Map.size() : "null"));
reqID_Str_List = null;
boolean haveRecordId = false;
if(StringUtils.isNotEmpty(isHaveRecordId) && isHaveRecordId.equals("true")){
haveRecordId = true;
}
int no_reqId = 0;
if(StringUtils.isNotEmpty(no_reqId_start)){
no_reqId = Integer.parseInt(no_reqId_start);
}
List<String> d3lineList = null;
String[] all_id3_fileNames = d3JsonFileNames.trim().split(",");
for(String fileName : all_id3_fileNames){
log.info(">>>>>>>>THE FILENAME START:"+fileName);
if(!d3FilePath.endsWith("/") && !d3FilePath.endsWith("\\")){
d3FilePath = d3FilePath + "/";
}
d3lineList = ReadOrWriteTxt.readTxtList(d3FilePath + fileName);
int saveCount = 0, tmp_not_recordId=0, listSize=d3lineList.size();
log.info(fileName+" lineList size:"+d3lineList.size());
RepaymentInfoZhuDai repaymentLoanInfo = null;
for(int i=0;i<d3lineList.size();i++){
try {
String d3JsonStr = d3lineList.get(i);
if(d3JsonStr.length()<30){//#singleLoanRepayInfo
continue;
}
repaymentLoanInfo = new Gson().fromJson(d3JsonStr, new TypeToken<RepaymentInfoZhuDai>(){}.getType());
if(!haveRecordId){
repaymentLoanInfo.setRecordId(repaymentLoanInfo.getReqID());
repaymentLoanInfo.setReqID(null);
}
if(haveReqID && reqID_Map.containsKey(repaymentLoanInfo.getRecordId())){
repaymentLoanInfo.setReqID(reqID_Map.get(repaymentLoanInfo.getRecordId()));
reqID_Map.remove(repaymentLoanInfo.getRecordId());
}
if(StringUtils.isEmpty(repaymentLoanInfo.getReqID())){
no_reqId++;
tmp_not_recordId++;
repaymentLoanInfo.setReqID("no_"+no_reqId);
}
try{
repaymentLoanInfoDbMapper.saveRepaymentLoanInfoLog(repaymentLoanInfo);
saveCount++;
}catch(Exception e){
log.error("保存还款数据记录失败, fileName: {} , DATA: {} ", fileName, d3JsonStr, e);
}
log.info("Build Save D3 End:"+i);
} catch (Exception e) {
log.error("保存还款数据处理异常, fileName: {} , DATA: {} ", fileName, d3lineList.get(i), e);
}
}
log.info(fileName+"<<<<<<保存还款数据记录结束, listSize: {} , saveCount: {} , tmp_not_recordId: {} ", listSize, saveCount, tmp_not_recordId);
d3lineList = null;
repaymentLoanInfo = null;
saveCount=0;tmp_not_recordId=0;listSize=0;
Thread.sleep(1500);
}
}catch (Exception e){
log.error("newD3ReplaceReqId 异常",e);
}
log.info("-----All 保存还款数据记录结束-----.");
}
public void deleteRedisKey(String key1, String key2, String key3) {
......
package cn.quantgroup.report.service.renhang;
import cn.quantgroup.report.domain.renhang.UserOcrVo;
import com.alibaba.fastjson.JSON;
import com.mysql.jdbc.PreparedStatement;
import lombok.extern.slf4j.Slf4j;
import java.sql.*;
import java.util.List;
import static cn.quantgroup.report.utils.RenHangHikDataSource.HIK_DATA_SOURCE_RENHANG;
@Slf4j
public class RenHangBatchExecuteJdbc {
private static void close(Connection conn, Statement st, ResultSet rs){
try {
if(rs!=null)
rs.close();
if(st!=null)
st.close();
if(conn!=null)
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
public static void batchInsertExecute(List<UserOcrVo> ocrInfoList){
String insert_sql = "INSERT INTO `user_ocr` (`uuid`, `address`, `birthday`, `citizen_id`, `gender`, `name`, `nation`, `agency`, `valid_date_begin`, `valid_date_end`, `created_at`, `updated_at`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
Connection conn = null;
java.sql.PreparedStatement ps = null;
try {
conn = HIK_DATA_SOURCE_RENHANG.dataSourceJdbc.getConnection();
ps = conn.prepareStatement(insert_sql);
conn.setAutoCommit(false);
for (int i = 0; i < ocrInfoList.size(); i++) {
UserOcrVo bean = ocrInfoList.get(i);
ps.setString(1, bean.getUuid());
ps.setString(2, bean.getAddress());
ps.setString(3, bean.getBirthday());
ps.setString(4, bean.getCitizenId());
ps.setString(5, bean.getGender());
ps.setString(6, bean.getName());
ps.setString(7, bean.getNation());
ps.setString(8, bean.getAgency());
ps.setString(9, bean.getValidDateBegin());
ps.setString(10, bean.getValidDateEnd());
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
ps.setTimestamp(11, timestamp);
ps.setTimestamp(12, timestamp);
ps.addBatch();
}
ps.executeBatch();
conn.commit();
}catch(Exception e){
log.error("======执行batchInsertExecute异常======"+insert_sql+"\r\n",e);
e.printStackTrace();
}finally {
close(conn, ps,null);
}
}
public static void batchUpdateExecute(List<UserOcrVo> ocrInfoList){
String update_sql = "update user_ocr set valid_date_begin=?, valid_date_end=?, updated_at=? where uuid=?";
Connection conn = null;
java.sql.PreparedStatement ps = null;
try {
conn = HIK_DATA_SOURCE_RENHANG.dataSourceJdbc.getConnection();
ps = conn.prepareStatement(update_sql);
conn.setAutoCommit(false);
for (int i = 0; i < ocrInfoList.size(); i++) {
UserOcrVo bean = ocrInfoList.get(i);
ps.setString(1, bean.getValidDateBegin());
ps.setString(2, bean.getValidDateEnd());
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
ps.setTimestamp(3, timestamp);
ps.setString(4, bean.getUuid());
ps.addBatch();
}
ps.executeBatch();
conn.commit();
}catch(Exception e){
log.error("======执行batchUpdateExecute异常======"+update_sql+"\r\n",e);
e.printStackTrace();
}finally {
close(conn, ps,null);
}
}
}
package cn.quantgroup.report.service.baihang;
package cn.quantgroup.report.service.renhang;
import cn.quantgroup.report.domain.baihang.*;
import cn.quantgroup.report.domain.master.RepaymentLoanWhiteList;
import cn.quantgroup.report.domain.renhang.User;
import cn.quantgroup.report.domain.renhang.UserOcrVo;
import cn.quantgroup.report.mapper.baihang.ApplyLoanInfoMapper;
import cn.quantgroup.report.mapper.baihang.LoanInfoMapper;
import cn.quantgroup.report.mapper.baihang.RepaymentLoanInfoMapper;
import cn.quantgroup.report.mapper.master.LoanInfoDbMapper;
import cn.quantgroup.report.mapper.master.RepaymentLoanInfoDbMapper;
import cn.quantgroup.report.mapper.master.RepaymentLoanWhiteListMapper;
import cn.quantgroup.report.mapper.renhang.UserMapper;
import cn.quantgroup.report.service.baihang.client.BhFileCreditApiClient;
import cn.quantgroup.report.service.baihang.client.BhInterfaceCreditApiClient;
import cn.quantgroup.report.service.baihang.request.FileUploadRequest;
......@@ -22,18 +21,19 @@ import cn.quantgroup.report.service.baihang.util.BHRSAUtils;
import cn.quantgroup.report.service.baihang.util.Base64;
import cn.quantgroup.report.service.baihang.util.TuoMinUtils;
import cn.quantgroup.report.service.http.IHttpService;
import cn.quantgroup.report.utils.DateUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.base.Stopwatch;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.lkb.data.hbase.dataservice.verify.OCRIdCardDataService;
import com.lkb.data.hbase.row.verify.OCRIdCardRow;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
......@@ -61,9 +61,9 @@ import java.util.concurrent.atomic.AtomicInteger;
* -----------------------------------------------------------------------------
*/
@Service
public class BaiHangZhuDaiService {
public class UserOcrService {
private static final Logger log = LoggerFactory.getLogger(BaiHangZhuDaiService.class);
private static final Logger log = LoggerFactory.getLogger(UserOcrService.class);
@Autowired
public ApplyLoanInfoMapper applyLoanInfoMapper;
......@@ -74,14 +74,6 @@ public class BaiHangZhuDaiService {
@Autowired
public RepaymentLoanInfoMapper repaymentLoanInfoMapper;
@Autowired
public LoanInfoDbMapper loanInfoDbMapper;
@Autowired
public RepaymentLoanInfoDbMapper repaymentLoanInfoDbMapper;
@Autowired
public RepaymentLoanWhiteListMapper repaymentLoanWhiteListMapper;
@Autowired
public IHttpService iHttpService;
......@@ -122,6 +114,13 @@ public class BaiHangZhuDaiService {
private static AtomicBoolean D2_Stop = new AtomicBoolean(false);
private static AtomicBoolean D3_Stop = new AtomicBoolean(false);
@Autowired
private UserMapper userMapper;
@PostConstruct
public void init(){
......@@ -133,21 +132,6 @@ public class BaiHangZhuDaiService {
log.error("初始化百行助贷PublicKey实例", e);
}
/*try{
long log_stUtc2 = System.currentTimeMillis();
List<String> contextList = FileUtils.readLines(new File(zl_file_path_name + "TEST_BS_USER_TM_201911061315.txt"), "utf-8");
if(contextList!=null && contextList.size()>0){
Map<String,String> tmpMap = new ConcurrentHashMap<>(contextList.size());
for(String context: contextList){
String[] tmp = context.split("=");
tmpMap.put(tmp[0],tmp[1]);
}
testBaoSongUserInfoTuoMingMap = tmpMap;
}
log.info("初始化测试环境百行报送-用户三要素脱敏字典结束, 耗时: {} ",System.currentTimeMillis()-log_stUtc2);
}catch(Exception e){
log.error("初始化测试环境百行报送-用户三要素脱敏字典异常", e);
}*/
}
private static PublicKey getBaihangZDPublickey(){
......@@ -163,6 +147,106 @@ public class BaiHangZhuDaiService {
}
//从Hbase里获取ocr方法
private List<UserOcrVo> getOcrInfoByHbase(List<User> userList) {
List<UserOcrVo> resultList = new ArrayList<>();
if (userList == null || userList.size() == 0) {
return resultList;
}
long start = System.currentTimeMillis();
JSONObject idCardContentA = null, idCardContentB = null;
UserOcrVo userOcrVo = null;
for (User user : userList) {
String uuid = user.getUuid();
try {
List<OCRIdCardRow> ocrIdCardRows = OCRIdCardDataService.get(uuid);
log.info("从hbase中查询身份证正反面结束, uuid: {} ", uuid);
if (CollectionUtils.isNotEmpty(ocrIdCardRows)) {
OCRIdCardRow ocrIdCardRow = ocrIdCardRows.get(0);
if (StringUtils.isNotBlank(ocrIdCardRow.getIdCardContentA())) {
idCardContentA = JSONObject.parseObject(ocrIdCardRow.getIdCardContentA());
}
if (StringUtils.isNotBlank(ocrIdCardRow.getIdCardContentB())) {
idCardContentB = JSONObject.parseObject(ocrIdCardRow.getIdCardContentB());
}
}
if (idCardContentA != null) {
userOcrVo = new UserOcrVo();
userOcrVo.setUuid(uuid);
userOcrVo.setName(idCardContentA.getString("name"));
userOcrVo.setGender(idCardContentA.getString("gender"));//性别 男/女
userOcrVo.setNation(idCardContentA.getString("nation"));//民族
userOcrVo.setBirthday(idCardContentA.getString("birthday"));//出生日期 格式 :1990.02.14
userOcrVo.setCitizenId(idCardContentA.getString("citizen_id"));//身份证号
userOcrVo.setAddress(idCardContentA.getString("address"));
}
if (idCardContentB != null) {
if (userOcrVo == null) {
userOcrVo = new UserOcrVo();
userOcrVo.setUuid(uuid);
}
userOcrVo.setAgency(idCardContentA.getString("agency"));//签发机关
userOcrVo.setValidDateBegin(idCardContentA.getString("valid_date_begin"));//有效日期之起始日期 格式:20131022
userOcrVo.setValidDateEnd(idCardContentA.getString("valid_date_end"));//有效日期之结束日期 格式:20231022
}
if (userOcrVo != null) {
resultList.add(userOcrVo);
}
} catch (Exception e) {
log.error("从hbase中查询身份证正反面异常, uuid: {} ", uuid, e);
} finally {
idCardContentA = null;
idCardContentB = null;
userOcrVo = null;
}
}
log.info("从hbase中获取OCR结束, 参数大小: {} , 结果大小: {} , 耗时: {} ", userList.size(), resultList.size(), System.currentTimeMillis()-start);
return resultList;
}
/**
* -----------------------------------------------------------------------------<br>
* 描 述: 同步新增用户ocr <br>
* 创建人: yanhui.Hao <br>
* 创建时间: 2020.06.10 19:48 <br>
* 最后修改人: <br>
* 最后修改时间: 2020.06.10 19:48 <br>
* 入参说明: <br>
* 出参说明: <br>
* -----------------------------------------------------------------------------
*/
public String synGrowingUser(String startnyr, String endnyr) {
long start1 = System.currentTimeMillis();
List<User> growUsersList = userMapper.queryGrowingUser();
log.info("查询DB新增用户结束, 大小: {} , 耗时: {} ", growUsersList!=null?growUsersList.size():0, (System.currentTimeMillis()-start1));
long start2 = System.currentTimeMillis();
List<UserOcrVo> ocrInfoList = getOcrInfoByHbase(growUsersList);
log.info("从Hbase里获取新增用户ocr结束, 大小: {} , 耗时: {} ", ocrInfoList!=null?ocrInfoList.size():0, (System.currentTimeMillis()-start2));
if(ocrInfoList!=null && ocrInfoList.size()>0){
RenHangBatchExecuteJdbc.batchInsertExecuteCallRecord(ocrInfoList);
}
return "执行结束";
}
//--------------------------------------Scheduled报送------------------------------------------------------------------------------
/**
......@@ -225,304 +309,10 @@ public class BaiHangZhuDaiService {
}
/**
* 助贷模式-实时批量报送放款D2数据
* Scheduled 实时放款数据(百行征信报送)
*/
public String sendZhuDaiLoanToBaiHang(String startnyr, String endnyr) {
log.info("量化派助贷TO百行报送T+1放款开始...");
//yyyy-MM-dd
BaiHangTimeRecord timeRecord = BaiHangTimeRecord.builder().startTime(startnyr).endTime(endnyr).build();
AtomicInteger succ_atomicInteger = new AtomicInteger();
AtomicInteger save_atomicInteger = new AtomicInteger();
List<LoanInfoZhuDai> loanInfos = new ArrayList<>();
Stopwatch sendWatch = Stopwatch.createStarted();
int loanInfosLhSize = 0;
try{
Stopwatch queryWatch1 = Stopwatch.createStarted();
loanInfos = loanInfoMapper.findRealTimeLoanInfoZhuDai(timeRecord);
log.info("量化派助贷TO百行报送-非联合贷放款申请报送开始, 大小: {} , 耗时: {} ", loanInfos.size(), (queryWatch1.stop().elapsed(TimeUnit.MILLISECONDS)/1000)+".s");
Stopwatch queryWatch2 = Stopwatch.createStarted();
List<LoanInfoZhuDai> loanInfosLh = loanInfoMapper.findRealTimeLoanInfoZhuDaiLh(timeRecord);
loanInfosLhSize = loanInfosLh!=null ? loanInfosLh.size() : 0;
log.info("量化派助贷TO百行报送-联合贷放款申请报送开始, 大小: {} , 耗时: {} ", loanInfosLhSize, (queryWatch2.stop().elapsed(TimeUnit.MILLISECONDS)/1000)+".s");
if(loanInfos==null){
loanInfos = new ArrayList<LoanInfoZhuDai>();
}
if(loanInfosLh!=null && loanInfosLh.size()>0){
loanInfos.addAll(loanInfosLh);
}
for (int i = 0; i < loanInfos.size(); i++) {
LoanInfoZhuDai loanInfozd_tmp = loanInfos.get(i);
String id = "";
try {
String reqId_log = loanInfozd_tmp.getReqID();
/* if (loanInfozd_tmp.getTotalTerm() > 1) {
List<String> targetRepaymentDayList = loanInfoMapper.findTargetRepaymentDayList(loanInfoReqId);
loanInfozd_tmp.setTargetRepayDateList(String.join(",", targetRepaymentDayList));
}*/
List<String> targetRepaymentDayList = loanInfoMapper.findTargetRepaymentDayList(reqId_log);
if(targetRepaymentDayList!=null && targetRepaymentDayList.size()>0){
loanInfozd_tmp.setTargetRepayDateList(String.join(",", targetRepaymentDayList));
//log.info("比较还款总期数&账单日列表totalTerm="+loanInfozd_tmp.getTotalTerm()+",targetRepaymentDayList size="+targetRepaymentDayList.size());
}else{
log.warn("比较还款总期数&账单日列表reqId_log: {} , totalTerm: {} , targetRepaymentDayList is null!", reqId_log, loanInfozd_tmp.getTotalTerm());
}
String relationID = loanInfozd_tmp.getRelationID();
if(relationID!=null){
if(relationID.length()>36){ //长度[1,36]
//lhp_1911049771615765816566b49a2db1c429
if(relationID.startsWith("lhp_")){
String tmp = relationID.substring(4,relationID.length());
if(tmp.length()>35){
//lhp_1909279744718808613622e008da4c110000
loanInfozd_tmp.setRelationID("H"+tmp.substring(0,35));
}else{
loanInfozd_tmp.setRelationID("L"+tmp);
}
}else{
log.warn("量化派助贷TO百行报送-放款返回结果不正确, 发现其他类型的relationID并且长度大于36, relationID: {} , reqId_log: {} ", relationID, reqId_log);
//continue;
loanInfozd_tmp.setRelationID("X"+relationID.substring(0,35));
}
}
}
//2020.03.16 {"errorCode":"D2_002","errorMsg":"信贷业务申请时间应早于等于信贷账户开立时间。"}
try {
Date applyDate = DateUtils.parseDate("yyyy-MM-dd'T'HH:mm:ss", loanInfozd_tmp.getApplyDate());
Date accountOpenDate = DateUtils.parseDate("yyyy-MM-dd'T'HH:mm:ss", loanInfozd_tmp.getAccountOpenDate());
if(applyDate!=null && accountOpenDate!=null){
//正常情况下 applyDate在前 accountOpenDate在后 applyDate <= accountOpenDate
if(applyDate.getTime() > accountOpenDate.getTime()){
log.warn("判断发现applyDate大于accountOpenDate时间, applyDate: {} , accountOpenDate: {} , reqId_log: {}", loanInfozd_tmp.getApplyDate(), loanInfozd_tmp.getAccountOpenDate(), reqId_log);
loanInfozd_tmp.setApplyDate(loanInfozd_tmp.getAccountOpenDate());
}
}
}catch (Exception e){
log.error("判断处理applyDate和accountOpenDate异常, applyDate: {} , accountOpenDate: {} ", loanInfozd_tmp.getApplyDate(), loanInfozd_tmp.getAccountOpenDate(), e);
}
UUID loanInfoId = UUID.randomUUID();
id = loanInfoId.toString().replaceAll("-", "");
try{
loanInfozd_tmp.setRecordId(id);
loanInfoDbMapper.saveLoanInfoRecordLog(loanInfozd_tmp);
save_atomicInteger.getAndIncrement();
}catch(Exception e){
log.error("量化派助贷TO百行报送-放款申请保存记录失败, reqId_log: {} , JSON: {} ", reqId_log, JSON.toJSONString(loanInfozd_tmp), e);
}
loanInfozd_tmp.setRecordId(null);
loanInfozd_tmp.setReqID(id);
String jsonStr = JSONObject.toJSONString(loanInfozd_tmp);
LoanInfoZhuDaiVo loanInfo = JSONObject.parseObject(jsonStr, LoanInfoZhuDaiVo.class);
FinTechAgencyBusinessZhuDai finTechAgencyBusiness = JSONObject.parseObject(jsonStr, FinTechAgencyBusinessZhuDai.class);
loanInfo.setFinTechAgencyBusiness(finTechAgencyBusiness);
String logJson = JSON.toJSONString(loanInfo);
loanInfo.setName(interfaceUploadClient(loanInfo.getName()));
loanInfo.setPid(interfaceUploadClient(loanInfo.getPid()));
loanInfo.setMobile(interfaceUploadClient(loanInfo.getMobile()));
String resultStr = iHttpService.postBaiHang(baiHangLoanInfoUrl, getHeader(), JSON.toJSONString(loanInfo));
log.info("助贷放款用户报送结果, param: {} , resultStr: {} ", logJson, resultStr);
if (Objects.isNull(resultStr) || !"success".equalsIgnoreCase(JSON.parseObject(resultStr).getString("status"))) {
log.info("量化派助贷TO百行报送-放款返回结果不正确, reqId_log: {} , recordId: {} , loanId: {} , bean: {} ", reqId_log, id, loanInfo.getLoanId(), JSON.toJSONString(loanInfo));
loanInfoDbMapper.updateCurrentRecordEnableFalce(BaiHangUpDateRecord.builder().enable("0").recordId(id).build());
} else {
succ_atomicInteger.getAndIncrement();
}
} catch (Exception e) {
log.error("量化派助贷TO百行报送-放款信息异常, reqId: {} , recordId: {} , loanId: {} ", loanInfozd_tmp.getReqID(), id, loanInfozd_tmp.getLoanId(), e);
}
}
}catch(Exception e){
log.error("量化派助贷TO百行报送-异常", e);
}
log.info("量化派助贷TO百行报送-放款申请完成, 实际大小: {} , 报送成功大小: {} , 保存日志: {} , 耗时: {} ", loanInfos.size(), succ_atomicInteger.get(), save_atomicInteger.get(), (sendWatch.stop().elapsed(TimeUnit.MILLISECONDS)/1000)+".s");
String resMsgTemp = "放款报送:查询 %d条(联合贷%d条), 报送成功 %d条, 存日志 %d条;";
resMsgTemp+="["+(loanInfos.size()==succ_atomicInteger.get())+"]";
return String.format(resMsgTemp, loanInfos.size(), loanInfosLhSize, succ_atomicInteger.get(), save_atomicInteger.get());
}
/**
* 助贷模式-实时还款&实时逾期还款D3数据报送
* Scheduled 还款&逾期(百行征信报送)
*/
public String sendZhuDaiRepaymentToBaiHang(String startnyr, String endnyr) {
log.info("量化派助贷TO百行报送T+1还款&逾期开始...");
//yyyy-MM-dd
BaiHangTimeRecord timeRecord = BaiHangTimeRecord.builder().startTime(startnyr).endTime(endnyr).build();
String resMsg = "";
String temp_huanKuan = "还款报送:查询 %d条(联合贷%d条), 实际 %d条, 跳过 %d条, 报送成功 %d条, 存日志 %d条;";
String temp_yuQi = "逾期报送:查询 %d条(联合贷%d条), 实际 %d条, 跳过 %d条, 报送成功 %d条, 存日志 %d条;";
for (int j = 0; j < 2; j++) {
Stopwatch sendWatch = Stopwatch.createStarted();
try {
List<RepaymentInfoZhuDai> repaymentLoanInfos = null;
List<RepaymentInfoZhuDai> repaymentLoanInfosLh = null;
if (j == 0) {
Stopwatch realTimeStopWatch1 = Stopwatch.createStarted();
repaymentLoanInfos = repaymentLoanInfoMapper.findRealTimeRepayMentInfo(timeRecord);
log.info("量化派助贷TO百行报送-非联合贷实时还款, startnyr: {} , endnyr: {} , 大小: {} , 耗时: {} ", startnyr, endnyr, repaymentLoanInfos.size(), (realTimeStopWatch1.stop().elapsed(TimeUnit.MILLISECONDS)/1000)+".s");
Stopwatch realTimeStopWatch2 = Stopwatch.createStarted();
repaymentLoanInfosLh = repaymentLoanInfoMapper.findRealTimeRepayMentInfoLh(timeRecord);
log.info("量化派助贷TO百行报送-联合贷实时还款, startnyr: {} , endnyr: {} , 大小: {} , 耗时: {} ", startnyr, endnyr, repaymentLoanInfosLh.size(), (realTimeStopWatch2.stop().elapsed(TimeUnit.MILLISECONDS)/1000)+".s");
} else {
Stopwatch realTimeOverdueStopWatch3 = Stopwatch.createStarted();
repaymentLoanInfos = repaymentLoanInfoMapper.findRealTimeRepayMentOverdue(timeRecord);
log.info("量化派助贷TO百行报送-非联合贷实时还款逾期, startnyr: {} , endnyr: {} , 大小: {} , 耗时: {} ", startnyr, endnyr, repaymentLoanInfos.size(), (realTimeOverdueStopWatch3.stop().elapsed(TimeUnit.MILLISECONDS)/1000)+".s");
Stopwatch realTimeOverdueStopWatch4 = Stopwatch.createStarted();
repaymentLoanInfosLh = repaymentLoanInfoMapper.findRealTimeRepayMentOverdueLh(timeRecord);
log.info("量化派助贷TO百行报送-联合贷实时还款逾期, startnyr: {} , endnyr: {} , 大小: {} , 耗时: {} ", startnyr, endnyr, repaymentLoanInfosLh.size(), (realTimeOverdueStopWatch4.stop().elapsed(TimeUnit.MILLISECONDS)/1000)+".s");
}
if(repaymentLoanInfos==null){
repaymentLoanInfos = new ArrayList<RepaymentInfoZhuDai>();
}
if(repaymentLoanInfosLh!=null && repaymentLoanInfosLh.size()>0){
repaymentLoanInfos.addAll(repaymentLoanInfosLh);
}
AtomicInteger totail_atomicInt = new AtomicInteger();
AtomicInteger tg_atomicInt = new AtomicInteger();
AtomicInteger succ_atomicInt= new AtomicInteger();
AtomicInteger saveLog_atomicInt= new AtomicInteger();
for (int i = 0; i < repaymentLoanInfos.size(); i++) {
RepaymentInfoZhuDai repaymentLoanInfo = repaymentLoanInfos.get(i);
String id = "";
String reqId_log = repaymentLoanInfo.getReqID();
try {
if (j > 0){ //逾期
RepaymentInfoZhuDai repaymentLoanInfo1 = repaymentLoanInfoDbMapper.findLastOne(BaiHangRepayment.builder().loanId(repaymentLoanInfo.getLoanId()).termNo(repaymentLoanInfo.getTermNo()).sendDate(startnyr).build());
////if (j > 0 && Objects.nonNull(repaymentLoanInfo1)) { //逾期的,跳过
if (Objects.nonNull(repaymentLoanInfo1)) { //逾期的,跳过
tg_atomicInt.getAndIncrement();
log.info("量化派助贷TO百行报送-实时还款逾期跳过报送, reqId_log: {} , loanId: {} , termNo: {} , startnyr: {} , endnyr: {} , bean: {} ", reqId_log, repaymentLoanInfo.getLoanId(), repaymentLoanInfo.getTermNo(), startnyr, endnyr, JSON.toJSONString(repaymentLoanInfo1));
//----------2020.02.02 保存跳过的数据,用于以后补全
try{
FileUtils.write(new File("/home/quant_group/baihang-report/data/baihang/D3/yuqi_tg/"+startnyr+"_"+endnyr+".json"),
JSON.toJSONString(repaymentLoanInfo)+"\r\n", "UTF-8", true);
}catch (Exception e){
log.error("量化派助贷TO百行报送-实时逾期跳过, Json数据保存文件异常,",e);
}
continue;
}
}
//2020.02.05 逾期还款增加白名单
/*本笔贷款状态 loanStatus 1:正常还款时填写;2:出现逾期时填写;3:贷款还清时填写;4:撤销贷款时填写;5:债权由机构转出时填写
本期还款状态 if(f.yqze>0,'overdue','normal') termStatus
normal 正常 本期正常还款时填写
overdue 逾期 本期还款出现逾期时填写
thirdPartyPayIn30 第三方代还 借款方逾期 0-30 天(含)内未按期足额还款且本次还款由第三方代借款方偿还
compensation 代偿 借款方逾期 30 天以上未按期足额还款且本次还款由第三方代借款方偿还*/
if(repaymentLoanInfo.getTermStatus()!=null && "overdue".equals(repaymentLoanInfo.getTermStatus())){
if(checkOverdueInWhiteList(repaymentLoanInfo,2, "whiteList_"+startnyr+"_"+endnyr+".json")){
tg_atomicInt.getAndIncrement();
log.info("量化派助贷TO百行报送-逾期还款在白名单跳过报送, reqId_log: {} , loanId: {} , termNo: {} , startnyr: {} , endnyr: {} ", reqId_log, repaymentLoanInfo.getLoanId(), repaymentLoanInfo.getTermNo(), startnyr, endnyr);
continue;
}
}
totail_atomicInt.getAndIncrement();
id = UUID.randomUUID().toString().replaceAll("-", "");
try {
repaymentLoanInfo.setRecordId(id);
repaymentLoanInfoDbMapper.saveRepaymentLoanInfoLog(repaymentLoanInfo);
saveLog_atomicInt.getAndIncrement();
} catch (Exception e) {
log.error("量化派助贷TO百行报送-实时还款保存记录异常, reqId_log: {} , loanId: {} , termNo: {} , JSON: {} ", reqId_log, repaymentLoanInfo.getLoanId(), repaymentLoanInfo.getTermNo(), JSON.toJSONString(repaymentLoanInfo), e);
}
repaymentLoanInfo.setRecordId(null);
repaymentLoanInfo.setReqID(id);
String logJson = JSON.toJSONString(repaymentLoanInfo);
repaymentLoanInfo.setPid(interfaceUploadClient(repaymentLoanInfo.getPid()));
repaymentLoanInfo.setName(interfaceUploadClient(repaymentLoanInfo.getName()));
repaymentLoanInfo.setMobile(interfaceUploadClient(repaymentLoanInfo.getMobile()));
String resultStr = iHttpService.postBaiHang(baiHangRepayMentLoanInfoUrl, getHeader(), JSON.toJSONString(repaymentLoanInfo));
log.info("助贷还款用户报送结果, J: {} , param: {} , resultStr: {} ", j, logJson, resultStr);
if (Objects.isNull(resultStr) || !"success".equalsIgnoreCase(JSON.parseObject(resultStr).getString("status"))) {
log.info("量化派助贷TO百行报送-还款返回结果不正确, 开始时间: {} , 结束时间: {} , reqId_log: {} , recordId: {} , loanId: {} , bean: {} ", startnyr, endnyr, reqId_log, id, repaymentLoanInfo.getLoanId(), JSON.toJSONString(repaymentLoanInfo));
repaymentLoanInfoDbMapper.updateCurrentRecordEnableFalse(BaiHangUpDateRecord.builder().enable("0").recordId(id).build());
} else {
succ_atomicInt.getAndIncrement();
}
} catch (Exception e) {
log.error("量化派助贷TO百行报送-还款信息异常, reqId_log: {} , recordId: {} , loanId: {} ", reqId_log, id, repaymentLoanInfo.getLoanId(), e);
}
}
log.info("量化派助贷TO百行报送-还款申请完成 J: {} , 开始时间: {} , 结束时间: {} , list大小: {} , 实际大小: {} , 跳过: {} , 报送成功大小: {} , 保存日志: {} , 耗时: {} ", j, startnyr, endnyr, repaymentLoanInfos.size(), totail_atomicInt.get(), tg_atomicInt.get(), succ_atomicInt.get(), saveLog_atomicInt.get(), (sendWatch.stop().elapsed(TimeUnit.MILLISECONDS)/1000)+".s");
if (j == 0) {
resMsg+=String.format(temp_huanKuan, repaymentLoanInfos.size(), (repaymentLoanInfosLh!=null ? repaymentLoanInfosLh.size() : 0), totail_atomicInt.get(), tg_atomicInt.get(), succ_atomicInt.get(), saveLog_atomicInt.get());
}else{
resMsg+= "\n";
resMsg+=String.format(temp_yuQi, repaymentLoanInfos.size(), (repaymentLoanInfosLh!=null ? repaymentLoanInfosLh.size() : 0), totail_atomicInt.get(), tg_atomicInt.get(), succ_atomicInt.get(), saveLog_atomicInt.get());
}
resMsg+="["+ (totail_atomicInt.get()==succ_atomicInt.get())+"]";
} catch (Exception e) {
log.error("量化派助贷TO百行报送-异常 J: {} , 开始时间: {} , 结束时间: {} ", j, startnyr, endnyr, e);
}
}
return resMsg;
}
/**
* 描述: 逾期还款报送,是否在白名单检测 <br/>
* 参数: [repaymentLoanInfo, type] <br/>
* 返回值: boolean <br/>
* 创建人: yanhui.Hao <br/>
* 创建时间: 2020.02.06 <br/>
*/
private boolean checkOverdueInWhiteList(RepaymentInfoZhuDai repaymentLoanInfo, int type, String bakFileName){
try{
RepaymentLoanWhiteList object = repaymentLoanWhiteListMapper.findRepaymentLoanWhiteListOne(repaymentLoanInfo.getLoanId(), type);
if(object!=null && object.getPid()!=null && object.getPid().equals(repaymentLoanInfo.getPid())){
try{
//"/home/quant_group/baihang-report/data/baihang/D3/yuqi_tg/whiteList_"+startnyr+"_"+endnyr+".json"
FileUtils.write(new File("/home/quant_group/baihang-report/data/baihang/D3/yuqi_tg/"+bakFileName),
JSON.toJSONString(repaymentLoanInfo)+"\r\n", "UTF-8", true);
}catch (Exception e){
log.error("量化派助贷TO百行报送-逾期还款在白名单跳过报送, Json数据保存文件异常, bean: {} ", JSON.toJSONString(repaymentLoanInfo), e);
}
return true;
}
}catch (Exception e){
log.error("检测逾期还款是在在白名单异常,",e);
}
return false;
}
//--------------------------------------手动重新报送------------------------------------------------------------------------------
/**
......@@ -580,291 +370,11 @@ public class BaiHangZhuDaiService {
return "众信利民助贷模式手动报送A1申请列表大小: "+handApplys.size()+" , 报送成功条数: "+succ_atomicInteger.get();
}
/**
* 描述: 手动重新报送-部分放款D2逻辑问题数据 (手动报送D2) <br/>
* 参数: [] <br/>
* 返回值: void <br/>
* 创建人: yanhui.Hao <br/>
* 创建时间: 2019.10.29 <br/>
*/
@Deprecated
public void sendHandLoaInfoReportToBaiHang(boolean isReadFile, List<String> paramJsonStr) throws Exception {
Stopwatch sendWatch = Stopwatch.createStarted();
List<String> handLoanInfos = null;
if(isReadFile){
handLoanInfos = FileUtils.readLines(new File(baihangHandD2DataUrl), "utf-8");
}else{
if(paramJsonStr==null || paramJsonStr.size()==0){
log.warn("众信利民助贷模式TO百行手动报送放款数据错误, paramJsonStr is Null , isReadFile: {} ",isReadFile);
return;
}else{
handLoanInfos = paramJsonStr;
}
}
for(int i=0;i<handLoanInfos.size();i++){
try {
LoanInfoZhuDai loanInfozd_tmp = new Gson().fromJson(handLoanInfos.get(i), new TypeToken<LoanInfoZhuDai>(){}.getType());
log.info("众信利民助贷模式TO百行手动报送放款单个数据, {}", JSON.toJSONString(loanInfozd_tmp));
String loanInfoReqId = loanInfozd_tmp.getReqID();
/*if(loanInfozd_tmp.getTotalTerm() > 1){
List<String> targetRepaymentDayList = loanInfoMapper.findTargetRepaymentDayList(loanInfoReqId);
loanInfozd_tmp.setTargetRepayDateList(String.join(",", targetRepaymentDayList));
System.out.println("比较还款总期数&账单日列表totalTerm="+loanInfozd_tmp.getTotalTerm()+",targetRepaymentDayList size="+targetRepaymentDayList.size());
}else{
System.err.println("比较还款总期数&账单日列表totalTerm="+loanInfozd_tmp.getTotalTerm());
}*/
List<String> targetRepaymentDayList = loanInfoMapper.findTargetRepaymentDayList(loanInfoReqId);
if(targetRepaymentDayList!=null && targetRepaymentDayList.size()>0){
loanInfozd_tmp.setTargetRepayDateList(String.join(",", targetRepaymentDayList));
//log.info("比较还款总期数&账单日列表totalTerm="+loanInfozd_tmp.getTotalTerm()+",targetRepaymentDayList size="+targetRepaymentDayList.size());
}else{
log.warn("比较还款总期数&账单日列表totalTerm="+loanInfozd_tmp.getTotalTerm()+",targetRepaymentDayList is null.");
}
String relationID = loanInfozd_tmp.getRelationID();
if(relationID!=null){
if(relationID.length()>36){ //长度[1,36]
//lhp_1911049771615765816566b49a2db1c429
if(relationID.startsWith("lhp_")){
String tmp = relationID.substring(4,relationID.length());
if(tmp.length()>35){
//lhp_1909279744718808613622e008da4c110000
loanInfozd_tmp.setRelationID("H"+tmp.substring(0,35));
}else{
loanInfozd_tmp.setRelationID("L"+tmp);
}
}else{
log.warn("众信利民助贷模式TO百行手动报送-数据不正确, 发现其他类型的relationID并且长度大于36, relationID: {} , loanInfoReqId: {} ", relationID, loanInfoReqId);
//continue;
loanInfozd_tmp.setRelationID("X"+relationID.substring(0,35));
}
}
}
try{
loanInfozd_tmp.setRecordId(loanInfozd_tmp.getReqID());
loanInfoDbMapper.saveLoanInfoRecordLog(loanInfozd_tmp);
}catch(Exception e){
log.error("众信利民助贷模式TO百行手动报送-放款申请保存记录失败, loanInfoReqId: {} , JSON: {} ", loanInfoReqId, JSON.toJSONString(loanInfozd_tmp), e);
}
loanInfozd_tmp.setRecordId(null);
String jsonStr = JSONObject.toJSONString(loanInfozd_tmp);
LoanInfoZhuDaiVo loanInfo = JSONObject.parseObject(jsonStr, LoanInfoZhuDaiVo.class);
FinTechAgencyBusinessZhuDai finTechAgencyBusiness = JSONObject.parseObject(jsonStr, FinTechAgencyBusinessZhuDai.class);
loanInfo.setFinTechAgencyBusiness(finTechAgencyBusiness);
String logJson = JSON.toJSONString(loanInfo);
loanInfo.setMobile(interfaceUploadClient(loanInfo.getMobile()));
loanInfo.setName(interfaceUploadClient(loanInfo.getName()));
loanInfo.setPid(interfaceUploadClient(loanInfo.getPid()));
String resultStr = iHttpService.postBaiHang(baiHangLoanInfoUrl, getHeader(), JSON.toJSONString(loanInfo));
log.info("众信利民助贷模式TO百行手动报送放款记录 loanInfoReqId: {} , loanId: {} , bean: {} , result: {} ", loanInfoReqId, loanInfo.getLoanId(), logJson, resultStr);
//存量测试手动整理
/*loanInfozd_tmp.setRecordId(null);
String jsonStr = JSONObject.toJSONString(loanInfozd_tmp);
LoanInfoZhuDaiVo loanInfoZhuDaiVo = JSONObject.parseObject(jsonStr, LoanInfoZhuDaiVo.class);
FinTechAgencyBusinessZhuDai finTechAgencyBusiness = JSONObject.parseObject(jsonStr, FinTechAgencyBusinessZhuDai.class);
loanInfoZhuDaiVo.setFinTechAgencyBusiness(finTechAgencyBusiness);
String id = UUID.randomUUID().toString().replaceAll("-", "");
loanInfoZhuDaiVo.setReqID(id);
try {
FileUtils.write(new File("D:\\用户目录\\Downloads\\build_D2_01_M.txt"), JSON.toJSONString(loanInfoZhuDaiVo)+"\r\n", "UTF-8", true);
//脱敏数据写一份
testTuoMinFileWrite("D:\\用户目录\\Downloads\\build_D2_TEST_01_M.txt","20101113",null,loanInfoZhuDaiVo,null);
} catch (Exception e) {
log.error("放款存量数据处理异常, startTime: {} , endTime: {} , recordId: {} , loanId: {} ",null, null, id, loanInfoZhuDaiVo.getLoanId(), e);
}*/
}catch (Exception e){
log.error("百行征信助贷模式手动报送放款记录异常, params: {} ", handLoanInfos.get(i), e);
}
}
log.info("众信利民助贷模式TO百行手动报送放款记录结束, 大小: {} , 耗时: {} ", handLoanInfos.size(), ((sendWatch.stop().elapsed(TimeUnit.MILLISECONDS)/1000)+".s"));
}
//D2手动报送,有账单日列表,和totalTerm
public String sendHandLoaInfoReportToBaiHang2(boolean isReadFile, List<String> paramJsonStr, String isSaveLogBean) throws Exception {
Stopwatch sendWatch = Stopwatch.createStarted();
List<String> handLoanInfos = null;
if(isReadFile){
handLoanInfos = FileUtils.readLines(new File(baihangHandD2DataUrl), "utf-8");
}else{
if(paramJsonStr==null || paramJsonStr.size()==0){
log.warn("众信利民助贷模式TO百行手动报送放款数据错误, paramJsonStr is Null , isReadFile: {} ",isReadFile);
return "众信利民助贷模式手动报送D2参数为空";
}else{
handLoanInfos = paramJsonStr;
}
}
boolean is_saveLogBean = false;
if(StringUtils.isNotEmpty(isSaveLogBean) && "true".equals(isSaveLogBean)){
is_saveLogBean = true;
}
AtomicInteger succ_atomicInteger = new AtomicInteger();
for(int i=0;i<handLoanInfos.size();i++){
try{
if(handLoanInfos.get(i).length()<30){
continue;
}
LoanInfoZhuDai loanInfozd_tmp = new Gson().fromJson(handLoanInfos.get(i), new TypeToken<LoanInfoZhuDai>(){}.getType());
if(!is_saveLogBean){
JSONObject businessJson = JSONObject.parseObject(handLoanInfos.get(i)).getJSONObject("finTechAgencyBusiness");
loanInfozd_tmp.setInstitutionalFundingPartner(businessJson.containsKey("institutionalFundingPartner") ? businessJson.getString("institutionalFundingPartner") : null);
loanInfozd_tmp.setInstitutionalFundingPartnerID(businessJson.containsKey("institutionalFundingPartnerID") ? businessJson.getString("institutionalFundingPartnerID") : null);
loanInfozd_tmp.setRelationID(businessJson.containsKey("relationID") ? businessJson.getString("relationID") : null);
loanInfozd_tmp.setInstitutionalFundingPartnerLoanID(businessJson.containsKey("institutionalFundingPartnerLoanID") ? businessJson.getString("institutionalFundingPartnerLoanID") : null);
loanInfozd_tmp.setOrderID(businessJson.containsKey("orderID") ? businessJson.getString("orderID") : null);
loanInfozd_tmp.setPreCreditLimit(businessJson.containsKey("preCreditLimit") ? businessJson.getBigDecimal("preCreditLimit") : null);
}else{
if(StringUtils.isEmpty(loanInfozd_tmp.getTargetRepayDateList())){
List<String> targetRepaymentDayList = loanInfoMapper.findTargetRepaymentDayList(loanInfozd_tmp.getReqID());
if(targetRepaymentDayList!=null && targetRepaymentDayList.size()>0){
loanInfozd_tmp.setTargetRepayDateList(String.join(",", targetRepaymentDayList));
}else{
log.warn("助贷模式D2手动报送-比较还款总期数&账单日列表, loanId : {} , lototalTerm: {} , reqId: {} ,targetRepaymentDayList is null.", loanInfozd_tmp.getLoanId(), loanInfozd_tmp.getTotalTerm(), loanInfozd_tmp.getReqID());
}
}
String relationID = loanInfozd_tmp.getRelationID();
if(relationID!=null){
if(relationID.length()>36){ //长度[1,36]
//lhp_1911049771615765816566b49a2db1c429
if(relationID.startsWith("lhp_")){
String tmp = relationID.substring(4,relationID.length());
if(tmp.length()>35){
//lhp_1909279744718808613622e008da4c110000
loanInfozd_tmp.setRelationID("H"+tmp.substring(0,35));
}else{
loanInfozd_tmp.setRelationID("L"+tmp);
}
}else{
log.warn("助贷模式D2手动报送-数据不正确, 发现其他类型的relationID并且长度大于36, relationID: {} , reqId: {} ", relationID, loanInfozd_tmp.getReqID());
loanInfozd_tmp.setRelationID("X"+relationID.substring(0,35));
}
}
}
}
log.info("众信利民助贷模式TO百行手动报送放款单个数据, {}", JSON.toJSONString(loanInfozd_tmp));
String loanInfoReqId = loanInfozd_tmp.getReqID();
if(loanInfozd_tmp.getRecordId()==null){
loanInfozd_tmp.setRecordId(UUID.randomUUID().toString().replaceAll("-", ""));
}
try{
loanInfoDbMapper.saveLoanInfoRecordLog(loanInfozd_tmp);
}catch(Exception e){
log.error("众信利民助贷模式TO百行手动报送-放款申请保存记录失败, loanInfoReqId: {} , JSON: {} ", loanInfoReqId, JSON.toJSONString(loanInfozd_tmp), e);
}
loanInfozd_tmp.setReqID(loanInfozd_tmp.getRecordId());
loanInfozd_tmp.setRecordId(null);
String jsonStr = JSONObject.toJSONString(loanInfozd_tmp);
LoanInfoZhuDaiVo loanInfo = JSONObject.parseObject(jsonStr, LoanInfoZhuDaiVo.class);
FinTechAgencyBusinessZhuDai finTechAgencyBusiness = JSONObject.parseObject(jsonStr, FinTechAgencyBusinessZhuDai.class);
loanInfo.setFinTechAgencyBusiness(finTechAgencyBusiness);
String logJson = JSON.toJSONString(loanInfo);
loanInfo.setMobile(interfaceUploadClient(loanInfo.getMobile()));
loanInfo.setName(interfaceUploadClient(loanInfo.getName()));
loanInfo.setPid(interfaceUploadClient(loanInfo.getPid()));
String resultStr = iHttpService.postBaiHang(baiHangLoanInfoUrl, getHeader(), JSON.toJSONString(loanInfo));
if (Objects.isNull(resultStr) || "success".equalsIgnoreCase(JSON.parseObject(resultStr).getString("status"))) {
succ_atomicInteger.getAndIncrement();
}
log.info("众信利民助贷模式TO百行手动报送放款记录, loanInfoReqId: {} , loanId: {} , bean: {} , result: {} ", loanInfoReqId, loanInfo.getLoanId(), logJson, resultStr);
}catch (Exception e){
log.error("百行征信助贷模式手动报送放款记录异常, params: {} ", handLoanInfos.get(i), e);
}
}
log.info("众信利民助贷模式TO百行手动报送放款记录结束, 大小: {} , 报送成功条数: {} , 耗时: {} ", handLoanInfos.size(), succ_atomicInteger.get(), ((sendWatch.stop().elapsed(TimeUnit.MILLISECONDS)/1000)+".s"));
return "众信利民助贷模式手动报送放款D2列表大小: "+handLoanInfos.size()+" , 报送成功条数: "+succ_atomicInteger.get();
}
/**
* 描述: 手动重新报送-部分还款D3逻辑问题数据 (手动报送D3) <br/>
* 参数: [] <br/>
* 返回值: void <br/>
* 创建人: yanhui.Hao <br/>
* 创建时间: 2019.10.29 <br/>
*/
public String sendHandRepaymentReportToBaiHang1(boolean isReadFile, List<String> paramJsonStr) throws Exception{
Stopwatch sendWatch = Stopwatch.createStarted();
List<String> repaymentLoanInfos = null;
if(isReadFile){
repaymentLoanInfos = FileUtils.readLines(new File(baihangHandD3DataUrl), "utf-8");
}else{
if(paramJsonStr==null || paramJsonStr.size()==0){
log.warn("众信利民助贷模式TO百行手动报送还款数据错误, paramJsonStr is Null , isReadFile: {} ",isReadFile);
return "众信利民助贷模式手动报送D3还款参数为空";
}else{
repaymentLoanInfos = paramJsonStr;
}
}
AtomicInteger succ_atomicInteger = new AtomicInteger();
//log.info("众信利民助贷模式TO百行报送还款数据, {}", JSON.toJSONString(repaymentLoanInfos));
for(int i=0;i<repaymentLoanInfos.size();i++){
try {
RepaymentInfoZhuDai repaymentLoanInfo = new Gson().fromJson(repaymentLoanInfos.get(i), new TypeToken<RepaymentInfoZhuDai>(){}.getType());
log.info("众信利民助贷模式TO百行手动报送还款数据单个数据, {}", JSON.toJSONString(repaymentLoanInfo));
//2020.02.05 逾期还款增加白名单
if(repaymentLoanInfo.getTermStatus()!=null && "overdue".equals(repaymentLoanInfo.getTermStatus())){
String newnyr = LocalDateTime.now().format(DateTimeFormatter.ISO_DATE);
String bakFileName = "whiteList_" + newnyr + ".json";
if(checkOverdueInWhiteList(repaymentLoanInfo,2, bakFileName)){
log.info("众信利民助贷模式TO百行手动报送还款在白名单跳过报送, reqId: {} , loanId: {} , termNo: {} , newnyr: {} ", repaymentLoanInfo.getReqID(), repaymentLoanInfo.getLoanId(), repaymentLoanInfo.getTermNo(), newnyr);
continue;
}
}
try {
////repaymentLoanInfo.setRecordId(repaymentLoanInfo.getReqID());
if(repaymentLoanInfo.getRecordId()==null){
repaymentLoanInfo.setRecordId(UUID.randomUUID().toString().replaceAll("-", ""));
}
repaymentLoanInfoDbMapper.saveRepaymentLoanInfoLog(repaymentLoanInfo);
} catch (Exception e) {
log.error("众信利民助贷模式TO百行手动报送还款保存记录异常, reqId_log: {} , loanId: {} , termNo: {} , JSON: {} ", repaymentLoanInfo.getReqID(), repaymentLoanInfo.getLoanId(), repaymentLoanInfo.getTermNo() ,JSON.toJSONString(repaymentLoanInfo), e);
}
repaymentLoanInfo.setReqID(repaymentLoanInfo.getRecordId());
repaymentLoanInfo.setRecordId(null);
String logJson = JSON.toJSONString(repaymentLoanInfo);
repaymentLoanInfo.setPid(interfaceUploadClient(repaymentLoanInfo.getPid()));
repaymentLoanInfo.setName(interfaceUploadClient(repaymentLoanInfo.getName()));
repaymentLoanInfo.setMobile(interfaceUploadClient(repaymentLoanInfo.getMobile()));
String resultStr = iHttpService.postBaiHang(baiHangRepayMentLoanInfoUrl, getHeader(), JSON.toJSONString(repaymentLoanInfo));
if (Objects.isNull(resultStr) || "success".equalsIgnoreCase(JSON.parseObject(resultStr).getString("status"))) {
succ_atomicInteger.getAndIncrement();
}
log.info("众信利民助贷模式TO百行手动报送还款记录 reqID: {} , bean: {} , result: {} ", repaymentLoanInfo.getReqID(), logJson, resultStr);
} catch (Exception e) {
log.error("百行征信助贷模式手动报送还款异常, params: {} ", repaymentLoanInfos.get(i), e);
}
}
log.info("众信利民助贷模式TO百行手动报送还款记录结束, 大小: {} , 耗时: {} ", repaymentLoanInfos.size(), ((sendWatch.stop().elapsed(TimeUnit.MILLISECONDS)/1000)+".s"));
return "众信利民助贷模式手动报送D3还款列表大小: "+repaymentLoanInfos.size()+" , 报送成功条数: "+succ_atomicInteger.get();
}
//-----------------------------------------------存量整理---------------------------------------------------------------------
/**
......@@ -1459,194 +969,6 @@ public class BaiHangZhuDaiService {
}
//test2.接口测试 手动调用
@Deprecated
public String apiSend(String type,String startDate, String endDate) {
//"2019-05-07T00:00:00"
if(StringUtils.isAnyBlank(type,startDate,endDate)){
return "参数为空";
}
if(startDate.length()!=19 || endDate.length()!=19 || !startDate.contains("T") || !endDate.contains("T")){
log.warn("日期格式有误, startDate : {} , endDate : {} ",startDate,endDate);
return "日期格式有误";
}
long sUtc1 = System.currentTimeMillis();
String starTime = LocalDateTime.parse(startDate).format(DateTimeFormatter.ISO_DATE);
String endTime = LocalDateTime.parse(endDate).format(DateTimeFormatter.ISO_DATE);
if("A1".equalsIgnoreCase(type)){
//贷款申请信息(A1)
List<ApplyLoanInfoZhuDai> applyLoanInfos = applyLoanInfoMapper.queryStockApplyLoanInfoZhuDai(BaiHangTimeRecord.builder().startTime(starTime).endTime(endTime).build());
int listSize = applyLoanInfos!=null ? applyLoanInfos.size(): 0;
log.info("百行-助贷申请数据查询结束, listSize : {} , startTime: {} , endTime: {} , 耗时: {} ", listSize, starTime, endTime, (System.currentTimeMillis()-sUtc1));
Stopwatch sendWatch = Stopwatch.createStarted();
AtomicInteger atomicInteger = new AtomicInteger();
for (int i = 0; i < applyLoanInfos.size(); i++) {
try {
ApplyLoanInfoZhuDai applyLoanInfo = applyLoanInfos.get(i);
applyLoanInfo.setName(interfaceUploadClient(applyLoanInfo.getName()));
applyLoanInfo.setMobile(interfaceUploadClient(applyLoanInfo.getMobile()));
applyLoanInfo.setPid(interfaceUploadClient(applyLoanInfo.getPid()));
String resultStr = iHttpService.postBaiHang(baiHangApplyLoanInfoUrl, getHeader(), JSON.toJSONString(applyLoanInfo));
if (Objects.isNull(resultStr) || !(resultStr.contains("queryHistory") && resultStr.contains("nonRevolvingLoan") && resultStr.contains("revolvingLoan"))) {
log.info("量化派助贷TO百行报送-贷款申请返回结果不正确, applyId: {} ", applyLoanInfo.getApplyId());
} else {
atomicInteger.getAndIncrement();
}
} catch (Exception e) {
log.error("量化派助贷TO百行报送-贷款申请信息异常", e);
}
}
log.info("量化派助贷TO百行报送-贷款申请报送完成, 实际大小: {} , 报送成功大小: {} , 耗时: {} ", applyLoanInfos.size(), atomicInteger.get(), sendWatch.stop().elapsed(TimeUnit.MILLISECONDS));
}else if("D2".equalsIgnoreCase(type)){
//非循环贷款账户数据信息(D2)
try{
List<LoanInfoZhuDai> loanInfozdList = loanInfoMapper.queryStockLoanInfoZhuDai(BaiHangTimeRecord.builder().startTime(starTime).endTime(endTime).build());
int listSize = loanInfozdList!=null ? loanInfozdList.size(): 0;
log.info("百行-助贷放款数据查询结束, listSize : {} , startTime: {} , endTime: {} , 耗时 : {} ", listSize, starTime, endTime, ((System.currentTimeMillis()-sUtc1)/1000)+".s");
AtomicInteger atomicInteger = new AtomicInteger();
Stopwatch sendWatch = Stopwatch.createStarted();
for (int i = 0; i < loanInfozdList.size(); i++) {
LoanInfoZhuDai loanInfo = loanInfozdList.get(i);
String id = "";
try {
String loanInfoReqId = loanInfo.getReqID();
/* if (loanInfo.getTotalTerm() > 1) {
List<String> targetRepaymentDayList = loanInfoMapper.findTargetRepaymentDayList(loanInfoReqId);
loanInfo.setTargetRepayDateList(String.join(",", targetRepaymentDayList));
}*/
List<String> targetRepaymentDayList = loanInfoMapper.findTargetRepaymentDayList(loanInfoReqId);
if(targetRepaymentDayList!=null && targetRepaymentDayList.size()>0){
loanInfo.setTargetRepayDateList(String.join(",", targetRepaymentDayList));
log.info("比较还款总期数&账单日列表totalTerm="+loanInfo.getTotalTerm()+",targetRepaymentDayList size="+targetRepaymentDayList.size());
}else{
log.warn("比较还款总期数&账单日列表totalTerm="+loanInfo.getTotalTerm()+",targetRepaymentDayList is null.");
}
/*UUID loanInfoId = UUID.randomUUID();
id = loanInfoId.toString().replaceAll("-", "");
loanInfo.setRecordId(id);
try{
loanInfoDbMapper.saveLoanInfoRecordLog(loanInfo);
}catch(Exception e){}
loanInfo.setRecordId(null);
loanInfo.setReqID(id);*/
UUID loanInfoId = UUID.randomUUID();
id = loanInfoId.toString().replaceAll("-", "");
try{
LoanInfoZhuDai record = new LoanInfoZhuDai();
BeanUtils.copyProperties(loanInfo, record);
record.setRecordId(id);
loanInfoDbMapper.saveLoanInfoRecordLog(record);
}catch(Exception e){
log.error("量化派助贷TO百行报送-放款申请保存记录失败" , e);
}
loanInfo.setReqID(id);
loanInfo.setName(interfaceUploadClient(loanInfo.getName()));
loanInfo.setPid(interfaceUploadClient(loanInfo.getPid()));
loanInfo.setMobile(interfaceUploadClient(loanInfo.getMobile()));
String resultStr = iHttpService.postBaiHang(baiHangLoanInfoUrl, getHeader(), JSON.toJSONString(loanInfo));
log.info("助贷放款用户报送结果, param: {} , resultStr: {} ", JSON.toJSONString(loanInfo), resultStr);
if (Objects.isNull(resultStr) || !"success".equalsIgnoreCase(JSON.parseObject(resultStr).getString("status"))) {
log.info("量化派助贷TO百行报送-放款返回结果不正确, recordId: {} , loanId: {} , bean: {} ", id, loanInfo.getLoanId(), JSON.toJSONString(loanInfo));
loanInfoDbMapper.updateCurrentRecordEnableFalce(BaiHangUpDateRecord.builder().enable("0").recordId(id).build());
} else {
atomicInteger.getAndIncrement();
}
} catch (Exception e) {
log.error("量化派助贷TO百行报送-放款信息异常, recordId: {} , loanId: {} ", id, loanInfo.getLoanId(), e);
}
}
log.info("量化派助贷TO百行报送-放款申请完成, 实际大小: {} , 报送成功大小: {} , 耗时: {} ", loanInfozdList.size(), atomicInteger.get(), sendWatch.stop().elapsed(TimeUnit.MILLISECONDS));
}catch(Exception e){
log.error("量化派助贷TO百行报送-异常", e);
}
}else if("D3".equalsIgnoreCase(type)){
//非循环贷款贷后数据信息(D3)
for (int j = 0; j < 2; j++) {
Stopwatch sendWatch = Stopwatch.createStarted();
try {
List<RepaymentInfoZhuDai> repaymentLoanInfos = null;
if (j == 0) {
Stopwatch stopwatch = Stopwatch.createStarted();
repaymentLoanInfos = repaymentLoanInfoMapper.queryStockRepayMentInfoZhuDai(BaiHangTimeRecord.builder().startTime(starTime).endTime(endTime).build());
log.info("百行-助贷还款查询结束, startTime: {} , endTime: {} , 大小: {} , 耗时: {} ", starTime, endTime, repaymentLoanInfos.size(), (stopwatch.stop().elapsed(TimeUnit.MILLISECONDS)/1000)+".s");
} else {
Stopwatch stopwatch = Stopwatch.createStarted();
repaymentLoanInfos = repaymentLoanInfoMapper.queryStockRepayMentInfoOverdueZhuDai(BaiHangTimeRecord.builder().startTime(starTime).endTime(endTime).build());
log.info("百行-助贷还款查询逾期结束, startTime: {} , endTime: {} , 大小: {} , 耗时: {} ", starTime, endTime, repaymentLoanInfos.size(), (stopwatch.stop().elapsed(TimeUnit.MILLISECONDS)/1000)+".s");
}
AtomicInteger atomicInteger = new AtomicInteger();
for (int i = 0; i < repaymentLoanInfos.size(); i++) {
RepaymentInfoZhuDai repaymentLoanInfo = repaymentLoanInfos.get(i);
String id = "";
try {
RepaymentInfoZhuDai repaymentLoanInfo1 = repaymentLoanInfoDbMapper.findLastOne(BaiHangRepayment.builder().loanId(repaymentLoanInfo.getLoanId()).termNo(repaymentLoanInfo.getTermNo()).build());
if (j > 0 && Objects.nonNull(repaymentLoanInfo1)) {
log.info("量化派助贷TO百行报送-实时还款逾期跳过报送, startTime: {} , endTime: {} , bean: {} ", starTime, endTime, JSON.toJSONString(repaymentLoanInfo1));
continue;
}
/*id = UUID.randomUUID().toString().replaceAll("-", "");
repaymentLoanInfo.setRecordId(id);
try {
repaymentLoanInfoDbMapper.saveRepaymentLoanInfoLog(repaymentLoanInfo);
} catch (Exception e) {
}
repaymentLoanInfo.setReqID(id);
repaymentLoanInfo.setRecordId(null);*/
id = UUID.randomUUID().toString().replaceAll("-", "");
try {
RepaymentInfoZhuDai record = new RepaymentInfoZhuDai();
BeanUtils.copyProperties(repaymentLoanInfo, record);
record.setRecordId(id);
repaymentLoanInfoDbMapper.saveRepaymentLoanInfoLog(record);
} catch (Exception e) {
log.error("量化派助贷TO百行报送-实时还款保存记录异常",e);
}
repaymentLoanInfo.setReqID(id);
repaymentLoanInfo.setPid(interfaceUploadClient(repaymentLoanInfo.getPid()));
repaymentLoanInfo.setName(interfaceUploadClient(repaymentLoanInfo.getName()));
repaymentLoanInfo.setMobile(interfaceUploadClient(repaymentLoanInfo.getMobile()));
String resultStr = iHttpService.postBaiHang(baiHangRepayMentLoanInfoUrl, getHeader(), JSON.toJSONString(repaymentLoanInfo));
log.info("助贷还款用户报送结果, param: {} , resultStr: {} ", JSON.toJSONString(repaymentLoanInfo), resultStr);
if (Objects.isNull(resultStr) || !"success".equalsIgnoreCase(JSON.parseObject(resultStr).getString("status"))) {
log.info("量化派助贷TO百行报送-还款返回结果不正确, 开始时间: {} , 结束时间: {} , recordId: {} , loanId: {} , bean: {} ", starTime, endTime, id, repaymentLoanInfo.getLoanId(), JSON.toJSONString(repaymentLoanInfo));
repaymentLoanInfoDbMapper.updateCurrentRecordEnableFalse(BaiHangUpDateRecord.builder().enable("0").recordId(id).build());
} else {
atomicInteger.getAndIncrement();
}
} catch (Exception e) {
log.error("量化派助贷TO百行报送-还款信息异常, recordId: {} , loanId: {} ", id, repaymentLoanInfo.getLoanId(), e);
}
}
log.info("量化派助贷TO百行报送-还款申请完成 J: {} , 开始时间: {} , 结束时间: {} , 实际大小: {} , 报送成功大小: {} , 耗时: {} ", j, starTime, endTime, repaymentLoanInfos.size(), atomicInteger.get(), sendWatch.stop().elapsed(TimeUnit.MILLISECONDS));
} catch (Exception e) {
log.error("量化派助贷TO百行报送-异常 J: {} , 开始时间: {} , 结束时间: {} ", j, starTime, endTime, e);
}
}
}else{
return "其他未知类型type="+type;
}
return type+"手动报送结束";
}
@Async
public void zhuDaiStockSyn(String type, String startDate, String noEndDate, String d3Type,String isNotHaveReqID) {
//"2019-05-07T00:00:00"
......@@ -1836,4 +1158,115 @@ public class BaiHangZhuDaiService {
}
log.info("处理A1结束");
}
/**
* -----------------------------------------------------------------------------<br>
* 描述: 合同下载
* saveImagePath报错下载图片的跟路径,下面每个人的合同在姓名文件夹下<br>
* paramsFile 入参文件,文件中参数格式 uuid|身份证|姓名|contract_no合同编号|loan_id
* 作者:yanhui.Hao <br>
* 时间:2020.03.09 <br>
* 授权: (C) Copyright (c) 2017 <br>
* 公司: 北京众信利民信息技术有限公司 <br>
* -----------------------------------------------------------------------------
*/
public static void downloads_sfz(String saveImagePath, String paramsFile) {//saveImagePath末尾不加\\
try {
//uuid|身份证|姓名|contract_no合同编号|template_id|编号 (uuid,姓名,合同编号,template_id,编号 )
List<String> paramsList = FileUtils.readLines(new File(paramsFile), "utf-8");
System.out.println("入参文件大小=" + paramsList.size());
for (String params : paramsList) {
//uuid|身份证|姓名|contract_no合同编号|loan_id
String[] split = params.trim().split("[|]");
String uuid = split[0];
List<OCRIdCardRow> ocrIdCardRows = OCRIdCardDataService.get(uuid);
log.info("从hbase中查询身份证正反面结束, uuid: {} ", uuid);
String idCardBaseContentA = "";
String idCardBaseContentB = "";
String userRenXingC = "";
JSONObject idCardContentA = null, idCardContentB = null;
if (CollectionUtils.isNotEmpty(ocrIdCardRows)) {
OCRIdCardRow ocrIdCardRow = ocrIdCardRows.get(0);
idCardBaseContentA = ocrIdCardRow.getIdCardBaseContentA();
idCardBaseContentB = ocrIdCardRow.getIdCardBaseContentB();
userRenXingC = ocrIdCardRow.getLivePhotoContent();
System.out.println(JSON.toJSONString(ocrIdCardRow));
if(StringUtils.isNotBlank(ocrIdCardRow.getIdCardContentA())){
idCardContentA = JSONObject.parseObject(ocrIdCardRow.getIdCardContentA());
}
if(StringUtils.isNotBlank(ocrIdCardRow.getIdCardContentB())){
idCardContentB = JSONObject.parseObject(ocrIdCardRow.getIdCardContentB());
}
//String ocrResult = ocrIdCardRow.getOcrResult();
}
//放到 saveImagePath >> 编号_姓名 >> 姓名_uuid >> A/B/C.jpg
//文件夹名用 明细列表中编号+姓名 2020.04.16
String pageName = split[5] + "_" +split[2]; //用户目录文件夹名(编号_姓名)
String pageOcrName = split[2]+"_"+split[0]; //Ocr目录文件夹名(姓名_uuid)
//数据材料_身份证OCR提取_清单:姓名 性别 民族 身份证号 身份证有效期 身份证地址
String c_name="", c_gender="", c_nation="", c_citizen_id="", c_valid_date = "", c_address = "";
if(idCardContentA!=null){
if(StringUtils.isNotEmpty(idCardContentA.getString("name"))){
c_name = idCardContentA.getString("name");
}
if(StringUtils.isNotEmpty(idCardContentA.getString("gender"))){
c_gender = idCardContentA.getString("gender");
}
if(StringUtils.isNotEmpty(idCardContentA.getString("nation"))){
c_nation = idCardContentA.getString("nation");
}
if(StringUtils.isNotEmpty(idCardContentA.getString("citizen_id"))){
c_citizen_id = idCardContentA.getString("citizen_id");
}
if(StringUtils.isNotEmpty(idCardContentA.getString("address"))){
c_address = idCardContentA.getString("address");
}
}
if(idCardContentB!=null){
if(StringUtils.isNotEmpty(idCardContentB.getString("valid_date_begin"))){
c_valid_date+=idCardContentB.getString("valid_date_begin");
}
c_valid_date+="-";
if(StringUtils.isNotEmpty(idCardContentB.getString("valid_date_end"))){
c_valid_date+=idCardContentB.getString("valid_date_end");
}
}
StringBuffer ocrDetails = new StringBuffer();
ocrDetails.append(split[5]).append("\t");//明细清单编号
ocrDetails.append(uuid).append("\t");
ocrDetails.append(c_name).append("\t");
ocrDetails.append(c_gender).append("\t");
ocrDetails.append(c_nation).append("\t");
ocrDetails.append(c_citizen_id).append("\t");
ocrDetails.append(c_valid_date).append("\t");
ocrDetails.append(c_address);
FileUtils.write(new File(saveImagePath + "\\" + "数据材料_身份证OCR提取_清单.txt"), ocrDetails.toString()+"\r\n", "UTF-8", true);
}
System.out.println(paramsFile+",身份证正反面下载完毕>>>>>>>>>>>>>>>");
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
downloads_sfz("D:\\JavaTeam\\Ocr及合同提取\\20200601\\材料", "D:\\JavaTeam\\Ocr及合同提取\\20200601\\paramsFile.txt");
}
}
package cn.quantgroup.report.service.thirdpartymonitor;
public class HBaseConfig {
public final static ThreadLocal<Boolean> readHBaseFirst = new ThreadLocal<Boolean>() {
public Boolean initialValue() {
return true;
}
};
public static void disableReadHBaseFirst() {
readHBaseFirst.set(false);
}
public static void enableReadHBaseFirst() {
readHBaseFirst.set(true);
}
}
package cn.quantgroup.report.service.thirdpartymonitor;
import cn.quantgroup.report.error.QGExceptionType;
import cn.quantgroup.report.error.QGPreconditions;
import cn.quantgroup.report.utils.ClockUtils;
//import com.lkb.data.hbase.utils.RowKeyTool;
import lombok.Builder;
import lombok.Data;
/*import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.util.Bytes;*/
@Data
public class ThirdPartyBean {
/* public static final TableName TABLE_NAME = TableName.valueOf("third-party-info");
public static final byte[] COLUMN_FAMILY = Bytes.toBytes("f");
public static final byte[] ID_NO = Bytes.toBytes("i");
public static final byte[] DATA_SOURCE = Bytes.toBytes("s");
public static final byte[] REQUEST_TIME = Bytes.toBytes("t");
public static final byte[] REQUEST_MESSAGE = Bytes.toBytes("q");
public static final byte[] RESPONSE_MESSAGE = Bytes.toBytes("p");
private String id;
private String requestTime;
private String datasource;
private String request;
private String response;
@Builder
public ThirdPartyBean(String id, String datasource, String request, String response) {
this.id = id;
this.datasource = datasource; //urltype
this.request = request;
this.response = response;
this.requestTime = ClockUtils.hBaseDateTimeStringFromTimestamp(ClockUtils.now());
}
public byte[] findRowKey() {
QGPreconditions.checkArgument(this.id != null && datasource != null, QGExceptionType.COMMON_STRING_PARAM_IS_NULL);
byte[] prefix = RowKeyTool.getMD5Prefix(id, 4);
QGPreconditions.checkArgument(prefix != null, QGExceptionType.COMMON_STRING_PARAM_IS_NULL);
return Bytes.add(prefix, RowKeyTool.createRowKeyField(id), Bytes.toBytes("|" + datasource));
}
public Put generatePut() {
byte[] rk = findRowKey();
Put put = new Put(rk);
put.addColumn(COLUMN_FAMILY, ID_NO, Bytes.toBytes(id));
put.addColumn(COLUMN_FAMILY, DATA_SOURCE, Bytes.toBytes(datasource));
put.addColumn(COLUMN_FAMILY, REQUEST_TIME, Bytes.toBytes(requestTime));
put.addColumn(COLUMN_FAMILY, REQUEST_MESSAGE, Bytes.toBytes(request));
put.addColumn(COLUMN_FAMILY, RESPONSE_MESSAGE, Bytes.toBytes(response));
return put;
}*/
}
package cn.quantgroup.report.service.thirdpartymonitor;
import cn.quantgroup.report.cmpt.CommonAlarmCmpt;
import cn.quantgroup.report.constant.TransactionCodeEnum;
import cn.quantgroup.report.domain.master.*;
import cn.quantgroup.report.enums.RequestUrlType;
import cn.quantgroup.report.mapper.master.*;
import cn.quantgroup.report.service.usersdk.IUserCenterService;
import com.google.common.base.Stopwatch;
//import com.lkb.data.hbase.dataservice.DataService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.time.FastDateFormat;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
@Service
@Slf4j
public class ThirdpartyApiMonitorService { //extends DataService
private static final FastDateFormat dateFormat = FastDateFormat.getInstance("yyyyMM", TimeZone.getDefault(), Locale.getDefault());
private static final String DATA_PRICE_CACHE = "MONITOR.DATA_PRICE_CACHE";
private static final String DATA_QRY_RECORD = "MONITOR.DATA_QRY_RECORD.";
private static final String DATA_ACCOUNT = "MONITOR.ACCOUNT.";
@Autowired
private UnionPayApiRequestEventMapper unionPayApiRequestEventMapper;
@Autowired
private CommonApiReqestEventMapper commonApiReqestEventMapper;
@Autowired
private ApiRequestLogPOMapper apiRequestLogPOMapper;
@Autowired
private TransactionLogPOMapper transactionLogPOMapper;
@Autowired
private CostRecordPOMapper costRecordPOMapper;
@Autowired
private DataPriceConfigPOMapper dataPriceConfigPOMapper;
@Autowired
private AccountPOMapper accountPOMapper;
@Autowired
private CommonAlarmCmpt commonAlarmCmpt;
@Autowired
private IUserCenterService userCenterService;
@Autowired
private RedisTemplate redisTemplate;
private static Map<String, DataPriceConfigPO> dataPriceMap = null;
@Value("${isDebug}")
private Boolean isDebug;
/**
*
* @param id 用户标示
* @param urlType 数据源类型
* @param isBilling 是否收费(0,收费 1 ,不收费)
* @param responseMessage 返回的信息(成功,权限不足,参数错误。。。等)
* @param millis 该次请求耗时
* @param businessCode 返回码,与返回信息对应
* 修改主要是isBilling 之后将增加是否计费字段,废弃之前httpcode都为200的字段
*/
public void create(String id, RequestUrlType urlType, String isBilling, String responseMessage, int millis, String businessCode, String...args) {
Stopwatch stopwatch = Stopwatch.createStarted();
switch (urlType) {
case CreditCardRecord:
unionPayApiRequestEventMapper.insert(UnionPayApiRequestEvent.builder()
.bankCardNo(id)
.mills(millis)
.requestUrlType(urlType.name())
.businessCode(businessCode)
.timeCreated(new Date())
.build());
break;
//量化派数据产品输出黑名等级
case LhpBlackListLevel:
commonApiReqestEventMapper.insert(CommonWithBillingApiRequestEvent.builder().userId(id)
.isBilling(isBilling)
.mills(millis)
.requestUrlType(urlType.name())
.responseCode(businessCode)
.responseMessage(responseMessage)
.timeCreated(new Date()).build());
break;
default:
log.error("暂时未监控{}", urlType.name());
break;
}
log.info("保存调用记录完成, id: {} , urlType: {} , 耗时: {} ", id, urlType, stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
}
public void saveLog(RequestUrlType urlType, String code, String msg, String flag, int millis) {
try {
apiRequestLogPOMapper.insert(ApiRequestLogPO.builder()
.urlType(urlType.name())
.resCode(code)
.resMsg(msg)
.hitFlag(flag)
.timeElapse(millis)
.createTime(new Date())
.suffix(dateFormat.format(new Date())).build());
}catch (Exception e){
log.error("保存接口请求记录失败", e);
}
}
public void saveTransactionLog(RequestUrlType urlType, String transactionId, String uuid, TransactionCodeEnum code) {
try {
transactionLogPOMapper.insert(TransactionLogPO.builder()
.transactionId(transactionId)
.uuid(uuid)
.urlType(urlType.name())
.code(code.getCode())
.timeCreated(new Date()).build());
}catch (Exception e){
log.error("保存接口请求记录TransactionLog失败", e);
}
}
public void saveTransactionLogByPhone(RequestUrlType urlType, String transactionId, String phone, TransactionCodeEnum code) {
try {
String uuid = userCenterService.getUuidByPhoneNumber(phone);
log.info("TransactionLog 查询 phone: {}, uuid: {}", phone, uuid);
transactionLogPOMapper.insert(TransactionLogPO.builder()
.transactionId(transactionId)
.uuid(uuid)
.urlType(urlType.name())
.code(code.getCode())
.timeCreated(new Date()).build());
}catch (Exception e){
log.error("保存接口请求记录TransactionLog失败", e);
}
}
public void saveTransactionLogByIdentifyNumber(RequestUrlType urlType, String transactionId, String identifyNumber, TransactionCodeEnum code) {
try {
String uuid = userCenterService.getUuidByIdentityNumber(identifyNumber);
log.info("TransactionLog 查询 identifyNumber: {}, uuid: {}", identifyNumber, uuid);
transactionLogPOMapper.insert(TransactionLogPO.builder()
.transactionId(transactionId)
.uuid(uuid)
.urlType(urlType.name())
.code(code.getCode())
.timeCreated(new Date()).build());
}catch (Exception e){
log.error("保存接口请求记录TransactionLog失败", e);
}
}
public void recordCostInDb(RequestUrlType urlType, String sourceName, Integer invokeTimes, BigDecimal cost, BigDecimal balance) {
costRecordPOMapper.insert(CostRecordPO.builder()
.urlType(urlType.name())
.sourceName(sourceName)
.invokeTimes(invokeTimes)
.cost(cost)
.balance(balance)
.createTime(new Date())
.suffix(dateFormat.format(new Date())).build());
}
public DataPriceConfigPO qryDataPrice(RequestUrlType urlType) {
try {
dataPriceMap = redisTemplate.opsForHash().entries(DATA_PRICE_CACHE);
if (dataPriceMap == null || dataPriceMap.size() == 0) {
synchronized (ThirdpartyApiMonitorService.class) {
if (dataPriceMap == null || dataPriceMap.size() == 0) {
List<DataPriceConfigPO> dataPriceConfigPOS = dataPriceConfigPOMapper.queryByParams(DataPriceConfigPO.builder().status("1").build());
dataPriceMap = new ConcurrentHashMap<>();
for (DataPriceConfigPO dataPriceConfigPO : dataPriceConfigPOS) {
dataPriceMap.put(dataPriceConfigPO.getUrlType(), dataPriceConfigPO);
}
redisTemplate.opsForHash().putAll(DATA_PRICE_CACHE, dataPriceMap);
}
}
}
}catch (Exception e){
log.error("获取配置数据失败", e);
return null;
}
return dataPriceMap.get(urlType.name());
}
public AccountPO qryAccount(String sourceName) {
List<AccountPO> accountPOS = accountPOMapper.selectByExample(AccountPO.builder().sourceName(sourceName).status("1").build());
return accountPOS.get(0);
}
private void updateAccount(AccountPO accountPO) {
accountPOMapper.updateByParams(accountPO);
}
public void recordCost(RequestUrlType urlType, String sourceName){
Long times = redisTemplate.opsForValue().increment(DATA_QRY_RECORD + urlType.name(), 1l);
DataPriceConfigPO dataPriceConfigPO = qryDataPrice(urlType);
if(times >= dataPriceConfigPO.getFrequency()){
String lockKey = DATA_ACCOUNT + sourceName;
boolean result = lock(lockKey, 60);
if(!result) return;
try{
AccountPO accountPO = qryAccount(sourceName);
BigDecimal blance = accountPO.getBlance();
BigDecimal cost = dataPriceConfigPO.getPrice().multiply(BigDecimal.valueOf(times));
blance = blance.subtract(cost);
accountPO.setBlance(blance);
if(blance.compareTo(accountPO.getThershold()) < 0){
commonAlarmCmpt.alarm("Warn", "三方数据源告警", "数据源【"+ sourceName +"】 余额已不足"+accountPO.getThershold()+", 目前账户余额为"+blance);
}
updateAccount(accountPO);
recordCostInDb(urlType, sourceName, times.intValue(), cost, blance);
redisTemplate.delete(DATA_QRY_RECORD + urlType.name());
}catch (Exception e){
log.error("扣费异常, requestUrlType: {} ", urlType, e);
}finally {
unlock(lockKey);
}
}
}
public void saveInHBase(RequestUrlType urlType, String id, String requestJson, String responseJson) {
}
/*public void saveInHBase(RequestUrlType urlType, String id, String requestJson, String responseJson) {
Stopwatch stopwatch = Stopwatch.createStarted();
if (BooleanUtils.isTrue(isDebug)) {
log.info("测试环境下不写入数据,urlType={},id={},requestJson={},responseJson={}", urlType, MaskedUtils.buildMaskedCommonString(id), requestJson, responseJson);
return;
}
Table table = null;
try {
table = connection.getTable(ThirdPartyBean.TABLE_NAME);
ThirdPartyBean thirdPartyDataRow = new ThirdPartyBean(id, urlType.name(), requestJson, responseJson);
Put put = thirdPartyDataRow.generatePut();
List<Get> rows = Lists.newArrayList(new Get(thirdPartyDataRow.findRowKey()));
List<String> contents = Lists.newArrayList(JSON.toJSONString(thirdPartyDataRow));
KafkaService.getInstance.process(table.existsAll(rows), ThirdPartyDataRow.TABLE_NAME.toString(), contents);
table.put(put);
} catch (Exception ex) {
log.error("Put the data error! urlType:{},id:{},requestJson:{},responseJson:{}", urlType, id, requestJson, responseJson, ex);
} finally {
IOUtils.closeQuietly(table);
}
log.info("数据源保存hbase完毕, id: {} , urlType: {} , 耗时: {} ", id, urlType, stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
}*/
/* public String loadInHBase(RequestUrlType urlType, String id) {
return loadInHBaseAndCheckTimeOut(urlType, id, 60);
}
public <T> T loadObjectInHBase(RequestUrlType requestUrlType, String id, TypeReference<T> clazz) {
String responseInHBase = loadInHBase(requestUrlType, id);
if (StringUtils.isNotBlank(responseInHBase)) {
T result = JSON.parseObject(responseInHBase, clazz);
if (result != null) {
log.info("直接从hbase拿到数据,responseInHBase:{}", responseInHBase);
}
return result;
}
return null;
}*/
/* public <T> T loadObjectInHBase(RequestUrlType requestUrlType, String id, Class<T> clazz) {
String responseInHBase = loadInHBase(requestUrlType, id);
if (StringUtils.isNotBlank(responseInHBase)) {
T result = JSON.parseObject(responseInHBase, clazz);
return result;
}
return null;
}*/
/*public JSONObject loadObjectInHbaseTimeOut(RequestUrlType urlType, String id, Integer days){
String data = loadInHBaseAndCheckTimeOut(urlType, id, days);
if(StringUtils.isNotBlank(data)){
return JSON.parseObject(data, JSONObject.class);
}
return null;
}*/
public String loadInHBaseAndCheckTimeOut(RequestUrlType urlType, String id, Integer days) {
return null;
}
/*public String loadInHBaseAndCheckTimeOut(RequestUrlType urlType, String id, Integer days) {
if (!HBaseConfig.readHBaseFirst.get().booleanValue()) {
log.info("不读取hbase哦噢噢噢噢");
return null;
}
QGPreconditions.checkArgument(StringUtils.isNotEmpty(id), QGExceptionType.COMMON_STRING_PARAM_IS_NULL);
QGPreconditions.checkArgument(urlType != null, QGExceptionType.COMMON_STRING_PARAM_IS_NULL);
Table table = null;
try {
table = connection.getTable(ThirdPartyDataRow.TABLE_NAME);
byte[] prefix = RowKeyTool.getMD5Prefix(id, 4);
if (prefix == null) {
log.error("The uuid is is error! urlType:{},id:{}", urlType, id);
return null;
}
Get get = new Get(Bytes.add(prefix, RowKeyTool.createRowKeyField(id), Bytes.toBytes("|" + urlType.name())));
Result result = table.get(get);
if (result == null || result.isEmpty()) {
return null;
}
byte[] responseMessage = result.getValue(ThirdPartyDataRow.COLUMN_FAMILY, ThirdPartyDataRow.RESPONSE_MESSAGE);
byte[] requestMessage = result.getValue(ThirdPartyDataRow.COLUMN_FAMILY, ThirdPartyDataRow.REQUEST_MESSAGE);
if (days != null && days.intValue() > 0) {
byte[] requestTime = result.getValue(ThirdPartyDataRow.COLUMN_FAMILY, ThirdPartyDataRow.REQUEST_TIME);
if (requestTime == null || requestTime.length == 0) {
return null;
}
long timeCreated = ClockUtils.hBaseParseTimestampFromDateTimeString(Bytes.toString(requestTime));
if (ClockUtils.getDaysBetween(timeCreated, ClockUtils.now()) > days) {
return null;
}
}
if (urlType.equals(HaoAnIdentityCheck)){
JSONObject jsonObject = new JSONObject();
jsonObject.put("requestMessage",Bytes.toString(requestMessage));
jsonObject.put("responseMessage",Bytes.toString(responseMessage));
return jsonObject.toJSONString();
}
log.info("从habse拿到数据 urlType:{},id:{}", urlType, id);
return Bytes.toString(responseMessage);
} catch (Exception ex) {
log.error("Get the data error! urlType:{},id:{}", urlType, id, ex);
return null;
} finally {
IOUtils.closeQuietly(table);
}
}
*/
/**
* lock
*
*/
public boolean lock(String lockKey, long timeOutSecond) {
long nano = System.nanoTime();
final Random r = new Random();
try {
while ((System.nanoTime() - nano) < 8000000000L) {
RedisConnection connection = redisTemplate.getConnectionFactory().getConnection();
boolean exits = connection.setNX(lockKey.getBytes(), new byte[0]);
connection.close();
//获取锁
if (exits) {
redisTemplate.expire(lockKey, timeOutSecond, TimeUnit.SECONDS);
return true;
}
try {
Thread.sleep(3, r.nextInt(500));
} catch (InterruptedException e) {
log.error("{}", e.getMessage(), e);
}
}
}catch (Exception e){
unlock(lockKey);
}
return false;
}
/**
* unlock
*
* @param lockKey
*/
public void unlock(String lockKey) {
//防止死锁
try {
RedisConnection connection = redisTemplate.getConnectionFactory().getConnection();
connection.del(lockKey.getBytes());
connection.close();
}catch (Exception e){
log.error("{}", e.getMessage(), e);
}
}
}
package cn.quantgroup.report.service.xyqbuser;
import cn.quantgroup.report.error.QGExceptionType;
import cn.quantgroup.report.mapper.xyqbuser.UserMapper;
import cn.quantgroup.report.domain.xyqbuser.User;
import cn.quantgroup.report.domain.xyqbuser.UserDetail;
import cn.quantgroup.report.error.QGPreconditions;
import cn.quantgroup.report.mapper.xyqbuser.UserDetailMapper;
import com.alibaba.fastjson.JSON;
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.stereotype.Service;
import java.util.List;
import java.util.Optional;
@Service
@Slf4j
public class XyqbUserService {
@Autowired
private UserDetailMapper userDetailMapper;
@Autowired
private UserMapper userMapper;
public Long findUserIdByIdentityNumberAndName(String identityNumber, String name) {
List<UserDetail> userDetailList = userDetailMapper.selectByIdentityNumber(identityNumber);
log.info("91征信匹配查询用户详细信息, identityNumber:{}, name:{}, 结果:{}", identityNumber, name, JSON.toJSONString(userDetailList));
QGPreconditions.checkArgument(CollectionUtils.isNotEmpty(userDetailList), QGExceptionType.XYQB_USER_NOT_EXSIT);
Optional<UserDetail> optional = userDetailList.parallelStream().filter(detail -> StringUtils.equals(detail.getName(), name)).findFirst();
QGPreconditions.checkArgument(optional.isPresent(), QGExceptionType.XYQB_USER_NOT_MATCH);
return optional.get().getUserId();
}
public User getUserByUUid(String uuid) {
return userMapper.selectByUuid(uuid);
}
public User getUserById(Long id) {
return userMapper.selectByPrimaryKey(id);
}
public UserDetail getUserDetailByUserID(Long userId) {
return userDetailMapper.selectByUserId(userId);
}
}
package cn.quantgroup.report.utils;
import cn.quantgroup.report.domain.tidbrisk.CallRecord3;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import javax.sql.DataSource;
import java.sql.*;
import java.util.List;
import static cn.quantgroup.report.utils.HikDataSourceTidbRisk.HIK_DATA_SOURCE_TIDB_RISK;
/**
* @Author fengjunkai
*/
@Slf4j
public class JdbcUtils {
/*
public static void prepareBatchUpdateExecuteTransactionid(String sql, List<CallRecord1> callRecord1s){
Connection conn = null;
PreparedStatement ps = null;
try {
conn = HIK_DATA_SOURCE.dataSourceJdbc.getConnection();
ps = conn.prepareStatement(sql);
conn.setAutoCommit(false);
// String sql = "INSERT INTO `call_record` (`request_url`, `transaction_id`, `uuid`, `url_type`, `code`, `created_at`, `updated_at`) VALUES (?,?,?,?,?,?,?)";
for (int i = 0; i < callRecord1s.size(); i++) {
CallRecord1 callRecord1 = callRecord1s.get(i);
ps.setString(1, callRecord1.getTransactionId());
ps.setString(2, callRecord1.getUuid());
ps.setString(3, callRecord1.getUrlType());
ps.setString(4, callRecord1.getCode());
ps.setTimestamp(5, callRecord1.getCreated_at());
ps.setTimestamp(6, callRecord1.getUpdated_at());
ps.addBatch();
}
ps.executeBatch();
conn.commit();
}catch(Exception e){
System.out.println("======执行sqlException异常======"+sql+"\r\n");
System.out.println("");
e.printStackTrace();
}finally {
close(conn, ps,null);
}
}
*/
private static void close(Connection conn, Statement st, ResultSet rs){
try {
if(rs!=null)
rs.close();
if(st!=null)
st.close();
if(conn!=null)
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
public static void batchUpdateExecuteCallRecord(DataSource dataSourceJdbc, String sql, List<CallRecord3> callRecord3List){
Connection conn = null;
PreparedStatement ps = null;
try {
//conn = dataSourceJdbc.getConnection(); //这样的慢,rewriteBatchedStatements=true不生效
conn = HIK_DATA_SOURCE_TIDB_RISK.dataSourceJdbc.getConnection();
ps = conn.prepareStatement(sql);
conn.setAutoCommit(false);
//"INSERT INTO `call_record` (`request_url`, `channel_type`, `channel_id`, `transaction_id`, `uuid`, `url_type`, `code`, `created_at`, `updated_at`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);"
for (int i = 0; i < callRecord3List.size(); i++) {
CallRecord3 callRecord3 = callRecord3List.get(i);
ps.setString(1, callRecord3.getRequestUrl());
ps.setString(2, callRecord3.getChannelType());
ps.setString(3, callRecord3.getChannelId());
ps.setString(4, callRecord3.getTransactionId());
ps.setString(5, callRecord3.getUuid());
ps.setString(6, callRecord3.getUrlType());
ps.setInt(7, callRecord3.getCode());
ps.setTimestamp(8, callRecord3.getCreatedAt());
ps.setTimestamp(9, callRecord3.getUpdatedAt());
ps.addBatch();
}
ps.executeBatch();
conn.commit();
}catch(Exception e){
log.error("======执行batchUpdateExecuteCallRecord异常======"+sql+"\r\n",e);
log.error("方法batchUpdateExecuteCallRecord异常, DATA: {} \n", JSON.toJSON(callRecord3List));
e.printStackTrace();
}finally {
close(conn, ps,null);
}
}
public static void batchInsertExecuteCallRecord(String sql, List<CallRecord3> callRecord3List){
Connection conn = null;
PreparedStatement ps = null;
try {
conn = HIK_DATA_SOURCE_TIDB_RISK.dataSourceJdbc.getConnection();
ps = conn.prepareStatement(sql);
conn.setAutoCommit(false);
for (int i = 0; i < callRecord3List.size(); i++) {
CallRecord3 callRecord3 = callRecord3List.get(i);
//delete from call_record where id=? AND transaction_id =?
ps.setLong(1, callRecord3.getId());
ps.setString(2, callRecord3.getTransactionId());
ps.addBatch();
}
ps.executeBatch();
conn.commit();
}catch(Exception e){
log.error("======执行batchInsertExecuteCallRecord异常======"+sql+"\r\n",e);
log.error("方法batchInsertExecuteCallRecord异常, DATA: {} \n", JSON.toJSON(callRecord3List));
e.printStackTrace();
}finally {
close(conn, ps,null);
}
}
}
......@@ -2,33 +2,41 @@ package cn.quantgroup.report.utils;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import javax.sql.DataSource;
/**
* Created by renfeng on 2019/4/22.
*/
public enum HikDataSourceTidbRisk {
HIK_DATA_SOURCE_TIDB_RISK;
@Slf4j
public enum RenHangHikDataSource {
HIK_DATA_SOURCE_RENHANG;
@Value("${db.renhang.rc_sync_guangda.fullurl}")
private String datasourceJdbcUrl;
@Value("${db.renhang.rc_sync_guangda.username}")
private String datasourceUsername;
@Value("${db.renhang.rc_sync_guangda.password}")
private String datasourcePassword;
public DataSource dataSourceJdbc;
HikDataSourceTidbRisk(){
RenHangHikDataSource(){
if(dataSourceJdbc==null){
System.out.println("======tidb.risk_datasource创建数据库连接dataSource1======");
HikariConfig config = new HikariConfig();
config.setJdbcUrl("jdbc:mysql://fengkong-tidb.quantgroups.com:4010/risk_datasource?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true");
config.setUsername("risk_datasource_w");
config.setPassword("50GjQLd6hUOSeTMB");
//"jdbc:mysql://fengkong-tidb.quantgroups.com:4010/risk_datasource?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true"
config.setJdbcUrl(datasourceJdbcUrl.substring(0, datasourceJdbcUrl.indexOf("?"))+"?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true");
config.setUsername(datasourceUsername);
config.setPassword(datasourcePassword);
config.setDriverClassName("com.mysql.jdbc.Driver");
config.setMaximumPoolSize(50);
config.setMinimumIdle(20);
config.setMaximumPoolSize(10);
config.setMinimumIdle(5);
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
dataSourceJdbc = new HikariDataSource(config);
System.out.println("tidb.risk_datasource创建数据库连接完毕");
System.out.println("rc_sync_guangda创建数据库连接完毕");
}
}
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.quantgroup.report.mapper.master.AccountPOMapper">
<resultMap id="BaseResultMap" type="cn.quantgroup.report.domain.master.AccountPO">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<result column="id" jdbcType="INTEGER" property="id" />
<result column="source_name" jdbcType="VARCHAR" property="sourceName" />
<result column="blance" jdbcType="DECIMAL" property="blance" />
<result column="thershold" jdbcType="DECIMAL" property="thershold" />
<result column="status" jdbcType="VARCHAR" property="status" />
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
id, source_name, blance, thershold, `status`
</sql>
<select id="selectByExample" parameterType="cn.quantgroup.report.domain.master.AccountPO" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<include refid="Base_Column_List"/>
from account
<trim prefix="where" prefixOverrides="and">
<if test="id != null">
and id = #{id,jdbcType=INTEGER}
</if>
<if test="sourceName != null">
and source_name = #{sourceName,jdbcType=VARCHAR}
</if>
</trim>
</select>
<update id="updateByParams" parameterType="cn.quantgroup.report.domain.master.DataPriceConfigPO">
update account
<set>
<if test="blance != null">
blance = #{blance,jdbcType=DECIMAL}
</if>
</set>
<trim prefix="where" prefixOverrides="and">
<if test="id != null">
and id = #{id,jdbcType=INTEGER}
</if>
<if test="sourceName != null">
and source_name = #{sourceName,jdbcType=VARCHAR}
</if>
</trim>
</update>
<insert id="insert" parameterType="cn.quantgroup.report.domain.master.AccountPO">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into account (id, source_name, blance, thershold,
`status`)
values (#{id,jdbcType=INTEGER}, #{sourceName,jdbcType=VARCHAR}, #{blance,jdbcType=DECIMAL}, #{thershold,jdbcType=DECIMAL},
#{status,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="cn.quantgroup.report.domain.master.AccountPO">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into account
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="sourceName != null">
source_name,
</if>
<if test="blance != null">
blance,
</if>
<if test="thershold != null">
thershold,
</if>
<if test="status != null">
`status`,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="sourceName != null">
#{sourceName,jdbcType=VARCHAR},
</if>
<if test="blance != null">
#{blance,jdbcType=DECIMAL},
</if>
<if test="thershold != null">
#{thershold,jdbcType=DECIMAL},
</if>
<if test="status != null">
#{status,jdbcType=VARCHAR},
</if>
</trim>
</insert>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.quantgroup.report.mapper.master.ApiRequestLogPOMapper">
<resultMap id="BaseResultMap" type="cn.quantgroup.report.domain.master.ApiRequestLogPO">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<result column="id" jdbcType="BIGINT" property="id" />
<result column="url_type" jdbcType="VARCHAR" property="urlType" />
<result column="res_code" jdbcType="VARCHAR" property="resCode" />
<result column="res_msg" jdbcType="VARCHAR" property="resMsg" />
<result column="hit_flag" jdbcType="VARCHAR" property="hitFlag" />
<result column="time_elapse" jdbcType="INTEGER" property="timeElapse" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
</resultMap>
<insert id="insert" parameterType="cn.quantgroup.report.domain.master.ApiRequestLogPO">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into api_request_log_${suffix} (id, url_type, res_code,
res_msg, hit_flag, time_elapse, create_time
)
values (#{id,jdbcType=BIGINT}, #{urlType,jdbcType=VARCHAR}, #{resCode,jdbcType=VARCHAR},
#{resMsg,jdbcType=VARCHAR}, #{hitFlag,jdbcType=VARCHAR}, #{timeElapse,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" parameterType="cn.quantgroup.report.domain.master.ApiRequestLogPO">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into api_request_log_${suffix}
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="urlType != null">
url_type,
</if>
<if test="resCode != null">
res_code,
</if>
<if test="resMsg != null">
res_msg,
</if>
<if test="hitFlag != null">
hit_flag,
</if>
<if test="timeElapse != null">
time_elapse,
</if>
<if test="createTime != null">
create_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="urlType != null">
#{urlType,jdbcType=VARCHAR},
</if>
<if test="resCode != null">
#{resCode,jdbcType=VARCHAR},
</if>
<if test="resMsg != null">
#{resMsg,jdbcType=VARCHAR},
</if>
<if test="hitFlag != null">
#{hitFlag,jdbcType=VARCHAR},
</if>
<if test="timeElapse != null">
#{timeElapse,jdbcType=INTEGER},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.quantgroup.report.mapper.master.ApplyLoanInfoDbMapper">
<resultMap id="ApplyLoanInfoBaseResultMap" type="cn.quantgroup.report.domain.baihang.ApplyLoanInfo">
<result column="recordId" jdbcType="VARCHAR" property="record_id"/>
<result column="reqID" jdbcType="VARCHAR" property="req_id"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="pid" jdbcType="VARCHAR" property="pid"/>
<result column="mobile" jdbcType="VARCHAR" property="mobile"/>
<result column="queryReason" jdbcType="INTEGER" property="queryReason"/>
<result column="guaranteeType" jdbcType="INTEGER" property="guaranteeType"/>
<result column="loanPurpose" jdbcType="INTEGER" property="loanPurpose"/>
<result column="customType" jdbcType="INTEGER" property="customType"/>
<result column="applyAmount" jdbcType="DECIMAL" property="applyAmount"/>
<result column="loanId" jdbcType="VARCHAR" property="loanId"/>
</resultMap>
<select id="saveApplyLoanInfoRecordLog" parameterType="cn.quantgroup.report.domain.baihang.ApplyLoanInfo">
insert into apply_loan_info (record_id, req_id, name, pid,mobile,query_reason,guarantee_type,loan_purpose,custom_type,apply_amount)
VALUES (#{record_Id},#{reqID},#{name},#{pid},#{mobile},#{queryReason},#{guaranteeType},#{loanPurpose},#{customType},#{applyAmount})
</select>
<!--1.根据loan_application_history_id查询工具报送的bean 申请A1 2019.10.20-->
<select id="findApplyInfoA1ByHistoryId" resultType="cn.quantgroup.report.domain.baihang.ApplyLoanInfoZhuDai">
select
a.id reqID
,'A' opCode
,DATE_FORMAT(now(),'%Y-%m-%dT%H:%i:%S') uploadTs
,'1' isFinTechAgencyBusiness
,DATE_FORMAT(case when i.created_at is null and h.created_at &lt;=f.created_at then h.created_at
when i.created_at is null and h.created_at>f.created_at then f.created_at
else i.created_at end,'%Y-%m-%dT%H:%i:%S') as applyDate
,if(d.order_no is null,a.loan_application_history_id,d.order_no) applyId
,'1' applyType
,b.name name
,'1' idType
,b.id_no pid
,b.phone_no mobile
,b.email emailAddress
,case when j.education=1 then '10'
when j.education=2 then '20'
when j.education=3 then '30'
when j.education in (4,6) then '40'
when j.education=5 then '50'
when j.education in (7,8) then '60'
else '70' end eduBackground
,'500' degree
,'1' guaranteeType
,'1' loanPurpose
,'99' customType
,'-1' applyAmount
,'8' livingCondition
,case when j.marry_status=1 then '10'
when j.marry_status=2 then '20'
when j.marry_status=4 then '30'
when j.marry_status=3 then '40'
else '90' end marriageStatus
from xyqb_i_loan_application_manifest_history a
left join xyqb_user_i_user_detail b on a.user_id=b.user_id
left join xyqb_i_loan_account_ext c on a.loan_application_history_id=c.loan_id
left join xyqb_i_apply_quota_record d on c.order_no=d.order_no
left join xyqb_i_loan_submit_info f on a.loan_application_history_id=f.loan_id
left join xyqb_i_loan_application_history h on a.loan_application_history_id=h.id
/* 2020.01.06表迁移 left join xyqb_i_quota_credit i on d.order_no=i.order_no */
left join business_flow_i_apply_list i on d.order_no=i.apply_no
left join xyqb_i_loan_base_info j on a.loan_application_history_id=j.loan_id
where a.funding_corp_id in (420,520,580,650,670,810,240,640,700, 880,890)
and a.contract_term not in (2,3)
and a.transaction_status in (2,5)
AND a.loan_application_history_id=#{loanApplicationHistoryId}
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.quantgroup.report.mapper.master.CommonApiReqestEventMapper">
<insert id="insert" parameterType="cn.quantgroup.report.domain.master.CommonWithBillingApiRequestEvent">
insert into common_request_event(user_id,time_created,mills,response_code,response_message,request_url_type,is_billing) values(#{userId},#{timeCreated},#{mills},#{responseCode},#{responseMessage},#{requestUrlType},#{isBilling})
</insert>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.quantgroup.report.mapper.master.CostRecordPOMapper">
<resultMap id="BaseResultMap" type="cn.quantgroup.report.domain.master.CostRecordPO">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<result column="id" jdbcType="INTEGER" property="id" />
<result column="source_name" jdbcType="VARCHAR" property="sourceName" />
<result column="url_type" jdbcType="VARCHAR" property="urlType" />
<result column="invoke_times" jdbcType="INTEGER" property="invokeTimes" />
<result column="cost" jdbcType="DECIMAL" property="cost" />
<result column="balance" jdbcType="DECIMAL" property="balance" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
</resultMap>
<insert id="insert" parameterType="cn.quantgroup.report.domain.master.CostRecordPO">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into cost_record (id, source_name, url_type,
invoke_times, cost, balance,
create_time)
values (#{id,jdbcType=INTEGER}, #{sourceName,jdbcType=VARCHAR}, #{urlType,jdbcType=VARCHAR},
#{invokeTimes,jdbcType=INTEGER}, #{cost,jdbcType=DECIMAL}, #{balance,jdbcType=DECIMAL},
#{createTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="cn.quantgroup.report.domain.master.CostRecordPO">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into cost_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="sourceName != null">
source_name,
</if>
<if test="urlType != null">
url_type,
</if>
<if test="invokeTimes != null">
invoke_times,
</if>
<if test="cost != null">
cost,
</if>
<if test="balance != null">
balance,
</if>
<if test="createTime != null">
create_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="sourceName != null">
#{sourceName,jdbcType=VARCHAR},
</if>
<if test="urlType != null">
#{urlType,jdbcType=VARCHAR},
</if>
<if test="invokeTimes != null">
#{invokeTimes,jdbcType=INTEGER},
</if>
<if test="cost != null">
#{cost,jdbcType=DECIMAL},
</if>
<if test="balance != null">
#{balance,jdbcType=DECIMAL},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.quantgroup.report.mapper.master.DataPriceConfigPOMapper">
<resultMap id="BaseResultMap" type="cn.quantgroup.report.domain.master.DataPriceConfigPO">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<result column="id" jdbcType="INTEGER" property="id" />
<result column="source_name" jdbcType="VARCHAR" property="sourceName" />
<result column="data_type" jdbcType="VARCHAR" property="dataType" />
<result column="url_type" jdbcType="VARCHAR" property="urlType" />
<result column="price" jdbcType="DECIMAL" property="price" />
<result column="frequency" jdbcType="INTEGER" property="frequency" />
<result column="status" jdbcType="VARCHAR" property="status" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
</resultMap>
<sql id="Base_Column_List">
id, source_name, data_type, url_type, price, frequency
</sql>
<select id="queryByParams" resultMap="BaseResultMap" parameterType="cn.quantgroup.report.domain.master.DataPriceConfigPO">
select
<include refid="Base_Column_List"/>
from data_price_config
<trim prefix="where" prefixOverrides="and">
<if test="id != null">
and id = #{id,jdbcType=INTEGER}
</if>
<if test="sourceName != null">
and source_name = #{sourceName,jdbcType=VARCHAR}
</if>
<if test="dataType != null">
and data_type = #{dataType,jdbcType=VARCHAR}
</if>
<if test="urlType != null">
and url_type = #{urlType,jdbcType=VARCHAR}
</if>
<if test="status != null">
and status = #{status,jdbcType=VARCHAR}
</if>
</trim>
</select>
<insert id="insert" parameterType="cn.quantgroup.report.domain.master.DataPriceConfigPO">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into data_price_config (id, source_name, data_type,
url_type, price, frequency, `status`,
create_time)
values (#{id,jdbcType=INTEGER}, #{sourceName,jdbcType=VARCHAR}, #{dataType,jdbcType=VARCHAR},
#{urlType,jdbcType=VARCHAR}, #{price,jdbcType=DECIMAL},#{frequency,jdbcType=INTEGER}, #{status,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="cn.quantgroup.report.domain.master.DataPriceConfigPO">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into data_price_config
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="sourceName != null">
source_name,
</if>
<if test="dataType != null">
data_type,
</if>
<if test="urlType != null">
url_type,
</if>
<if test="price != null">
price,
</if>
<if test="frequency != null">
frequency,
</if>
<if test="status != null">
`status`,
</if>
<if test="createTime != null">
create_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="sourceName != null">
#{sourceName,jdbcType=VARCHAR},
</if>
<if test="dataType != null">
#{dataType,jdbcType=VARCHAR},
</if>
<if test="urlType != null">
#{urlType,jdbcType=VARCHAR},
</if>
<if test="price != null">
#{price,jdbcType=DECIMAL},
</if>
<if test="frequency != null">
#{frequency,jdbcType=INTEGER},
</if>
<if test="status != null">
#{status,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.quantgroup.report.mapper.master.DataSourceCacheConfigMapper">
<resultMap id="BaseResultMap" type="cn.quantgroup.report.domain.master.DataSourceCacheConfig">
<result column="product_type" jdbcType="VARCHAR" property="productType" />
<result column="product_name" jdbcType="VARCHAR" property="productName" />
<result column="product_cache_time" jdbcType="INTEGER" property="productCacheTime" />
<result column="product_cache_time" jdbcType="INTEGER" property="productCacheTime" />
<result column="product_test_cache_time" jdbcType="INTEGER" property="productTestCacheTime" />
<result column="data_source_name" jdbcType="VARCHAR" property="dataSourceName" />
</resultMap>
<select id="findAllCacheConfig" parameterType="cn.quantgroup.report.domain.master.DataSourceCacheConfig" resultMap="BaseResultMap">
select * from data_source_cache_config where enable = true;
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.quantgroup.report.mapper.master.DsSpecialUserHandleMapper">
<resultMap id="selectResultMap" type="cn.quantgroup.report.domain.master.DsSpecialUserHandle">
<result column="method_name" jdbcType="VARCHAR" property="methodName" />
<result column="service_name" jdbcType="VARCHAR" property="serviceName" />
<result column="uuid" jdbcType="VARCHAR" property="uuid" />
</resultMap>
<insert id="insert" parameterType="cn.quantgroup.report.domain.master.DsSpecialUserHandle">
insert into ds_special_user_handle(method_name,service_name,uuid)
values(#{methodName,jdbcType=VARCHAR},#{serviceName,jdbcType=VARCHAR},#{uuid,jdbcType=VARCHAR})
</insert>
<select id="selectAllByEnable" parameterType="cn.quantgroup.report.domain.master.DsSpecialUserHandle" resultMap="selectResultMap">
select c.method_name, c.service_name, c.uuid from ds_special_user_handle c where c.enable=true;
</select>
<update id="updateNotEnableByParams" parameterType="cn.quantgroup.report.domain.master.DsSpecialUserHandle">
update ds_special_user_handle c
set c.enable=false
where c.enable=true
<if test="methodName != null">
AND c.method_name = #{methodName,jdbcType=VARCHAR}
</if>
<if test="serviceName != null">
AND c.service_name = #{serviceName,jdbcType=VARCHAR}
</if>
<if test="uuid != null">
AND c.uuid = #{uuid,jdbcType=VARCHAR}
</if>
</update>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.quantgroup.report.mapper.master.ElevenBeiApiReqestEventMapper">
<insert id="insert" parameterType="cn.quantgroup.report.domain.master.ElevenBeiApiRequestEvent">
insert into eleven_bei_api_request_event(identity_number,time_created,mills,response_code,response_message,request_url_type,is_billing) values(#{identity},#{timeCreated},#{mills},#{responseCode},#{responseMessage},#{requestUrlType},#{isBilling})
</insert>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.quantgroup.report.mapper.master.IntelliCreditLoanIssueMapper">
<resultMap id="BaseResultMap" type="cn.quantgroup.report.domain.master.IntelliCreditLoanIssue">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="pid" jdbcType="VARCHAR" property="pid"/>
<result column="mobile" jdbcType="VARCHAR" property="mobile"/>
<result column="loan_type" jdbcType="VARCHAR" property="loanType"/>
<result column="account_open_date" jdbcType="BIGINT" property="accountOpenDate"/>
<result column="apply_date" jdbcType="BIGINT" property="applyDate"/>
<result column="issue_date" jdbcType="BIGINT" property="issueDate"/>
<result column="loan_amount" jdbcType="DECIMAL" property="loanAmount"/>
<result column="loan_id" jdbcType="BIGINT" property="loanId"/>
<result column="total_term" jdbcType="INTEGER" property="totalTerm"/>
<result column="first_repayment_date" jdbcType="BIGINT" property="firstRepaymentDate"/>
<result column="term_period" jdbcType="INTEGER" property="termPeriod"/>
<result column="plan_count" jdbcType="INTEGER" property="planCount"/>
<result column="status" jdbcType="TINYINT" property="status"/>
<result column="time_created" jdbcType="TIMESTAMP" property="timeCreated"/>
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs"
type="cn.quantgroup.report.domain.master.IntelliCreditLoanIssue">
<result column="device" jdbcType="LONGVARCHAR" property="device"/>
</resultMap>
<sql id="Base_Column_List">
id, name, pid, mobile, loan_type, account_open_date, apply_date, issue_date, loan_amount,
loan_id, total_term, first_repayment_date, term_period, plan_count, status, time_created
</sql>
<sql id="Blob_Column_List">
device
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="ResultMapWithBLOBs">
select
<include refid="Base_Column_List"/>
,
<include refid="Blob_Column_List"/>
from intelli_credit_loan_issue
where id = #{id,jdbcType=BIGINT}
</select>
<select id="selectUndoneByBeginId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from intelli_credit_loan_issue
where id > #{id,jdbcType=BIGINT} and `status` > 1
</select>
<insert id="insert" parameterType="cn.quantgroup.report.domain.master.IntelliCreditLoanIssue">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
SELECT LAST_INSERT_ID()
</selectKey>
insert into intelli_credit_loan_issue (name, pid, mobile,
loan_type, account_open_date, apply_date,
issue_date, loan_amount, loan_id,
total_term, first_repayment_date, term_period,
plan_count, status, time_created,
device)
values (#{name,jdbcType=VARCHAR}, #{pid,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR},
#{loanType,jdbcType=VARCHAR}, #{accountOpenDate,jdbcType=BIGINT}, #{applyDate,jdbcType=BIGINT},
#{issueDate,jdbcType=BIGINT}, #{loanAmount,jdbcType=DECIMAL}, #{loanId,jdbcType=BIGINT},
#{totalTerm,jdbcType=INTEGER}, #{firstRepaymentDate,jdbcType=INTEGER}, #{termPeriod,jdbcType=INTEGER},
#{planCount,jdbcType=INTEGER}, #{status,jdbcType=TINYINT}, #{timeCreated,jdbcType=TIMESTAMP},
#{device,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="cn.quantgroup.report.domain.master.IntelliCreditLoanIssue">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
SELECT LAST_INSERT_ID()
</selectKey>
insert into intelli_credit_loan_issue
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null">
name,
</if>
<if test="pid != null">
pid,
</if>
<if test="mobile != null">
mobile,
</if>
<if test="loanType != null">
loan_type,
</if>
<if test="accountOpenDate != null">
account_open_date,
</if>
<if test="applyDate != null">
apply_date,
</if>
<if test="issueDate != null">
issue_date,
</if>
<if test="loanAmount != null">
loan_amount,
</if>
<if test="loanId != null">
loan_id,
</if>
<if test="totalTerm != null">
total_term,
</if>
<if test="firstRepaymentDate != null">
first_repayment_date,
</if>
<if test="termPeriod != null">
term_period,
</if>
<if test="planCount != null">
plan_count,
</if>
<if test="status != null">
status,
</if>
<if test="timeCreated != null">
time_created,
</if>
<if test="device != null">
device,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="pid != null">
#{pid,jdbcType=VARCHAR},
</if>
<if test="mobile != null">
#{mobile,jdbcType=VARCHAR},
</if>
<if test="loanType != null">
#{loanType,jdbcType=VARCHAR},
</if>
<if test="accountOpenDate != null">
#{accountOpenDate,jdbcType=BIGINT},
</if>
<if test="applyDate != null">
#{applyDate,jdbcType=BIGINT},
</if>
<if test="issueDate != null">
#{issueDate,jdbcType=BIGINT},
</if>
<if test="loanAmount != null">
#{loanAmount,jdbcType=DECIMAL},
</if>
<if test="loanId != null">
#{loanId,jdbcType=BIGINT},
</if>
<if test="totalTerm != null">
#{totalTerm,jdbcType=INTEGER},
</if>
<if test="firstRepaymentDate != null">
#{firstRepaymentDate,jdbcType=INTEGER},
</if>
<if test="termPeriod != null">
#{termPeriod,jdbcType=INTEGER},
</if>
<if test="planCount != null">
#{planCount,jdbcType=INTEGER},
</if>
<if test="status != null">
#{status,jdbcType=TINYINT},
</if>
<if test="timeCreated != null">
#{timeCreated,jdbcType=TIMESTAMP},
</if>
<if test="device != null">
#{device,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective"
parameterType="cn.quantgroup.report.domain.master.IntelliCreditLoanIssue">
update intelli_credit_loan_issue
<set>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="pid != null">
pid = #{pid,jdbcType=VARCHAR},
</if>
<if test="mobile != null">
mobile = #{mobile,jdbcType=VARCHAR},
</if>
<if test="loanType != null">
loan_type = #{loanType,jdbcType=VARCHAR},
</if>
<if test="accountOpenDate != null">
account_open_date = #{accountOpenDate,jdbcType=BIGINT},
</if>
<if test="applyDate != null">
apply_date = #{applyDate,jdbcType=BIGINT},
</if>
<if test="issueDate != null">
issue_date = #{issueDate,jdbcType=BIGINT},
</if>
<if test="loanAmount != null">
loan_amount = #{loanAmount,jdbcType=DECIMAL},
</if>
<if test="loanId != null">
loan_id = #{loanId,jdbcType=BIGINT},
</if>
<if test="totalTerm != null">
total_term = #{totalTerm,jdbcType=INTEGER},
</if>
<if test="firstRepaymentDate != null">
first_repayment_date = #{firstRepaymentDate,jdbcType=INTEGER},
</if>
<if test="termPeriod != null">
term_period = #{termPeriod,jdbcType=INTEGER},
</if>
<if test="planCount != null">
plan_count = #{planCount,jdbcType=INTEGER},
</if>
<if test="status != null">
status = #{status,jdbcType=TINYINT},
</if>
<if test="timeCreated != null">
time_created = #{timeCreated,jdbcType=TIMESTAMP},
</if>
<if test="device != null">
device = #{device,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKeyWithBLOBs"
parameterType="cn.quantgroup.report.domain.master.IntelliCreditLoanIssue">
UPDATE intelli_credit_loan_issue
SET name = #{name,jdbcType=VARCHAR},
pid = #{pid,jdbcType=VARCHAR},
mobile = #{mobile,jdbcType=VARCHAR},
loan_type = #{loanType,jdbcType=VARCHAR},
account_open_date = #{accountOpenDate,jdbcType=BIGINT},
apply_date = #{applyDate,jdbcType=BIGINT},
issue_date = #{issueDate,jdbcType=BIGINT},
loan_amount = #{loanAmount,jdbcType=DECIMAL},
loan_id = #{loanId,jdbcType=BIGINT},
total_term = #{totalTerm,jdbcType=INTEGER},
first_repayment_date = #{firstRepaymentDate,jdbcType=INTEGER},
term_period = #{termPeriod,jdbcType=INTEGER},
plan_count = #{planCount,jdbcType=INTEGER},
status = #{status,jdbcType=TINYINT},
time_created = #{timeCreated,jdbcType=TIMESTAMP},
device = #{device,jdbcType=LONGVARCHAR}
WHERE id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="cn.quantgroup.report.domain.master.IntelliCreditLoanIssue">
UPDATE intelli_credit_loan_issue
SET name = #{name,jdbcType=VARCHAR},
pid = #{pid,jdbcType=VARCHAR},
mobile = #{mobile,jdbcType=VARCHAR},
loan_type = #{loanType,jdbcType=VARCHAR},
account_open_date = #{accountOpenDate,jdbcType=BIGINT},
apply_date = #{applyDate,jdbcType=BIGINT},
issue_date = #{issueDate,jdbcType=BIGINT},
loan_amount = #{loanAmount,jdbcType=DECIMAL},
loan_id = #{loanId,jdbcType=BIGINT},
total_term = #{totalTerm,jdbcType=INTEGER},
first_repayment_date = #{firstRepaymentDate,jdbcType=INTEGER},
term_period = #{termPeriod,jdbcType=INTEGER},
plan_count = #{planCount,jdbcType=INTEGER},
status = #{status,jdbcType=TINYINT},
time_created = #{timeCreated,jdbcType=TIMESTAMP}
WHERE id = #{id,jdbcType=BIGINT}
</update>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.quantgroup.report.mapper.master.IntelliCreditLoanTraceMapper">
<resultMap id="BaseResultMap" type="cn.quantgroup.report.domain.master.IntelliCreditLoanTrace">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="loan_id" jdbcType="BIGINT" property="loanId"/>
<result column="repayment_plan_id" jdbcType="BIGINT" property="repaymentPlanId"/>
<result column="term_no" jdbcType="INTEGER" property="termNo"/>
<result column="term_status" jdbcType="VARCHAR" property="termStatus"/>
<result column="target_repayment_date" jdbcType="BIGINT" property="targetRepaymentDate"/>
<result column="real_repayment_date" jdbcType="BIGINT" property="realRepaymentDate"/>
<result column="target_repayment" jdbcType="DECIMAL" property="targetRepayment"/>
<result column="real_repayment" jdbcType="DECIMAL" property="realRepayment"/>
<result column="status_confirm_at" jdbcType="BIGINT" property="statusConfirmAt"/>
<result column="overdue_status" jdbcType="VARCHAR" property="overdueStatus"/>
<result column="status" jdbcType="TINYINT" property="status"/>
</resultMap>
<sql id="Base_Column_List">
id, loan_id, repayment_plan_id, term_no, term_status, target_repayment_date, real_repayment_date,
target_repayment, real_repayment, status_confirm_at, overdue_status, status
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from intelli_credit_loan_trace
where id = #{id,jdbcType=BIGINT}
</select>
<insert id="insert" parameterType="cn.quantgroup.report.domain.master.IntelliCreditLoanTrace">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
SELECT LAST_INSERT_ID()
</selectKey>
insert into intelli_credit_loan_trace (loan_id, repayment_plan_id, term_no,
term_status, target_repayment_date, real_repayment_date,
target_repayment, real_repayment, status_confirm_at,
overdue_status, status)
values (#{loanId,jdbcType=BIGINT}, #{repaymentPlanId,jdbcType=BIGINT}, #{termNo,jdbcType=INTEGER},
#{termStatus,jdbcType=VARCHAR}, #{targetRepaymentDate,jdbcType=BIGINT}, #{realRepaymentDate,jdbcType=BIGINT},
#{targetRepayment,jdbcType=DECIMAL}, #{realRepayment,jdbcType=DECIMAL}, #{statusConfirmAt,jdbcType=BIGINT},
#{overdueStatus,jdbcType=VARCHAR}, #{status,jdbcType=TINYINT})
</insert>
<insert id="insertSelective" parameterType="cn.quantgroup.report.domain.master.IntelliCreditLoanTrace">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
SELECT LAST_INSERT_ID()
</selectKey>
insert into intelli_credit_loan_trace
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="loanId != null">
loan_id,
</if>
<if test="repaymentPlanId != null">
repayment_plan_id,
</if>
<if test="termNo != null">
term_no,
</if>
<if test="termStatus != null">
term_status,
</if>
<if test="targetRepaymentDate != null">
target_repayment_date,
</if>
<if test="realRepaymentDate != null">
real_repayment_date,
</if>
<if test="targetRepayment != null">
target_repayment,
</if>
<if test="realRepayment != null">
real_repayment,
</if>
<if test="statusConfirmAt != null">
status_confirm_at,
</if>
<if test="overdueStatus != null">
overdue_status,
</if>
<if test="status != null">
status,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="loanId != null">
#{loanId,jdbcType=BIGINT},
</if>
<if test="repaymentPlanId != null">
#{repaymentPlanId,jdbcType=BIGINT},
</if>
<if test="termNo != null">
#{termNo,jdbcType=INTEGER},
</if>
<if test="termStatus != null">
#{termStatus,jdbcType=VARCHAR},
</if>
<if test="targetRepaymentDate != null">
#{targetRepaymentDate,jdbcType=BIGINT},
</if>
<if test="realRepaymentDate != null">
#{realRepaymentDate,jdbcType=BIGINT},
</if>
<if test="targetRepayment != null">
#{targetRepayment,jdbcType=DECIMAL},
</if>
<if test="realRepayment != null">
#{realRepayment,jdbcType=DECIMAL},
</if>
<if test="statusConfirmAt != null">
#{statusConfirmAt,jdbcType=BIGINT},
</if>
<if test="overdueStatus != null">
#{overdueStatus,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=TINYINT},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective"
parameterType="cn.quantgroup.report.domain.master.IntelliCreditLoanTrace">
update intelli_credit_loan_trace
<set>
<if test="loanId != null">
loan_id = #{loanId,jdbcType=BIGINT},
</if>
<if test="repaymentPlanId != null">
repayment_plan_id = #{repaymentPlanId,jdbcType=BIGINT},
</if>
<if test="termNo != null">
term_no = #{termNo,jdbcType=INTEGER},
</if>
<if test="termStatus != null">
term_status = #{termStatus,jdbcType=VARCHAR},
</if>
<if test="targetRepaymentDate != null">
target_repayment_date = #{targetRepaymentDate,jdbcType=BIGINT},
</if>
<if test="realRepaymentDate != null">
real_repayment_date = #{realRepaymentDate,jdbcType=BIGINT},
</if>
<if test="targetRepayment != null">
target_repayment = #{targetRepayment,jdbcType=DECIMAL},
</if>
<if test="realRepayment != null">
real_repayment = #{realRepayment,jdbcType=DECIMAL},
</if>
<if test="statusConfirmAt != null">
status_confirm_at = #{statusConfirmAt,jdbcType=BIGINT},
</if>
<if test="overdueStatus != null">
overdue_status = #{overdueStatus,jdbcType=VARCHAR},
</if>
<if test="status != null">
status = #{status,jdbcType=TINYINT},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="cn.quantgroup.report.domain.master.IntelliCreditLoanTrace">
UPDATE intelli_credit_loan_trace
SET loan_id = #{loanId,jdbcType=BIGINT},
repayment_plan_id = #{repaymentPlanId,jdbcType=BIGINT},
term_no = #{termNo,jdbcType=INTEGER},
term_status = #{termStatus,jdbcType=VARCHAR},
target_repayment_date = #{targetRepaymentDate,jdbcType=BIGINT},
real_repayment_date = #{realRepaymentDate,jdbcType=BIGINT},
target_repayment = #{targetRepayment,jdbcType=DECIMAL},
real_repayment = #{realRepayment,jdbcType=DECIMAL},
status_confirm_at = #{statusConfirmAt,jdbcType=BIGINT},
overdue_status = #{overdueStatus,jdbcType=VARCHAR},
status = #{status,jdbcType=TINYINT}
WHERE id = #{id,jdbcType=BIGINT}
</update>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.quantgroup.report.mapper.master.IntelliCreditRequestEventMapper">
<resultMap id="BaseResultMap" type="cn.quantgroup.report.domain.master.IntelliCreditRequestEvent">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="uuid" jdbcType="VARCHAR" property="uuid" />
<result column="time_created" jdbcType="TIMESTAMP" property="timeCreated" />
<result column="http_code" jdbcType="INTEGER" property="httpCode" />
<result column="response_message" jdbcType="VARCHAR" property="responseMessage" />
<result column="mills" jdbcType="INTEGER" property="mills" />
</resultMap>
<sql id="Base_Column_List">
id, loan_id, time_created, http_code, response_message, mills
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from intelli_credit_request_event
where id = #{id,jdbcType=BIGINT}
</select>
<insert id="insert" parameterType="cn.quantgroup.report.domain.master.IntelliCreditRequestEvent">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
SELECT LAST_INSERT_ID()
</selectKey>
insert into intelli_credit_request_event (uuid, time_created, http_code,
response_message, mills)
values (#{uuid,jdbcType=VARCHAR}, #{timeCreated,jdbcType=TIMESTAMP}, #{httpCode,jdbcType=INTEGER},
#{responseMessage,jdbcType=VARCHAR}, #{mills,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="cn.quantgroup.report.domain.master.IntelliCreditRequestEvent">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
SELECT LAST_INSERT_ID()
</selectKey>
insert into intelli_credit_request_event
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="loanId != null">
loan_id,
</if>
<if test="timeCreated != null">
time_created,
</if>
<if test="httpCode != null">
http_code,
</if>
<if test="responseMessage != null">
response_message,
</if>
<if test="mills != null">
mills,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="loanId != null">
#{loanId,jdbcType=BIGINT},
</if>
<if test="timeCreated != null">
#{timeCreated,jdbcType=TIMESTAMP},
</if>
<if test="httpCode != null">
#{httpCode,jdbcType=INTEGER},
</if>
<if test="responseMessage != null">
#{responseMessage,jdbcType=VARCHAR},
</if>
<if test="mills != null">
#{mills,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="cn.quantgroup.report.domain.master.IntelliCreditRequestEvent">
update intelli_credit_request_event
<set>
<if test="loanId != null">
loan_id = #{loanId,jdbcType=BIGINT},
</if>
<if test="timeCreated != null">
time_created = #{timeCreated,jdbcType=TIMESTAMP},
</if>
<if test="httpCode != null">
http_code = #{httpCode,jdbcType=INTEGER},
</if>
<if test="responseMessage != null">
response_message = #{responseMessage,jdbcType=VARCHAR},
</if>
<if test="mills != null">
mills = #{mills,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="cn.quantgroup.report.domain.master.IntelliCreditRequestEvent">
update intelli_credit_request_event
set loan_id = #{loanId,jdbcType=BIGINT},
time_created = #{timeCreated,jdbcType=TIMESTAMP},
http_code = #{httpCode,jdbcType=INTEGER},
response_message = #{responseMessage,jdbcType=VARCHAR},
mills = #{mills,jdbcType=INTEGER}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.quantgroup.report.mapper.master.LoanInfoDbMapper">
<resultMap id="LoanInfoResultMap" type="cn.quantgroup.report.domain.baihang.LoanInfoZhuDai">
<result column="recordId" jdbcType="VARCHAR" property="record_id"/>
<result column="reqID" jdbcType="VARCHAR" property="req_id"/>
<result column="opCode" jdbcType="VARCHAR" property="op_Code"/>
<result column="uploadTs" jdbcType="VARCHAR" property="upload_ts"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="pid" jdbcType="VARCHAR" property="pid"/>
<result column="mobile" jdbcType="VARCHAR" property="mobile"/>
<result column="loanId" jdbcType="VARCHAR" property="loan_id"/>
<result column="guaranteeType" jdbcType="INTEGER" property="guarantee_type"/>
<result column="loanPurpose" jdbcType="INTEGER" property="loan_purpose"/>
<result column="applyDate" jdbcType="VARCHAR" property="apply_date"/>
<result column="accountOpenDate" jdbcType="VARCHAR" property="account_open_date"/>
<result column="issueDate" jdbcType="VARCHAR" property="issue_date"/>
<result column="dueDate" jdbcType="VARCHAR" property="due_date"/>
<result column="loanAmount" jdbcType="DECIMAL" property="loan_amount"/>
<result column="totalTerm" jdbcType="INTEGER" property="total_term"/>
<result column="targetRepayDateType" jdbcType="INTEGER" property="target_repay_date_type"/>
<result column="termPeriod" jdbcType="INTEGER" property="term_period"/>
<result column="firstRepaymentDate" jdbcType="VARCHAR" property="first_repayment_date"/>
<result column="gracePeriod" jdbcType="INTEGER" property="grace_period"/>
</resultMap>
<select id="saveLoanInfoRecordLog" parameterType="cn.quantgroup.report.domain.baihang.LoanInfoZhuDai">
<!--insert into loan_info_zhudai (record_id, req_id, name, pid,mobile,op_Code,upload_ts,loan_id,guarantee_type,loan_purpose,apply_date,account_open_date,
issue_date,due_date,loan_amount,total_term,target_repay_date_type,term_period,first_repayment_date,grace_period)
VALUES (#{recordId},#{reqID},#{name},#{pid},#{mobile},#{opCode},#{uploadTs},#{loanId},#{guaranteeType},#{loanPurpose},#{applyDate}
,#{accountOpenDate},#{issueDate},#{dueDate},#{loanAmount},#{totalTerm},#{targetRepayDateType},#{termPeriod},#{firstRepaymentDate},#{gracePeriod})*/-->
insert into loan_info_zhudai (record_id, req_id, name, pid,mobile,op_Code,upload_ts,loan_id,guarantee_type,loan_purpose,apply_date,account_open_date,
issue_date,due_date,loan_amount,total_term,target_repay_date_type,term_period,first_repayment_date,grace_period,
institutional_funding_partner,institutional_funding_partner_id,institutional_funding_partner_loan_id,relation_id,order_id,pre_credit_limit)
VALUES (#{recordId},#{reqID},#{name},#{pid},#{mobile},#{opCode},#{uploadTs},#{loanId},#{guaranteeType},#{loanPurpose},#{applyDate},
#{accountOpenDate},#{issueDate},#{dueDate},#{loanAmount},#{totalTerm},#{targetRepayDateType},#{termPeriod},#{firstRepaymentDate},#{gracePeriod},
#{institutionalFundingPartner},#{institutionalFundingPartnerID},#{institutionalFundingPartnerLoanID},#{relationID},#{orderID},#{preCreditLimit})
</select>
<update id="updateCurrentRecordEnableFalce" parameterType="cn.quantgroup.report.domain.baihang.BaiHangUpDateRecord">
update loan_info_zhudai set enable = #{enable, jdbcType=VARCHAR} where record_id = #{recordId, jdbcType=VARCHAR};
</update>
<!--<select id="findAll" resultMap="LoanInfoResultMap">
select * from loan_info_zhudai where enable = false;
</select>-->
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.quantgroup.report.mapper.master.RepaymentLoanInfoDbMapper">
<resultMap id="RepaymetnLoanInfoResultMap" type="cn.quantgroup.report.domain.baihang.RepaymentInfoZhuDai">
<result column="reqID" jdbcType="VARCHAR" property="req_id"/>
<result column="recordId" jdbcType="VARCHAR" property="record_id"/>
<result column="opCode" jdbcType="VARCHAR" property="op_code"/>
<result column="uploadTs" jdbcType="VARCHAR" property="upload_ts"/>
<result column="loanId" jdbcType="VARCHAR" property="loan_id"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="pid" jdbcType="VARCHAR" property="pid"/>
<result column="mobile" jdbcType="VARCHAR" property="mobile"/>
<result column="termNo" jdbcType="INTEGER" property="term_no"/>
<result column="termStatus" jdbcType="VARCHAR" property="term_status"/>
<result column="targetRepaymentDate" jdbcType="VARCHAR" property="target_repayment_date"/>
<result column="realRepaymentDate" jdbcType="VARCHAR" property="real_repayment_date"/>
<result column="plannedPayment" jdbcType="DECIMAL" property="planned_payment"/>
<result column="targetRepayment" jdbcType="DECIMAL" property="target_repayment"/>
<result column="realRepayment" jdbcType="DECIMAL" property="real_repayment"/>
<result column="overdueStatus" jdbcType="VARCHAR" property="overdue_status"/>
<result column="statusConfirmAt" jdbcType="VARCHAR" property="status_confirm_at"/>
<result column="overdueAmount" jdbcType="DECIMAL" property="overdue_amount"/>
<result column="remainingAmount" jdbcType="DECIMAL" property="remaining_amount"/>
<result column="loanStatus" jdbcType="INTEGER" property="loan_status"/>
</resultMap>
<resultMap id="RepaymentLoanInfoVoResultMapByBS" type="cn.quantgroup.report.domain.baihang.RepaymentLoanInfoLog">
<result column="reqID" jdbcType="VARCHAR" property="req_id"/>
<result column="opCode" jdbcType="VARCHAR" property="op_code"/>
<result column="uploadTs" jdbcType="VARCHAR" property="upload_ts"/>
<result column="loanId" jdbcType="VARCHAR" property="loan_id"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="pid" jdbcType="VARCHAR" property="pid"/>
<result column="mobile" jdbcType="VARCHAR" property="mobile"/>
<result column="termNo" jdbcType="INTEGER" property="term_no"/>
<result column="termStatus" jdbcType="VARCHAR" property="term_status"/>
<result column="targetRepaymentDate" jdbcType="VARCHAR" property="target_repayment_date"/>
<result column="realRepaymentDate" jdbcType="VARCHAR" property="real_repayment_date"/>
<result column="plannedPayment" jdbcType="DECIMAL" property="planned_payment"/>
<result column="targetRepayment" jdbcType="DECIMAL" property="target_repayment"/>
<result column="realRepayment" jdbcType="DECIMAL" property="real_repayment"/>
<result column="overdueStatus" jdbcType="VARCHAR" property="overdue_status"/>
<result column="statusConfirmAt" jdbcType="VARCHAR" property="status_confirm_at"/>
<result column="overdueAmount" jdbcType="DECIMAL" property="overdue_amount"/>
<result column="remainingAmount" jdbcType="DECIMAL" property="remaining_amount"/>
<result column="loanStatus" jdbcType="INTEGER" property="loan_status"/>
<result column="recordId" jdbcType="VARCHAR" property="record_id"/>
<result column="id" jdbcType="DECIMAL" property="id"/>
<result column="enable" jdbcType="INTEGER" property="enable"/>
<result column="createdAt" jdbcType="VARCHAR" property="created_at"/>
<result column="updatedAt" jdbcType="VARCHAR" property="updated_at"/>
</resultMap>
<select id="saveRepaymentLoanInfoLog" parameterType="cn.quantgroup.report.domain.baihang.RepaymentInfoZhuDai" resultType="cn.quantgroup.report.domain.baihang.RepaymentInfoZhuDai">
insert into
repayment_loan_info_zhudai
(record_id,req_id ,name,pid ,mobile ,op_code ,upload_ts ,loan_id ,term_no ,term_status ,target_repayment_date ,real_repayment_date,planned_payment ,target_repayment,real_repayment ,overdue_amount,remaining_amount,overdue_status,loan_status,status_confirm_at)
values (#{recordId, jdbcType=VARCHAR},#{reqID, jdbcType=VARCHAR},#{name, jdbcType=VARCHAR},#{pid, jdbcType=VARCHAR},#{mobile, jdbcType=VARCHAR},#{opCode, jdbcType=VARCHAR},
#{uploadTs, jdbcType=VARCHAR},#{loanId, jdbcType=VARCHAR},#{termNo, jdbcType=INTEGER},#{termStatus, jdbcType=INTEGER},#{targetRepaymentDate, jdbcType=VARCHAR},#{realRepaymentDate, jdbcType=VARCHAR},
#{plannedPayment, jdbcType=DECIMAL},#{targetRepayment, jdbcType=DECIMAL},#{realRepayment, jdbcType=DECIMAL},#{overdueAmount, jdbcType=DECIMAL},#{remainingAmount, jdbcType=DECIMAL},
#{overdueStatus, jdbcType=INTEGER},#{loanStatus, jdbcType=INTEGER},#{statusConfirmAt, jdbcType=VARCHAR})
</select>
<update id="updateCurrentRecordEnableFalse" parameterType="cn.quantgroup.report.domain.baihang.BaiHangUpDateRecord">
update repayment_loan_info_zhudai set enable = #{enable, jdbcType=VARCHAR}, updated_at = CURRENT_TIMESTAMP() where record_id = #{recordId, jdbcType=VARCHAR};
</update>
<!-- <select id="findAll" resultMap="RepaymetnLoanInfoResultMap">
select * from repayment_loan_info_zhudai where enable = false;
</select>-->
<select id="findLastOne" parameterType="cn.quantgroup.report.domain.baihang.BaiHangRepayment" resultType="cn.quantgroup.report.domain.baihang.RepaymentInfoZhuDai">
select id, record_id, req_id, loan_id, term_no, status_confirm_at, term_status
from repayment_loan_info_zhudai where loan_id = #{loanId} and term_no = #{termNo}
<!--2020.01.07 17:55 值针对当天,还款报了,逾期又有一条的情况 DATE_FORMAT(now(),'%Y-%m-%d') -->
<!-- 2020.02.06 16:14和广达保持一致 and created_at >= #{sendDate} -->
limit 1;
</select>
<!--根据日志中的reqID查询loan_id及还款信息 2019.09.25-->
<select id="findByD3RecordId" resultMap="RepaymentLoanInfoVoResultMapByBS">
SELECT * from repayment_loan_info_zhudai
WHERE op_code='A' and record_id IN
<foreach collection="array" item="recordId" index="index" open="(" close=")" separator=",">
#{recordId}
</foreach>
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.quantgroup.report.mapper.master.RepaymentLoanWhiteListMapper">
<resultMap id="repaymentLoanWhiteListMap" type="cn.quantgroup.report.domain.master.RepaymentLoanWhiteList">
<!--<result column="id" jdbcType="DECIMAL" property="id"/>-->
<result column="pid" jdbcType="VARCHAR" property="pid"/>
<result column="mobile" jdbcType="VARCHAR" property="mobile"/>
<result column="loanId" jdbcType="VARCHAR" property="loan_id"/>
<result column="type" jdbcType="INTEGER" property="type"/>
<!--<result column="enable" jdbcType="INTEGER" property="enable"/>
<result column="createdAt" jdbcType="VARCHAR" property="created_at"/>-->
</resultMap>
<!--<update id="updateCurrentRecordEnableFalce" parameterType="cn.quantgroup.report.domain.baihang.BaiHangUpDateRecord">
update loan_info_zhudai set enable = #{enable, jdbcType=VARCHAR} where record_id = #{recordId, jdbcType=VARCHAR};
</update>-->
<!--<select id="findByD3RecordId" resultMap="RepaymentLoanInfoVoResultMapByBS">
SELECT * from repayment_loan_info_zhudai
WHERE op_code='A' and record_id IN
<foreach collection="array" item="recordId" index="index" open="(" close=")" separator=",">
#{recordId}
</foreach>
</select>-->
<select id="findRepaymentLoanWhiteListOne" resultMap="repaymentLoanWhiteListMap">
select pid, mobile, loan_id, type from repayment_loan_white_list
where loan_id=#{loanId} AND type=#{type} AND enable=1
limit 1;
</select>
<!--<select id="findLastOne" parameterType="cn.quantgroup.report.domain.baihang.BaiHangRepayment" resultType="cn.quantgroup.report.domain.baihang.RepaymentInfoZhuDai">
select id, record_id, req_id, loan_id, term_no, status_confirm_at, term_status
from repayment_loan_info_zhudai where loan_id = #{loanId} and term_no = #{termNo}
&lt;!&ndash;2020.01.07 17:55 值针对当天,还款报了,逾期又有一条的情况 DATE_FORMAT(now(),'%Y-%m-%d') &ndash;&gt;
and created_at >= #{sendDate}
limit 1;
</select>-->
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.quantgroup.report.mapper.master.TransactionLogPOMapper">
<resultMap id="BaseResultMap" type="cn.quantgroup.report.domain.master.TransactionLogPO">
<result column="transaction_id" jdbcType="VARCHAR" property="transactionId" />
<result column="uuid" jdbcType="VARCHAR" property="uuid" />
<result column="url_type" jdbcType="VARCHAR" property="urlType" />
<result column="code" jdbcType="VARCHAR" property="code" />
<result column="time_created" jdbcType="TIMESTAMP" property="timeCreated" />
</resultMap>
<insert id="insert" parameterType="cn.quantgroup.report.domain.master.TransactionLogPO">
insert into transaction_log (transaction_id, uuid, url_type, code, time_created)
values (#{transactionId,jdbcType=VARCHAR}, #{uuid,jdbcType=VARCHAR}, #{urlType,jdbcType=VARCHAR}, #{code,jdbcType=INTEGER},
#{timeCreated,jdbcType=TIMESTAMP}
)
</insert>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.quantgroup.report.mapper.master.UnionPayApiRequestEventMapper">
<insert id="insert" parameterType="cn.quantgroup.report.domain.master.UnionPayApiRequestEvent">
insert into union_pay_api_request_event(bankCardNo,time_created,mills,businessCode,request_url_type) values(#{bankCardNo},#{timeCreated},#{mills},#{businessCode},#{requestUrlType})
</insert>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.quantgroup.report.mapper.renhang.UserMapper">
<resultMap id="growingUserMap" type="cn.quantgroup.report.domain.renhang.User">
<result column="uuid" jdbcType="VARCHAR" property="uuid"/>
<result column="enable" jdbcType="INTEGER" property="enable"/>
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
</resultMap>
<select id="queryGrowingUser" parameterType="cn.quantgroup.report.domain.renhang.User" resultMap="growingUserMap">
SELECT u.uuid, u.`enable`, u.updated_at, u.created_at from `user` u
left join user_ocr o on u.uuid = o.uuid
where o.id is null;
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.quantgroup.report.mapper.renhang.UserOcrMapper">
<insert id="insertUserOcr" parameterType="cn.quantgroup.report.domain.renhang.UserOcrVo">
INSERT INTO `user_ocr` (`uuid`, `address`, `birthday`, `citizen_id`, `gender`, `name`, `nation`, `agency`, `valid_date_begin`, `valid_date_end`, `created_at`, `updated_at`)
VALUES (#{uuid,jdbcType=VARCHAR},
#{address,jdbcType=VARCHAR},
#{birthday,jdbcType=VARCHAR},
#{citizenId,jdbcType=VARCHAR},
#{gender,jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR},
#{nation,jdbcType=VARCHAR},
#{agency,jdbcType=VARCHAR},
#{validDateBegin,jdbcType=VARCHAR},
#{validDateEnd,jdbcType=VARCHAR},
now(),
now()
)
</insert>
<select id="findUserOcr" parameterType="cn.quantgroup.report.domain.renhang.UserOcrVo" resultType="cn.quantgroup.report.domain.renhang.UserOcrVo">
select * from user_ocr a
where a.uuid = #{uuid,jdbcType=VARCHAR}
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.quantgroup.report.mapper.tidbrisk.CallRecordMapper">
<!--
<resultMap id="BaseResultMap" type="cn.quantgroup.risk.datasource.domain.master.TransactionLogPO">
<result column="transaction_id" jdbcType="VARCHAR" property="transactionId" />
<result column="uuid" jdbcType="VARCHAR" property="uuid" />
<result column="url_type" jdbcType="VARCHAR" property="urlType" />
<result column="code" jdbcType="VARCHAR" property="code" />
<result column="time_created" jdbcType="TIMESTAMP" property="timeCreated" />
</resultMap>
<insert id="insert" parameterType="cn.quantgroup.risk.datasource.domain.master.TransactionLogPO">
insert into transaction_log (transaction_id, uuid, url_type, code, time_created)
values (#{transactionId,jdbcType=VARCHAR}, #{uuid,jdbcType=VARCHAR}, #{urlType,jdbcType=VARCHAR}, #{code,jdbcType=INTEGER},
#{timeCreated,jdbcType=TIMESTAMP}
)
</insert>
-->
<insert id="insertCallRecord" parameterType="cn.quantgroup.report.domain.tidbrisk.CallRecord2">
INSERT INTO call_record (channel_type,channel_id,transaction_id,uuid,url_type,`code` ,request_url,created_at, updated_at)
VALUES
( #{channelType,jdbcType=VARCHAR},
#{channelId,jdbcType=VARCHAR},
#{transactionId,jdbcType=VARCHAR},
#{uuid,jdbcType=VARCHAR},
#{urlType,jdbcType=VARCHAR},
#{code,jdbcType=INTEGER},
#{requestUrl,jdbcType=VARCHAR},
now(),
now()
)
</insert>
</mapper>
\ No newline at end of file
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