jinlin
2024-07-16 c2f855eb59e9d19d4957bc4cb51e3ca63d4ce4c4
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
270
271
272
273
274
275
276
277
278
279
280
281
<?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.modules.mainPart.task.dao.TaskCenterDao">
    <delete id="deleteTable">
        drop table ${tableName}
    </delete>
 
    <select id="page" resultType="com.zt.modules.workflow.model.WfRunTask">
        SELECT
        a.id,
        a.prev_id,
        a.prev_step_id,
        a.flow_id,
        a.step_id,
        a.step_name,
        a.biz_id,
        a.title,
        a.sender_id,
        a.sender_name,
        a.sender_time,
        a.group_id,
        a.receive_id,
        a.receive_name,
        a.receive_time,
        a.open_time,
       /* a.finish_time,*/
        a.finish_time2,
        a.comment,
        a.is_sign,
        a.sort,
        a.note,
        a.remark,
        a.is_delete,
        a.dept_id,
        a.company_id,
        a.tenant_id,
        a.topic,
        a.apply_user_id,
        a.apply_time,
/*        a.apply_user,*/
        a.step_marker,
        /*--step_router,*/
        a.flow_code,
        a.group_id2,
        a.finish_id,
        a.finish_name,
        a.biz_group_id,
        a.opinion,
        (case when status = 1 then '被驳回' else '' end)  as statusName,
        DateDiff(CURRENT_DATE,a.receive_time) as idleDays,
        a.topic AS taskName,
        a.step_name as taskType,
        a.biz_id as id,
        0 as Product_id,
        0 as MAINTAIN_LEVEL,
        0 as YEAR,
        a.receive_name as apply_user,
        date_add(a.receive_time,interval 7 day) AS finishTime,
        a.step_id as APPROVE_STEP_ID,
        a.step_marker,
        a.flow_code,
        a.apply_user as taskPeople,
        2 code,
        a.title  as summary,
        b.step_router,
        b.step_router_id
        FROM wf_run_task a
        left join wf_def_step b on a.step_id = b.id
        WHERE a.is_delete =0 and a.status in (0,1)
        AND a.receive_id = #{userId}
        <if test="projectId != null and projectId != ''">
            and a.biz_group_id = #{projectId}
         </if>
        <if test="djxlSystem != null and djxlSystem != ''">
            and a.flow_id in (select id from wf_def where system_type = #{djxlSystem})
        </if>
        ORDER BY a.receive_time DESC
    </select>
 
    <update id="pageDone_temp">
        drop table if exists ${pageDone_temp1};
        create table ${pageDone_temp1} as
        SELECT * FROM (
                          SELECT
                              a1.id,
                              a1.title,
                              a1.topic,
                              a1.remark,
                              a1.biz_id,
                              a1.biz_group_id,
                              a1.flow_code,
                              a1.step_id,
                              a1.step_marker,
                              /*a.step_name as step_name_my,*/
                              a1.receive_name as sender_name,
                              a1.receive_time,
                              a1.finish_time as finish_time,
                              a1.status
                          FROM wf_run_task a1
                          WHERE a1.is_delete = 0
                                and (a1.receive_id=#{userId}
                                    or EXISTS(SELECT 1 FROM sys_role s1,sys_role_user s2 WHERE s1.id = s2.role_id AND s2.user_id = #{userId} AND
                                    s2.is_delete=0 and s1.code in ('all','xtglybm')))
                                <if test="djxlSystem != null and djxlSystem != ''">
                                    and a1.flow_id in (select id from wf_def where system_type = #{djxlSystem})
                                </if>
 
                      ) a2
        where status in (20,10)
        group by a2.biz_id,a2.flow_code,a2.step_id;
 
        drop table if exists ${pageDone_temp2};
        create table ${pageDone_temp2} as
        select * from
            (select
                 b1.prev_id,
                 b1.group_id,
                 b1.biz_id,
                 b1.flow_code,
                 b1.step_id,
                 b1.step_marker,
                 b1.step_name,
                 b1.receive_name,
                 b1.receive_time,
                 b1.status
             from ${pageDone_temp1} a1,
                  wf_run_task b1
             WHERE b1.is_delete = 0
               and b1.status in(0,1,100)
 
               and a1.biz_id = b1.biz_id
               and a1.flow_code = b1.flow_code
             order by b1.receive_time DESC
            ) b2 group by biz_id,flow_code,step_id;
    </update>
 
    <select id="pageDone" resultType="com.zt.modules.workflow.model.WfRunTask">
        SELECT
        a.id,
        a.title,
        a.topic,
        a.remark,
        a.biz_id,
        a.flow_code,
        a.biz_group_id,
        c.step_read_router_id,
        a.sender_name,
        a.finish_time,
        b.prev_id,
        b.step_marker,
        b.step_name,
        case when c.can_recall=1 and a.id=b.prev_id and c.step_no &lt; d.step_no and d.step_no &lt; 100
            then 1 else 0 end as canRecall,
        c.step_no as myStepNo,
        d.step_no as curStepNo,
        (select group_concat(DISTINCT receive_name) from ${pageDone_temp2} s where s.group_id=b.group_id limit 0,3) receive_name,
        b.receive_time,
        (case when a.status = 10 then '驳回' else '' end)  as statusName,
        c.name as finishStepName,
        a.sender_name as finishUserName
        FROM ${pageDone_temp1} a
        join ${pageDone_temp2} b on a.biz_id = b.biz_id and a.flow_code = b.flow_code
        left join wf_def_step c on a.step_id = c.id
        left join wf_def_step d on b.step_id = d.id
        group by a.biz_id,a.flow_code,a.step_id
        ORDER BY a.receive_time DESC
    </select>
 
    <select id="page2" resultType="com.zt.modules.workflow.model.WfRunTask">
        SELECT
            0 as bizGroupId,
            CONCAT(p.Name, '-', a.YEAR, '-', c.Dict_label ) AS topic,
            case when a.current_state =1 then '助理修改计划' else '处长审批计划' end AS step_name,
            case when a.current_state =1 then '驳回' else '' end AS statusName,
            a.id,
            '80' STEP_ID,
            case when a.current_state =1 then 'zl' else 'cz' end AS STEP_MARKER,
            'yearPlan' as FLOW_CODE,
            u.nick_name as APPLY_USER,
            2 as code,
            '年度修理计划'  as title,
            '年度修理计划'  as remark,
            a.create_date AS RECEIVE_TIME,
            DateDiff(CURRENT_DATE,a.create_date) as idleDays
        FROM
            zhgl_annual_plan a
                LEFT JOIN view_zt_boat_tree p on concat(a.product_id) = p.product_id
                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')
                LEFT JOIN sys_user u ON u.user_id = a.creator
        WHERE a.is_delete = 0
          and (
                (current_state = 1
                    and EXISTS(SELECT 1 FROM sys_role s1,sys_role_user s2
                        WHERE s1.id = s2.role_id AND s2.user_id = #{userId} AND
                            s2.is_delete=0 and s1.CODE = 'zlbm')
                    ) or (
                        current_state = '5'
                        and EXISTS(SELECT 1 FROM sys_role s1,sys_role_user s2
                            WHERE s1.id = s2.role_id AND s2.user_id = #{userId} AND
                                s2.is_delete=0 and s1.CODE = 'czbm')
                    )
            )
        order by a.update_date desc limit 0,1
    </select>
 
 
 
    <select id="getRowByProjectId" resultType="com.zt.modules.workflow.model.WfRunTask">
        SELECT
            a.id,
            a.prev_id,
            a.prev_step_id,
            a.flow_id,
            a.step_id,
            a.step_name,
            a.biz_id,
            a.title,
            a.sender_id,
            a.sender_name,
            a.sender_time,
            a.group_id,
            a.receive_id,
            a.receive_name,
            a.receive_time,
            a.open_time,
            a.finish_time,
            a.finish_time2,
            a.comment,
            a.is_sign,
            a.sort,
            a.note,
            a.remark,
            a.is_delete,
            a.dept_id,
            a.company_id,
            a.tenant_id,
            a.topic,
            a.apply_user_id,
            a.apply_time,
            a.apply_user,
            a.step_marker,
            /*--step_router,*/
            a.flow_code,
            a.group_id2,
            a.finish_id,
            a.finish_name,
            a.biz_group_id,
            a.opinion,
            (case when status = 1 then '被驳回' else '' end)  as statusName,
            DateDiff(CURRENT_DATE,a.receive_time) as idleDays,
            a.topic AS taskName,
            a.step_name as taskType,
            a.biz_id as id,
            0 as Product_id,
            0 as MAINTAIN_LEVEL,
            0 as YEAR,
            a.receive_time AS finishTime,
            a.step_id as APPROVE_STEP_ID,
            a.step_marker,
            a.flow_code,
            a.apply_user as taskPeople,
            2 code,
            a.title  as summary,
            b.step_router,
            b.step_router_id
        FROM wf_run_task a
                 left join wf_def_step b on a.step_id = b.id
        WHERE a.is_delete =0 and a.status in (0,1)
          and a.topic=(select model_name from wx_project where id=#{projectId})
          and a.step_marker='jsfa_sc'
        ORDER BY a.receive_time DESC limit 1
    </select>
 
    <update id="oneKeyDoneCy">
        update wf_run_task
        set status=20, updater=#{userId}, update_date=CURRENT_TIMESTAMP
        where step_marker in('rjh_cy','zjh_cy','yjh_cy') and status=0 and receive_id=#{userId}
    </update>
</mapper>