From 74863c38a407b1e0f36250dfa0c63e5da7fe5f66 Mon Sep 17 00:00:00 2001
From: pang.jiabao <pang_jiabao@163.com>
Date: 星期一, 19 一月 2026 18:06:51 +0800
Subject: [PATCH] WMS功能完善

---
 src/main/resources/mapper/ViewDigitalTwinMapper.xml |   97 +++++++++++++++++++++++++++++-------------------
 1 files changed, 58 insertions(+), 39 deletions(-)

diff --git a/src/main/resources/mapper/ViewDigitalTwinMapper.xml b/src/main/resources/mapper/ViewDigitalTwinMapper.xml
index 4f909df..3fa11af 100644
--- a/src/main/resources/mapper/ViewDigitalTwinMapper.xml
+++ b/src/main/resources/mapper/ViewDigitalTwinMapper.xml
@@ -6,45 +6,61 @@
     <!--鎬昏锛氭�诲簱浣嶃�佸凡鐢ㄥ簱浣嶃�佷粖鏃ュ簱瀛樸�佷粖鏃ュ嚭搴撱�佷粖鏃ュ叆搴�-->
     <select id="overview" resultType="Double">
         SELECT COUNT(*) FROM asr_loc_mast WHERE loc_sts != 'Z'
-            <if test="areaId != null">
-                and area_id = #{areaId}
-            </if>
+        <!--            <if test="areaId != null">-->
+        <!--                and area_id = #{areaId}-->
+        <!--            </if>-->
         UNION ALL
         SELECT COUNT(*) FROM asr_loc_mast WHERE loc_sts = 'F' or loc_sts = 'P' or loc_sts = 'Q' or loc_sts = 'R' or loc_sts = 'S' or loc_sts = 'X'
-        <if test="areaId != null">
-            and area_id = #{areaId}
-        </if>
+        <!--        <if test="areaId != null">-->
+        <!--            and area_id = #{areaId}-->
+        <!--        </if>-->
         UNION ALL
         SELECT ISNULL(SUM(anfme), 0) FROM asr_loc_detl
-        <if test="areaId != null">
-            WHERE area_id = #{areaId}
-        </if>
+        <!--        <if test="areaId != null">-->
+        <!--            WHERE area_id = #{areaId}-->
+        <!--        </if>-->
         UNION ALL
         SELECT ISNULL(SUM(anfme), 0) FROM asr_wrkin_view WHERE CONVERT(VARCHAR, io_time, 23) = CONVERT(VARCHAR, GETDATE(), 23)
-        <if test="areaId != null">
-            and area_id = #{areaId}
-        </if>
+        <!--        <if test="areaId != null">-->
+        <!--            and area_id = #{areaId}-->
+        <!--        </if>-->
         UNION ALL
         SELECT ISNULL(SUM(anfme), 0) FROM asr_wrkout_view WHERE CONVERT(VARCHAR, io_time, 23) = CONVERT(VARCHAR, GETDATE(), 23)
-        <if test="areaId != null">
-            and area_id = #{areaId}
-        </if>
+        <!--        <if test="areaId != null">-->
+        <!--            and area_id = #{areaId}-->
+        <!--        </if>-->
     </select>
 
     <select id="recentOrder" resultType="com.zy.asrs.entity.digitaltwin.DtOrderVo">
-        SELECT CONVERT(VARCHAR, order_time, 23) as orderDate, COUNT(*) AS orderNum
-        FROM man_order
+
+        SELECT
+        FORMAT(orderDate, 'yyyyMMdd') as orderDate,
+        COUNT(*) as orderNum
+        FROM (
+        SELECT
+        CAST(order_time AS DATE) as orderDate
+        FROM man_order_pakin
         WHERE order_time BETWEEN #{startTime} AND #{endTime}
-        GROUP BY CONVERT(VARCHAR, order_time, 23)
+
+        UNION ALL
+
+        SELECT
+        CAST(order_time AS DATE) as orderDate
+        FROM man_order_pakout
+        WHERE order_time BETWEEN #{startTime} AND #{endTime}
+        ) combined
+        GROUP BY orderDate
+        ORDER BY orderDate
+
     </select>
 
     <select id="recentInBound" resultType="com.zy.asrs.entity.digitaltwin.DtInAndOutBoundVo">
         SELECT CONVERT(VARCHAR, io_time, 23) AS boundDate, SUM(anfme) AS inBoundNum
         FROM asr_wrkin_view
         WHERE io_time BETWEEN #{startTime} AND #{endTime}
-        <if test="areaId != null">
-            and area_id = #{areaId}
-        </if>
+<!--        <if test="areaId != null">-->
+<!--            and area_id = #{areaId}-->
+<!--        </if>-->
         GROUP BY CONVERT(VARCHAR, io_time, 23)
     </select>
 
@@ -52,28 +68,31 @@
         SELECT CONVERT(VARCHAR, io_time, 23) AS boundDate, SUM(anfme) AS outBoundNum
         FROM asr_wrkout_view
         WHERE io_time BETWEEN #{startTime} AND #{endTime}
-        <if test="areaId != null">
-            and area_id = #{areaId}
-        </if>
+<!--        <if test="areaId != null">-->
+<!--            and area_id = #{areaId}-->
+<!--        </if>-->
         GROUP BY CONVERT(VARCHAR, io_time, 23)
     </select>
 
     <select id="recentDetainMat" resultType="com.zy.asrs.entity.digitaltwin.DtDetainMatVo">
-        select
-        *
-        from (
-            select
-                ROW_NUMBER() OVER(Order by t.io_time desc) as row , *
-            from (
-                SELECT area_id AS belongAreaId, area_name AS belongAreaName, matnr AS matId, maktx AS matName,
-                       loc_no AS lokId, '' AS lokName,
-                       DATEDIFF(MINUTE, appe_time, GETDATE()) AS detainTime, appe_time AS inBoundTime
-                    FROM asr_loc_detl WHERE appe_time &lt; #{startTime}
-                <if test="areaId != null">
-                    and area_id = #{areaId}
-                </if>
-                ) t
-        ) a where 1=1 and a.row between ((#{pageIndex}-1)*#{pageSize}+1) and (#{pageIndex}*#{pageSize})
+        SELECT *
+        FROM (
+        SELECT
+        ROW_NUMBER() OVER(ORDER BY t.inBoundTime DESC) AS rownum,
+        t.*
+        FROM (
+        SELECT
+        matnr AS matId,
+        maktx AS matName,
+        loc_no AS lokId,
+        '' AS lokName,
+        DATEDIFF(MINUTE, appe_time, GETDATE()) AS detainTime,
+        appe_time AS inBoundTime
+        FROM asr_loc_detl
+        WHERE appe_time &lt;= #{startTime}
+        ) t
+        ) a
+        WHERE a.rownum BETWEEN ((#{pageIndex}-1)*#{pageSize}+1) AND (#{pageIndex}*#{pageSize})
     </select>
 
 </mapper>

--
Gitblit v1.9.1