洪城义警-正式版后台
zhongrj
2023-06-27 2ca9993b57bdd090c4345ea6767687e2fbb83014
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
<?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="org.springblade.modules.taskqd.mapper.TaskqdMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="taskResultMap" type="org.springblade.modules.taskqd.vo.TaskqdVO">
        <id column="id" property="id"/>
        <result column="rname" property="rname"/>
        <result column="content" property="content"/>
        <result column="time" property="time"/>
        <result column="province" property="province"/>
        <result column="city" property="city"/>
        <result column="jnum" property="jnum"/>
        <result column="line" property="line"/>
        <result column="rtype" property="rtype"/>
        <result column="serid" property="serid"/>
        <result column="integral" property="integral"/>
        <result column="url" property="url"/>
        <result column="captain" property="captain"/>
        <result column="team" property="team"/>
        <result column="iscation" property="iscation"/>
        <result column="publisher" property="publisher"/>
        <result column="fid" property="fid"/>
        <result column="fname" property="fname"/>
        <result column="gather" property="gather"/>
        <result column="gathername" property="gathername"/>
        <result column="tasktype" property="tasktype"/>
        <result column="phone" property="phone"/>
        <result column="train" property="train"/>
    </resultMap>
 
 
    <update id="updatet">
        update sys_taskqd
        SET serid=#{serid},
        num=#{num}
        <if test="param4!='' and param4!=null">
            ,captain =#{param4}
        </if>
        <if test="param5!='' and param5!=null">
            ,team =#{param5}
        </if>
        where id = #{id}
    </update>
    <update id="updateRtype">
        UPDATE sys_taskqd
        <set>
            <if test='type == "0" '>rtype=#{type},stime = now(),</if>
            <if test='type == "1" '>rtype=#{type},sendtime = now(),</if>
        </set>
        WHERE id = #{rid}
    </update>
 
    <update id="updateSerid">
        update sys_taskqd
        SET serid=#{serid},team=#{newteam},num=#{newnum}
        where id = #{rid}
    </update>
 
    <!--日常任务列表-->
    <select id="getlist" resultMap="taskResultMap">
        SELECT
        *
        FROM
        sys_taskqd
        WHERE
        serid LIKE concat("%",#{id},"%")
        <if test="type == 3">
            and rtype = 1
        </if>
        <if test="type == 2">
            AND ( rtype = "0" OR rtype = "2" )
        </if>
    </select>
 
    <!--任务统计-->
    <select id="selectList" resultMap="taskResultMap">
        select jnum, num, serid, team ,time,endtime
        from sys_taskqd
        where id = #{id}
    </select>
    <select id="taskCount" resultType="java.util.HashMap">
        SELECT
            count( * ) AS count
        FROM
            sys_taskqd
        WHERE
            serid LIKE  concat("%",#{id},"%")
            AND rtype = "1" UNION ALL
        SELECT
            count( * ) AS count
        FROM
            sys_taskqd
        WHERE
            serid LIKE concat("%",#{id},"%")
            AND ( rtype = "0" OR rtype = "2" )
    </select>
    <select id="allTask" resultType="java.util.HashMap">
        SELECT
        *
        FROM
        sys_taskqd
        WHERE 1 = 1
        AND ( rtype = "0" OR rtype = "2" )
 
    </select>
 
    <select id="queryReceiver" resultType="java.util.HashMap">
        SELECT u.*,
               r.role_name
        FROM blade_user u
                 LEFT JOIN (SELECT id, role_name FROM blade_role) r on u.role_id = r.id
        WHERE u.id in (${serid})
    </select>
 
    <select id="selectLi" resultMap="taskResultMap">
        SELECT A.*,IFNULL(B.num,0) as nums FROM (
        select qd.* from sys_taskqd qd LEFT JOIN sys_jurisdiction j ON j.id = qd.jurisdiction where 1=1 AND
        <if test="type==0">
            (qd.rtype = "2" or qd.rtype = "0") AND
            <if test="serid != '1123598821738675201'">
                find_in_set(#{serid}, serid) and
            </if>
            qd.tasktype=#{tasktype}) A LEFT JOIN (SELECT COUNT(*) as num,hdid,serid
            FROM
            sys_taskfk WHERE 1 = 1
            <if test="serid != '1123598821738675201'">
                and serid=#{serid}
            </if>
            GROUP BY hdid,serid) B ON A.id=B.hdid
        </if>
        <if test="type==2">
            qd.rtype = "1" AND
            <if test="serid != '1123598821738675201'">
                find_in_set(#{serid}, serid) and
            </if>
            qd.tasktype=#{tasktype}) A LEFT JOIN (SELECT COUNT(*) as num,hdid,serid
            FROM
            sys_taskfk WHERE 1 = 1
            <if test="serid != '1123598821738675201'">
                and serid=#{serid}
            </if>
            GROUP BY hdid,serid) B ON A.id=B.hdid
        </if>
        <if test="type==1">
            <if test="jurisdiction!='1372091709474910209'">
                <if test="tasktype !=2">
                    qd.jnum!=qd.num AND
                </if>
                qd.rtype = "2"
                and qd.tasktype=#{tasktype}
                <if test="serid != '1123598821738675201'">
                    and (!find_in_set(#{serid}, serid) OR serid IS NULL )
                </if>
                and
                ((j.id =#{jurisdiction} or
                j.parent_id = #{jurisdiction}) or (j.id =#{workjurisdiction} or
                j.parent_id = #{workjurisdiction}))
            </if>
            ) A LEFT JOIN (SELECT
            COUNT(*)
            as num,hdid FROM sys_taskfk GROUP BY hdid) B ON A.id=B.hdid
        </if>
    </select>
 
    <select id="selectNum" resultType="java.util.HashMap">
        SELECT COUNT(*) as num, tasktype
        FROM sys_taskqd qd
                 LEFT JOIN sys_jurisdiction j ON j.id = qd.jurisdiction
        WHERE jnum!=num AND qd.rtype = "2" AND
           (!find_in_set(#{serid}
            , serid)
           OR serid IS NULL )
          and ((j.id =#{jurisdiction}
           or j.parent_id = #{jurisdiction})
           or (j.id =#{workjurisdiction}
           or j.parent_id = #{workjurisdiction}))
        GROUP BY tasktype
    </select>
 
    <select id="querySerid" resultType="java.lang.String">
        SELECT serid
        from sys_taskqd
        where id = #{rid}
    </select>
 
    <select id="countTaskByJur" resultType="org.springblade.modules.taskqd.entity.Taskqd">
        SELECT *
        FROM sys_taskqd qd
        WHERE qd.jurisdiction = #{jurisdiction}
        <choose>
            <when test='period=="day" '>
                AND TO_DAYS(qd.time) = TO_DAYS(#{startTime})
            </when>
            <when test='period == "week" '>
                 AND YEARWEEK(DATE_FORMAT(qd.time,"%Y-%m-%d"),1) = YEARWEEK(#{startTime},1)
             </when>
            <when test='period == "month" '>
                AND DATE_FORMAT(qd.time,"%Y-%m") = DATE_FORMAT(#{startTime},"%Y-%m")
            </when>
            <when test='period == "all" '></when>
        </choose>
        LIMIT 0,15
    </select>
 
    <select id="getRealTime" resultType="java.lang.Integer">
        SELECT (UNIX_TIMESTAMP(sendtime)-UNIX_TIMESTAMP(stime))
            subsecond
        FROM sys_taskqd
        WHERE id = #{hdid}
    </select>
 
    <!--自定义分页查询-->
    <select id="selectTaskQdPage" resultType="org.springblade.modules.taskqd.vo.TaskqdVO">
        select * from sys_taskqd where 1=1
    </select>
 
    <!--导出任务数据-->
    <select id="selectTaskList" resultType="org.springblade.modules.taskqd.excel.TaskExcel">
        select
        st.id,st.rname,st.time,st.endtime,st.content,st.gathername,st.fname,st.integral,
        sr.role_name as trainName,
        case when rtype='0' then '正在进行'
         when rtype='1' then '已结束'
         when rtype='2' then '任务未开始'
        end as rtypeName,
        sj.dept_name as jurisdictionName
        from sys_taskqd st
        left join sys_jurisdiction sj on sj.id = st.jurisdiction
        left join blade_role sr on sr.id = st.train
        where 1=1
        <if test="task.tasktype!=null and task.tasktype!=''">
            and st.tasktype = #{task.tasktype}
        </if>
        <if test="task.rtype!=null and task.rtype!=''">
            and st.rtype = #{task.rtype}
        </if>
        <if test="task.rname!=null and task.rname!=''">
            and st.rname like concat('%',#{task.rname},'%')
        </if>
        <if test="task.jurisdiction!=null and task.jurisdiction!=''">
            and st.jurisdiction = #{task.jurisdiction}
        </if>
    </select>
</mapper>