Lius
2025-06-17 777dded0826a78d09e050f69652dcbba9676bd8a
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
<?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.MdcEquipmentRunningSectionMapper">
 
    <!--查询单台设备最后时间段记录(非报警)-->
    <select id="getMaxNormal" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentRunningSection">
        SELECT TOP 1 * FROM mdc_equipment_running_section WHERE equipment_id = #{equipmentId} AND status <![CDATA[ <> ]]> '22' ORDER BY end_time DESC
    </select>
 
    <!--获取计算段时间后的最后一条记录(报警)-->
    <select id="getMaxError" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentRunningSection">
        SELECT TOP 1 * FROM mdc_equipment_running_section WHERE equipment_id = #{equipmentId} AND status = '22' ORDER BY end_time DESC
    </select>
 
    <!--获取设备运行记录最早的数据-->
    <select id="getFirstData" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentRunningSection">
        SELECT TOP 1 * FROM mdc_equipment_running_section WHERE equipment_id = #{equipmentId} ORDER BY start_time
    </select>
 
    <!--查询设备单日运行状态时间段记录-->
    <select id="listForEquipmentStatisticalInfo" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentRunningSection">
        SELECT
            *
        FROM
            mdc_equipment_running_section
        WHERE
            equipment_id = #{ equipmentId }
            AND  (start_time &lt;= #{ endDate } AND end_time &gt;= #{ startDate })
        ORDER BY
            start_time
    </select>
 
    <!--计算一段时间内的数据-->
    <select id="listEquipmentRunningSection" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentRunningSection">
        SELECT
            *
        FROM
            mdc_equipment_running_section
        WHERE
            equipment_id = #{ equipmentId }
            AND  (start_long &lt;= #{ endLong } AND end_long &gt;= #{ startLong })
        ORDER BY
            start_time
    </select>
 
    <!--计算一段时间内的运行数据-->
    <select id="listEquipmentRunningSectionRun" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentRunningSection">
        SELECT
            *
        FROM
            mdc_equipment_running_section
        WHERE
            equipment_id = #{ equipmentId }
            AND status <![CDATA[ <> ]]> '22'
            AND  (start_long &lt;= #{ endLong } AND end_long &gt;= #{ startLong })
        ORDER BY
            start_time
    </select>
 
    <!--计算一段时间内的故障数据-->
    <select id="listEquipmentRunningSectionError" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentRunningSection">
        SELECT
            *
        FROM
            mdc_equipment_running_section
        WHERE
            equipment_id = #{ equipmentId }
            AND status = '22'
            AND  (start_long &lt;= #{ endLong } AND end_long &gt;= #{ startLong })
        ORDER BY
            start_time
    </select>
 
    <!--查询一段时间内的报警数据-->
    <select id="findAlarmList" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentRunningSection">
        SELECT
            *
        FROM
            mdc_equipment_running_section
        <where>
            <if test="vo.equipmentIdList != null and vo.equipmentIdList.size() > 0 ">
                AND equipment_id IN
                <foreach collection="vo.equipmentIdList" item="id" index="index" open="(" close=")" separator=",">
                    #{ id }
                </foreach>
            </if>
            AND (start_time &lt;= #{ vo.endDate } AND end_time &gt;= #{ vo.startDate })
            AND status = '22'
            AND alarm != ''
        </where>
        ORDER BY
            start_time
    </select>
 
    <!--查询数量-->
    <select id="findAlarmCount" resultType="java.lang.Integer">
        SELECT
            COUNT(*)
        FROM
            mdc_equipment_running_section
        <where>
            AND status = '22'
            AND alarm = #{ alarmCode }
            AND (start_time &lt;= #{ endDate } AND end_time &gt;= #{ startDate })
            AND equipment_id = #{ equipmentId }
        </where>
    </select>
 
    <!--根据日期查询数量-->
    <select id="findAlarmCountByDate" resultType="java.lang.Integer">
        SELECT
            COUNT(*)
        FROM
            mdc_equipment_running_section
        <where>
            AND status = '22'
            AND alarm = #{ vo.alarmCode }
            AND (start_time &lt;= #{ endDate } AND end_time &gt;= #{ startDate })
            <if test="vo.equipmentIdList != null and vo.equipmentIdList.size() > 0 ">
                AND equipment_id IN
                <foreach collection="vo.equipmentIdList" item="id" index="index" open="(" close=")" separator=",">
                    #{ id }
                </foreach>
            </if>
        </where>
    </select>
 
    <!--查询时间段内运行数据-->
    <select id="selectRunningData" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentRunningSection">
        SELECT
            *
        FROM
            mdc_equipment_running_section
        WHERE
            equipment_id = #{ equipmentId }
          AND status = '3'
          AND  (start_time &lt;= #{ endDate } AND end_time &gt;= #{ startDate })
        ORDER BY
            start_time
    </select>
 
    <!--查询报警号报警详细信息-->
    <select id="selectAlarmList" resultType="org.jeecg.modules.mdc.dto.MdcAlarmListDto">
        SELECT
            t1.equipment_id,
            t2.equipment_name,
            t1.start_time,
            t1.end_time,
            t1.duration
        FROM
            mdc_equipment_running_section t1 LEFT JOIN mdc_equipment t2 ON t1.equipment_id = t2.equipment_id
        <where>
            AND t1.status = '22'
            AND t1.alarm = #{ vo.alarmCode }
            AND (t1.start_time &lt;= #{ endDate } AND t1.end_time &gt;= #{ startDate })
            <if test="vo.equipmentIdList != null and vo.equipmentIdList.size() > 0 ">
                AND t1.equipment_id IN
                <foreach collection="vo.equipmentIdList" item="id" index="index" open="(" close=")" separator=",">
                    #{ id }
                </foreach>
            </if>
        </where>
    </select>
 
    <select id="getDataList" resultType="java.lang.Integer">
        SELECT
            status
        FROM
            mdc_equipment_running_section
        WHERE
            equipment_id = #{ equipmentId }
          AND start_time &gt; #{date}
          AND status IS NOT NULL
    </select>
 
    <select id="findWaitList" resultType="org.jeecg.modules.mdc.dto.MdcEquipmentWaitSectionDto">
        SELECT
            t1.*,
            t2.equipment_name
        FROM
            mdc_equipment_running_section t1
                LEFT JOIN mdc_equipment t2 ON t1.equipment_id = t2.equipment_id
        WHERE
            duration > 1200
          AND status = 2
          AND CONVERT ( VARCHAR, start_time, 120 ) LIKE CONCAT(#{date},'%')
        ORDER BY
            equipment_id, start_time DESC
    </select>
 
    <select id="findFaultList" resultType="org.jeecg.modules.mdc.vo.EquFaultRecord">
        SELECT
            t3.equipment_code equipmentId,
            t1.fault_start_time startTime,
            t2.actual_end_time endTime
        FROM
            eam_report_repair t1
                LEFT JOIN eam_repair_order t2 ON t2.report_id = t1.id
                LEFT JOIN eam_equipment t3 ON t1.equipment_id = t3.id
        WHERE
            (
                ( t1.fault_start_time BETWEEN #{startTime} AND #{endTime} )
                OR ( t2.actual_end_time BETWEEN #{startTime} AND #{endTime} )
                OR ( t1.fault_start_time &lt; #{startTime} AND t2.actual_end_time IS NULL )
            )
          AND t3.equipment_code = #{equipmentId}
          AND t1.report_status != 'ABOLISH'
    </select>
 
 
</mapper>