فهرست منبع

Merge branch 'master' of http://39.101.143.165:8090/785834757/jzg

更新代码
lipf 4 ماه پیش
والد
کامیت
097ffc6267

+ 33 - 0
commons/src/main/java/com/jzg/commons/entity/finance/vo/ImportUpdateExcelResultVo.java

@@ -0,0 +1,33 @@
+package com.jzg.commons.entity.finance.vo;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * excel 导入结果的Vo-只修改已存在的数据,不新增
+ * 修改失败的数据会生成一个Excel的下载链接,返回给页面,页面可以下载
+ */
+@Data
+public class ImportUpdateExcelResultVo {
+
+    /**
+     * 成功数量
+     */
+    private Integer successNumber;
+
+    /**
+     * 失败数量
+     */
+    private Integer failedNumber;
+
+    /**
+     * 失败数据  修复这里!
+     */
+    private List<ReceivableExportExcelVo> failedData;
+
+    /**
+     * 新增:失败文件下载链接
+     */
+    private String failFileUrl;
+}

+ 1 - 1
tenant/organization/src/main/java/com/jzg/organization/controller/ReceivableController.java

@@ -230,7 +230,7 @@ public class ReceivableController {
     @PostMapping("/importPlatFormReceivable")
     @Operation(summary = "导入平台协议")
     public HttpResult importPlatFormReceivable(@RequestParam("file") MultipartFile file){
-        ImportExcelResultVo importExcelResultVo = receivableService.importPlatFormReceivable(file);
+        ImportUpdateExcelResultVo importExcelResultVo = receivableService.importPlatFormReceivable(file);
         return HttpResult.ok(importExcelResultVo);
     }
 

+ 1 - 1
tenant/organization/src/main/java/com/jzg/organization/service/ReceivableService.java

@@ -154,7 +154,7 @@ public interface ReceivableService extends IService<InsPlyIncome> {
      * @param file
      * @return
      */
-    ImportExcelResultVo importPlatFormReceivable(MultipartFile file);
+    ImportUpdateExcelResultVo importPlatFormReceivable(MultipartFile file);
 
     /**
      * 批量修改

+ 66 - 30
tenant/organization/src/main/java/com/jzg/organization/service/impl/ReceivableServiceImpl.java

@@ -1,5 +1,6 @@
 package com.jzg.organization.service.impl;
 
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.collection.ListUtil;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.util.ObjectUtil;
@@ -639,8 +640,8 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
     }
 
     @Override
-    public ImportExcelResultVo importPlatFormReceivable(MultipartFile file) {
-        ImportExcelResultVo importExcelResultVo = new ImportExcelResultVo();
+    public ImportUpdateExcelResultVo importPlatFormReceivable(MultipartFile file) {
+        ImportUpdateExcelResultVo importExcelResultVo = new ImportUpdateExcelResultVo();
 
         List<ReceivableExportExcelVo> receivableExportExcelVos = importReceivableExcel(file);
         AssertionUtils.isEmpty(receivableExportExcelVos, "数据处理失败,导入失败");
@@ -650,11 +651,26 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
         AssertionUtils.isFail(listHttpResult.getCode() != 200, listHttpResult.getMsg());
 
         int failedNumber = 0;
-        List<Object> failedExcel = new ArrayList<>();
-        List<InsPlyIncome> successExcel = new ArrayList<>();
+        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++;
@@ -663,35 +679,39 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
                 continue;
             }
 
-            // 检测是否有重复的保单号
-            InsPlyIncome checkInsPlyIncome = baseMapper.selectOne(new LambdaQueryWrapper<InsPlyIncome>()
-                    .eq(InsPlyIncome::getJqPolicyNo, vo.getJqPolicyNo()));
-            if (!Objects.isNull(checkInsPlyIncome)) {
+            // 2. Excel内部保单号重复
+            if (repeatPolicyNoSet.contains(vo.getJqPolicyNo())) {
                 failedNumber++;
-                vo.setErrorMessage("车险保单号重复");
+                vo.setErrorMessage("保单号重复");
                 failedExcel.add(vo);
                 continue;
             }
 
-            // 判断应收数据是否已开票 / 已结算
-            InsPlyIncome checkInsPlyIncomeByOrderNo = baseMapper.selectOne(new LambdaQueryWrapper<InsPlyIncome>()
-                    .eq(InsPlyIncome::getOrderNo, vo.getOrderNo()));
-            if (ObjectUtil.isNotNull(checkInsPlyIncomeByOrderNo)){
-                if ("1".equals(checkInsPlyIncomeByOrderNo.getSuperviseSettlement()) || "1".equals(checkInsPlyIncomeByOrderNo.getOtherSettlement())
-                        || "1".equals(checkInsPlyIncomeByOrderNo.getJySuperviseSettlement()) || "1".equals(checkInsPlyIncomeByOrderNo.getJyOtherSettlement())){
-                    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;
+            }
 
+            // ===================== 数据库已存在 → 继续后续校验(需求3顺序) =====================
+            // 判断已开票 / 已结算
+            if ("1".equals(existIncome.getSuperviseSettlement()) || "1".equals(existIncome.getOtherSettlement())
+                    || "1".equals(existIncome.getJySuperviseSettlement()) || "1".equals(existIncome.getJyOtherSettlement())) {
+                failedNumber++;
+                vo.setErrorMessage("应收数据已结算");
+                failedExcel.add(vo);
+                continue;
+            }
 
-            // 处理数据
+            // 封装修改数据
             InsPlyIncome insPlyIncome = new InsPlyIncome();
-            insPlyIncome.setId(IdGenerate.nextId());
+            insPlyIncome.setId(existIncome.getId()); // 必须带ID才能修改
             insPlyIncome.setLicenseNo(vo.getLicenseNo());
             insPlyIncome.setJqPolicyNo(vo.getJqPolicyNo());
             insPlyIncome.setJqSuperviseCostsProportion(vo.getJqSuperviseCostsProportion());
@@ -703,16 +723,32 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
             insPlyIncome.setJySuperviseCostsProportion(vo.getJySuperviseCostsProportion());
             insPlyIncome.setJyOtherCostsProportion(vo.getJyOtherCostsProportion());
             insPlyIncome.setContactPerson(vo.getDockingPerson());
-            successExcel.add(insPlyIncome);
+
+            // 加入修改列表
+            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.setSuccessNumber(successExcel.size());
+        importExcelResultVo.setFailFileUrl(failFileUrl);
+        importExcelResultVo.setSuccessNumber(updateExcel.size());
         importExcelResultVo.setFailedNumber(failedNumber);
 
-        // 批量插入数据
-        baseMapper.insert(successExcel);
-
         return importExcelResultVo;
     }
 

+ 1 - 0
tenant/organization/src/main/resources/mapper/PtlAgreementCostMapper.xml

@@ -204,6 +204,7 @@
             t.failure_time,
             t.audit_method,
             t.cost_describe,
+            t.approved,
             t.is_delete,
             t.create_by,
             t.create_time,

+ 2 - 0
tenant/organization/src/main/resources/mapper/PtlSchemeMapper.xml

@@ -36,6 +36,7 @@
             <result column="scheme_type" property="schemeType"/>
             <result column="description" property="description"/>
             <collection property="drivings" ofType="com.jzg.commons.entity.scheme.vo.SchemeResultVo$Driving">
+                <id column="jc_id" property="id"/>
                 <result column="product_name" property="productName"/>
                 <result column="product_code" property="productCode"/>
                 <result column="alias" property="alias"/>
@@ -148,6 +149,7 @@
             psi.scheme_id,
             psi.scheme_type,
             psi.scheme_name,
+            jc.id as jc_id,
             jc.product_name,
             jc.alias,
             jc.product_code,