<?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.ProductDao">
|
|
<select id="getAll" resultType="com.zt.life.core.model.Product">
|
select a.*, a.level
|
from view_zt_boat_tree a
|
where a.is_delete = 0
|
and (
|
exists(select 1 from view_zt_boat_tree b where b.product_id = concat(a.product_id) and b.is_delete = 0)
|
)
|
and a.level in ('model','side','system1','system2','equipment')
|
order by sort
|
</select>
|
|
<select id="getShipList" resultType="com.zt.life.core.model.Product">
|
select a.*, a.level2 as LEVEL
|
from core_product a
|
where a.is_delete = 0 and a.status = 1 and a.level2='L2'
|
<if test="localAear!=null">
|
and ship_id in (select ship_id from sys_area_ship where area='${localAear}')
|
</if>
|
ORDER BY sort
|
</select>
|
|
<select id="getList" resultType="com.zt.life.core.model.Product">
|
select a.*, a.level2 as LEVEL
|
from core_product 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.Product">
|
SELECT
|
a.*, a.level2 as LEVEL
|
FROM core_product a
|
WHERE
|
a.level2 = #{level}
|
</select>
|
|
<select id="getSubList" parameterType="java.lang.String" resultType="com.zt.life.core.model.Product">
|
SELECT id, product_id, name, level2 as level
|
FROM core_product
|
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="getListByIds" parameterType="java.lang.String" resultType="com.zt.life.core.model.Product">
|
SELECT id, product_id, name, level2 as level
|
FROM core_product
|
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.Long" resultType="com.zt.common.entity.MapData">
|
SELECT product_id as id,name
|
FROM core_product
|
WHERE 1=1 AND is_delete=0
|
and status=1 and ship_id = #{shipId}
|
</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}
|
</select>
|
|
<select id="getProduct" resultType="com.zt.life.core.model.Product">
|
select a.label as name,a.info_id as id, a.layer as level
|
from zt_boat_tree a
|
where a.isdelete = 0
|
<!--and (
|
exists(select 1 from view_zt_boat_tree b where b.product_id = concat(a.product_id) and b.is_delete = 0)
|
)-->
|
<if test="levels != null and levels != ''">
|
and layer in (${levels})
|
</if>
|
<if test="productId != null and productId != ''">
|
and connect_id = concat(#{productId})
|
</if>
|
group by info_id
|
order by label
|
</select>
|
|
<select id="getProjectByProductId" resultType="com.zt.life.core.model.Product">
|
SELECT b.id,b.product_id,b.area,b.name, 'system1' as `level` FROM (
|
SELECT
|
a.id,
|
a.product_id,
|
CONCAT(d.name,'-',a.`year`,'-',c.dict_label) AS `name`,
|
'qd' as area
|
FROM
|
wx_qd_project a
|
left join (select label as name,info_id, layer as level
|
from zt_boat_tree
|
where isdelete = 0 and layer = 'side'
|
group by info_id
|
) d on d.info_id = concat(a.product_id)
|
LEFT JOIN qd_sys_dict_data c ON a.maintain_level = c.dict_value AND dict_type_id IN (SELECT id FROM sys_dict_type WHERE dict_type='question_level_type')
|
WHERE
|
a.is_delete = 0
|
<if test="sideId != null and sideId != ''">
|
and a.product_id = #{sideId}
|
</if>
|
UNION
|
SELECT
|
a.id,
|
a.product_id,
|
a.model_name as `name`,
|
'sy' as area
|
FROM
|
wx_project a
|
LEFT JOIN sys_dict_data c ON a.maintain_level = c.dict_value AND dict_type_id IN (SELECT id FROM sys_dict_type WHERE dict_type='question_level_type')
|
WHERE
|
a.is_delete = 0
|
<if test="sideId != null and sideId != ''">
|
and a.product_id = #{sideId}
|
</if>
|
) b
|
</select>
|
|
<select id="getProductIdAndProjectId" resultType="com.zt.life.core.model.Product">
|
SELECT b.id,b.product_id,b.`YEAR` FROM (
|
SELECT
|
a.id,
|
a.product_id,
|
/*d.parent_product_id,*/
|
a.`year`
|
FROM
|
wx_qd_project a
|
/*left join view_zt_boat_tree d on d.product_id = concat(a.product_id)*/
|
WHERE
|
a.is_delete = 0
|
UNION
|
SELECT
|
a.id,
|
a.product_id,
|
/* d.parent_product_id,*/
|
a.`year`
|
FROM
|
wx_project a
|
/* left join view_zt_boat_tree d on d.product_id = concat(a.product_id)*/
|
WHERE
|
a.is_delete = 0
|
) b
|
ORDER BY b.`YEAR` DESC
|
LIMIT 1;
|
</select>
|
<select id="getIdByNameByProductId" resultType="java.lang.Long">
|
SELECT product_id
|
FROM view_zt_boat_tree
|
WHERE is_delete = 0
|
and (`level` = 'system1' or `level` = 'system2')
|
and name = #{name}
|
and concat(',', parent_product_ids, ',') like concat('%,', #{productId}, ',%')
|
</select>
|
</mapper>
|