Lius
2025-03-03 5ae1b71ab6b57140d46e6a8b9e606bb4a390ce27
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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
<?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.MdcEquipmentMapper">
 
    <!--查询设备的所属部门名称信息-->
    <select id="getDepNamesByEquipmentIds" resultType="org.jeecg.modules.mdc.vo.MdcEquipmentDepVo">
        SELECT d.depart_name, ed.equipment_id FROM mdc_equipment_depart ed, sys_depart d WHERE d.id = ed.dep_id AND ed.equipment_id IN
        <foreach collection="equipmentIds" index="index" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
    </select>
 
    <!--查询设备的所属产线名称信息-->
    <select id="getProNamesByEquipmentIds" resultType="org.jeecg.modules.mdc.vo.MdcEquipmentProVo">
        SELECT p.production_name, pe.equipment_id FROM mdc_production_equipment pe, mdc_production p WHERE p.id = pe.production_id AND pe.equipment_id IN
        <foreach collection="equipmentIds" index="index" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
    </select>
 
    <!--根据部门id查询设备列表-->
    <select id="pageListByDepId" resultType="org.jeecg.modules.mdc.entity.MdcEquipment">
        SELECT
            me.*
        FROM
            mdc_equipment_depart med,
            mdc_equipment me
        WHERE
            med.equipment_id = me.id
            AND med.dep_id = #{ departId }
        <if test="equipmentId != null and equipmentId != '' ">
            AND me.equipment_id = #{equipmentId}
        </if>
    </select>
 
    <!--根据产线id查询设备列表-->
    <select id="pageListByProId" resultType="org.jeecg.modules.mdc.entity.MdcEquipment">
        SELECT
            me.*
        FROM
            mdc_production_equipment mpe,
            mdc_equipment me
        WHERE
            mpe.equipment_id = me.id
            AND mpe.production_id = #{ productionId }
        <if test="equipmentId != null and equipmentId != '' ">
            AND me.equipment_id = #{equipmentId}
        </if>
    </select>
 
    <!--根据部门id查询设备-->
    <select id="queryByDepartId" resultType="org.jeecg.modules.mdc.entity.MdcEquipment">
        SELECT
            me.*
        FROM
            mdc_equipment_depart med,
            mdc_equipment me
        WHERE
            med.equipment_id = me.id
            AND med.dep_id = #{ departId }
        ORDER BY me.equipment_id
    </select>
 
    <!--根据产线id查询设备-->
    <select id="queryByProductionId" resultType="org.jeecg.modules.mdc.entity.MdcEquipment">
        SELECT
            me.*
        FROM
            mdc_production_equipment mpe,
            mdc_equipment me
        WHERE
            mpe.equipment_id = me.id
            AND mpe.production_id = #{ productionId }
        ORDER BY me.equipment_id
    </select>
 
    <!--根据产线id查询设备id集合-->
    <select id="queryIdsByProductions" resultType="java.lang.String">
        SELECT
            me.equipment_id
        FROM
            mdc_equipment me
            LEFT JOIN mdc_production_equipment mpe ON me.id = mpe.equipment_id
        WHERE
            mpe.production_id IN
        <foreach collection="allProductionIds" index="index" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
    </select>
 
    <!--查询设备监控信息-->
    <select id="checkStatusFromEquipmentIds" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentMonitor">
        SELECT
            t1.equipment_id,
            t2.CollectTime,
            t1.equipment_name,
            t2.Oporation,
            t1.id,
            t1.equipment_status,
            t1.equipment_type equipmentType,
            t3.equipment_type_pictures
        FROM
            mdc_equipment t1
            LEFT JOIN Equipment t2 ON t1.equipment_id = t2.EquipmentID
            LEFT JOIN mdc_equipment_type t3 ON t1.equipment_type = t3.equipment_type_name
        WHERE equipment_id IN
        <foreach collection="equipmentIds" index="index" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
        ORDER BY t1.equipment_id
    </select>
 
    <!--根据部门id查询设备id集合-->
    <select id="queryIdsByDeparts" resultType="java.lang.String">
        SELECT
            me.equipment_id
        FROM
            mdc_equipment me
            LEFT JOIN mdc_equipment_depart med ON me.id = med.equipment_id
        WHERE
        med.dep_id IN
        <foreach collection="allDepartIds" index="index" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
    </select>
 
    <!--根据设备编号查询设备信息和部门信息-->
    <select id="findEquDepList" resultType="org.jeecg.modules.mdc.dto.MdcEquDepDto">
        SELECT
            sd.id,
            sd.parent_id,
            sd.depart_name,
            sd.org_type,
            me.equipment_id,
            me.equipment_name,
            me.equipment_type
        FROM
            mdc_equipment_depart med
            LEFT JOIN sys_depart sd ON med.dep_id = sd.id
            LEFT JOIN mdc_equipment me ON me.id = med.equipment_id
        <where>
            me.equipment_id IN
            <foreach collection="equipmentIdList" index="index" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
            AND me.equipment_status = 0
        </where>
        ORDER BY sd.depart_order
    </select>
 
    <!--根据设备编号查询设备信息和产线信息-->
    <select id="findEquProList" resultType="org.jeecg.modules.mdc.dto.MdcEquProDto">
        SELECT
            mp.id,
            mp.parent_id,
            mp.production_name,
            mp.org_type,
            me.equipment_id,
            me.equipment_name,
            me.equipment_type
        FROM
            mdc_production_equipment mpe
            LEFT JOIN mdc_production mp ON mpe.production_id = mp.id
            LEFT JOIN mdc_equipment me ON me.id = mpe.equipment_id
        <where>
            me.equipment_id IN
            <foreach collection="equipmentIdList" index="index" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
            AND me.equipment_status = 0
        </where>
        ORDER BY mp.production_order
    </select>
 
    <!--根据大屏车间id查询设备列表-->
    <select id="getEquipmentByWorkshopId" resultType="org.jeecg.modules.mdc.entity.MdcEquipment">
        SELECT
            me.*
        FROM
            mdc_workshop_equipment mwe
            LEFT JOIN mdc_equipment me ON me.equipment_id = mwe.equipment_id
        <where>
            AND mwe.workshop_id = #{ workshopEquipmentVo.workshopId }
            <if test="workshopEquipmentVo.equipmentId != null and workshopEquipmentVo.equipmentId != ''">
                AND mwe.equipment_id = #{ workshopEquipmentVo.equipmentId }
            </if>
        </where>
        ORDER BY me.equipment_id
    </select>
 
    <!--分页列表-->
    <select id="pageList" 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
            LEFT JOIN mdc_production t3 ON t2.production_id = t3.id
        <where>
            <if test="mdcEquipment.equipmentId != null and mdcEquipment.equipmentId != '' ">
                AND t1.equipment_id LIKE CONCAT(CONCAT('%',#{mdcEquipment.equipmentId}),'%')
            </if>
            <if test="mdcEquipment.equipmentName != null and mdcEquipment.equipmentName != '' ">
                AND t1.equipment_name LIKE CONCAT(CONCAT('%',#{mdcEquipment.equipmentName}),'%')
            </if>
            <if test="mdcEquipment.equipmentModel != null and mdcEquipment.equipmentModel != '' ">
                AND t1.equipment_name = #{mdcEquipment.equipmentModel}
            </if>
            <if test="mdcEquipment.equipmentType != null and mdcEquipment.equipmentType != '' ">
                AND t1.equipmentType = #{mdcEquipment.equipmentType}
            </if>
            <if test="mdcEquipment.driveType != null and mdcEquipment.driveType != '' ">
                AND t1.drive_type = #{mdcEquipment.driveType}
            </if>
            <if test="mdcEquipment.deviceLevel != null and mdcEquipment.deviceLevel != '' ">
                AND t1.device_level = #{mdcEquipment.deviceLevel}
            </if>
            <if test="mdcEquipment.deviceCategory != null and mdcEquipment.deviceCategory != '' ">
                AND t1.device_category = #{mdcEquipment.deviceCategory}
            </if>
            <if test="mdcEquipment.productionIds != null and mdcEquipment.productionIds.size() > 0 ">
                AND t3.id IN
                <foreach collection="mdcEquipment.productionIds" index="index" item="id" open="(" separator="," close=")">
                    #{id}
                </foreach>
            </if>
        </where>
        order by t1.sort_no
    </select>
 
    <select id="exportXlsList" 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
            LEFT JOIN mdc_production t3 ON t2.production_id = t3.id
        <where>
            <if test="mdcEquipment.equipmentId != null and mdcEquipment.equipmentId != '' ">
                AND t1.equipment_id LIKE CONCAT(CONCAT('%',#{mdcEquipment.equipmentId}),'%')
            </if>
            <if test="mdcEquipment.equipmentName != null and mdcEquipment.equipmentName != '' ">
                AND t1.equipment_name LIKE CONCAT(CONCAT('%',#{mdcEquipment.equipmentName}),'%')
            </if>
            <if test="mdcEquipment.equipmentModel != null and mdcEquipment.equipmentModel != '' ">
                AND t1.equipment_name = #{mdcEquipment.equipmentModel}
            </if>
            <if test="mdcEquipment.equipmentType != null and mdcEquipment.equipmentType != '' ">
                AND t1.equipment_type = #{mdcEquipment.equipmentType}
            </if>
            <if test="mdcEquipment.driveType != null and mdcEquipment.driveType != '' ">
                AND t1.drive_type = #{mdcEquipment.driveType}
            </if>
            <if test="mdcEquipment.productionIds != null and mdcEquipment.productionIds.size() > 0 ">
                AND t3.id IN
                <foreach collection="mdcEquipment.productionIds" index="index" item="id" open="(" separator="," close=")">
                    #{id}
                </foreach>
            </if>
        </where>
        order by t1.sort_no
    </select>
 
    <!--查询单表数据-->
    <select id="findWorkLineLast" resultType="org.jeecg.modules.mdc.dto.MdcEquipmentDto">
        select top 1 spindlespeed, actualspindlespeed from [${tableName}] order by CollectTime  desc
    </select>
 
    <!--根据id获取设备信息-->
    <select id="findById" resultType="org.jeecg.modules.mdc.dto.MdcEquipmentDetailedDto">
        SELECT
            t1.*,
            t2.MaxAxis maxAxis,
            t2.ValidAxis validAxis
        FROM
            mdc_equipment t1
                LEFT JOIN EquipmentBaseInfo t2 ON t1.equipment_id = t2.EquipmentID
        WHERE
            t1.id = #{ id }
    </select>
 
    <!--根据产线id获取设备状态列表-->
    <select id="getEquipmentMonitorList" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentMonitor">
        SELECT e.equipment_id,
               et.CollectTime,
               e.equipment_name,
               et.Oporation,
               e.id,
               e.equipment_status,
               e.equipment_type AS equipmentType,
               etp.equipment_type_pictures
        FROM mdc_equipment e
                 LEFT JOIN Equipment et ON e.equipment_id = et.EquipmentID
                 LEFT JOIN mdc_equipment_type etp ON e.equipment_type = etp.equipment_type_name
                 JOIN mdc_workshop_equipment we ON e.equipment_id = we.equipment_id
        WHERE we.workshop_id = #{workshopId}
    </select>
 
</mapper>