Commit 9e1191c0 authored by 郝彦辉's avatar 郝彦辉

非联合贷-实时数据报送sql修改

parent 6d7d2f7a
......@@ -129,4 +129,9 @@ public class ManualToolController {
}
}
@RequestMapping("/dealWithExcelData")
public GlobalResponse dealWithExcelData(String filePath,String type){
return manualToolService.dealWithExcelData(filePath,type);
}
}
......@@ -40,6 +40,8 @@ import javax.annotation.PostConstruct;
import java.io.File;
import java.io.IOException;
import java.security.PublicKey;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
......@@ -103,7 +105,7 @@ public class BaiHangZhuDaiService {
@Value("${baihang.zhudai.password}")
public String password;
private DateFormat df_uploadTs = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
private static PublicKey baihang_zhudai_publickey = null;
@PostConstruct
public void init(){
......@@ -234,6 +236,18 @@ public class BaiHangZhuDaiService {
}
loanInfozd_tmp.setReqID(id);
String relationID = loanInfozd_tmp.getRelationID();
if(relationID!=null){
if(relationID.length()>36){//长度[1,26]
//lhp_1911049771615765816566b49a2db1c429
if(relationID.startsWith("lhp_")){
loanInfozd_tmp.setRelationID(relationID.replace("lhp_","L"));
}
}else{
log.error("量化派助贷TO百行报送-放款返回结果不正确, 发现其他类型的relationID并且长度大于36,relationID="+relationID+",loanId="+loanInfozd_tmp.getLoanId());
continue;
}
}
String jsonStr = JSONObject.toJSONString(loanInfozd_tmp);
......@@ -358,8 +372,8 @@ public class BaiHangZhuDaiService {
}
}
//--------------------------------------------------------------------------------------------------------------------
//--------------------------------------手动重新报送------------------------------------------------------------------------------
/**
* 描述: 手动重新报送-部分申请A1逻辑问题数据 (手动报送A1) <br/>
* 参数: [] <br/>
......@@ -375,6 +389,9 @@ public class BaiHangZhuDaiService {
ApplyLoanInfoZhuDai applyInfo = new Gson().fromJson(handApplys.get(i), new TypeToken<ApplyLoanInfoZhuDai>(){}.getType());
log.info("百行征信助贷模式报送贷款申请数据单个数据, {}", JSON.toJSONString(applyInfo));
/* String uploadTs = df_uploadTs.format(new Date());
applyInfo.setUploadTs(uploadTs.replace(" ","T"));*/
applyInfo.setName(interfaceUploadClient(applyInfo.getName()));
applyInfo.setMobile(interfaceUploadClient(applyInfo.getMobile()));
applyInfo.setPid(interfaceUploadClient(applyInfo.getPid()));
......@@ -401,31 +418,55 @@ public class BaiHangZhuDaiService {
log.info("百行征信助贷模式报送放款数据, {}", JSON.toJSONString(handLoanInfos));
for(int i=0;i<handLoanInfos.size();i++){
LoanInfoZhuDai loanInfo = new Gson().fromJson(handLoanInfos.get(i), new TypeToken<LoanInfoZhuDai>(){}.getType());
log.info("百行征信助贷模式报送放款数据单个数据, {}", JSON.toJSONString(loanInfo));
String loanInfoReqId = loanInfo.getReqID();
LoanInfoZhuDai loanInfozd_tmp = new Gson().fromJson(handLoanInfos.get(i), new TypeToken<LoanInfoZhuDai>(){}.getType());
log.info("百行征信助贷模式报送放款数据单个数据, {}", JSON.toJSONString(loanInfozd_tmp));
String loanInfoReqId = loanInfozd_tmp.getReqID();
if(loanInfo.getTotalTerm() > 1){
if(loanInfozd_tmp.getTotalTerm() > 1){
List<String> targetRepaymentDayList = loanInfoMapper.findTargetRepaymentDayList(loanInfoReqId);
loanInfo.setTargetRepayDateList(String.join(",", targetRepaymentDayList));
loanInfozd_tmp.setTargetRepayDateList(String.join(",", targetRepaymentDayList));
}
/*String uploadTs = df_uploadTs.format(new Date());
loanInfozd_tmp.setUploadTs(uploadTs.replace(" ","T"));
loanInfozd_tmp.setLoanId(loanInfozd_tmp.getOrderID());*/
/*try{
loanInfoDbMapper.saveLoanInfoRecordLog(loanInfo);
}catch(Exception e){}*/
try{
LoanInfo record = new LoanInfo();
BeanUtils.copyProperties(loanInfo, record);
record.setRecordId(loanInfo.getReqID());
BeanUtils.copyProperties(loanInfozd_tmp, record);
record.setRecordId(loanInfozd_tmp.getReqID());
loanInfoDbMapper.saveLoanInfoRecordLog(record);
}catch(Exception e){
log.error("量化派助贷TO百行报送-放款申请保存记录失败" , e);
}
String relationID = loanInfozd_tmp.getRelationID();
if(relationID!=null){
if(relationID.length()>36){//长度[1,26]
//lhp_1911049771615765816566b49a2db1c429
if(relationID.startsWith("lhp_")){
loanInfozd_tmp.setRelationID(relationID.replace("lhp_","L"));
}
}else{
log.error("量化派助贷TO百行报送-放款返回结果不正确, 发现其他类型的relationID并且长度大于36,relationID="+relationID+",loanId="+loanInfozd_tmp.getLoanId());
continue;
}
}
String jsonStr = JSONObject.toJSONString(loanInfozd_tmp);
LoanInfoZhuDaiVo loanInfo = JSONObject.parseObject(jsonStr, LoanInfoZhuDaiVo.class);
FinTechAgencyBusinessZhuDai finTechAgencyBusiness = JSONObject.parseObject(jsonStr, FinTechAgencyBusinessZhuDai.class);
loanInfo.setFinTechAgencyBusiness(finTechAgencyBusiness);
loanInfo.setMobile(interfaceUploadClient(loanInfo.getMobile()));
loanInfo.setName(interfaceUploadClient(loanInfo.getName()));
loanInfo.setPid(interfaceUploadClient(loanInfo.getPid()));
String resultStr = iHttpService.postBaiHang(baiHangLoanInfoUrl, getHeader(), JSON.toJSONString(loanInfo));
log.info("北京众信利民助贷模式TO百行征信报送放款记录(手动) loanId: {} , bean: {} , result: {} ", loanInfo.getLoanId(), JSON.toJSONString(loanInfo), resultStr);
}
......@@ -454,6 +495,9 @@ public class BaiHangZhuDaiService {
repaymentLoanInfo.setReqID(repaymentLoanInfo.getRecordId());
repaymentLoanInfo.setRecordId(null);*/
/* String uploadTs = df_uploadTs.format(new Date());
repaymentLoanInfo.setUploadTs(uploadTs.replace(" ","T"));*/
try {
RepaymentLoanInfo record = new RepaymentLoanInfo();
BeanUtils.copyProperties(repaymentLoanInfo, record);
......@@ -476,7 +520,7 @@ public class BaiHangZhuDaiService {
}
//--------------------------------------------------------------------------------------------------------------------
//-----------------------------------------------工具---------------------------------------------------------------------
/**
* 描述: http 百行-助贷申请存量数据 整理 <br/>
* 参数: [strStartDate, noEndDate] <br/>
......@@ -562,6 +606,19 @@ public class BaiHangZhuDaiService {
if(listSize>0){
for (int i = 0; i < listSize; i++) {
LoanInfoZhuDai loanInfozd_tmp = loanInfozdList.get(i);
String relationID = loanInfozd_tmp.getRelationID();
if(relationID!=null){
if(relationID.length()>36){//长度[1,26]
//lhp_1911049771615765816566b49a2db1c429
if(relationID.startsWith("lhp_")){
loanInfozd_tmp.setRelationID(relationID.replace("lhp_","L"));
}
}else{
log.error("量化派助贷TO百行报送-放款返回结果不正确, 发现其他类型的relationID并且长度大于36,relationID="+relationID+",loanId="+loanInfozd_tmp.getLoanId());
continue;
}
}
String jsonStr = JSONObject.toJSONString(loanInfozd_tmp);
LoanInfoZhuDaiVo loanInfoZhuDaiVo = JSONObject.parseObject(jsonStr, LoanInfoZhuDaiVo.class);
......
......@@ -4,14 +4,13 @@ package cn.quantgroup.report.service.manualTool;
import cn.quantgroup.report.ApplicationContextHolder;
import cn.quantgroup.report.config.aop.DistributedLock;
import cn.quantgroup.report.config.aop.MonitorType;
import cn.quantgroup.report.domain.baihang.RepaymentLoanInfoVo;
import cn.quantgroup.report.domain.baihang.*;
import cn.quantgroup.report.mapper.baihang.LoanInfoMapper;
import cn.quantgroup.report.response.GlobalResponse;
import cn.quantgroup.report.service.CommonSuperService;
import cn.quantgroup.report.utils.*;
import cn.quantgroup.report.utils.commonutil.MD5Util;
import cn.quantgroup.report.config.aop.Monitor;
import cn.quantgroup.report.domain.baihang.LoanInfoVo;
import cn.quantgroup.report.mapper.master.RepaymentLoanInfoDbMapper;
import cn.quantgroup.report.utils.commonutil.AesCrypto;
import cn.quantgroup.report.utils.commonutil.Base64;
......@@ -20,6 +19,8 @@ import cn.quantgroup.report.utils.http.HttpRequestUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -29,11 +30,9 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* -----------------------------------------------------------------------------<br>
......@@ -562,4 +561,96 @@ public class ManualToolService implements CommonSuperService {
}
public GlobalResponse dealWithExcelData(String filePath,String type) {
if(StringUtils.isAnyBlank(filePath,type)){
return new GlobalResponse("1000", "百行征信手动报送失败");
}
List<Object> jsonArray = new ArrayList<Object>();
List<String> lineList = ReadOrWriteTxt.readTxtList(filePath);
String[] titleKeys = lineList.get(0).split("\t");
StringBuffer jsonStr = new StringBuffer();
DateFormat df_uploadTs = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
for (int i = 1; i < lineList.size() ; i++) {
String[] datas = lineList.get(i).split("\t");
JSONObject json = new JSONObject();
for (int k=0; k<titleKeys.length; k++){
json.put(titleKeys[k].trim(), (datas[k]!=null ? datas[k].toString().trim() :null));
}
if("A1".equals(type)){
//ApplyLoanInfoZhuDai bean = new Gson().fromJson(json.toJSONString(), new TypeToken<ApplyLoanInfoZhuDai>(){}.getType());
ApplyLoanInfoZhuDai bean = JSONObject.toJavaObject(json, ApplyLoanInfoZhuDai.class);
String uploadTs = df_uploadTs.format(new Date());
bean.setUploadTs(uploadTs.replace(" ","T"));
jsonArray.add(bean);
jsonStr.append(JSON.toJSONString(bean));
jsonStr.append("\n");
}else if("D2".equals(type)){
//LoanInfoZhuDaiVo bean = new Gson().fromJson(json.toJSONString(), new TypeToken<LoanInfoZhuDaiVo>(){}.getType());
//FinTechAgencyBusinessZhuDai finTechAgencyBusiness = new Gson().fromJson(json.toJSONString(), new TypeToken<FinTechAgencyBusinessZhuDai>(){}.getType());
//bean.setFinTechAgencyBusiness(finTechAgencyBusiness);
LoanInfoZhuDai bean = JSONObject.toJavaObject(json, LoanInfoZhuDai.class);
String uploadTs = df_uploadTs.format(new Date());
bean.setUploadTs(uploadTs.replace(" ","T"));
jsonArray.add(bean);
jsonStr.append(JSON.toJSONString(bean));
jsonStr.append("\n");
}else if("D3".equals(type)){
//RepaymentInfoZhuDai bean = new Gson().fromJson(json.toJSONString(), new TypeToken<RepaymentInfoZhuDai>(){}.getType());
RepaymentInfoZhuDai bean = JSONObject.toJavaObject(json, RepaymentInfoZhuDai.class);
String uploadTs = df_uploadTs.format(new Date());
bean.setUploadTs(uploadTs.replace(" ","T"));
jsonArray.add(bean);
jsonStr.append(JSON.toJSONString(bean));
jsonStr.append("\n");
}else{
log.error("其他类型type:"+type);
jsonArray.add(json);
jsonStr.append(JSON.toJSONString(json));
jsonStr.append("\n");
}
}
//String jsonStr = JSONArray.toJSONString(jsonArray);
String writeName = filePath.substring(0,filePath.lastIndexOf("\\"));
writeName = writeName + "\\build\\";
writeName = writeName + filePath.substring(filePath.lastIndexOf("\\")+1, filePath.length());
ReadOrWriteTxt.writeTxt(writeName,jsonStr.toString());
log.info("处理后数据入文件OK:"+writeName);
return new GlobalResponse("0", "处理后数据入文件OK:"+writeName);
}
public static void main(String[] args) {
/* for (int i=0; i<12; i++){
String id = UUID.randomUUID().toString().replaceAll("-", "");
System.out.println(id);
}*/
List<String> lineList = ReadOrWriteTxt.readTxtList("C:\\Users\\Administrator\\Desktop\\测试\\文件测试\\baihang\\d3d3.txt");
for(int i=0;i<lineList.size();i++){
RepaymentInfoZhuDai repaymentLoanInfo = new Gson().fromJson(lineList.get(i), new TypeToken<RepaymentInfoZhuDai>(){}.getType());
String id = UUID.randomUUID().toString().replaceAll("-", "");
repaymentLoanInfo.setReqID(id);
System.out.println(JSON.toJSONString(repaymentLoanInfo));
}
}
}
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