hyingbo
6 天以前 e935889261ef38c8eaef31e54cbfc466d63d2ef4
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?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="org.jeecg.modules.mdc.mapper.MdcHomeMapper">
 
    <select id="getProductionByPid" resultType="org.jeecg.modules.system.entity.MdcProduction">
        SELECT
            t1.*
        FROM
            mdc_production t1
                LEFT JOIN mdc_user_production t2 ON t1.id = t2.pro_id
        WHERE
            t1.parent_id = #{ productionId } AND t2.user_id = #{ userId }
    </select>
 
    <select id="getProcessCount" resultType="java.math.BigDecimal">
        SELECT
            SUM(process_long)
        FROM
            mdc_equipment_statistical_info
        <where>
            <if test="equipmentIdList != null and equipmentIdList.size() > 0 ">
                AND equipment_id IN
                <foreach collection="equipmentIdList" index="index" item="id" open="(" separator="," close=")">
                    #{id}
                </foreach>
            </if>
            AND the_date = #{ date }
        </where>
    </select>
 
    <select id="getOeeByDate" resultType="java.math.BigDecimal">
        SELECT
            SUM(overall_equipment_efficiency)
        FROM
            mdc_overall_equipment_efficiency
        <where>
            <if test="equipmentIdList != null and equipmentIdList.size() > 0 ">
                AND equipment_id IN
                <foreach collection="equipmentIdList" index="index" item="id" open="(" separator="," close=")">
                    #{id}
                </foreach>
            </if>
            AND valid_date = #{ date }
        </where>
    </select>
 
    <select id="getUtilizationByMonth" resultType="java.util.Map">
        SELECT
            SUM(process_long) processLong,
            SUM(open_long) openLong,
            COUNT(*) processDay
        FROM
            mdc_equipment_statistical_info
        <where>
            <if test="equipmentIdList != null and equipmentIdList.size() > 0 ">
                AND equipment_id IN
                <foreach collection="equipmentIdList" index="index" item="id" open="(" separator="," close=")">
                    #{id}
                </foreach>
            </if>
            AND the_date LIKE CONCAT('%', #{ date } ,'%')
        </where>
    </select>
 
    <select id="getEquipmentDayUtilizationStatistics" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalInfo">
        SELECT
            the_date,
            SUM ( process_long ) processLong,
            SUM ( open_long ) openLong
        FROM
            mdc_equipment_statistical_info
        <where>
            <if test="equipmentIdList != null and equipmentIdList.size() > 0 ">
                AND equipment_id IN
                <foreach collection="equipmentIdList" index="index" item="id" open="(" separator="," close=")">
                    #{id}
                </foreach>
            </if>
            <if test="dateList != null and dateList.size() > 0 ">
                AND the_date IN
                <foreach collection="dateList" index="index" item="date" open="(" separator="," close=")">
                    #{date}
                </foreach>
            </if>
        </where>
        GROUP BY
            the_date
    </select>
 
    <select id="getEquipmentOEEMonthStatistics" resultType="org.jeecg.modules.mdc.entity.MdcOverallEquipmentEfficiency">
        SELECT
            *
        FROM
            mdc_overall_equipment_efficiency
        <where>
            AND valid_date = #{validDate}
            <if test="equipmentIdList != null and equipmentIdList.size() > 0 ">
                AND equipment_id IN
                <foreach collection="equipmentIdList" index="index" item="id" open="(" separator="," close=")">
                    #{id}
                </foreach>
            </if>
        </where>
    </select>
 
    <select id="getUtilizationByDay" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalInfo">
        SELECT
            the_date,
            SUM ( process_long ) processLong,
            SUM ( open_long ) openLong
        FROM
            mdc_equipment_statistical_info
        <where>
            AND the_date = #{date}
            <if test="equipmentIdList != null and equipmentIdList.size() > 0 ">
                AND equipment_id IN
                <foreach collection="equipmentIdList" index="index" item="id" open="(" separator="," close=")">
                    #{id}
                </foreach>
            </if>
        </where>
        GROUP BY
            the_date
    </select>
 
    <select id="getEquipmentSevenUtilizationStatistics" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalInfo">
        SELECT
            equipment_id,
            SUM ( process_long ) processLong,
            SUM ( open_long ) openLong
        FROM
            mdc_equipment_statistical_info
        <where>
            AND the_date BETWEEN #{start} AND #{end}
            <if test="equipmentIdList != null and equipmentIdList.size() > 0 ">
                AND equipment_id IN
                <foreach collection="equipmentIdList" index="index" item="id" open="(" separator="," close=")">
                    #{id}
                </foreach>
            </if>
        </where>
        GROUP BY
            equipment_id
    </select>
 
 
    <select id="getEquipmentList" resultType="org.jeecg.modules.mdc.entity.MdcEquipment">
        SELECT
            t1.*
        FROM
            mdc_equipment t1
                LEFT JOIN mdc_production_equipment t2 ON t1.id = t2.equipment_id
        WHERE
            t2.production_id = #{productionId}
    </select>
 
 
</mapper>