Commit d753fa55 authored by 郑建's avatar 郑建

测试补报

parent dcf35437
package cn.quantgroup.report.controller.external;
import cn.quantgroup.report.service.repair.RepairService;
import com.google.common.base.Stopwatch;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.concurrent.TimeUnit;
/**
* @author jian.zheng
* @date 2021/3/2 - 18:43
......@@ -24,7 +27,12 @@ public class RepairController {
@RequestMapping("/repair")
public String mainLoanInfoSend(int pageNo,String type){
try{
repairService.doRepair(pageNo,type);
Stopwatch stopwatch = Stopwatch.createStarted();
repairService.doRepair("normal_lh");
repairService.doRepair("overdue_lh");
repairService.doRepair("normal");
repairService.doRepair("overdue");
log.info("本次测试总耗时 {}",stopwatch.elapsed(TimeUnit.MILLISECONDS));
log.info("数据补报成功");
return "数据补报成功";
}catch(Exception e){
......
......@@ -57,14 +57,32 @@ public class RepairService implements CommonSuperService {
RepaymentLoanInfoSycMapper findMapper;
private static Integer[] fundingIds = {420, 520, 580, 650, 670, 810, 240, 640, 700};
// private static Integer[] fundingIds = {580};
private static Integer[] fundingIdsLh = {880, 890};
private static final String logFilePath = "C:\\Users\\Administrator\\Desktop\\data\\";
public static final String errorLog = "C:\\Users\\Administrator\\Desktop\\data\\error.txt";
public boolean doRepair(int pageNo,String type) throws Exception{
final int size = 2000;
public void doRepair(String type) {
Stopwatch stopwatch = Stopwatch.createStarted();
log.info("开始报送 {}",type);
boolean flag = true;
int i=0;
while (flag){
try {
flag = doRepair(i,type);
} catch (Exception e) {
log.info("overdue_lh 第 {} 页 异常",i,e);
continue;
}
i++;
}
log.info("本次测试 {} 总耗时 {}",type,stopwatch.elapsed(TimeUnit.MILLISECONDS));
}
private boolean doRepair(int pageNo,String type) throws Exception{
final int size = 5000;
Stopwatch stopwatch = Stopwatch.createStarted();
Integer[] currentFundingIds;
if ("normal".equals(type) || "overdue".equals(type)){
......@@ -127,7 +145,7 @@ public class RepairService implements CommonSuperService {
stopwatch.reset();
stopwatch.start();
try {
log.info("开始报送 新增 {} 条,修复 {} 条",addList.size(),modifyList.size());
log.info("开始报送 新增 {} 条,修复 {} 条 总计 {} 条",addList.size(),modifyList.size(),modifyList.size() + addList.size());
report(addList);
report(modifyList);
File newEmpty = new File(logFilePath+"newEmpty-"+fundId+"-"+pageNo+type+".txt");
......@@ -158,22 +176,22 @@ public class RepairService implements CommonSuperService {
continue;
}
}
// info.setReqID(info.getRecordId());
// info.setRecordId(null);
// info.setPid(BaiHangZhuDaiService.interfaceUploadClient(info.getPid()));
// info.setName(BaiHangZhuDaiService.interfaceUploadClient(info.getName()));
// info.setMobile(BaiHangZhuDaiService.interfaceUploadClient(info.getMobile()));
// String resultStr = iHttpService.postBaiHang(baiHangRepayMentLoanInfoUrl, getHeader(), JSON.toJSONString(info));
info.setReqID(info.getRecordId());
info.setRecordId(null);
info.setPid(BaiHangZhuDaiService.interfaceUploadClient(info.getPid()));
info.setName(BaiHangZhuDaiService.interfaceUploadClient(info.getName()));
info.setMobile(BaiHangZhuDaiService.interfaceUploadClient(info.getMobile()));
String resultStr = iHttpService.postBaiHang(baiHangRepayMentLoanInfoUrl, getHeader(), JSON.toJSONString(info));
Thread.sleep(120L);
// log.info("众信利民助贷模式TO百行手动报送还款记录 reqID: {} , bean: {} , result: {} ", info.getReqID(), JSON.toJSONString(info), resultStr);
// if (Objects.isNull(resultStr) || "success".equalsIgnoreCase(JSON.parseObject(resultStr).getString("status"))) {
log.info("众信利民助贷模式TO百行手动报送还款记录 reqID: {} , bean: {} , result: {} ", info.getReqID(), JSON.toJSONString(info), resultStr);
if (Objects.isNull(resultStr) || "success".equalsIgnoreCase(JSON.parseObject(resultStr).getString("status"))) {
successCount++;
// }else {
// File file = new File(errorLog);
// List<String> logs = FileUtils.readLines(file,"utf-8");
// logs.add(JSON.toJSONString(resultStr));
// FileUtils.writeLines(file,logs);
// }
}else {
File file = new File(errorLog);
List<String> logs = FileUtils.readLines(file,"utf-8");
logs.add(JSON.toJSONString(resultStr));
FileUtils.writeLines(file,logs);
}
}
log.info("报送成功 {} 条, 失败 {} 条 , 跳过 {} 条",successCount,addList.size() - successCount,jumpCount);
}
......
......@@ -30,28 +30,12 @@ public class BaihangReportApplicationTests {
@Test
public void testRepair(){
Stopwatch stopwatch = Stopwatch.createStarted();
doRepair("normal_lh");
doRepair("overdue_lh");
doRepair("normal");
doRepair("overdue");
// service.doRepair("normal_lh");
// service.doRepair("overdue_lh");
service.doRepair("normal");
service.doRepair("overdue");
log.info("本次测试总耗时 {}",stopwatch.elapsed(TimeUnit.MILLISECONDS));
}
private void doRepair(String type) {
Stopwatch stopwatch = Stopwatch.createStarted();
log.info("开始报送 {}",type);
boolean flag = true;
int i=0;
while (flag){
try {
flag = service.doRepair(i,type);
} catch (Exception e) {
log.info("overdue_lh 第 {} 页 异常",i,e);
continue;
}
i++;
}
log.info("本次测试 {} 总耗时 {}",type,stopwatch.elapsed(TimeUnit.MILLISECONDS));
}
}
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