lyh
2025-07-02 212eb8010c66c321dcdfc617725b37885573a44e
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
<?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.MdcEfficiencyReportMapper">
 
    <!--查询利用率数据-->
    <select id="efficiencyList" resultType="org.jeecg.modules.mdc.dto.MdcEfficiencyDto">
        SELECT
            t2.equipment_id equipmentId,
            t2.equipment_name equipmentName,
            t2.equipment_type equipmentType,
            t1.the_date theDate,
            t1.process_long processLong,
            t1.process_long / 86400 utilizationRate,
            CASE
                WHEN t1.open_long > 0 THEN
                t1.process_long / t1.open_long ELSE 0
            END startRate,
            t1.open_long / 86400 openRate,
            t1.open_long openLong,
            t1.wait_long waitLong,
            t1.close_long closeLong,
            COALESCE(t3.fault_long, 0) faultLong,
            COALESCE(t3.fault_rate, 0) faultRate,
            COALESCE(t3.remove_fault_run_long, 0) removeFaultRunLong
        FROM
            mdc_equipment t2
            LEFT JOIN mdc_equipment_statistical_info t1 ON t1.equipment_id = t2.equipment_id
            LEFT JOIN mdc_equipment_fault_info t3 ON t2.equipment_id = t3.equipment_id AND t1.the_date = t3.the_date
        WHERE
            t1.the_date &lt;= #{ vo.endTime }
            AND t1.the_date &gt;= #{ vo.startTime }
        <if test="vo.equipmentType != null and vo.equipmentType != '' ">
            AND t2.equipment_type = #{ vo.equipmentType }
        </if>
        <if test="vo.driveType != null and vo.driveType != '' ">
            AND t2.drive_type = #{ vo.driveType }
        </if>
        <if test="vo.deviceLevel != null and vo.deviceLevel != '' ">
            AND t2.device_level = #{vo.deviceLevel}
        </if>
        <if test="vo.deviceCategory != null and vo.deviceCategory != '' ">
            AND t2.device_category = #{vo.deviceCategory}
        </if>
        <if test="vo.equipmentIdList != null and vo.equipmentIdList.size() > 0 ">
            AND t2.equipment_id IN
            <foreach collection="vo.equipmentIdList" item="id" index="index" open="(" close=")" separator=",">
                #{ id }
            </foreach>
        </if>
        ORDER BY t1.the_date
    </select>
 
    <!--查询开动率数据-->
    <select id="efficiencyPOList" resultType="org.jeecg.modules.mdc.dto.MdcEfficiencyDto">
        SELECT
            t2.equipment_id equipmentId,
            t2.equipment_name equipmentName,
            t2.equipment_type equipmentType,
            t1.the_date theDate,
            t1.process_long processLong,
            CASE
                WHEN t1.open_long > 0 THEN
                t1.process_long / t1.open_long ELSE 0
            END utilizationRate,
            CASE
                WHEN t1.open_long > 0 THEN
                t1.process_long / t1.open_long ELSE 0
            END startRate,
            t1.open_long / 86400 openRate,
            t1.open_long openLong,
            t1.wait_long waitLong,
            t1.close_long closeLong,
            COALESCE(t3.fault_long, 0) faultLong,
            COALESCE(t3.fault_rate, 0) faultRate,
            COALESCE(t3.remove_fault_run_long, 0) removeFaultRunLong
        FROM
            mdc_equipment t2
            LEFT JOIN mdc_equipment_statistical_info t1 ON t1.equipment_id = t2.equipment_id
            LEFT JOIN mdc_equipment_fault_info t3 ON t2.equipment_id = t3.equipment_id AND t1.the_date = t3.the_date
        WHERE
            t1.the_date &lt;= #{ vo.endTime }
            AND t1.the_date &gt;= #{ vo.startTime }
        <if test="vo.equipmentType != null and vo.equipmentType != '' ">
            AND t2.equipment_type = #{ vo.equipmentType }
        </if>
        <if test="vo.driveType != null and vo.driveType != '' ">
            AND t2.drive_type = #{ vo.driveType }
        </if>
        <if test="vo.deviceLevel != null and vo.deviceLevel != '' ">
            AND t2.device_level = #{vo.deviceLevel}
        </if>
        <if test="vo.deviceCategory != null and vo.deviceCategory != '' ">
            AND t2.device_category = #{vo.deviceCategory}
        </if>
        <if test="vo.equipmentIdList != null and vo.equipmentIdList.size() > 0 ">
            AND t2.equipment_id IN
            <foreach collection="vo.equipmentIdList" item="id" index="index" open="(" close=")" separator=",">
                #{ id }
            </foreach>
        </if>
        ORDER BY t1.the_date
    </select>
 
    <!--得到所有班次数据之和-->
    <select id="efficiencyShiftSumList" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalShiftInfo">
        SELECT
            t2.equipment_id equipmentId,
            t2.equipment_name equipmentName,
            t2.equipment_type equipmentType,
            t1.the_date theDate,
            t1.shift_id shiftId,
            t1.shift_sub_id shiftSubId,
            SUM ( t1.process_long ) processLong,
            SUM ( t1.open_long ) openLong,
            SUM ( t1.wait_long ) waitLong,
            SUM ( t1.close_long ) closeLong,
            sum ( t1.total_long ) totalLong
        FROM
            mdc_equipment t2
            LEFT JOIN mdc_equipment_statistical_shift_info t1 ON t1.equipment_id = t2.equipment_id
        <where>
            AND t1.the_date &lt;= #{ vo.endTime }
            AND t1.the_date &gt;= #{ vo.startTime }
            <if test="vo.equipmentIdList != null and vo.equipmentIdList.size() > 0 ">
                AND t2.equipment_id IN
                <foreach collection="vo.equipmentIdList" item="id" index="index" open="(" close=")" separator=",">
                    #{ id }
                </foreach>
            </if>
            <if test="vo.shiftId != null and vo.shiftId != ''">
                AND t1.shift_id = #{ vo.shiftId }
            </if>
            <if test="vo.shiftSubId != null and vo.shiftSubId != ''">
                AND t1.shift_sub_id = #{ vo.shiftSubId }
            </if>
            <if test="vo.equipmentType != null and vo.equipmentType != '' ">
                AND t2.equipment_type = #{ vo.equipmentType }
            </if>
            <if test="vo.driveType != null and vo.driveType != '' ">
                AND t2.drive_type = #{ vo.driveType }
            </if>
            <if test="vo.deviceLevel != null and vo.deviceLevel != '' ">
                AND t2.device_level = #{vo.deviceLevel}
            </if>
            <if test="vo.deviceCategory != null and vo.deviceCategory != '' ">
                AND t2.device_category = #{vo.deviceCategory}
            </if>
        </where>
        GROUP BY
            t2.equipment_id,
            t2.equipment_name,
            t2.equipment_type,
            t1.the_date,
            t1.shift_id,
            t1.shift_sub_id
        ORDER BY
            t1.the_date
    </select>
 
    <!--查询原始数据-->
    <select id="comparativeAnalysis" resultType="org.jeecg.modules.mdc.dto.MdcComAnaDto">
        SELECT
            mesi.equipment_id equipmentId,
            SUM ( mesi.open_long ) openLong,
            SUM ( mesi.close_long ) closeLong,
            SUM ( mesi.wait_long ) waitLong,
            SUM ( mesi.process_long ) processLong
        FROM
            mdc_equipment_statistical_info mesi
            LEFT JOIN mdc_equipment me ON mesi.equipment_id = me.equipment_id
        <where>
            <if test="vo.equipmentIdList != null and vo.equipmentIdList.size() > 0 ">
                AND mesi.equipment_id IN
                <foreach collection="vo.equipmentIdList" item="id" index="index" open="(" close=")" separator=",">
                    #{ id }
                </foreach>
            </if>
            <if test="vo.driveType != null and vo.driveType != null">
                AND me.drive_type = #{ vo.driveType }
            </if>
            AND mesi.the_date BETWEEN #{ vo.startTime } AND #{ vo.endTime }
        </where>
        GROUP BY
            mesi.equipment_id
    </select>
 
 
    <select id="getEfficiencyRate" resultType="java.math.BigDecimal">
        SELECT
            process_long
        FROM
            mdc_equipment_statistical_info
        WHERE
            equipment_id = #{ equipmentId } AND the_date &gt;= #{ date }
        ORDER BY the_date ASC
    </select>
 
    <select id="equipmentEfficiencyAnalyze" resultType="org.jeecg.modules.mdc.dto.EquipmentEfficiencyAnalyzeDto">
        SELECT
            t3.equipment_name,
            t1.utilization_rate AS utilizationRate,
            t2.utilization_rate AS shiftUtilizationRate,
            t1.remove_fault_rate AS amendUtilizationRate
        FROM
            mdc_equipment_statistical_info_month t1
                LEFT JOIN mdc_equipment_statistical_shift_info_month t2 ON t1.the_month = t2.the_month AND t2.shift_type = 1
                AND t1.equipment_id = t2.equipment_id
                LEFT JOIN mdc_equipment t3 ON t3.equipment_id = t1.equipment_id
        WHERE
            t1.equipment_id IN
            <foreach collection="equipmentIdList" item="id" index="index" open="(" close=")" separator=",">
                #{id}
            </foreach>
            AND t1.the_month = #{month}
        ORDER BY
            t1.utilization_rate DESC
    </select>
 
    <select id="teamEquipmentEfficiencyAnalyze" resultType="org.jeecg.modules.mdc.dto.TeamEquEffDto">
        SELECT
            t3.team_code AS teamCode,
            t1.utilization_rate AS utilizationRate,
            t2.utilization_rate AS shiftUtilizationRate,
            t1.remove_fault_rate AS amendUtilizationRate
        FROM
            mdc_equipment_statistical_info_month t1
                LEFT JOIN mdc_equipment_statistical_shift_info_month t2 ON t1.the_month = t2.the_month AND t2.shift_type = 1
                AND t1.equipment_id = t2.equipment_id
                LEFT JOIN mdc_equipment t3 ON t3.equipment_id = t1.equipment_id
        WHERE
            t1.equipment_id IN
            <foreach collection="equipmentIdList" item="id" index="index" open="(" close=")" separator=",">
                #{id}
            </foreach>
            AND t1.the_month = #{month}
    </select>
 
    <select id="comprehensiveRateAnalyze" resultType="org.jeecg.modules.mdc.dto.ComRateDto">
        SELECT
            t1.the_month AS theMonth,
            AVG ( t1.utilization_rate ) AS utilizationRate,
            AVG ( t2.utilization_rate ) AS shiftUtilizationRate,
            AVG ( t1.remove_fault_rate ) AS amendUtilizationRate,
            SUM ( t1.process_long ) AS processLong
        FROM
            mdc_equipment_statistical_info_month t1
                LEFT JOIN mdc_equipment_statistical_shift_info_month t2 ON t1.the_month = t2.the_month
                AND t1.equipment_id = t2.equipment_id
                AND t2.shift_type = 1
                LEFT JOIN mdc_equipment t3 ON t3.equipment_id = t1.equipment_id
        WHERE
            t1.equipment_id IN
            <foreach collection="equipmentIdList" item="id" index="index" open="(" close=")" separator=",">
                #{id}
            </foreach>
            AND t1.the_month BETWEEN #{start} AND #{end}
        GROUP BY
            t1.the_month
        ORDER BY
            t1.the_month
    </select>
 
    <select id="comprehensiveShiftRateAnalyze" resultType="org.jeecg.modules.mdc.dto.ComShiftRateDto">
        SELECT
            t1.the_month AS theMonth,
            t1.shift_sub AS shiftSub,
            t2.shift_sub_name AS shiftSubName,
            AVG ( t1.utilization_rate ) AS utilizationRate
        FROM
            mdc_equipment_statistical_shift_info_month t1
                LEFT JOIN mdc_shift_sub t2 ON t1.shift_sub = t2.id
        WHERE
            t2.shift_id = #{shiftId}
            AND t1.equipment_id IN
            <foreach collection="equipmentIdList" item="id" index="index" open="(" close=")" separator=",">
                #{id}
            </foreach>
            AND t1.the_month BETWEEN #{start} AND #{end}
            AND t1.shift_type = 2
        GROUP BY
            t1.the_month,
            t1.shift_sub,
            t2.shift_sub_name
    </select>
</mapper>