Files
mosty-dyga-cloud/mosty-rwzx/src/main/resources/mapper/TbRwTaskMapper.xml
2025-09-04 18:25:00 +08:00

354 lines
14 KiB
XML

<?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.mosty.rwzx.mapper.TbRwTaskMapper">
<select id="selectDict" resultType="com.mosty.common.config.entity.SysDictItem">
select *
from mosty_base.sys_dict_item
where zdbh = #{dictName}
and xt_zxbz = '0'
</select>
<select id="getTaskRanking" parameterType="com.mosty.base.model.dto.rwzx.TbRwTaskStatisticsDto"
resultType="com.mosty.base.model.vo.rwzx.TbRwTaskRankingVo">
select userinfo.jsrsfzh,
userinfo.jsrmc,
ssbm,
IFNULL(YTable.YS, '0') YS,
IFNULL(NTable.NS, '0') NS,
(IFNULL( YTable.YS,0) / ( IFNULL( YTable.YS,0) + IFNULL( NTable.NS,0) )) rate
from (select jsrsfzh, jsrmc, ssbm
from mosty_rwzx.tb_rw_task_user
WHERE xt_sjzt = '1' and xt_scbz = '0'
<if test="ssbmid != null and ssbmid != ''">
and ssbmid = #{ssbmid}
</if>
GROUP BY jsrsfzh, jsrmc, ssbm) userinfo
LEFT JOIN (SELECT jsrsfzh,
sum(s) YS
FROM (SELECT i.dm, u.jsrsfzh, count(u.id) s
FROM mosty_base.sys_dict_item i
left JOIN (select *
from mosty_rwzx.tb_rw_task_user
where xt_sjzt = '1' and xt_scbz = '0') u on i.dm = u.rwzt
where i.zdbh = 'D_BZ_GRRWZT'
and i.xt_zxbz = '0'
GROUP BY i.dm, u.jsrsfzh
ORDER BY i.dm) g
WHERE dm = '2'
GROUP BY jsrsfzh) YTable on userinfo.jsrsfzh = YTable.jsrsfzh
LEFT JOIN (SELECT jsrsfzh,
sum(s) NS
FROM (SELECT i.dm, u.jsrsfzh, count(u.id) s
FROM mosty_base.sys_dict_item i
left JOIN (select *
from mosty_rwzx.tb_rw_task_user
where xt_sjzt = '1' and xt_scbz = '0') u on i.dm = u.rwzt
where i.zdbh = 'D_BZ_GRRWZT'
and i.xt_zxbz = '0'
GROUP BY i.dm, u.jsrsfzh
ORDER BY i.dm) g
WHERE dm != '2'
GROUP BY
jsrsfzh) NTable on userinfo.jsrsfzh = NTable.jsrsfzh
order by rate DESC LIMIT 0,10
</select>
<!--获取我的任务列表-->
<select id="getMyRwList" resultType="com.mosty.base.model.entity.rwzx.TbRwTaskUser">
select * from tb_rw_task_user a where a.xt_scbz = '0' and a.xt_sjzt = '1'
<if test="dto.kssj != null and dto.jssj != null and dto.kssj != '' and dto.jssj != ''">
and a.rwfqsj &gt; #{kssj}
and a.rwfqsj &lt; #{jssj}
</if>
<if test="dto.rwxl != null and dto.rwxl != ''">
and a.rwxl = #{dto.rwxl}
</if>
<if test="dto.rwmc != null and dto.rwmc != ''">
and a.rwmc like concat('%',#{dto.rwmc},'%')
</if>
<if test="dto.rwnr != null and dto.rwnr != ''">
and a.rwnr like concat('%',#{dto.rwnr},'%')
</if>
<if test="dto.rwlx != null and dto.rwlx != ''">
and a.rwlx = #{dto.rwlx}
</if>
<if test="dto.rwjjcd != null and dto.rwjjcd != ''">
and a.rwjjcd = #{dto.rwjjcd}
</if>
<if test="dto.rwzt != null and dto.rwzt != ''">
and a.rwzt = #{dto.rwzt}
</if>
and case
when a.rwjsdx = '01' then a.jsrsfzh = #{sfzh}
when a.rwjsdx = '02' then a.jsbmdm = #{ssbmid}
when a.rwjsdx = '03' then
a.jsxzid in (select c.id from mosty_qwgl.tb_qw_xfbb c,mosty_qwgl.tb_qw_jl d where c.id = d.ywid and
c.xt_sjzt = '1' and c.xt_scbz = '0' and d.xt_sjzt = '1' and d.xt_scbz = '0' and
(c.fzr_sfzh = #{sfzh} or d.sfzh = #{sfzh}))
end
<if test="dto.grrwzt != null and dto.grrwzt != ''">
and a.grrwzt = #{dto.grrwzt}
</if>
order by a.rwfqsj desc
limit #{pageIndex},#{pageSize}
</select>
<!--获取我的任务的数量-->
<select id="getMyRwCount" resultType="java.lang.Integer">
select count(1) from tb_rw_task a where a.xt_scbz = '0' and a.xt_sjzt = '1'
<if test="dto.kssj != null and dto.jssj != null and dto.kssj != '' and dto.jssj != ''">
and a.rwfqsj &gt; #{kssj}
and a.rwfqsj &lt; #{jssj}
</if>
<if test="dto.rwmc != null and dto.rwmc != ''">
and a.rwmc like concat('%',#{dto.rwmc},'%')
</if>
<if test="dto.rwnr != null and dto.rwnr != ''">
and a.rwnr like concat('%',#{dto.rwnr},'%')
</if>
<if test="dto.rwxl != null and dto.rwxl != ''">
and a.rwxl = #{dto.rwxl}
</if>
<if test="dto.rwlx != null and dto.rwlx != ''">
and a.rwlx = #{dto.rwlx}
</if>
<if test="dto.rwjjcd != null and dto.rwjjcd != ''">
and a.rwjjcd = #{dto.rwjjcd}
</if>
<if test="dto.rwzt != null and dto.rwzt != ''">
and a.rwzt = #{dto.rwzt}
</if>
and a.id in (
select rwid from tb_rw_task_user b where b.xt_scbz = '0' and b.xt_sjzt = '1'
and case
when b.rwjsdx = '01' then b.jsrsfzh = #{sfzh}
when b.rwjsdx = '02' then b.jsbmdm = #{ssbmid}
when b.rwjsdx = '03' then
b.jsxzid in (select c.id from mosty_qwgl.tb_qw_xfbb c,mosty_qwgl.tb_qw_jl d where c.id = d.ywid and
c.xt_sjzt = '1' and c.xt_scbz = '0' and d.xt_sjzt = '1' and d.xt_scbz = '0' and
(c.fzr_sfzh = #{sfzh} or d.sfzh = #{sfzh}))
end
<if test="dto.grrwzt != null and dto.grrwzt != ''">
and b.rwzt = #{dto.grrwzt}
</if>
)
</select>
<select id="getCount" resultType="java.lang.Integer">
select count(1) from tb_rw_task a where a.xt_scbz = '0' and a.xt_sjzt = '1'
<if test="rwjxzt != null and rwjxzt != ''">
and a.rwjxzt = #{rwjxzt}
</if>
<if test="time != null">
and DATE_FORMAT(a.rwfqsj,'%Y-%m-%d')
between DATE_FORMAT(#{time},'%Y-%m-%d')
and DATE_FORMAT(now(),'%Y-%m-%d')
</if>
<if test="sfzh != null and sfzh != ''">
and a.id in (
select rwid from tb_rw_task_user b where b.jsrsfzh = #{sfzh}
)
</if>
</select>
<select id="getTaskByDept" resultType="Map">
select ssbmdm, ssbm, count(ssbmdm) as count
from tb_rw_task_user a
where a.xt_scbz = '0'
and a.xt_sjzt = '1'
and a.ssbmdm is not null
group by ssbmdm, ssbm
order by count(ssbmdm) desc;
</select>
<select id="getCountByDept" resultType="Integer">
select count(1) from tb_rw_task_user b where b.xt_scbz = '0' and b.xt_sjzt = '1'
and ssbmdm = #{ssbmdm}
<if test='type == "1"'>
and rwzt = '2'
</if>
<if test='type == "2"'>
and rwzt != '2'
</if>
</select>
<select id="myRwCount" resultType="Map">
select count(1) count, rwxl
from tb_rw_task_user b
where b.xt_scbz = '0'
and b.xt_sjzt = '1'
and case
when b.rwjsdx = '01' then b.jsrsfzh = #{sfzh}
when b.rwjsdx = '02' then b.jsbmdm = #{ssbmid}
when b.rwjsdx = '03' then
b.jsxzid in (select c.id
from mosty_qwgl.tb_qw_xfbb c,
mosty_qwgl.tb_qw_jl d
where c.id = d.ywid
and c.xt_sjzt = '1'
and c.xt_scbz = '0'
and d.xt_sjzt = '1'
and d.xt_scbz = '0'
and (c.fzr_sfzh = #{sfzh} or d.sfzh = #{sfzh}))
end
group by rwxl
</select>
<select id="rwCountByState" resultType="java.util.Map">
select count(1) count, rwjxzt from tb_rw_task a where a.xt_scbz = '0' and a.xt_sjzt = '1'
<if test="dto.kssj != null and dto.jssj != null and dto.kssj != '' and dto.jssj != ''">
and a.rwfqsj &gt; #{dto.kssj}
and a.rwfqsj &lt; #{dto.jssj}
</if>
<if test="dto.rwnr != null and dto.rwnr != ''">
and a.rwnr like concat('%',#{dto.rwnr},'%')
</if>
<if test="rwxlList != null and rwxlList.size() != 0">
and a.rwxl in
<foreach collection="rwxlList" open="(" separator="," close=")" item="item">
#{item}
</foreach>
</if>
<if test="rwjsdxList != null and rwjsdxList.size() != 0">
and a.rwjsdx in
<foreach collection="rwjsdxList" open="(" separator="," close=")" item="item">
#{item}
</foreach>
</if>
<if test="dto.rwzt != null and dto.rwzt != ''">
and a.rwzt = #{dto.rwzt}
</if>
group by rwjxzt
</select>
<select id="getYclTask" resultType="java.lang.Integer">
select count(1)
from tb_rw_task_user_all b
where b.xt_scbz = '0'
and b.xt_sjzt = '1'
and case
when b.rwjsdx = '01' then b.jsrsfzh = #{sfzh}
when b.rwjsdx = '02' then b.jsbmdm = #{ssbmid}
when b.rwjsdx = '03' then
b.jsxzid in (select c.id
from mosty_qwgl.tb_qw_xfbb c,
mosty_qwgl.tb_qw_jl d
where c.id = d.ywid
and c.xt_sjzt = '1'
and c.xt_scbz = '0'
and d.xt_sjzt = '1'
and d.xt_scbz = '0'
and (c.fzr_sfzh = #{sfzh} or d.sfzh = #{sfzh}))
end
and (grrwzt = '2' or rwjxzt = '3' or rwjxzt = '4')
</select>
<select id="getMyRwListYwc" resultType="com.mosty.base.model.entity.rwzx.TbRwTaskUserAll">
select * from tb_rw_task_user_all a where a.xt_scbz = '0' and a.xt_sjzt = '1'
<if test="dto.kssj != null and dto.jssj != null and dto.kssj != '' and dto.jssj != ''">
and a.rwfqsj &gt; #{kssj}
and a.rwfqsj &lt; #{jssj}
</if>
<if test="dto.rwxl != null and dto.rwxl != ''">
and a.rwxl = #{dto.rwxl}
</if>
<if test="dto.rwmc != null and dto.rwmc != ''">
and a.rwmc like concat('%',#{dto.rwmc},'%')
</if>
<if test="dto.rwnr != null and dto.rwnr != ''">
and a.rwnr like concat('%',#{dto.rwnr},'%')
</if>
<if test="dto.rwlx != null and dto.rwlx != ''">
and a.rwlx = #{dto.rwlx}
</if>
<if test="dto.rwjjcd != null and dto.rwjjcd != ''">
and a.rwjjcd = #{dto.rwjjcd}
</if>
<if test="dto.rwzt != null and dto.rwzt != ''">
and a.rwzt = #{dto.rwzt}
</if>
and case
when a.rwjsdx = '01' then a.jsrsfzh = #{sfzh}
when a.rwjsdx = '02' then a.jsbmdm = #{ssbmid}
when a.rwjsdx = '03' then
a.jsxzid in (select c.id from mosty_qwgl.tb_qw_xfbb c,mosty_qwgl.tb_qw_jl d where c.id = d.ywid and
c.xt_sjzt = '1' and c.xt_scbz = '0' and d.xt_sjzt = '1' and d.xt_scbz = '0' and
(c.fzr_sfzh = #{sfzh} or d.sfzh = #{sfzh}))
end
and (grrwzt = '2' or rwjxzt = '3' or rwjxzt = '4')
order by a.rwfqsj desc
limit #{pageIndex},#{pageSize}
</select>
<select id="getMyRwCountYwc" resultType="integer">
select count(1) from tb_rw_task_user_all a where a.xt_scbz = '0' and a.xt_sjzt = '1'
<if test="dto.kssj != null and dto.jssj != null and dto.kssj != '' and dto.jssj != ''">
and a.rwfqsj &gt; #{kssj}
and a.rwfqsj &lt; #{jssj}
</if>
<if test="dto.rwxl != null and dto.rwxl != ''">
and a.rwxl = #{dto.rwxl}
</if>
<if test="dto.rwmc != null and dto.rwmc != ''">
and a.rwmc like concat('%',#{dto.rwmc},'%')
</if>
<if test="dto.rwnr != null and dto.rwnr != ''">
and a.rwnr like concat('%',#{dto.rwnr},'%')
</if>
<if test="dto.rwlx != null and dto.rwlx != ''">
and a.rwlx = #{dto.rwlx}
</if>
<if test="dto.rwjjcd != null and dto.rwjjcd != ''">
and a.rwjjcd = #{dto.rwjjcd}
</if>
<if test="dto.rwzt != null and dto.rwzt != ''">
and a.rwzt = #{dto.rwzt}
</if>
and case
when a.rwjsdx = '01' then a.jsrsfzh = #{sfzh}
when a.rwjsdx = '02' then a.jsbmdm = #{ssbmid}
when a.rwjsdx = '03' then
a.jsxzid in (select c.id from mosty_qwgl.tb_qw_xfbb c,mosty_qwgl.tb_qw_jl d where c.id = d.ywid and
c.xt_sjzt = '1' and c.xt_scbz = '0' and d.xt_sjzt = '1' and d.xt_scbz = '0' and
(c.fzr_sfzh = #{sfzh} or d.sfzh = #{sfzh}))
end
and (grrwzt = '2' or rwjxzt = '3' or rwjxzt = '4')
</select>
<select id="checkHasNewTask" resultType="int">
select count(1)
from tb_rw_task_user b
where b.xt_scbz = '0'
and b.xt_sjzt = '1'
and case
when b.rwjsdx = '01' then b.jsrsfzh = #{sfzh}
when b.rwjsdx = '02' then b.jsbmdm = #{ssbmid}
when b.rwjsdx = '03' then
b.jsxzid in (select c.id
from mosty_qwgl.tb_qw_xfbb c,
mosty_qwgl.tb_qw_jl d
where c.id = d.ywid
and c.xt_sjzt = '1'
and c.xt_scbz = '0'
and d.xt_sjzt = '1'
and d.xt_scbz = '0'
and (c.fzr_sfzh = #{sfzh} or d.sfzh = #{sfzh}))
end
and date_format(rwfqsj, '%Y-%m-%d %H:%i:%s') >= #{time}
</select>
</mapper>