|
|
@@ -2534,148 +2534,16 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
"应收开票-导出模板(平台)-" + Instant.now());
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 车险应收数据导入
|
|
|
- *
|
|
|
- * @param file
|
|
|
- * @author lipf
|
|
|
- * @date 2026/8/17 15:43
|
|
|
- */
|
|
|
- @Override
|
|
|
- public ImportUpdateExcelResultVo importAccountsReceivableInvoice4CarRisk(MultipartFile file) {
|
|
|
- String userName = baseController.getUserName();
|
|
|
- log.info("用户[{}]导入私有车险应收文件",userName);
|
|
|
-
|
|
|
- List<ExcelContent4PrivateSuperviseCar> excelContents = importIncomeService.parseImportExcel4PrivateCar(file);
|
|
|
- if (CollUtil.isEmpty(excelContents)){
|
|
|
- log.info("数据不能为空,导入失败");
|
|
|
- throw new SystemException("数据不能为空,导入失败");
|
|
|
- }
|
|
|
- AssertionUtils.isEmpty(excelContents, "车险应收数据处理失败,导入失败");
|
|
|
- //List<ImportContentExt> datas = importIncomeService.fillExcelContent4Private(excelContents);
|
|
|
-
|
|
|
-
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 导入应收开票数据
|
|
|
- * @param file Excel文件,包含应收开票数据,文件格式应符合InvoiceReceivableExportExcelVo的定义
|
|
|
- * @return ImportUpdateExcelResultVo 返回导入结果对象,包含:
|
|
|
- * - successNumber: 成功导入的记录数(新增或更新)
|
|
|
- * - failedNumber: 失败的记录数
|
|
|
- * - failedData: 失败的数据列表,包含错误原因说明
|
|
|
- * - failFileUrl: 失败数据Excel文件的下载链接(如果有失败数据)
|
|
|
- * - orderNos: 成功导入的订单号列表
|
|
|
- */
|
|
|
- @Override
|
|
|
- public ImportUpdateExcelResultVo importAccountsReceivableInvoice4NoCarRisk(MultipartFile file) {
|
|
|
- String userName = baseController.getUserName();
|
|
|
- log.info("用户[{}]导入私有非车险应收文件",userName);
|
|
|
-
|
|
|
- List<ExcelContent4PrivateSuperviseNoCar> excelContents = importIncomeService.parseImportExcel4PrivateNoCar(file);
|
|
|
- if (CollUtil.isEmpty(excelContents)){
|
|
|
- throw new SystemException("数据不能为空,导入失败");
|
|
|
- }
|
|
|
- AssertionUtils.isEmpty(excelContents, "数据处理失败,导入失败");
|
|
|
- List<ImportContentExt> datas = importIncomeService.fillExcelContent4Private(excelContents);
|
|
|
-
|
|
|
-
|
|
|
- // int failedNumber = 0;
|
|
|
- List<ImportContentExt> failedExcel = new ArrayList<>();
|
|
|
- // 只存储需要【修改】的数据
|
|
|
- List<InsPlyIncome> updateExcel = new ArrayList<>();
|
|
|
- List<InsPlyIncome> insertExcel = new ArrayList<>();
|
|
|
- // 存储导入成功的订单号
|
|
|
- List<String> successOrderNoList = new ArrayList<>();
|
|
|
-
|
|
|
- // 校验Excel内部保单号重复
|
|
|
- Set<String> existPolicyNoSet = new HashSet<>();
|
|
|
- Set<String> repeatPolicyNoSet = new HashSet<>();
|
|
|
- Set<String> existCompanyIdSet = new HashSet<>();
|
|
|
-
|
|
|
- for (ImportContentExt vo : datas) {
|
|
|
- String policyNo = vo.getJqPolicyNo();
|
|
|
- if (existPolicyNoSet.contains(policyNo)) {
|
|
|
- repeatPolicyNoSet.add(policyNo);
|
|
|
- } else {
|
|
|
- existPolicyNoSet.add(policyNo);
|
|
|
- }
|
|
|
- existCompanyIdSet.add(vo.getCompanyName());
|
|
|
- }
|
|
|
-
|
|
|
- // 导入只能一个保司
|
|
|
- if (existCompanyIdSet.size() > 1) {
|
|
|
- throw new SystemException("导入数据不能包含多个保险公司");
|
|
|
- }
|
|
|
-
|
|
|
- // 处理数据
|
|
|
- for (ImportContentExt vo : datas) {
|
|
|
- // 1. 空数据校验
|
|
|
- ImportResultVo resultVo = vo.checkEmpty();
|
|
|
- if (!resultVo.isSuccess()) {
|
|
|
- vo.setErrorMessage(resultVo.convert2Str());
|
|
|
- failedExcel.add(vo);
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- // 2. Excel内部保单号重复
|
|
|
- if (repeatPolicyNoSet.contains(vo.getJqPolicyNo())) {
|
|
|
- vo.setErrorMessage("保单号重复");
|
|
|
- failedExcel.add(vo);
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- // 查询订单
|
|
|
- HttpResult<InsOrdersVo> insOrdersVoHttpResult = insOrdersClient.selectById(vo.getOrderNo());
|
|
|
- InsOrdersVo data = insOrdersVoHttpResult.getData();
|
|
|
- if (null == data){
|
|
|
- vo.setErrorMessage("订单号不存在");
|
|
|
- failedExcel.add(vo);
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- // 查询数据库中是否已存在该协议
|
|
|
- PtlAgreement ptlAgreement = ptlAgreementMapper.selectOne(new LambdaQueryWrapper<PtlAgreement>()
|
|
|
- .eq(PtlAgreement::getId, data.getAgreementId()));
|
|
|
-
|
|
|
- // 数据库不存在 → 直接失败
|
|
|
- if (Objects.isNull(ptlAgreement) || !"2".equals(ptlAgreement.getAgreementType().toString())) {
|
|
|
- vo.setErrorMessage("协议编码在协议中不存在");
|
|
|
- failedExcel.add(vo);
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- // 查询数据库中是否已存在该保单号
|
|
|
- ImportContentExt failedVO = importIncomeService.spliceData(vo, insertExcel, updateExcel);
|
|
|
- if(failedVO != null){
|
|
|
- failedExcel.add(failedVO);
|
|
|
- }
|
|
|
- }
|
|
|
- ImportUpdateExcelResultVo importExcelResultVo = importIncomeService.getDataManipulationResult(updateExcel, insertExcel, failedExcel);
|
|
|
- log.info("私有应收:导入结果。importExcelResultVo=[{}]", JSONUtil.toJsonStr(importExcelResultVo));
|
|
|
- return importExcelResultVo;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 导入平台的应收数据
|
|
|
* @param file
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public ImportUpdateExcelResultVo importPlatformReceivableInvoice(MultipartFile file) {
|
|
|
+ public ImportUpdateExcelResultVo importPlatformReceivableInvoice(MultipartFile file, String type) {
|
|
|
String userName = baseController.getUserName();
|
|
|
log.info("用户[{}]导入平台应收文件",userName);
|
|
|
-
|
|
|
- List<ExcelContent4Platform> excelContents = importIncomeService.parseImportExcel4Platform(file);
|
|
|
- log.info("从Excel文件中读取到[{}]条记录", CollUtil.size(excelContents));
|
|
|
- if (CollUtil.isEmpty(excelContents)){
|
|
|
- log.error("用户[{}]导入平台应收文件,数据不能为空,导入失败",userName);
|
|
|
- throw new SystemException("数据不能为空,导入失败");
|
|
|
- }
|
|
|
- AssertionUtils.isEmpty(excelContents, "数据处理失败,导入失败");
|
|
|
- List<ImportContentExt> datas = importIncomeService.fillExcelContent4Platform(excelContents);
|
|
|
-
|
|
|
+ List<ImportContentExt> datas = this.parseAndFillContent(file, type);
|
|
|
// 只存储需要【修改】的数据
|
|
|
List<InsPlyIncome> updateExcel = new ArrayList<>();
|
|
|
List<InsPlyIncome> insertExcel = new ArrayList<>();
|
|
|
@@ -2731,6 +2599,33 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
return importExcelResultVo;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 解析Excel内容并填充缺失的字段
|
|
|
+ *
|
|
|
+ * @param type 类型 20 表示平台协议 11表示车险手续费 12 表示非车险手续费
|
|
|
+ * @param file 上传的文件
|
|
|
+ * @author lipf
|
|
|
+ * @date 2026/8/17 16:57
|
|
|
+ */
|
|
|
+ private List<ImportContentExt> parseAndFillContent(MultipartFile file, String type) {
|
|
|
+ log.info("解析Excel内容并填充缺失的字段. type=[{}]", type);
|
|
|
+
|
|
|
+ if("11".equals(type)){
|
|
|
+ List<ExcelContent4PrivateSuperviseCar> excelContents2 = importIncomeService.parseImportExcel4PrivateCar(file);
|
|
|
+ return importIncomeService.fillExcelContent4All(excelContents2);
|
|
|
+ } if("12".equals(type)){
|
|
|
+ List<ExcelContent4PrivateSuperviseNoCar> excelContents3 = importIncomeService.parseImportExcel4PrivateNoCar(file);
|
|
|
+ return importIncomeService.fillExcelContent4All(excelContents3);
|
|
|
+// } if("20".equals(type)){
|
|
|
+// List<ExcelContent4Platform> excelContents = importIncomeService.parseImportExcel4Platform(file);
|
|
|
+// return importIncomeService.fillExcelContent4All(excelContents);
|
|
|
+ }else{
|
|
|
+ List<ExcelContent4Platform> excelContents = importIncomeService.parseImportExcel4Platform(file);
|
|
|
+ return importIncomeService.fillExcelContent4All(excelContents);
|
|
|
+// log.info("解析Excel内容并填充缺失的字段.类型不支持 type=[{}]", type);
|
|
|
+// return Collections.emptyList();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
/**
|