Commit 6506d06e authored by 郝彦辉's avatar 郝彦辉

写文件用批量写入

parent 52b51a60
......@@ -909,6 +909,8 @@ public class BaiHangZhuDaiService {
int counter = 0;
log.info("开始>>整理百行-助贷还款&逾期存量数据 startDate : {} , noEndDate : {} ......",startDate,noEndDate);
StringBuffer tmpWriteBuffer = null;
while (true) {
if(D3_Stop.get()){
log.error("All还款&逾期存量数据查询STOP, D3_Stop: {} , endTime: {} ",D3_Stop.get(), erlyDate.plusDays(counter).format(DateTimeFormatter.ISO_DATE));
......@@ -919,6 +921,7 @@ public class BaiHangZhuDaiService {
if (erlyDate.plusDays(counter).compareTo(endDate) > 0) {
break;
}
List<RepaymentInfoZhuDai> repaymentInfoList = new ArrayList<>();
List<RepaymentInfoZhuDai> repaymentLoanInfosLh = new ArrayList<>();
......@@ -931,11 +934,9 @@ public class BaiHangZhuDaiService {
long log_stUtc = System.currentTimeMillis();
try {
if (type == 0) {
if(StringUtils.isNotEmpty(d3Type) && d3Type.equals("1")){//只要逾期
continue;
}
//Stopwatch stopwatch = Stopwatch.createStarted();
/* repaymentInfoList = repaymentLoanInfoMapper.queryStockRepayMentInfoZhuDai(timeRecord);*/
......@@ -951,7 +952,6 @@ public class BaiHangZhuDaiService {
}
} else {
if(StringUtils.isNotEmpty(d3Type) && d3Type.equals("0")){//只要还款
continue;
}
......@@ -975,7 +975,8 @@ public class BaiHangZhuDaiService {
repaymentInfoList.addAll(repaymentLoanInfosLh);
}
tmpWriteBuffer = new StringBuffer();
int buffCount = 0;
for (int j = 0; j < repaymentInfoList.size(); j++) {
RepaymentInfoZhuDai repaymentInfo = repaymentInfoList.get(j);
String id = UUID.randomUUID().toString().replaceAll("-", "");
......@@ -994,12 +995,20 @@ public class BaiHangZhuDaiService {
repaymentInfo.setUploadTs(repaymentInfo.getStatusConfirmAt());
}
FileUtils.write(new File(fileName+"_01.txt"), JSON.toJSONString(repaymentInfo)+"\r\n", "UTF-8", true);
//这么写太慢了
///////FileUtils.write(new File(fileName+"_01.txt"), JSON.toJSONString(repaymentInfo)+"\r\n", "UTF-8", true);
//脱敏数据写一份
//testTuoMinFileWrite(fileName+"_TEST_01.txt",starTime,null,null,repaymentInfo);
tmpWriteBuffer.append(JSON.toJSONString(repaymentInfo)+"\r\n");
buffCount++;
}
FileUtils.write(new File(fileName+"_01.txt"), tmpWriteBuffer.toString(), "UTF-8", true);
log.info("批量写入文件结束,repaymentInfoList="+repaymentInfoList.size()+",buffCount="+buffCount+",Check Size="+(repaymentInfoList.size()==buffCount));
tmpWriteBuffer=null;
buffCount=0;
} catch (Exception e) {
log.error("还款&逾期存量数据处理异常, startTime: {} , endTime: {} , type: {} ", starTime, endTime, type, e);
try{
......
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