jinlin
2024-08-02 826cd5b51d5106cfea07e397eda184fb15ec7a30
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
<?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>