|
@ -1,5 +1,6 @@ |
|
|
package com.inscloudtech.bankStatementAnalysis.helper; |
|
|
package com.inscloudtech.bankStatementAnalysis.helper; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateTime; |
|
|
import cn.hutool.core.date.DateUtil; |
|
|
import cn.hutool.core.date.DateUtil; |
|
|
import cn.hutool.core.io.FileUtil; |
|
|
import cn.hutool.core.io.FileUtil; |
|
|
import cn.hutool.core.util.IdUtil; |
|
|
import cn.hutool.core.util.IdUtil; |
|
@ -247,25 +248,11 @@ public class CGSAnalysisHelper { |
|
|
@Override |
|
|
@Override |
|
|
public void invoke(CGSBankStatement data, AnalysisContext context) { |
|
|
public void invoke(CGSBankStatement data, AnalysisContext context) { |
|
|
if(StrUtil.isEmpty(data.getCardNumber())){ |
|
|
if(StrUtil.isEmpty(data.getCardNumber())){ |
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
String transTime = data.getTransTime(); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
if(StrUtil.isNotEmpty(transTime)){ |
|
|
|
|
|
if (transTime.length() > format.length()) { |
|
|
|
|
|
transTime = transTime.substring(0, format.length()); |
|
|
|
|
|
}else if (transTime.length() < format.length()){ |
|
|
|
|
|
transTime += "000000"; |
|
|
|
|
|
data.setTransTime(transTime); |
|
|
|
|
|
} |
|
|
|
|
|
DateUtil.parse(transTime, format); |
|
|
|
|
|
|
|
|
if(StrUtil.isNotEmpty(data.getAccountNumber())){ |
|
|
|
|
|
data.setCardNumber(data.getAccountNumber()); |
|
|
}else { |
|
|
}else { |
|
|
throw new AnalyzeDataFailedException( |
|
|
|
|
|
String.format("解析交易时间错误,无法将【%s】格式化为【%s】", transTime, format), new Exception()); |
|
|
|
|
|
|
|
|
return; |
|
|
} |
|
|
} |
|
|
}catch (Exception e){ |
|
|
|
|
|
importResultService.record(caseId,bankName,e,sourceFile); |
|
|
|
|
|
} |
|
|
} |
|
|
data.setSourceFile(sourceFile); |
|
|
data.setSourceFile(sourceFile); |
|
|
data.setBankName(bankName); |
|
|
data.setBankName(bankName); |
|
@ -384,8 +371,27 @@ public class CGSAnalysisHelper { |
|
|
// 4 交易时间 |
|
|
// 4 交易时间 |
|
|
String transTime = entity.getTransTime(); |
|
|
String transTime = entity.getTransTime(); |
|
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(transTime)) { |
|
|
|
|
|
bs.setTransactionTime(DateUtil.parse(transTime, format)); |
|
|
|
|
|
|
|
|
if(StrUtil.isNotEmpty(transTime)){ |
|
|
|
|
|
if (transTime.length() > format.length()) { |
|
|
|
|
|
transTime = transTime.substring(0, format.length()); |
|
|
|
|
|
}else if (transTime.length() < format.length()){ |
|
|
|
|
|
int sub = format.length() - transTime.length(); |
|
|
|
|
|
for (int i = 0;i < sub; i++){ |
|
|
|
|
|
transTime += "0"; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
String substring = transTime.substring(transTime.length() - 6); |
|
|
|
|
|
if(substring.equals("240000")){ |
|
|
|
|
|
String[] split = transTime.split("240000"); |
|
|
|
|
|
transTime = split[0] + "000000"; |
|
|
|
|
|
} |
|
|
|
|
|
try { |
|
|
|
|
|
bs.setTransactionTime( DateUtil.parse(transTime, format)); |
|
|
|
|
|
}catch (Exception e){ |
|
|
|
|
|
throw new AnalyzeDataFailedException( |
|
|
|
|
|
String.format("解析交易时间错误,无法将【%s】格式化为【%s】", transTime, format), new Exception()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 2交易金额 |
|
|
// 2交易金额 |
|
@ -408,7 +414,7 @@ public class CGSAnalysisHelper { |
|
|
|
|
|
|
|
|
//去重 |
|
|
//去重 |
|
|
String uniqueKey = bs.getCardHolderName()+bs.getIdCardNo()+bs.getCardNumber()+bs.getTransactionTime()+bs.getTransactionAmount()+ |
|
|
String uniqueKey = bs.getCardHolderName()+bs.getIdCardNo()+bs.getCardNumber()+bs.getTransactionTime()+bs.getTransactionAmount()+ |
|
|
bs.getBalance(); |
|
|
|
|
|
|
|
|
bs.getBalance()+entity.getTransNo(); |
|
|
if (uniqueKeySet.contains(uniqueKey)) { |
|
|
if (uniqueKeySet.contains(uniqueKey)) { |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
@ -467,5 +473,14 @@ public class CGSAnalysisHelper { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
|
|
|
String transTime = "20190801240000"; |
|
|
|
|
|
if(transTime.contains("240000")){ |
|
|
|
|
|
String[] split = transTime.split("240000"); |
|
|
|
|
|
transTime = split[0] + "000000"; |
|
|
|
|
|
} |
|
|
|
|
|
DateTime parse = DateUtil.parse(transTime, format); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |