Commit 17ae39e6 authored by 陈宏杰's avatar 陈宏杰

A1报送

parent d422d04a
...@@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.io.File;
import java.util.Date; import java.util.Date;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
...@@ -168,4 +169,15 @@ public class ManualToolController { ...@@ -168,4 +169,15 @@ public class ManualToolController {
} }
} }
@RequestMapping("/encryptFile")
public String encryptFile(String filePath){
try {
File file = new File(filePath);
fileReportService.encryptFile(file.getAbsolutePath());
return "SUCCESS";
}catch (Exception e){
return e.getMessage();
}
}
} }
...@@ -82,5 +82,5 @@ public class ApplyLoanInfoZhuDai { ...@@ -82,5 +82,5 @@ public class ApplyLoanInfoZhuDai {
//mac; //mac;
//ipAddress; //ipAddress;
//osName; //osName;
private String recordId;
} }
package cn.quantgroup.report.mapper.master;
import cn.quantgroup.report.domain.baihang.ApplyLoanInfoZhuDai;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* -----------------------------------------------------------------------------<br>
* 描述: 贷款申请信息 <br>
* 作者:hongjie.chen <br>
* 时间:2021.07.08 <br>
* -----------------------------------------------------------------------------
*/
@Repository
public interface ApplyLoanInfoZhuDaiMapper {
void saveApplyLoanInfoZhuDaiLog(ApplyLoanInfoZhuDai applyLoanInfoZhuDai);
List<ApplyLoanInfoZhuDai> findApplyLoanInfoZhuDaiLog(String reqId);
}
...@@ -5,11 +5,13 @@ import cn.quantgroup.report.error.QGException; ...@@ -5,11 +5,13 @@ import cn.quantgroup.report.error.QGException;
import cn.quantgroup.report.mapper.baihang.ApplyLoanInfoMapper; 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.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;
import cn.quantgroup.report.service.baihang.request.FileUploadRequest; import cn.quantgroup.report.service.baihang.request.FileUploadRequest;
import cn.quantgroup.report.service.baihang.response.FileUploadResponse; import cn.quantgroup.report.service.baihang.response.FileUploadResponse;
import cn.quantgroup.report.service.baihang.util.TuoMinUtils;
import cn.quantgroup.report.service.http.IHttpService; import cn.quantgroup.report.service.http.IHttpService;
import cn.quantgroup.report.utils.DateUtils; import cn.quantgroup.report.utils.DateUtils;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
...@@ -23,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -23,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.io.File; import java.io.File;
import java.time.LocalDateTime; import java.time.LocalDateTime;
...@@ -56,6 +59,8 @@ public class BaiHangFileReportService { ...@@ -56,6 +59,8 @@ public class BaiHangFileReportService {
public LoanInfoDbMapper loanInfoDbMapper; public LoanInfoDbMapper loanInfoDbMapper;
@Autowired @Autowired
public RepaymentLoanInfoDbMapper repaymentLoanInfoDbMapper; public RepaymentLoanInfoDbMapper repaymentLoanInfoDbMapper;
@Autowired
public ApplyLoanInfoZhuDaiMapper applyLoanInfoZhuDaiMapper;
private static final String HOST_PATH = "/home/quant_group/reportFile/"; private static final String HOST_PATH = "/home/quant_group/reportFile/";
...@@ -107,12 +112,66 @@ public class BaiHangFileReportService { ...@@ -107,12 +112,66 @@ public class BaiHangFileReportService {
} }
/** /**
* 贷款申请信息(A1) 暂时不支持A1报送 * 贷款申请信息(A1)
* @param starTime 开始时间 * @param starTime 开始时间
* @param endTime 截止时间 * @param endTime 截止时间
*/ */
private void reportA1(String starTime, String endTime){ private void reportA1(String starTime, String endTime){
throw new QGException(COMMON_ILLEGAL_PARAM_TOAST,"报送类型暂不支持"); try {
Stopwatch queryWatch1 = Stopwatch.createStarted();
BaiHangTimeRecord timeRecord = BaiHangTimeRecord.builder().startTime(starTime).endTime(endTime).build();
List<ApplyLoanInfoZhuDai> applyLoanInfos = applyLoanInfoMapper.findRealTimeApplyLoanZhuDai(timeRecord);
log.info("量化派助贷TO百行报送(A1)-非联合贷申请查询完成, 大小: {} , 耗时: {} ", (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();
List<String> reportList = new ArrayList<>();
reportList.add("#applyInfo");
String reqId_log = "";
List<ApplyLoanInfoZhuDai> zhuDaiLogList = null;
for (int i = 0; i < applyLoanInfos.size(); i++) {
try {
ApplyLoanInfoZhuDai applyLoanInfo = applyLoanInfos.get(i);
reqId_log = applyLoanInfo.getReqID();
zhuDaiLogList = applyLoanInfoZhuDaiMapper.findApplyLoanInfoZhuDaiLog(applyLoanInfo.getReqID());
if (CollectionUtils.isEmpty(zhuDaiLogList)) {
try {
ApplyLoanInfoZhuDai record = new ApplyLoanInfoZhuDai();
BeanUtils.copyProperties(applyLoanInfo, record);
record.setRecordId(UUID.randomUUID().toString().replaceAll("-", ""));
applyLoanInfoZhuDaiMapper.saveApplyLoanInfoZhuDaiLog(record);
} catch (Exception e) {
log.error("量化派助贷TO百行报送(A1)-贷款申请信息保存记录失败", e);
}
//邮箱有错误的就不传
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百行报送(A1)-贷款申请信息重复报送, applyLoanInfo: {} ", JSON.toJSONString(applyLoanInfo));
}
} catch (Exception e) {
log.error("量化派助贷TO百行报送(A1)-贷款申请信息异常, reqId_log: {} ", reqId_log, e);
}
}
File file = new File(HOST_PATH+"量子数科科技有限公司_A1_"+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百行报送(A1)-贷款申请信息为空,加密文件不生成!starTime={},endTime={}",starTime,endTime);
} else {
createFile(file.getAbsolutePath());
}
log.info("量化派助贷TO百行报送(A1)-贷款申请信息完成, 实际大小: {} , 报送成功大小: {} , 耗时: {} ", applyLoanInfos.size(), atomicInteger.get(), sendWatch.stop().elapsed(TimeUnit.MILLISECONDS));
} catch (Exception e) {
log.error("量化派助贷TO百行报送(A1)-异常", e);
}
} }
/** /**
...@@ -281,5 +340,16 @@ public class BaiHangFileReportService { ...@@ -281,5 +340,16 @@ public class BaiHangFileReportService {
} }
} }
private String fileNameReplaceAll(String str) {
if (str.length()<=0) {
return "";
}
return str.replaceAll("-","").replaceAll(":","").replaceAll(" ","");
}
public void encryptFile(String filePath){
createFile(filePath);
}
} }
<?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.ApplyLoanInfoZhuDaiMapper">
<resultMap id="applyLoanInfoZhuDaiMap" type="cn.quantgroup.report.domain.baihang.ApplyLoanInfoZhuDai">
<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="saveApplyLoanInfoZhuDaiLog" parameterType="cn.quantgroup.report.domain.baihang.ApplyLoanInfoZhuDai">
insert into apply_loan_info_zhudai (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>
<select id="findApplyLoanInfoZhuDaiLog" parameterType="java.lang.String" resultMap="applyLoanInfoZhuDaiMap">
select *
from apply_loan_info_zhudai
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