From 77620e883c248f042b62a1d3c59c0f312d4b5741 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期五, 17 四月 2026 09:36:49 +0800
Subject: [PATCH] Merge branch 'dev_天津_君歌化工' of http://114.132.189.42:9002/r/product-inventory-management-after into dev_天津_君歌化工

---
 src/main/java/com/ruoyi/basic/pojo/Customer.java                    |   12 +-
 src/main/java/com/ruoyi/quality/pojo/QualityUnqualified.java        |   24 ++++
 src/main/resources/mapper/basic/CustomerMapper.xml                  |   55 +++++++++++
 src/main/java/com/ruoyi/basic/mapper/CustomerMapper.java            |   49 ---------
 src/main/resources/mapper/quality/QualityUnqualifiedMapper.xml      |    4 
 src/main/java/com/ruoyi/basic/controller/CustomerController.java    |   28 +++++
 src/main/java/com/ruoyi/basic/excel/CustomerExcelDTO.java           |   38 +++++++
 doc/君歌化工.sql                                                        |    7 +
 src/main/java/com/ruoyi/basic/service/ICustomerService.java         |    6 +
 src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java |   51 +++++++++
 10 files changed, 218 insertions(+), 56 deletions(-)

diff --git "a/doc/\345\220\233\346\255\214\345\214\226\345\267\245.sql" "b/doc/\345\220\233\346\255\214\345\214\226\345\267\245.sql"
index bf29b5d..182974d 100644
--- "a/doc/\345\220\233\346\255\214\345\214\226\345\267\245.sql"
+++ "b/doc/\345\220\233\346\255\214\345\214\226\345\267\245.sql"
@@ -18,6 +18,13 @@
     MODIFY COLUMN `create_time` datetime NULL DEFAULT NULL COMMENT '褰曞叆鏃堕棿' AFTER `dept_id`,
     MODIFY COLUMN `update_time` datetime NULL DEFAULT NULL COMMENT '鏇存柊鏃堕棿' AFTER `create_time`;
 
+ALTER TABLE `product-inventory-management-jghg`.`quality_unqualified`
+    ADD COLUMN `reason_analysis` varchar(255) NULL COMMENT '鍘熷洜鍒嗘瀽' AFTER `dept_id`,
+ADD COLUMN `preventive_corrective` varchar(255) NULL COMMENT '棰勯槻涓庣籂姝f帾鏂�' AFTER `reason_analysis`,
+ADD COLUMN `loss_working` varchar(255) NULL COMMENT '宸ユ椂鎹熷け' AFTER `preventive_corrective`,
+ADD COLUMN `loss_material` varchar(255) NULL COMMENT '鏉愭枡璐规崯澶�' AFTER `loss_working`;
+
+
 ALTER TABLE `product-inventory-management-jghg`.`product_process_route_item`
     ADD COLUMN `planned_work_hours` decimal(15, 2) NULL COMMENT '璁″垝宸ユ椂' AFTER `product_order_id`,
     MODIFY COLUMN `product_route_id` bigint NULL DEFAULT 0 COMMENT '鐢熶骇璁㈠崟鐨勫伐鑹鸿矾绾縤d' AFTER `product_order_id`;
diff --git a/src/main/java/com/ruoyi/basic/controller/CustomerController.java b/src/main/java/com/ruoyi/basic/controller/CustomerController.java
index 94c4007..008c92d 100644
--- a/src/main/java/com/ruoyi/basic/controller/CustomerController.java
+++ b/src/main/java/com/ruoyi/basic/controller/CustomerController.java
@@ -2,6 +2,8 @@
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.basic.dto.CustomerDto;
+import com.ruoyi.basic.excel.CustomerExcelDTO;
 import com.ruoyi.basic.pojo.Customer;
 import com.ruoyi.basic.service.ICustomerService;
 import com.ruoyi.common.utils.poi.ExcelUtil;
@@ -51,6 +53,23 @@
         }
         ExcelUtil<Customer> util = new ExcelUtil<Customer>(Customer.class);
         util.exportExcel(response, list, "瀹㈡埛妗f鏁版嵁");
+    }
+
+    /**
+     * 瀵煎嚭瀹㈡埛璺熻繘璁板綍
+     */
+    @Log(title = "瀹㈡埛妗f", businessType = BusinessType.EXPORT)
+    @PostMapping("/exportFollowUpList")
+    public void exportFollowUpList(HttpServletResponse response, Customer customer) {
+        Long[] ids = customer.getIds();
+        List<CustomerExcelDTO> list;
+        if (ids != null && ids.length > 0) {
+            list = customerService.selectCustomerDtoByIds(ids);
+        } else {
+            list = customerService.selectCustomerDtoLists();
+        }
+        ExcelUtil<CustomerExcelDTO> util = new ExcelUtil<CustomerExcelDTO>(CustomerExcelDTO.class);
+        util.exportExcel(response, list, "瀹㈡埛璺熻繘璁板綍");
     }
 
     @PostMapping("/downloadTemplate")
@@ -116,4 +135,13 @@
     public List customerList(Customer customer) {
         return customerService.customerList(customer);
     }
+
+    /**
+     * 杞Щ瀹㈡埛
+     */
+    @Log(title = "瀹㈡埛妗f", businessType = BusinessType.UPDATE)
+    @PatchMapping("/transferCustomer")
+    public AjaxResult transferCustomer(@RequestBody CustomerDto customerDto) {
+        return toAjax(customerService.transferCustomer(customerDto));
+    }
 }
diff --git a/src/main/java/com/ruoyi/basic/excel/CustomerExcelDTO.java b/src/main/java/com/ruoyi/basic/excel/CustomerExcelDTO.java
new file mode 100644
index 0000000..6856505
--- /dev/null
+++ b/src/main/java/com/ruoyi/basic/excel/CustomerExcelDTO.java
@@ -0,0 +1,38 @@
+package com.ruoyi.basic.excel;
+
+import com.ruoyi.framework.aspectj.lang.annotation.Excel;
+
+import java.time.LocalDateTime;
+
+public class CustomerExcelDTO {
+    @Excel(name = "瀹㈡埛鍚嶇О")
+    private String customerName;
+    @Excel(name = "绾崇◣浜鸿瘑鍒彿")
+    private String taxpayerIdentificationNumber;
+    @Excel(name = "鍏徃鍦板潃")
+    private String companyAddress;
+    @Excel(name = "鍏徃鐢佃瘽")
+    private String companyPhone;
+    @Excel(name = "鑱旂郴浜�")
+    private String contactPerson;
+    @Excel(name = "鑱旂郴鐢佃瘽",cellType = Excel.ColumnType.STRING)
+    private String contactPhone;
+    @Excel(name = "缁存姢浜�")
+    private String maintainer;
+    @Excel(name = "閾惰鍩烘湰鎴�")
+    private String basicBankAccount;
+    @Excel(name = "閾惰璐﹀彿")
+    private String bankAccount;
+    @Excel(name = "寮�鎴疯鍙�")
+    private String bankCode;
+    @Excel(name = "璺熻繘鏃堕棿", dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime followUpTime;
+    @Excel(name = "璺熻繘鏂瑰紡")
+    private String followUpMethod;
+    @Excel(name = "璺熻繘绋嬪害")
+    private String followUpLevel;
+    @Excel(name = "璺熻繘浜哄鍚�")
+    private String followerUserName;
+    @Excel(name = "鍐呭")
+    private String content;
+}
diff --git a/src/main/java/com/ruoyi/basic/mapper/CustomerMapper.java b/src/main/java/com/ruoyi/basic/mapper/CustomerMapper.java
index 1946f26..e5f5053 100644
--- a/src/main/java/com/ruoyi/basic/mapper/CustomerMapper.java
+++ b/src/main/java/com/ruoyi/basic/mapper/CustomerMapper.java
@@ -1,6 +1,7 @@
 package com.ruoyi.basic.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ruoyi.basic.excel.CustomerExcelDTO;
 import com.ruoyi.basic.pojo.Customer;
 
 import java.util.List;
@@ -13,51 +14,7 @@
  */
 public interface CustomerMapper extends BaseMapper<Customer>
 {
-    /**
-     * 鏌ヨ瀹㈡埛妗f
-     * 
-     * @param id 瀹㈡埛妗f涓婚敭
-     * @return 瀹㈡埛妗f
-     */
-    Customer selectCustomerById(Long id);
 
-    /**
-     * 鏌ヨ瀹㈡埛妗f鍒楄〃
-     * 
-     * @param customer 瀹㈡埛妗f
-     * @return 瀹㈡埛妗f闆嗗悎
-     */
-    List<Customer> selectCustomerList(Customer customer);
-
-    /**
-     * 鏂板瀹㈡埛妗f
-     * 
-     * @param customer 瀹㈡埛妗f
-     * @return 缁撴灉
-     */
-    int insertCustomer(Customer customer);
-
-    /**
-     * 淇敼瀹㈡埛妗f
-     * 
-     * @param customer 瀹㈡埛妗f
-     * @return 缁撴灉
-     */
-    int updateCustomer(Customer customer);
-
-    /**
-     * 鍒犻櫎瀹㈡埛妗f
-     * 
-     * @param id 瀹㈡埛妗f涓婚敭
-     * @return 缁撴灉
-     */
-    int deleteCustomerById(Long id);
-
-    /**
-     * 鎵归噺鍒犻櫎瀹㈡埛妗f
-     * 
-     * @param ids 闇�瑕佸垹闄ょ殑鏁版嵁涓婚敭闆嗗悎
-     * @return 缁撴灉
-     */
-    int deleteCustomerByIds(Long[] ids);
+    List<CustomerExcelDTO> selectCustomerDtoListByIds(List<Long> ids);
+    List<CustomerExcelDTO> selectCustomerDtoLists();
 }
diff --git a/src/main/java/com/ruoyi/basic/pojo/Customer.java b/src/main/java/com/ruoyi/basic/pojo/Customer.java
index 753d76f..513222c 100644
--- a/src/main/java/com/ruoyi/basic/pojo/Customer.java
+++ b/src/main/java/com/ruoyi/basic/pojo/Customer.java
@@ -1,15 +1,13 @@
 package com.ruoyi.basic.pojo;
 
-import java.io.Serializable;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.util.Date;
-
 import com.baomidou.mybatisplus.annotation.*;
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.framework.aspectj.lang.annotation.Excel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
-import com.ruoyi.framework.aspectj.lang.annotation.Excel;
+
+import java.io.Serializable;
+import java.util.Date;
 
 /**
  * 瀹㈡埛妗f瀵硅薄 customer
@@ -117,7 +115,7 @@
     @Excel(name = "寮�鎴疯鍙�")
     private String bankCode;
     @ApiModelProperty(value = "鍒涘缓鐢ㄦ埛")
-    @TableField(fill = FieldFill.INSERT)
+//    @TableField(fill = FieldFill.INSERT)
     private Integer createUser;
 
     @TableField(fill = FieldFill.INSERT)
diff --git a/src/main/java/com/ruoyi/basic/service/ICustomerService.java b/src/main/java/com/ruoyi/basic/service/ICustomerService.java
index 989e474..0466614 100644
--- a/src/main/java/com/ruoyi/basic/service/ICustomerService.java
+++ b/src/main/java/com/ruoyi/basic/service/ICustomerService.java
@@ -4,6 +4,7 @@
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ruoyi.basic.dto.CustomerDto;
+import com.ruoyi.basic.excel.CustomerExcelDTO;
 import com.ruoyi.basic.pojo.Customer;
 import com.ruoyi.framework.web.domain.AjaxResult;
 import org.springframework.web.multipart.MultipartFile;
@@ -68,6 +69,8 @@
 
     List<Customer> selectCustomerListByIds(Long[] ids);
 
+    List<CustomerExcelDTO> selectCustomerDtoByIds(Long[] ids);
+
     /**
      * 鏌ヨ瀹㈡埛淇℃伅
      *
@@ -76,6 +79,9 @@
     List<Map<String, Object>> customerList(Customer customer);
 
     List<Customer> selectCustomerLists(Customer customer);
+    List<CustomerExcelDTO> selectCustomerDtoLists();
 
     AjaxResult importData(MultipartFile file);
+
+    int transferCustomer(CustomerDto customer);
 }
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);
+    }
 }
diff --git a/src/main/java/com/ruoyi/quality/pojo/QualityUnqualified.java b/src/main/java/com/ruoyi/quality/pojo/QualityUnqualified.java
index 60760ec..ecfca49 100644
--- a/src/main/java/com/ruoyi/quality/pojo/QualityUnqualified.java
+++ b/src/main/java/com/ruoyi/quality/pojo/QualityUnqualified.java
@@ -143,4 +143,28 @@
 
     @TableField(fill = FieldFill.INSERT)
     private Long deptId;
+
+    /**
+     * 鍘熷洜鍒嗘瀽
+     */
+    @Excel(name = "鍘熷洜鍒嗘瀽")
+    private String reasonAnalysis;
+
+    /**
+     * 棰勯槻涓庣籂姝f帾鏂�
+     */
+    @Excel(name = "棰勯槻涓庣籂姝f帾鏂�")
+    private String preventiveCorrective;
+
+    /**
+     * 宸ユ椂鎹熷け
+     */
+    @Excel(name = "宸ユ椂鎹熷け")
+    private String lossWorking;
+
+    /**
+     * 鏉愭枡璐规崯澶�
+     */
+    @Excel(name = "鏉愭枡璐规崯澶�")
+    private String lossMaterial;
 }
diff --git a/src/main/resources/mapper/basic/CustomerMapper.xml b/src/main/resources/mapper/basic/CustomerMapper.xml
new file mode 100644
index 0000000..4a29e94
--- /dev/null
+++ b/src/main/resources/mapper/basic/CustomerMapper.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ruoyi.basic.mapper.CustomerMapper">
+
+    <select id="selectCustomerDtoListByIds" resultType="com.ruoyi.basic.excel.CustomerExcelDTO">
+        SELECT
+            c.customer_name AS customerName,
+            c.taxpayer_identification_number AS taxpayerIdentificationNumber,
+            c.company_address AS companyAddress,
+            c.company_phone AS companyPhone,
+            c.contact_person AS contactPerson,
+            c.contact_phone AS contactPhone,
+            c.maintainer AS maintainer,
+            c.basic_bank_account AS basicBankAccount,
+            c.bank_account AS bankAccount,
+            c.bank_code AS bankCode,
+            cfu.follow_up_time AS followUpTime,
+            cfu.follow_up_method AS followUpMethod,
+            cfu.follow_up_level AS followUpLevel,
+            cfu.follower_user_name AS followerUserName,
+            cfu.content AS content
+        FROM customer c
+        LEFT JOIN customer_follow_up cfu ON c.id = cfu.customer_id
+        WHERE c.id IN
+        <foreach collection="ids" item="id" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+        ORDER BY c.create_user
+    </select>
+
+    <select id="selectCustomerDtoLists" resultType="com.ruoyi.basic.excel.CustomerExcelDTO">
+        SELECT
+            c.customer_name AS customerName,
+            c.taxpayer_identification_number AS taxpayerIdentificationNumber,
+            c.company_address AS companyAddress,
+            c.company_phone AS companyPhone,
+            c.contact_person AS contactPerson,
+            c.contact_phone AS contactPhone,
+            c.maintainer AS maintainer,
+            c.basic_bank_account AS basicBankAccount,
+            c.bank_account AS bankAccount,
+            c.bank_code AS bankCode,
+            cfu.follow_up_time AS followUpTime,
+            cfu.follow_up_method AS followUpMethod,
+            cfu.follow_up_level AS followUpLevel,
+            cfu.follower_user_name AS followerUserName,
+            cfu.content AS content
+        FROM
+            customer c
+                LEFT JOIN customer_follow_up cfu ON c.id = cfu.customer_id
+        ORDER BY
+            c.create_user
+    </select>
+
+</mapper>
diff --git a/src/main/resources/mapper/quality/QualityUnqualifiedMapper.xml b/src/main/resources/mapper/quality/QualityUnqualifiedMapper.xml
index 5bda4f6..99f402d 100644
--- a/src/main/resources/mapper/quality/QualityUnqualifiedMapper.xml
+++ b/src/main/resources/mapper/quality/QualityUnqualifiedMapper.xml
@@ -16,6 +16,10 @@
         qu.deal_result,
         qu.deal_name,
         qu.deal_time,
+        qu.reason_analysis,
+        qu.preventive_corrective,
+        qu.loss_working,
+        qu.loss_material,
         CASE
         WHEN qu.model = pm.id THEN pm.model
         ELSE qu.model

--
Gitblit v1.9.3