2024-08-15 23:12:50 +08:00
|
|
|
CREATE VIEW worker_stats AS
|
|
|
|
select
|
2024-08-29 23:01:48 +08:00
|
|
|
user.id,user.username username,user.mobile,dt.id typeid,dt.name typename,
|
2024-08-15 23:12:50 +08:00
|
|
|
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
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
CREATE VIEW floor_stats AS
|
2024-08-29 23:01:48 +08:00
|
|
|
select user.id,user.username name,user.mobile,group_concat(DISTINCT CONCAT(ad.name,'/',floor.name)) adr,
|
2024-08-15 23:12:50 +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, 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
|
|
|
|
GROUP BY
|
|
|
|
user.id,user.name,user.mobile
|
|
|
|
|
|
|
|
|