Commit ef26e231 authored by 陈宏杰's avatar 陈宏杰

报送A1被拒的

parent 2c3cbd16
package cn.quantgroup.report.domain.baihang;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class ApplyLoanInfoZhuDaiRefuse {
private String reqID;
private String opCode;//操作代码A-增加 M-修改
private String uploadTs;
private int isFinTechAgencyBusiness;//是否是助贷业务 N
private String applyDate;
private String applyId;
private int applyType;
private String name;
private int idType;
private String pid;
private String mobile;
private String emailAddress; //电子邮箱
private int eduBackground;//学历
private int degree;//学位
private int guaranteeType;//信贷业务担保类型
private int loanPurpose;//贷款用途 Y/N
private int customType; //客户类型
private BigDecimal applyAmount; //申请贷款金额
private String businessOrgCreditCode;//业务发生机构代码 Y/N
//private String homeAddress; //N
//private String homePhone; //N
//private String workName; //N
//private String workAddress; //N
//private String workPhone; //N
//private String idAddress; //N
//private String mailAddress; //N
private int livingCondition;//居住状况
private int marriageStatus; //婚姻状况
private String spouseName;//配偶姓名 Y/N
//private Integer spouseIdType;
//private String spousePid;
//private String spouseMobile;
//private String spouseWorkName;
//private String firstContactsName; //第一联系人姓名 Y/N
//private Integer firstContactsRelationship;
//private Integer firstContactsIdType;
//private String firstContactsPid;
//private String firstContactsMobile; //第一联系人手机号码 Y/N
//private String firstContactsTelephone;
//private String firstContactsWorkName;
//private String secondContactsName;//第二联系人姓名 Y/N
//private Integer secondContactsRelationship;
//private Integer secondContactsIdType;
//private String secondContactsPid;
//private String secondContactsMobile;//第二联系人手机号码 Y/N
//private String secondContactsTelephone;
//private String secondContactsWorkName;
//device;
//deviceType;
//imei;
//mac;
//ipAddress;
//osName;
private String recordId;
}
...@@ -60,4 +60,7 @@ public interface ApplyLoanInfoMapper { ...@@ -60,4 +60,7 @@ public interface ApplyLoanInfoMapper {
List<FundingCorpInfo> findFundingCorpInfo(List<Integer> list); List<FundingCorpInfo> findFundingCorpInfo(List<Integer> list);
List<ApplyLoanInfoZhuDai> findApplyInfoOfRefuse(BaiHangTimeRecord timeRecord);
} }
...@@ -19,4 +19,6 @@ public interface ApplyLoanInfoZhuDaiMapper { ...@@ -19,4 +19,6 @@ public interface ApplyLoanInfoZhuDaiMapper {
List<ApplyLoanInfoZhuDai> findApplyLoanInfoZhuDaiLog(String reqId); List<ApplyLoanInfoZhuDai> findApplyLoanInfoZhuDaiLog(String reqId);
List<ApplyLoanInfoZhuDai> findByApplyId(String applyId);
} }
package cn.quantgroup.report.mapper.master;
import cn.quantgroup.report.domain.baihang.ApplyLoanInfoZhuDai;
import cn.quantgroup.report.domain.baihang.ApplyLoanInfoZhuDaiRefuse;
import cn.quantgroup.report.domain.baihang.LoanInfoZhuDai;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface ApplyLoanInfoZhuDaiRefuseMapper {
void saveApplyLoanInfoZhuDaiRefuseLog(ApplyLoanInfoZhuDaiRefuse applyLoanInfoZhuDaiRefuse);
void batchSaveLog(List<ApplyLoanInfoZhuDaiRefuse> list);
List<ApplyLoanInfoZhuDaiRefuse> findApplyLoanInfoZhuDaiRefuseLog(String reqId);
}
...@@ -6,6 +6,7 @@ import cn.quantgroup.report.mapper.baihang.ApplyLoanInfoMapper; ...@@ -6,6 +6,7 @@ import cn.quantgroup.report.mapper.baihang.ApplyLoanInfoMapper;
import cn.quantgroup.report.mapper.baihang.LoanInfoMapper; import cn.quantgroup.report.mapper.baihang.LoanInfoMapper;
import cn.quantgroup.report.mapper.baihang.RepaymentLoanInfoMapper; import cn.quantgroup.report.mapper.baihang.RepaymentLoanInfoMapper;
import cn.quantgroup.report.mapper.master.ApplyLoanInfoZhuDaiMapper; import cn.quantgroup.report.mapper.master.ApplyLoanInfoZhuDaiMapper;
import cn.quantgroup.report.mapper.master.ApplyLoanInfoZhuDaiRefuseMapper;
import cn.quantgroup.report.mapper.master.LoanInfoDbMapper; import cn.quantgroup.report.mapper.master.LoanInfoDbMapper;
import cn.quantgroup.report.mapper.master.RepaymentLoanInfoDbMapper; import cn.quantgroup.report.mapper.master.RepaymentLoanInfoDbMapper;
import cn.quantgroup.report.service.baihang.client.BhFileCreditApiClient; import cn.quantgroup.report.service.baihang.client.BhFileCreditApiClient;
...@@ -63,10 +64,13 @@ public class BaiHangFileReportService { ...@@ -63,10 +64,13 @@ public class BaiHangFileReportService {
public RepaymentLoanInfoDbMapper repaymentLoanInfoDbMapper; public RepaymentLoanInfoDbMapper repaymentLoanInfoDbMapper;
@Autowired @Autowired
public ApplyLoanInfoZhuDaiMapper applyLoanInfoZhuDaiMapper; public ApplyLoanInfoZhuDaiMapper applyLoanInfoZhuDaiMapper;
@Autowired
public ApplyLoanInfoZhuDaiRefuseMapper applyLoanInfoZhuDaiRefuseMapper;
private static final String HOST_PATH = "/home/quant_group/reportFile/"; private static final String HOST_PATH = "/home/quant_group/reportFile/";
// private static final String HOST_PATH = "C:\\Users\\musterHunter\\Desktop\\TEST_REPORT\\"; // private static final String HOST_PATH = "C:\\Users\\musterHunter\\Desktop\\TEST_REPORT\\";
private static final Integer A1_INITIAL_CAPACITY = 6000;
private static final Integer D2_INITIAL_CAPACITY = 5000; private static final Integer D2_INITIAL_CAPACITY = 5000;
...@@ -139,6 +143,8 @@ public class BaiHangFileReportService { ...@@ -139,6 +143,8 @@ public class BaiHangFileReportService {
log.info("开始生成报送文件{}----- {} -- {}",type,starTime,endTime); log.info("开始生成报送文件{}----- {} -- {}",type,starTime,endTime);
if ("A1".equalsIgnoreCase(type)) { if ("A1".equalsIgnoreCase(type)) {
encryptFileName = reportA1(starTime,endTime); encryptFileName = reportA1(starTime,endTime);
} else if ("A1Refuse".equalsIgnoreCase(type)) {
encryptFileName = reportA1Refuse(starTime,endTime);
} else if ("D2".equalsIgnoreCase(type)) { } else if ("D2".equalsIgnoreCase(type)) {
encryptFileName = reportD2(starTime,endTime,prefix); encryptFileName = reportD2(starTime,endTime,prefix);
} else if ("D3".equalsIgnoreCase(type)) { } else if ("D3".equalsIgnoreCase(type)) {
...@@ -223,6 +229,67 @@ public class BaiHangFileReportService { ...@@ -223,6 +229,67 @@ public class BaiHangFileReportService {
return encryptFileName; return encryptFileName;
} }
private String reportA1Refuse(String starTime, String endTime){
String encryptFileName = null;
List<ApplyLoanInfoZhuDaiRefuse> recordList = new ArrayList<>(A1_INITIAL_CAPACITY),zhuDaiRefuseLogList = null;
List<ApplyLoanInfoZhuDai> zhuDaiLogList = null,applyLoanInfos = null;
List<String> reportList = new ArrayList<>();
try {
Stopwatch queryWatch1 = Stopwatch.createStarted();
BaiHangTimeRecord timeRecord = BaiHangTimeRecord.builder().startTime(starTime).endTime(endTime).build();
applyLoanInfos = applyLoanInfoMapper.findApplyInfoOfRefuse(timeRecord);
log.info("量化派助贷TO百行报送(A1Refuse)-非联合贷申请查询完成, 大小: {} , 耗时: {} ", (applyLoanInfos != null ? applyLoanInfos.size() : 0), (queryWatch1.stop().elapsed(TimeUnit.MILLISECONDS) / 1000) + ".s");
if (applyLoanInfos == null) {
applyLoanInfos = new ArrayList<ApplyLoanInfoZhuDai>();
}
AtomicInteger atomicInteger = new AtomicInteger();
Stopwatch sendWatch = Stopwatch.createStarted();
reportList.add("#applyInfo");
String reqId_log = "";
for (int i = 0; i < applyLoanInfos.size(); i++) {
try {
ApplyLoanInfoZhuDai applyLoanInfo = applyLoanInfos.get(i);
reqId_log = applyLoanInfo.getReqID();
zhuDaiLogList = applyLoanInfoZhuDaiMapper.findByApplyId(applyLoanInfo.getApplyId());
zhuDaiRefuseLogList = applyLoanInfoZhuDaiRefuseMapper.findApplyLoanInfoZhuDaiRefuseLog(applyLoanInfo.getReqID());
if (CollectionUtils.isEmpty(zhuDaiLogList) && CollectionUtils.isEmpty(zhuDaiRefuseLogList)) {
ApplyLoanInfoZhuDaiRefuse record = new ApplyLoanInfoZhuDaiRefuse();
BeanUtils.copyProperties(applyLoanInfo, record);
record.setRecordId(UUID.randomUUID().toString().replaceAll("-", ""));
recordList.add(record);
//邮箱有错误的就不传
if (!TuoMinUtils.checkEmail(applyLoanInfo.getEmailAddress())) {
applyLoanInfo.setEmailAddress(null);
}
applyLoanInfo.setName(sensitiveFilter(applyLoanInfo.getName()));
applyLoanInfo.setMobile(sensitiveFilter(applyLoanInfo.getMobile()));
applyLoanInfo.setPid(sensitiveFilter(applyLoanInfo.getPid()));
reportList.add(JSON.toJSONString(applyLoanInfo));
atomicInteger.getAndIncrement();
} else {
log.error("量化派助贷TO百行报送(A1Refuse)-贷款申请信息重复报送, applyLoanInfo: {} ", JSON.toJSONString(applyLoanInfo));
}
} catch (Exception e) {
log.error("量化派助贷TO百行报送(A1Refuse)-贷款申请信息异常, reqId_log: {} ", reqId_log, e);
}
}
saveApplyLoanInfoZhuDaiRefuse(recordList,starTime,endTime);
File file = new File(HOST_PATH+"量子数科科技有限公司_A1Re_"+fileNameReplaceAll(starTime.split("T")[0])+"_"+fileNameReplaceAll(endTime.split("T")[0])+"_"+String.format("%06d",new Random().nextInt(999999))+".txt");
FileUtils.writeLines(file,reportList);
if (reportList.size()<=1) {
log.info("量化派助贷TO百行报送(A1Refuse)-贷款申请信息为空,加密文件不生成!starTime={},endTime={}",starTime,endTime);
} else {
encryptFileName = createFile(file.getAbsolutePath());
}
log.info("量化派助贷TO百行报送(A1Refuse)-贷款申请信息完成, 实际大小: {} , 报送成功大小: {} , 耗时: {} ", applyLoanInfos.size(), atomicInteger.get(), sendWatch.stop().elapsed(TimeUnit.MILLISECONDS));
} catch (Exception e) {
log.error("量化派助贷TO百行报送(A1Refuse)-异常", e);
} finally {
clear(applyLoanInfos,recordList,reportList);
}
return encryptFileName;
}
/** /**
* 非循环贷款账户数据信息(D2) * 非循环贷款账户数据信息(D2)
* @param starTime 开始时间 * @param starTime 开始时间
...@@ -673,6 +740,24 @@ public class BaiHangFileReportService { ...@@ -673,6 +740,24 @@ public class BaiHangFileReportService {
} }
} }
private void saveApplyLoanInfoZhuDaiRefuse(List<ApplyLoanInfoZhuDaiRefuse> recordList,String startTime, String endTime) {
if (!CollectionUtils.isEmpty(recordList)) {
List<List<ApplyLoanInfoZhuDaiRefuse>> allList = null;
try {
allList = Lists.partition(recordList, LISTS_PARTITION_SIZE);
Stopwatch saveStopwatch = Stopwatch.createStarted();
allList.stream().forEach(pRecordList -> {
applyLoanInfoZhuDaiRefuseMapper.batchSaveLog(pRecordList);
});
log.info("量化派助贷TO百行报送(A1Refuse)批量插入结束, startTime: {} , endTime: {} , 大小: {} , 耗时: {} ", startTime, endTime, recordList.size(), (saveStopwatch.stop().elapsed(TimeUnit.MILLISECONDS) / 1000) + ".s");
} catch (Exception e) {
log.error("量化派助贷TO百行报送(A1Refuse)保存异常", e);
} finally {
clear(recordList,allList);
}
}
}
private Boolean increment(String key) { private Boolean increment(String key) {
Long increment = redisTemplate.opsForValue().increment(key, 1); Long increment = redisTemplate.opsForValue().increment(key, 1);
return increment <= 1; return increment <= 1;
......
...@@ -146,4 +146,48 @@ ...@@ -146,4 +146,48 @@
</foreach> </foreach>
</select> </select>
<select id="findApplyInfoOfRefuse" parameterType="cn.quantgroup.report.domain.baihang.BaiHangTimeRecord" resultType="cn.quantgroup.report.domain.baihang.ApplyLoanInfoZhuDai">
select
CONCAT('apply',i.id) reqID
,'A' opCode
,DATE_FORMAT(now(),'%Y-%m-%dT%H:%i:%S') uploadTs
,'1' isFinTechAgencyBusiness
,DATE_FORMAT(i.created_at,'%Y-%m-%dT%H:%i:%S') as applyDate
,i.apply_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 business_flow.apply_list i
left join xyqb_user.user u on u.uuid=i.uuid
left join xyqb_user.user_detail b on u.id=b.user_id
left join xyqb_user.user_ext_info j on u.id=j.user_id
where i.product_type=0
and i.apply_status>=4
and (i.audit_result=0 or i.assets_result=0)
and i.created_at >= #{startTime,jdbcType=VARCHAR}
and i.created_at &lt; #{endTime,jdbcType=VARCHAR};
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -44,5 +44,11 @@ ...@@ -44,5 +44,11 @@
where req_id = #{reqId,jdbcType=VARCHAR} where req_id = #{reqId,jdbcType=VARCHAR}
</select> </select>
<select id="findByApplyId" parameterType="java.lang.String" resultMap="applyLoanInfoZhuDaiMap">
select *
from apply_loan_info_zhudai
where apply_id = #{applyId,jdbcType=VARCHAR}
</select>
</mapper> </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.ApplyLoanInfoZhuDaiRefuseMapper">
<resultMap id="applyLoanInfoZhuDaiRefuseMap" type="cn.quantgroup.report.domain.baihang.ApplyLoanInfoZhuDaiRefuse">
<result property="recordId" jdbcType="VARCHAR" column="record_id"/>
<result property="reqID" jdbcType="VARCHAR" column="req_id"/>
<result property="opCode" jdbcType="VARCHAR" column="op_code"/>
<result property="uploadTs" jdbcType="VARCHAR" column="upload_ts"/>
<result property="isFinTechAgencyBusiness" jdbcType="INTEGER" column="is_fin_tech_agency_business"/>
<result property="applyDate" jdbcType="VARCHAR" column="apply_date"/>
<result property="applyId" jdbcType="VARCHAR" column="apply_id"/>
<result property="applyType" jdbcType="INTEGER" column="apply_type"/>
<result property="name" jdbcType="VARCHAR" column="name"/>
<result property="idType" jdbcType="INTEGER" column="id_type"/>
<result property="pid" jdbcType="VARCHAR" column="pid"/>
<result property="mobile" jdbcType="VARCHAR" column="mobile"/>
<result property="emailAddress" jdbcType="VARCHAR" column="email_address"/>
<result property="eduBackground" jdbcType="INTEGER" column="edu_background"/>
<result property="degree" jdbcType="INTEGER" column="degree"/>
<result property="guaranteeType" jdbcType="INTEGER" column="guarantee_type"/>
<result property="loanPurpose" jdbcType="INTEGER" column="loan_purpose"/>
<result property="customType" jdbcType="INTEGER" column="custom_type"/>
<result property="applyAmount" jdbcType="DECIMAL" column="apply_amount"/>
<result property="businessOrgCreditCode" jdbcType="VARCHAR" column="business_org_credit_code"/>
<result property="livingCondition" jdbcType="INTEGER" column="living_condition"/>
<result property="marriageStatus" jdbcType="INTEGER" column="marriage_status"/>
<result property="spouseName" jdbcType="VARCHAR" column="spouse_name"/>
</resultMap>
<select id="saveApplyLoanInfoZhuDaiRefuseLog" parameterType="cn.quantgroup.report.domain.baihang.ApplyLoanInfoZhuDaiRefuse">
insert into apply_loan_info_zhudai_refuse (record_id,req_id,op_code,upload_ts,is_fin_tech_agency_business,apply_date,
apply_id,apply_type,name,id_type,pid,mobile,email_address,edu_background,
degree,guarantee_type,loan_purpose,custom_type,apply_amount,business_org_credit_code,
living_condition,marriage_status,spouse_name)
VALUES (#{recordId},#{reqID},#{opCode},#{uploadTs},#{isFinTechAgencyBusiness},#{applyDate},#{applyId},#{applyType},#{name},#{idType},
#{pid},#{mobile},#{emailAddress},#{eduBackground},#{degree},#{guaranteeType},#{loanPurpose},#{customType},#{applyAmount},
#{businessOrgCreditCode},#{livingCondition},#{marriageStatus},#{spouseName})
</select>
<insert id="batchSaveLog" parameterType="java.util.List">
insert into apply_loan_info_zhudai_refuse (record_id,req_id,op_code,upload_ts,is_fin_tech_agency_business,apply_date,
apply_id,apply_type,name,id_type,pid,mobile,email_address,edu_background,
degree,guarantee_type,loan_purpose,custom_type,apply_amount,business_org_credit_code,
living_condition,marriage_status,spouse_name)
values
<foreach collection="list" item="item" index="index" separator="," >
(#{recordId},#{reqID},#{opCode},#{uploadTs},#{isFinTechAgencyBusiness},#{applyDate},#{applyId},#{applyType},#{name},#{idType},
#{pid},#{mobile},#{emailAddress},#{eduBackground},#{degree},#{guaranteeType},#{loanPurpose},#{customType},#{applyAmount},
#{businessOrgCreditCode},#{livingCondition},#{marriageStatus},#{spouseName})
</foreach>
</insert>
<select id="findApplyLoanInfoZhuDaiRefuseLog" parameterType="java.lang.String" resultMap="applyLoanInfoZhuDaiRefuseMap">
select *
from apply_loan_info_zhudai_refuse
where req_id = #{reqId,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