4 天以前 06321d70dd7617fdc7d475b190e629143fec3263
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
<?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="cn.iocoder.yudao.module.mes.dal.mysql.home.MesBagCodeHomeStatisticsMapper">
 
    <!-- ========== 基础数据 ========== -->
 
    <!-- 统计品种总数(mdm_item) -->
    <select id="selectMdmItemCount" resultType="java.lang.Long">
        SELECT COUNT(*)
        FROM mdm_item
        WHERE deleted = 0
    </select>
 
    <!-- 统计 MES 品种数(mes_md_item) -->
    <select id="selectMesItemCount" resultType="java.lang.Long">
        SELECT COUNT(*)
        FROM mes_md_item
        WHERE deleted = 0
    </select>
 
    <!-- 统计品种分类数(mes_md_item_type) -->
    <select id="selectItemTypeCount" resultType="java.lang.Long">
        SELECT COUNT(*)
        FROM mes_md_item_type
        WHERE deleted = 0
    </select>
 
    <!-- 统计计量单位数(mdm_unit_measure) -->
    <select id="selectUnitMeasureCount" resultType="java.lang.Long">
        SELECT COUNT(*)
        FROM mdm_unit_measure
        WHERE deleted = 0
    </select>
 
    <!-- ========== 一袋一码 ========== -->
 
    <!-- 统计产线数(mes_pro_line) -->
    <select id="selectLineCount" resultType="java.lang.Long">
        SELECT COUNT(*)
        FROM mes_pro_line
        WHERE deleted = 0
    </select>
 
    <!-- 统计批次总数(mes_pro_batch) -->
    <select id="selectBatchCount" resultType="java.lang.Long">
        SELECT COUNT(*)
        FROM mes_pro_batch
        WHERE deleted = 0
    </select>
 
    <!-- 统计袋码总数(mes_pro_bag_code) -->
    <select id="selectBagCodeCount" resultType="java.lang.Long">
        SELECT COUNT(*)
        FROM mes_pro_bag_code
        WHERE deleted = 0
    </select>
 
    <!-- 统计托盘码总数(mes_pro_pallet) -->
    <select id="selectPalletCount" resultType="java.lang.Long">
        SELECT COUNT(*)
        FROM mes_pro_pallet
        WHERE deleted = 0
    </select>
 
    <!-- ========== 状态分布 ========== -->
 
    <!-- 按状态统计批次数量 -->
    <select id="selectBatchCountGroupByStatus" resultType="java.util.Map">
        SELECT status, COUNT(*) AS count
        FROM mes_pro_batch
        WHERE deleted = 0
        GROUP BY status
    </select>
 
    <!-- 按状态统计袋码数量 -->
    <select id="selectBagCodeCountGroupByStatus" resultType="java.util.Map">
        SELECT status, COUNT(*) AS count
        FROM mes_pro_bag_code
        WHERE deleted = 0
        GROUP BY status
    </select>
 
    <!-- 按天聚合袋码生成量 -->
    <select id="selectDailyBagCodeTrend" resultType="java.util.Map">
        SELECT DATE_FORMAT(create_time, '%Y-%m-%d') AS date,
               COUNT(*)                              AS count
        FROM mes_pro_bag_code
        WHERE deleted = 0
          AND create_time >= #{beginTime}
          <if test="endTime != null">
              AND create_time &lt; #{endTime}
          </if>
        GROUP BY DATE_FORMAT(create_time, '%Y-%m-%d')
        ORDER BY date
    </select>
 
</mapper>