<?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>
|