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