Browse Source

rar流水导入

master
583641232@qq.com 1 year ago
parent
commit
4e0bed6061
  1. 11
      cas-admin/src/main/java/com/inscloudtech/web/controller/datacenter/RealEstateController.java
  2. 2
      cas-system/src/main/java/com/inscloudtech/bankStatementAnalysis/helper/HBDataAnalysisHelper.java
  3. 41
      cas-system/src/main/java/com/inscloudtech/bankStatementAnalysis/service/impl/ImportServiceImpl.java
  4. 27
      cas-system/src/main/java/com/inscloudtech/datacenter/service/QueryCenterService.java

11
cas-admin/src/main/java/com/inscloudtech/web/controller/datacenter/RealEstateController.java

@ -84,29 +84,24 @@ public class RealEstateController extends BaseController {
try { try {
// 获取文件名和扩展名 // 获取文件名和扩展名
String suffix = FileUtil.getSuffix(file.getOriginalFilename()); String suffix = FileUtil.getSuffix(file.getOriginalFilename());
// 创建临时文件 // 创建临时文件
Path tempFilePath = Files.createTempFile("temp", "." + suffix); Path tempFilePath = Files.createTempFile("temp", "." + suffix);
File tempFile = tempFilePath.toFile(); File tempFile = tempFilePath.toFile();
// 写入文件内容 // 写入文件内容
try (InputStream inputStream = file.getInputStream()) { try (InputStream inputStream = file.getInputStream()) {
Files.copy(inputStream, tempFilePath, StandardCopyOption.REPLACE_EXISTING); Files.copy(inputStream, tempFilePath, StandardCopyOption.REPLACE_EXISTING);
} }
Workbook wb = new Workbook(tempFile.getAbsolutePath()); Workbook wb = new Workbook(tempFile.getAbsolutePath());
List<RealEstate> list = new ArrayList<>(); List<RealEstate> list = new ArrayList<>();
int count = wb.getWorksheets().getCount(); int count = wb.getWorksheets().getCount();
for (int sheetNo = 0; sheetNo < count; sheetNo++) { for (int sheetNo = 0; sheetNo < count; sheetNo++) {
Worksheet worksheet = wb.getWorksheets().get(sheetNo); Worksheet worksheet = wb.getWorksheets().get(sheetNo);
Cells cells = worksheet.getCells(); Cells cells = worksheet.getCells();
Cell flagCell = AsposeUtil.getCell(cells, "开户日");
Cell flagCell = AsposeUtil.getCell(cells, "房产地址");
Integer headRowNumber = flagCell.getRow() + 1;
ImportExcelHelper<RealEstate> helper = new ImportExcelHelper<>(); ImportExcelHelper<RealEstate> helper = new ImportExcelHelper<>();
List<RealEstate> tempList = helper.getListWithInputStream(file.getInputStream(), RealEstate.class, sheetNo, 1);
List<RealEstate> tempList = helper.getListWithInputStream(file.getInputStream(), RealEstate.class, sheetNo, headRowNumber);
list.addAll(tempList); list.addAll(tempList);
} }
// ExcelResult<RealEstate> excelResult = ExcelUtil.importExcel(file.getInputStream(), RealEstate.class, true); // ExcelResult<RealEstate> excelResult = ExcelUtil.importExcel(file.getInputStream(), RealEstate.class, true);

2
cas-system/src/main/java/com/inscloudtech/bankStatementAnalysis/helper/HBDataAnalysisHelper.java

@ -503,9 +503,7 @@ public class HBDataAnalysisHelper {
if (nameCell == null) { if (nameCell == null) {
nameCell = AsposeUtil.getCell(excelFile, "账户名称"); nameCell = AsposeUtil.getCell(excelFile, "账户名称");
if (nameCell == null) { if (nameCell == null) {
log.error("无法获取账户名称{}",excelFile.getAbsolutePath());
readHuaXiaAccountDetails(excelFile); readHuaXiaAccountDetails(excelFile);
// throw new ImportDataFailedException("无法获取账户名称", excelFile.getAbsolutePath());
}else { }else {
String cardHolderName = null; String cardHolderName = null;
String cardNumber = null; String cardNumber = null;

41
cas-system/src/main/java/com/inscloudtech/bankStatementAnalysis/service/impl/ImportServiceImpl.java

@ -2,6 +2,7 @@ package com.inscloudtech.bankStatementAnalysis.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
@ -14,18 +15,26 @@ import com.alibaba.excel.read.metadata.ReadSheet;
import com.alibaba.excel.util.ListUtils; import com.alibaba.excel.util.ListUtils;
import com.aspose.cells.Cell;
import com.aspose.cells.Cells;
import com.aspose.cells.Workbook;
import com.aspose.cells.Worksheet;
import com.inscloudtech.bankStatementAnalysis.domain.HeadField; import com.inscloudtech.bankStatementAnalysis.domain.HeadField;
import com.inscloudtech.bankStatementAnalysis.domain.ImportOpeningAccountInfo; import com.inscloudtech.bankStatementAnalysis.domain.ImportOpeningAccountInfo;
import com.inscloudtech.bankStatementAnalysis.domain.ReadDto; import com.inscloudtech.bankStatementAnalysis.domain.ReadDto;
import com.inscloudtech.bankStatementAnalysis.helper.EsMapperHolder; import com.inscloudtech.bankStatementAnalysis.helper.EsMapperHolder;
import com.inscloudtech.bankStatementAnalysis.helper.HelperUtil; import com.inscloudtech.bankStatementAnalysis.helper.HelperUtil;
import com.inscloudtech.bankStatementAnalysis.service.ImportService; import com.inscloudtech.bankStatementAnalysis.service.ImportService;
import com.inscloudtech.bankStatementAnalysis.util.AsposeUtil;
import com.inscloudtech.common.constant.Constants; import com.inscloudtech.common.constant.Constants;
import com.inscloudtech.common.excel.ImportExcelHelper;
import com.inscloudtech.common.exception.dc.ImportDataFailedException; import com.inscloudtech.common.exception.dc.ImportDataFailedException;
import com.inscloudtech.datacenter.domain.RealEstate;
import com.inscloudtech.datacenter.mapper.es.ESOpeningAccountInfoMapper; import com.inscloudtech.datacenter.mapper.es.ESOpeningAccountInfoMapper;
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 lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.dromara.easyes.core.biz.SAPageInfo; import org.dromara.easyes.core.biz.SAPageInfo;
import org.dromara.easyes.core.conditions.select.LambdaEsQueryWrapper; import org.dromara.easyes.core.conditions.select.LambdaEsQueryWrapper;
@ -33,12 +42,19 @@ import org.dromara.easyes.core.core.BaseEsMapper;
import org.dromara.easyes.core.core.EsWrappers; import org.dromara.easyes.core.core.EsWrappers;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.File;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.*; import java.util.*;
import java.util.function.Function; import java.util.function.Function;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlException;
import org.springframework.web.multipart.MultipartFile;
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
@Slf4j @Slf4j
@ -363,7 +379,30 @@ public class ImportServiceImpl implements ImportService {
String idCardVerify = "([1-9]\\d{5}(18|19|20)\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx])|([1-9]\\d{5}\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3})"; String idCardVerify = "([1-9]\\d{5}(18|19|20)\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx])|([1-9]\\d{5}\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3})";
String CarNumberVerify = "^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$"; String CarNumberVerify = "^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$";
@SneakyThrows
void aaa(MultipartFile file){
// 获取文件名和扩展名
String suffix = FileUtil.getSuffix(file.getOriginalFilename());
// 创建临时文件
Path tempFilePath = Files.createTempFile("temp", "." + suffix);
File tempFile = tempFilePath.toFile();
// 写入文件内容
try (InputStream inputStream = file.getInputStream()) {
Files.copy(inputStream, tempFilePath, StandardCopyOption.REPLACE_EXISTING);
}
Workbook wb = new Workbook(tempFile.getAbsolutePath());
List<RealEstate> list = new ArrayList<>();
int count = wb.getWorksheets().getCount();
for (int sheetNo = 0; sheetNo < count; sheetNo++) {
Worksheet worksheet = wb.getWorksheets().get(sheetNo);
Cells cells = worksheet.getCells();
Cell flagCell = AsposeUtil.getCell(cells, "房产地址");
Integer headRowNumber = flagCell.getRow() + 1;
ImportExcelHelper<RealEstate> helper = new ImportExcelHelper<>();
List<RealEstate> tempList = helper.getListWithInputStream(file.getInputStream(), RealEstate.class, sheetNo, headRowNumber);
list.addAll(tempList);
}
}
} }

27
cas-system/src/main/java/com/inscloudtech/datacenter/service/QueryCenterService.java

@ -2,6 +2,7 @@ package com.inscloudtech.datacenter.service;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ClassUtil; import cn.hutool.core.util.ClassUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
@ -196,10 +197,10 @@ public class QueryCenterService {
} }
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
result.put("indexArr", ArrayUtil.toArray(indexList, String.class));
result.put("nameFieldList", nameFieldList);
result.put("idCardFieldList", idCardFieldList);
result.put("phoneFieldList", phoneFieldList);
result.putOpt("indexArr", ArrayUtil.toArray(indexList, String.class));
result.putOnce("nameFieldList", nameFieldList);
result.putOpt("idCardFieldList", idCardFieldList);
result.putOpt("phoneFieldList", phoneFieldList);
return result; return result;
} }
@ -254,9 +255,9 @@ public class QueryCenterService {
indexAndCount.put("dc_bank_statement",bsRes.getHits().getTotalHits().value); indexAndCount.put("dc_bank_statement",bsRes.getHits().getTotalHits().value);
JSONObject queryInfo = getQueryInfo(initQueryIndex(0)); JSONObject queryInfo = getQueryInfo(initQueryIndex(0));
String[] indexArrs = queryInfo.getBean("indexArr", String[].class);
SearchRequest searchRequest = new SearchRequest(indexArrs); // 设置要查询的索引
List<String> indexList = queryInfo.getBeanList("indexArr", String.class);
String[] indexArr = ArrayUtil.toArray(indexList, String.class);
SearchRequest searchRequest = new SearchRequest(indexArr); // 设置要查询的索引
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
if (null != query.getCaseId()) { if (null != query.getCaseId()) {
@ -427,7 +428,9 @@ public class QueryCenterService {
@SneakyThrows @SneakyThrows
public JSONObject getData4ExcelExport(QueryCenterQuery query) { public JSONObject getData4ExcelExport(QueryCenterQuery query) {
JSONObject queryInfo = getQueryInfo(initQueryIndex(query.getIsOther())); JSONObject queryInfo = getQueryInfo(initQueryIndex(query.getIsOther()));
SearchRequest searchRequest = new SearchRequest(queryInfo.getBean("indexArr", String[].class)); // 设置要查询的索引
List<String> indexList = queryInfo.getBeanList("indexArr", String.class);
String[] indexArr = ArrayUtil.toArray(indexList, String.class);
SearchRequest searchRequest = new SearchRequest(indexArr); // 设置要查询的索引
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
// if (null != query.getCaseId()) { // if (null != query.getCaseId()) {
@ -714,7 +717,9 @@ public class QueryCenterService {
@SneakyThrows @SneakyThrows
public JSONObject getData4Report(List<Class<?>> willSearch, String name, String idCard, String caseId) { public JSONObject getData4Report(List<Class<?>> willSearch, String name, String idCard, String caseId) {
JSONObject queryInfo = getQueryInfo(willSearch); JSONObject queryInfo = getQueryInfo(willSearch);
SearchRequest searchRequest = new SearchRequest(queryInfo.getBean("indexArr", String[].class)); // 设置要查询的索引
List<String> indexList = queryInfo.getBeanList("indexArr", String.class);
String[] indexArr = ArrayUtil.toArray(indexList, String.class);
SearchRequest searchRequest = new SearchRequest(indexArr); // 设置要查询的索引
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
if (null != caseId) { if (null != caseId) {
@ -834,7 +839,9 @@ public class QueryCenterService {
@SneakyThrows @SneakyThrows
public Map<String, ?> getData4ReportWithHighlight(List<Class<?>> willSearch, String name,String idCard, String caseId) { public Map<String, ?> getData4ReportWithHighlight(List<Class<?>> willSearch, String name,String idCard, String caseId) {
JSONObject queryInfo = getQueryInfo(willSearch); JSONObject queryInfo = getQueryInfo(willSearch);
SearchRequest searchRequest = new SearchRequest(queryInfo.getBean("indexArr", String[].class)); // 设置要查询的索引
List<String> indexList = queryInfo.getBeanList("indexArr", String.class);
String[] indexArr = ArrayUtil.toArray(indexList, String.class);
SearchRequest searchRequest = new SearchRequest(indexArr); // 设置要查询的索引
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
if (null != caseId) { if (null != caseId) {

Loading…
Cancel
Save