Commit 4ef9e937 authored by 郝彦辉's avatar 郝彦辉

工具提交1

parent b213d7e7
...@@ -315,4 +315,28 @@ public class ExZhuDaiBaiHangReSendController { ...@@ -315,4 +315,28 @@ public class ExZhuDaiBaiHangReSendController {
return "d3CheckToJson任务调度失败,参数错误"; return "d3CheckToJson任务调度失败,参数错误";
} }
} }
@RequestMapping("/manual/d3IsHaveD2")
public String d3IsHaveD2(String p3,String secretKey, String filePath){
if(manualToolService.checkSecretKey(p3,secretKey)){
baiHangZhuDaiService.d3IsHaveD2(filePath);
return "d3IsHaveD2任务调度完成";
}else{
return "d3IsHaveD2任务调度失败,参数错误";
}
}
@RequestMapping("/manual/d3_saveDbLog")
public String d3_saveDbLog(String p3,String secretKey, String filePath, String writeFilePath){
if(StringUtils.isEmpty(writeFilePath)){
return "d3_saveDbLog任务调度失败,参数为空";
}
if(manualToolService.checkSecretKey(p3,secretKey)){
baiHangZhuDaiService.d3_saveDbLog(filePath, writeFilePath);
return "d3_saveDbLog任务调度完成";
}else{
return "d3_saveDbLog任务调度失败,参数错误";
}
}
} }
...@@ -41,4 +41,5 @@ public class RepaymentInfoZhuDai implements Serializable { ...@@ -41,4 +41,5 @@ public class RepaymentInfoZhuDai implements Serializable {
private String recordId; private String recordId;
public boolean getRecordId;
} }
...@@ -2168,73 +2168,112 @@ public class BaiHangZhuDaiService { ...@@ -2168,73 +2168,112 @@ public class BaiHangZhuDaiService {
return "处理D3数据结束 "; return "处理D3数据结束 ";
} }
@Async
public String d3IsHaveD2(String filePath) {
//写入文件的路径和前缀
String writeFilePath = "/home/quant_group/baihang-report/data/tmp";
String file_= "result";
if(filePath.lastIndexOf("/")!=-1){//linux
writeFilePath = filePath.substring(0,filePath.lastIndexOf("/")) + "/ishave";
file_ = filePath.substring(filePath.lastIndexOf("/"), filePath.lastIndexOf("."));
}else{//windows
writeFilePath = filePath.substring(0,filePath.lastIndexOf("\\")) + "\\ishave";
file_ = filePath.substring(filePath.lastIndexOf("\\"), filePath.lastIndexOf("."));
}
public static void main(String[] args) { long starUtc = System.currentTimeMillis();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"); List<String> d2InfosList = null;
/*Timestamp timestamp = new Timestamp((new Date()).getTime()); try {
LocalDateTime nowTime = LocalDateTime.now(); d2InfosList = FileUtils.readLines(new File(filePath), "utf-8");
String format = nowTime.format(DateTimeFormatter.ISO_DATE_TIME); } catch (IOException e) {
format = nowTime.format(DateTimeFormatter.ISO_LOCAL_DATE); e.printStackTrace();
format = nowTime.format(formatter); }
format = nowTime.toString(); log.info("d2InfosList读取文件: {} , 大小: {} , 耗时: {} ", filePath, d2InfosList.size(), (System.currentTimeMillis()-starUtc));
System.out.println(format);*/
int fsize = d2InfosList.size();
LocalDateTime loca_log_uploadTs = LocalDateTime.parse("2016-08-23T00:00:00").plusDays(1); // String SQL_QUERY_D2 = " select d2.req_id, d2.record_id, d2.op_code from loan_info_zhudai d2 where d2.loan_id=? ;";
String uploadTs_2 = loca_log_uploadTs.format(formatter); for(int i=0; i< fsize; i++){
String strJson = d2InfosList.get(i);
String run_lastTime = "2016-08-24T00:00:01"; try{
if(StringUtils.isNotEmpty(run_lastTime)){ if(strJson.length() < 30 ){//#singleLoanRepayInfo
LocalDateTime loca_run_lastTime = LocalDateTime.parse(run_lastTime); log.warn("d2InfosList筛选文件内容时发现数据错误, 文件: {} , 内容: {} ", filePath, strJson);
if (loca_run_lastTime.compareTo(loca_log_uploadTs) > 0) { continue;
uploadTs_2 = loca_run_lastTime.format(formatter); }
RepaymentInfoZhuDai repaymentLoanInfo = new Gson().fromJson(strJson, new TypeToken<RepaymentInfoZhuDai>(){}.getType());
try{
List<LoanInfoZhuDai> logBeanList = riskDatasourceJdbcTemplate.query(SQL_QUERY_D2, new Object[]{repaymentLoanInfo.getLoanId()}, new RowMapper<LoanInfoZhuDai>() {
@Override
public LoanInfoZhuDai mapRow(ResultSet rs, int rowNum) throws SQLException {
LoanInfoZhuDai bean = new LoanInfoZhuDai();
bean.setRecordId(rs.getString("record_id"));
bean.setReqID(rs.getString("req_id"));
bean.setOpCode(rs.getString("op_code"));
return bean;
}
});
if(logBeanList!=null && logBeanList.size()>0){
if(StringUtils.isEmpty(repaymentLoanInfo.getRecordId())){
repaymentLoanInfo.setRecordId(UUID.randomUUID().toString().replaceAll("-", ""));
}
this.wirteFile(writeFilePath + file_+ "_ok.txt", JSON.toJSONString(repaymentLoanInfo)+"\r\n");
}else{
this.wirteFile(writeFilePath + file_+ "_isEmpty.txt", JSON.toJSONString(repaymentLoanInfo)+"\r\n");
}
}catch (Exception e){
log.error("在到d2中查询d3数据异常, loanId: {} ", repaymentLoanInfo.getLoanId(), e);
}
}catch (Exception e){
log.error("在到d2中查询d3数据未知异常, 文件: {} , 内容: {} , 第i: {} ", filePath, strJson, i, e);
} }
log.info("在到d2中查询d3数据结束, filePath: {} , 第i: {} <<<", filePath, i);
} }
System.out.println(uploadTs_2);
return "在到d2中查询d3数据结束";
}
List<RepaymentLoanInfoLog> logBeanList = new ArrayList();
RepaymentLoanInfoLog bean1 = new RepaymentLoanInfoLog();
bean1.setUpdatedAt(Timestamp.valueOf("2011-05-09 11:49:00"));
logBeanList.add(bean1);
RepaymentLoanInfoLog bean2 = new RepaymentLoanInfoLog(); @Async
bean2.setUpdatedAt(Timestamp.valueOf("2011-05-09 11:50:00")); public void d3_saveDbLog(String filePath, String writeFilePath) {
logBeanList.add(bean2); long starUtc = System.currentTimeMillis();
List<String> d3InfosList = null;
try {
d3InfosList = FileUtils.readLines(new File(filePath), "utf-8");
} catch (IOException e) {
e.printStackTrace();
}
int fsize = d3InfosList.size();
log.info("d3InfosList读取文件: {} , 大小: {} , 耗时: {} ", filePath, fsize, (System.currentTimeMillis()-starUtc));
RepaymentLoanInfoLog bean3 = new RepaymentLoanInfoLog();
bean3.setUpdatedAt(Timestamp.valueOf("2011-05-09 11:48:00"));
logBeanList.add(bean3);
Collections.sort(logBeanList, new Comparator<RepaymentLoanInfoLog>() { int saveCount=0;
public int compare(RepaymentLoanInfoLog o1, RepaymentLoanInfoLog o2) { for(int i=0; i< fsize; i++){
// 按照学生的年龄进行降序排列 String strJson = d3InfosList.get(i);
if (o1.getUpdatedAt().getTime() > o2.getUpdatedAt().getTime()) { try{
return -1; if(strJson.length() < 30 ){//#singleLoanRepayInfo
} log.warn("d3InfosList筛选文件内容时发现数据错误, 文件: {} , 内容: {} ", filePath, strJson);
if (o1.getUpdatedAt().getTime() == o2.getUpdatedAt().getTime()) { continue;
return 0;
} }
return 1; RepaymentInfoZhuDai repaymentLoanInfo = new Gson().fromJson(strJson, new TypeToken<RepaymentInfoZhuDai>(){}.getType());
} repaymentLoanInfoDbMapper.saveRepaymentLoanInfoLog(repaymentLoanInfo);
});
System.out.println(JSON.toJSONString(logBeanList)); repaymentLoanInfo.setReqID(repaymentLoanInfo.getRecordId());
repaymentLoanInfo.setRecordId(null);
this.wirteFile(writeFilePath, JSON.toJSONString(repaymentLoanInfo)+"\r\n");
saveCount++;
}catch (Exception e){
log.error("保存还款数据记录失败, fileName: {} , DATA: {} , 第i: {} ", filePath, strJson, i, e);
}
//“本笔贷款状态”报送“3-结清”后,继续报送的还款记录中还款状态确认时间statusConfirmAt应早于等于结清时的还款状态确认时间。2017-03-10T00:00:00 log.info("保存还款数据记录结束, 第i: {} <<<", i);
/* if(logBean_jq!=null){ }
if(repaymentLoanInfo.getTermNo() < logBean_jq.getTermNo()){*/
LocalDateTime loca_new = LocalDateTime.parse("2017-03-10T00:00:00"); //repaymentLoanInfo.getStatusConfirmAt()
LocalDateTime loca_jq = LocalDateTime.parse("2017-03-10T00:00:00"); //logBean_jq.getStatusConfirmAt()
if (loca_new.compareTo(loca_jq) > 0) {
String statusConfirmAt_jq = loca_jq.format(formatter);
System.out.println(statusConfirmAt_jq);
//repaymentLoanInfo.setStatusConfirmAt(statusConfirmAt_jq);
//log.warn("查询比较两次报送数据不相同, 修改以M报送_且已经有结清的, filePath: {} , loanId: {} , termNo: {} , logBean: {} ", file_, loanId, termNo, JSON.toJSONString(logBean));
}
/* }
}*/
log.info("All保存还款数据记录结束, 文件:{} ,list大小:{} , 保存成功:{} ", filePath, fsize, saveCount);
} }
} }
...@@ -3619,9 +3619,32 @@ public class ManualToolService implements CommonSuperService { ...@@ -3619,9 +3619,32 @@ public class ManualToolService implements CommonSuperService {
} }
public static void main(String[] args) { private static void build_d3_reqId_20200604(String filepath, String readName, String okName) {
try{
List<String> d3JsonList_hk = FileUtils.readLines(new File(filepath+readName), "utf-8");
log.info("build_d3_reqId_20200604() read files jsonList_1 size:{} ", d3JsonList_hk.size());
for(int i=0; i<d3JsonList_hk.size(); i++){
String jsonStr = d3JsonList_hk.get(i).trim();
if(jsonStr.length()<30){
continue;
}
RepaymentInfoZhuDai repaymentLoanInfo = new Gson().fromJson(jsonStr, new TypeToken<RepaymentInfoZhuDai>(){}.getType());
repaymentLoanInfo.setReqID(repaymentLoanInfo.getRecordId());
repaymentLoanInfo.setRecordId(null);
FileUtils.write(new File(filepath+readName), JSON.toJSONString(repaymentLoanInfo)+"\r\n", "UTF-8", true);
}
log.info("build_d3_reqId_20200604() All D3还款 LOG:保存记录结束");
}catch (Exception e){
log.error("build_d3_reqId_20200604()处理还款记录异常!", e);
}
}
public static void main(String[] args) {
//d3_build_20200309(); //d3_build_20200309();
//d3_build_20200309_ok(); //d3_build_20200309_ok();
...@@ -3637,6 +3660,7 @@ public class ManualToolService implements CommonSuperService { ...@@ -3637,6 +3660,7 @@ public class ManualToolService implements CommonSuperService {
// bairong_ziduab_build(); // bairong_ziduab_build();
build_d3_reqId_20200604("D:\\用户目录\\Downloads\\tmp_ok\\", "all_D3_20191225_20200601_06_M.txt", "all_D3_20191225_20200601_06_M_ok.txt");
} }
......
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