洪城义警-正式版后台
zengh
2022-05-26 4c19ddd36bdfb43b5ef4e8df3c9a98cd4d356d6c
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
<?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.catalog.mapper.catalogMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="catalogResultMap" type="org.springblade.modules.catalog.entitly.catalog">
        <id column="id" property="id"/>
        <result column="name" property="name"/>
        <result column="pId" property="pId"/>
        <result column="eqid" property="eqid"/>
        <result column="tenant_id" property="tenant_id"/>
    </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>
 
 
    <select id="selectCatalogList" resultType="java.util.HashMap">
        SELECT id,name,pId FROM `sys_catalog`
    </select>
 
    <select id="selectCatalogEqNUmber" resultType="java.util.HashMap">
 
        SELECT
           id,name,pId,eqid
        FROM
            sys_catalog where 1 = 1
        <if test="id!=null">
            and id = #{id}
        </if>
 
    </select>
 
    <select id="selectCount" resultType="java.util.HashMap">
        SELECT
    COUNT( * ) AS counta
FROM
    sys_alarm UNION
SELECT
    COUNT( * )
FROM
    sys_equipment
WHERE
    parent_id != 0 UNION
SELECT
    COUNT( * )
FROM
    sys_suser UNION
SELECT
    COUNT( * )
FROM
    sys_security WHERE type=1
    </select>
 
    <select id="selectAddvcd" resultType="java.util.HashMap">
        SELECT
    COUNT(*) AS value,
    s.addvcd,
    d.addvnm as name
FROM
    sys_suser s
    INNER JOIN sys_district d ON d.addvcds = s.addvcd
GROUP BY
    s.addvcd
    </select>
 
    <select id="selectEq" resultType="java.util.HashMap">
      SELECT
    COUNT(*) AS value,
    s.addvcd,
    blade_region.name as name
FROM
    sys_equipment s
    INNER JOIN blade_region on blade_region.`code`=s.addvcd
    WHERE s.parent_id!=0
    GROUP BY s.addvcd,blade_region.name
    </select>
    <select id="selectWar" resultType="java.util.HashMap">
     SELECT COUNT(*) as cou,waringType FROM `sys_alarm` where DATE_FORMAT(alarmTime,'%Y-%m-%d')&gt;=#{beginTime} and DATE_FORMAT(alarmTime,'%Y-%m-%d')&lt;=#{endTime} GROUP BY waringType ORDER BY cou desc
    </select>
 
    <select id="lazyTree" resultMap="treeNodeResultMap" >
        SELECT
        dept.id,
        dept.pId as parent_id,
        dept.name AS title,
        dept.eqid AS "value",
        dept.eqid AS "key",
        (
        SELECT
        CASE WHEN count(1) > 0 THEN 1 ELSE 0 END
        FROM
        sys_catalog
        WHERE
        pId = dept.id
        ) AS "has_children"
        FROM
        sys_catalog dept
        WHERE
        dept.pId = #{param2}
        <if test="param1!=null and param1!=''">
            and dept.tenant_id = #{param1}
        </if>
    </select>
 
    <select id="tree" resultMap="treeNodeResultMap">
        select id, pId as parent_id, name as title, id as "value", id as "key" from sys_catalog
    </select>
 
    <update id="updateCatalog">
    update sys_catalog SET name=#{name},eqid=#{eqid}
        <if test="pid!=null and pid!=''">
            ,pId=#{pid}
        </if>
     where eqid=#{eqid}
    </update>
 
    <insert id="addCatalog">
       INSERT INTO sys_catalog (name,eqid,pId) VALUES (#{name},#{eqid},#{pid})
    </insert>
 
    <!--获取行政区-》客户-》部门机构 -》安保人员 树形数据-->
<!--    <select id="getBigTree" resultMap="treeNodeResultMap">-->
<!--        (-->
<!--            SELECT-->
<!--                id,-->
<!--                pId as parent_id,-->
<!--                name AS title,-->
<!--                id AS "value",-->
<!--                id AS "key"-->
<!--            FROM-->
<!--                sys_catalog-->
<!--        )-->
 
<!--        union all-->
 
<!--        (-->
<!--            select-->
<!--                bu.id,-->
<!--                sc.id as parent_id,-->
<!--                bu.real_name AS title,-->
<!--                bu.id AS "value",-->
<!--                bu.id AS "key"-->
<!--            from-->
<!--                blade_user bu-->
<!--            left join-->
<!--                sys_catalog sc-->
<!--            on-->
<!--                sc.dept_id = SUBSTRING(bu.dept_id,-19)-->
<!--            left join-->
<!--                blade_role br-->
<!--            on-->
<!--                bu.role_id = br.id-->
<!--            where-->
<!--                br.role_alias = '处警员'-->
<!--            and-->
<!--                bu.is_deleted=0-->
<!--        )-->
<!--    </select>-->
 
 
    <!--获取行政区-》客户-》部门机构 -》安保人员 树形数据-->
    <select id="getBigTree" resultMap="treeNodeResultMap">
        select DISTINCT  * from (
            (SELECT
              dept.id,
              dept.parent_id,
              dept.dept_name AS title,
              dept.id AS "value",
              dept.id AS "key",
                        (
                            SELECT
                                CASE WHEN count(1) > 0 THEN 1 ELSE 0 END
                            FROM
                                blade_dept
                            WHERE
                                parent_id = dept.id and is_deleted = 0
                        ) AS "has_children"
                    FROM
                        blade_dept dept
                    WHERE
                        dept.is_deleted = 0
            )
 
            union
 
            (select
                bu.id,
                REVERSE(left(REVERSE(dept_id),LOCATE(',',REVERSE(dept_id))-1)) as parent_id,
                real_name AS title,
                bu.id AS "value",
                bu.id AS "key",
                0 as "has_children"
                from
                blade_user bu
                left join
                    blade_role br
                    on
                    bu.role_id = br.id
                where
                        br.role_alias = 'qfqkdw'
                and
                    bu.is_deleted=0
            )
        )c
    </select>
 
 
 
 
</mapper>