|
|
@@ -29,6 +29,8 @@ import com.jzg.commons.entity.Constant;
|
|
|
import com.jzg.commons.entity.finance.dto.*;
|
|
|
import com.jzg.commons.entity.finance.po.*;
|
|
|
import com.jzg.commons.entity.finance.vo.*;
|
|
|
+import com.jzg.commons.entity.finance.vo.importbatchmodify.InsPlyIncomeBatch;
|
|
|
+import com.jzg.commons.entity.finance.vo.importbatchmodify.InsPlyIncomeExportVo;
|
|
|
import com.jzg.commons.entity.finance.vo.importimcome.*;
|
|
|
import com.jzg.commons.entity.orders.po.InsOrderAdjust;
|
|
|
import com.jzg.commons.entity.orders.po.InsOrdersPolicy;
|
|
|
@@ -138,7 +140,8 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
private PtlAgreementMapper ptlAgreementMapper;
|
|
|
@Autowired
|
|
|
private SysUploadFilesMapper sysUploadFilesMapper;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private InsOrdersPolicyMapper insOrdersPolicyMapper;
|
|
|
@Autowired
|
|
|
private ExportBaseServiceImpl exportBaseService;
|
|
|
@Autowired
|
|
|
@@ -2235,188 +2238,179 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
*/
|
|
|
@Override
|
|
|
public String exportTemplateReceivableList() {
|
|
|
- List<InsPlyIncomeExportVo> emptyList = ListUtil.empty();
|
|
|
-
|
|
|
+ List<InsPlyIncomeExportVo> exportVos = new ArrayList<>();
|
|
|
+ InsPlyIncomeExportVo vo = new InsPlyIncomeExportVo();
|
|
|
+ // 这里是参考样例,方便业务进行修改
|
|
|
+ vo.setLicenseNo("样例:晋AK68H2");
|
|
|
+ vo.setJqPolicyNo("jq_2026年8月26日10:00:48");
|
|
|
+ vo.setSyPolicyNo("sy_2026年8月26日10:00:56");
|
|
|
+ vo.setJyPolicyNo("jy_2026年8月26日10:01:04");
|
|
|
+ vo.setJqSuperviseCostsProportion("10");
|
|
|
+ vo.setJqOtherCostsProportion("15");
|
|
|
+ vo.setSySuperviseCostsProportion("12");
|
|
|
+ vo.setSyOtherCostsProportion("11");
|
|
|
+ vo.setJySuperviseCostsProportion("13");
|
|
|
+ vo.setJyOtherCostsProportion("17");
|
|
|
+ exportVos.add(vo);
|
|
|
// 调用动态导出
|
|
|
return exportBaseService.upLoadFile(
|
|
|
InsPlyIncomeExportVo.class,
|
|
|
- emptyList,
|
|
|
- "私有协议应收-批量修改-导出模板-" + Instant.now()
|
|
|
+ exportVos,
|
|
|
+ "批量修改-导出模板-" + Instant.now()
|
|
|
);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 导入应收列表更新数据
|
|
|
- * <p>
|
|
|
- * 该方法用于从Excel文件中导入并更新平台协议的应收订单数据,包括以下处理逻辑:
|
|
|
- * 1. 解析Excel文件获取应收数据列表
|
|
|
- * 2. 获取所有保险公司信息
|
|
|
- * 3. 校验Excel内部订单号是否重复
|
|
|
- * 4. 遍历每条数据进行以下校验和处理:
|
|
|
- * - 检查必填字段是否为空
|
|
|
- * - 检查Excel内部订单号是否重复
|
|
|
- * - 查询数据库中订单号是否存在(只允许修改,不允许新增)
|
|
|
- * - 检查应收数据是否已结算(已结算的数据不允许修改)
|
|
|
- * - 查询订单是否存在
|
|
|
- * - 验证协议编码和类型是否匹配
|
|
|
- * - 构建InsPlyIncome对象并设置需要更新的字段
|
|
|
- * 5. 批量更新成功的记录到数据库
|
|
|
- * 6. 如果有失败数据,生成失败数据Excel文件并提供下载链接
|
|
|
- * 7. 返回导入结果(包含成功数、失败数、失败数据和下载链接)
|
|
|
- * </p>
|
|
|
- *
|
|
|
- * @param file Excel文件,包含平台协议应收数据,文件格式应符合ReceivableExportExcelVo的定义
|
|
|
- * @return ImportUpdateExcelResultVo 返回导入结果对象,包含:
|
|
|
- * - successNumber: 成功更新的记录数
|
|
|
- * - failedNumber: 失败的记录数
|
|
|
- * - failedData: 失败的数据列表,包含错误原因说明
|
|
|
- * - failFileUrl: 失败数据Excel文件的下载链接(如果有失败数据)
|
|
|
+ * 导入应收列表更新数据来更新比例数据
|
|
|
+ * @author jiakai,lipf
|
|
|
*/
|
|
|
@Override
|
|
|
public ImportUpdateExcelResultVo importReceivableListUpdate(MultipartFile file) {
|
|
|
String userName = baseController.getUserName();
|
|
|
- log.info("用户[{}]导入平台协议文件",userName);
|
|
|
+ log.info("用户[{}]导入平台/私有文件",userName);
|
|
|
ImportUpdateExcelResultVo importExcelResultVo = new ImportUpdateExcelResultVo();
|
|
|
- List<ReceivableExportExcelVo> receivableExportExcelVos = importReceivableExcel(file);
|
|
|
- if (CollUtil.isEmpty(receivableExportExcelVos)){
|
|
|
+ List<InsPlyIncomeExportVo> excelContents = importReceivableExcel(file);
|
|
|
+ log.info("用户[{}]导入平台/私有批量修改文件,一共导入[{}]条记录",userName, CollUtil.size(excelContents));
|
|
|
+ if (CollUtil.isEmpty(excelContents)){
|
|
|
throw new SystemException("数据不能为空,导入失败");
|
|
|
}
|
|
|
- AssertionUtils.isEmpty(receivableExportExcelVos, "数据处理失败,导入失败");
|
|
|
- // 获取保司名称
|
|
|
- HttpResult<List<EsmInsCompany>> listHttpResult = esmInsCompanyClient.liveCompanyList();
|
|
|
- AssertionUtils.isFail(listHttpResult.getCode() != 200, listHttpResult.getMsg());
|
|
|
+ AssertionUtils.isEmpty(excelContents, "数据处理失败,导入失败");
|
|
|
|
|
|
- int failedNumber = 0;
|
|
|
- List<ReceivableExportExcelVo> failedExcel = new ArrayList<>();
|
|
|
- // 只存储需要【修改】的数据
|
|
|
- List<InsPlyIncome> updateExcel = new ArrayList<>();
|
|
|
-
|
|
|
- // 校验Excel内部保单号重复
|
|
|
- Set<String> existPolicyNoSet = new HashSet<>();
|
|
|
- Set<String> repeatPolicyNoSet = new HashSet<>();
|
|
|
-
|
|
|
- for (ReceivableExportExcelVo vo : receivableExportExcelVos) {
|
|
|
- String orderNo = vo.getOrderNo();
|
|
|
- if (existPolicyNoSet.contains(orderNo)) {
|
|
|
- repeatPolicyNoSet.add(orderNo);
|
|
|
- } else {
|
|
|
- existPolicyNoSet.add(orderNo);
|
|
|
- }
|
|
|
+ List<InsPlyIncomeBatch> datas = this.fillExcelConte(excelContents);
|
|
|
+ HttpResult<String> validateRes = this.validateBatch(datas);
|
|
|
+ if(validateRes.isFail()){
|
|
|
+ log.error("批量导入修改。校验异常。 validateRes=[{}]", JSONUtil.toJsonStr(validateRes));
|
|
|
+ importExcelResultVo.setErrMsg(validateRes.getMsg());
|
|
|
+ return importExcelResultVo;
|
|
|
}
|
|
|
-
|
|
|
- // 处理数据
|
|
|
-
|
|
|
- for (ReceivableExportExcelVo vo : receivableExportExcelVos) {
|
|
|
- // 1. 空数据校验
|
|
|
- ImportResultVo resultVo = vo.checkEmpty();
|
|
|
- if (!resultVo.isSuccess()) {
|
|
|
- failedNumber++;
|
|
|
- vo.setErrorMessage(resultVo.getMessage().stream().collect(Collectors.joining(",")));
|
|
|
- failedExcel.add(vo);
|
|
|
- continue;
|
|
|
+ List<BatchModifyVo> batchModifyVos = datas.stream().map(action->{
|
|
|
+ BatchModifyVo batchModifyVo = new BatchModifyVo();
|
|
|
+ BeanUtils.copyProperties(action,batchModifyVo);
|
|
|
+ if(StrUtil.isNotEmpty(action.getOrderNo())){
|
|
|
+ batchModifyVo.getOrderNos().add(action.getOrderNo());
|
|
|
}
|
|
|
-
|
|
|
- // 2. Excel内部保单号重复
|
|
|
- if (repeatPolicyNoSet.contains(vo.getOrderNo())) {
|
|
|
- failedNumber++;
|
|
|
- vo.setErrorMessage("订单号重复");
|
|
|
- failedExcel.add(vo);
|
|
|
- continue;
|
|
|
+ if(StrUtil.isNotEmpty(action.getIncomeId())){
|
|
|
+ batchModifyVo.getIncomeIds().add(action.getIncomeId());
|
|
|
}
|
|
|
+ return batchModifyVo;
|
|
|
+ }).toList();
|
|
|
+ StringJoiner joiner = new StringJoiner(",","车牌号为","的记录批量修改异常");
|
|
|
+ for (BatchModifyVo batchModifyVo : batchModifyVos) {
|
|
|
+ boolean b = this.batchModify(batchModifyVo);
|
|
|
+ if(!b){
|
|
|
+ joiner.add(batchModifyVo.getLicenseNo());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(StrUtil.isNotEmpty(joiner.toString())){
|
|
|
+ String msg = String.format("批量导入修改,全部成功。成功修改[%d]条记录", CollUtil.size(excelContents));
|
|
|
+ log.info(msg);
|
|
|
+ importExcelResultVo.setErrMsg(msg);
|
|
|
+ return importExcelResultVo;
|
|
|
+ }
|
|
|
+ String errMsg = joiner.toString();
|
|
|
+ log.info("导入excel进行批量修改异常。 errMsg=[{}]",errMsg);
|
|
|
+ importExcelResultVo.setErrMsg(errMsg);
|
|
|
+ return importExcelResultVo;
|
|
|
+ }
|
|
|
|
|
|
- // 3. 查询数据库中是否已存在该订单号
|
|
|
- InsPlyIncome existIncome = baseMapper.selectOne(new LambdaQueryWrapper<InsPlyIncome>()
|
|
|
- .eq(InsPlyIncome::getOrderNo, vo.getOrderNo()));
|
|
|
-
|
|
|
- // 数据库不存在 → 直接失败
|
|
|
- if (Objects.isNull(existIncome)) {
|
|
|
- failedNumber++;
|
|
|
- vo.setErrorMessage("订单号不存在,不允许新增");
|
|
|
- failedExcel.add(vo);
|
|
|
+ /**
|
|
|
+ * 校验批量修改导入的数据是否正常,
|
|
|
+ *
|
|
|
+ * @param datas
|
|
|
+ * @author lipf
|
|
|
+ * @date 2026/8/26 10:51
|
|
|
+ */
|
|
|
+ private HttpResult<String> validateBatch(List<InsPlyIncomeBatch> datas) {
|
|
|
+ log.info("导入批量修改。 datas.size=[{}]", JSONUtil.toJsonStr(datas));
|
|
|
+ StringJoiner joiner = new StringJoiner(",","校验未通过: ","");
|
|
|
+ for (InsPlyIncomeBatch data : datas) {
|
|
|
+ if(StrUtil.isEmpty(data.getOrderNo())){
|
|
|
+ joiner.add(String.format("车牌号为[%s]的记录根据保单号没有找到订单信息", data.getLicenseNo()));
|
|
|
continue;
|
|
|
}
|
|
|
-
|
|
|
- // 数据库已存在 → 继续后续校验
|
|
|
- // 判断已开票 / 已结算
|
|
|
- String settlementFlag = "1";
|
|
|
- if (settlementFlag.equals(existIncome.getSuperviseSettlement()) || settlementFlag.equals(existIncome.getOtherSettlement())
|
|
|
- || settlementFlag.equals(existIncome.getJySuperviseSettlement()) || settlementFlag.equals(existIncome.getJyOtherSettlement())
|
|
|
- || settlementFlag.equals(existIncome.getPlatformSuperviseSettlement()) || settlementFlag.equals(existIncome.getPlatformOtherSettlement())) {
|
|
|
- failedNumber++;
|
|
|
- vo.setErrorMessage("应收数据已结算");
|
|
|
- failedExcel.add(vo);
|
|
|
+ InsPlyIncome insPlyIncome = data.getInsPlyIncome();
|
|
|
+ if(insPlyIncome == null){
|
|
|
+ joiner.add(String.format("车牌号为[%s]的记录根据订单号[%s]没有找到应收记录", data.getLicenseNo(), data.getOrderNo()));
|
|
|
continue;
|
|
|
}
|
|
|
+ }
|
|
|
+ List<ImportContentExt> exts = datas.stream().map(action->{
|
|
|
+ ImportContentExt ext = new ImportContentExt();
|
|
|
+ BeanUtils.copyProperties(action,ext);
|
|
|
+ return ext;
|
|
|
+ }).toList();
|
|
|
+ String s = this.validatePolicy(exts, "20");
|
|
|
+ if(StrUtil.isNotEmpty(s)){
|
|
|
+ joiner.add(s);
|
|
|
+ }
|
|
|
+ if(StrUtil.isNotEmpty(joiner.toString())){
|
|
|
+ return HttpResult.ok();
|
|
|
+ }
|
|
|
+ return HttpResult.error(joiner.toString());
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 为Excel中的数据填充其他必要的字段, 为后续的校验提前准备数据
|
|
|
+ *
|
|
|
+ * @param excelContents excel中导入的记录
|
|
|
+ * @author lipf
|
|
|
+ * @date 2026/8/26 10:46
|
|
|
+ */
|
|
|
+ private List<InsPlyIncomeBatch> fillExcelConte(List<InsPlyIncomeExportVo> excelContents) {
|
|
|
+ log.info("为[{}]条导入数据填充必要的字段", CollUtil.size(excelContents));
|
|
|
+ List<InsPlyIncomeBatch> res = new ArrayList<>();
|
|
|
+ for (InsPlyIncomeExportVo excelContent : excelContents) {
|
|
|
+ InsPlyIncomeBatch ext = new InsPlyIncomeBatch();
|
|
|
+ BeanUtils.copyProperties(excelContent,ext);
|
|
|
+ res.add(ext);
|
|
|
// 查询订单
|
|
|
- HttpResult<InsOrdersVo> insOrdersVoHttpResult = insOrdersClient.selectById(vo.getOrderNo());
|
|
|
- InsOrdersVo data = insOrdersVoHttpResult.getData();
|
|
|
- if (null == data){
|
|
|
- failedNumber++;
|
|
|
- vo.setErrorMessage("订单号不存在");
|
|
|
- failedExcel.add(vo);
|
|
|
+ String orderNO = "";
|
|
|
+ if(StrUtil.isNotEmpty(excelContent.getJqPolicyNo()) && StrUtil.isEmpty(orderNO)){
|
|
|
+ LambdaQueryWrapper<InsOrdersPolicy> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(InsOrdersPolicy::getJqPolicyNo,excelContent.getJqPolicyNo());
|
|
|
+ List<InsOrdersPolicy> insOrdersPolicies = insOrdersPolicyMapper.selectList(queryWrapper);
|
|
|
+ if(CollUtil.isNotEmpty(insOrdersPolicies)){
|
|
|
+ ext.setInsOrdersPolicy(insOrdersPolicies.get(0));
|
|
|
+ orderNO = insOrdersPolicies.get(0).getOrderNo();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(StrUtil.isNotEmpty(excelContent.getSyPolicyNo()) && StrUtil.isEmpty(orderNO)){
|
|
|
+ LambdaQueryWrapper<InsOrdersPolicy> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(InsOrdersPolicy::getSyPolicyNo,excelContent.getSyPolicyNo());
|
|
|
+ List<InsOrdersPolicy> insOrdersPolicies = insOrdersPolicyMapper.selectList(queryWrapper);
|
|
|
+ if(CollUtil.isNotEmpty(insOrdersPolicies)){
|
|
|
+ ext.setInsOrdersPolicy(insOrdersPolicies.get(0));
|
|
|
+ orderNO = insOrdersPolicies.get(0).getOrderNo();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(StrUtil.isNotEmpty(excelContent.getJyPolicyNo()) && StrUtil.isEmpty(orderNO)){
|
|
|
+ LambdaQueryWrapper<InsOrdersPolicy> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(InsOrdersPolicy::getJyPolicyNo,excelContent.getJyPolicyNo());
|
|
|
+ List<InsOrdersPolicy> insOrdersPolicies = insOrdersPolicyMapper.selectList(queryWrapper);
|
|
|
+ if(CollUtil.isNotEmpty(insOrdersPolicies)){
|
|
|
+ ext.setInsOrdersPolicy(insOrdersPolicies.get(0));
|
|
|
+ orderNO = insOrdersPolicies.get(0).getOrderNo();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(StrUtil.isEmpty(orderNO)){
|
|
|
continue;
|
|
|
}
|
|
|
-
|
|
|
- // 查询数据库中是否已存在该协议
|
|
|
- PtlAgreement ptlAgreement = ptlAgreementMapper.selectOne(new LambdaQueryWrapper<PtlAgreement>()
|
|
|
- .eq(PtlAgreement::getId, data.getAgreementId()));
|
|
|
-
|
|
|
- // 数据库不存在 → 直接失败
|
|
|
- if (Objects.isNull(ptlAgreement) || !ptlAgreement.getAgreementType().toString().equals(vo.getAgreementType())) {
|
|
|
- failedNumber++;
|
|
|
- vo.setErrorMessage("协议编码在协议中不存在");
|
|
|
- failedExcel.add(vo);
|
|
|
+ log.info("处理订单号是[{}]的订单",orderNO);
|
|
|
+ ext.setOrderNo(orderNO);
|
|
|
+
|
|
|
+ LambdaQueryWrapper<InsPlyIncome> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(InsPlyIncome::getOrderNo,orderNO);
|
|
|
+ List<InsPlyIncome> insPlyIncomes = insPlyIncomeMapper.selectList(wrapper);
|
|
|
+ if(CollUtil.isEmpty(insPlyIncomes)){
|
|
|
+ log.info("订单号为[{}]的数据没有进入应收",orderNO);
|
|
|
continue;
|
|
|
}
|
|
|
-
|
|
|
- // 封装修改数据
|
|
|
- InsPlyIncome insPlyIncome = new InsPlyIncome();
|
|
|
- insPlyIncome.setId(existIncome.getId());
|
|
|
- insPlyIncome.setLicenseNo(vo.getLicenseNo());
|
|
|
- insPlyIncome.setJqPolicyNo(vo.getJqPolicyNo());
|
|
|
- insPlyIncome.setJqSuperviseCostsProportion(vo.getJqSuperviseCostsProportion());
|
|
|
- insPlyIncome.setJqOtherCostsProportion(vo.getJqOtherCostsProportion());
|
|
|
- insPlyIncome.setSyPolicyNo(vo.getSyPolicyNo());
|
|
|
- insPlyIncome.setSySuperviseCostsProportion(vo.getSySuperviseCostsProportion());
|
|
|
- insPlyIncome.setSyOtherCostsProportion(vo.getSyOtherCostsProportion());
|
|
|
- insPlyIncome.setJyPolicyNo(vo.getJyPolicyNo());
|
|
|
- insPlyIncome.setJySuperviseCostsProportion(vo.getJySuperviseCostsProportion());
|
|
|
- insPlyIncome.setJyOtherCostsProportion(vo.getJyOtherCostsProportion());
|
|
|
- insPlyIncome.setContactPerson(vo.getDockingPerson());
|
|
|
- insPlyIncome.setContactPersonPhone(vo.getDockingPersonPhone());
|
|
|
- // 协议编号
|
|
|
- insPlyIncome.setAgreementId(ptlAgreement.getId());
|
|
|
- insPlyIncome.setAgreementName(ptlAgreement.getAgreementName());
|
|
|
- insPlyIncome.setAgreementType(ptlAgreement.getAgreementType().toString());
|
|
|
- insPlyIncome.setSystemCode(ptlAgreement.getSystemCode());
|
|
|
-
|
|
|
- // 加入修改列表
|
|
|
- updateExcel.add(insPlyIncome);
|
|
|
- }
|
|
|
-
|
|
|
- // 执行批量更新(只更新,不新增)
|
|
|
- if (CollUtil.isNotEmpty(updateExcel)) {
|
|
|
- baseMapper.updateById(updateExcel);
|
|
|
- }
|
|
|
-
|
|
|
- // ===================== 生成失败数据下载链接 =====================
|
|
|
- String failFileUrl = "";
|
|
|
- if (CollUtil.isNotEmpty(failedExcel)) {
|
|
|
- failFileUrl = exportBaseService.upLoadFile(
|
|
|
- ReceivableExportExcelVo.class,
|
|
|
- failedExcel,
|
|
|
- "平台协议应收-导入失败-" + Instant.now()
|
|
|
- );
|
|
|
+ InsPlyIncome insPlyIncome = insPlyIncomes.get(0);
|
|
|
+ ext.setIncomeId(insPlyIncome.getId());
|
|
|
+ ext.setInsPlyIncome(insPlyIncome);
|
|
|
}
|
|
|
|
|
|
- // 返回结果
|
|
|
- importExcelResultVo.setFailedData(failedExcel);
|
|
|
- importExcelResultVo.setFailFileUrl(failFileUrl);
|
|
|
- importExcelResultVo.setSuccessNumber(updateExcel.size());
|
|
|
- importExcelResultVo.setFailedNumber(failedNumber);
|
|
|
-
|
|
|
- return importExcelResultVo;
|
|
|
+ return res;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -3134,10 +3128,10 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<ReceivableExportExcelVo> importReceivableExcel(MultipartFile file) {
|
|
|
+ public List<InsPlyIncomeExportVo> importReceivableExcel(MultipartFile file) {
|
|
|
ReceivbleExcelListener listener = new ReceivbleExcelListener();
|
|
|
try (InputStream inputStream = file.getInputStream()) {
|
|
|
- EasyExcel.read(inputStream, ReceivableExportExcelVo.class, listener)
|
|
|
+ EasyExcel.read(inputStream, InsPlyIncomeExportVo.class, listener)
|
|
|
.sheet()
|
|
|
.doRead();
|
|
|
return listener.getDataList();
|
|
|
@@ -3147,9 +3141,6 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
@Override
|
|
|
public List<JyExcelVo> importJyExcel(MultipartFile file) {
|
|
|
JyExcelListener listener = new JyExcelListener();
|
|
|
@@ -3462,151 +3453,151 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
* - failedData: 失败的数据列表,包含错误原因说明
|
|
|
* - failFileUrl: 失败数据Excel文件的下载链接(如果有失败数据)
|
|
|
*/
|
|
|
- @Override
|
|
|
- public ImportUpdateExcelResultVo importPlatFormReceivable(MultipartFile file) {
|
|
|
- String userName = baseController.getUserName();
|
|
|
- log.info("用户[{}]导入平台协议文件",userName);
|
|
|
- ImportUpdateExcelResultVo importExcelResultVo = new ImportUpdateExcelResultVo();
|
|
|
- List<ReceivableExportExcelVo> receivableExportExcelVos = importReceivableExcel(file);
|
|
|
- if (CollUtil.isEmpty(receivableExportExcelVos)){
|
|
|
- throw new SystemException("数据不能为空,导入失败");
|
|
|
- }
|
|
|
- AssertionUtils.isEmpty(receivableExportExcelVos, "数据处理失败,导入失败");
|
|
|
- // 获取保司名称
|
|
|
- HttpResult<List<EsmInsCompany>> listHttpResult = esmInsCompanyClient.liveCompanyList();
|
|
|
- AssertionUtils.isFail(listHttpResult.getCode() != 200, listHttpResult.getMsg());
|
|
|
-
|
|
|
- int failedNumber = 0;
|
|
|
- List<ReceivableExportExcelVo> failedExcel = new ArrayList<>();
|
|
|
- // 只存储需要【修改】的数据
|
|
|
- List<InsPlyIncome> updateExcel = new ArrayList<>();
|
|
|
-
|
|
|
- // 校验Excel内部保单号重复
|
|
|
- Set<String> existPolicyNoSet = new HashSet<>();
|
|
|
- Set<String> repeatPolicyNoSet = new HashSet<>();
|
|
|
-
|
|
|
- for (ReceivableExportExcelVo vo : receivableExportExcelVos) {
|
|
|
- String policyNo = vo.getJqPolicyNo();
|
|
|
- if (existPolicyNoSet.contains(policyNo)) {
|
|
|
- repeatPolicyNoSet.add(policyNo);
|
|
|
- } else {
|
|
|
- existPolicyNoSet.add(policyNo);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 处理数据
|
|
|
- for (ReceivableExportExcelVo vo : receivableExportExcelVos) {
|
|
|
- // 1. 空数据校验
|
|
|
- ImportResultVo resultVo = vo.checkEmpty();
|
|
|
- if (!resultVo.isSuccess()) {
|
|
|
- failedNumber++;
|
|
|
- vo.setErrorMessage(resultVo.convert2Str());
|
|
|
- failedExcel.add(vo);
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- // 2. Excel内部保单号重复
|
|
|
- if (repeatPolicyNoSet.contains(vo.getJqPolicyNo())) {
|
|
|
- failedNumber++;
|
|
|
- vo.setErrorMessage("保单号重复");
|
|
|
- failedExcel.add(vo);
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- // 查询订单
|
|
|
- HttpResult<InsOrdersVo> insOrdersVoHttpResult = insOrdersClient.selectById(vo.getOrderNo());
|
|
|
- InsOrdersVo data = insOrdersVoHttpResult.getData();
|
|
|
- if (null == data){
|
|
|
- failedNumber++;
|
|
|
- vo.setErrorMessage("订单号不存在");
|
|
|
- failedExcel.add(vo);
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- // 查询数据库中是否已存在该协议
|
|
|
- PtlAgreement ptlAgreement = ptlAgreementMapper.selectOne(new LambdaQueryWrapper<PtlAgreement>()
|
|
|
- .eq(PtlAgreement::getId, data.getAgreementId()));
|
|
|
-
|
|
|
- // 数据库不存在 → 直接失败
|
|
|
- if (Objects.isNull(ptlAgreement) || !ptlAgreement.getAgreementType().toString().equals(vo.getAgreementType())) {
|
|
|
- failedNumber++;
|
|
|
- vo.setErrorMessage("协议编码在协议中不存在");
|
|
|
- failedExcel.add(vo);
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- // 3. 查询数据库中是否已存在该保单号
|
|
|
- InsPlyIncome existIncome = baseMapper.selectOne(new LambdaQueryWrapper<InsPlyIncome>()
|
|
|
- .eq(InsPlyIncome::getJqPolicyNo, vo.getJqPolicyNo()));
|
|
|
-
|
|
|
- // 数据库不存在 → 直接失败
|
|
|
- if (Objects.isNull(existIncome)) {
|
|
|
- failedNumber++;
|
|
|
- vo.setErrorMessage("保单号不存在,不允许新增");
|
|
|
- failedExcel.add(vo);
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- // 数据库已存在 → 继续后续校验
|
|
|
- // 判断已开票 / 已结算
|
|
|
- String settlementFlag = "1";
|
|
|
- if (settlementFlag.equals(existIncome.getSuperviseSettlement()) || settlementFlag.equals(existIncome.getOtherSettlement())
|
|
|
- || settlementFlag.equals(existIncome.getJySuperviseSettlement()) || settlementFlag.equals(existIncome.getJyOtherSettlement())
|
|
|
- || settlementFlag.equals(existIncome.getPlatformSuperviseSettlement()) || settlementFlag.equals(existIncome.getPlatformOtherSettlement())) {
|
|
|
- failedNumber++;
|
|
|
- vo.setErrorMessage("应收数据已结算");
|
|
|
- failedExcel.add(vo);
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- // 封装修改数据
|
|
|
- InsPlyIncome insPlyIncome = new InsPlyIncome();
|
|
|
- insPlyIncome.setId(existIncome.getId());
|
|
|
- insPlyIncome.setLicenseNo(vo.getLicenseNo());
|
|
|
- insPlyIncome.setJqPolicyNo(vo.getJqPolicyNo());
|
|
|
- insPlyIncome.setJqSuperviseCostsProportion(vo.getJqSuperviseCostsProportion());
|
|
|
- insPlyIncome.setJqOtherCostsProportion(vo.getJqOtherCostsProportion());
|
|
|
- insPlyIncome.setSyPolicyNo(vo.getSyPolicyNo());
|
|
|
- insPlyIncome.setSySuperviseCostsProportion(vo.getSySuperviseCostsProportion());
|
|
|
- insPlyIncome.setSyOtherCostsProportion(vo.getSyOtherCostsProportion());
|
|
|
- insPlyIncome.setJyPolicyNo(vo.getJyPolicyNo());
|
|
|
- insPlyIncome.setJySuperviseCostsProportion(vo.getJySuperviseCostsProportion());
|
|
|
- insPlyIncome.setJyOtherCostsProportion(vo.getJyOtherCostsProportion());
|
|
|
- insPlyIncome.setContactPerson(vo.getDockingPerson());
|
|
|
- insPlyIncome.setContactPersonPhone(vo.getDockingPersonPhone());
|
|
|
- // 协议编号
|
|
|
- insPlyIncome.setAgreementId(ptlAgreement.getId());
|
|
|
- insPlyIncome.setAgreementName(ptlAgreement.getAgreementName());
|
|
|
- insPlyIncome.setAgreementType(ptlAgreement.getAgreementType().toString());
|
|
|
- insPlyIncome.setSystemCode(ptlAgreement.getSystemCode());
|
|
|
-
|
|
|
- // 加入修改列表
|
|
|
- updateExcel.add(insPlyIncome);
|
|
|
- }
|
|
|
-
|
|
|
- // 执行批量更新(只更新,不新增)
|
|
|
- if (CollUtil.isNotEmpty(updateExcel)) {
|
|
|
- baseMapper.updateById(updateExcel);
|
|
|
- }
|
|
|
-
|
|
|
- // ===================== 生成失败数据下载链接 =====================
|
|
|
- String failFileUrl = "";
|
|
|
- if (CollUtil.isNotEmpty(failedExcel)) {
|
|
|
- failFileUrl = exportBaseService.upLoadFile(
|
|
|
- ReceivableExportExcelVo.class,
|
|
|
- failedExcel,
|
|
|
- "平台协议应收-导入失败-" + Instant.now()
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- // 返回结果
|
|
|
- importExcelResultVo.setFailedData(failedExcel);
|
|
|
- importExcelResultVo.setFailFileUrl(failFileUrl);
|
|
|
- importExcelResultVo.setSuccessNumber(updateExcel.size());
|
|
|
- importExcelResultVo.setFailedNumber(failedNumber);
|
|
|
-
|
|
|
- return importExcelResultVo;
|
|
|
- }
|
|
|
+// @Override
|
|
|
+// public ImportUpdateExcelResultVo importPlatFormReceivable(MultipartFile file) {
|
|
|
+// String userName = baseController.getUserName();
|
|
|
+// log.info("用户[{}]导入平台协议文件",userName);
|
|
|
+// ImportUpdateExcelResultVo importExcelResultVo = new ImportUpdateExcelResultVo();
|
|
|
+// List<ReceivableExportExcelVo> receivableExportExcelVos = importReceivableExcel(file);
|
|
|
+// if (CollUtil.isEmpty(receivableExportExcelVos)){
|
|
|
+// throw new SystemException("数据不能为空,导入失败");
|
|
|
+// }
|
|
|
+// AssertionUtils.isEmpty(receivableExportExcelVos, "数据处理失败,导入失败");
|
|
|
+// // 获取保司名称
|
|
|
+// HttpResult<List<EsmInsCompany>> listHttpResult = esmInsCompanyClient.liveCompanyList();
|
|
|
+// AssertionUtils.isFail(listHttpResult.getCode() != 200, listHttpResult.getMsg());
|
|
|
+//
|
|
|
+// int failedNumber = 0;
|
|
|
+// List<ReceivableExportExcelVo> failedExcel = new ArrayList<>();
|
|
|
+// // 只存储需要【修改】的数据
|
|
|
+// List<InsPlyIncome> updateExcel = new ArrayList<>();
|
|
|
+//
|
|
|
+// // 校验Excel内部保单号重复
|
|
|
+// Set<String> existPolicyNoSet = new HashSet<>();
|
|
|
+// Set<String> repeatPolicyNoSet = new HashSet<>();
|
|
|
+//
|
|
|
+// for (ReceivableExportExcelVo vo : receivableExportExcelVos) {
|
|
|
+// String policyNo = vo.getJqPolicyNo();
|
|
|
+// if (existPolicyNoSet.contains(policyNo)) {
|
|
|
+// repeatPolicyNoSet.add(policyNo);
|
|
|
+// } else {
|
|
|
+// existPolicyNoSet.add(policyNo);
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 处理数据
|
|
|
+// for (ReceivableExportExcelVo vo : receivableExportExcelVos) {
|
|
|
+// // 1. 空数据校验
|
|
|
+// ImportResultVo resultVo = vo.checkEmpty();
|
|
|
+// if (!resultVo.isSuccess()) {
|
|
|
+// failedNumber++;
|
|
|
+// vo.setErrorMessage(resultVo.convert2Str());
|
|
|
+// failedExcel.add(vo);
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 2. Excel内部保单号重复
|
|
|
+// if (repeatPolicyNoSet.contains(vo.getJqPolicyNo())) {
|
|
|
+// failedNumber++;
|
|
|
+// vo.setErrorMessage("保单号重复");
|
|
|
+// failedExcel.add(vo);
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 查询订单
|
|
|
+// HttpResult<InsOrdersVo> insOrdersVoHttpResult = insOrdersClient.selectById(vo.getOrderNo());
|
|
|
+// InsOrdersVo data = insOrdersVoHttpResult.getData();
|
|
|
+// if (null == data){
|
|
|
+// failedNumber++;
|
|
|
+// vo.setErrorMessage("订单号不存在");
|
|
|
+// failedExcel.add(vo);
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 查询数据库中是否已存在该协议
|
|
|
+// PtlAgreement ptlAgreement = ptlAgreementMapper.selectOne(new LambdaQueryWrapper<PtlAgreement>()
|
|
|
+// .eq(PtlAgreement::getId, data.getAgreementId()));
|
|
|
+//
|
|
|
+// // 数据库不存在 → 直接失败
|
|
|
+// if (Objects.isNull(ptlAgreement) || !ptlAgreement.getAgreementType().toString().equals(vo.getAgreementType())) {
|
|
|
+// failedNumber++;
|
|
|
+// vo.setErrorMessage("协议编码在协议中不存在");
|
|
|
+// failedExcel.add(vo);
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 3. 查询数据库中是否已存在该保单号
|
|
|
+// InsPlyIncome existIncome = baseMapper.selectOne(new LambdaQueryWrapper<InsPlyIncome>()
|
|
|
+// .eq(InsPlyIncome::getJqPolicyNo, vo.getJqPolicyNo()));
|
|
|
+//
|
|
|
+// // 数据库不存在 → 直接失败
|
|
|
+// if (Objects.isNull(existIncome)) {
|
|
|
+// failedNumber++;
|
|
|
+// vo.setErrorMessage("保单号不存在,不允许新增");
|
|
|
+// failedExcel.add(vo);
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 数据库已存在 → 继续后续校验
|
|
|
+// // 判断已开票 / 已结算
|
|
|
+// String settlementFlag = "1";
|
|
|
+// if (settlementFlag.equals(existIncome.getSuperviseSettlement()) || settlementFlag.equals(existIncome.getOtherSettlement())
|
|
|
+// || settlementFlag.equals(existIncome.getJySuperviseSettlement()) || settlementFlag.equals(existIncome.getJyOtherSettlement())
|
|
|
+// || settlementFlag.equals(existIncome.getPlatformSuperviseSettlement()) || settlementFlag.equals(existIncome.getPlatformOtherSettlement())) {
|
|
|
+// failedNumber++;
|
|
|
+// vo.setErrorMessage("应收数据已结算");
|
|
|
+// failedExcel.add(vo);
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 封装修改数据
|
|
|
+// InsPlyIncome insPlyIncome = new InsPlyIncome();
|
|
|
+// insPlyIncome.setId(existIncome.getId());
|
|
|
+// insPlyIncome.setLicenseNo(vo.getLicenseNo());
|
|
|
+// insPlyIncome.setJqPolicyNo(vo.getJqPolicyNo());
|
|
|
+// insPlyIncome.setJqSuperviseCostsProportion(vo.getJqSuperviseCostsProportion());
|
|
|
+// insPlyIncome.setJqOtherCostsProportion(vo.getJqOtherCostsProportion());
|
|
|
+// insPlyIncome.setSyPolicyNo(vo.getSyPolicyNo());
|
|
|
+// insPlyIncome.setSySuperviseCostsProportion(vo.getSySuperviseCostsProportion());
|
|
|
+// insPlyIncome.setSyOtherCostsProportion(vo.getSyOtherCostsProportion());
|
|
|
+// insPlyIncome.setJyPolicyNo(vo.getJyPolicyNo());
|
|
|
+// insPlyIncome.setJySuperviseCostsProportion(vo.getJySuperviseCostsProportion());
|
|
|
+// insPlyIncome.setJyOtherCostsProportion(vo.getJyOtherCostsProportion());
|
|
|
+// insPlyIncome.setContactPerson(vo.getDockingPerson());
|
|
|
+// insPlyIncome.setContactPersonPhone(vo.getDockingPersonPhone());
|
|
|
+// // 协议编号
|
|
|
+// insPlyIncome.setAgreementId(ptlAgreement.getId());
|
|
|
+// insPlyIncome.setAgreementName(ptlAgreement.getAgreementName());
|
|
|
+// insPlyIncome.setAgreementType(ptlAgreement.getAgreementType().toString());
|
|
|
+// insPlyIncome.setSystemCode(ptlAgreement.getSystemCode());
|
|
|
+//
|
|
|
+// // 加入修改列表
|
|
|
+// updateExcel.add(insPlyIncome);
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 执行批量更新(只更新,不新增)
|
|
|
+// if (CollUtil.isNotEmpty(updateExcel)) {
|
|
|
+// baseMapper.updateById(updateExcel);
|
|
|
+// }
|
|
|
+//
|
|
|
+// // ===================== 生成失败数据下载链接 =====================
|
|
|
+// String failFileUrl = "";
|
|
|
+// if (CollUtil.isNotEmpty(failedExcel)) {
|
|
|
+// failFileUrl = exportBaseService.upLoadFile(
|
|
|
+// ReceivableExportExcelVo.class,
|
|
|
+// failedExcel,
|
|
|
+// "平台协议应收-导入失败-" + Instant.now()
|
|
|
+// );
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 返回结果
|
|
|
+// importExcelResultVo.setFailedData(failedExcel);
|
|
|
+// importExcelResultVo.setFailFileUrl(failFileUrl);
|
|
|
+// importExcelResultVo.setSuccessNumber(updateExcel.size());
|
|
|
+// importExcelResultVo.setFailedNumber(failedNumber);
|
|
|
+//
|
|
|
+// return importExcelResultVo;
|
|
|
+// }
|
|
|
|
|
|
/**
|
|
|
* 导入驾意险数据
|
|
|
@@ -5481,23 +5472,6 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
EasyExcelUtils.exportForWeb(ServletUtils.getResponse(), ExportSuperviseSettlementExcelDto.class, list, "车险手续费结算明细");
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 导出平台协议Excel
|
|
|
- *
|
|
|
- * @return
|
|
|
- */
|
|
|
- @Override
|
|
|
- public String exportTemplatePlatFormReceivable() {
|
|
|
- List<ReceivableExportExcelDto> emptyList = ListUtil.empty();
|
|
|
-
|
|
|
- // 调用动态导出
|
|
|
- return exportBaseService.upLoadFile(
|
|
|
- ReceivableExportExcelDto.class,
|
|
|
- emptyList,
|
|
|
- "平台协议应收-批量导入-导出模板-" + Instant.now()
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 导出平台协议Excel
|
|
|
*
|