count((it.ITEM_STATE=5 or it.ITEM_STATE=10) or null) as resolvedNum,
ifnull(format(round(count((it.ITEM_STATE=5 or it.ITEM_STATE=10) or null)/count(it.id),4),4),'0.0000') as resolvedRatio,
ifnull(format(round(count((it.EVALUATION_SCORE=1 or it.EVALUATION_SCORE=2) or null)/count(it.id),4),4),'0.0000') as goodRatio,
count( (it.EVALUATION_SCORE=0 or it.EVALUATION_SCORE=1 or it.EVALUATION_SCORE=2) or null) as evaluateTotal,
count( (it.EVALUATION_SCORE=1 or it.EVALUATION_SCORE=2) or null) as goodTotal,
count( it.EVALUATION_SCORE=0 or null) as badTotal,
ifnull(format(round(count(it.EVALUATION_SCORE=0 or null)/count( (it.EVALUATION_SCORE=0 or it.EVALUATION_SCORE=1 or it.EVALUATION_SCORE=2) or null),4),4),'0.0000') as badRatio
SELECT st.`id` AS orgId,
'street' as orgType,
st.pid AS pid,
st.pids AS pids,
count(it.id) as projectTotal,
count((it.ITEM_STATE=5 or it.ITEM_STATE=10) or null) as resolvedNum,
ifnull(format(round(count((it.ITEM_STATE=5 or it.ITEM_STATE=10) or null)/count(it.id),4),4),'0.0000') as resolvedRatio,
ifnull(format(round(count((it.EVALUATION_SCORE=1 or it.EVALUATION_SCORE=2) or null)/count(it.id),4),4),'0.0000') as goodRatio,
count( (it.EVALUATION_SCORE=0 or it.EVALUATION_SCORE=1 or it.EVALUATION_SCORE=2) or null) as evaluateTotal,
count( (it.EVALUATION_SCORE=1 or it.EVALUATION_SCORE=2) or null) as goodTotal,
count( it.EVALUATION_SCORE=0 or null) as badTotal,
ifnull(format(round(count(it.EVALUATION_SCORE=0 or null)/count( (it.EVALUATION_SCORE=0 or it.EVALUATION_SCORE=1 or it.EVALUATION_SCORE=2) or null),4),4),'0.0000') as badRatio
FROM `esua_epdc_admin`.`sys_dept` sd
left join `esua_epdc_admin`.`sys_dept` co on co.id=sd.pid
left join `esua_epdc_admin`.`sys_dept` st on st.id=co.pid
left join (select lin.* from (select * from esua_epdc_events.epdc_item order by id) lin
where lin.DEL_FLAG=0
AND date_format( lin.CREATED_TIME, '%Y-%m-%d' ) <= #{yesterDayDate}
group by lin.EVENT_ID) it on it.GRID_ID=sd.id
WHERE sd.`del_flag`= 0
AND sd.`type_key`= 'grid_party'
AND sd.`id` NOT IN( SELECT t.`dept_id`
FROM `esua_epdc_admin`.`sys_dept_config` t
WHERE t.`del_flag`= 0)
group by st.id
where lin.DEL_FLAG=0
AND date_format( lin.CREATED_TIME, '%Y-%m-%d' ) <=#{yesterDayDate}
group by lin.EVENT_ID) it on it.GRID_ID=sd.id
WHERE sd.`del_flag`= 0
AND sd.`type_key`= 'grid_party'
AND sd.`id` NOT IN( SELECT t.`dept_id`
FROM `esua_epdc_admin`.`sys_dept_config` t
WHERE t.`del_flag`= 0)
group by st.id
union all
SELECT co.`id` AS orgId,
'community' as orgType,
co.pid AS pid,
co.pids AS pids,
count(it.id) as projectTotal,
count((it.ITEM_STATE=5 or it.ITEM_STATE=10) or null) as resolvedNum,
ifnull(format(round(count((it.ITEM_STATE=5 or it.ITEM_STATE=10) or null)/count(it.id),4),4),'0.0000') as resolvedRatio,
ifnull(format(round(count((it.EVALUATION_SCORE=1 or it.EVALUATION_SCORE=2) or null)/count(it.id),4),4),'0.0000') as goodRatio,
count( (it.EVALUATION_SCORE=0 or it.EVALUATION_SCORE=1 or it.EVALUATION_SCORE=2) or null) as evaluateTotal,
count( (it.EVALUATION_SCORE=1 or it.EVALUATION_SCORE=2) or null) as goodTotal,
count( it.EVALUATION_SCORE=0 or null) as badTotal,
ifnull(format(round(count(it.EVALUATION_SCORE=0 or null)/count( (it.EVALUATION_SCORE=0 or it.EVALUATION_SCORE=1 or it.EVALUATION_SCORE=2) or null),4),4),'0.0000') as badRatio
FROM `esua_epdc_admin`.`sys_dept` sd
left join `esua_epdc_admin`.`sys_dept` co on co.id=sd.pid
left join (select lin.* from (select * from esua_epdc_events.epdc_item order by id) lin
where lin.DEL_FLAG=0
AND date_format( lin.CREATED_TIME, '%Y-%m-%d' ) <=#{yesterDayDate}