216 lines
11 KiB
XML
Raw Normal View History

2024-08-15 23:12:50 +08:00
<?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.ics.admin.mapper.RepairStatsMapper">
2024-08-29 23:01:48 +08:00
<!-- 人员绩效 维修工 -->
2024-08-17 01:05:19 +08:00
<select id="selectRepairWorkerStatsList" parameterType="com.ics.admin.vo.RepairWorkerStatsVo" resultType="com.ics.admin.vo.RepairWorkerStatsVo">
2024-08-15 23:12:50 +08:00
SELECT id, username, mobile, typeid, typename, zs, process, closed, Unresolved, pj,
case when pj>0 then CONCAT(h,'',ROUND(h/pj*100,1),'%') else '00%' end as h,
case when pj>0 then CONCAT(m,'',ROUND(m/pj*100,1),'%') else '00%' end as m,
case when pj>0 then CONCAT(l,'',ROUND(l/pj*100,1),'%') else '00%' end as l
2024-08-29 23:01:48 +08:00
FROM
<![CDATA[
(
select
user.id,user.username username,user.mobile,dt.id typeid,dt.name typename,
count(rep.id) as zs,
SUM(case when rep.status=5 or rep.status=7 then 1 else 0 end) as process,
SUM(case when rep.status=9 or rep.status=13 then 1 else 0 end) as closed,
SUM(case when rep.resolve=0 then 1 else 0 end) as Unresolved,
count(rep.eval_service) pj,
SUM(case when rep.eval_service>=4 then 1 else 0 end) as h,
SUM(case when rep.eval_service=3 then 1 else 0 end) as m,
SUM(case when rep.eval_service<=2 then 1 else 0 end) as l
from
ics_customer_staff user, ics_repair rep, ics_repair_device_type dt
where
user.delete_flag=0 and rep.delete_flag=0 and dt.delete_flag=0
and user.id=rep.repair_user_id and rep.type_id=dt.id
]]>
<if test="start != null and end != null">
and rep.create_time between #{start} and #{end}
</if>
<![CDATA[
and (rep.status=5 or rep.status=7 or rep.status=9 or rep.status=13)
GROUP BY
user.id,user.name,user.mobile,dt.id,dt.name
) tb
]]>
2024-08-15 23:12:50 +08:00
<where>
<if test="username != null and username != ''">AND username LIKE CONCAT('%', #{username}, '%')</if>
<if test="mobile != null and mobile != ''">AND mobile LIKE CONCAT('%', #{mobile}, '%')</if>
<if test="typeid != null">AND typeid = #{typeid}</if>
</where>
</select>
2024-08-29 23:01:48 +08:00
<!-- 人员绩效 楼层管理员 -->
2024-08-17 01:05:19 +08:00
<select id="selectRepairFloorStatsVoList" parameterType="com.ics.admin.vo.RepairFloorStatsVo" resultType="com.ics.admin.vo.RepairFloorStatsVo">
2024-08-15 23:12:50 +08:00
SELECT id, name, mobile, adr, zs, process, closed, Unresolved, pj,
case when pj>0 then CONCAT(h,'',ROUND(h/pj*100,1),'%') else '00%' end as h,
case when pj>0 then CONCAT(m,'',ROUND(m/pj*100,1),'%') else '00%' end as m,
case when pj>0 then CONCAT(l,'',ROUND(l/pj*100,1),'%') else '00%' end as l
2024-08-29 23:01:48 +08:00
FROM
<![CDATA[
(
select user.id,user.username name,user.mobile,group_concat(DISTINCT CONCAT(ad.name,'/',floor.name)) adr,
count(rep.id) as zs,
SUM(case when rep.status<9 then 1 else 0 end) as process,
SUM(case when rep.status>=9 then 1 else 0 end) as closed,
SUM(case when rep.resolve=0 then 1 else 0 end) as Unresolved,
count(rep.eval_service) pj,
SUM(case when rep.eval_service>=4 then 1 else 0 end) as h,
SUM(case when rep.eval_service=3 then 1 else 0 end) as m,
SUM(case when rep.eval_service<=2 then 1 else 0 end) as l
from
ics_customer_staff user, ics_repair_address ad, ics_repair_address_floor floor, ics_repair rep
where
user.delete_flag=0 and floor.delete_flag=0 and rep.delete_flag=0 and ad.delete_flag=0
and user.id=floor.admin_id and floor.address_id=ad.id and floor.id=rep.floor_id
]]>
<if test="start != null and end != null">
and rep.create_time between #{start} and #{end}
</if>
<![CDATA[
GROUP BY
user.id,user.name,user.mobile
) tb
]]>
2024-08-15 23:12:50 +08:00
<where>
<if test="name != null and name != ''">AND name LIKE CONCAT('%', #{name}, '%')</if>
<if test="mobile != null and mobile != ''">AND mobile LIKE CONCAT('%', #{mobile}, '%')</if>
<if test="adr != null and adr != ''">AND adr LIKE CONCAT('%', #{adr}, '%')</if>
</where>
</select>
2024-08-27 14:29:31 +08:00
<!-- 楼层管理员自行报修情况 -->
<select id="getRepairFloorCreateStats" resultType="com.ics.admin.vo.RepairFloorStatsVo">
<![CDATA[
SELECT id, name, mobile, zs, process, closed, unresolved, pj,
case when pj>0 then CONCAT(h,'',ROUND(h/pj*100,1),'%') else '00%' end as h,
case when pj>0 then CONCAT(m,'',ROUND(m/pj*100,1),'%') else '00%' end as m,
case when pj>0 then CONCAT(l,'',ROUND(l/pj*100,1),'%') else '00%' end as l
FROM
(
2024-08-29 23:01:48 +08:00
select user.id,user.username name,user.mobile,
2024-08-27 14:29:31 +08:00
count(rep.id) as zs,
SUM(case when rep.status<9 then 1 else 0 end) as process,
SUM(case when rep.status>=9 then 1 else 0 end) as closed,
SUM(case when rep.resolve=0 then 1 else 0 end) as unresolved,
count(rep.eval_service) pj,
SUM(case when rep.eval_service>=4 then 1 else 0 end) as h,
SUM(case when rep.eval_service=3 then 1 else 0 end) as m,
SUM(case when rep.eval_service<=2 then 1 else 0 end) as l
from
ics_customer_staff user, (select admin_id from ics_repair_address_floor where delete_flag=0 group by admin_Id) floor, ics_repair rep
where
user.delete_flag=0 and rep.delete_flag=0
and user.id=floor.admin_id and cast(user.id as char)=rep.create_by
]]>
<if test="startTime != null and endTime != null">
and rep.create_time between #{startTime} and #{endTime}
</if>
<if test="keywords != null and keywords != ''">
and (user.name LIKE CONCAT('%', #{keywords}, '%') or user.mobile like CONCAT('%', #{keywords}, '%'))
</if>
<![CDATA[
GROUP BY
user.id,user.name,user.mobile
) tb
]]>
</select>
2024-08-17 01:05:19 +08:00
<!-- 第一行 管理员 工单与 通知统计 -->
<select id="repairAdminStats" resultType="com.ics.admin.vo.RepairAdminStatsVo">
<![CDATA[
SELECT `wait`,`anew`,newnotice,oldnotice FROM
2024-08-30 00:30:34 +08:00
(SELECT count(id) as `wait` FROM ics_repair where delete_flag=0 and status=1) as A,
(SELECT count(id) as `anew` FROM ics_repair where delete_flag=0 and status=3) as B,
(select count(id) as newnotice from ics_repair_remind where `read`=0 and user_id= #{userId}) C,
(select count(id) as oldnotice from ics_repair_remind where `read`=1 and user_id= #{userId}) D
2024-08-17 01:05:19 +08:00
]]>
</select>
<!-- 第二、三行 工单统计、工单完成情况、评价情况 -->
<select id="repairStats" resultType="com.ics.admin.vo.RepairStatsVo">
2024-08-15 23:12:50 +08:00
<![CDATA[
SELECT
count(id) zs,
2024-08-30 00:30:34 +08:00
sum(case when status <= 7 then 1 else 0 end) `wait`,
2024-08-17 01:05:19 +08:00
sum(case when predate is not null and predate < now() and status < 9 then 1 else 0 end) timeout,
sum(case when eval_service is not null then 1 else 0 end) as pj,
sum(case when eval_service is not null and eval_service >=4 then 1 else 0 end) as h,
sum(case when eval_service is not null and eval_service =3 then 1 else 0 end) as m,
sum(case when eval_service is not null and eval_service <=2 then 1 else 0 end) as l,
sum(case when status > 7 then 1 else 0 end) wc,
sum(case when timeout =5 and status>=9 then 1 else 0 end) htimeout,
sum(case when timeout =3 and status>=9 then 1 else 0 end) mtimeout,
sum(case when timeout<=1 and status>=9 then 1 else 0 end) ntimeout
2024-08-15 23:12:50 +08:00
FROM
ics_repair
WHERE
2024-08-17 01:05:19 +08:00
delete_flag = 0 and create_time between #{startTime} and #{endTime}
2024-08-15 23:12:50 +08:00
]]>
</select>
2024-08-17 15:02:14 +08:00
<!-- 第四行 左侧 楼层负责人情况统计 -->
<select id="floorStats" resultType="com.ics.admin.vo.RepairFloorStatsVo">
<![CDATA[
SELECT USER.id, USER.NAME, count( rep.id ) AS zs,
SUM( CASE WHEN rep.STATUS >= 9 THEN 1 ELSE 0 END ) AS closed
FROM
ics_customer_staff USER,ics_repair_address_floor floor,ics_repair rep
WHERE
USER.delete_flag = 0 AND floor.delete_flag = 0 AND rep.delete_flag = 0
AND USER.id = floor.admin_id AND floor.id = rep.floor_id
and rep.create_time between #{startTime} and #{endTime}
GROUP BY USER.id,USER.NAME
order by zs desc
]]>
</select>
<!-- 第四行 右上 设备故障统计 -->
<select id="deviceStats" resultType="com.ics.admin.vo.RepairFloorStatsVo">
<![CDATA[
2024-08-30 01:10:31 +08:00
SELECT dt.id, dt.name, count(rep.id) AS zs, SUM(CASE WHEN rep.STATUS >= 9 THEN 1 ELSE 0 END) AS closed
FROM ics_repair_device_type dt, ics_repair rep
2024-08-17 15:02:14 +08:00
WHERE
2024-08-30 01:10:31 +08:00
dt.delete_flag = 0 AND rep.delete_flag = 0 AND dt.id = rep.type_id
2024-08-17 15:02:14 +08:00
and rep.create_time between #{startTime} and #{endTime}
2024-08-30 01:10:31 +08:00
GROUP BY dt.id, dt.NAME
2024-08-17 15:02:14 +08:00
order by zs desc
]]>
</select>
<!-- 第四行 右下 故障类型统计 -->
<select id="failureStats" resultType="com.ics.admin.vo.RepairFloorStatsVo">
<![CDATA[
SELECT
failure.id,failure.name,count( rep.id ) AS zs
FROM
ics_repair_failure_type failure,ics_repair rep
WHERE
rep.delete_flag = 0 AND failure.delete_flag = 0 and (rep.status=9 or rep.status=13)
AND failure.id = rep.failure_type_id and rep.create_time between #{startTime} and #{endTime}
GROUP BY failure.id,failure.NAME order by zs desc
]]>
</select>
<!-- 第五行 设备、品牌、评价 统计 -->
<select id="deviceTypeStats" resultType="com.ics.admin.vo.RepairDivceTypeStatsVo">
<![CDATA[
SELECT dt.id typeid, dt.name typename, device.name devicename, device.brand,
count(rep.id) AS zs,
sum(CASE WHEN rep.STATUS >= 9 THEN 1 ELSE 0 END) AS closed,
sum(case when eval_service is not null then 1 else 0 end) as pj,
sum(case when eval_service is not null and eval_service >=4 then 1 else 0 end) as h,
sum(case when eval_service is not null and eval_service =3 then 1 else 0 end) as m,
sum(case when eval_service is not null and eval_service <=2 then 1 else 0 end) as l
FROM ics_repair_device_type dt, ics_repair_device device, ics_repair rep
WHERE
dt.delete_flag=0 and device.delete_flag = 0 AND rep.delete_flag = 0
and dt.id=device.type_id AND device.id = rep.device_id
and rep.create_time between #{startTime} and #{endTime}
GROUP BY dt.id, dt.name, device.name
order by zs desc
]]>
</select>
2024-08-15 23:12:50 +08:00
</mapper>