局长信箱-后台服务
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

500 lines
22 KiB

<?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.biutag.lan.mapper.DataScreenMapper">
<select id="selectRecentlyMailListByFirst" resultType="com.biutag.lan.domain.Mail">
select a.id,contact_name,contact_phone,a.create_time ,b.name mail_state from mail a
left join dict_data b on a.mail_state=b.value
left join mail_mark c on a.id=c.mail_id
where a.first_dept_id=#{id}
order by a.create_time desc limit 20;
</select>
<select id="selectRecentlyMailList" resultType="com.biutag.lan.domain.Mail">
select a.id,contact_name,contact_phone,a.create_time ,b.name mail_state from mail a
left join dict_data b on a.mail_state=b.value
left join mail_mark c on a.id=c.mail_id
where 1=1
<if test="id != null and id != ''">and a.second_dept_id=#{id}</if>
order by a.create_time desc limit 20;
</select>
<select id="getCompletedRate" resultType="java.util.Map">
select a.short_name,
ROUND(sum(COALESCE(CAST(b.completed AS INTEGER), 0)) * 100 / count(1), 0) rateNumber,
CONCAT(rateNumber, '%') rate,
SUM(COALESCE(CAST(b.completed AS INTEGER), 0)) completed,
count(b.mail_id) sum
from dept a left join mail m on a.id = m.first_dept_id left join mail_mark b on b.mail_id = m.id
where a.category = '1'
group by a.short_name
order by rateNumber desc
</select>
<select id="getResolvedRate" resultType="java.util.Map">
select t.short_name,
t.resolved,
t.sum,
CASE WHEN t.sum = 0 THEN 0 ELSE ROUND((t.resolved / t.sum) * 100) END AS rateNumber,
concat(rateNumber, '%') rate
from (select a.short_name,
SUM(COALESCE(CAST(b.resolved AS INTEGER), 0)) resolved,
SUM(CASE WHEN b.completed = '1' THEN 1 ELSE 0 END) sum
from dept a left join mail m on a.id = m.first_dept_id left join mail_mark b on b.mail_id = m.id
where a.category = '1'
group by a.short_name) t
order by rateNumber desc
</select>
<select id="getSatisfiedRate" resultType="java.util.Map">
select a.id,
a.short_name,
SUM(COALESCE(CAST(b.satisfied AS INTEGER), 0)) satisfied,
SUM(CASE WHEN b.completed = '1' THEN 1 ELSE 0 END) sum,
CASE WHEN sum = 0 THEN 0 ELSE ROUND(sum(COALESCE(CAST(b.satisfied AS INTEGER), 0))*100/sum,0) END rateNumber,
CONCAT(rateNumber,'%') rate
from dept a left join mail m on a.id = m.first_dept_id left join mail_mark b on b.mail_id = m.id
where a.category = '1'
group by a.short_name, a.id
order by rateNumber desc
</select>
<select id="getStationCompletedRateByDept" resultType="java.util.Map">
SELECT A.short_name,
SUM(COALESCE(CAST(b.completed AS INTEGER), 0)) completed,
COUNT(b.mail_id) SUM,
CASE
WHEN SUM = 0 THEN
0 ELSE ROUND( SUM ( COALESCE (CAST(b.completed AS INTEGER), 0 ) ) * 100 / SUM, 0 )
END ratenumber
,
CONCAT ( ratenumber, '%' ) rate
from dept a left join mail_mark b on
<choose>
<when test="level == 1">
a.id=b.second_dept_id
</when>
<otherwise>
a.id=b.three_dept_id
</otherwise>
</choose>
where a.pid= #{deptId}
GROUP BY a.short_name
order by ratenumber desc , sum desc
</select>
<select id="getStationResolvedRateByDept" resultType="java.util.Map">
select a.short_name,
ROUND(sum(COALESCE(CAST(b.resolved AS INTEGER), 0)) * 100 / count(1), 0) ratenumber,
CONCAT(ratenumber, '%') rate,
SUM(COALESCE(CAST(b.resolved AS INTEGER), 0)) resolved,
count(b.mail_id) sum
from dept a left join mail_mark b on
<choose>
<when test="level == 1">
a.id=b.second_dept_id
</when>
<otherwise>
a.id=b.three_dept_id
</otherwise>
</choose>
where a.pid=#{deptId}
GROUP BY a.short_name
order by ratenumber desc, sum desc
</select>
<select id="getStationSatisfiedRateByDept" resultType="java.util.Map">
select a.short_name,
SUM(COALESCE(CAST(b.satisfied AS INTEGER), 0)) satisfied,
count(b.mail_id) sum,
ROUND(sum(COALESCE(CAST(b.satisfied AS INTEGER), 0))*100/count(1),0) ratenumber,
CONCAT(ratenumber,'%') rate
from dept a
left join mail_mark b on
<choose>
<when test="level == 1">
a.id=b.second_dept_id
</when>
<otherwise>
a.id=b.three_dept_id
</otherwise>
</choose>
where a.pid=#{deptId}
GROUP BY a.short_name order by ratenumber desc ,sum desc
</select>
<select id="getTodayMailCount" resultType="int">
select count(1) mailCount from mail where create_time>=CURRENT_DATE
<if test="deptId != null and deptId != ''">and second_dept_id=#{deptId}</if>
</select>
<select id="getAllMailCount" resultType="int">
select count(1) as countSum from mail_mark where 1=1
<if test="deptId != null and deptId != ''">and second_dept_id=#{deptId}</if>
</select>
<select id="getResolvedRateByDeptId" resultType="java.util.Map">
select b.second_dept_name name,
CONCAT(ROUND(sum(COALESCE(CAST(b.resolved AS INTEGER), 0))*100/SUM(CASE WHEN b.completed = '1' THEN 1 ELSE 0 END),0),'%') rate,
SUM(COALESCE(CAST(b.resolved AS INTEGER), 0)) resolved,
SUM(CASE WHEN b.completed = '1' THEN 1 ELSE 0 END) sum
from dept a inner join mail_mark b on a.id=b.second_dept_id where a.category='2'
<if test="deptId != null and deptId != ''">and b.second_dept_id=#{deptId} GROUP BY second_dept_name</if>
</select>
<select id="getAllResolvedRate" resultType="java.util.Map">
SELECT
resolved,
resolvedSum,
CONCAT ( CASE WHEN resolvedSum = 0 THEN 0 ELSE resolved * 100 / resolvedSum END, '%' ) resolvedRate
FROM
(SELECT
COALESCE(SUM( CASE WHEN b.resolved = '1' THEN 1 ELSE 0 END ), 0) resolved,
COALESCE(SUM ( CASE WHEN b.completed = '1' THEN 1 ELSE 0 END ), 0) resolvedSum
from mail_mark b
left join dept a on a.id=b.second_dept_id
where 1 = 1
<if test="deptId != null and deptId != ''">
and a.category='2' and b.second_dept_id=#{deptId} GROUP BY second_dept_name
</if>
)
</select>
<select id="getAllCompletedRate" resultType="java.util.Map">
select
COALESCE(SUM(CAST ( b.completed AS INTEGER ) ), 0) AS completedVal,
COUNT ( 1 ) AS completedSum,
CONCAT (CASE WHEN completedSum = 0 THEN 0 ELSE ROUND( completedVal * 100 / completedSum ) END, '%' ) AS completedRate
from mail_mark b left join dept a on a.id=b.second_dept_id where 1=1
<if test="deptId != null and deptId != ''">and a.category='2' and b.second_dept_id=#{deptId} GROUP BY
second_dept_name
</if>
</select>
<select id="getAllSatisfiedRate" resultType="java.util.Map">
SELECT
COALESCE(SUM (CASE WHEN b.satisfied = '1' THEN 1 ELSE 0 END), 0) AS satisfiedVal,
COALESCE(SUM ( CASE WHEN b.completed = '1' THEN 1 ELSE 0 END ), 0) AS satisfiedsum,
CONCAT(CASE WHEN satisfiedsum = 0 THEN 0 ELSE ROUND(satisfiedVal / satisfiedsum * 100) END, '%') AS satisfiedRate
FROM
(
SELECT
mm.completed,
mm.satisfied,
mm.second_dept_id
FROM
mail_mark mm
LEFT JOIN mail M ON mm.mail_id = M.ID
WHERE
M.SOURCE NOT IN ( '警务评议案件当事人不满意样本', '警务评议110不满意样本' )
) b
LEFT JOIN dept A ON A.ID = b.second_dept_id
WHERE
1 = 1
<if test="deptId != null and deptId != ''">
and a.category='2' and b.second_dept_id=#{deptId} GROUP BY second_dept_id
</if>
</select>
<select id="mailTypeRank" resultType="java.util.Map">
select ROW_NUMBER() OVER (ORDER BY sumCount desc) AS rownumber ,
mail_first_category category,
count(1) sumcount ,
(select count(1) from mail where 1=1
<if test="id != null and id != ''">
<choose>
<when test="level == 1">
and first_dept_id=#{id}
</when>
<otherwise>
and second_dept_id=#{id}
</otherwise>
</choose>
</if>) AS denominator,
CONCAT(ROUND(CASE WHEN denominator = 0 THEN 0 ELSE sumCount * 100 / denominator END,0),'%') countRate
FROM mail
where mail_time > '2025-09-13'
<if test="id != null and id != ''">
<choose>
<when test="level == 1">
and first_dept_id=#{id}
</when>
<otherwise>
and second_dept_id=#{id}
</otherwise>
</choose>
</if>
GROUP BY
mail_first_category
order by sumCount desc
LIMIT 10
</select>
<select id="getMailDayTrend" resultType="java.util.Map">
select TO_CHAR(create_time, 'YYYY/MM/DD') create_time,count(1) countsum from mail
WHERE
1=1
<if test="deptId != null and deptId != ''">
and second_dept_id=#{deptId}
</if>
<if test="startDate != null and startDate != ''">
and create_time between #{startDate} and #{endDate}
</if>
group by TO_CHAR(create_time, 'YYYY/MM/DD') order by create_time
</select>
<select id="getMailWeekTrend" resultType="java.util.Map">
select countSum ,(year || '/' || week) week from (
SELECT
EXTRACT(YEAR FROM create_time) AS year,
EXTRACT(WEEK FROM create_time) AS week ,
count(1) countSum
FROM mail WHERE 1=1
<if test="deptId != null and deptId != ''">
and second_dept_id=#{deptId}
</if>
<if test="startDate != null and startDate != ''">
and create_time between #{startDate} and #{endDate}
</if>
GROUP BY year,week order by year,week) a
</select>
<select id="getMailMonthTrend" resultType="com.biutag.lan.domain.vo.MonthValue">
SELECT
to_char(create_time::DATE, 'MM') AS month ,
count(1) count_sum
FROM mail where
1=1
<if test="deptId != null and deptId != ''">
and second_dept_id=#{deptId}
</if>
<if test="year != null and year != ''">
and EXTRACT(YEAR FROM create_time)=#{year}
</if>
GROUP BY month order by month
</select>
<select id="mapData" resultType="com.biutag.lan.domain.vo.MapData">
SELECT d.name, a.id,
( SELECT COUNT ( 1 ) FROM mail C WHERE C.create_time >= CURRENT_DATE AND C.first_dept_id = A.ID ) AS today_sum,
COUNT ( b.mail_id ) AS all_sum,
SUM ( COALESCE ( CAST ( b.completed AS INTEGER ), 0 ) ) AS completed_val,
CASE WHEN all_sum = 0 THEN 0 ELSE ROUND(completed_val * 100 / all_sum,0) END AS value,
CONCAT(value, '%') AS completed_rate,
SUM ( COALESCE ( CAST ( b.resolved AS INTEGER ), 0 ) ) AS resolved_val,
CONCAT(CASE WHEN completed_val = 0 THEN 0 ELSE ROUND(resolved_val * 100 / completed_val, 0) END,'%') AS resolved_rate,
SUM ( COALESCE ( CAST ( b.satisfied AS INTEGER ), 0 ) ) AS satisfied_val,
CONCAT(CASE WHEN completed_val = 0 THEN 0 ELSE ROUND(satisfied_val * 100 / completed_val, 0) END,'%') AS satisfied_rate
FROM
mail_mark b
RIGHT JOIN mail M ON M.ID = b.mail_id
RIGHT JOIN dept A ON A.ID = M.first_dept_id
LEFT JOIN county_street_dept d ON A.ID = d.dept_id
WHERE
A.LEVEL = 1
AND A.category = 1
GROUP BY
d.name,
A.id
order by value DESC
</select>
<select id="mapDataBySecond" resultType="com.biutag.lan.domain.vo.MapData" parameterType="java.lang.String">
SELECT d.name, d.dept_id id,
( SELECT COUNT ( 1 ) FROM mail C WHERE C.create_time >= CURRENT_DATE AND C.second_dept_id = d.dept_id ) AS today_sum,
COUNT ( b.mail_id ) AS all_sum,
SUM ( COALESCE ( CAST ( b.completed AS INTEGER ), 0 ) ) AS completed_val,
CASE WHEN all_sum = 0 THEN 0 ELSE ROUND(completed_val * 100 / all_sum,0) END AS value,
CONCAT(value, '%') AS completed_rate,
SUM ( COALESCE ( CAST ( b.resolved AS INTEGER ), 0 ) ) AS resolved_val,
CONCAT(CASE WHEN completed_val = 0 THEN 0 ELSE ROUND(resolved_val * 100 / completed_val, 0) END,'%') AS resolved_rate,
SUM ( COALESCE ( CAST ( b.satisfied AS INTEGER ), 0 ) ) AS satisfied_val,
CONCAT(CASE WHEN completed_val = 0 THEN 0 ELSE ROUND(satisfied_val * 100 / completed_val, 0) END,'%') AS satisfied_rate
FROM
county_street_dept d
LEFT JOIN mail_mark b ON b.second_dept_id = d.dept_id
WHERE
d.pid = #{deptId}
GROUP BY
d.name,
d.dept_id
order by value DESC
</select>
<select id="mapDataByThree" resultType="com.biutag.lan.domain.vo.MapData" parameterType="java.lang.String">
SELECT d.name, d.dept_id id,
( SELECT COUNT ( 1 ) FROM mail C WHERE C.create_time >= CURRENT_DATE AND C.three_dept_id = d.dept_id ) AS today_sum,
COUNT ( b.mail_id ) AS all_sum,
SUM ( COALESCE ( CAST ( b.completed AS INTEGER ), 0 ) ) AS completed_val,
CASE WHEN all_sum = 0 THEN 0 ELSE ROUND(completed_val * 100 / all_sum,0) END AS value,
CONCAT(value, '%') AS completed_rate,
SUM ( COALESCE ( CAST ( b.resolved AS INTEGER ), 0 ) ) AS resolved_val,
CONCAT(CASE WHEN completed_val = 0 THEN 0 ELSE ROUND(resolved_val * 100 / completed_val, 0) END,'%') AS resolved_rate,
SUM ( COALESCE ( CAST ( b.satisfied AS INTEGER ), 0 ) ) AS satisfied_val,
CONCAT(CASE WHEN completed_val = 0 THEN 0 ELSE ROUND(satisfied_val * 100 / completed_val, 0) END,'%') AS satisfied_rate
FROM
county_street_dept d
LEFT JOIN mail_mark b ON b.three_dept_id = d.dept_id
WHERE
d.pid = #{deptId}
GROUP BY
d.name,
d.dept_id
order by value DESC
</select>
<select id="currentCountyMapJSON" resultType="java.util.Map" parameterType="java.lang.String">
select geometry from county_street_dept where 1=1
<if test="deptId != null and deptId != ''">and dept_id=#{deptId}</if>
limit 1
</select>
<select id="selectDutyListByTodayAndDeptPId" resultType="com.biutag.entity.system.Duty">
select distinct on (a.depart_id, a.emp_no,b.sort) a.* from duty a
inner join dept b on a.depart_id=b.id where
now() BETWEEN to_date(a.start_time) + interval '9 H' and (to_date(a.end_time) + interval '33 H')
<if test="deptType!=null and deptType!=''">
and a.dept_type=#{deptType}
</if>
<if test="deptPId != null">
and b.pid=#{deptPId}
</if>
order by b.sort asc
</select>
<select id="selectDutyListByTodayAndDeptId" resultType="com.biutag.entity.system.Duty">
select distinct on (a.depart_id, a.emp_no,b.sort) a.* from duty a
inner join dept b on a.depart_id=b.id where
now() BETWEEN to_date(a.start_time) + interval '9 H' and (to_date(a.end_time) + interval '33 H')
<if test="deptType!=null and deptType!=''">
and a.dept_type=#{deptType}
</if>
<if test="deptId!=null">
and b.id=#{deptId}
</if>
order by b.sort asc
</select>
<select id="getMailDetail" resultType="com.biutag.lan.domain.vo.MailDetail">
select *
from mail
where id = #{id} limit 1
</select>
<select id="getVerifyPolice" resultType="java.util.Map">
select name, emp_no, id_code, gender, birthday, (select name from dept where id = #{deptId} limit 1) deptName
from police_user
where emp_no =#{empNo} limit 1
</select>
<select id="getDuration" resultType="java.util.Map">
select consuming_time,limited_time from mail_flow
where 1=1
<if test="mailId != null and mailId != ''">and mail_id=#{mailId}</if>
<if test="flowKey != null and flowKey != ''">and flow_key =#{flowKey}</if>
order by create_time desc limit 1
</select>
<select id="getOtherStationCompletedRateByDept" resultType="java.util.Map" parameterType="String">
select b.three_dept_name name,
CONCAT(ROUND(sum(COALESCE(CAST(b.completed AS INTEGER), 0)) * 100 / count(1), 0), '%') rate,
ROUND(sum(COALESCE(CAST(b.completed AS INTEGER), 0)) * 100 / count(1), 0) rateNumber,
SUM(COALESCE(CAST(b.completed AS INTEGER), 0)) completed,
count(1) sum
from dept a inner join mail_mark b
on a.id=b.second_dept_id
where b.second_dept_id=#{deptId}
GROUP BY three_dept_name
order by rateNumber desc, sum desc limit 10
</select>
<select id="getOtherStationResolvedRateByDept" resultType="java.util.Map" parameterType="String">
select b.three_dept_name name,
CONCAT(ROUND(sum(COALESCE(CAST(b.resolved AS INTEGER), 0)) * 100 / count(1), 0), '%') rate,
ROUND(sum(COALESCE(CAST(b.resolved AS INTEGER), 0)) * 100 / count(1), 0) rateNumber,
SUM(COALESCE(CAST(b.resolved AS INTEGER), 0)) resolved,
count(1) sum
from dept a inner join mail_mark b
on a.id=b.second_dept_id
where b.second_dept_id=#{deptId}
GROUP BY three_dept_name
order by rateNumber desc, sum desc limit 10
</select>
<select id="getOtherStationSatisfiedRateByDept" resultType="java.util.Map" parameterType="String">
select b.three_dept_name name,
CONCAT(ROUND(sum(COALESCE(CAST(b.satisfied AS INTEGER), 0)) * 100 / count(1), 0), '%') rate,
ROUND(sum(COALESCE(CAST(b.satisfied AS INTEGER), 0)) * 100 / count(1), 0) rateNumber,
SUM(COALESCE(CAST(b.satisfied AS INTEGER), 0)) satisfied,
count(1) sum
from dept a inner join mail_mark b
on a.id=b.second_dept_id
where b.second_dept_id=#{deptId}
GROUP BY three_dept_name
order by rateNumber desc, sum desc limit 10
</select>
<select id="getOtherCompletedRate" resultType="java.util.Map">
select a.name,
CONCAT(ROUND(sum(COALESCE(CAST(b.completed AS INTEGER), 0)) * 100 / count(1), 0), '%') rate,
ROUND(sum(COALESCE(CAST(b.completed AS INTEGER), 0)) * 100 / count(1), 0) rateNumber,
SUM(COALESCE(CAST(b.completed AS INTEGER), 0)) completed,
count(1) sum
from dept a left join mail_mark b
on a.id = b.second_dept_id
where
a.level = '2'
and (((a.category = '3'
or a.category = '4')
and a.name != '交警支队')
or a.name = '公交分局'
or a.name = '森林公安局'
or a.name = '经开区分局')
group by a.name
order by rateNumber desc
</select>
<select id="getOtherResolvedRate" resultType="java.util.Map">
select a.name,
CONCAT(ROUND(sum(COALESCE(CAST(b.resolved AS INTEGER), 0)) * 100 / count(1), 0), '%') rate,
ROUND(sum(COALESCE(CAST(b.resolved AS INTEGER), 0)) * 100 / count(1), 0) rateNumber,
SUM(COALESCE(CAST(b.resolved AS INTEGER), 0)) resolved,
count(1) sum
from dept a left join mail_mark b
on a.id = b.second_dept_id
where
a.level = '2'
and (((a.category = '3'
or a.category = '4')
and a.name != '交警支队')
or a.name = '公交分局'
or a.name = '森林公安局'
or a.name = '经开区分局')
group by a.name
order by rateNumber desc
</select>
<select id="getOtherSatisfiedRate" resultType="java.util.Map">
select a.name,
CONCAT(ROUND(sum(COALESCE(CAST(b.satisfied AS INTEGER), 0)) * 100 / count(1), 0), '%') rate,
ROUND(sum(COALESCE(CAST(b.satisfied AS INTEGER), 0)) * 100 / count(1), 0) rateNumber,
SUM(COALESCE(CAST(b.satisfied AS INTEGER), 0)) satisfied,
count(1) sum
-- from dept a left join mail_mark b on a.id=b.second_dept_id where a.category='2' GROUP BY a.name order by rateNumber desc limit 10
from dept a left join mail_mark b
on a.id = b.second_dept_id
where
a.level = '2'
and (((a.category = '3'
or a.category = '4')
and a.name != '交警支队')
or a.name = '公交分局'
or a.name = '森林公安局'
or a.name = '经开区分局')
group by a.name
order by rateNumber desc
</select>
</mapper>