自动化立体仓库 - WMS系统
zyh
8 天以前 3eee2147f220634b620b7ed84c97fbd8257205d5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?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.zy.asrs.mapper.DigitalTwinMapper">
 
    <!--总览:总库位、已用库位、今日库存、今日出库、今日入库-->
    <select id="overview" resultType="Double">
        SELECT COUNT(*) FROM asr_loc_mast WHERE loc_sts != 'Z'
        <!--            <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>-->
        UNION ALL
        SELECT ISNULL(SUM(anfme), 0) FROM asr_loc_detl
        <!--        <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>-->
        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>-->
    </select>
 
    <select id="recentOrder" resultType="com.zy.asrs.entity.digitaltwin.DtOrderVo">
 
        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}
 
                 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>-->
        GROUP BY CONVERT(VARCHAR, io_time, 23)
    </select>
 
    <select id="recentOutBound" resultType="com.zy.asrs.entity.digitaltwin.DtInAndOutBoundVo">
        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>-->
        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.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>