From f7df7a209811ff100251e568d1f3d501438d1d07 Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期一, 20 四月 2026 10:14:06 +0800
Subject: [PATCH] fix:多张表生成

---
 src/main/java/com/ruoyi/basic/service/impl/CustomerPrivateServiceImpl.java |   24 ++++++++++++++++++++++--
 1 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/main/java/com/ruoyi/basic/service/impl/CustomerPrivateServiceImpl.java b/src/main/java/com/ruoyi/basic/service/impl/CustomerPrivateServiceImpl.java
index 3edeaa0..95f6193 100644
--- a/src/main/java/com/ruoyi/basic/service/impl/CustomerPrivateServiceImpl.java
+++ b/src/main/java/com/ruoyi/basic/service/impl/CustomerPrivateServiceImpl.java
@@ -56,6 +56,11 @@
     @Autowired
     private SalesLedgerMapper salesLedgerMapper;
 
+    @Autowired
+    private  CustomerPrivateMapper customerPrivateMapper;
+    @Autowired
+    private CustomerPrivateService customerPrivateService;
+
 
     @Override
     public Boolean add(CustomerPrivateDto customerPrivateDto) {
@@ -64,6 +69,7 @@
         //鏂板绉佹捣璁板綍
         CustomerPrivatePool customerPrivatePool = new CustomerPrivatePool();
         customerPrivatePool.setCustomerId(customerPrivateDto.getId());
+        customerPrivatePool.setType(0L);
         customerPrivatePool.setBoundId(SecurityUtils.getLoginUser().getUserId());
         customerPrivatePoolMapper.insert(customerPrivatePool);
         return true;
@@ -93,20 +99,34 @@
     @Override
     public R importData(MultipartFile file) {
         try {
+            List<CustomerPrivate> existingList = customerPrivateService.list();
+            java.util.Set<String> existingCustomerNames = existingList.stream()
+                    .map(CustomerPrivate::getCustomerName)
+                    .collect(Collectors.toSet());
+
             ExcelUtil<CustomerPrivate> util = new ExcelUtil<CustomerPrivate>(CustomerPrivate.class);
             List<CustomerPrivate> userList = util.importExcel(file.getInputStream());
             if (CollectionUtils.isEmpty(userList)) {
                 return R.fail("妯℃澘閿欒鎴栧鍏ユ暟鎹负绌�");
             }
+
+            int successCount = 0;
+            int skipCount = 0;
             for (CustomerPrivate user : userList) {
+                if (existingCustomerNames.contains(user.getCustomerName())) {
+                    skipCount++;
+                    continue;
+                }
                 CustomerPrivateDto customerPrivateDto = new CustomerPrivateDto();
                 BeanUtils.copyProperties(user, customerPrivateDto);
                 this.add(customerPrivateDto);
+                existingCustomerNames.add(user.getCustomerName());
+                successCount++;
             }
-            return R.ok(true);
+            return R.ok("瀵煎叆瀹屾垚锛屾垚鍔�" + successCount + "鏉★紝璺宠繃閲嶅" + skipCount + "鏉�");
         } catch (Exception e) {
             e.printStackTrace();
-            return R.fail("瀵煎叆澶辫触");
+            return R.fail("瀵煎叆澶辫触锛�" + e.getMessage());
         }
     }
 }

--
Gitblit v1.9.3