From 49ff365a6977628cbb5db0ec5a4a234edd0c91ad Mon Sep 17 00:00:00 2001
From: 廖井涛 <2265517004@qq.com>
Date: 星期三, 25 九月 2024 16:30:55 +0800
Subject: [PATCH] 客户订单导出面积修改

---
 north-glass-erp/src/main/resources/mapper/sd/CustomerMapper.xml |  253 +++++++++++++++++++++++++++++---------------------
 1 files changed, 147 insertions(+), 106 deletions(-)

diff --git a/north-glass-erp/src/main/resources/mapper/sd/CustomerMapper.xml b/north-glass-erp/src/main/resources/mapper/sd/CustomerMapper.xml
index a947688..d4d1026 100644
--- a/north-glass-erp/src/main/resources/mapper/sd/CustomerMapper.xml
+++ b/north-glass-erp/src/main/resources/mapper/sd/CustomerMapper.xml
@@ -40,70 +40,60 @@
     </resultMap>
 
 
-    <select id="getSelectCustomerOderDate" resultMap="selectCustomerOrderDetail">
-        select od.order_id,
-               od.order_number,
-               o.project,
-               od.product_id,
-               od.product_name,
-               o.customer_id,
-               o.customer_name,
-               sum(od.quantity) as quantity,
-               sum(od.area) as area,
-               od.shape,
-               od.width,
-               od.height,
-               o.batch,
-               o.money,
-               o.order_type,
-               o.salesman,
-               o.create_time
-        from order_detail od
-                 left join `order` o on o.order_id = od.order_id
-        <where>
-                and date(o.create_time)>=#{startDate} and date(o.create_time) &lt;= #{endDate}
-            <if test="orderDetail.order.customerId != null and orderDetail.order.customerId != ''">
-                and o.customer_id = #{orderDetail.order.customerId}
-            </if>
-            <if test="orderDetail.order.project != null and orderDetail.order.project != ''">
-                and o.project regexp #{orderDetail.order.project}
-            </if>
-            <if test="orderDetail.order.batch != null and orderDetail.order.batch != ''">
-                and o.batch regexp #{orderDetail.order.batch}
-            </if>
-            <if test="orderDetail.order.money != null and orderDetail.order.money != ''">
-                and o.money regexp REGEXP_REPLACE(#{orderDetail.order.money},'\\.0+$','')
-            </if>
-            <if test="orderDetail.order.orderType != null and orderDetail.order.orderType != ''">
-                and o.order_type regexp #{orderDetail.order.orderType}
-            </if>
-            <if test="orderDetail.order.salesman != null and orderDetail.order.salesman != ''">
-                and o.salesman regexp #{orderDetail.order.salesman}
-            </if>
-            <if test="orderDetail.orderId != null and orderDetail.orderId != ''">
-                and od.order_id regexp #{orderDetail.orderId}
-            </if>
-            <if test="orderDetail.orderNumber != null and orderDetail.orderNumber != ''">
-                and od.order_number regexp #{orderDetail.orderNumber}
-            </if>
-            <if test="orderDetail.productId != null and orderDetail.productId != ''">
-                and od.product_id regexp #{orderDetail.productId}
-            </if>
-            <if test="orderDetail.productName != null and orderDetail.productName != ''">
-                and od.product_name regexp #{orderDetail.productName}
-            </if>
-            <if test="orderDetail.shape != null and orderDetail.shape != ''">
-                and od.shape regexp #{orderDetail.shape}
-            </if>
-            <if test="orderDetail.width != null and orderDetail.width != ''">
-                and od.width regexp  REGEXP_REPLACE(#{orderDetail.width},'\\.0+$','')
-            </if>
-            <if test="orderDetail.height != null and orderDetail.height != ''">
-                and od.height regexp  REGEXP_REPLACE(#{orderDetail.height},'\\.0+$','')
-            </if>
+    <select id="getSelectCustomerDeliveryDate" >
+        select d.delivery_id,dd.order_id,d.customer_id,d.customer_name,
+               d.project,od.product_name,sum(dd.quantity) as quantity,sum(dd.area) as area,dd.price,sum(dd.money) as money,
+                date(d.create_time) as create_time
 
+        from sd.delivery_detail dd
+                 left join sd.delivery d on d.delivery_id = dd.delivery_id
+                 left join sd.order_detail od on od.order_id=dd.order_id and od.order_number=dd.order_number
+
+                where date(d.create_time)>=#{startDate} and date(d.create_time) &lt;= #{endDate}
+                and d.customer_id = #{orderDetail.order.customerId}
+        group by od.order_id,od.product_id
+        limit #{offset},#{pageSize};
+    </select>
+
+    <select id="getSelectCustomerDeliveryDatePageTotal" >
+        select
+        CEILING(count(zu.id)/#{pageSize}) as 'pageTotal',
+        count(zu.id) as 'total' from (select od.product_id,od.id
+        from sd.delivery_detail dd
+        left join sd.delivery d on d.delivery_id = dd.delivery_id
+        left join sd.order_detail od on od.order_id=dd.order_id and od.order_number=dd.order_number
+        where
+             date(d.create_time)>=#{startDate} and date(d.create_time) &lt;= #{endDate}
+            and d.customer_id = #{orderDetail.order.customerId}
+        group by od.order_id,od.product_id) as zu
+    </select>
+
+    <select id="getSelectCustomerOderDate" >
+        select od.order_id,
+        od.order_number,
+        o.project,
+        od.product_id,
+        od.product_name,
+        o.customer_id,
+        o.customer_name,
+        sum(od.quantity) as quantity,
+        sum(od.compute_gross_area) as area,
+        od.shape,
+        od.width,
+        od.height,
+        o.batch,
+        od.price,
+        sum(od.gross_amount) as money,
+        o.order_type,
+        o.salesman,
+        date(o.create_time) as create_time
+        from order_detail od
+        left join `order` o on o.order_id = od.order_id
+        <where>
+            and date(o.create_time)>=#{startDate} and date(o.create_time) &lt;= #{endDate}
+                                   and o.customer_id = #{orderDetail.order.customerId} and o.create_order>0
         </where>
-        group by od.product_id, od.width, od.height
+        group by od.order_id,od.product_id
         limit #{offset},#{pageSize};
     </select>
 
@@ -115,48 +105,9 @@
         left join `order` o on o.order_id = od.order_id
         <where>
             and date(o.create_time)>=#{startDate} and date(o.create_time) &lt;= #{endDate}
-            <if test="orderDetail.order.customerId != null and orderDetail.order.customerId != ''">
-                and o.customer_id = #{orderDetail.order.customerId}
-            </if>
-            <if test="orderDetail.order.project != null and orderDetail.order.project != ''">
-                and o.project regexp #{orderDetail.order.project}
-            </if>
-            <if test="orderDetail.order.batch != null and orderDetail.order.batch != ''">
-                and o.batch regexp #{orderDetail.order.batch}
-            </if>
-            <if test="orderDetail.order.money != null and orderDetail.order.money != ''">
-                and o.money regexp REGEXP_REPLACE(#{orderDetail.order.money},'\\.0+$','')
-            </if>
-            <if test="orderDetail.order.orderType != null and orderDetail.order.orderType != ''">
-                and o.order_type regexp #{orderDetail.order.orderType}
-            </if>
-            <if test="orderDetail.order.salesman != null and orderDetail.order.salesman != ''">
-                and o.salesman regexp #{orderDetail.order.salesman}
-            </if>
-            <if test="orderDetail.orderId != null and orderDetail.orderId != ''">
-                and od.order_id regexp #{orderDetail.orderId}
-            </if>
-            <if test="orderDetail.orderNumber != null and orderDetail.orderNumber != ''">
-                and od.order_number regexp #{orderDetail.orderNumber}
-            </if>
-            <if test="orderDetail.productId != null and orderDetail.productId != ''">
-                and od.product_id regexp #{orderDetail.productId}
-            </if>
-            <if test="orderDetail.productName != null and orderDetail.productName != ''">
-                and od.product_name regexp #{orderDetail.productName}
-            </if>
-            <if test="orderDetail.shape != null and orderDetail.shape != ''">
-                and od.shape regexp #{orderDetail.shape}
-            </if>
-            <if test="orderDetail.width != null and orderDetail.width != ''">
-                and od.width regexp  REGEXP_REPLACE(#{orderDetail.width},'\\.0+$','')
-            </if>
-            <if test="orderDetail.height != null and orderDetail.height != ''">
-                and od.height regexp  REGEXP_REPLACE(#{orderDetail.height},'\\.0+$','')
-            </if>
-
+                and o.customer_id = #{orderDetail.order.customerId} and o.create_order>0
         </where>
-        group by od.product_id, od.width, od.height) as zu
+        group by od.order_id,od.product_id) as zu
     </select>
 
     <select id="getCustomerList">
@@ -197,6 +148,9 @@
             </if>
             <if test="customer.customerName != null and customer.customerName != ''">
                 and c.customer_name regexp #{customer.customerName}
+            </if>
+            <if test="customer.customerAbbreviation != null and customer.customerAbbreviation != ''">
+                and c.customer_abbreviation regexp #{customer.customerAbbreviation}
             </if>
             <if test="customer.grade != null and customer.grade != ''">
                 and c.grade regexp #{customer.grade}
@@ -252,15 +206,15 @@
     </select>
 
     <insert id="insertCustomer"  useGeneratedKeys="true" >
-        insert into sd.customer(customer_name,grade,money_limit,address,contact,phone)
+        insert into sd.customer(customer_name,customer_abbreviation,grade,money_limit,address,contact,phone)
         values (
-                   #{customer.customerName},#{customer.grade},#{customer.moneyLimit},
+                   #{customer.customerName},#{customer.customerAbbreviation},#{customer.grade},#{customer.moneyLimit},
                 #{customer.address},#{customer.contact},#{customer.phone}
                )
     </insert>
 
     <update id="updateCustomer"  useGeneratedKeys="true" >
-        update sd.customer set customer_name=#{customer.customerName},grade=#{customer.grade},
+        update sd.customer set customer_name=#{customer.customerName},customer_abbreviation=#{customer.customerAbbreviation},grade=#{customer.grade},
                                     money_limit=#{customer.moneyLimit},address= #{customer.address},
                                     contact=#{customer.contact},phone=#{customer.phone} where id=#{customer.id}
     </update>
@@ -268,4 +222,91 @@
     <delete id="deleteCustomer" >
         delete from sd.customer  where id=#{customer.id}
     </delete>
+
+    <select id="exportSelectCustomerDeliveryDate" >
+        select d.delivery_id,
+               dd.order_id,
+               d.customer_name,
+               d.project,
+               od.product_name,
+               sum(dd.quantity)    as quantity,
+               sum(dd.area)        as area,
+               dd.price,
+               sum(dd.money)       as money,
+               date(d.create_time) as create_time
+
+        from sd.delivery_detail dd
+                 left join sd.delivery d on d.delivery_id = dd.delivery_id
+                 left join sd.order_detail od on od.order_id = dd.order_id and od.order_number = dd.order_number
+
+        where date(d.create_time) >= #{startDate}
+          and date(d.create_time) &lt;= #{endDate}
+          and d.customer_id = #{orderDetail.order.customerId}
+        group by od.order_id,od.product_id
+
+        UNION ALL
+
+        select d.delivery_id,
+               o.order_id,
+               d.customer_name,
+               d.project,
+               bom.alias           as product_name,
+               sum(om.quantity)    as quantity,
+               0                   as area,
+               om.price,
+               sum(om.money)       as money,
+               date(d.create_time) as create_time
+
+        from (select * from sd.delivery_detail group by order_id) as dd
+                 left join sd.delivery d on d.delivery_id = dd.delivery_id
+                 left join sd.`order` o on o.order_id = dd.order_id
+                 left join sd.order_other_money om on om.order_id = o.order_id
+                 left join sd.basic_other_money bom on bom.`column` = om.`column`
+
+        where date(d.create_time) >= #{startDate}
+          and date(d.create_time) &lt;= #{endDate}
+          and d.customer_id = #{orderDetail.order.customerId}
+          and om.money is not null
+        group by d.delivery_id, o.order_id, om.`column`
+    </select>
+
+    <select id="exportSelectCustomerOderDate" >
+        select od.order_id,
+               o.project,
+               od.product_name,
+               o.customer_name,
+               sum(od.quantity)     as quantity,
+               sum(od.compute_gross_area)         as area,
+               od.price,
+               sum(od.gross_amount) as money,
+               date(o.create_time)  as create_time
+        from order_detail od
+                 left join `order` o on o.order_id = od.order_id
+        where date(o.create_time) >= #{startDate}
+          and date(o.create_time) &lt;= #{endDate}
+          and o.customer_id = #{orderDetail.order.customerId}
+          and o.create_order>0
+        group by od.order_id,od.product_id
+
+        UNION ALL
+
+        select o.order_id,
+               o.project,
+               bom.alias           as product_name,
+               o.customer_name,
+               sum(om.quantity)    as quantity,
+               0                   as area,
+               om.price,
+               sum(om.money)       as money,
+               date(o.create_time) as create_time
+        from `order` o
+                 left join sd.order_other_money om on om.order_id = o.order_id
+                 left join sd.basic_other_money bom on bom.`column` = om.`column`
+        where date(o.create_time) >= #{startDate}
+          and date(o.create_time) &lt;= #{endDate}
+          and o.customer_id = #{orderDetail.order.customerId}
+          and om.money is not null
+        group by o.order_id, om.`column`
+
+    </select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.8.0