From 78b637613099f0e2e04e98c5f33c24f8e6c78c7a Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期四, 30 四月 2026 09:17:47 +0800
Subject: [PATCH] fix: 质检内的工序修改为部件类型

---
 src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java |   51 ++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 48 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java b/src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java
index 58810c9..154605a 100644
--- a/src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java
+++ b/src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java
@@ -1,8 +1,6 @@
 package com.ruoyi.basic.service.impl;
 
 
-import cn.hutool.core.date.DateUtil;
-import cn.hutool.core.date.LocalDateTimeUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -11,6 +9,7 @@
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.basic.dto.CustomerDto;
 import com.ruoyi.basic.dto.CustomerFollowUpDto;
+import com.ruoyi.basic.excel.CustomerExcelDTO;
 import com.ruoyi.basic.mapper.CustomerMapper;
 import com.ruoyi.basic.pojo.Customer;
 import com.ruoyi.basic.pojo.CustomerFollowUp;
@@ -25,6 +24,7 @@
 import com.ruoyi.framework.security.LoginUser;
 import com.ruoyi.framework.web.domain.AjaxResult;
 import com.ruoyi.project.system.domain.SysUser;
+import com.ruoyi.project.system.mapper.SysUserMapper;
 import com.ruoyi.sales.mapper.SalesLedgerMapper;
 import com.ruoyi.sales.pojo.SalesLedger;
 import lombok.AllArgsConstructor;
@@ -35,7 +35,6 @@
 import org.springframework.util.CollectionUtils;
 import org.springframework.web.multipart.MultipartFile;
 
-import java.time.LocalDate;
 import java.time.ZoneId;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -59,6 +58,8 @@
     private CustomerFollowUpFileService customerFollowUpFileService;
 
     private CustomerReturnVisitService customerReturnVisitService;
+
+    private SysUserMapper sysUserMapper;
 
     /**
      * 鏌ヨ瀹㈡埛妗f
@@ -142,6 +143,7 @@
             queryWrapper.like(Customer::getCustomerType, customerType);
         }
 
+
         // 3. 鎵ц鍒嗛〉鏌ヨ锛堜繚鐣欏垎椤靛厓鏁版嵁锛�
         IPage<Customer> customerPage = customerMapper.selectPage(page, queryWrapper);
 
@@ -188,9 +190,17 @@
      */
     @Override
     public int insertCustomer(Customer customer) {
+        // 1. 鏍¢獙瀹㈡埛鍚嶇О鏄惁宸插瓨鍦�
+        LambdaQueryWrapper<Customer> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(Customer::getCustomerName, customer.getCustomerName());
+        List<Customer> customerList = customerMapper.selectList(queryWrapper);
+        if (!customerList.isEmpty()) {
+            throw new RuntimeException("瀹㈡埛鍚嶇О宸插瓨鍦�");
+        }
         LoginUser loginUser = SecurityUtils.getLoginUser();
         Long tenantId = loginUser.getTenantId();
         customer.setTenantId(tenantId);
+        customer.setCreateUser(loginUser.getUserId().intValue());
         return customerMapper.insert(customer);
     }
 
@@ -202,6 +212,14 @@
      */
     @Override
     public int updateCustomer(Customer customer) {
+        // 1. 鏍¢獙瀹㈡埛鍚嶇О鏄惁宸插瓨鍦�
+        LambdaQueryWrapper<Customer> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(Customer::getCustomerName, customer.getCustomerName());
+        queryWrapper.ne(Customer::getId, customer.getId());
+        List<Customer> customerList = customerMapper.selectList(queryWrapper);
+        if (!customerList.isEmpty()) {
+            throw new RuntimeException("瀹㈡埛鍚嶇О宸插瓨鍦�");
+        }
         LoginUser loginUser = SecurityUtils.getLoginUser();
         Long tenantId = loginUser.getTenantId();
         customer.setTenantId(tenantId);
@@ -239,8 +257,18 @@
     }
 
     @Override
+    public List<CustomerExcelDTO> selectCustomerDtoByIds(Long[] ids) {
+        return customerMapper.selectCustomerDtoListByIds(Arrays.asList(ids));
+    }
+
+    @Override
     public List<Customer> selectCustomerLists(Customer customer) {
         return customerMapper.selectList(null);
+    }
+
+    @Override
+    public List<CustomerExcelDTO> selectCustomerDtoLists() {
+        return customerMapper.selectCustomerDtoLists();
     }
 
     @Override
@@ -297,4 +325,21 @@
         }
         return sb.toString();
     }
+
+    @Override
+    public int transferCustomer(CustomerDto customerDto) {
+        // 鏍¢獙缁存姢浜烘槸鍚﹀瓨鍦�
+        SysUser sysUser = sysUserMapper.selectUserById(customerDto.getCreateUser().longValue());
+        if (sysUser == null) {
+            throw new RuntimeException("缁存姢浜轰笉瀛樺湪");
+        }
+        // 鏍¢獙瀹㈡埛鏄惁瀛樺湪
+        Customer customer = customerMapper.selectById(customerDto.getId());
+        if (customer == null) {
+            throw new RuntimeException("瀹㈡埛涓嶅瓨鍦�");
+        }
+        customer.setMaintainer(sysUser.getNickName());
+        customer.setCreateUser(customerDto.getCreateUser());
+        return customerMapper.updateById(customer);
+    }
 }

--
Gitblit v1.9.3