From 41ab7abd0b0ec0fefb03b60bbaf42c02fbda666b Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期四, 23 四月 2026 15:53:16 +0800
Subject: [PATCH] feat(production): 添加生产订单与销售台账关联功能

---
 src/main/resources/mapper/basic/CustomerMapper.xml |  112 +++++++++++++------------------------------------------
 1 files changed, 27 insertions(+), 85 deletions(-)

diff --git a/src/main/resources/mapper/basic/CustomerMapper.xml b/src/main/resources/mapper/basic/CustomerMapper.xml
index d098178..3b42238 100644
--- a/src/main/resources/mapper/basic/CustomerMapper.xml
+++ b/src/main/resources/mapper/basic/CustomerMapper.xml
@@ -1,91 +1,33 @@
-<?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">
+<?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">
-    
-    <resultMap type="com.ruoyi.basic.pojo.Customer" id="CustomerResult">
-        <result property="id"    column="id"    />
-        <result property="customerName"    column="customer_name"    />
-        <result property="taxpayerIdentificationNumber"    column="taxpayer_identification_number"    />
-        <result property="companyAddress"    column="company_address"    />
-        <result property="companyPhone"    column="company_phone"    />
-        <result property="contactPerson"    column="contact_person"    />
-        <result property="contactPhone"    column="contact_phone"    />
-        <result property="maintainer"    column="maintainer"    />
-        <result property="maintenanceTime"    column="maintenance_time"    />
+
+    <!-- 閫氱敤鏌ヨ鏄犲皠缁撴灉 -->
+    <resultMap id="BaseResultMap" type="com.ruoyi.basic.pojo.Customer">
+        <id column="id" property="id" />
     </resultMap>
-
-    <sql id="selectCustomerVo">
-        select id, customer_name, taxpayer_identification_number, company_address, company_phone, contact_person, contact_phone, maintainer, maintenance_time from customer
-    </sql>
-
-    <select id="selectCustomerList" parameterType="com.ruoyi.basic.pojo.Customer" resultMap="CustomerResult">
-        <include refid="selectCustomerVo"/>
-        <where>  
-            <if test="customerName != null  and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
-            <if test="taxpayerIdentificationNumber != null  and taxpayerIdentificationNumber != ''"> and taxpayer_identification_number = #{taxpayerIdentificationNumber}</if>
-            <if test="companyAddress != null  and companyAddress != ''"> and company_address = #{companyAddress}</if>
-            <if test="companyPhone != null  and companyPhone != ''"> and company_phone = #{companyPhone}</if>
-            <if test="contactPerson != null  and contactPerson != ''"> and contact_person = #{contactPerson}</if>
-            <if test="contactPhone != null  and contactPhone != ''"> and contact_phone = #{contactPhone}</if>
-            <if test="maintainer != null  and maintainer != ''"> and maintainer = #{maintainer}</if>
-            <if test="maintenanceTime != null "> and maintenance_time = #{maintenanceTime}</if>
+    <select id="listPage" resultType="com.ruoyi.basic.dto.CustomerDto">
+        select
+        c.*,
+        u.user_name usage_user_name,
+        (
+        select group_concat(u2.user_name separator ', ')
+        from customer_private_pool cpp2
+        left join sys_user u2 on cpp2.bound_id = u2.user_id
+        where cpp2.customer_id = c.id and cpp2.delete_flag = 0
+        and cpp2.bound_id != c.usage_user
+        ) as together_user_names
+        from customer c
+        left join sys_user u on c.usage_user = u.user_id
+        <where>
+            <if test="c.customerName != null and c.customerName != ''">
+                and customer_name like concat('%', #{c.customerName}, '%')
+            </if>
+            <if test="c.customerType != null and c.customerType != ''">
+                and customer_type = #{c.customerType}
+            </if>
         </where>
     </select>
-    
-    <select id="selectCustomerById" parameterType="Long" resultMap="CustomerResult">
-        <include refid="selectCustomerVo"/>
-        where id = #{id}
-    </select>
 
-    <insert id="insertCustomer" parameterType="com.ruoyi.basic.pojo.Customer" useGeneratedKeys="true" keyProperty="id">
-        insert into customer
-        <trim prefix="(" suffix=")" suffixOverrides=",">
-            <if test="customerName != null and customerName != ''">customer_name,</if>
-            <if test="taxpayerIdentificationNumber != null and taxpayerIdentificationNumber != ''">taxpayer_identification_number,</if>
-            <if test="companyAddress != null and companyAddress != ''">company_address,</if>
-            <if test="companyPhone != null and companyPhone != ''">company_phone,</if>
-            <if test="contactPerson != null and contactPerson != ''">contact_person,</if>
-            <if test="contactPhone != null and contactPhone != ''">contact_phone,</if>
-            <if test="maintainer != null and maintainer != ''">maintainer,</if>
-            <if test="maintenanceTime != null">maintenance_time,</if>
-         </trim>
-        <trim prefix="values (" suffix=")" suffixOverrides=",">
-            <if test="customerName != null and customerName != ''">#{customerName},</if>
-            <if test="taxpayerIdentificationNumber != null and taxpayerIdentificationNumber != ''">#{taxpayerIdentificationNumber},</if>
-            <if test="companyAddress != null and companyAddress != ''">#{companyAddress},</if>
-            <if test="companyPhone != null and companyPhone != ''">#{companyPhone},</if>
-            <if test="contactPerson != null and contactPerson != ''">#{contactPerson},</if>
-            <if test="contactPhone != null and contactPhone != ''">#{contactPhone},</if>
-            <if test="maintainer != null and maintainer != ''">#{maintainer},</if>
-            <if test="maintenanceTime != null">#{maintenanceTime},</if>
-         </trim>
-    </insert>
 
-    <update id="updateCustomer" parameterType="com.ruoyi.basic.pojo.Customer">
-        update customer
-        <trim prefix="SET" suffixOverrides=",">
-            <if test="customerName != null and customerName != ''">customer_name = #{customerName},</if>
-            <if test="taxpayerIdentificationNumber != null and taxpayerIdentificationNumber != ''">taxpayer_identification_number = #{taxpayerIdentificationNumber},</if>
-            <if test="companyAddress != null and companyAddress != ''">company_address = #{companyAddress},</if>
-            <if test="companyPhone != null and companyPhone != ''">company_phone = #{companyPhone},</if>
-            <if test="contactPerson != null and contactPerson != ''">contact_person = #{contactPerson},</if>
-            <if test="contactPhone != null and contactPhone != ''">contact_phone = #{contactPhone},</if>
-            <if test="maintainer != null and maintainer != ''">maintainer = #{maintainer},</if>
-            <if test="maintenanceTime != null">maintenance_time = #{maintenanceTime},</if>
-        </trim>
-        where id = #{id}
-    </update>
-
-    <delete id="deleteCustomerById" parameterType="Long">
-        delete from customer where id = #{id}
-    </delete>
-
-    <delete id="deleteCustomerByIds" parameterType="String">
-        delete from customer where id in 
-        <foreach item="id" collection="array" open="(" separator="," close=")">
-            #{id}
-        </foreach>
-    </delete>
-</mapper>
\ No newline at end of file
+</mapper>

--
Gitblit v1.9.3