From 82a5de6d2ec80b45660149c84be28734032562f6 Mon Sep 17 00:00:00 2001
From: chenlu <1320612696@qq.com>
Date: 星期五, 11 十月 2024 15:21:53 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/ERP_override

---
 north-glass-erp/src/main/resources/mapper/sd/OrderMapper.xml |  212 ++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 193 insertions(+), 19 deletions(-)

diff --git a/north-glass-erp/src/main/resources/mapper/sd/OrderMapper.xml b/north-glass-erp/src/main/resources/mapper/sd/OrderMapper.xml
index fcf7a2d..b4dd989 100644
--- a/north-glass-erp/src/main/resources/mapper/sd/OrderMapper.xml
+++ b/north-glass-erp/src/main/resources/mapper/sd/OrderMapper.xml
@@ -3,26 +3,99 @@
         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.example.erp.mapper.sd.OrderMapper">
+
+    <select id="selectOrder">
+        select
+            *
+        from
+            sd.`order` as o
+        where
+            o.quantity=#{order.quantity} and o.area=#{order.area} and o.project=#{order.project} and o.customer_id=#{order.customerId}
+    </select>
+
     <select id="selectMaxOrderId">
         select
-            COUNT(a.order_id)
+           ifnull(SUBSTR(max(right(order_id,8)) from 7),0)
         from
             `order` as a
         where
             date(a.create_time) = curdate()
+        /*order by order_id desc,order_id	desc limit  1*/
     </select>
-    
+
+    <select id="selectMaxOrderIdByMonth">
+        select
+            ifnull(SUBSTR(max(right(order_id,8)) from 5),0)
+        from
+            `order` as a
+        where
+            date(a.create_time)  BETWEEN DATE_FORMAT(DATE(NOW()), '%Y-%m-01') AND DATE(NOW())
+    </select>
+
+    <select id="selectMaxOrderIdByYear">
+       select
+           ifnull(SUBSTR(max(right(order_id,8)) from 3),0)
+        from
+            `order` as a
+        where
+            year(a.create_time)  = year(now())
+            and a.id>400
+    </select>
+
+    <select id="selectOrderIdMin">
+        select count(*) from sd.`order` where SUBSTR(order_id,3,11)>#{substringInt}
+    </select>
+
+    <select id="selectOrderIdIs">
+        select count(*) from sd.`order` where SUBSTR(order_id,3,11)=#{substringInt}
+    </select>
+
+    <select id="selectOrderIdDay">
+        select count(*) from sd.`order` where order_id=#{oldOrderId} and SUBSTR(#{oldOrderId},9,2)=01
+    </select>
+
+    <select id="selectOrderIdMonth">
+        select count(*) from sd.`order` where order_id=#{oldOrderId} and SUBSTR(#{oldOrderId},7,4)=0001
+    </select>
+
+    <select id="selectOrderIdYear">
+        select count(*) from sd.`order` where order_id=#{oldOrderId} and SUBSTR(#{oldOrderId},5,2)=000001
+    </select>
+
+    <select id="selectOrderId">
+        select * from sd.`order` where order_id=#{orderId}
+    </select>
+
+    <update id="updateOrderId">
+        update sd.`order` set order_id=#{newOrderId} where order_id=#{oldOrderId}
+    </update>
 
     <update id="updateOrderParameter">
         update `order` o
         left join
-            (select a.order_id,sum(a.perimeter) as aa,sum(a.quantity) as b,sum(a.compute_gross_area)  as c
-             from sd.order_detail as a group by a.order_id)  od
+            (select a.order_id,
+                    round(sum(a.perimeter),2) as aa,
+                    sum(a.quantity) as b,
+                    sum(a.compute_gross_area)  as c,
+                   sum(a.gross_amount) as 'detailAmount'
+             from sd.order_detail as a group by a.order_id
+            ) as od
             on o.order_id = od.order_id
+        left join (select oom.order_id,
+                          sum(oom.money) as 'money'
+                   from order_other_money as oom
+                   where
+                       oom.order_id = #{orderId}
+                   group by oom.order_id
+                   ) as c
+        on c.order_id = o.order_id
         set
+            o.money = ifnull(od.detailAmount,0)+ifnull(c.money,0),
             o.quantity = od.b,
             o.area = od.c,
-            o.perimeter= od.aa
+            o.perimeter= od.aa,
+            o.other_money = ifnull(c.money,0),
+            o.other_remarks = (select group_concat( distinct edging_type) from order_detail where order_id = #{orderId} and  edging_type is not null)
         where
             o.order_id = #{orderId}
 
@@ -30,10 +103,13 @@
     
     <select id="getOrderList">
         select
-            *
+            *,
+        ifnull(sum(fgi.quantity_available),0) as goodsQuantity
         from
-            `order` as o
-        where  o.create_time>=#{startDate} and o.create_time &lt;= #{endDate}
+            sd.`order` as o
+        left join mm.finished_goods_inventory as  fgi
+        on o.order_id = fgi.order_id
+        where  date(o.create_time)>=#{startDate} and date(o.create_time) &lt;= #{endDate}
 
           <if test="orderType!= null and orderType != ''">
                and o.create_order = #{orderType}
@@ -44,10 +120,10 @@
            </if>
 
            <if test="order.customerId != null and order.customerId != ''">
-               and o.customer_id REGEXP #{customerId}
+               and o.customer_id REGEXP #{order.customerId}
            </if>
            <if test="order.customerName != null and order.customerName != ''">
-               and o.customer_name REGEXP #{customerName}
+               and o.customer_name REGEXP #{order.customerName}
            </if>
            <if test="order.project != null and order.project != ''">
                and o.project REGEXP #{order.project}
@@ -60,7 +136,7 @@
            </if>
 
            <if test="order.area != null and order.area != ''">
-               and o.area REGEXP #{order.area}
+               and o.area REGEXP REGEXP_REPLACE(#{order.area}, '\\.0+$', '')
            </if>
            <if test="order.createTime != null and order.createTime != ''">
                and date(o.create_time) = #{order.createTime}
@@ -74,6 +150,14 @@
            <if test="order.salesman != null and order.salesman != ''">
                and o.salesman REGEXP #{order.salesman}
            </if>
+
+            <if test="order.creator != null and order.creator != ''">
+                and o.creator REGEXP #{order.creator}
+            </if>
+
+            <if test="order.verifier != null and order.verifier != ''">
+                and o.verifier REGEXP #{order.verifier}
+            </if>
 
            <if test="order.perimeter != null and order.perimeter != ''">
                and o.perimeter REGEXP #{order.perimeter}
@@ -90,18 +174,40 @@
            <if test="order.deliveryAddress != null and order.deliveryAddress != ''">
                and o.delivery_address REGEXP #{order.deliveryAddress}
            </if>
-
+        <if test="order.delivery != null ">
+            and o.delivery = #{order.delivery}
+        </if>
+        <if test="order.processReview != null ">
+            and o.process_review = #{order.processReview}
+        </if>
+        <if test="order.orderReview != null ">
+            and o.order_review = #{order.orderReview}
+        </if>
+        <if test="order.productionOrder != null ">
+            and o.production_order = #{order.productionOrder}
+        </if>
+        <if test="order.processingCard != null ">
+            and o.processing_card = #{order.processingCard}
+        </if>
+        <if test="order.warehousing != null ">
+            and o.warehousing = #{order.warehousing}
+        </if>
+        <if test="order.processingNote != null and order.processingNote != ''">
+            and o.processing_note REGEXP #{order.processingNote}
+        </if>
+        group by o.id
         order by o.id desc
         limit #{offset},#{pageSize}
     </select>
 
     <select id="getPageTotal">
         select
-            CEILING(count(o.id)/#{pageSize})
+            CEILING(count(o.id)/#{pageSize}) as 'pageTotal',
+            count(o.id) as 'total'
         from
         `order` as o
-        where o.create_time>=#{startDate} and o.create_time &lt;= #{endDate}
-            <if test="orderType!= null and orderType != ''">
+        where date (o.create_time)>=#{startDate} and date(o.create_time) &lt;= #{endDate}
+            <if test="orderType!= null and orderType != 0">
                 and o.create_order = #{orderType}
             </if>
 
@@ -110,10 +216,10 @@
             </if>
 
             <if test="order.customerId != null and order.customerId != ''">
-                and o.customer_id REGEXP #{customerId}
+                and o.customer_id REGEXP #{order.customerId}
             </if>
             <if test="order.customerName != null and order.customerName != ''">
-                and o.customer_name REGEXP #{customerName}
+                and o.customer_name REGEXP #{order.customerName}
             </if>
             <if test="order.project != null and order.project != ''">
                 and o.project REGEXP #{order.project}
@@ -141,6 +247,14 @@
                 and o.salesman REGEXP #{order.salesman}
             </if>
 
+            <if test="order.creator != null and order.creator != ''">
+                and o.creator REGEXP #{order.creator}
+            </if>
+
+            <if test="order.verifier != null and order.verifier != ''">
+                and o.verifier REGEXP #{order.verifier}
+            </if>
+
             <if test="order.perimeter != null and order.perimeter != ''">
                 and o.perimeter REGEXP #{order.perimeter}
             </if>
@@ -156,9 +270,69 @@
             <if test="order.deliveryAddress != null and order.deliveryAddress != ''">
                 and o.delivery_address REGEXP #{order.deliveryAddress}
             </if>
-
+        <if test="order.delivery != null ">
+            and o.delivery = #{order.delivery}
+        </if>
+        <if test="order.processReview != null ">
+            and o.process_review = #{order.processReview}
+        </if>
+        <if test="order.orderReview != null ">
+            and o.order_review = #{order.orderReview}
+        </if>
+        <if test="order.productionOrder != null ">
+            and o.production_order = #{order.productionOrder}
+        </if>
+        <if test="order.processingCard != null ">
+            and o.processing_card = #{order.processingCard}
+        </if>
+        <if test="order.warehousing != null ">
+            and o.warehousing = #{order.warehousing}
+        </if>
+        <if test="order.processingNote != null and order.processingNote != ''">
+            and o.processing_note REGEXP #{order.processingNote}
+        </if>
         order by o.id desc
-        limit #{offset},#{pageSize}
     </select>
+    
+    <update id="reviewOrderById">
+        update `order` set order_review = #{status},
+                           verifier_id = #{userId},
+                           verifier = #{userName},
+                           update_time=now()
+                           where order_id = #{id}
+    </update>
+    <update id="reviewOrderByIds">
+        update `order` set order_review = #{status},process_review = #{status},
+                           verifier_id = null,
+                           verifier = null
+        where order_id = #{id}
+    </update>
 
+    <update id="reviewProcessById">
+        update `order` set process_review = #{status} where order_id = #{id}
+    </update>
+
+    <update id="updateMoney">
+        update `order` set money = #{order.money},calculate_type = #{order.calculateType},other_money=#{order.otherMoney} where order_id = #{order.orderId}
+    </update>
+
+    <update id="cancelOrder">
+        update `order` as a set
+            a.create_order = - a.create_order,
+            a.process_review = - a.process_review,
+            a.order_review = - a.order_review,
+            a.production_order = - a.production_order,
+            a.processing_card =  - a.processing_card,
+            a.warehousing = - a.warehousing,
+            a.delivery = - a.delivery
+        where order_id = #{order.orderId}
+    </update>
+
+    <update id="updateOrderPrintNumber">
+        update sd.`order` o
+            set o.printing_number=o.printing_number+1
+        where
+            o.order_id = #{orderId}
+
+    </update>
 </mapper>
\ No newline at end of file

--
Gitblit v1.8.0