<?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,
|
CONNECT_GROUP AS groups,
|
LAYER AS level
|
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 and hasLifeData = 1) 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>
|