|
@ -18,32 +18,26 @@ import com.alibaba.excel.read.listener.ReadListener; |
|
|
import com.alibaba.excel.read.metadata.ReadSheet; |
|
|
import com.alibaba.excel.read.metadata.ReadSheet; |
|
|
import com.alibaba.excel.read.metadata.holder.ReadHolder; |
|
|
import com.alibaba.excel.read.metadata.holder.ReadHolder; |
|
|
import com.alibaba.excel.util.ListUtils; |
|
|
import com.alibaba.excel.util.ListUtils; |
|
|
|
|
|
|
|
|
import com.aspose.cells.Cell; |
|
|
import com.aspose.cells.Cell; |
|
|
import com.aspose.cells.Cells; |
|
|
import com.aspose.cells.Cells; |
|
|
import com.aspose.cells.Workbook; |
|
|
import com.aspose.cells.Workbook; |
|
|
import com.aspose.cells.Worksheet; |
|
|
import com.aspose.cells.Worksheet; |
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
|
|
|
|
|
|
|
|
import com.inscloudtech.bankStatementAnalysis.helper.HelperUtil; |
|
|
|
|
|
|
|
|
import com.inscloudtech.bankStatementAnalysis.domain.ImportCommonStatement; |
|
|
|
|
|
import com.inscloudtech.bankStatementAnalysis.domain.entity.PSBCETStatementEntity; |
|
|
|
|
|
import com.inscloudtech.bankStatementAnalysis.domain.entity.PSBCOpeningAccountInfoEntity; |
|
|
|
|
|
import com.inscloudtech.bankStatementAnalysis.domain.entity.PSBCStatementEntity; |
|
|
|
|
|
import com.inscloudtech.bankStatementAnalysis.mapper.EsPSBCOpeningAccountInfoMapper; |
|
|
|
|
|
import com.inscloudtech.bankStatementAnalysis.mapper.EsPSBCStatementMapper; |
|
|
|
|
|
import com.inscloudtech.bankStatementAnalysis.util.AsposeUtil; |
|
|
import com.inscloudtech.common.constant.Constants; |
|
|
import com.inscloudtech.common.constant.Constants; |
|
|
import com.inscloudtech.common.exception.dc.AnalyzeDataFailedException; |
|
|
import com.inscloudtech.common.exception.dc.AnalyzeDataFailedException; |
|
|
import com.inscloudtech.common.exception.dc.ImportDataFailedException; |
|
|
import com.inscloudtech.common.exception.dc.ImportDataFailedException; |
|
|
import com.inscloudtech.common.utils.bean.BeanUtils; |
|
|
import com.inscloudtech.common.utils.bean.BeanUtils; |
|
|
import com.inscloudtech.common.utils.file.FileUtils; |
|
|
|
|
|
import com.inscloudtech.datacenter.domain.PlateNumberInfo; |
|
|
|
|
|
import com.inscloudtech.bankStatementAnalysis.mapper.EsPSBCOpeningAccountInfoMapper; |
|
|
|
|
|
import com.inscloudtech.bankStatementAnalysis.mapper.EsPSBCStatementMapper; |
|
|
|
|
|
import com.inscloudtech.datacenter.service.ImportResultService; |
|
|
|
|
|
import com.inscloudtech.datacenter.domain.BankStatement; |
|
|
import com.inscloudtech.datacenter.domain.BankStatement; |
|
|
import com.inscloudtech.datacenter.domain.OpeningAccountInfo; |
|
|
import com.inscloudtech.datacenter.domain.OpeningAccountInfo; |
|
|
|
|
|
|
|
|
import com.inscloudtech.bankStatementAnalysis.domain.entity.PSBCETStatementEntity; |
|
|
|
|
|
import com.inscloudtech.bankStatementAnalysis.domain.entity.PSBCOpeningAccountInfoEntity; |
|
|
|
|
|
import com.inscloudtech.bankStatementAnalysis.domain.entity.PSBCStatementEntity; |
|
|
|
|
|
|
|
|
|
|
|
import com.inscloudtech.bankStatementAnalysis.util.AsposeUtil; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.inscloudtech.datacenter.domain.PlateNumberInfo; |
|
|
|
|
|
import com.inscloudtech.datacenter.service.ImportResultService; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.springframework.stereotype.Component; |
|
|
import org.springframework.stereotype.Component; |
|
@ -55,7 +49,6 @@ import java.util.*; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 中国邮政储蓄银行数据分析 |
|
|
* 中国邮政储蓄银行数据分析 |
|
|
*/ |
|
|
*/ |
|
@ -429,7 +422,6 @@ public class PSBCDataAnalysisHelper { |
|
|
saveData(); |
|
|
saveData(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
log.info("读取邮政储蓄银行流水结束"); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
@ -524,7 +516,7 @@ public class PSBCDataAnalysisHelper { |
|
|
return map; |
|
|
return map; |
|
|
} |
|
|
} |
|
|
/** |
|
|
/** |
|
|
* 读取开户信息 |
|
|
|
|
|
|
|
|
* |
|
|
*/ |
|
|
*/ |
|
|
private void readETData(File excelFile) { |
|
|
private void readETData(File excelFile) { |
|
|
String excelFileName = excelFile.getAbsolutePath(); |
|
|
String excelFileName = excelFile.getAbsolutePath(); |
|
@ -578,7 +570,6 @@ public class PSBCDataAnalysisHelper { |
|
|
saveData(); |
|
|
saveData(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
log.info("读取邮政储蓄银行流水结束"); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
@ -606,6 +597,76 @@ public class PSBCDataAnalysisHelper { |
|
|
reader.read(sheet); |
|
|
reader.read(sheet); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void readBs20240912(File excelFile, Cells cells, int sheetNo,Cell qtlsh){ |
|
|
|
|
|
|
|
|
|
|
|
String cardHolderName = HelperUtil.getStringValue(cells, "客户名称:"); |
|
|
|
|
|
String cardNumber = HelperUtil.getStringValue(cells, "客户账号:"); |
|
|
|
|
|
|
|
|
|
|
|
String sourceFile = HelperUtil.getSourceFileName(excelFile.getAbsolutePath(),BANK_NAME); |
|
|
|
|
|
try (ExcelReader reader = EasyExcel.read(excelFile).build()) { |
|
|
|
|
|
ReadSheet sheet = EasyExcel.readSheet(sheetNo) |
|
|
|
|
|
.headRowNumber(qtlsh.getRow()+1) |
|
|
|
|
|
.head(ImportCommonStatement.class) |
|
|
|
|
|
.registerReadListener(new ReadListener<ImportCommonStatement>() { |
|
|
|
|
|
private static final int BATCH_SIZE = Constants.BATCH_SIZE; |
|
|
|
|
|
private List<PSBCStatementEntity> cacheList = |
|
|
|
|
|
ListUtils.newArrayListWithExpectedSize(BATCH_SIZE); |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void invoke(ImportCommonStatement importData, AnalysisContext context) { |
|
|
|
|
|
String balance = importData.getBalance(); |
|
|
|
|
|
if (StringUtils.isEmpty(balance)) { // 过滤没有余额的数据 |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
PSBCStatementEntity entry = new PSBCStatementEntity(); |
|
|
|
|
|
BeanUtil.copyProperties(importData,entry); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String id = IdUtil.objectId(); |
|
|
|
|
|
entry.setId(id); |
|
|
|
|
|
entry.setCardNumber(cardNumber); |
|
|
|
|
|
entry.setCardHolderName(cardHolderName); |
|
|
|
|
|
entry.setSourceFile(sourceFile); |
|
|
|
|
|
String transactionTime = importData.getTransactionDate() + " " + importData.getTransactionTime(); |
|
|
|
|
|
entry.setTransactionTime(transactionTime); |
|
|
|
|
|
String loanFlag = importData.getLoanFlag(); |
|
|
|
|
|
String transactionAmount = importData.getTransactionAmount(); |
|
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(transactionAmount); |
|
|
|
|
|
if (StrUtil.isNotEmpty(loanFlag) && loanFlag.contains("借")) {//transChannel |
|
|
|
|
|
BigDecimal subtract = bigDecimal.negate(); |
|
|
|
|
|
entry.setTransactionAmount(subtract.toString()); |
|
|
|
|
|
} |
|
|
|
|
|
cacheList.add(entry); |
|
|
|
|
|
if (cacheList.size() >= BATCH_SIZE) { |
|
|
|
|
|
saveData(); |
|
|
|
|
|
cacheList = ListUtils.newArrayListWithExpectedSize(BATCH_SIZE); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void doAfterAllAnalysed(AnalysisContext context) { |
|
|
|
|
|
// 保存不够一百条数据的批次 |
|
|
|
|
|
if (!cacheList.isEmpty()) { |
|
|
|
|
|
saveData(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void saveData() { |
|
|
|
|
|
statementMapper.insertBatch(cacheList); |
|
|
|
|
|
cacheList = ListUtils.newArrayListWithExpectedSize(BATCH_SIZE); |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
.build(); |
|
|
|
|
|
reader.read(sheet); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
log.error("读取流水失败", e); |
|
|
|
|
|
throw new ImportDataFailedException(e.getMessage(), sourceFile); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private void readPSBCStatement(File excelFile, Cells cells, int sheetNo) throws Exception { |
|
|
private void readPSBCStatement(File excelFile, Cells cells, int sheetNo) throws Exception { |
|
|
|
|
|
|
|
|
Cell cell = AsposeUtil.getCell(cells, "交易日期"); |
|
|
Cell cell = AsposeUtil.getCell(cells, "交易日期"); |
|
@ -617,7 +678,11 @@ public class PSBCDataAnalysisHelper { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Cell rstCell = AsposeUtil.getCell(excelFile, 0, "客户账号"); |
|
|
Cell rstCell = AsposeUtil.getCell(excelFile, 0, "客户账号"); |
|
|
if (rstCell != null) {//et模板 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Cell qtlsh = AsposeUtil.getCell(excelFile, 0, "前台流水号"); |
|
|
|
|
|
if(qtlsh != null && rstCell != null){ |
|
|
|
|
|
readBs20240912(excelFile,cells,sheetNo,qtlsh); |
|
|
|
|
|
}else if(rstCell != null) {//et模板 |
|
|
readETData(excelFile); |
|
|
readETData(excelFile); |
|
|
}else { |
|
|
}else { |
|
|
rstCell = AsposeUtil.getCell(excelFile, 0, "账号卡号"); |
|
|
rstCell = AsposeUtil.getCell(excelFile, 0, "账号卡号"); |
|
@ -723,7 +788,6 @@ public class PSBCDataAnalysisHelper { |
|
|
saveData(); |
|
|
saveData(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
log.info("读取邮政储蓄银行流水结束"); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|