yangys
2025-11-18 8e944cfabb253fc2556588e308e282586043f7b0
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
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
<?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="com.qianwen.smartman.modules.smis.mapper.MachineMapper">
 
    <update id="changeCollectSwitch">
        UPDATE blade_machine m,
            blade_workstation w,
            blade_workstation_of_machine wm
        SET m.collect_switch = #{collectSwitch}
        WHERE w.id = wm.workstation_id
          AND m.id = wm.machine_id
          AND w.tenant_id = #{tenantId}
          AND w.id = #{workstationId};
    </update>
 
    <select id="typeAndonRecord" resultType="int">
        select count(*)
        from blade_andon_record bar
                 left join blade_device_andon_type bdat on bar.type_id = bdat.andon_type_id and bdat.is_deleted = 0
                 left join blade_machine bm on bm.machine_type_id = bdat.device_type_id and bm.is_deleted = 0
        where bar.is_deleted = 0
          and bar.cur_status in (1, 2)
          and bm.id in
        <foreach collection="ids" index="index" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
    </select>
 
    <select id="selectMachineDetail" resultType="com.qianwen.smartman.modules.smis.vo.MachineDetailVO">
        select bm.id,
               bm.tenant_id              tenantId,
               bm.extend_id              extendId,
               machine_code              machineCode,
               machine_name              machineName,
               machine_model             machineModel,
               machine_life_status       machineLifeStatus,
               machine_use_status        machineUseStatus,
               factory_no                factoryNo,
               assets_code               assetsCode,
               brand,
               nameplate,
               bm.avatar,
               serial_no                 serialNo,
               factory_file              factoryFile,
               manufacturer,
               country_of_manufacture    countryOfManufacture,
               system_name               systemName,
               software_version          softwareVersion,
               net_weight                netWeight,
               power,
               voltage,
               dimensions,
               production_time           productionTime,
               delivery_time             deliveryTime,
               depreciation_year         depreciationYear,
               turn_to_fixed_assets_time turnToFixedAssetsTime,
               invoice_value             invoiceValue,
               ovfa,
               net_asset_value           netAssetValue,
               bm.organization_id        organizationId,
               bcg2.name                 organizationName,
               production_line           productionLine,
               management_class          managementClass,
               elaborate_equipment       elaborateEquipment,
               bm.pin_code               pinCode,
               short_code                shortCode,
               installation_location     installationLocation,
               bm.remark,
               machine_type_id           machineTypeId,
               bdt.name                  machineTypeName,
               bdt.code                  machineTypeCode,
               bm.group_id               groupId,
               bcg1.name                 groupName,
               bm.employee_id            employeeId,
               be.name                   employeeName,
               bm.status                 status
        from blade_machine bm
                 LEFT JOIN blade_device_type bdt on bm.machine_type_id = bdt.id and bdt.is_deleted = 0
                 LEFT JOIN blade_common_group bcg1 on bm.group_id = bcg1.id and bcg1.is_deleted = 0
                 LEFT JOIN blade_common_group bcg2 on bm.organization_id = bcg2.id and bcg2.is_deleted = 0
                 LEFT JOIN blade_employee be on bm.employee_id = be.id and be.is_deleted = 0
        where bm.id = #{id}
    </select>
 
    <select id="pageMachine" resultType="com.qianwen.smartman.modules.smis.vo.MachineListVO">
        select bm.id,
        bm.machine_code machineCode,
        bm.machine_name machineName,
        bdt.id machineTypeId,
        bdt.name machineTypeName,
        bm.machine_model machineModel,
        bcg.name groupName,
        bm.machine_type_id,
        bm.serial_no serialNo,
        bm.short_code shortCode,
        bm.machine_use_status machineUseStatus,
        bm.status status
        from blade_machine bm
        LEFT JOIN blade_device_type bdt on bm.machine_type_id = bdt.id and bdt.is_deleted = 0
        LEFT JOIN blade_common_group bcg on bm.group_id = bcg.id and bcg.is_deleted = 0
        WHERE bm.is_deleted = 0
        <if test="machineName != null and machineName != ''">
            and machine_name like CONCAT(#{machineName}, '%')
        </if>
        <if test="machineCode != null and machineCode != ''">
            and machine_code like CONCAT( #{machineCode}, '%')
        </if>
        <if test="machineTypeId != null">
            and machine_type_id = #{machineTypeId}
        </if>
        <if test="groupId != null and groupId != allMachineId">
            and group_id = #{groupId}
        </if>
        <if test="status != null">
            and bm.status = #{status}
        </if>
        ORDER BY bm.create_time DESC,bm.id DESC
    </select>
    <select id="deviceListByDeviceTypeId" resultType="com.qianwen.smartman.modules.smis.dto.DeviceSimpleDTO">
        SELECT t1.machine_type_id AS deviceTypeId,
               t2.name            AS deviceTypeName,
               t1.id              AS deviceId,
               t1.machine_code    AS code,
               t1.machine_name    AS name,
               t1.machine_model   AS machineModel
        FROM blade_machine t1
                 LEFT JOIN blade_device_type t2
                           ON t1.machine_type_id = t2.id and t2.is_deleted = 0
        WHERE t1.machine_type_id = #{deviceTypeId}
          and t1.is_deleted = 0
    </select>
 
    <select id="deviceListByDeviceIdList" resultType="com.qianwen.smartman.modules.smis.dto.DeviceSimpleDTO">
        SELECT t1.machine_type_id AS deviceTypeId,
        t2.name AS deviceTypeName,
        t1.id AS deviceId,
        t1.machine_code AS code,
        t1.machine_name AS name,
        t1.machine_model AS machineModel
        FROM blade_machine t1
        LEFT JOIN blade_device_type t2
        ON t1.machine_type_id = t2.id and t2.is_deleted = 0
        WHERE t1.is_deleted = 0
        <if test="deviceIdList!= null and deviceIdList.size > 0 ">
            AND t1.id IN
            <foreach collection="deviceIdList" index="index" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
    </select>
 
    <select id="listMachineDetail" resultType="com.qianwen.smartman.modules.smis.vo.MachineDetailVO">
        select bm.id,
        bm.tenant_id tenantId,
        bm.extend_id extendId,
        machine_code machineCode,
        machine_name machineName,
        machine_model machineModel,
        machine_life_status machineLifeStatus,
        machine_use_status machineUseStatus,
        factory_no factoryNo,
        assets_code assetsCode,
        brand,
        nameplate,
        bm.avatar,
        serial_no serialNo,
        factory_file factoryFile,
        manufacturer,
        country_of_manufacture countryOfManufacture,
        system_name systemName,
        software_version softwareVersion,
        net_weight netWeight,
        power,
        voltage,
        dimensions,
        production_time productionTime,
        delivery_time deliveryTime,
        depreciation_year depreciationYear,
        turn_to_fixed_assets_time turnToFixedAssetsTime,
        invoice_value invoiceValue,
        ovfa,
        net_asset_value netAssetValue,
        bm.organization_id organizationId,
        bcg2.name organizationName,
        production_line productionLine,
        management_class managementClas,
        elaborate_equipment elaborateEquipment,
        bm.pin_code pinCode,
        short_code shortCode,
        installation_location installationLocation,
        bm.remark,
        machine_type_id machineTypeId,
        bdt.name machineTypeName,
        bdt.code machineTypeCode,
        bcg1.name groupName,
        be.name employeeName
        from blade_machine bm
        LEFT JOIN blade_device_type bdt on bm.machine_type_id = bdt.id and bdt.is_deleted = 0
        LEFT JOIN blade_common_group bcg1 on bm.group_id = bcg1.id and bcg1.is_deleted = 0
        LEFT JOIN blade_common_group bcg2 on bm.organization_id = bcg2.id and bcg2.is_deleted = 0
        LEFT JOIN blade_employee be on bm.employee_id = be.id and be.is_deleted = 0
        WHERE bm.is_deleted = 0
        <if test="machineName != null and machineName != ''">
            and machine_name like CONCAT( #{machineName}, '%')
        </if>
        <if test="machineCode != null and machineCode != ''">
            and machine_code like CONCAT( #{machineCode}, '%')
        </if>
        <if test="machineTypeId != null">
            and machine_type_id = #{machineTypeId}
        </if>
        <if test="groupId != null and groupId != allMachineId">
            and group_id = #{groupId}
        </if>
        <if test="status != null">
            and bm.status = #{status}
        </if>
        ORDER BY bm.create_time DESC,bm.id DESC
    </select>
 
    <select id="getMachineByWorkStation" resultType="com.qianwen.smartman.modules.smis.dto.MachineExtDTO">
        select distinct bm.extend_id, bwom.workstation_id
        from blade_machine bm
        INNER JOIN blade_workstation_of_machine bwom on bm.id = bwom.machine_id
        where bm.is_deleted = 0
        and bwom.workstation_id in
        <foreach collection="workstationIds" index="index" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
    </select>
 
    <select id="queryDateTypeState" resultType="java.lang.String">
        select bdv.dmp_id
        from blade_workstation_wcs bww
                 left join blade_dmp_variables bdv on bww.dmp_variables_id = bdv.id
        where workstation_id = #{workstationId}
          and bww.data_type = #{code}
          and bww.is_deleted = 0
    </select>
 
    <select id="selectMachineDetailByCode" resultType="com.qianwen.smartman.modules.smis.vo.MachineDetailVO">
        select bm.id,
               bm.tenant_id              tenantId,
               bm.extend_id              extendId,
               machine_code              machineCode,
               machine_name              machineName,
               machine_model             machineModel,
               machine_life_status       machineLifeStatus,
               machine_use_status        machineUseStatus,
               factory_no                factoryNo,
               assets_code               assetsCode,
               brand,
               nameplate,
               bm.avatar,
               serial_no                 serialNo,
               factory_file              factoryFile,
               manufacturer,
               country_of_manufacture    countryOfManufacture,
               system_name               systemName,
               software_version          softwareVersion,
               net_weight                netWeight,
               power,
               voltage,
               dimensions,
               production_time           productionTime,
               delivery_time             deliveryTime,
               depreciation_year         depreciationYear,
               turn_to_fixed_assets_time turnToFixedAssetsTime,
               invoice_value             invoiceValue,
               ovfa,
               net_asset_value           netAssetValue,
               bm.organization_id        organizationId,
               bcg2.name                 organizationName,
               production_line           productionLine,
               management_class          managementClass,
               elaborate_equipment       elaborateEquipment,
               bm.pin_code               pinCode,
               short_code                shortCode,
               installation_location     installationLocation,
               bm.remark,
               machine_type_id           machineTypeId,
               bdt.name                  machineTypeName,
               bdt.code                  machineTypeCode,
               bm.group_id               groupId,
               bcg1.name                 groupName,
               bm.employee_id            employeeId,
               be.name                   employeeName,
               bm.status                 status
        from blade_machine bm
                 LEFT JOIN blade_device_type bdt
                           on bm.machine_type_id = bdt.id and bdt.is_deleted = 0
                 LEFT JOIN blade_common_group bcg1 on bm.group_id = bcg1.id and bcg1.is_deleted = 0
                 LEFT JOIN blade_common_group bcg2 on bm.organization_id = bcg2.id and bcg2.is_deleted = 0
                 LEFT JOIN blade_employee be on bm.employee_id = be.id and be.is_deleted = 0
        where bm.machine_code = #{machineCode}
    </select>
 
    <select id="pageMachineByParam" resultType="com.qianwen.smartman.modules.smis.vo.MachineListVO">
        select bm.id,
        bm.machine_code machineCode,
        bm.machine_name machineName,
        bdt.id machineTypeId,
        bdt.name machineTypeName,
        bm.machine_model machineModel,
        bcg.name groupName,
        bm.machine_type_id,
        bm.serial_no serialNo,
        bm.short_code shortCode,
        bm.machine_use_status machineUseStatus,
        bm.status status
        from blade_machine bm
        LEFT JOIN blade_device_type bdt on bm.machine_type_id = bdt.id and bdt.is_deleted = 0
        LEFT JOIN blade_common_group bcg on bm.group_id = bcg.id and bcg.is_deleted = 0
        WHERE bm.is_deleted = 0
        <if test="machineSelectVO.keyword != null and machineSelectVO.keyword != ''">
            and (bm.machine_name like CONCAT(#{machineSelectVO.keyword}, '%')
            or bm.machine_code like CONCAT(#{machineSelectVO.keyword}, '%'))
        </if>
        ORDER BY bm.create_time DESC,bm.id DESC
    </select>
    <!--    查询未绑定的机器-->
    <select id="listNoBand" resultType="com.qianwen.smartman.modules.smis.vo.MachineVO">
        select bm.*
        from blade_machine bm
        where bm.is_deleted = 0
          AND bm.id not in (select bwom.machine_id
                            from blade_workstation_of_machine bwom)
    </select>
    <select id="listHaveBand" resultType="com.qianwen.smartman.modules.smis.vo.MachineVO">
        select bm.*
        from blade_machine bm
        where bm.is_deleted = 0
          AND bm.id in (select bwom.machine_id
                        from blade_workstation_of_machine bwom)
    </select>
</mapper>