zss
2023-09-12 cbf4b74927fe51c19c307d89b326ae999cb6a165
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
<?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.yuanchu.mom.mapper.DeviceMapper">
    <!--查询设备维护 左侧列表设备组展示-->
    <select id="deviceTwoTree" resultType="java.util.Map">
        SELECT distinct father,type
        FROM mom_ocean.device d
        WHERE d.state = 1
        AND d.type = #{type}
        <if test="search_class !=null and search_class != ''">
            AND d.`name` like concat('%',#{search_class},'%')
        </if>
    </select>
    <!--查询设备维护 右侧列表展示该设备组下的所有设备-->
    <select id="selectTreeDevice" resultType="java.util.Map">
        select device.id,
        code,
        device.name,
        user.name userName,
        DATE_FORMAT(end_measure, '%Y-%m-%d'),
        device_status,
        factory
        from mom_ocean.device,mom_ocean.user
        where device.state=1
        and user.id=keeper
        and type=#{type}
        and father=#{father}
        <if test="deviceStatus!=null and deviceStatus!=''">
            and device_status=#{deviceStatus}
        </if>
        <if test="message!=null and message!=''">
            and code like concat('%',#{message},'%')
            or device.name like concat('%',#{message},'%')
        </if>
    </select>
    <!--根据设备分组查询设备-->
    <select id="getDeviceNameByGroup" resultType="java.util.Map">
        select id, name
        from mom_ocean.device
        where state = 1
          and father = #{deviceGroup}
          and device_status in (1, 5)
    </select>
    <!--选择设备组-->
    <select id="chooseDevGroup" resultType="java.util.Map">
        select distinct father
        from mom_ocean.device
        where state = 1
          and device_status in (1, 5)
    </select>
 
    <!--原材料检验-选择设备-->
    <resultMap id="oneMap" type="map">
        <result property="name" column="father"/>
        <collection property="children" resultMap="twoMap" javaType="List"/>
    </resultMap>
    <resultMap id="twoMap" type="map">
        <id property="id" column="id"/>
        <result property="name" column="name"/>
    </resultMap>
    <select id="chooseDevice" resultMap="oneMap">
        select id, father, name
        from mom_ocean.device
        where state = 1
          and device_status in (1, 5)
    </select>
 
    <!--新增选择设备组-->
    <select id="listGroup" resultType="java.lang.String">
        select distinct father
        from mom_ocean.device
        where state = 1
          and type = #{type}
    </select>
    <!--批量删除-->
    <update id="delAllDevice">
        update mom_ocean.device
        set state=0
        where id in (${ids})
    </update>
</mapper>