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

提交2020.06.11

parent 4de7b501
......@@ -23,10 +23,10 @@ public class RenHangDatasourceProperties {
@Value("${db.driver}")
private String driverClass;
@Value("${db.minPoolSize}")
private int minPoolSize;
@Value("${db.maxPoolSize}")
private int maxPoolSize;
//@Value("${db.minPoolSize}")
private int minPoolSize = 10;
//@Value("${db.maxPoolSize}")
private int maxPoolSize =20 ;
......
package cn.quantgroup.report.config.datasource.xyqbuser;
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.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import javax.sql.DataSource;
/**
* Desc:
* User: HaiNan.Wang
* Date: 2017/5/2
*/
@Import(XyqbUserDatasourceProperties.class)
@Configuration
@Slf4j
@MapperScan(basePackages = XyqbUserDataSourceConfig.PACKAGE, sqlSessionFactoryRef = "xyqbUserSqlSessionFactory")
public class XyqbUserDataSourceConfig {
static final String PACKAGE = "cn.quantgroup.report.mapper.xyqbuser";
@Value("${xyqb_user.mapper-locations}")
private String mapperLocations;
@Value("${xyqb_user.type-aliases-package}")
private String typeAliasesPackage;
@Value("${config-location}")
private String configLocation;
@Autowired
private XyqbUserDatasourceProperties xyqbUserDatasourceProperties;
@Bean(name = "xyqbUserDataSource")
public DataSource xyqbUserDataSource() {
HikariConfig config = new HikariConfig();
config.setJdbcUrl(xyqbUserDatasourceProperties.getJdbcUrl());
log.info("数据库地址:{}", xyqbUserDatasourceProperties.getJdbcUrl());
config.setPassword(xyqbUserDatasourceProperties.getPassword());
config.setUsername(xyqbUserDatasourceProperties.getUsername());
config.setMaximumPoolSize(xyqbUserDatasourceProperties.getMaxPoolSize());
config.setMinimumIdle(xyqbUserDatasourceProperties.getMinPoolSize());
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
return new HikariDataSource(config);
}
@Bean(name = "xyqbUserTransactionManager")
public DataSourceTransactionManager xyqbUserTransactionManager(@Qualifier("xyqbUserDataSource") DataSource xyqbUserDataSource) {
return new DataSourceTransactionManager(xyqbUserDataSource);
}
@Bean(name = "xyqbUserSqlSessionFactory")
public SqlSessionFactory xyqbUserSqlSessionFactory(@Qualifier("xyqbUserDataSource") DataSource xyqbUserDataSource) throws Exception {
final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(xyqbUserDataSource);
sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver()
.getResources(mapperLocations));
sessionFactory.setTypeAliasesPackage(typeAliasesPackage);
sessionFactory.setConfigLocation(new PathMatchingResourcePatternResolver()
.getResource(configLocation));
return sessionFactory.getObject();
}
@Bean(name = "xyqbUserSqlSessionTemplate")
public SqlSessionTemplate xyqbUserSqlSessionTemplate(@Qualifier("xyqbUserSqlSessionFactory") SqlSessionFactory xyqbUserSqlSessionFactory) throws Exception {
return new SqlSessionTemplate(xyqbUserSqlSessionFactory);
}
}
package cn.quantgroup.report.config.datasource.xyqbuser;
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 XyqbUserDatasourceProperties {
@Value("${db.driver}")
private String driverClass;
@Value("${db.minPoolSize}")
private int minPoolSize;
@Value("${db.maxPoolSize}")
private int maxPoolSize;
@Value("${db.xyqb_user.url}")
private String jdbcUrl;
@Value("${db.xyqb_user.username}")
private String username;
@Value("${db.xyqb_user.password}")
private String password;
}
......@@ -2,8 +2,10 @@ package cn.quantgroup.report.controller;
import cn.quantgroup.report.response.GlobalResponse;
import cn.quantgroup.report.service.manualTool.ManualToolService;
import cn.quantgroup.report.service.renhang.UserOcrService;
import com.google.common.collect.ImmutableMap;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -18,6 +20,9 @@ public class ManualToolController {
@Autowired
private ManualToolService manualToolService;
@Autowired
private UserOcrService userOcrService;
......@@ -68,4 +73,30 @@ public class ManualToolController {
}
@RequestMapping("/synGrowingUser")
public String synGrowingUser(String startnyr, String endnyr) {
userOcrService.synGrowingUserOcr(startnyr, endnyr);
return "synGrowingUser方法调度成功";
}
@RequestMapping("/synUserOcrByUuids")
public String synUserOcrByUuids(String uuids) {
if (StringUtils.isEmpty(uuids)) {
return "参数为空";
}
userOcrService.synUserOcrByUuids(uuids);
return "synUserOcrByUuids方法调度成功";
}
@RequestMapping("/synValidDateEndUserOcr")
public String synValidDateEndUserOcr() {
userOcrService.synValidDateEndUserOcr();
return "synValidDateEndUserOcr方法调度成功";
}
}
package cn.quantgroup.report.domain.renhang;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
......@@ -7,6 +8,7 @@ import lombok.NoArgsConstructor;
import org.apache.commons.net.ntp.TimeStamp;
import java.io.Serializable;
import java.util.Date;
@Builder
@Data
......@@ -27,8 +29,10 @@ public class User implements Serializable{
private Integer enable; //'是否可用'
private TimeStamp createdAt;
//@JsonIgnore
private Date createdAt;
private TimeStamp updatedAt;
//@JsonIgnore
private Date updatedAt;
}
package cn.quantgroup.report.domain.xyqbuser;
import lombok.Data;
import java.util.Date;
@Data
public class User {
private Long id;
private String phoneNo;
private String uuid;
private Date createdAt;
}
\ No newline at end of file
package cn.quantgroup.report.domain.xyqbuser;
import lombok.Data;
import java.util.Date;
@Data
public class UserDetail {
private Long id;
private Long userId;
private String phoneNo;
private String name;
private String idNo;
private Integer idType;
private Boolean isAuthenticated;
private Integer gender;
private String email;
private String qq;
private Date createdAt;
private Date updatedAt;
}
\ No newline at end of file
......@@ -13,4 +13,5 @@ public interface UserMapper {
//查询日增用户,之前没有的
List<User> queryGrowingUser();
List<User> queryValidDateEndUserOcr(String todayNyr);
}
\ No newline at end of file
package cn.quantgroup.report.mapper.xyqbuser;
import cn.quantgroup.report.domain.xyqbuser.UserDetail;
import java.util.List;
public interface UserDetailMapper {
UserDetail selectByPrimaryKey(Long id);
UserDetail selectByUserId(Long userId);
List<UserDetail> selectByIdentityNumber(String identityNumber);
}
\ No newline at end of file
package cn.quantgroup.report.mapper.xyqbuser;
import cn.quantgroup.report.domain.xyqbuser.User;
public interface UserMapper {
User selectByPrimaryKey(Long id);
User selectByUuid(String uuid);
}
\ No newline at end of file
package cn.quantgroup.report.service.renhang;
import cn.quantgroup.report.domain.renhang.UserOcrVo;
import com.alibaba.fastjson.JSON;
import com.mysql.jdbc.PreparedStatement;
import cn.quantgroup.report.utils.RenHangHikDataSource;
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 {
......@@ -31,62 +28,87 @@ public class RenHangBatchExecuteJdbc {
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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
int commit_count = 1000;
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();
conn = RenHangHikDataSource.INSTANCE.batchDataSourceJdbc.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();
try{
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();
if(i>0 && i%commit_count==0){
ps.executeBatch();
conn.commit();
//ps.clearBatch();
log.info("提交结束:"+ (i/commit_count + 1));
}
}catch (Exception e){
log.error("执行batchInsertExecute异常, SQL:{} , count: {} ", insert_sql, e);
}
}
ps.executeBatch();
conn.commit();
log.info("所有保存提交结束");
}catch(Exception e){
log.error("======执行batchInsertExecute异常======"+insert_sql+"\r\n",e);
e.printStackTrace();
log.error("执行batchInsertExecute异常, SQL:{} , count: last ", insert_sql, e);
}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=?";
int commit_count = 1000;
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();
conn = RenHangHikDataSource.INSTANCE.batchDataSourceJdbc.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();
try{
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();
if(i>0 && i%commit_count==0){
ps.executeBatch();
conn.commit();
//ps.clearBatch();
log.info("提交结束:"+ (i/commit_count + 1));
}
}catch (Exception e){
log.error("执行batchUpdateExecute异常, SQL:{} , count: {} ", update_sql, e);
}
}
ps.executeBatch();
conn.commit();
}catch(Exception e){
log.error("======执行batchUpdateExecute异常======"+update_sql+"\r\n",e);
e.printStackTrace();
log.error("执行batchUpdateExecute异常, SQL:{} , count: last ", update_sql, e);
}finally {
close(conn, ps,null);
}
......
package cn.quantgroup.report.service.renhang;
import cn.quantgroup.report.domain.baihang.*;
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.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;
import cn.quantgroup.report.service.baihang.request.FileUploadValidationRequest;
import cn.quantgroup.report.service.baihang.request.InterfaceUploadRequest;
import cn.quantgroup.report.service.baihang.request.InterfaceUploadValidationRequest;
import cn.quantgroup.report.service.baihang.response.FileUploadResponse;
import cn.quantgroup.report.service.baihang.response.FileUploadValidationResponse;
import cn.quantgroup.report.service.baihang.response.InterfaceUploadResponse;
import cn.quantgroup.report.service.baihang.response.InterfaceUploadValidationResponse;
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 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.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.io.File;
import java.io.IOException;
import java.security.PublicKey;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
/**
* -----------------------------------------------------------------------------<br>
......@@ -65,51 +45,9 @@ public class UserOcrService {
private static final Logger log = LoggerFactory.getLogger(UserOcrService.class);
@Autowired
public ApplyLoanInfoMapper applyLoanInfoMapper;
@Autowired
public LoanInfoMapper loanInfoMapper;
@Autowired
public RepaymentLoanInfoMapper repaymentLoanInfoMapper;
@Autowired
public IHttpService iHttpService;
@Value("${baihang.zhudai.A1.data.url}")
public String baihangHandA1DataUrl;
@Value("${baihang.zhudai.D2.data.url}")
public String baihangHandD2DataUrl;
@Value("${baihang.zhudai.D3.data.url}")
public String baihangHandD3DataUrl;
@Value("${baihang.zhudai.applyloan.url}")
public String baiHangApplyLoanInfoUrl;
@Value("${baihang.zhudai.loaninfo.url}")
public String baiHangLoanInfoUrl;
@Value("${baihang.zhudai.repaymentloaninfo.url}")
public String baiHangRepayMentLoanInfoUrl;
@Value("${baihang.zhudai.account.name}")
public String account;
@Value("${baihang.zhudai.password}")
public String password;
@Value("${baihang.zhudai.cunliang.data.url}")
public String zl_file_path_name; // = "D:\\JavaTeam\\baihang\\cunLiang\\";存量数据整理目录
private static PublicKey baihang_zhudai_publickey = null;
//测试环境报送,用户三要素需要脱敏
private static Map<String,String> testBaoSongUserInfoTuoMingMap = new ConcurrentHashMap<>();
//联合贷产品上线时间,上线后才有数据
private static LocalDateTime liang_he_dai_start = LocalDateTime.parse("2019-10-25T00:00:00");
private static AtomicBoolean A1_Stop = new AtomicBoolean(false);
private static AtomicBoolean D2_Stop = new AtomicBoolean(false);
private static AtomicBoolean D3_Stop = new AtomicBoolean(false);
......@@ -119,34 +57,6 @@ public class UserOcrService {
@PostConstruct
public void init(){
try{
long log_stUtc1 = System.currentTimeMillis();
baihang_zhudai_publickey = BHRSAUtils.readRSAPublicKey("/baihang/rsa_public_key.pem");
log.info("初始化百行助贷PublicKey实例完成, 耗时: {} ",System.currentTimeMillis()-log_stUtc1);
}catch(Exception e){
log.error("初始化百行助贷PublicKey实例", e);
}
}
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;
}
//从Hbase里获取ocr方法
private List<UserOcrVo> getOcrInfoByHbase(List<User> userList) {
List<UserOcrVo> resultList = new ArrayList<>();
......@@ -156,11 +66,12 @@ public class UserOcrService {
long start = System.currentTimeMillis();
JSONObject idCardContentA = null, idCardContentB = null;
UserOcrVo userOcrVo = null;
for (User user : userList) {
for (int i=0; i<userList.size(); i++) {
User user = userList.get(i);
String uuid = user.getUuid();
try {
List<OCRIdCardRow> ocrIdCardRows = OCRIdCardDataService.get(uuid);
log.info("从hbase中查询身份证正反面结束, uuid: {} ", uuid);
log.info("从hbase中查询身份证正反面结束, count: {} , uuid: {} ", i, uuid);
if (CollectionUtils.isNotEmpty(ocrIdCardRows)) {
OCRIdCardRow ocrIdCardRow = ocrIdCardRows.get(0);
......@@ -187,9 +98,9 @@ public class UserOcrService {
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
userOcrVo.setAgency(idCardContentB.getString("agency"));//签发机关
userOcrVo.setValidDateBegin(idCardContentB.getString("valid_date_begin"));//有效日期之起始日期 格式:20131022
userOcrVo.setValidDateEnd(idCardContentB.getString("valid_date_end"));//有效日期之结束日期 格式:20231022
}
if (userOcrVo != null) {
......@@ -219,629 +130,100 @@ public class UserOcrService {
* 出参说明: <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报送------------------------------------------------------------------------------
/**
* 助贷模式-实时批量报送用户贷款申请A1数据
* Scheduled 贷款申请(百行征信报送)
*/
public String sendZhuDaiApplyToBaiHang(String startnyr, String endnyr) {
log.info("量化派助贷TO百行报送T+1申请开始...");
//yyyy-MM-dd
Stopwatch queryWatch1 = Stopwatch.createStarted();
BaiHangTimeRecord timeRecord = BaiHangTimeRecord.builder().startTime(startnyr).endTime(endnyr).build();
List<ApplyLoanInfoZhuDai> applyLoanInfos = applyLoanInfoMapper.findRealTimeApplyLoanZhuDai(timeRecord);
log.info("量化派助贷TO百行报送-非联合贷申请查询完成, 大小: {} , 耗时: {} ", (applyLoanInfos!=null?applyLoanInfos.size() : 0), (queryWatch1.stop().elapsed(TimeUnit.MILLISECONDS)/1000)+".s");
Stopwatch queryWatch2 = Stopwatch.createStarted();
List<ApplyLoanInfoZhuDai> applyLoanInfosLh = applyLoanInfoMapper.findRealTimeApplyLoanZhuDaiLh(timeRecord);
log.info("量化派助贷TO百行报送-联合贷申请查询完成, 大小: {} , 耗时: {} ", (applyLoanInfosLh!=null?applyLoanInfosLh.size() : 0), (queryWatch2.stop().elapsed(TimeUnit.MILLISECONDS)/1000)+".s");
if(applyLoanInfos==null){
applyLoanInfos = new ArrayList<ApplyLoanInfoZhuDai>();
}
if(applyLoanInfosLh!=null && applyLoanInfosLh.size()>0){
applyLoanInfos.addAll(applyLoanInfosLh);
}
Stopwatch sendWatch = Stopwatch.createStarted();
AtomicInteger succ_atomicInteger = new AtomicInteger();
for (int i = 0; i < applyLoanInfos.size(); i++) {
String reqId_log = "";
try {
ApplyLoanInfoZhuDai applyLoanInfo = applyLoanInfos.get(i);
reqId_log = applyLoanInfo.getReqID();
//邮箱有错误的就不传
if(!TuoMinUtils.checkEmail(applyLoanInfo.getEmailAddress())){
applyLoanInfo.setEmailAddress(null);
}
String logJson = JSON.toJSONString(applyLoanInfo);
applyLoanInfo.setName(interfaceUploadClient(applyLoanInfo.getName()));
applyLoanInfo.setMobile(interfaceUploadClient(applyLoanInfo.getMobile()));
applyLoanInfo.setPid(interfaceUploadClient(applyLoanInfo.getPid()));
String resultStr = iHttpService.postBaiHang(baiHangApplyLoanInfoUrl, getHeader(), JSON.toJSONString(applyLoanInfo));
log.info("助贷贷款申请A1报送结果, param: {} , resultStr: {} ", logJson, resultStr);
//if (Objects.isNull(resultStr) || !(resultStr.contains("queryHistory") && resultStr.contains("nonRevolvingLoan") && resultStr.contains("revolvingLoan"))) {
if (Objects.isNull(resultStr) || !"success".equalsIgnoreCase(JSON.parseObject(resultStr).getString("status"))) {
log.info("量化派助贷TO百行报送-贷款申请返回结果不正确, reqId_log: {} , applyId: {} ", reqId_log, applyLoanInfo.getApplyId());
} else {
succ_atomicInteger.getAndIncrement();
}
} catch (Exception e) {
log.error("量化派助贷TO百行报送-贷款申请信息异常, reqId_log: {} ", reqId_log, e);
}
}
log.info("量化派助贷TO百行报送-贷款申请报送完成, 实际大小: {} , 报送成功大小: {} , 耗时: {} ", applyLoanInfos.size(), succ_atomicInteger.get(), (sendWatch.stop().elapsed(TimeUnit.MILLISECONDS)/1000)+".s");
String resMsgTemp = "申请报送: 查询 %d条(联合贷%d条), 报送成功 %d条;";
resMsgTemp+="["+(applyLoanInfos.size()==succ_atomicInteger.get())+"]";
return String.format(resMsgTemp, applyLoanInfos.size(), (applyLoanInfosLh!=null?applyLoanInfosLh.size():0), succ_atomicInteger.get());
}
//--------------------------------------手动重新报送------------------------------------------------------------------------------
/**
* 描述: 手动重新报送-部分申请A1逻辑问题数据 (手动报送A1) <br/>
* 参数: [] <br/>
* 返回值: void <br/>
* 创建人: yanhui.Hao <br/>
* 创建时间: 2019.10.29 <br/>
*/
public String sendHandApplyToBaiHang(boolean isReadFile,List<String> paramJsonStr) throws Exception {
Stopwatch sendWatch = Stopwatch.createStarted();
List<String> handApplys = null;
if(isReadFile){
handApplys = FileUtils.readLines(new File(baihangHandA1DataUrl), "utf-8");
}else{
if(paramJsonStr==null || paramJsonStr.size()==0){
log.warn("众信利民助贷模式TO百行手动报送贷款申请错误, paramJsonStr is Null , isReadFile: {} ",isReadFile);
return "众信利民助贷模式手动报送A1申请参数为空";
}else{
handApplys = paramJsonStr;
}
}
AtomicInteger succ_atomicInteger = new AtomicInteger();
for(int i=0;i<handApplys.size();i++){
try {
ApplyLoanInfoZhuDai applyInfo = new Gson().fromJson(handApplys.get(i), new TypeToken<ApplyLoanInfoZhuDai>(){}.getType());
//邮箱有错误的就不传
if(!TuoMinUtils.checkEmail(applyInfo.getEmailAddress())){
applyInfo.setEmailAddress(null);
}
log.info("众信利民助贷模式TO百行手动报送申请单个数据, {}", JSON.toJSONString(applyInfo));
String logJson = JSON.toJSONString(applyInfo);
applyInfo.setName(interfaceUploadClient(applyInfo.getName()));
applyInfo.setMobile(interfaceUploadClient(applyInfo.getMobile()));
applyInfo.setPid(interfaceUploadClient(applyInfo.getPid()));
@Async
public String synGrowingUserOcr(String startnyr, String endnyr) {
try {
long start1 = System.currentTimeMillis();
List<User> growUsersList = userMapper.queryGrowingUser();
String resultStr = iHttpService.postBaiHang(baiHangApplyLoanInfoUrl, getHeader(), JSON.toJSONString(applyInfo));
/*if (Objects.isNull(resultStr) || !(resultStr.contains("queryHistory") && resultStr.contains("nonRevolvingLoan") && resultStr.contains("revolvingLoan"))) {
log.info("量化派助贷TO百行报送-贷款申请返回结果不正确, loanId: {} ", applyInfo.getLoanId());
}*/
if (Objects.isNull(resultStr) || "success".equalsIgnoreCase(JSON.parseObject(resultStr).getString("status"))) {
succ_atomicInteger.getAndIncrement();
}
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));
log.info("众信利民助贷模式TO百行手动报送贷款申请记录 bean: {} , result: {} ", logJson, resultStr);
} catch (Exception e) {
log.error("百行征信助贷模式手动报送贷款申请记录异常, params: {} ", handApplys.get(i), e);
if(ocrInfoList!=null && ocrInfoList.size()>0){
RenHangBatchExecuteJdbc.batchInsertExecute(ocrInfoList);
}
}catch (Exception e){
log.error("执行同步增量ocr信息异常,", e);
return "执行异常";
}
log.info("众信利民助贷模式TO百行手动报送贷款申请结束, 大小: {} , 耗时: {} ", handApplys.size(), ((sendWatch.stop().elapsed(TimeUnit.MILLISECONDS)/1000)+".s"));
return "众信利民助贷模式手动报送A1申请列表大小: "+handApplys.size()+" , 报送成功条数: "+succ_atomicInteger.get();
return "执行结束";
}
//-----------------------------------------------存量整理---------------------------------------------------------------------
/**
* 描述: http 百行-助贷申请A1存量数据 整理 <br/>
* 参数: [strStartDate, noEndDate] <br/>
* 返回值: java.lang.String <br/>
* 创建人: yanhui.Hao <br/>
* 创建时间: 2019.10.23 <br/>
*/
public String stockApplyLoanInfoZhuDai(String startDate, String noEndDate, String isNotHaveReqID) {
//"2019-05-07T00:00:00"
if (StringUtils.isAnyBlank(startDate, noEndDate)) {
log.warn("stockLoanInfoZhuDai日期格式有误, startDate : {} , noEndDate : {} ", startDate, noEndDate);
return "日期格式有误";
}
if (startDate.length() != 19 || noEndDate.length() != 19 || !startDate.contains("T") || !noEndDate.contains("T")) {
log.warn("stockLoanInfoZhuDai日期格式有误, startDate : {} , noEndDate : {} ", startDate, noEndDate);
return "日期格式有误";
}
boolean notHaveReqID = true;
if(StringUtils.isNotEmpty(isNotHaveReqID) && "true".equals(isNotHaveReqID)){
notHaveReqID = false;
}
final String fileName = zl_file_path_name + "lhp_A1_" + startDate.substring(0, startDate.indexOf("T")).replace("-", "") + "_" + noEndDate.substring(0, noEndDate.indexOf("T")).replace("-", "");
LocalDateTime erlyDate = LocalDateTime.parse(startDate);
LocalDateTime endDate = LocalDateTime.parse(noEndDate);
//2019.11.20 把标题加就去,以免忘记加
@Async
public String synUserOcrByUuids(String uuids) {
try {
FileUtils.write(new File(fileName+"_01.txt"), "#applyInfo\r\n", "UTF-8", true);
}catch (Exception e){
log.error("A1存量添加标题#applyInfo异常",e);
}
int counter = 0;
log.info("开始>>百行-助贷申请存量数据整理, startDate : {} , noEndDate : {} ......", startDate, noEndDate);
long sUtc1 = System.currentTimeMillis();
while (true) {
long sUtc2 = System.currentTimeMillis();
if(A1_Stop.get()){
log.error("All申请存量数据查询STOP, A1_Stop: {} , endTime: {} ",A1_Stop.get(), erlyDate.plusDays(counter).format(DateTimeFormatter.ISO_DATE));
break;
long start1 = System.currentTimeMillis();
String[] uuidArray = uuids.split(",");
List<User> userList = new ArrayList<>();
for (String uuid : uuidArray){
User user = new User();
user.setUuid(uuid);
userList.add(user);
}
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);
BaiHangTimeRecord timeRecord = BaiHangTimeRecord.builder().startTime(starTime).endTime(endTime).build();
/*List<ApplyLoanInfoZhuDai> applyLoanInfoList = applyLoanInfoMapper.queryStockApplyLoanInfoZhuDai(timeRecord);*/
log.info("入参用户大小: {} , 耗时: {} ", userList!=null?userList.size():0, (System.currentTimeMillis()-start1));
Stopwatch queryWatch1 = Stopwatch.createStarted();
List<ApplyLoanInfoZhuDai> applyLoanInfoList = applyLoanInfoMapper.findRealTimeApplyLoanZhuDai(timeRecord);
log.info("申请存量-非联合贷查询结束, 大小: {} , starTime: {} , 耗时: {} ", applyLoanInfoList.size(), starTime, (queryWatch1.stop().elapsed(TimeUnit.MILLISECONDS)/1000)+".s");
List<ApplyLoanInfoZhuDai> applyLoanInfosLh = null;
//联合贷产品上线时间,上线后才有数据
if(erlyDate.plusDays(counter-1).compareTo(liang_he_dai_start) >= 0){
Stopwatch queryWatch2 = Stopwatch.createStarted();
applyLoanInfosLh = applyLoanInfoMapper.findRealTimeApplyLoanZhuDaiLh(timeRecord);
log.info("申请存量-联合贷查询结束, 大小: {} , starTime: {} , 耗时: {} ", applyLoanInfosLh.size(), starTime, (queryWatch2.stop().elapsed(TimeUnit.MILLISECONDS)/1000)+".s");
}
long start2 = System.currentTimeMillis();
List<UserOcrVo> ocrInfoList = getOcrInfoByHbase(userList);
log.info("从Hbase里获取新增用户ocr结束, 大小: {} , 耗时: {} ", ocrInfoList!=null?ocrInfoList.size():0, (System.currentTimeMillis()-start2));
if(applyLoanInfoList==null){
applyLoanInfoList = new ArrayList<ApplyLoanInfoZhuDai>();
}
if(applyLoanInfosLh!=null && applyLoanInfosLh.size()>0){
applyLoanInfoList.addAll(applyLoanInfosLh);
}
int listSize = applyLoanInfoList!=null ? applyLoanInfoList.size(): 0;
log.info("All申请存量数据查询结束, listSize : {} , startTime: {} , endTime: {} , 耗时 : {} ", listSize, starTime, endTime, ((System.currentTimeMillis()-sUtc2)/1000)+".s");
String upladTs = LocalDateTime.now().toString().substring(0, 19);
for (int i = 0; i < applyLoanInfoList.size(); i++) {
try {
ApplyLoanInfoZhuDai applyLoanInfo = applyLoanInfoList.get(i);
applyLoanInfo.setUploadTs(upladTs);
if(notHaveReqID){
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
log.info("history log A1 oldReqID="+applyLoanInfo.getReqID()+",newReqID="+uuid);
applyLoanInfo.setReqID(uuid);
}
//邮箱有错误的就不传
if(!TuoMinUtils.checkEmail(applyLoanInfo.getEmailAddress())){
applyLoanInfo.setEmailAddress(null);
}
//2019.11.18
if(applyLoanInfo.getApplyDate()!=null){
applyLoanInfo.setUploadTs(applyLoanInfo.getApplyDate());//applyDate
}
FileUtils.write(new File(fileName+"_01.txt"), JSON.toJSONString(applyLoanInfo)+"\r\n", "UTF-8", true);
//脱敏数据写一份
//testTuoMinFileWrite(fileName+"_TEST_01.txt",starTime,applyLoanInfo,null,null);
} catch (Exception e) {
log.error("申请存量数据处理异常, startTime: {} , endTime: {} ",starTime, endTime, e);
}
if(ocrInfoList!=null && ocrInfoList.size()>0){
RenHangBatchExecuteJdbc.batchInsertExecute(ocrInfoList);
}
}catch (Exception e){
log.error("执行同步增量ocr信息异常,", e);
return "执行异常";
}
log.info("结束<<百行-助贷申请整理, startTime : {} , endTime : {} , 总耗时: {} ......",startDate,noEndDate, ((System.currentTimeMillis()-sUtc1)/1000)+".s");
return "百行-助贷申请整理结束";
return "执行结束";
}
/**
* 描述: http 百行-助贷放款D2存量数据 整理 <br/>
* 参数: [strStartDate, noEndDate] <br/>
* 返回值: java.lang.String <br/>
* 创建人: yanhui.Hao <br/>
* 创建时间: 2019.10.23 <br/>
*/
public String stockLoanInfoZhuDai(String startDate, String noEndDate,String isNotHaveReqID) {
//"2019-05-07T00:00:00"
if(StringUtils.isAnyBlank(startDate,noEndDate)){
log.warn("stockLoanInfoZhuDai日期格式有误, startDate : {} , noEndDate : {} ",startDate,noEndDate);
return "日期格式有误";
}
if(startDate.length()!=19 || noEndDate.length()!=19 || !startDate.contains("T") || !noEndDate.contains("T")){
log.warn("stockLoanInfoZhuDai日期格式有误, startDate : {} , noEndDate : {} ",startDate,noEndDate);
return "日期格式有误";
}
final String fileName = zl_file_path_name+"lhp_D2_" + startDate.substring(0,startDate.indexOf("T")).replace("-","") + "_" + noEndDate.substring(0,noEndDate.indexOf("T")).replace("-","");
LocalDateTime erlyDate = LocalDateTime.parse(startDate);
LocalDateTime endDate = LocalDateTime.parse(noEndDate);
boolean notHaveReqID = true;
if(StringUtils.isNotEmpty(isNotHaveReqID) && "true".equals(isNotHaveReqID)){
notHaveReqID = false;
}
//2019.11.20 把标题加就去,以免忘记加
@Async
public String synValidDateEndUserOcr() {
try {
FileUtils.write(new File(fileName+"_01.txt"), "#singleLoanAccountInfo\r\n", "UTF-8", true);
}catch (Exception e){
log.error("D2存量添加标题#singleLoanAccountInfo异常",e);
}
int counter = 0;
log.info("开始>>百行-助贷放款存量数据整理, startDate : {} , noEndDate : {} ......",startDate,noEndDate);
while (true) {
if(D2_Stop.get()){
log.error("All放款存量数据查询STOP, D2_Stop: {} , endTime: {} ",D2_Stop.get(), erlyDate.plusDays(counter).format(DateTimeFormatter.ISO_DATE));
break;
}
counter++;
if (erlyDate.plusDays(counter).compareTo(endDate) > 0) {
break;
}
long sUtc1 = System.currentTimeMillis();
String starTime = erlyDate.plusDays(counter-1).format(DateTimeFormatter.ISO_DATE);
String endTime = erlyDate.plusDays(counter).format(DateTimeFormatter.ISO_DATE);
BaiHangTimeRecord timeRecord = BaiHangTimeRecord.builder().startTime(starTime).endTime(endTime).build();
long start1 = System.currentTimeMillis();
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
String todayNyr = dateFormat.format(new Date());
List<User> validDateEndList = userMapper.queryValidDateEndUserOcr(todayNyr);
/* List<LoanInfoZhuDai> loanInfozdList = loanInfoMapper.queryStockLoanInfoZhuDai(timeRecord);*/
log.info("查询DB用户身份证有效期已过期结束, todayNyr: {} , 大小: {} , 耗时: {} ", todayNyr, validDateEndList!=null?validDateEndList.size():0, (System.currentTimeMillis()-start1));
Stopwatch queryWatch1 = Stopwatch.createStarted();
List<LoanInfoZhuDai> loanInfozdList = loanInfoMapper.findRealTimeLoanInfoZhuDai(timeRecord);
log.info("放款存量-非联合贷查询结束, 大小: {} , starTime: {} , 耗时: {} ", loanInfozdList.size(), starTime, (queryWatch1.stop().elapsed(TimeUnit.MILLISECONDS)/1000)+".s");
List<LoanInfoZhuDai> loanInfozdListLh = null;
//联合贷产品上线时间,上线后才有数据
if(erlyDate.plusDays(counter-1).compareTo(liang_he_dai_start) >= 0){
Stopwatch queryWatch2 = Stopwatch.createStarted();
loanInfozdListLh = loanInfoMapper.findRealTimeLoanInfoZhuDaiLh(timeRecord);
log.info("放款存量-联合贷查询结束, 大小: {} , starTime: {} , 耗时: {} ", loanInfozdListLh.size(), starTime, (queryWatch2.stop().elapsed(TimeUnit.MILLISECONDS)/1000)+".s");
long start2 = System.currentTimeMillis();
List<UserOcrVo> ocrInfoList = getOcrInfoByHbase(validDateEndList);
log.info("从Hbase里获取新增用户ocr结束, 大小: {} , 耗时: {} ", ocrInfoList!=null?ocrInfoList.size():0, (System.currentTimeMillis()-start2));
if(ocrInfoList!=null && ocrInfoList.size()>0){
RenHangBatchExecuteJdbc.batchInsertExecute(ocrInfoList);
}
if(loanInfozdList==null){
loanInfozdList = new ArrayList<LoanInfoZhuDai>();
}
if(loanInfozdListLh!=null && loanInfozdListLh.size()>0){
loanInfozdList.addAll(loanInfozdListLh);
}
int listSize = loanInfozdList!=null ? loanInfozdList.size(): 0;
log.info("All放款存量数据查询结束, listSize : {} , startTime: {} , endTime: {} , 耗时 : {} ", listSize, starTime, endTime, ((System.currentTimeMillis()-sUtc1)/1000)+".s");
if(listSize>0){
for (int i = 0; i < listSize; i++) {
LoanInfoZhuDai loanInfozd_tmp = loanInfozdList.get(i);
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.error("量化派助贷TO百行报送-放款返回结果不正确, 发现其他类型的relationID并且长度大于36,relationID: {} , startTime: {} , endTime: {} , loanId: {} ", relationID, starTime, endTime, loanInfozd_tmp.getLoanId());
//continue;
loanInfozd_tmp.setRelationID("X"+relationID.substring(0,35));
}
}
}
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("-", "");
try {
String loanInfoReqId = loanInfoZhuDaiVo.getReqID();
/*if (loanInfoZhuDaiVo.getTotalTerm() > 1) {
List<String> targetRepaymentDayList = loanInfoMapper.findTargetRepaymentDayList(loanInfoReqId);
loanInfoZhuDaiVo.setTargetRepayDateList(String.join(",", targetRepaymentDayList));
}*/
List<String> targetRepaymentDayList = loanInfoMapper.findTargetRepaymentDayList(loanInfoReqId);
if(targetRepaymentDayList!=null && targetRepaymentDayList.size()>0){
loanInfoZhuDaiVo.setTargetRepayDateList(String.join(",", targetRepaymentDayList));
//log.info("比较还款总期数&账单日列表totalTerm="+loanInfoZhuDaiVo.getTotalTerm()+",targetRepaymentDayList size="+targetRepaymentDayList.size());
}else{
log.warn("比较还款总期数&账单日列表totalTerm="+loanInfoZhuDaiVo.getTotalTerm()+",targetRepaymentDayList is null.");
}
if(notHaveReqID){//ReqID 替换为uuid
log.info("history log D2 oldReqID="+loanInfoZhuDaiVo.getReqID()+",newReqID="+id);
loanInfoZhuDaiVo.setReqID(id);
}
//2019.11.18
if(loanInfoZhuDaiVo.getIssueDate()!=null){
loanInfoZhuDaiVo.setUploadTs(loanInfoZhuDaiVo.getIssueDate()); //issueDate
}
FileUtils.write(new File(fileName+"_01.txt"), JSON.toJSONString(loanInfoZhuDaiVo)+"\r\n", "UTF-8", true);
//脱敏数据写一份
//testTuoMinFileWrite(fileName+"_TEST_01.txt",starTime,null,loanInfoZhuDaiVo,null);
} catch (Exception e) {
log.error("放款存量数据处理异常, startTime: {} , endTime: {} , recordId: {} , loanId: {} ",starTime, endTime, id, loanInfoZhuDaiVo.getLoanId(), e);
}
}
}
}
log.info("结束<<百行-助贷放款整理, startDate : {} , noEndDate : {} ......",startDate,noEndDate);
return "百行-助贷放款整理结束";
}
/**
* 描述: http 百行-助贷还款&逾期D3存量数据 整理 <br/>
* 参数: [strStartDate, noEndDate] <br/>
* 返回值: java.lang.String <br/>
* 创建人: yanhui.Hao <br/>
* 创建时间: 2019.10.23 <br/>
*/
public String stockRepayMentInfoZhuDai(String startDate, String noEndDate, String d3Type,String isNotHaveReqID) {//d3Type=0 还款,type=1 逾期
//"2019-05-07T00:00:00"
if(StringUtils.isAnyBlank(startDate,noEndDate)){
log.warn("stockRepayMentInfoZhuDai日期格式有误, startDate : {} , noEndDate : {} ",startDate,noEndDate);
return "日期格式有误";
}
if(startDate.length()!=19 || noEndDate.length()!=19 || !startDate.contains("T") || !noEndDate.contains("T")){
log.warn("stockRepayMentInfoZhuDai日期格式有误, startDate : {} , noEndDate : {} ",startDate,noEndDate);
return "日期格式有误";
}
final String fileName = zl_file_path_name+"lhp_D3_" + startDate.substring(0,startDate.indexOf("T")).replace("-","") + "_" + noEndDate.substring(0,noEndDate.indexOf("T")).replace("-","");
LocalDateTime erlyDate = LocalDateTime.parse(startDate);
LocalDateTime endDate = LocalDateTime.parse(noEndDate);
boolean notHaveReqID = true;
if(StringUtils.isNotEmpty(isNotHaveReqID) && "true".equals(isNotHaveReqID)){
notHaveReqID = false;
}
//2019.11.20 把标题加就去,以免忘记加
try {
FileUtils.write(new File(fileName+"_01.txt"), "#singleLoanRepayInfo\r\n", "UTF-8", true);
}catch (Exception e){
log.error("D3存量添加标题#singleLoanRepayInfo异常",e);
log.error("执行同步增量ocr信息异常,", e);
return "执行异常";
}
int counter = 0;
log.info("开始>>整理百行-助贷还款&逾期存量数据 startDate : {} , noEndDate : {} ......",startDate,noEndDate);
StringBuffer tmpWriteBuffer = null;
while (true) {
if(D3_Stop.get()){
log.error("All还款&逾期存量数据查询STOP, D3_Stop: {} , endTime: {} ",D3_Stop.get(), erlyDate.plusDays(counter).format(DateTimeFormatter.ISO_DATE));
break;
}
counter++;
if (erlyDate.plusDays(counter).compareTo(endDate) > 0) {
break;
}
List<RepaymentInfoZhuDai> repaymentInfoList = new ArrayList<>();
List<RepaymentInfoZhuDai> repaymentLoanInfosLh = new ArrayList<>();
String starTime = erlyDate.plusDays(counter-1).format(DateTimeFormatter.ISO_DATE);
String endTime = erlyDate.plusDays(counter).format(DateTimeFormatter.ISO_DATE);
log.info("整理百行-助贷还款&逾期 startTime: {} , endTime: {} ------------", starTime, endTime);
BaiHangTimeRecord timeRecord = BaiHangTimeRecord.builder().startTime(starTime).endTime(endTime).build();
for (int type = 0; type < 2; type++) {
long log_stUtc = System.currentTimeMillis();
try {
if (type == 0) {
if(StringUtils.isNotEmpty(d3Type) && d3Type.equals("1")){//只要逾期
continue;
}
//Stopwatch stopwatch = Stopwatch.createStarted();
/* repaymentInfoList = repaymentLoanInfoMapper.queryStockRepayMentInfoZhuDai(timeRecord);*/
Stopwatch realTimeStopWatch1 = Stopwatch.createStarted();
repaymentInfoList = repaymentLoanInfoMapper.findRealTimeRepayMentInfo(timeRecord);
log.info("还款存量-非联合贷查询结束, 大小: {} , starTime: {} , 耗时: {} ", repaymentInfoList.size(), starTime, (realTimeStopWatch1.stop().elapsed(TimeUnit.MILLISECONDS)/1000)+".s");
//联合贷产品上线时间,上线后才有数据
if(erlyDate.plusDays(counter-1).compareTo(liang_he_dai_start) >= 0){
Stopwatch realTimeStopWatch2 = Stopwatch.createStarted();
repaymentLoanInfosLh = repaymentLoanInfoMapper.findRealTimeRepayMentInfoLh(timeRecord);
log.info("还款存量-联合贷查询结束, 大小: {} , starTime: {} , 耗时: {} ", repaymentLoanInfosLh.size(), starTime, (realTimeStopWatch2.stop().elapsed(TimeUnit.MILLISECONDS)/1000)+".s");
}
} else {
if(StringUtils.isNotEmpty(d3Type) && d3Type.equals("0")){//只要还款
continue;
}
Stopwatch realTimeOverdueStopWatch3 = Stopwatch.createStarted();
repaymentInfoList = repaymentLoanInfoMapper.findRealTimeRepayMentOverdue(timeRecord);
log.info("逾期存量-非联合贷查询结束, 大小: {} , starTime: {} , 耗时: {} ", repaymentInfoList.size(), starTime, (realTimeOverdueStopWatch3.stop().elapsed(TimeUnit.MILLISECONDS)/1000)+".s");
//联合贷产品上线时间,上线后才有数据
if(erlyDate.plusDays(counter-1).compareTo(liang_he_dai_start) >= 0){
Stopwatch realTimeOverdueStopWatch4 = Stopwatch.createStarted();
repaymentLoanInfosLh = repaymentLoanInfoMapper.findRealTimeRepayMentOverdueLh(timeRecord);
log.info("逾期存量-联合贷查询结束, 大小: {} , starTime: {} , 耗时: {} ", repaymentLoanInfosLh.size(), starTime, (realTimeOverdueStopWatch4.stop().elapsed(TimeUnit.MILLISECONDS)/1000)+".s");
}
}
if(repaymentInfoList==null){
repaymentInfoList = new ArrayList<RepaymentInfoZhuDai>();
}
if(repaymentLoanInfosLh!=null && repaymentLoanInfosLh.size()>0){
repaymentInfoList.addAll(repaymentLoanInfosLh);
}
return "执行结束";
}
tmpWriteBuffer = new StringBuffer();
int buffCount = 0;
for (int j = 0; j < repaymentInfoList.size(); j++) {
RepaymentInfoZhuDai repaymentInfo = repaymentInfoList.get(j);
if(notHaveReqID){
String id = UUID.randomUUID().toString().replaceAll("-", "");
log.info("history log D3 oldReqID="+repaymentInfo.getReqID()+",newReqID="+id+",loanId="+repaymentInfo.getLoanId());
repaymentInfo.setReqID(id);
}
//2019.11.18
// if("normal".equals(repaymentInfo.getTermStatus().trim()) ){
// repaymentInfo.setUploadTs(repaymentInfo.getRealRepaymentDate());////realRepaymentDate 实际还款时间
// }else {
// //overdue
// repaymentInfo.setUploadTs(repaymentInfo.getStatusConfirmAt());//statusConfirmAt还款状态确认时间
// }
//“还款状态确认时间”应早于等于记录生成时间(uploadTs)
if(repaymentInfo.getStatusConfirmAt()!=null){
repaymentInfo.setUploadTs(repaymentInfo.getStatusConfirmAt());
}
//这么写太慢了
///////FileUtils.write(new File(fileName+"_01.txt"), JSON.toJSONString(repaymentInfo)+"\r\n", "UTF-8", true);
//脱敏数据写一份
//testTuoMinFileWrite(fileName+"_TEST_01.txt",starTime,null,null,repaymentInfo);
tmpWriteBuffer.append(JSON.toJSONString(repaymentInfo)+"\r\n");
buffCount++;
}
FileUtils.write(new File(fileName+"_01.txt"), tmpWriteBuffer.toString(), "UTF-8", true);
log.info("批量写入文件结束, startTime: {} , type: {} , repaymentInfoList="+repaymentInfoList.size()+",buffCount="+buffCount+",Check Size="+(repaymentInfoList.size()==buffCount), starTime, type);
tmpWriteBuffer=null;
buffCount=0;
} catch (Exception e) {
log.error("还款&逾期存量数据处理异常, startTime: {} , endTime: {} , type: {} ", starTime, endTime, type, e);
try{
String errMsgFlag = "Query Exception>>";//记录标识,用于补数据
if (type == 0) {
errMsgFlag+="还款整理,";
}else{
errMsgFlag+="逾期整理,";
}
errMsgFlag+="starTime="+starTime+",endTime="+endTime;
FileUtils.write(new File(fileName+"_01.txt"), errMsgFlag+"\r\n", "UTF-8", true);
//脱敏数据写一份
//testTuoMinFileWrite(fileName+"_TEST_01.txt",starTime,null,null,repaymentInfo);
///FileUtils.write(new File(fileName+"_TEST_01.txt"), errMsgFlag+"\r\n", "UTF-8", true);
}catch (Exception e2){
log.error("还款&逾期写入文件异常, startTime: {} , endTime: {} , type: {} ", starTime, endTime, type, e2);
}
}
//打印日志
if (type == 0) {
log.info("All还款整理结束, startTime: {} , endTime: {} , 大小: {} , 总耗时: {} ", starTime, endTime, repaymentInfoList.size(), ((System.currentTimeMillis()-log_stUtc)/1000)+".s");
}else{
log.info("All逾期整理结束, startTime: {} , endTime: {} , 大小: {} , 总耗时: {} ", starTime, endTime, repaymentInfoList.size(), ((System.currentTimeMillis()-log_stUtc)/1000)+".s");
}
}
}
log.info("结束<<百行-助贷还款整理......");
return "百行-助贷还款整理结束";
}
//-----------------------------------------------其他工具---------------------------------------------------------------------
private Map<String, String> getHeader() {
Map<String, String> headerMap = new HashMap<>();
headerMap.put("Authorization", "Basic " + Base64.byteArrayToBase64((account + ":" + password).getBytes()));
headerMap.put("Content-Type", "application/json");
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();
}
/**
* 解密
*
* @throws Exception
*/
//public static void interfaceUploadValidationClient() throws Exception {
private static void interfaceUploadValidationClient(String miwen) throws Exception {
//RSA私钥文件路径(百行提供测试环境私钥文件)
// String RSA_PRIVATE_KEY = "d:\\rsa_private_key.pem";
......@@ -969,304 +351,4 @@ public class UserOcrService {
}
@Async
public void zhuDaiStockSyn(String type, String startDate, String noEndDate, String d3Type,String isNotHaveReqID) {
//"2019-05-07T00:00:00"
if (StringUtils.isAnyBlank(type,startDate, noEndDate)) {
log.warn("Async zhuDaiStockSyn 参数不能为空, startDate : {} , noEndDate : {} ", startDate, noEndDate);
return;
}
if (startDate.length() != 19 || noEndDate.length() != 19 || !startDate.contains("T") || !noEndDate.contains("T")) {
log.warn("Async zhuDaiStockSyn 日期格式有误, startDate : {} , noEndDate : {} ", startDate, noEndDate);
return;
}
if("A1".equalsIgnoreCase(type)) {
//贷款申请信息(A1)
log.warn("Async zhuDaiStockSyn Start {}, {}, {}, ", type, startDate, noEndDate);
stockApplyLoanInfoZhuDai(startDate,noEndDate,isNotHaveReqID);
}else if("D2".equalsIgnoreCase(type)) {
//非循环贷款账户数据信息(D2)
stockLoanInfoZhuDai(startDate,noEndDate,isNotHaveReqID);
} else if("D3".equalsIgnoreCase(type)) {
//非循环贷款贷后数据信息(D3)
stockRepayMentInfoZhuDai(startDate, noEndDate, d3Type,isNotHaveReqID);
}else{
log.warn("Async zhuDaiStockSyn 参数 type: {} 未知.", type);
}
}
//用户三要素脱敏后数据写一份
private void testTuoMinFileWrite(String fileName,String startDate, ApplyLoanInfoZhuDai bean_a1, LoanInfoZhuDaiVo bean_d2, RepaymentInfoZhuDai bean_d3) {
String pid = null, mapVal = null, jsonContext = "";
try {
if (bean_a1 != null) {
pid = bean_a1.getPid();
mapVal = testBaoSongUserInfoTuoMingMap.get(pid);
if (StringUtils.isNotEmpty(mapVal)) {
String[] arry = mapVal.split(",");//pid,mobile,name
bean_a1.setPid(arry[0]);
bean_a1.setMobile(arry[1]);
bean_a1.setName(arry[2]);
} else {
//addUserMap(pid,mobile,name);
log.warn(" TEST FILE A1 发现其他不在字典中用户, startDate: {} , pid: {} ", startDate, pid);
}
jsonContext = JSON.toJSONString(bean_a1);
} else if (bean_d2 != null) {
pid = bean_d2.getPid();
mapVal = testBaoSongUserInfoTuoMingMap.get(pid);
if (StringUtils.isNotEmpty(mapVal)) {
String[] arry = mapVal.split(",");//pid,mobile,name
bean_d2.setPid(arry[0]);
bean_d2.setMobile(arry[1]);
bean_d2.setName(arry[2]);
} else {
//addUserMap(pid,mobile,name);
log.warn(" TEST FILE D2 发现其他不在字典中用户, startDate: {} , pid: {} ", startDate, pid);
}
jsonContext = JSON.toJSONString(bean_d2);
} else if (bean_d3 != null) {
pid = bean_d3.getPid();
mapVal = testBaoSongUserInfoTuoMingMap.get(pid);
if (StringUtils.isNotEmpty(mapVal)) {
String[] arry = mapVal.split(",");//pid,mobile,name
bean_d3.setPid(arry[0]);
bean_d3.setMobile(arry[1]);
bean_d3.setName(arry[2]);
} else {
//addUserMap(pid,mobile,name);
log.warn(" TEST FILE D3 发现其他不在字典中用户, startDate: {} , pid: {} ", startDate, pid);
}
jsonContext = JSON.toJSONString(bean_d3);
} else {
log.error(" TEST FILE testTuoMinFileWrite()实体对象都为空, startDate: {} ",startDate);
return;
}
FileUtils.write(new File(fileName), jsonContext+"\r\n", "UTF-8", true);
} catch (Exception e) {
log.error(" TEST FILE testTuoMinFileWrite()写入文件异常, startDate: {} , pid: {} ", startDate, pid, e);
}
}
private String addUserMap(String pid, String mobile, String name) {
log.warn(" find other user: {} , {} , {} ", pid, mobile, name);
synchronized (testBaoSongUserInfoTuoMingMap) {
if (testBaoSongUserInfoTuoMingMap.containsKey(pid)) {
return testBaoSongUserInfoTuoMingMap.get(pid); //pid,mobile,name
} else {
String mapValue = TuoMinUtils.random_idcard(pid) + "," + TuoMinUtils.random_mobile(mobile) + "," + TuoMinUtils.random_name(name);
testBaoSongUserInfoTuoMingMap.put(pid, mapValue);
return mapValue;
}
}
}
public String zhuDaiStockStop(String type,boolean value) {
if("A1".equalsIgnoreCase(type)) {
//贷款申请信息(A1)
A1_Stop.set(value);
return "A1_Stop="+A1_Stop.get();
}else if("D2".equalsIgnoreCase(type)) {
//非循环贷款账户数据信息(D2)
D2_Stop.set(value);
return "D2_Stop="+D2_Stop.get();
} else if("D3".equalsIgnoreCase(type)) {
//非循环贷款贷后数据信息(D3)
D3_Stop.set(value);
return "D3_Stop="+D3_Stop.get();
}else{
log.warn("Async zhuDaiStockStop 参数 type: {} 未知.", type);
return "未知type="+type;
}
}
public String build_stockRepayMentInfoZhuDai(String jsonFile) throws IOException {
String sourceStr = FileUtils.readFileToString(new File(jsonFile), "utf-8");
JSONObject sourceJson = JSON.parseObject(sourceStr);
JSONArray recordsJsonArr = sourceJson.getJSONArray("RECORDS");
System.out.println("总条数:" + recordsJsonArr.size());
//RepaymentInfoZhuDai repaymentLoanInfo = new Gson().fromJson(repaymentLoanInfos.get(i), new TypeToken<RepaymentInfoZhuDai>(){}.getType());
//log.info("众信利民助贷模式TO百行手动报送还款数据单个数据, {}", JSON.toJSONString(repaymentLoanInfo));
String name = "";
if(jsonFile.lastIndexOf("/")!=-1){//linux
name = jsonFile.substring(jsonFile.lastIndexOf("/")+1, jsonFile.length());
}else{//windows
name = jsonFile.substring(jsonFile.lastIndexOf("\\")+1, jsonFile.length());
}
name = name.substring(0,name.lastIndexOf("."));
final String fileName = zl_file_path_name + name;
long log_stUtc = System.currentTimeMillis();
try {
for (int j = 0; j < recordsJsonArr.size(); j++) {
String tmpStr = recordsJsonArr.getJSONObject(j).toJSONString();
RepaymentInfoZhuDai repaymentInfo = new Gson().fromJson(tmpStr, new TypeToken<RepaymentInfoZhuDai>() {}.getType());
String id = UUID.randomUUID().toString().replaceAll("-", "");
repaymentInfo.setReqID(id);
FileUtils.write(new File(fileName + "_01.txt"), JSON.toJSONString(repaymentInfo) + "\r\n", "UTF-8", true);
//脱敏数据写一份
testTuoMinFileWrite(fileName + "_TEST_01.txt", "shoudongBuild", null, null, repaymentInfo);
}
} catch (Exception e) {
log.error("还款&逾期存量数据处理异常,", e);
}
//打印日志
log.info("All还款||逾期整理结束, 大小: {} , 总耗时: {} ", recordsJsonArr.size(), ((System.currentTimeMillis() - log_stUtc) / 1000) + ".s");
return "百行-助贷还款整理结束";
}
public void build_A1(List<String> lineList) throws IOException {
log.info("lineList:"+lineList.size());
for(int i=0;i<lineList.size();i++){
String str = lineList.get(i);
if(str.startsWith("----------")){
log.info(str);
continue;
}
ApplyLoanInfoZhuDai applyInfo = new Gson().fromJson(str, new TypeToken<ApplyLoanInfoZhuDai>(){}.getType());
log.info("众信利民助贷模式TO百行手动报送申请单个数据, {}", JSON.toJSONString(applyInfo));
String emailAddress = applyInfo.getEmailAddress();
if(TuoMinUtils.checkEmail(emailAddress)){
log.error("emailAddress="+emailAddress+" is ok.");
}else{
applyInfo.setEmailAddress("");
log.warn("emailAddress="+emailAddress+" is error.");
}
try {
FileUtils.write(new File("D:\\用户目录\\Downloads\\build_A1_TEST_01_M.txt"), JSON.toJSONString(applyInfo)+"\r\n", "UTF-8", true);
//脱敏数据写一份
//testTuoMinFileWrite("D:\\用户目录\\Downloads\\build_A1_TEST_01_M.txt",null,applyInfo,null,null);
} catch (Exception e) {
log.error("申请存量数据处理异常, startTime: {} , endTime: {} ",null, null, e);
}
}
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.usersdk;
import cn.quantgroup.report.domain.sdk.SdkUser;
import cn.quantgroup.report.domain.xyqbuser.User;
import cn.quantgroup.report.domain.xyqbuser.UserDetail;
public interface IUserCenterService {
......@@ -19,14 +17,7 @@ public interface IUserCenterService {
*/
public SdkUser getSdkUserByUuid(String uuid);
public User getSdkUserByUserId(String userId);
public UserDetail getSdkUserDetailByUserId(Long userId);
public Long getUserIdByIdentityNumberAndName(String identityNumber, String name);
public Long getUserIdByIdentityNumber(String identityNumber);
public String getUuidByIdentityNumber(String identityNumber);
public String getUuidByPhoneNumber(String phoneNumber);
public SdkUser getUserFullInfoByUuid(String uuid);
......
package cn.quantgroup.report.service.usersdk.impl;
import cn.quantgroup.motan.bean.UserInfo;
import cn.quantgroup.motan.retbean.XUser;
import cn.quantgroup.motan.retbean.XUserDetail;
import cn.quantgroup.motan.retbean.XUserFullInfo;
import cn.quantgroup.motan.vo.UserSysResult;
import cn.quantgroup.report.cmpt.CommonAlarmCmpt;
import cn.quantgroup.report.domain.sdk.SdkUser;
import cn.quantgroup.report.domain.xyqbuser.User;
import cn.quantgroup.report.error.QGExceptionType;
import cn.quantgroup.report.error.QGPreconditions;
import cn.quantgroup.report.service.usersdk.IUserCenterService;
import cn.quantgroup.report.domain.xyqbuser.UserDetail;
import cn.quantgroup.report.service.http.IHttpService;
import cn.quantgroup.report.service.usersdk.IUserCenterService;
import cn.quantgroup.user.IUserSdkService;
import cn.quantgroup.user.UserSdkServiceFactory;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.ImmutableMap;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.impl.client.CloseableHttpClient;
import org.slf4j.Logger;
......@@ -30,9 +23,6 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
@Service
public class UserCenterServiceImpl implements IUserCenterService {
......@@ -93,113 +83,6 @@ public class UserCenterServiceImpl implements IUserCenterService {
return null;
}
@Override
public User getSdkUserByUserId(String userId) {
try{
UserSysResult<XUser> userByUserId = userSdkService.findUserByUserId(Long.parseLong(userId));
User user = new User();
if(userByUserId.isSuccess()&&userByUserId.getData()!=null){
XUser data = userByUserId.getData();
BeanUtils.copyProperties(data, user);
return user;
}
}catch(Exception e){
LOGGER.error("查询用户用心异常,uuid: {} , {}",userId,e);
iMonitorAlarmService.alarm("WARN","用户中心查询异常告警","接口 : findUserByUserId(userId) , 异常信息:"+e.getMessage());
}
return null;
}
@Override
public UserDetail getSdkUserDetailByUserId(Long userId) {
try{
UserSysResult<XUserDetail> userDetailUserSysResult = userSdkService.findUserDetailByUserId(userId);
UserDetail userDetail = new UserDetail();
if(userDetailUserSysResult.isSuccess() && userDetailUserSysResult.getData()!=null){
XUserDetail xUserDetail = userDetailUserSysResult.getData();
BeanUtils.copyProperties(xUserDetail, userDetail);
return userDetail;
}
}catch(Exception e){
LOGGER.error("查询用户中心用户详情异常, userId: {} , {}", userId, e);
iMonitorAlarmService.alarm("WARN","用户中心查询异常告警","接口 : getSdkUserDetailByUserId(userId) , 异常信息:"+e.getMessage());
}
return null;
}
@Override
public Long getUserIdByIdentityNumberAndName(String identityNumber, String name) {
UserSysResult<List<XUserDetail>> userDetailBySpecification = userSdkService.queryUserDetailBySpecification(null, null, identityNumber);
LOGGER.info("getUserIdByIdentityNumberAndName, identityNumber: {} , name:{}, 结果:{}", identityNumber, name, JSON.toJSONString(userDetailBySpecification));
List<UserDetail> userDetails = new ArrayList<>();
if(userDetailBySpecification.isSuccess()&&userDetailBySpecification.getData()!=null){
List<XUserDetail> xUserDetails = userDetailBySpecification.getData();
xUserDetails.forEach(xUserDetail2 -> {
UserDetail userDetail = new UserDetail();
BeanUtils.copyProperties(xUserDetail2, userDetail);
userDetails.add(userDetail);
});
QGPreconditions.checkArgument(CollectionUtils.isNotEmpty(userDetails), QGExceptionType.XYQB_USER_NOT_EXSIT);
Optional<UserDetail> optional = userDetails.parallelStream().filter(detail -> StringUtils.equals(detail.getName(), name)).findFirst();
boolean isPresent = optional.isPresent();
QGPreconditions.checkArgument(isPresent, QGExceptionType.XYQB_USER_NOT_MATCH);
long userId = optional.get().getUserId();
return userId;
}
return null;
}
public Long getUserIdByIdentityNumber(String identityNumber) {
UserSysResult<List<XUserDetail>> userDetailBySpecification = userSdkService.queryUserDetailBySpecification(null, null, identityNumber);
LOGGER.info("getUserIdByIdentityNumber, identityNumber:{}, 结果:{}", identityNumber, JSON.toJSONString(userDetailBySpecification));
List<UserDetail> userDetails = new ArrayList<>();
if(userDetailBySpecification.isSuccess()&&userDetailBySpecification.getData()!=null){
List<XUserDetail> xUserDetails = userDetailBySpecification.getData();
xUserDetails.forEach(xUserDetail2 -> {
UserDetail userDetail = new UserDetail();
BeanUtils.copyProperties(xUserDetail2, userDetail);
userDetails.add(userDetail);
});
QGPreconditions.checkArgument(CollectionUtils.isNotEmpty(userDetails), QGExceptionType.XYQB_USER_NOT_EXSIT);
Optional<UserDetail> optional = userDetails.parallelStream().filter(detail -> (detail.getUserId() != null)).findFirst();
boolean isPresent = optional.isPresent();
QGPreconditions.checkArgument(isPresent, QGExceptionType.XYQB_USER_NOT_MATCH);
long userId = optional.get().getUserId();
return userId;
}
return null;
}
@Override
public String getUuidByIdentityNumber(String identityNumber) {
try {
UserSysResult<List<XUserDetail>> userDetailBySpecification = userSdkService.queryUserDetailBySpecification(null, null, identityNumber);
LOGGER.info("getUuidByIdentityNumber, identityNumber: {} , 结果:{}", identityNumber, JSON.toJSONString(userDetailBySpecification));
List<UserDetail> userDetails = new ArrayList<>();
if (userDetailBySpecification.isSuccess() && userDetailBySpecification.getData() != null) {
List<XUserDetail> xUserDetails = userDetailBySpecification.getData();
xUserDetails.forEach(xUserDetail2 -> {
UserDetail userDetail = new UserDetail();
BeanUtils.copyProperties(xUserDetail2, userDetail);
userDetails.add(userDetail);
});
QGPreconditions.checkArgument(CollectionUtils.isNotEmpty(userDetails), QGExceptionType.XYQB_USER_NOT_EXSIT);
Optional<UserDetail> optional = userDetails.parallelStream().filter(detail -> (detail.getUserId() != null)).findFirst();
boolean isPresent = optional.isPresent();
QGPreconditions.checkArgument(isPresent, QGExceptionType.XYQB_USER_NOT_MATCH);
long userId = optional.get().getUserId();
User user = getSdkUserByUserId(String.valueOf(userId));
if (user == null) {
LOGGER.info("查询用户用心,identityNumber: {} , user {}",identityNumber, user);
return null;
}
return user.getUuid();
}
}catch (Exception e){
LOGGER.error("查询用户用心异常,identityNumber: {} , {}",identityNumber,e);
}
return null;
}
@Override
public String getUuidByPhoneNumber(String phoneNumber) {
......
package cn.quantgroup.report.utils;
import cn.quantgroup.report.service.renhang.UserOcrService;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import javax.sql.DataSource;
@Slf4j
public enum RenHangHikDataSource {
HIK_DATA_SOURCE_RENHANG;
@Value("${db.renhang.rc_sync_guangda.fullurl}")
INSTANCE;
/* @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;
private String datasourcePassword;*/
public DataSource dataSourceJdbc;
public DataSource batchDataSourceJdbc;
RenHangHikDataSource(){
if(dataSourceJdbc==null){
Logger log = LoggerFactory.getLogger(RenHangHikDataSource.class);
if(batchDataSourceJdbc==null){
HikariConfig config = new HikariConfig();
//"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.setJdbcUrl("jdbc:mysql://172.30.220.4:3306/rc_sync_guangda?useUnicode=true&characterEncoding=UTF8&useSSL=false&rewriteBatchedStatements=true");
//config.setJdbcUrl(datasourceJdbcUrl.substring(0, datasourceJdbcUrl.indexOf("?"))+"?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true");
config.setUsername("rc_sync_guangda_w");
config.setPassword("KETqFdAj6b4vHX4z");
config.setDriverClassName("com.mysql.jdbc.Driver");
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("rc_sync_guangda创建数据库连接完毕");
batchDataSourceJdbc = new HikariDataSource(config);
log.info("rc_sync_guangda创建数据库连接完毕");
}
}
......
......@@ -6,7 +6,7 @@
<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="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
</resultMap>
......@@ -17,4 +17,20 @@
where o.id is null;
</select>
<select id="findTargetRepaymentDayList" parameterType="java.lang.String" resultType="java.lang.String">
select date(DATE_SUB(deadline,INTERVAL 1 second)) from xyqb_i_repayment_plan where loan_application_history_id=#{reqID}
</select>
<select id="queryValidDateEndUserOcr" parameterType="java.lang.String" resultMap="growingUserMap">
select uo.uuid, '1' enable, uo.updated_at, uo.created_at from user_ocr uo
where LENGTH(uo.valid_date_end)=8
and DATE_FORMAT(uo.valid_date_end,'%Y%m%d') &lt; DATE_FORMAT(#{todayNyr},'%Y-%m-%d')
UNION
select uo.uuid, '1' enable, uo.updated_at, uo.created_at from user_ocr uo
where LENGTH(uo.valid_date_end)!=8
and uo.valid_date_end!='长期'
and uo.valid_date_end!='长期有效'
</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.xyqbuser.UserDetailMapper">
<resultMap id="BaseResultMap" type="cn.quantgroup.report.domain.xyqbuser.UserDetail">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="user_id" jdbcType="BIGINT" property="userId"/>
<result column="phone_no" jdbcType="VARCHAR" property="phoneNo"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="id_no" jdbcType="VARCHAR" property="idNo"/>
<result column="id_type" jdbcType="TINYINT" property="idType"/>
<result column="is_authenticated" jdbcType="BIT" property="isAuthenticated"/>
<result column="gender" jdbcType="TINYINT" property="gender"/>
<result column="email" jdbcType="VARCHAR" property="email"/>
<result column="qq" jdbcType="VARCHAR" property="qq"/>
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt"/>
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt"/>
</resultMap>
<sql id="Base_Column_List">
id, user_id, phone_no, name, id_no, id_type, is_authenticated, gender, email, qq,
created_at, updated_at
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from user_detail
where id = #{id,jdbcType=BIGINT}
</select>
<select id="selectByUserId" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from user_detail
where user_id = #{userId,jdbcType=BIGINT}
</select>
<select id="selectByIdentityNumber" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from user_detail
where id_no = #{identityNumber,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.xyqbuser.UserMapper">
<resultMap id="BaseResultMap" type="cn.quantgroup.report.domain.xyqbuser.User">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="phone_no" jdbcType="VARCHAR" property="phoneNo"/>
<result column="uuid" jdbcType="VARCHAR" property="uuid"/>
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt"/>
</resultMap>
<sql id="Base_Column_List">
id, phone_no, uuid,created_at
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from user
where id = #{id,jdbcType=BIGINT}
</select>
<select id="selectByUuid" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from user
where uuid = #{uuid,jdbcType=VARCHAR}
</select>
</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