nnnjjj123
2021-01-06 3b67e70f41bac39d1d74d2039a2fb286a32a8d41
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
<?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.springblade.modules.equipment.mapper.EquipmentMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="equipmentResultMap" type="org.springblade.modules.equipment.entity.Equipment">
        <id column="id" property="id"/>
        <result column="deviceName" property="deviceName"/>
        <result column="deviceNumber" property="deviceNumber"/>
        <result column="deviceType" property="deviceType"/>
        <result column="ownership" property="ownership"/>
        <result column="ownerId" property="ownerId"/>
        <result column="devicestate" property="devicestate"/>
        <result column="stime" property="stime"/>
        <result column="coordinate" property="coordinate"/>
        <result column="parent_id" property="parentId"/>
        <result column="jd" property="jd"/>
        <result column="wd" property="wd"/>
        <result column="addvcd" property="addvcd"/>
        <result column="street" property="street"/>
    </resultMap>
 
    <resultMap id="treeNodeResultMap" type="org.springblade.core.tool.node.TreeNode">
        <id column="id" property="id"/>
        <result column="parent_id" property="parentId"/>
        <result column="title" property="title"/>
        <result column="value" property="value"/>
        <result column="key" property="key"/>
        <result column="has_children" property="hasChildren"/>
    </resultMap>
 
    <resultMap id="deptVOResultMap" type="org.springblade.modules.equipment.vo.EquipmentVOS">
        <id column="id" property="id"/>
        <result column="deviceName" property="deviceName"/>
        <result column="deviceNumber" property="deviceNumber"/>
        <result column="deviceType" property="deviceType"/>
        <result column="ownership" property="ownership"/>
        <result column="ownerId" property="ownerId"/>
        <result column="devicestate" property="devicestate"/>
        <result column="stime" property="stime"/>
        <result column="coordinate" property="coordinate"/>
        <result column="parent_id" property="parentId"/>
        <result column="jd" property="jd"/>
        <result column="wd" property="wd"/>
        <result column="addvnm" property="addvnm"/>
        <result column="street" property="street"/>
        <result column="has_children" property="hasChildren"/>
        <result column="yname" property="yname"/>
        <result column="bType" property="bType"/>
        <result column="dtype" property="dtype"/>
    </resultMap>
 
 
    <select id="selectEquipmentPage" resultMap="equipmentResultMap">
        select * from sys_equipment where is_deleted = 0
    </select>
 
    <!--新增-->
    <insert id="s" parameterType="org.springblade.modules.equipment.entity.Equipment">
       INSERT INTO sys_equipment (deviceName,deviceNumber,deviceType,ownership,ownerId,devicestate,stime,coordinate,parent_id,jd,wd,addvcd,street,dtype) VALUES (#{deviceName},#{deviceNumber},#{deviceType},#{ownership},#{yname},#{devicestate},#{stime},POINT(#{jd},#{wd}),#{parentId},#{jd},#{wd},#{addvcd},#{streeName},#{dtype})
    </insert>
 
    <select id="tree" resultMap="treeNodeResultMap">
          select id, parent_id, deviceName as title, id as "value", id as "key" from sys_equipment
    </select>
 
 
    <select id="lazyList" resultMap="deptVOResultMap">
        SELECT dept.id,dept.deviceName,dept.deviceNumber,dept.deviceType,dept.ownership,
        dept.ownerId,dept.devicestate,dept.stime,
        ST_ASTEXT(dept.coordinate) as coordinate,dept.dtype,
        dept.parent_id,FORMAT(dept.jd,6) as jd,FORMAT(dept.wd,6) as wd,dept.street as streeName,u.yname,d.addvnm,dept.addvcd,
        (
        SELECT
        CASE WHEN count(1) > 0 THEN 1 ELSE 0 END
        FROM
        sys_equipment
        WHERE
        parent_id = dept.id
        ) AS "has_children"
        FROM
        sys_equipment dept left JOIN sys_suser u on u.ynumber=dept.ownerId LEFT JOIN sys_district d on
        d.addvcds=dept.addvcd LEFT JOIN sys_street s on s.id=dept.street
        WHERE 1=1
        <if test="parentId!=null">
            and dept.parent_id =#{parentId}
        </if>
        <if test="param2.deviceName!=null and param2.deviceName!=''">
            and dept.deviceName like concat(concat('%', #{param2.deviceName}),'%')
        </if>
        <if test="param2.deviceType!=null and param2.deviceType!=''">
            and dept.deviceType like concat(concat('%', #{param2.deviceType}),'%')
        </if>
        <if test="param2.deviceNumber!=null and param2.deviceNumber!=''">
            and dept.deviceNumber like concat(concat('%', #{param2.deviceNumber}),'%')
        </if>
        <if test="param2.devicestate!=null and param2.devicestate!=''">
            and dept.devicestate like concat(concat('%', #{param2.devicestate}),'%')
        </if>
        <if test="param2.dtype!=null and param2.dtype!=''">
            and dept.dtype like concat(concat('%', #{param2.dtype}),'%')
        </if>
    </select>
 
    <update id="updateOne" parameterType="org.springblade.modules.equipment.entity.Equipment">
    update sys_equipment SET deviceName=#{deviceName},deviceNumber=#{deviceNumber},deviceType=#{deviceType},
    ownership=#{ownership},ownerId=#{yname},devicestate=#{devicestate},stime=#{stime},
    coordinate=POINT(#{jd},#{wd}),parent_id=#{parentId},jd=#{jd},wd=#{wd},addvcd=#{addvnm},street=#{streeName},dtype=#{dtype} where id=#{id}
</update>
 
 
    <select id="selectInfo" resultMap="deptVOResultMap"
            parameterType="org.springblade.modules.equipment.entity.Equipment">
        SELECT
        dept.id,dept.deviceName,dept.deviceNumber,dept.deviceType,dept.ownership,
        dept.ownerId,dept.devicestate,dept.stime,
        ST_ASTEXT(dept.coordinate) as coordinate,dept.dtype,
        dept.parent_id,dept.jd,dept.wd,dept.street as streeName,u.yname,d.addvnm,dept.addvcd,
        (
        SELECT
        CASE WHEN count(1) > 0 THEN 1 ELSE 0 END
        FROM
        sys_equipment
        WHERE
        parent_id = dept.id
        ) AS "has_children"
        FROM
        sys_equipment dept left JOIN sys_suser u on u.ynumber=dept.ownerId LEFT JOIN sys_district d on d.addvcds=dept.addvcd LEFT JOIN sys_street s on s.id=dept.street
        WHERE  dept.id=#{id}
    </select>
 
    <select id="selectList" resultMap="deptVOResultMap">
        SELECT e.id,e.deviceName,e.deviceNumber,e.deviceType,e.ownership,
        e.ownerId,e.devicestate,e.stime,e.street as streeName,
        ST_ASTEXT(e.coordinate) as coordinate,e.dtype,
        e.parent_id,e.jd,e.wd,e.addvcd,
        s.yname,d.bType,di.addvnm FROM `sys_equipment` e
        LEFT JOIN sys_suser s
        on s.ynumber=e.ownerId LEFT JOIN act_deploy d on d.deviceNumber=e.deviceNumber LEFT JOIN sys_district di on di.addvcds=e.addvcd LEFT JOIN sys_street t on t.id=e.street
        where 1=1
        <if test="deviceType!=null and deviceType!=''">
            and e.deviceType=#{deviceType}
        </if>
    </select>
 
</mapper>