Commit 47ca61ac authored by 陈宏杰's avatar 陈宏杰

新老数据衔接

parent b1d3bc34
......@@ -132,11 +132,11 @@ public class BaiHangFileReportService {
String encryptFileName = null;
List<String> encryptFileNameList = new LinkedList();
daySplitCount = Objects.isNull(daySplitCount) ? 10 : daySplitCount;
String dateFormat = "yyyy-MM-dd";
String dateFormat = "yyyy-MM-dd HH:mm:ss";
Date stepStartDate = DateUtils.parseDate(dateFormat,start);
Date stepEndDate = org.apache.commons.lang3.time.DateUtils.addDays(stepStartDate,daySplitCount);
// D3 还款记录 防止漏期
Date endDate = "D3R".equalsIgnoreCase(type) ? org.apache.commons.lang3.time.DateUtils.addDays(new Date(),1) : DateUtils.parseDate(dateFormat,end);
Date endDate = StringUtils.containsAny(type,"D3R","D3O","D3O30") ? org.apache.commons.lang3.time.DateUtils.addDays(new Date(),1) : DateUtils.parseDate(dateFormat,end);
Date loanStartDate = StringUtils.isBlank(loanStartDateStr) ? new Date() : DateUtils.parseDate(dateFormat,loanStartDateStr);
Date loanEndDate = StringUtils.isBlank(loanEndDateStr) ? new Date() : DateUtils.parseDate(dateFormat,loanEndDateStr);
Stopwatch stopwatch = Stopwatch.createStarted();
......@@ -185,11 +185,11 @@ public class BaiHangFileReportService {
// encryptFileName = reportD3(starTime,endTime,prefix);
throw new QGException(COMMON_ILLEGAL_PARAM_TOAST,"暂不支持该类型数据报送");
} else if ("D3O".equalsIgnoreCase(type)) {
encryptFileName = reportD3O(starTime,endTime,prefix);
encryptFileName = reportD3O(starTime,endTime,loanStartTime,loanEndTime,prefix);
} else if ("D3R".equalsIgnoreCase(type)) {
encryptFileName = reportD3R(starTime,endTime,loanStartTime,loanEndTime,prefix);
} else if ("D3O30".equalsIgnoreCase(type)) {
encryptFileName = reportD3OFor30Day(starTime,endTime,prefix);
encryptFileName = reportD3OFor30Day(starTime,endTime,loanStartTime,loanEndTime,prefix);
} else {
throw new QGException(COMMON_ILLEGAL_PARAM_TOAST,"报送类型不正确");
}
......@@ -553,7 +553,7 @@ public class BaiHangFileReportService {
* @param startTime 开始时间
* @param endTime 截止时间
*/
private String reportD3O(String startTime, String endTime, String prefix) {
private String reportD3O(String startTime, String endTime, String loanStartTime, String loanEndTime, String prefix) {
String encryptFileName = null;
List<RepaymentInfoZhuDai> repaymentLoanInfos = null,recordList = new ArrayList<>(D3_INITIAL_CAPACITY);
List<String> reportList = new ArrayList<>(D3_INITIAL_CAPACITY);
......@@ -561,7 +561,7 @@ public class BaiHangFileReportService {
Stopwatch sendWatch = Stopwatch.createStarted();
try {
Stopwatch queryStopwatch = Stopwatch.createStarted();
repaymentLoanInfos = repaymentLoanInfoMapper.queryOverdueRecordOfD3(BaiHangTimeRecord.builder().startTime(startTime).endTime(endTime).build());
repaymentLoanInfos = repaymentLoanInfoMapper.queryOverdueRecordOfD3(BaiHangTimeRecord.builder().startTime(startTime).endTime(endTime).loanStartTime(loanStartTime).loanEndTime(loanEndTime).build());
log.info("量化派助贷TO百行报送(D3)-逾期记录查询结束, startTime: {} , endTime: {} , 大小: {} , 耗时: {} ", startTime, endTime, repaymentLoanInfos.size(), (queryStopwatch.stop().elapsed(TimeUnit.MILLISECONDS) / 1000) + ".s");
AtomicInteger atomicInteger = new AtomicInteger();
String id = "";
......@@ -607,7 +607,7 @@ public class BaiHangFileReportService {
/**
* 应还款日次日起,每30天的次日报送一次逾期记录,直至结清或转出
*/
private String reportD3OFor30Day(String startTime, String endTime, String prefix) {
private String reportD3OFor30Day(String startTime, String endTime, String loanStartTime, String loanEndTime, String prefix) {
String encryptFileName = null;
List<LoanApplicationHistoryIdInfo> idInfos = null;
LoanApplicationHistoryIdInfo idInfo = null;
......@@ -621,16 +621,21 @@ public class BaiHangFileReportService {
Stopwatch sendWatch = Stopwatch.createStarted();
try {
Stopwatch queryStopwatch = Stopwatch.createStarted();
idInfos = repaymentLoanInfoMapper.queryLoanApplicationHistoryIdInfo(BaiHangTimeRecord.builder().startTime(startTime).endTime(endTime).build());
idInfos = repaymentLoanInfoMapper.queryLoanApplicationHistoryIdInfo(BaiHangTimeRecord.builder().loanStartTime(loanStartTime).loanEndTime(loanEndTime).build());
log.info("量化派助贷TO百行报送(D3)-每30天逾期记录总数查询结束, startTime: {} , endTime: {} , 大小: {} , 耗时: {} ", startTime, endTime, CollectionUtils.isEmpty(idInfos) ? 0 : idInfos.size(), (queryStopwatch.stop().elapsed(TimeUnit.MILLISECONDS) / 1000) + ".s");
for(int i = 0; i < idInfos.size(); i++) {
step = 1;
idInfo = idInfos.get(i);
if (Objects.isNull(idInfo.getRepaymentReceivedAt()) || "2000-01-01".equals(DateUtils.formatDate(idInfo.getRepaymentReceivedAt(),"yyyy-MM-dd"))) {
idInfo.setRepaymentReceivedAt(new Date());
idInfo.setRepaymentReceivedAt(DateUtils.parseDate("yyyy-MM-dd HH:mm:ss",endTime));
}
while (Boolean.TRUE) {
stepEndDate = org.apache.commons.lang3.time.DateUtils.addDays(idInfo.getDeadline(),30*step);
if (stepEndDate.compareTo(DateUtils.parseDate("yyyy-MM-dd HH:mm:ss",startTime))<0) {
log.info("每30天逾期-跳过日期 {} , loanApplicationHistoryId = {}",DateUtils.parse(stepEndDate),idInfo.getLoanApplicationHistoryId());
step++;
continue;
}
if (stepEndDate.compareTo(idInfo.getRepaymentReceivedAt())>0) {
break;
}
......
......@@ -990,12 +990,13 @@
from (select a.*
from xyqb.repayment_plan a
left join xyqb.loan_application_manifest_history b
on a.loan_application_history_id=b.loan_application_history_id and b.loan_paid_at >= #{startTime,jdbcType=VARCHAR} and b.loan_paid_at &lt; #{endTime,jdbcType=VARCHAR}
on a.loan_application_history_id=b.loan_application_history_id and b.loan_paid_at >= #{loanStartTime,jdbcType=VARCHAR} and b.loan_paid_at &lt; #{loanEndTime,jdbcType=VARCHAR}
where (a.repayment_status !=3 or (a.repayment_status =3 and a.repaid_at>=a.deadline))
and b.funding_corp_id in (1080,100040,1030,100030)
and b.transaction_status in (2,5)
and b.contract_term not in (2,3)
and a.deadline &lt; NOW()) a
and a.deadline >= #{startTime,jdbcType=VARCHAR}
and a.deadline &lt; #{endTime,jdbcType=VARCHAR}) a
left join xyqb_user.user_detail b on a.user_id=b.user_id
left join xyqb.loan_account_ext c on a.loan_application_history_id=c.loan_id
left join xyqb.apply_quota_record d on c.order_no=d.order_no
......@@ -1004,7 +1005,7 @@
,min(if(((a.repayment_status !=3 and (c.repayment_received_at is null or DATE_FORMAT(c.repayment_received_at,'%Y-%m-%d') = '2000-01-01' or a.deadline &lt;= c.repayment_received_at)) or (a.repayment_status =3 and a.deadline &lt;= c.repayment_received_at)),c.deadline,null)) min_deadline
from xyqb.repayment_plan a
left join xyqb.loan_application_manifest_history b
on a.loan_application_history_id=b.loan_application_history_id and b.loan_paid_at >= #{startTime,jdbcType=VARCHAR} and b.loan_paid_at &lt; #{endTime,jdbcType=VARCHAR}
on a.loan_application_history_id=b.loan_application_history_id and b.loan_paid_at >= #{loanStartTime,jdbcType=VARCHAR} and b.loan_paid_at &lt; #{loanEndTime,jdbcType=VARCHAR}
left join xyqb.repayment_record g on a.id=g.repayment_plan_id
left join xyqb.plan_amount_detail h on a.id=h.plan_id
left join xyqb.repayment_plan c on a.loan_application_history_id=c.loan_application_history_id
......@@ -1017,7 +1018,7 @@
,sum(if(g.repayment_status !=3 or (g.repayment_status =3 and if(TO_DAYS(IFNULL(a.repayment_received_at,NOW()))!=TO_DAYS(date(DATE_sub(a.deadline,INTERVAL 1 second))),a.deadline,a.repayment_received_at) &lt;= g.repayment_received_at),if(b.loan_paid_at>='2018-01-01',g.principal,h.principle),0)) dkye
from xyqb.repayment_plan a
left join xyqb.loan_application_manifest_history b
on a.loan_application_history_id=b.loan_application_history_id and b.loan_paid_at >= #{startTime,jdbcType=VARCHAR} and b.loan_paid_at &lt; #{endTime,jdbcType=VARCHAR}
on a.loan_application_history_id=b.loan_application_history_id and b.loan_paid_at >= #{loanStartTime,jdbcType=VARCHAR} and b.loan_paid_at &lt; #{loanEndTime,jdbcType=VARCHAR}
left join xyqb.repayment_record g on a.loan_application_history_id=g.loan_application_history_id
left join xyqb.plan_amount_detail h on a.id=h.plan_id
where b.funding_corp_id in (1080,100040,1030,100030)
......@@ -1028,7 +1029,7 @@
if(TO_DAYS(IFNULL(a.repayment_received_at,NOW()))!=TO_DAYS(date(DATE_sub(a.deadline,INTERVAL 1 second))),a.deadline,a.repayment_received_at) received_at
from xyqb.repayment_plan a
left join xyqb.loan_application_manifest_history b
on a.loan_application_history_id=b.loan_application_history_id and b.loan_paid_at >= #{startTime,jdbcType=VARCHAR} and b.loan_paid_at &lt; #{endTime,jdbcType=VARCHAR}
on a.loan_application_history_id=b.loan_application_history_id and b.loan_paid_at >= #{loanStartTime,jdbcType=VARCHAR} and b.loan_paid_at &lt; #{loanEndTime,jdbcType=VARCHAR}
where b.funding_corp_id in (1080,100040,1030,100030)
group by a.loan_application_history_id,a.term_no
) z on a.loan_application_history_id=z.loan_application_history_id and a.term_no=z.term_no
......@@ -1182,7 +1183,7 @@
select a.loan_application_history_id,max(a.repayment_received_at) as repaymentReceivedAt,max(a.deadline) as deadline
from xyqb.repayment_plan a
left join xyqb.loan_application_manifest_history b
on a.loan_application_history_id=b.loan_application_history_id and b.loan_paid_at >= #{startTime,jdbcType=VARCHAR} and b.loan_paid_at &lt; #{endTime,jdbcType=VARCHAR}
on a.loan_application_history_id=b.loan_application_history_id and b.loan_paid_at >= #{loanStartTime,jdbcType=VARCHAR} and b.loan_paid_at &lt; #{loanEndTime,jdbcType=VARCHAR}
where (a.repayment_status !=3 or (a.repayment_status =3 and a.repaid_at>=a.deadline))
and b.funding_corp_id in (1080,100040,1030,100030)
and b.transaction_status in (2,5)
......
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