when (select ID from esua_epdc_events.epdc_item_handle_process where STATE != 10 and DEL_FLAG ='0' and ITEM_ID = t1.ID group by t1.ID) is null then 1
else 2 end as projectLevel
when t1.ITEM_STATE = 0 and (select COUNT(1) from esua_epdc_events.epdc_item_handle_process where DEL_FLAG ='0' and ITEM_ID = t1.ID) = 1 then 1
when (t1.ITEM_STATE = 0 or t1.ITEM_STATE = 5) and (select COUNT(1) from esua_epdc_events.epdc_item_handle_process where DEL_FLAG ='0' and ITEM_ID = t1.ID) > 1 then 2
else '' end as projectLevel
from (select * from(select * from esua_epdc_events.epdc_item where DEL_FLAG = '0'
and GRID_ID not in ( SELECT t.`dept_id`
FROM `esua_epdc_admin`.`sys_dept_config` t
@ -56,8 +57,8 @@
order by ID)a group by a.EVENT_ID) t1
left join esua_epdc_events.epdc_img t2 on t1.EVENT_ID = t2.REFERENCE_ID and t1.DEL_FLAG = '0'
left join esua_epdc_events.epdc_item_handle_process t3 on t3.ITEM_ID = t1.ID and t3.DEL_FLAG = '0' and t3.STATE = 10
where date_format(t1.UPDATED_TIME, '%Y-%m-%d') >= STR_TO_DATE(#{yearMonthDay}, '%Y-%m-%d')
and date_format(t1.UPDATED_TIME, '%Y-%m-%d') <= date_sub(curdate(),interval 1 day)
when (t4.ID is not null and t1.STATE = 0 and t1.CREATED_TIME != (select min(t.CREATED_TIME) from esua_epdc_events.epdc_item_handle_process t where t.DEL_FLAG = '0' and t1.ITEM_ID = t.ITEM_ID group by t.ITEM_ID)) then 'transfer'
when (t4.ID is null and t1.STATE = 0 and t1.CREATED_TIME != (select min(t.CREATED_TIME) from esua_epdc_events.epdc_item_handle_process t where t.DEL_FLAG = '0' and t1.ITEM_ID = t.ITEM_ID group by t.ITEM_ID)) then 'response'
when (t1.STATE = 0 and t1.CREATED_TIME = (select min(t.CREATED_TIME) from esua_epdc_events.epdc_item_handle_process t where t.DEL_FLAG = '0' and t1.ITEM_ID = t.ITEM_ID group by t.ITEM_ID)) then 'created'
when t1.STATE = 5 then 'close'
when t1.STATE = 10 then 'closed_case'
else '' END as operation,
when t1.STATE = 5 then 'close'
when (t4.ID is not null and t1.STATE = 0 ) then 'transfer'
when (t1.STATE = 0 and t1.CREATED_TIME = (select min(t.CREATED_TIME) from esua_epdc_events.epdc_item_handle_process t where t.DEL_FLAG = '0' and t1.ITEM_ID = t.ITEM_ID group by t.ITEM_ID)) then 'created'
else 'response' END as operation,
t1.OUT_HANDLE_ADVICE as publicReply,
t1.HANDLE_ADVICE as internalRemark,
t1.CREATED_TIME as processTime
from esua_epdc_events.epdc_item_handle_process t1
left join esua_epdc_events.epdc_item_dept t4 on t4.ITEM_HANDLE_ID = t1.ID and t4.DEL_FLAG = '0'
where date_format(t1.UPDATED_TIME, '%Y-%m-%d') >= STR_TO_DATE(#{yearMonthDay}, '%Y-%m-%d')
and date_format(t1.UPDATED_TIME, '%Y-%m-%d') <= date_sub(curdate(),interval 1 day) and t1.DEL_FLAG = '0'
left join esua_epdc_events.epdc_item_dept t4 on t4.ITEM_HANDLE_ID = t1.ID
where t1.UPDATED_TIME >= #{yearMonthDay}
and t1.UPDATED_TIME <= now() and t1.DEL_FLAG = '0'
and t1.HANDLER_DEPT_ID not in ( SELECT t.`dept_id`