|
@@ -2541,41 +2541,136 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
public ImportUpdateExcelResultVo importPlatformReceivableInvoice(MultipartFile file, String type) {
|
|
public ImportUpdateExcelResultVo importPlatformReceivableInvoice(MultipartFile file, String type) {
|
|
|
|
|
+ ImportUpdateExcelResultVo resultVo = new ImportUpdateExcelResultVo();
|
|
|
String userName = baseController.getUserName();
|
|
String userName = baseController.getUserName();
|
|
|
- log.info("用户[{}]导入平台应收文件",userName);
|
|
|
|
|
|
|
+ log.info("用户[{}]导入平台应收文件。type=[{}]",userName,type);
|
|
|
List<ImportContentExt> datas = this.parseAndFillContent(file, type);
|
|
List<ImportContentExt> datas = this.parseAndFillContent(file, type);
|
|
|
- // 只存储需要【修改】的数据
|
|
|
|
|
- List<InsPlyIncome> updateExcel = new ArrayList<>();
|
|
|
|
|
- List<InsPlyIncome> insertExcel = new ArrayList<>();
|
|
|
|
|
- List<ImportContentExt> failedExcel = new ArrayList<>();
|
|
|
|
|
-
|
|
|
|
|
- // 校验Excel内部保单号重复
|
|
|
|
|
- Set<String> existPolicyNoSet = new HashSet<>();
|
|
|
|
|
- Set<String> repeatPolicyNoSet = new HashSet<>();
|
|
|
|
|
- Set<String> existCompanyIdSet = new HashSet<>();
|
|
|
|
|
|
|
+ String errMsg = this.validateData(datas,type);
|
|
|
|
|
+ if(StrUtil.isNotEmpty(errMsg)){
|
|
|
|
|
+ log.error("数据校验异常. errMsg=[{}]", errMsg);
|
|
|
|
|
+ resultVo.setErrMsg(errMsg);
|
|
|
|
|
+ return resultVo;
|
|
|
|
|
+ }
|
|
|
|
|
+ resultVo.setSuccessNumber(CollUtil.size(datas));
|
|
|
|
|
+ List<String> orderNos = datas.stream().map(ImportContentExt::getOrderNo).toList();
|
|
|
|
|
+ resultVo.setOrderNos(orderNos);
|
|
|
|
|
+ return resultVo;
|
|
|
|
|
+//
|
|
|
|
|
+// // 只存储需要【修改】的数据
|
|
|
|
|
+// List<InsPlyIncome> updateExcel = new ArrayList<>();
|
|
|
|
|
+// List<InsPlyIncome> insertExcel = new ArrayList<>();
|
|
|
|
|
+// List<ImportContentExt> failedExcel = 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.getParternerCompanyId());
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// // 导入只能一个保司
|
|
|
|
|
+// if (existCompanyIdSet.size() > 1) {
|
|
|
|
|
+// log.info("导入数据不能包含多个保险公司. existCompanyIdSet=[{}]", JSONUtil.toJsonStr(existCompanyIdSet));
|
|
|
|
|
+// throw new SystemException("导入数据不能包含多个保险公司");
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// // 执行批量更新
|
|
|
|
|
+// ImportUpdateExcelResultVo importExcelResultVo = importIncomeService.getDataManipulationResult(updateExcel, insertExcel,failedExcel);
|
|
|
|
|
+// log.info("平台应收导入结果:importExcelResultVo=[{}]", JSONUtil.toJsonStr(importExcelResultVo));
|
|
|
|
|
+//
|
|
|
|
|
+// return importExcelResultVo;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- for (ImportContentExt vo : datas) {
|
|
|
|
|
- String policyNo = vo.getJqPolicyNo();
|
|
|
|
|
- if (existPolicyNoSet.contains(policyNo)) {
|
|
|
|
|
- repeatPolicyNoSet.add(policyNo);
|
|
|
|
|
- } else {
|
|
|
|
|
- existPolicyNoSet.add(policyNo);
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 校验数据的合法性
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param datas excel导入数据初步处理后的数据
|
|
|
|
|
+ * @param type 数据类型
|
|
|
|
|
+ * @author lipf
|
|
|
|
|
+ * @date 2026/8/19 15:34
|
|
|
|
|
+ */
|
|
|
|
|
+ private String validateData(List<ImportContentExt> datas, String type) {
|
|
|
|
|
+ StringBuilder errrMsg = new StringBuilder();
|
|
|
|
|
+ List<ImportContentExt> licenseNos = datas.stream().filter(action -> StrUtil.isEmpty(action.getLicenseNo())).toList();
|
|
|
|
|
+ if(CollUtil.isNotEmpty(licenseNos)){
|
|
|
|
|
+ errrMsg.append("存在记录车牌号为空,请检查后重新导入");
|
|
|
|
|
+ return errrMsg.toString();
|
|
|
|
|
+ }
|
|
|
|
|
+ String orderAbanda = datas.stream().filter(action -> StrUtil.isEmpty(action.getOrderNo()))
|
|
|
|
|
+ .map(ImportContentExt::getLicenseNo).collect(Collectors.joining(""));
|
|
|
|
|
+ if(StrUtil.isNotEmpty(orderAbanda)){
|
|
|
|
|
+ errrMsg.append("车牌号为").append(orderAbanda).append("的订单不存在. ");
|
|
|
|
|
+ }
|
|
|
|
|
+ String incomeAbanda = datas.stream().filter(action -> StrUtil.isNotEmpty(action.getOrderNo())).filter(action-> action.getInsPlyIncome() == null)
|
|
|
|
|
+ .map(ImportContentExt::getLicenseNo).collect(Collectors.joining(","));
|
|
|
|
|
+ if(StrUtil.isNotEmpty(incomeAbanda)){
|
|
|
|
|
+ errrMsg.append("车牌号为").append(incomeAbanda).append("的应收数据不存在. ");
|
|
|
|
|
+ }
|
|
|
|
|
+ if("20".equals(type)){
|
|
|
|
|
+// List<String> contactPersons = datas.stream().map(ImportContentExt::getContactPerson).filter(Objects::nonNull).distinct().toList();
|
|
|
|
|
+// if(CollUtil.size(contactPersons) > 1){
|
|
|
|
|
+// errrMsg.append("该批数据的对接人不唯一");
|
|
|
|
|
+// }else if(CollUtil.isEmpty(contactPersons)){
|
|
|
|
|
+// errrMsg.append("该批数据的对接人为空");
|
|
|
|
|
+// }
|
|
|
|
|
+ }else if("11".equals(type) || "12".equals(type)){
|
|
|
|
|
+ List<String> parternerCompanyIds = datas.stream().map(ImportContentExt::getParternerCompanyId).filter(Objects::nonNull).distinct().toList();
|
|
|
|
|
+ if(CollUtil.size(parternerCompanyIds) > 1){
|
|
|
|
|
+ errrMsg.append("该批数据的保险机构不唯一. ");
|
|
|
|
|
+ }else if(CollUtil.isEmpty(parternerCompanyIds)){
|
|
|
|
|
+ errrMsg.append("该批数据的保险机构为空. ");
|
|
|
}
|
|
}
|
|
|
- existCompanyIdSet.add(vo.getParternerCompanyId());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 导入只能一个保司
|
|
|
|
|
- if (existCompanyIdSet.size() > 1) {
|
|
|
|
|
- log.info("导入数据不能包含多个保险公司. existCompanyIdSet=[{}]", JSONUtil.toJsonStr(existCompanyIdSet));
|
|
|
|
|
- throw new SystemException("导入数据不能包含多个保险公司");
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ for (ImportContentExt data : datas) {
|
|
|
|
|
+ boolean all = false;
|
|
|
|
|
+ boolean jq = false;
|
|
|
|
|
+ boolean sy = false;
|
|
|
|
|
+ boolean jy = false;
|
|
|
|
|
+ InsPlyIncome insPlyIncome = data.getInsPlyIncome();
|
|
|
|
|
+ String jqadd = BigDecimalUtil.add(insPlyIncome.getJqSuperviseCostsProportion(), insPlyIncome.getJqOtherCostsProportion());
|
|
|
|
|
+ BigDecimal jqsubtract = BigDecimalUtil.subtract(new BigDecimal(jqadd), new BigDecimal(data.getJqInletRatio()));
|
|
|
|
|
+ if(BigDecimal.ZERO.compareTo(jqsubtract) != 0){
|
|
|
|
|
+ all = true;
|
|
|
|
|
+ jq = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ String syadd = BigDecimalUtil.add(insPlyIncome.getSySuperviseCostsProportion(), insPlyIncome.getSyOtherCostsProportion());
|
|
|
|
|
+ BigDecimal sysubtract = BigDecimalUtil.subtract(new BigDecimal(syadd), new BigDecimal(data.getSyInletRatio()));
|
|
|
|
|
+ if(BigDecimal.ZERO.compareTo(sysubtract) != 0){
|
|
|
|
|
+ all = true;
|
|
|
|
|
+ sy = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ String jyadd = BigDecimalUtil.add(insPlyIncome.getJySuperviseCostsProportion(), insPlyIncome.getJyOtherCostsProportion());
|
|
|
|
|
+ BigDecimal jysubtract = BigDecimalUtil.subtract(new BigDecimal(jyadd), new BigDecimal(data.getJyInletRatio()));
|
|
|
|
|
+ if(BigDecimal.ZERO.compareTo(jysubtract) != 0){
|
|
|
|
|
+ all = true;
|
|
|
|
|
+ jy = true;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- // 执行批量更新
|
|
|
|
|
- ImportUpdateExcelResultVo importExcelResultVo = importIncomeService.getDataManipulationResult(updateExcel, insertExcel,failedExcel);
|
|
|
|
|
- log.info("平台应收导入结果:importExcelResultVo=[{}]", JSONUtil.toJsonStr(importExcelResultVo));
|
|
|
|
|
|
|
+ if(all){
|
|
|
|
|
+ errrMsg.append("车牌号为").append(data.getLicenseNo()).append("的导入记录中,");
|
|
|
|
|
+ if(jq){
|
|
|
|
|
+ errrMsg.append("交强险入口比例异常. 应收数据的交强险入口比例是[").append(jqadd).append("].excel维护的交强险入口比例是[").append(data.getJqInletRatio()).append("].");
|
|
|
|
|
+ }
|
|
|
|
|
+ if(sy){
|
|
|
|
|
+ errrMsg.append("商业险入口比例异常.应收数据的商业险入口比例是[").append(syadd).append("].excel维护的商业险入口比例是[").append(data.getSyInletRatio()).append("].");
|
|
|
|
|
+ }
|
|
|
|
|
+ if(jy){
|
|
|
|
|
+ errrMsg.append("驾意险入口比例异常.应收数据的驾意险入口比例是[").append(jyadd).append("].excel维护的驾意险入口比例是[").append(data.getJyInletRatio()).append("].");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- return importExcelResultVo;
|
|
|
|
|
|
|
+ return errrMsg.toString();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|