Commit 452c26c0 authored by 陈宏杰's avatar 陈宏杰

集合分组

parent c098b7a8
......@@ -17,6 +17,7 @@ import cn.quantgroup.report.utils.DateUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.common.base.Stopwatch;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -66,6 +67,9 @@ public class BaiHangFileReportService {
private static final Integer D3_INITIAL_CAPACITY = 5000;
private static final Integer LISTS_PARTITION_SIZE = 5000;
/**
* 创建报送文件 通常用于存量报送
* @param type 报送类型 A1:申请信息 D2:放款信息 D3:还款信息
......@@ -390,13 +394,7 @@ public class BaiHangFileReportService {
log.error("量化派助贷TO百行报送(D3)-逾期记录处理异常, recordId: {} , loanId: {} ", id, repaymentLoanInfo.getLoanId(), e);
}
}
try {
Stopwatch saveStopwatch = Stopwatch.createStarted();
repaymentLoanInfoDbMapper.batchSaveRepaymentLoanInfoLog(recordList);
log.info("量化派助贷TO百行报送(D3)-逾期记录批量插入结束, startTime: {} , endTime: {} , 大小: {} , 耗时: {} ", startTime, endTime, recordList.size(), (saveStopwatch.stop().elapsed(TimeUnit.MILLISECONDS) / 1000) + ".s");
} catch (Exception e) {
log.error("量化派助贷TO百行报送(D3)-逾期记录保存异常", e);
}
saveRepaymentLoanInfoLog(recordList,startTime,endTime);
File file = new File(HOST_PATH+"量子数科科技有限公司_D3O_"+fileNameReplaceAll(startTime.split("T")[0])+"_"+fileNameReplaceAll(endTime.split("T")[0])+"_"+String.format("%06d",new Random().nextInt(999999))+".txt");
FileUtils.writeLines(file,reportList);
if (reportList.size()<=1) {
......@@ -464,13 +462,7 @@ public class BaiHangFileReportService {
log.error("量化派助贷TO百行报送(D3)-每30天逾期记录处理异常, recordId: {} , loanId: {} ", id, repaymentLoanInfo.getLoanId(), e);
}
}
try {
Stopwatch saveStopwatch = Stopwatch.createStarted();
repaymentLoanInfoDbMapper.batchSaveRepaymentLoanInfoLog(recordList);
log.info("量化派助贷TO百行报送(D3)-每30天逾期记录批量插入结束, startTime: {} , endTime: {} , 大小: {} , 耗时: {} ", startTime, endTime, recordList.size(), (saveStopwatch.stop().elapsed(TimeUnit.MILLISECONDS) / 1000) + ".s");
} catch (Exception e) {
log.error("量化派助贷TO百行报送(D3)-每30天逾期记录保存异常", e);
}
saveRepaymentLoanInfoLog(recordList,startTime,endTime);
File file = new File(HOST_PATH+"量子数科科技有限公司_D3O30_"+fileNameReplaceAll(startTime.split("T")[0])+"_"+fileNameReplaceAll(endTime.split("T")[0])+"_"+String.format("%06d",new Random().nextInt(999999))+".txt");
FileUtils.writeLines(file,reportList);
if (reportList.size()<=1) {
......@@ -520,13 +512,7 @@ public class BaiHangFileReportService {
log.error("量化派助贷TO百行报送(D3)-还款记录处理异常, recordId: {} , loanId: {} ", id, repaymentLoanInfo.getLoanId(), e);
}
}
try {
Stopwatch saveStopwatch = Stopwatch.createStarted();
repaymentLoanInfoDbMapper.batchSaveRepaymentLoanInfoLog(recordList);
log.info("量化派助贷TO百行报送(D3)-还款记录批量插入结束, startTime: {} , endTime: {} , 大小: {} , 耗时: {} ", startTime, endTime, recordList.size(), (saveStopwatch.stop().elapsed(TimeUnit.MILLISECONDS) / 1000) + ".s");
} catch (Exception e) {
log.error("量化派助贷TO百行报送(D3)-还款记录保存异常", e);
}
saveRepaymentLoanInfoLog(recordList,startTime,endTime);
File file = new File(HOST_PATH+"量子数科科技有限公司_D3R_"+fileNameReplaceAll(startTime.split("T")[0])+"_"+fileNameReplaceAll(endTime.split("T")[0])+"_"+String.format("%06d",new Random().nextInt(999999))+".txt");
FileUtils.writeLines(file,reportList);
if (reportList.size()<=1) {
......@@ -550,4 +536,19 @@ public class BaiHangFileReportService {
}
}
private void saveRepaymentLoanInfoLog(List<RepaymentInfoZhuDai> recordList,String startTime, String endTime) {
if (!CollectionUtils.isEmpty(recordList)) {
try {
List<List<RepaymentInfoZhuDai>> allList = Lists.partition(recordList, LISTS_PARTITION_SIZE);
Stopwatch saveStopwatch = Stopwatch.createStarted();
allList.stream().forEach(pRecordList -> {
repaymentLoanInfoDbMapper.batchSaveRepaymentLoanInfoLog(pRecordList);
});
log.info("量化派助贷TO百行报送(D3)批量插入结束, startTime: {} , endTime: {} , 大小: {} , 耗时: {} ", startTime, endTime, recordList.size(), (saveStopwatch.stop().elapsed(TimeUnit.MILLISECONDS) / 1000) + ".s");
} catch (Exception e) {
log.error("量化派助贷TO百行报送(D3)保存异常", e);
}
}
}
}
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