Commit 49f140b8 authored by 郑建's avatar 郑建

增加执行天间隔逻辑 防止单周期内数据量太大执行失败

parent 44d05d95
...@@ -159,8 +159,13 @@ public class ManualToolController { ...@@ -159,8 +159,13 @@ public class ManualToolController {
} }
@RequestMapping("/createFile") @RequestMapping("/createFile")
public void testD2Repost(String type, String startDate, String endDate){ public String testD2Repost(String type, String startDate, String endDate,Integer daySpilt){
fileReportService.createReportFile(type,startDate+"T00:00:00",endDate+"T00:00:00"); try {
fileReportService.createReportFile(type,startDate,endDate,daySpilt);
return "SUCCESS";
}catch (Exception e){
return e.getMessage();
}
} }
} }
...@@ -27,10 +27,7 @@ import org.springframework.stereotype.Service; ...@@ -27,10 +27,7 @@ import org.springframework.stereotype.Service;
import java.io.File; import java.io.File;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
...@@ -65,38 +62,53 @@ public class BaiHangFileReportService { ...@@ -65,38 +62,53 @@ public class BaiHangFileReportService {
/** /**
* 创建报送文件 通常用于存量报送 * 创建报送文件 通常用于存量报送
* @param type 报送类型 A1:申请信息 D2:放款信息 D3:还款信息 * @param type 报送类型 A1:申请信息 D2:放款信息 D3:还款信息
* @param startDate 报送区间的开始时间 格式:"2019-05-07T00:00:00" * @param start 报送区间的开始时间 格式:"2019-05-07T00:00:00"
* @param endDate 报送区间的截止时间 格式:"2019-05-07T00:00:00" * @param end 报送区间的截止时间 格式:"2019-05-07T00:00:00"
*/ */
public void createReportFile(String type, String startDate, String endDate) { @Async
if (StringUtils.isAnyBlank(type, startDate, endDate)) { public void createReportFile(String type, String start, String end,int daySplitCount) {
if (StringUtils.isAnyBlank(type, start, end)) {
throw new QGException(COMMON_ILLEGAL_PARAM_TOAST,"存在为空参数"); throw new QGException(COMMON_ILLEGAL_PARAM_TOAST,"存在为空参数");
} }
if (startDate.length() != 19 || endDate.length() != 19 || !startDate.contains("T") || !endDate.contains("T")) { String dateFormat = "yyyy-MM-dd";
log.warn("日期格式有误, startDate : {} , endDate : {} ", startDate, endDate); Date stepStartDate = DateUtils.parseDate(dateFormat,start);
throw new QGException(COMMON_ILLEGAL_PARAM_TOAST,"日期格式错误"); Date stepEndDate = org.apache.commons.lang3.time.DateUtils.addDays(stepStartDate,daySplitCount);
Date endDate = DateUtils.parseDate(dateFormat,end);
Stopwatch stopwatch = Stopwatch.createStarted();
while (stepEndDate.getTime() <= endDate.getTime()){
createReportFile(type,stepStartDate,stepEndDate);
stepStartDate = new Date(stepEndDate.getTime());
stepEndDate = org.apache.commons.lang3.time.DateUtils.addDays(stepEndDate,daySplitCount);
} }
String starTime = LocalDateTime.parse(startDate).format(DateTimeFormatter.ISO_DATE); log.info("当前 {} -- {}--{} 任务执行结束 总耗时 : {}",type,start,end,stopwatch.elapsed(TimeUnit.MILLISECONDS));
String endTime = LocalDateTime.parse(endDate).format(DateTimeFormatter.ISO_DATE); if (stepEndDate.getTime() > endDate.getTime()){
if ("A1".equalsIgnoreCase(type)) { createReportFile(type,stepStartDate,endDate);
reportA1(starTime,endTime);
} else if ("D2".equalsIgnoreCase(type)) {
reportD2(starTime,endTime);
} else if ("D3".equalsIgnoreCase(type)) {
reportD3(starTime,endTime);
} else {
throw new QGException(COMMON_ILLEGAL_PARAM_TOAST,"报送类型不正确");
} }
} }
private void createReportFile(String type, Date startDate, Date endDate) {
Stopwatch stopwatch = Stopwatch.createStarted();
String starTime = DateUtils.formatDate(startDate,"yyyy-MM-dd hh:mm:ss");
String endTime = DateUtils.formatDate(endDate,"yyyy-MM-dd hh:mm:ss");
log.info("开始生成报送文件{}----- {} -- {}",type,starTime,endTime);
// if ("A1".equalsIgnoreCase(type)) {
// reportA1(starTime,endTime);
// } else if ("D2".equalsIgnoreCase(type)) {
// reportD2(starTime,endTime);
// } else if ("D3".equalsIgnoreCase(type)) {
// reportD3(starTime,endTime);
// } else {
// throw new QGException(COMMON_ILLEGAL_PARAM_TOAST,"报送类型不正确");
// }
log.info("生成报送文件结束{}----- {} -- {},耗时 {}",type,starTime,endTime,stopwatch.elapsed(TimeUnit.MILLISECONDS));
}
/** /**
* 贷款申请信息(A1) 暂时不支持A1报送 * 贷款申请信息(A1) 暂时不支持A1报送
* @param starTime 开始时间 * @param starTime 开始时间
* @param endTime 截止时间 * @param endTime 截止时间
*/ */
@Async private void reportA1(String starTime, String endTime){
public void reportA1(String starTime, String endTime){
throw new QGException(COMMON_ILLEGAL_PARAM_TOAST,"报送类型暂不支持"); throw new QGException(COMMON_ILLEGAL_PARAM_TOAST,"报送类型暂不支持");
} }
...@@ -105,8 +117,7 @@ public class BaiHangFileReportService { ...@@ -105,8 +117,7 @@ public class BaiHangFileReportService {
* @param starTime 开始时间 * @param starTime 开始时间
* @param endTime 截至时间 * @param endTime 截至时间
*/ */
@Async private void reportD2(String starTime, String endTime) {
public void reportD2(String starTime, String endTime) {
Stopwatch stopwatch = Stopwatch.createStarted(); Stopwatch stopwatch = Stopwatch.createStarted();
try { try {
List<LoanInfoZhuDai> loanInfozdList = loanInfoMapper.queryStockLoanInfoZhuDai(BaiHangTimeRecord.builder().startTime(starTime).endTime(endTime).build()); List<LoanInfoZhuDai> loanInfozdList = loanInfoMapper.queryStockLoanInfoZhuDai(BaiHangTimeRecord.builder().startTime(starTime).endTime(endTime).build());
...@@ -170,8 +181,7 @@ public class BaiHangFileReportService { ...@@ -170,8 +181,7 @@ public class BaiHangFileReportService {
* @param startTime 开始时间 * @param startTime 开始时间
* @param endTime 截止时间 * @param endTime 截止时间
*/ */
@Async private void reportD3( String startTime, String endTime) {
public void reportD3( String startTime, String endTime) {
for (int j = 0; j < 2; j++) { for (int j = 0; j < 2; j++) {
List<String> reportList = new ArrayList<>(); List<String> reportList = new ArrayList<>();
reportList.add("#singleLoanRepayInfo"); reportList.add("#singleLoanRepayInfo");
......
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