Browse Source

config

master
583641232@qq.com 1 year ago
parent
commit
a14f679c04
  1. 77
      cas-system/src/main/java/com/inscloudtech/bankStatementAnalysis/helper/CCBDataAnalysisHelper.java
  2. 5
      cas-system/src/main/java/com/inscloudtech/bankStatementAnalysis/listener/ReadCCBCurrentAccountInfoListener.java

77
cas-system/src/main/java/com/inscloudtech/bankStatementAnalysis/helper/CCBDataAnalysisHelper.java

@ -447,6 +447,9 @@ public class CCBDataAnalysisHelper {
List<PlateNumberInfo> plateNumberInfoList = new ArrayList<>();
for (CCBCurrentBankStatementEntity entity : entityList) {
String sourceFile = entity.getSourceFile();
if(StrUtil.isEmpty(sourceFile)){
continue;
}
try {
boolean isSame = false;
@ -519,7 +522,7 @@ public class CCBDataAnalysisHelper {
// 2 交易金额 可能是double或者int类型
if(StrUtil.isEmpty(entity.getLoanFlag())){
if(StrUtil.isEmpty(entity.getLoanFlag()) && entity.getExpenditureAmount() != null && entity.getIncomeAmount() != null){
BigDecimal expenditureAmount = BigDecimal.valueOf(Double.parseDouble(entity.getExpenditureAmount()));
BigDecimal incomeAmount = BigDecimal.valueOf(Double.parseDouble(entity.getIncomeAmount()));
bs.setTransactionAmount(incomeAmount.subtract(expenditureAmount));
@ -586,6 +589,7 @@ public class CCBDataAnalysisHelper {
bsList = ListUtils.newArrayListWithExpectedSize(Constants.BATCH_SIZE);
}
} catch (Exception e) {
e.printStackTrace();
importResultService.record(caseId, BANK_NAME, e,sourceFile);
}
}
@ -644,24 +648,23 @@ public class CCBDataAnalysisHelper {
if (AsposeUtil.getCell(cells, "个人账户信息") != null) {
// 读取账户信息
readAccountInfo(excelFile, cells, sheetNo);
readAccountInfo(excelFile, cells, sheetNo, ssss);
} else if (AsposeUtil.getCell(cells, "个人活期明细信息") != null) {
// 读取活期信息
readCurrentDetailsV2(excelFile, cells, sheetNo);
readCurrentDetailsV2(excelFile, cells, sheetNo, ssss);
} else if (AsposeUtil.getCell(cells, "个人定期明细信息") != null) {
// 读取定期明细
readRegularDetailsV2(excelFile, cells, sheetNo);
readRegularDetailsV2(excelFile, cells, sheetNo, ssss);
} else if (AsposeUtil.getCell(cells, "新一代电子现金") != null || AsposeUtil.getCell(cells, "电子现金-新一代") != null) {
// 读取电子现金明细
readElectronicCashDetails(excelFile, cells, sheetNo);
readElectronicCashDetails(excelFile, cells, sheetNo, ssss);
} else if (AsposeUtil.getCell(cells, "企业账户信息") != null) {
// 读取企业账户信息
readCompanyAccountInfo(excelFile, cells, sheetNo);
readCompanyAccountInfo(excelFile, cells, sheetNo, ssss);
} else if (AsposeUtil.getCell(cells, "企业活期明细信息") != null) {
// 读取活期明细
// readCompanyCurrentDetails(excelFile, cells, sheetNo);
xiangjiaoTemplate(excelFile, sheetNo);
List<CCBCurrentBankStatementEntity> entityList = HelperUtil.getEntityList(esCCBCurrentBankStatementMapper, CCBCurrentBankStatementEntity.class);
xiangjiaoTemplate(excelFile, sheetNo, ssss);
} else if (AsposeUtil.getCell(cells, "企业定期明细信息") != null) {
// 读取定期明细
readCompanyRegularDetails(excelFile, cells, sheetNo);
@ -860,7 +863,7 @@ public class CCBDataAnalysisHelper {
}
}
private void xiangjiaoTemplate(File excelFile, int sheetNo ) throws Exception {
private void xiangjiaoTemplate(File excelFile, int sheetNo , String sourceFile) throws Exception {
List<AnalyzeItem> itemList = getAnalyzeItemList(excelFile.getAbsolutePath(), sheetNo);
for (AnalyzeItem item : itemList) {
@ -869,7 +872,7 @@ public class CCBDataAnalysisHelper {
ReadSheet readSheet = EasyExcel.readSheet(sheetNo)
.headRowNumber(item.headRowNumber)
.head(CCBCurrentBankStatementEntity.class)
.registerReadListener(getCurrentDetailListener(item))
.registerReadListener(getCurrentDetailListener(item,sourceFile))
.build();
r.read(readSheet);
@ -885,8 +888,7 @@ public class CCBDataAnalysisHelper {
}
}
private void readCompanyAccountInfo(File excelFile, Cells cells, int sheetNo) {
String sourceFile = HelperUtil.getSourceFileName(excelFile.getAbsolutePath(),BANK_NAME);
private void readCompanyAccountInfo(File excelFile, Cells cells, int sheetNo,String sourceFile) {
// 关键字企业活期账户信息
Cell startCell = null;
@ -949,17 +951,17 @@ public class CCBDataAnalysisHelper {
}
// 读取定期数据分为个人和企业两种数据
private void readRegularDetailsV2(File excelFile, Cells cells, int sheetNo) throws Exception {
private void readRegularDetailsV2(File excelFile, Cells cells, int sheetNo,String sourceFile) throws Exception {
Cell cell = AsposeUtil.getCell(excelFile, sheetNo, "企业");
if (cell != null) {
readRegularDetailsForCompany(excelFile, sheetNo);
readRegularDetailsForCompany(excelFile, sheetNo,sourceFile);
} else {
readRegularDetailsForPerson(excelFile, sheetNo);
readRegularDetailsForPerson(excelFile, sheetNo,sourceFile);
}
}
private void readRegularDetailsForCompany(File excelFile, int sheetNo) throws Exception {
private void readRegularDetailsForCompany(File excelFile, int sheetNo,String sourceFile) throws Exception {
List<AnalyzeItem> itemList = getAnalyzeItemListForCompany(excelFile.getAbsolutePath(), sheetNo);
for (AnalyzeItem item : itemList) {
@ -968,7 +970,7 @@ public class CCBDataAnalysisHelper {
ReadSheet readSheet = EasyExcel.readSheet(sheetNo)
.headRowNumber(item.headRowNumber)
.head(CCBRegularBankStatementEntity.class)
.registerReadListener(getRegularDetailListener(item))
.registerReadListener(getRegularDetailListener(item,sourceFile))
.build();
r.read(readSheet);
@ -984,7 +986,7 @@ public class CCBDataAnalysisHelper {
}
}
private void readRegularDetailsForPerson(File excelFile, int sheetNo) throws Exception {
private void readRegularDetailsForPerson(File excelFile, int sheetNo,String sourceFile) throws Exception {
List<AnalyzeItem> itemList = getAnalyzeItemList(excelFile.getAbsolutePath(), sheetNo);
for (AnalyzeItem item : itemList) {
@ -993,7 +995,7 @@ public class CCBDataAnalysisHelper {
ReadSheet readSheet = EasyExcel.readSheet(sheetNo)
.headRowNumber(item.headRowNumber)
.head(CCBRegularBankStatementEntity.class)
.registerReadListener(getRegularDetailListener(item))
.registerReadListener(getRegularDetailListener(item,sourceFile))
.build();
r.read(readSheet);
@ -1006,7 +1008,7 @@ public class CCBDataAnalysisHelper {
}
}
private ReadListener<CCBRegularBankStatementEntity> getRegularDetailListener(AnalyzeItem item) {
private ReadListener<CCBRegularBankStatementEntity> getRegularDetailListener(AnalyzeItem item,String sourceFile) {
AtomicInteger cnt = new AtomicInteger(item.headRowNumber + 1);
return new ReadListener<CCBRegularBankStatementEntity>() {
@ -1022,7 +1024,7 @@ public class CCBDataAnalysisHelper {
entity.setId(id);
entity.setCardNumber(item.getCardNumber());
entity.setCardHolderName(item.getCardHolderName());
entity.setSourceFile(sourceFile);
docList.add(entity);
if (docList.size() >= Constants.BATCH_SIZE) {
saveToMongo();
@ -1051,7 +1053,7 @@ public class CCBDataAnalysisHelper {
}
// 个人活期明细信息
private void readCurrentDetailsV2(File excelFile, Cells cells, int sheetNo) throws Exception {
private void readCurrentDetailsV2(File excelFile, Cells cells, int sheetNo, String sourceFile) throws Exception {
List<AnalyzeItem> itemList = getAnalyzeItemList(excelFile.getAbsolutePath(), sheetNo);
for (AnalyzeItem item : itemList) {
@ -1060,7 +1062,7 @@ public class CCBDataAnalysisHelper {
ReadSheet readSheet = EasyExcel.readSheet(sheetNo)
.headRowNumber(item.headRowNumber)
.head(CCBCurrentBankStatementEntity.class)
.registerReadListener(getCurrentDetailListener(item))
.registerReadListener(getCurrentDetailListener(item,sourceFile))
.build();
r.read(readSheet);
@ -1076,7 +1078,7 @@ public class CCBDataAnalysisHelper {
}
}
private ReadListener<CCBCurrentBankStatementEntity> getCurrentDetailListener(AnalyzeItem item) {
private ReadListener<CCBCurrentBankStatementEntity> getCurrentDetailListener(AnalyzeItem item,String sourceFile) {
AtomicInteger cnt = new AtomicInteger(item.headRowNumber + 1);
return new ReadListener<CCBCurrentBankStatementEntity>() {
@ -1097,6 +1099,7 @@ public class CCBDataAnalysisHelper {
if(StrUtil.isEmpty(entity.getCardNumber())){
entity.setCardNumber(item.getCardNumber());
}
entity.setSourceFile(sourceFile);
entity.setCardHolderName(item.getCardHolderName());
docList.add(entity);
@ -1129,7 +1132,7 @@ public class CCBDataAnalysisHelper {
/**
* 读取电子现金明细
*/
private void readElectronicCashDetails(File excelFile, Cells cells, int sheetNo) throws Exception {
private void readElectronicCashDetails(File excelFile, Cells cells, int sheetNo,String sourceFile) throws Exception {
List<AnalyzeItem> itemList = getAnalyzeItemList(excelFile.getAbsolutePath(), sheetNo);
for (AnalyzeItem item : itemList) {
@ -1138,7 +1141,7 @@ public class CCBDataAnalysisHelper {
ReadSheet readSheet = EasyExcel.readSheet(sheetNo)
.headRowNumber(item.headRowNumber)
.head(CCBElectronicCashBankStatementEntity.class)
.registerReadListener(getElectronicCashDetailListener(item))
.registerReadListener(getElectronicCashDetailListener(item,sourceFile))
.build();
r.read(readSheet);
@ -1156,7 +1159,7 @@ public class CCBDataAnalysisHelper {
}
}
private ReadListener<CCBElectronicCashBankStatementEntity> getElectronicCashDetailListener(AnalyzeItem item) {
private ReadListener<CCBElectronicCashBankStatementEntity> getElectronicCashDetailListener(AnalyzeItem item,String sourceFile) {
AtomicInteger cnt = new AtomicInteger(item.headRowNumber + 1);
return new ReadListener<CCBElectronicCashBankStatementEntity>() {
@ -1170,7 +1173,7 @@ public class CCBDataAnalysisHelper {
entity.setId(id);
entity.setCardNumber(item.getCardNumber());
entity.setCardHolderName(item.getCardHolderName());
entity.setSourceFile(sourceFile);
docList.add(entity);
if (docList.size() >= Constants.BATCH_SIZE) {
saveToMongo();
@ -1208,7 +1211,7 @@ public class CCBDataAnalysisHelper {
/**
* 读取账户信息
*/
private void readAccountInfo(File excelFile, Cells cells, int sheetNo) throws Exception {
private void readAccountInfo(File excelFile, Cells cells, int sheetNo,String sourceFile) throws Exception {
// 三种账户信息
int currentStartRow = AsposeUtil.getRowNumber(excelFile, sheetNo, "活期账户信息", 0);
if (currentStartRow != -1) {
@ -1217,7 +1220,7 @@ public class CCBDataAnalysisHelper {
int currentEndRow = AsposeUtil.getRowNumber(excelFile, sheetNo, "根据查询条件", currentStartRow);
if (currentEndRow != -1) {
// 1个人活期账户信息 个人活期账户信息
readCurrentAccountInfo(excelFile, sheetNo, currentStartRow, currentEndRow);
readCurrentAccountInfo(excelFile, sheetNo, currentStartRow, currentEndRow,sourceFile);
}
}
int regularStartRow = AsposeUtil.getRowNumber(excelFile, sheetNo, "定期账户信息", 0);
@ -1226,7 +1229,7 @@ public class CCBDataAnalysisHelper {
int regularEndRow = AsposeUtil.getRowNumber(excelFile, sheetNo, "根据查询条件", regularStartRow);
if (regularEndRow != -1) {
// 2个人定期账户信息
readRegularAccountInfo(excelFile, sheetNo, regularStartRow, regularEndRow);
readRegularAccountInfo(excelFile, sheetNo, regularStartRow, regularEndRow,sourceFile);
}
}
@ -1237,7 +1240,7 @@ public class CCBDataAnalysisHelper {
AsposeUtil.getRowNumber(excelFile, sheetNo, "个人电子现金账户信息", electronicCashStartRow);
if (electronicCashEndRow != -1) {
// 3个人电子现金账户信息
readElectronicCashAccountInfo(excelFile, sheetNo, electronicCashStartRow, electronicCashEndRow);
readElectronicCashAccountInfo(excelFile, sheetNo, electronicCashStartRow, electronicCashEndRow,sourceFile);
}
}
}
@ -1245,8 +1248,7 @@ public class CCBDataAnalysisHelper {
/**
* 读取电子现金账户信息
*/
private void readElectronicCashAccountInfo(File excelFile, int sheetNo, int startRow, int endRow) {
String sourceFile = HelperUtil.getSourceFileName(excelFile.getAbsolutePath(),BANK_NAME);
private void readElectronicCashAccountInfo(File excelFile, int sheetNo, int startRow, int endRow,String sourceFile) {
Class<CCBElectronicCashAccountInfoEntity> clazz = CCBElectronicCashAccountInfoEntity.class;
try (ExcelReader reader = EasyExcel.read(excelFile).build()) {
ReadSheet readSheet = EasyExcel.readSheet(sheetNo)
@ -1270,8 +1272,7 @@ public class CCBDataAnalysisHelper {
/**
* 读取定期账户信息
*/
private void readRegularAccountInfo(File excelFile, int sheetNo, int startRow, int endRow) {
String sourceFile = HelperUtil.getSourceFileName(excelFile.getAbsolutePath(),BANK_NAME);
private void readRegularAccountInfo(File excelFile, int sheetNo, int startRow, int endRow,String sourceFile) {
try (ExcelReader reader = EasyExcel.read(excelFile).build()) {
ReadSheet readSheet = EasyExcel.readSheet(sheetNo)
.headRowNumber(startRow)
@ -1293,12 +1294,12 @@ public class CCBDataAnalysisHelper {
/**
* 读取活期账户信息
*/
private void readCurrentAccountInfo(File excelFile, int sheetNo, int startRow, int endRow) {
private void readCurrentAccountInfo(File excelFile, int sheetNo, int startRow, int endRow,String sourceFile) {
try (ExcelReader reader = EasyExcel.read(excelFile).build()) {
ReadSheet readSheet = EasyExcel.readSheet(sheetNo)
.headRowNumber(startRow)
.head(CCBCurrentAccountInfoEntity.class)
.registerReadListener(new ReadCCBCurrentAccountInfoListener(startRow, endRow, accountInfoMapper))
.registerReadListener(new ReadCCBCurrentAccountInfoListener(startRow, endRow, accountInfoMapper,sourceFile))
.build();
reader.read(readSheet);
} catch (Exception e) {

5
cas-system/src/main/java/com/inscloudtech/bankStatementAnalysis/listener/ReadCCBCurrentAccountInfoListener.java

@ -21,7 +21,7 @@ public class ReadCCBCurrentAccountInfoListener implements ReadListener<CCBCurren
private int startRow;
private int endRow;
private String sourceFile;
private static final int BATCH_SIZE = 100;
@ -29,10 +29,11 @@ public class ReadCCBCurrentAccountInfoListener implements ReadListener<CCBCurren
private final EsCCBCurrentAccountInfoMapper infoMapper;
public ReadCCBCurrentAccountInfoListener(int startRow, int endRow, EsCCBCurrentAccountInfoMapper infoMapper) {
public ReadCCBCurrentAccountInfoListener(int startRow, int endRow, EsCCBCurrentAccountInfoMapper infoMapper,String sourceFile) {
this.startRow = startRow;
this.endRow = endRow;
this.infoMapper = infoMapper;
this.sourceFile = sourceFile;
}
@Override

Loading…
Cancel
Save