From 3613e726ec84d7593c3d1f78df03b2515c0fff2e Mon Sep 17 00:00:00 2001
From: CeDo <cedoogle@gmail.com>
Date: 星期四, 20 五月 2021 15:16:44 +0800
Subject: [PATCH] Merge branch 'cedoodev' into test

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComCvtServeServiceImpl.java |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComCvtServeServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComCvtServeServiceImpl.java
index c0ace74..54adbe3 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComCvtServeServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComCvtServeServiceImpl.java
@@ -174,6 +174,7 @@
             comCvtBusinessDOS = comCvtBusinessDAO.selectList(new LambdaQueryWrapper<>());
         }
         Map<String, Long> businessMap = getBusinessMap(comCvtBusinessDOS);
+        List<String> errorInfo = new ArrayList<>();
         list.forEach(comCvtServeExcelVO -> {
             /**
              * 便民服务分类存在 并且 便民服务商家 匹配上
@@ -189,9 +190,21 @@
                 }else{
                     log.error(String.format("导入失败:商家【%s】下已有服务【%s】",comCvtServeExcelVO.getBusinessName(),comCvtServeExcelVO.getServiceName()));
                 }
+            }else{
+                if(!categoryMap.containsKey(comCvtServeExcelVO.getCategoryName())) {
+                    errorInfo.add(comCvtServeExcelVO.getCategoryName() +"导入失败: 服务分类不存在");
+                }
+                if(!businessMap.containsKey(comCvtServeExcelVO.getBusinessName())) {
+                    errorInfo.add(comCvtServeExcelVO.getBusinessName() +"导入失败: 便民服务商家不存在");
+                }
             }
         });
-        this.saveBatch(comCvtServeDOS);
+        boolean saveBatched = this.saveBatch(comCvtServeDOS);
+        if(saveBatched) {
+            if (comCvtServeDOS.size()>0 && errorInfo != null && errorInfo.size() > 0) {
+                return R.fail("导入部分成功:" + errorInfo.toString());
+            }
+        }
         return R.ok("共计导入服务数量:"+comCvtServeDOS.size());
     }
 

--
Gitblit v1.7.1