Commit 2a96f9cf authored by 陈宏杰's avatar 陈宏杰

请勿重复操作

parent fa329ad4
...@@ -9,6 +9,7 @@ import cn.quantgroup.report.mapper.master.ApplyLoanInfoZhuDaiMapper; ...@@ -9,6 +9,7 @@ import cn.quantgroup.report.mapper.master.ApplyLoanInfoZhuDaiMapper;
import cn.quantgroup.report.mapper.master.LoanInfoDbMapper; import cn.quantgroup.report.mapper.master.LoanInfoDbMapper;
import cn.quantgroup.report.mapper.master.RepaymentLoanInfoDbMapper; import cn.quantgroup.report.mapper.master.RepaymentLoanInfoDbMapper;
import cn.quantgroup.report.service.baihang.client.BhFileCreditApiClient; import cn.quantgroup.report.service.baihang.client.BhFileCreditApiClient;
import cn.quantgroup.report.service.baihang.constant.Constant;
import cn.quantgroup.report.service.baihang.request.FileUploadRequest; import cn.quantgroup.report.service.baihang.request.FileUploadRequest;
import cn.quantgroup.report.service.baihang.response.FileUploadResponse; import cn.quantgroup.report.service.baihang.response.FileUploadResponse;
import cn.quantgroup.report.service.baihang.util.TuoMinUtils; import cn.quantgroup.report.service.baihang.util.TuoMinUtils;
...@@ -24,6 +25,7 @@ import org.apache.commons.lang3.StringUtils; ...@@ -24,6 +25,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
...@@ -69,6 +71,9 @@ public class BaiHangFileReportService { ...@@ -69,6 +71,9 @@ public class BaiHangFileReportService {
private static final Integer LISTS_PARTITION_SIZE = 5000; private static final Integer LISTS_PARTITION_SIZE = 5000;
@Autowired
private RedisTemplate<String,String> redisTemplate;
/** /**
* 创建报送文件 通常用于存量报送 * 创建报送文件 通常用于存量报送
...@@ -196,6 +201,11 @@ public class BaiHangFileReportService { ...@@ -196,6 +201,11 @@ public class BaiHangFileReportService {
* @param endTime 截至时间 * @param endTime 截至时间
*/ */
private void reportD2(String starTime, String endTime) { private void reportD2(String starTime, String endTime) {
if (!increment(Constant.QG_ZHU_DAI_REPORT_STOCK_D2_LOCK_KEY)) {
log.info("量化派助贷TO百行报送(D2)-放款信息已开始报送...请勿重复操作");
return;
}
redisTemplate.expire(Constant.QG_ZHU_DAI_REPORT_STOCK_D2_LOCK_KEY, 5, TimeUnit.MINUTES);
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());
...@@ -245,7 +255,7 @@ public class BaiHangFileReportService { ...@@ -245,7 +255,7 @@ public class BaiHangFileReportService {
log.error("量化派助贷TO百行报送-放款信息异常, recordId: {} , loanId: {} ", id, loanInfo.getLoanId(), e); log.error("量化派助贷TO百行报送-放款信息异常, recordId: {} , loanId: {} ", id, loanInfo.getLoanId(), e);
} }
} }
File file = new File( HOST_PATH+"量子数科科技有限公司_D2_"+endTime.split("T")[0].replaceAll("-","")+"_0002"+".txt"); File file = new File(HOST_PATH+"量子数科科技有限公司_D2_"+fileNameReplaceAll(starTime.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) {
log.info("量化派助贷TO百行报送-放款信息为空,加密文件不生成!starTime={},endTime={}",starTime,endTime); log.info("量化派助贷TO百行报送-放款信息为空,加密文件不生成!starTime={},endTime={}",starTime,endTime);
...@@ -377,6 +387,11 @@ public class BaiHangFileReportService { ...@@ -377,6 +387,11 @@ public class BaiHangFileReportService {
* @param endTime 截止时间 * @param endTime 截止时间
*/ */
private void reportD3O(String startTime, String endTime) { private void reportD3O(String startTime, String endTime) {
if (!increment(Constant.QG_ZHU_DAI_REPORT_STOCK_D3O_LOCK_KEY)) {
log.info("量化派助贷TO百行报送(D3)-逾期记录已开始报送...请勿重复操作");
return;
}
redisTemplate.expire(Constant.QG_ZHU_DAI_REPORT_STOCK_D3O_LOCK_KEY, 5, TimeUnit.MINUTES);
List<RepaymentInfoZhuDai> repaymentLoanInfos = null,recordList = new ArrayList<>(D3_INITIAL_CAPACITY); List<RepaymentInfoZhuDai> repaymentLoanInfos = null,recordList = new ArrayList<>(D3_INITIAL_CAPACITY);
List<String> reportList = new ArrayList<>(D3_INITIAL_CAPACITY); List<String> reportList = new ArrayList<>(D3_INITIAL_CAPACITY);
reportList.add("#singleLoanRepayInfo"); reportList.add("#singleLoanRepayInfo");
...@@ -425,6 +440,11 @@ public class BaiHangFileReportService { ...@@ -425,6 +440,11 @@ public class BaiHangFileReportService {
* 应还款日次日起,每30天的次日报送一次逾期记录,直至结清或转出 * 应还款日次日起,每30天的次日报送一次逾期记录,直至结清或转出
*/ */
private void reportD3OFor30Day(String startTime, String endTime) { private void reportD3OFor30Day(String startTime, String endTime) {
if (!increment(Constant.QG_ZHU_DAI_REPORT_STOCK_D3O30_LOCK_KEY)) {
log.info("量化派助贷TO百行报送(D3)-每30天逾期记录已开始报送...请勿重复操作");
return;
}
redisTemplate.expire(Constant.QG_ZHU_DAI_REPORT_STOCK_D3O30_LOCK_KEY, 5, TimeUnit.MINUTES);
List<LoanApplicationHistoryIdInfo> idInfos = null; List<LoanApplicationHistoryIdInfo> idInfos = null;
LoanApplicationHistoryIdInfo idInfo = null; LoanApplicationHistoryIdInfo idInfo = null;
List<RepaymentInfoZhuDai> repaymentLoanInfos = new ArrayList<>(D3_INITIAL_CAPACITY),tempRepaymentLoanInfos = null,recordList = new ArrayList<>(D3_INITIAL_CAPACITY); List<RepaymentInfoZhuDai> repaymentLoanInfos = new ArrayList<>(D3_INITIAL_CAPACITY),tempRepaymentLoanInfos = null,recordList = new ArrayList<>(D3_INITIAL_CAPACITY);
...@@ -495,6 +515,11 @@ public class BaiHangFileReportService { ...@@ -495,6 +515,11 @@ public class BaiHangFileReportService {
* @param endTime 截止时间 * @param endTime 截止时间
*/ */
private void reportD3R(String startTime, String endTime, String loanStartTime, String loanEndTime) { private void reportD3R(String startTime, String endTime, String loanStartTime, String loanEndTime) {
if (!increment(Constant.QG_ZHU_DAI_REPORT_STOCK_D3R_LOCK_KEY)) {
log.info("量化派助贷TO百行报送(D3)-还款记录已开始报送...请勿重复操作");
return;
}
redisTemplate.expire(Constant.QG_ZHU_DAI_REPORT_STOCK_D3R_LOCK_KEY, 5, TimeUnit.MINUTES);
List<RepaymentInfoZhuDai> repaymentLoanInfos = null,recordList = new ArrayList<>(D3_INITIAL_CAPACITY); List<RepaymentInfoZhuDai> repaymentLoanInfos = null,recordList = new ArrayList<>(D3_INITIAL_CAPACITY);
List<String> reportList = new ArrayList<>(D3_INITIAL_CAPACITY); List<String> reportList = new ArrayList<>(D3_INITIAL_CAPACITY);
reportList.add("#singleLoanRepayInfo"); reportList.add("#singleLoanRepayInfo");
...@@ -565,4 +590,9 @@ public class BaiHangFileReportService { ...@@ -565,4 +590,9 @@ public class BaiHangFileReportService {
} }
} }
private Boolean increment(String key){
Long increment = redisTemplate.opsForValue().increment(key, 1);
return increment <= 1;
}
} }
...@@ -8,4 +8,16 @@ public class Constant { ...@@ -8,4 +8,16 @@ public class Constant {
public static final String XYQB_HISTORY_DAI_REPORT_LOCK_KEY = "XYQB_HISTORY_DAI_REPORT_LOCK_KEY"; public static final String XYQB_HISTORY_DAI_REPORT_LOCK_KEY = "XYQB_HISTORY_DAI_REPORT_LOCK_KEY";
/** 存量D2 */
public static final String QG_ZHU_DAI_REPORT_STOCK_D2_LOCK_KEY = "QG_ZHU_DAI_REPORT_STOCK_D2_LOCK_KEY";
/** 存量D3 逾期记录 */
public static final String QG_ZHU_DAI_REPORT_STOCK_D3O_LOCK_KEY = "QG_ZHU_DAI_REPORT_STOCK_D3O_LOCK_KEY";
/** 存量D3 每30天报送 */
public static final String QG_ZHU_DAI_REPORT_STOCK_D3O30_LOCK_KEY = "QG_ZHU_DAI_REPORT_STOCK_D3O30_LOCK_KEY";
/** 存量D3 还款记录 */
public static final String QG_ZHU_DAI_REPORT_STOCK_D3R_LOCK_KEY = "QG_ZHU_DAI_REPORT_STOCK_D3R_LOCK_KEY";
} }
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