jinlin
4 天以前 66f0597bf6a1e79540c6bc51dedf561c22f3bdb5
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
<?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.example.server.progressTrack.dao.DjJdgzNetworkLevel3Dao">
    <delete id="deleteLevel3">
        update dj_jdgz_network_level3
        set is_delete=1
        where id = ${id};
    </delete>
    <delete id="deleteLevel3List">
        update dj_jdgz_network_level3_list
        set is_delete=1
        where network_id = ${id};
    </delete>
    <delete id="deleteByTeamGroup">
        update dj_jdgz_network_level3_list
        set is_delete=1
        where network_id in (select id from dj_jdgz_network_level3 where NAME = #{name})
          and TEAMGROUP_ID = ${teamGroupId};
        update dj_jdgz_network_level3
        set is_delete=1
        where NAME = ${name};
    </delete>
 
    <select id="getList" resultType="com.example.server.progressTrack.model.DjJdgzNetworkLevel3">
        SELECT
        a.*,
        b.PROCESS_NAME AS level1NodeName,
        c.project_name,
        d.PROCESS_NAME AS level2NodeName
        FROM `dj_jdgz_network_level3` a
        LEFT JOIN dj_jdgz_network_level1 c on c.ID = a.LEVEL1_NETWORK_ID
        LEFT JOIN dj_jdgz_network_level1_list b on b.NETWORK_ID = c.ID
        LEFT JOIN dj_jdgz_network_level2_list d on d.ID = a.LEVEL2_NODE_ID
        where
        a.is_delete = 0
        and b.is_delete = 0
        and c.is_delete = 0
        and d.is_delete = 0
        <if test="shipId!=null">
            and c.ship_id = ${shipId}
        </if>
        <if test="deptId!=null">
            and a.dept_id = ${deptId}
        </if>
        <if test="teamId!=null">
            and a.TEAMGROUP_ID = ${teamId}
        </if>
        <if test="cabinId!=null">
            and ',' || a.cabin_id || ',' LIKE '%,${cabinId},%';
        </if>
        <if test="isealCabin!=10000 and isealCabin!=null">
            and a.iseal_cabin = ${isealCabin}
        </if>
        <if test="isLt!=10000 and isLt!=null">
            and a.islt = ${isLt}
        </if>
        <if test="type!=null and type!=''">
            and a.type = '${type}'
        </if>
        <if test="name!=null and name!=''">
            and a.name LIKE '%${name}%'
        </if>
        group by a.id
    </select>
 
    <select id="getNodeStatusData" resultType="com.example.server.progressTrack.Dto.NetworkNodeStatusDto">
        select ID, REQUIRED_COMPLETION_TIME, ACTUAL_COMPLETION, CURRENT_STATUS
        from dj_jdgz_network_level3_list
        where IS_DELETE = 0
          and NETWORK_ID = #{id};
    </select>
    <select id="getByNodeId" resultType="com.example.server.progressTrack.model.DjJdgzNetworkLevel3">
        select *
        from dj_jdgz_network_level3
        where is_delete = 0
          and LEVEL2_NODE_ID = ${id}
    </select>
    <select id="getListByLevel1"
            resultType="com.example.client.dto.JComboBoxItem">
        select *
        from dj_jdgz_network_level3
        where is_delete = 0
          and LEVEL1_network_id = ${level1NetworkId}
    </select>
    <select id="getListByExport" resultType="com.example.client.dto.JComboBoxItem">
        SELECT
        a.*
        FROM `dj_jdgz_network_level3` a
        where
        a.is_delete = 0
        <if test="projectId!=null">
            and a.LEVEL1_network_id = ${projectId}
        </if>
        <if test="deptId!=null">
            and a.dept_id = ${deptId}
        </if>
        <if test="teamId!=null">
            and a.TEAMGROUP_ID = ${teamId}
        </if>
    </select>
    <select id="getNodeList" resultType="com.example.server.progressTrack.Dto.TableNodeDto">
        SELECT
        c.name,
        b.NETWORK_ID,
        b.process_name,
        c.islt,
        c.iseal_cabin,
        b.ID, b.REQUIRED_COMPLETION_TIME, b.ACTUAL_COMPLETION, b.CURRENT_STATUS
        FROM dj_jdgz_track_record a
        LEFT JOIN dj_jdgz_network_level3_list b on b.ID = a.LEVEL3_NODE_ID
        LEFT JOIN dj_jdgz_network_level3 c on c.ID = b.NETWORK_ID
        LEFT JOIN dj_jdgz_network_level1 d on d.ID = c.LEVEL1_NETWORK_ID
        where
        a.is_delete = 0
        and b.is_delete = 0
        and c.is_delete = 0
        and d.is_delete = 0
        <if test="shipId!=null">
            and d.ship_id = ${shipId}
        </if>
        <if test="deptId!=null">
            and c.dept_id = ${deptId}
        </if>
        <if test="teamId!=null">
            and c.TEAMGROUP_ID = ${teamId}
        </if>
        <if test="cabinId!=null">
            and c.cabin_id = ${cabinId}
        </if>
        <if test="isCabin!=10000 and isCabin!=null">
            and c.iseal_cabin = ${isCabin}
        </if>
        <if test="islt!=10000 and islt!=null">
            and c.islt = ${islt}
        </if>
        <if test="type!=null and type!=''">
            and c.type = '${type}'
        </if>
        <if test="name!=null and name!=''">
            and c.name LIKE '%${name}%'
        </if>
        ORDER BY NETWORK_ID
    </select>
    <select id="getStatist" resultType="com.example.server.progressTrack.Dto.StatistProductDto">
        SELECT
            a.id,
            CASE WHEN a.pid = 0 THEN a.NAME ELSE '    ' || a.NAME END AS name,
            CASE WHEN a.pid = 0 THEN '' || a.id ELSE '' || a.pid || a.SORT END AS sort,
            COUNT(DISTINCT CASE WHEN fvp.process_name = '设备拆卸出舱' THEN b.id END) AS cxsl,
            COUNT(DISTINCT CASE WHEN fvp.process_name = '设备分交' THEN b.id END) AS fjsl,
            COUNT(DISTINCT CASE WHEN fvp.process_name = '拆检鉴定' THEN b.id END) AS jdsl,
            COUNT(DISTINCT CASE WHEN fvp.process_name = '设备返厂' THEN b.id END) AS fcsl,
            COUNT(DISTINCT CASE WHEN fvp.process_name = '回装' THEN b.id END) AS hzsl,
            COUNT(DISTINCT CASE WHEN fvp.process_name = '拆卸出舱' THEN b.id END) AS ccsl,
            COUNT(DISTINCT CASE WHEN fvp.process_name = '入库' THEN b.id END) AS rksl,
            COUNT(DISTINCT CASE WHEN fvp.process_name = '存放位置' THEN b.id END) AS cfsl,
            COUNT(DISTINCT CASE WHEN fvp.process_name = '移交T队' THEN b.id END) AS yjsl,
            COUNT(DISTINCT CASE WHEN fvp.process_name = '设备到厂' THEN b.id END) AS dcsl,
            COUNT(DISTINCT CASE WHEN fvp.process_name = '设备安装' THEN b.id END) AS azsl,
            COUNT(DISTINCT CASE WHEN all_complete.network_id IS NOT NULL THEN b.id END) AS wcsl
        FROM
            dj_sys_teamgroup_class a
            left JOIN
            dj_jdgz_network_level3 b ON a.id = b.TEAMGROUP_ID OR a.id = b.DEPT_ID
            LEFT JOIN dj_jdgz_network_level1 d on d.ID = b.LEVEL1_NETWORK_ID
                LEFT JOIN (
                SELECT
                    network_id,
                    process_name
                FROM (
                         SELECT
                             c.network_id,
                             c.process_name,
                             c.CURRENT_STATUS,
                             ROW_NUMBER() OVER (
                                 PARTITION BY c.network_id
                                 ORDER BY c.sort
                                 ) AS rn
                         FROM
                             dj_jdgz_network_level3_list c
                         WHERE
                             (c.CURRENT_STATUS = 0 OR c.CURRENT_STATUS IS NULL) and c.is_delete = 0
                     ) AS ranked_processes
                WHERE
                    ranked_processes.rn = 1
            ) AS fvp ON b.id = fvp.network_id
                LEFT JOIN (
                SELECT
                    network_id
                FROM
                    dj_jdgz_network_level3_list
                LEFT JOIN dj_jdgz_network_level3 ON dj_jdgz_network_level3_list.network_id = dj_jdgz_network_level3.id
                where dj_jdgz_network_level3_list.is_delete = 0
                and dj_jdgz_network_level3.is_delete = 0
                and dj_jdgz_network_level3.type = '${type}'
                GROUP BY
                    network_id
                HAVING
                    COUNT(CASE WHEN CURRENT_STATUS = 1 THEN 1 END) = COUNT(*)
            ) AS all_complete ON b.id = all_complete.network_id
        WHERE
            a.AREA = 'hld' AND a.IS_DELETE = 0 and d.ship_id = ${level1Id} and d.is_delete =0 and b.is_delete =0
        GROUP BY
            a.id, a.name
        ORDER BY
            sort;
    </select>
    <select id="getRemark" resultType="java.lang.String">
        SELECT
            b.remark
        FROM
            dj_jdgz_track_record b
                LEFT JOIN dj_jdgz_network_level3 a ON b.LEVEL3_NETWORK_ID = a.ID
        WHERE
            a.is_delete = 0
          AND b.is_delete = 0
          AND a.id = ${networkId}
          AND a.type = '${type}'
          AND b.remark IS NOT NULL
        ORDER BY
            ABS((julianday('now') - julianday(b.CREATE_DATE)) * 86400) desc,
            ABS((julianday('now') - julianday(b.UPDATE_DATE)) * 86400) desc
 
            LIMIT 1;
    </select>
    <select id="getdata" resultType="com.example.server.progressTrack.Dto.Level3ExportCloum">
        select c.NAME,b.PROCESS_NAME,b.CURRENT_STATUS,b.REQUIRED_COMPLETION_TIME,b.ACTUAL_COMPLETION,c.dept_id,c.teamgroup_id
        FROM dj_jdgz_track_record a
        LEFT JOIN dj_jdgz_network_level3_list b on b.ID = a.LEVEL3_NODE_ID
        LEFT JOIN dj_jdgz_network_level3 c on c.ID = b.NETWORK_ID
        LEFT JOIN dj_jdgz_network_level1 d on d.ID = c.LEVEL1_NETWORK_ID
        where a.IS_DELETE = 0
        and c.LEVEL1_NETWORK_ID = ${level1NetworkId}
        and c.LEVEL1_NETWORK_ID = d.id
        and b.IS_DELETE = 0
        and b.NETWORK_ID = c.id
        and c.IS_DELETE = 0
        and d.IS_DELETE = 0
        <if test="deptId!=null">
            and c.DEPT_ID = ${deptId}
        </if>
        <if test="teamGroupId!=null">
            and c.TEAMGROUP_ID = ${teamGroupId}
        </if>
        <if test="status!=null and status=='进行中'">
            and (b.CURRENT_STATUS = 0 or b.CURRENT_STATUS is null)
            and b.REQUIRED_COMPLETION_TIME &gt;= ( SELECT date( 'now', '-' || d.advent_day || ' days' ) )
        </if>
        <if test="status!=null and status=='临期'">
            and (b.CURRENT_STATUS = 0 or b.CURRENT_STATUS is null)
            and b.REQUIRED_COMPLETION_TIME &lt; ( SELECT date( 'now', '-' || d.advent_day || ' days' ) )
        </if>
        <if test="status!=null and status=='逾期'">
            and (b.CURRENT_STATUS = 0 or b.CURRENT_STATUS is null)
            and b.REQUIRED_COMPLETION_TIME &lt; ( SELECT datetime( 'now' ) )
        </if>
        <if test="status!=null and status=='正常完成'">
            and b.CURRENT_STATUS = 1
            AND b.REQUIRED_COMPLETION_TIME &gt;= b.ACTUAL_COMPLETION
        </if>
        <if test="status!=null and status=='超期完成'">
            and b.CURRENT_STATUS = 1
            AND b.REQUIRED_COMPLETION_TIME &lt; b.ACTUAL_COMPLETION
        </if>
    </select>
 
 
</mapper>