|
|
@ -3,6 +3,8 @@ package com.inscloudtech.bankStatementAnalysis.helper; |
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
import cn.hutool.core.io.FileUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import cn.hutool.json.JSON; |
|
|
|
import cn.hutool.json.JSONObject; |
|
|
|
import com.alibaba.excel.EasyExcel; |
|
|
|
import com.alibaba.excel.ExcelReader; |
|
|
|
import com.alibaba.excel.read.metadata.ReadSheet; |
|
|
@ -103,7 +105,7 @@ public class ICBCDataAnalysisHelper { |
|
|
|
String withSheetName = sourceFile + BankStatementConstants.NAME_WITH_SHEET_NAME + worksheetName; |
|
|
|
/**20240418新增模板*/ |
|
|
|
if (cell420240418 != null) { |
|
|
|
readBSFor20240418(cells,cell420240418,absolutePath, sheetNo,withSheetName); |
|
|
|
readBSFor20240418(cells,absolutePath, sheetNo,withSheetName); |
|
|
|
}else if (khCell != null) { |
|
|
|
// 判断是否是开户信息 |
|
|
|
int rowNumber = khCell.getRow() + 1; |
|
|
@ -127,20 +129,58 @@ public class ICBCDataAnalysisHelper { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void readBSFor20240418(Cells cells,Cell dateCell,String absolutePath, int sheetNo,String sourceFile) { |
|
|
|
int startRow = dateCell.getRow(); |
|
|
|
Cell cardHolderNameCell = cells.get(startRow - 1, 1); |
|
|
|
if(null == cardHolderNameCell || StrUtil.isEmpty(cardHolderNameCell.getStringValue())){ |
|
|
|
throw new ImportDataFailedException("读取持卡人信息异常", sourceFile); |
|
|
|
} |
|
|
|
private void readBSFor20240418(Cells cells ,String absolutePath, int sheetNo,String sourceFile) { |
|
|
|
// int startRow = dateCell.getRow(); |
|
|
|
// Cell cardHolderNameCell = cells.get(startRow - 1, 1); |
|
|
|
// if(null == cardHolderNameCell || StrUtil.isEmpty(cardHolderNameCell.getStringValue())){ |
|
|
|
// throw new ImportDataFailedException("读取持卡人信息异常", sourceFile); |
|
|
|
// } |
|
|
|
|
|
|
|
String cardHolderName = cardHolderNameCell.getStringValue().trim(); |
|
|
|
|
|
|
|
List<JSONObject> maps = new LinkedList<>(); |
|
|
|
int maxRow = cells.getMaxRow(); |
|
|
|
List<HeadField> headFields = new ArrayList<>(); |
|
|
|
headFields.add(new HeadField("transactionAmount","发生额")); |
|
|
|
headFields.add(new HeadField("balance","余额")); |
|
|
|
headFields.add(new HeadField("accountNumber","商密二级,帐号")); |
|
|
|
importService.readMultiplePersonAndMultipleHeadBankStatement(absolutePath,startRow + 1,sheetNo, |
|
|
|
for(int i = 0; i < maxRow; i++){ |
|
|
|
Cell dateCell = cells.get(i, 2); |
|
|
|
String stringValue = dateCell.getStringValue(); |
|
|
|
if (StrUtil.isEmpty(stringValue)) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
if(stringValue.equals("入帐日期")){ |
|
|
|
int startRow = dateCell.getRow(); |
|
|
|
Cell cardHolderNameCell = cells.get(startRow - 1, 1); |
|
|
|
if(null == cardHolderNameCell || StrUtil.isEmpty(cardHolderNameCell.getStringValue())){ |
|
|
|
throw new ImportDataFailedException("读取持卡人信息异常", sourceFile); |
|
|
|
} |
|
|
|
String cardHolderName = cardHolderNameCell.getStringValue().trim(); |
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
|
jsonObject.putOnce("startRow",i); |
|
|
|
jsonObject.putOnce("cardHolderName",cardHolderName); |
|
|
|
maps.add(jsonObject); |
|
|
|
} |
|
|
|
} |
|
|
|
int size = maps.size(); |
|
|
|
for(int i = 0; i < size; i++){ |
|
|
|
JSONObject jsonObject = maps.get(i); |
|
|
|
String cardHolderName = jsonObject.getStr("cardHolderName"); |
|
|
|
int headRowNumber = jsonObject.getInt("startRow") + 1; |
|
|
|
int endRow = maxRow -1; |
|
|
|
if(i + 1 < size){ |
|
|
|
JSONObject nextRow = maps.get(i + 1); |
|
|
|
endRow = nextRow.getInt("startRow") - 1; |
|
|
|
} |
|
|
|
|
|
|
|
if(endRow - headRowNumber <= 1){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
importService.readMultiplePersonAndMultipleHeadBankStatement(absolutePath,headRowNumber,endRow,sheetNo, |
|
|
|
ICBCBankStatementEntry.class,bankStatementMapper,cardHolderName,sourceFile,headFields); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|