Commit 0f8a765a authored by 陈宏杰's avatar 陈宏杰

批量插入

parent 0f58c44d
...@@ -37,4 +37,6 @@ public interface RepaymentLoanInfoDbMapper { ...@@ -37,4 +37,6 @@ public interface RepaymentLoanInfoDbMapper {
*/ */
List<RepaymentLoanInfoLog> findByD3RecordId(String[] recordIdArray); List<RepaymentLoanInfoLog> findByD3RecordId(String[] recordIdArray);
void batchSaveRepaymentLoanInfoLog(List<RepaymentInfoZhuDai> list);
} }
...@@ -320,8 +320,8 @@ public class BaiHangFileReportService { ...@@ -320,8 +320,8 @@ public class BaiHangFileReportService {
* @param endTime 截止时间 * @param endTime 截止时间
*/ */
private void reportD3O(String startTime, String endTime) { private void reportD3O(String startTime, String endTime) {
List<RepaymentInfoZhuDai> repaymentLoanInfos = null; List<RepaymentInfoZhuDai> repaymentLoanInfos = null,recordList = new ArrayList<>(5000);
List<String> reportList = new ArrayList<>(); List<String> reportList = new ArrayList<>(5000);
reportList.add("#singleLoanRepayInfo"); reportList.add("#singleLoanRepayInfo");
Stopwatch sendWatch = Stopwatch.createStarted(); Stopwatch sendWatch = Stopwatch.createStarted();
try { try {
...@@ -334,14 +334,10 @@ public class BaiHangFileReportService { ...@@ -334,14 +334,10 @@ public class BaiHangFileReportService {
RepaymentInfoZhuDai repaymentLoanInfo = repaymentLoanInfos.get(i); RepaymentInfoZhuDai repaymentLoanInfo = repaymentLoanInfos.get(i);
try { try {
id = UUID.randomUUID().toString().replaceAll("-", ""); id = UUID.randomUUID().toString().replaceAll("-", "");
try { RepaymentInfoZhuDai record = new RepaymentInfoZhuDai();
RepaymentInfoZhuDai record = new RepaymentInfoZhuDai(); BeanUtils.copyProperties(repaymentLoanInfo, record);
BeanUtils.copyProperties(repaymentLoanInfo, record); record.setRecordId(id);
record.setRecordId(id); recordList.add(record);
repaymentLoanInfoDbMapper.saveRepaymentLoanInfoLog(record);
} catch (Exception e) {
log.error("量化派助贷TO百行报送(D3)-逾期记录保存异常", e);
}
repaymentLoanInfo.setReqID(id); repaymentLoanInfo.setReqID(id);
repaymentLoanInfo.setName(sensitiveFilter(repaymentLoanInfo.getName())); repaymentLoanInfo.setName(sensitiveFilter(repaymentLoanInfo.getName()));
repaymentLoanInfo.setPid(sensitiveFilter(repaymentLoanInfo.getPid())); repaymentLoanInfo.setPid(sensitiveFilter(repaymentLoanInfo.getPid()));
...@@ -352,6 +348,11 @@ public class BaiHangFileReportService { ...@@ -352,6 +348,11 @@ public class BaiHangFileReportService {
log.error("量化派助贷TO百行报送(D3)-逾期记录处理异常, recordId: {} , loanId: {} ", id, repaymentLoanInfo.getLoanId(), e); log.error("量化派助贷TO百行报送(D3)-逾期记录处理异常, recordId: {} , loanId: {} ", id, repaymentLoanInfo.getLoanId(), e);
} }
} }
try {
repaymentLoanInfoDbMapper.batchSaveRepaymentLoanInfoLog(recordList);
} catch (Exception e) {
log.error("量化派助贷TO百行报送(D3)-逾期记录保存异常", e);
}
File file = new File("量子数科科技有限公司_D3O_"+fileNameReplaceAll(startTime.split("T")[0])+"_"+fileNameReplaceAll(endTime.split("T")[0])+"_"+String.format("%06d",new Random().nextInt(999999))+".txt"); File file = new File("量子数科科技有限公司_D3O_"+fileNameReplaceAll(startTime.split("T")[0])+"_"+fileNameReplaceAll(endTime.split("T")[0])+"_"+String.format("%06d",new Random().nextInt(999999))+".txt");
FileUtils.writeLines(file,reportList); FileUtils.writeLines(file,reportList);
if (reportList.size()<=1) { if (reportList.size()<=1) {
...@@ -371,12 +372,12 @@ public class BaiHangFileReportService { ...@@ -371,12 +372,12 @@ public class BaiHangFileReportService {
private void reportD3OFor30Day(String startTime, String endTime) { private void reportD3OFor30Day(String startTime, String endTime) {
List<LoanApplicationHistoryIdInfo> idInfos = null; List<LoanApplicationHistoryIdInfo> idInfos = null;
LoanApplicationHistoryIdInfo idInfo = null; LoanApplicationHistoryIdInfo idInfo = null;
List<RepaymentInfoZhuDai> repaymentLoanInfos = new ArrayList<>(),tempRepaymentLoanInfos = null; List<RepaymentInfoZhuDai> repaymentLoanInfos = new ArrayList<>(5000),tempRepaymentLoanInfos = null,recordList = new ArrayList<>(5000);
Date stepEndDate = null; Date stepEndDate = null;
Integer step = null; Integer step = null;
String id = ""; String id = "";
AtomicInteger atomicInteger = new AtomicInteger(); AtomicInteger atomicInteger = new AtomicInteger();
List<String> reportList = new ArrayList<>(); List<String> reportList = new ArrayList<>(5000);
reportList.add("#singleLoanRepayInfo"); reportList.add("#singleLoanRepayInfo");
Stopwatch sendWatch = Stopwatch.createStarted(); Stopwatch sendWatch = Stopwatch.createStarted();
try { try {
...@@ -403,14 +404,10 @@ public class BaiHangFileReportService { ...@@ -403,14 +404,10 @@ public class BaiHangFileReportService {
RepaymentInfoZhuDai repaymentLoanInfo = repaymentLoanInfos.get(i); RepaymentInfoZhuDai repaymentLoanInfo = repaymentLoanInfos.get(i);
try { try {
id = UUID.randomUUID().toString().replaceAll("-", ""); id = UUID.randomUUID().toString().replaceAll("-", "");
try { RepaymentInfoZhuDai record = new RepaymentInfoZhuDai();
RepaymentInfoZhuDai record = new RepaymentInfoZhuDai(); BeanUtils.copyProperties(repaymentLoanInfo, record);
BeanUtils.copyProperties(repaymentLoanInfo, record); record.setRecordId(id);
record.setRecordId(id); recordList.add(record);
repaymentLoanInfoDbMapper.saveRepaymentLoanInfoLog(record);
} catch (Exception e) {
log.error("量化派助贷TO百行报送(D3)-每30天逾期记录保存异常", e);
}
repaymentLoanInfo.setReqID(id); repaymentLoanInfo.setReqID(id);
repaymentLoanInfo.setName(sensitiveFilter(repaymentLoanInfo.getName())); repaymentLoanInfo.setName(sensitiveFilter(repaymentLoanInfo.getName()));
repaymentLoanInfo.setPid(sensitiveFilter(repaymentLoanInfo.getPid())); repaymentLoanInfo.setPid(sensitiveFilter(repaymentLoanInfo.getPid()));
...@@ -421,6 +418,11 @@ public class BaiHangFileReportService { ...@@ -421,6 +418,11 @@ public class BaiHangFileReportService {
log.error("量化派助贷TO百行报送(D3)-每30天逾期记录处理异常, recordId: {} , loanId: {} ", id, repaymentLoanInfo.getLoanId(), e); log.error("量化派助贷TO百行报送(D3)-每30天逾期记录处理异常, recordId: {} , loanId: {} ", id, repaymentLoanInfo.getLoanId(), e);
} }
} }
try {
repaymentLoanInfoDbMapper.batchSaveRepaymentLoanInfoLog(recordList);
} catch (Exception e) {
log.error("量化派助贷TO百行报送(D3)-每30天逾期记录保存异常", e);
}
File file = new File("量子数科科技有限公司_D3O30_"+fileNameReplaceAll(startTime.split("T")[0])+"_"+fileNameReplaceAll(endTime.split("T")[0])+"_"+String.format("%06d",new Random().nextInt(999999))+".txt"); File file = new File("量子数科科技有限公司_D3O30_"+fileNameReplaceAll(startTime.split("T")[0])+"_"+fileNameReplaceAll(endTime.split("T")[0])+"_"+String.format("%06d",new Random().nextInt(999999))+".txt");
FileUtils.writeLines(file,reportList); FileUtils.writeLines(file,reportList);
if (reportList.size()<=1) { if (reportList.size()<=1) {
...@@ -440,8 +442,8 @@ public class BaiHangFileReportService { ...@@ -440,8 +442,8 @@ public class BaiHangFileReportService {
* @param endTime 截止时间 * @param endTime 截止时间
*/ */
private void reportD3R(String startTime, String endTime) { private void reportD3R(String startTime, String endTime) {
List<RepaymentInfoZhuDai> repaymentLoanInfos = null; List<RepaymentInfoZhuDai> repaymentLoanInfos = null,recordList = new ArrayList<>(5000);
List<String> reportList = new ArrayList<>(); List<String> reportList = new ArrayList<>(5000);
reportList.add("#singleLoanRepayInfo"); reportList.add("#singleLoanRepayInfo");
Stopwatch sendWatch = Stopwatch.createStarted(); Stopwatch sendWatch = Stopwatch.createStarted();
try { try {
...@@ -454,14 +456,10 @@ public class BaiHangFileReportService { ...@@ -454,14 +456,10 @@ public class BaiHangFileReportService {
RepaymentInfoZhuDai repaymentLoanInfo = repaymentLoanInfos.get(i); RepaymentInfoZhuDai repaymentLoanInfo = repaymentLoanInfos.get(i);
try { try {
id = UUID.randomUUID().toString().replaceAll("-", ""); id = UUID.randomUUID().toString().replaceAll("-", "");
try { RepaymentInfoZhuDai record = new RepaymentInfoZhuDai();
RepaymentInfoZhuDai record = new RepaymentInfoZhuDai(); BeanUtils.copyProperties(repaymentLoanInfo, record);
BeanUtils.copyProperties(repaymentLoanInfo, record); record.setRecordId(id);
record.setRecordId(id); recordList.add(record);
repaymentLoanInfoDbMapper.saveRepaymentLoanInfoLog(record);
} catch (Exception e) {
log.error("量化派助贷TO百行报送(D3)-还款记录保存异常", e);
}
repaymentLoanInfo.setReqID(id); repaymentLoanInfo.setReqID(id);
repaymentLoanInfo.setName(sensitiveFilter(repaymentLoanInfo.getName())); repaymentLoanInfo.setName(sensitiveFilter(repaymentLoanInfo.getName()));
repaymentLoanInfo.setPid(sensitiveFilter(repaymentLoanInfo.getPid())); repaymentLoanInfo.setPid(sensitiveFilter(repaymentLoanInfo.getPid()));
...@@ -472,6 +470,11 @@ public class BaiHangFileReportService { ...@@ -472,6 +470,11 @@ public class BaiHangFileReportService {
log.error("量化派助贷TO百行报送(D3)-还款记录处理异常, recordId: {} , loanId: {} ", id, repaymentLoanInfo.getLoanId(), e); log.error("量化派助贷TO百行报送(D3)-还款记录处理异常, recordId: {} , loanId: {} ", id, repaymentLoanInfo.getLoanId(), e);
} }
} }
try {
repaymentLoanInfoDbMapper.batchSaveRepaymentLoanInfoLog(recordList);
} catch (Exception e) {
log.error("量化派助贷TO百行报送(D3)-还款记录保存异常", e);
}
File file = new File("量子数科科技有限公司_D3R_"+fileNameReplaceAll(startTime.split("T")[0])+"_"+fileNameReplaceAll(endTime.split("T")[0])+"_"+String.format("%06d",new Random().nextInt(999999))+".txt"); File file = new File("量子数科科技有限公司_D3R_"+fileNameReplaceAll(startTime.split("T")[0])+"_"+fileNameReplaceAll(endTime.split("T")[0])+"_"+String.format("%06d",new Random().nextInt(999999))+".txt");
FileUtils.writeLines(file,reportList); FileUtils.writeLines(file,reportList);
if (reportList.size()<=1) { if (reportList.size()<=1) {
......
...@@ -92,4 +92,16 @@ ...@@ -92,4 +92,16 @@
</foreach> </foreach>
</select> </select>
<insert id="batchSaveRepaymentLoanInfoLog" parameterType="java.util.List">
insert into repayment_loan_info_zhudai
(record_id,req_id ,name,pid ,mobile ,op_code ,upload_ts ,loan_id ,term_no ,term_status ,target_repayment_date ,real_repayment_date,planned_payment ,target_repayment,real_repayment ,overdue_amount,remaining_amount,overdue_status,loan_status,status_confirm_at)
values
<foreach collection="list" item="item" index="index" separator="," >
(#{item.recordId, jdbcType=VARCHAR},#{item.reqID, jdbcType=VARCHAR},#{item.name, jdbcType=VARCHAR},#{item.pid, jdbcType=VARCHAR},#{item.mobile, jdbcType=VARCHAR},#{item.opCode, jdbcType=VARCHAR},
#{item.uploadTs, jdbcType=VARCHAR},#{item.loanId, jdbcType=VARCHAR},#{item.termNo, jdbcType=INTEGER},#{item.termStatus, jdbcType=INTEGER},#{item.targetRepaymentDate, jdbcType=VARCHAR},#{item.realRepaymentDate, jdbcType=VARCHAR},
#{item.plannedPayment, jdbcType=DECIMAL},#{item.targetRepayment, jdbcType=DECIMAL},#{item.realRepayment, jdbcType=DECIMAL},#{item.overdueAmount, jdbcType=DECIMAL},#{item.remainingAmount, jdbcType=DECIMAL},
#{item.overdueStatus, jdbcType=INTEGER},#{item.loanStatus, jdbcType=INTEGER},#{item.statusConfirmAt, jdbcType=VARCHAR})
</foreach>
</insert>
</mapper> </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