xyc
2025-02-21 664db98c9e8595ce4dd636a27f480e3a08b81ff5
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="com.zt.life.core.dao.ZtProductDao">
    <delete id="deleteTable">
        drop table  ${tableName}
    </delete>
 
    <select id="searchNodes" resultType="com.zt.life.core.dto.SearchNodesDto">
        SELECT info_id        AS id,
               label          AS name,
               layer          AS level,
               connect_group  AS `GROUPS`
        from zt_boat_tree
        where label  like  '%${name}%'
          and connect_group like '%${pid}%'
        group by info_id
        order by label
    </select>
 
    <select id="getNamesByIds" resultType="com.zt.common.entity.MapData">
        SELECT info_id       AS id,
               label         AS name
        from zt_boat_tree
        where info_id  in  (${ids})
        and  layer in ('side','system1','system2','equipment','componentFolder')
        group by info_id
        order by name
    </select>
 
    <select id="getAll" resultType="com.zt.life.core.model.ZtProduct">
           select *
        from (
            SELECT id            as dataId,
            info_id       AS productId,
            label         AS name,
            connect_id    AS parentProductId,
            connect_group AS parentProductIds,
            layer         AS level,
            project,
            sort,
            isdelete      AS is_delete,
            create_by     AS CREATEOR,
            create_time   AS CREATE_DATE,
            case when exists(select 1 from eqpt_used c where b.info_ID = c.product_id) then 0 else 1 end
            as hasNotData
            FROM (SELECT A.*
--             ROW_NUMBER() OVER (PARTITION BY A.INFO_ID ORDER BY A.CREATE_TIME desc) AS NEWINDEX
            FROM zt_boat_tree A
                where isdelete = 0
                 ) B
            ) c order by sort
    </select>
 
    <select id="getAllNodes" resultType="com.zt.life.core.model.ZtProduct">
        SELECT  data_id,
                product_id,
                name,
                parent_product_id,
                parent_product_ids,
                level
        FROM view_zt_boat_tree
        where level is not null and name is not null and product_id is not null
    </select>
 
    <select id="getTreeNodes" resultType="com.zt.life.core.model.ZtProduct">
        select * from (
        SELECT b.*,
        case when exists(select 1 from view_zt_boat_tree c where b.product_id = c.parent_product_id and c.is_delete=0 and c.level in ('system1','system2','equipment')) then 0 else 1 end
        as leaf,
        case when exists(select 1 from product_data c where c.id = b.product_id ) then 0 else 1 end
        as hasNotData
        FROM view_zt_boat_tree B
        where is_delete = 0
        <if test="pid!=null and pid!=''">
            and parent_product_id=#{pid} and level in ('system1','system2','equipment')
        </if>
        <if test="pid==null or pid==''">
            and level in ('side')
        </if>
        ) c order by sort
    </select>
 
    <select id="getShipList" resultType="com.zt.life.core.model.ZtProduct">
        SELECT
        id     as dataId,
        info_id       AS productId,
        label         AS name,
        connect_id    AS parentProductId,
        connect_group AS parentProductIds,
        layer         AS level,
        project,
        sort,
        isdelete      AS is_delete,
        create_by     AS CREATEOR,
        create_time   AS CREATE_DATE
 
        FROM zt_boat_tree A
        where a.isdelete = 0 and  a.layer='side'
        <if test="localAear!=null and localAear != ''">
            and info_id in (select ship_id from sys_area_ship where area='${localAear}')
        </if>
    </select>
 
    <select id="getList" resultType="com.zt.life.core.model.ZtProduct">
        select a.*
        from view_zt_boat_tree a
        <where>
            <if test="whereSql!=null">
                ${whereSql}
            </if>
        </where>
        <if test="orderBySql!=null">
            ORDER BY ${orderBySql}
        </if>
    </select>
 
    <select id="getLevelList" parameterType="java.lang.String" resultType="com.zt.life.core.model.ZtProduct">
        SELECT
            a.*
        FROM view_zt_boat_tree a
        WHERE
            a.level =  #{level}
    </select>
 
 
    <select id="ungetSubList" parameterType="java.lang.String" resultType="com.zt.life.core.model.ZtProduct">
        SELECT product_id, name, level
        FROM view_zt_boat_tree
        WHERE 1=1 AND is_delete=0
        <if test='pid=="0"'>
            and product_id IN( SELECT ship_id
            FROM
            sys_area_ship
            WHERE
            area = 'sy'
            )
        </if>
        <if test="pid!='0'.toString()">
            and parent_product_id = #{pid}
        </if>
    </select>
 
    <select id="getSubList" parameterType="java.lang.String" resultType="com.zt.life.core.model.ZtProduct">
        SELECT info_id as product_id, label as name, layer level
        FROM zt_boat_tree
        WHERE 1=1 AND isdelete=0
        <if test='pid=="0"'>
            layer = 'side'
        </if>
        <if test="pid!='0'">
            and connect_id = #{pid} and layer in ('side','system1','system2','equipment','componentFolder')
        </if>
        group by info_id
        order by level desc
    </select>
 
    <select id="getListByIds" parameterType="java.lang.String" resultType="com.zt.life.core.model.ZtProduct">
        SELECT product_id, name, level
        FROM view_zt_boat_tree
        WHERE 1=1 AND is_delete=0
        <if test="ids!=null and ids!=''">
            and CONCAT(',',#{ids},',') like CONCAT('%,',product_id,',%')
        </if>
        <if test="ids==null or ids==''">
            and parent_product_id = -1
        </if>
    </select>
 
    <select id="getAllNodeByShipId" parameterType="java.lang.String" resultType="com.zt.common.entity.MapData">
        SELECT
        product_id       AS id,
        name
        FROM view_zt_boat_tree A
        where a.is_delete = 0
        <if test="shipId!=null">
            and parent_product_ids like concat('%,',#{shipId},',%')
        </if>
    </select>
 
    <select id="getIdByName" resultType="java.lang.Long">
        SELECT
            product_id
        FROM
            view_zt_boat_tree
        WHERE 1=1
          AND is_delete=0
          and name = #{name}
        limit 1
    </select>
 
    <select id="getProductIdByNameSql" resultType="java.lang.Long">
        SELECT
            product_id
        FROM
            view_zt_boat_tree
        WHERE 1=1
          AND is_delete=0
          and level = #{level}
          and name = #{name}
          and concat(',',parent_product_ids,',')  like concat('%,',#{pid},',%')
        limit 1
    </select>
 
    <select id="getNameById" resultType="java.lang.String">
        SELECT name FROM view_zt_boat_tree WHERE  is_delete = 0  and product_id = #{id}
    </select>
    <select id="getNameListById" resultType="java.lang.String">
        select replace(group_concat(name),',','/') as name
        from (
                 SELECT a.name,
                        case when a.level = 'side' then 1
                             when a.level = 'system1' then 2
                             when a.level = 'system2' then 3
                             else 4 end as level2
                 FROM `view_zt_boat_tree` a,
                      view_zt_boat_tree b
                 where a.level in ('side','system1','system2','equipment','componentFolder')
                   and b.product_id = '${id}'
                   and (concat(',',b.parent_product_ids,',') like concat('%,',a.product_id,',%') or b.product_id = a.product_id)
                 order by level2
             ) c
    </select>
 
    <select id="getOneByProductId" resultType="com.zt.life.core.model.ZtProduct">
        SELECT     `p`.`id` as `data_id`,
                  `p`.`info_id` as `product_id`,
                  `p`.`label` as `name`,
                  `p`.`connect_id` as `parent_product_id`,
                  `p`.`connect_group` as `parent_product_ids`,
                  `p`.`layer` as `level`,
                  `p`.`project` as `project`,
                  `p`.`sort` as `sort`,
                  `p`.`isdelete` as `is_delete`,
                  `p`.`create_by` as `createor`,
                  `p`.`create_time` as `create_date`
        FROM zt_boat_tree p
        WHERE  p.isdelete = 0
          and p.info_id =concat(#{productId})
        group by info_id
        limit 1
    </select>
 
    <select id="getByProductIdList" resultType="com.zt.life.core.model.ZtProduct">
        SELECT     `p`.`id` as `data_id`,
                  `p`.`info_id` as `product_id`,
                  `p`.`label` as `name`,
                  `p`.`connect_id` as `parent_product_id`,
                  `p`.`connect_group` as `parent_product_ids`,
                  `p`.`layer` as `level`,
                  `p`.`project` as `project`,
                  `p`.`sort` as `sort`,
                  `p`.`isdelete` as `is_delete`,
                  `p`.`create_by` as `createor`,
                  `p`.`create_time` as `create_date`
        FROM zt_boat_tree p
        WHERE  p.isdelete = 0
          and (concat(',',#{parentProductIds},',') like concat('%,',p.info_id,',%'))
          and p.layer in ('model','side','system1','system2','equipment','componentFolder')
          group by info_id
    </select>
 
    <select id="getByProductId" resultType="com.zt.life.core.model.ZtProduct">
        SELECT p.*
             ,p2.data_id as modelId
             ,p2.product_id as modelProductId
             ,p2.name as modelName
             ,p3.data_id as shipId
             ,p3.product_id as shipProductId
             ,p3.name as shipName
             ,p4.data_id as sysId
             ,p4.product_id as sysProductId
             ,p4.name as sysName
             ,p5.data_id as subSysId
             ,p5.product_id as subSysProductId
             ,p5.name as subSysName
             ,p6.data_id as deviceId
             ,p6.product_id as deviceProductId
             ,p6.name as deviceName
        FROM view_zt_boat_tree p
                 left join view_zt_boat_tree p2 on concat(',',p.parent_product_ids,',',p.product_id,',') like concat('%,',p2.product_id,',%') and p2.level = 'model'
                 left join view_zt_boat_tree p3 on concat(',',p.parent_product_ids,',',p.product_id,',') like concat('%,',p3.product_id,',%') and p3.level = 'side'
                 left join view_zt_boat_tree p4 on concat(',',p.parent_product_ids,',',p.product_id,',') like concat('%,',p4.product_id,',%') and p4.level = 'system1'
                 left join view_zt_boat_tree p5 on concat(',',p.parent_product_ids,',',p.product_id,',') like concat('%,',p5.product_id,',%') and p5.level = 'system2'
                 left join view_zt_boat_tree p6 on concat(',',p.parent_product_ids,',',p.product_id,',') like concat('%,',p6.product_id,',%') and p6.level in ('equipment','componentFolder')
        WHERE  p.is_delete = 0  and p.product_id =concat(#{productId})
        limit 1
    </select>
 
    <select id="getNameAll" resultType="com.zt.common.entity.MapData">
        SELECT
            product_id AS id,
            name
        FROM
            view_zt_boat_tree
        WHERE  is_delete = 0
    </select>
 
</mapper>