Commit 7a822e5d authored by 郝彦辉's avatar 郝彦辉

将存量D3的json数据保存到repayment_loan_info_zhudai表

parent bc15550b
......@@ -142,4 +142,12 @@ public class ManualToolController {
return "d2_saveLog调用结束";
}
@RequestMapping("/d3_saveLog")
public String d3_saveLog(String d3FilePath, String d3JsonFileNames, String reqIdLogName, String no_reqId_start){
manualToolService.d3_saveLog(d3FilePath,d3JsonFileNames,reqIdLogName,no_reqId_start);
return "d3_saveLog调用结束";
}
}
......@@ -2016,6 +2016,101 @@ public class ManualToolService implements CommonSuperService {
}
}
@Async
public void d3_saveLog(String d3FilePath, String d3JsonFileNames, String reqIdLogName, String no_reqId_start) {
try{
boolean haveReqID = false;
List<String> reqID_Str_List = null;
HashMap<String,String> reqID_Map = null;
if(StringUtils.isNotEmpty(reqIdLogName)){
reqID_Str_List = ReadOrWriteTxt.readTxtList(reqIdLogName);
log.info("files reqID_Str_List size="+reqID_Str_List.size());
reqID_Map = new HashMap<>(reqID_Str_List.size());
String[] arry = null;
//oldReqID=30067778,newReqID=199bbec95c0b41178055f1c5164bd7fb
for(String str : reqID_Str_List){
if(str.length()<2){
continue;
}
arry = str.split("=");
reqID_Map.put(arry[2],arry[1].split(",")[0]);
}
haveReqID = true;
}
log.info("param haveReqID: {} , reqID_Str_List: {} , reqID_Map: {} ", haveReqID, (reqID_Str_List!=null ? reqID_Str_List.size() : "null"), (reqID_Map!=null ? reqID_Map.size() : "null"));
reqID_Str_List = null;
int no_reqId = 0;
if(StringUtils.isNotEmpty(no_reqId_start)){
no_reqId = Integer.parseInt(no_reqId_start);
}
List<String> d3lineList = null;
String[] all_id3_fileNames = d3JsonFileNames.trim().split(",");
for(String fileName : all_id3_fileNames){
log.info(">>>>>>>>THE FILENAME START:"+fileName);
if(!d3FilePath.endsWith("/") && !d3FilePath.endsWith("\\")){
d3FilePath = d3FilePath + "/";
}
d3lineList = ReadOrWriteTxt.readTxtList(d3FilePath + fileName);
int saveCount = 0, tmp_not_recordId=0, listSize=d3lineList.size();
log.info(fileName+" lineList size:"+d3lineList.size());
RepaymentInfoZhuDai repaymentLoanInfo = null;
for(int i=0;i<d3lineList.size();i++){
try {
String d3JsonStr = d3lineList.get(i);
if(d3JsonStr.length()<30){//#singleLoanRepayInfo
continue;
}
repaymentLoanInfo = new Gson().fromJson(d3JsonStr, new TypeToken<RepaymentInfoZhuDai>(){}.getType());
repaymentLoanInfo.setRecordId(repaymentLoanInfo.getReqID());
repaymentLoanInfo.setReqID(null);
if(haveReqID && reqID_Map.containsKey(repaymentLoanInfo.getRecordId())){
repaymentLoanInfo.setReqID(reqID_Map.get(repaymentLoanInfo.getRecordId()));
reqID_Map.remove(repaymentLoanInfo.getRecordId());
}
if(StringUtils.isEmpty(repaymentLoanInfo.getReqID())){
no_reqId++;
tmp_not_recordId++;
repaymentLoanInfo.setReqID("no_"+no_reqId);
}
try{
repaymentLoanInfoDbMapper.saveRepaymentLoanInfoLog(repaymentLoanInfo);
saveCount++;
}catch(Exception e){
log.error("保存还款数据记录失败, fileName: {} , DATA: {} ", fileName, d3JsonStr, e);
}
log.info("Build Save D3 End:"+i);
} catch (Exception e) {
log.error("保存还款数据处理异常, fileName: {} , DATA: {} ", fileName, d3lineList.get(i), e);
}
}
log.info(fileName+"<<<<<<保存还款数据记录结束, listSize: {} , saveCount: {} , tmp_not_recordId: {} ", listSize, saveCount);
d3lineList = null;
repaymentLoanInfo = null;
saveCount=0;tmp_not_recordId=0;listSize=0;
Thread.sleep(1500);
}
}catch (Exception e){
log.error("newD3ReplaceReqId 异常",e);
}
log.info("-----All 保存还款数据记录结束-----.");
}
public static void main(String[] args) {
// List<String> lineList = ReadOrWriteTxt.readTxtList("D:\\用户目录\\Downloads\\D2_M_01.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