select t1.*, t3.short_name countyName, t4.id schemeId, t4.file_id schemeFileId
from fhzg_grid_operation_abnormality t1
left join dwd_shb_ds_feeder_base t2 on t1.line_id = t2.psr_id
left join sys_dept t3 on t3.isc_org_id = t2.maint_org
left join fhzg_operation_abnormality_transfer_scheme t4 on t1.id =t4.oa_id
and t3.dept_id = #{queryDTO.countyCode}
AND t3.dept_id IN
#{item}
and t1.line_name like concat('%',#{queryDTO.feederName},'%')
and t1.alarm_start_time > #{queryDTO.volStartTime}
and t1.alarm_end_time < #{queryDTO.volEndTime}
order by t1.alarm_start_time desc
with line_switch_tab as (
select f.line_id bdg_line_id,e.switch_id dk_kg_id,d.line_id dg_line_id,s.switch_id bh_kg_id,e.switching_seq
from fhzg_operation_abnormality_switching_sequence s
join fhzg_operation_abnormality_await_transfer_path_detail d on d.oa_id=s.oa_id and d.close_switch_id=s.switch_id
join fhzg_operation_abnormality_await_transfer_path_detail f on d.group_line_id=f.group_line_id and f.close_switch_id is null
join (select oa_id, (switching_seq - 1) switch_seq, switch_id, switching_seq
from fhzg_operation_abnormality_switching_sequence where operation_type = 'open'
) e on s.switching_seq= e.switch_seq and s.oa_id= e.oa_id and s.operation_type='close'where s.oa_id=#{oaId} )
select after_feeder, psr_id, psr_name, psr_type, feeder, switch_id, end_switch_id, switching_seq
from (with recursive res_tab as (
select t.psr_id, t.name, t.psr_type, feeder, st.dk_kg_id switch_id, st.switching_seq, st.dg_line_id
from t_feeder_topo t join line_switch_tab st on t.feeder = st.bdg_line_id and t.psr_id = st.dk_kg_id
union all
select t.psr_id, t.name, t.psr_type, t.feeder, p.switch_id, p.switching_seq, p.dg_line_id
from t_feeder_topo t join res_tab p on t.start_kg_id = p.psr_id and t.feeder = p.feeder
where t.psr_type in #{item}
) select feeder after_feeder,psr_id,name psr_name,psr_type,dg_line_id feeder,switch_id,null end_switch_id,switching_seq
from res_tab where psr_id != switch_id) t
union all
select after_feeder, psr_id, psr_name, psr_type, feeder, switch_id, end_switch_id, switching_seq
from (with recursive res_tab as (
select st.bdg_line_id, t.psr_id, t.name, t.psr_type, t.feeder, st.dk_kg_id switch_id, st.switching_seq, st.bh_kg_id, t.psr_id kg_id
from t_feeder_topo t join line_switch_tab st on t.feeder = st.dg_line_id
and (case when st.dg_line_id = st.bdg_line_id then t.psr_id = st.dk_kg_id else t.is_start_kg = '1' end)
union all
select p.bdg_line_id,if(t.psr_id=p.bh_kg_id,'-',t.psr_id) psr_id,t.name,t.psr_type,t.feeder,p.switch_id,p.switching_seq,p.bh_kg_id,p.kg_id
from t_feeder_topo t join res_tab p on t.start_kg_id = p.psr_id and t.feeder = p.feeder
where t.psr_type in #{item}
) select bdg_line_id after_feeder, psr_id, name psr_name, psr_type, feeder, switch_id, null end_switch_id, switching_seq
from res_tab where psr_id not in ('-')) t
with recursive res_tab as (
select t.feeder, t.feeder_name, t.psr_id, t.name, t.psr_type, t.normal_open, t.start_kg_id
from t_feeder_topo t join t_feeder_topo f on t.psr_id = f.psr_id and t.feeder != f.feeder
where f.normal_open = 'true' and f.feeder = #{feederId}
union all
select t.feeder, t.feeder_name, t.psr_id, t.name, t.psr_type, t.normal_open, t.start_kg_id
from t_feeder_topo t join res_tab p on t.psr_id = p.start_kg_id and t.feeder = p.feeder
where t.psr_type in #{item}
) select if(t.normal_open = 'true', '-', t.psr_id) psr_id, t.name, t.normal_open,
t.psr_type, t.feeder, if(t.normal_open = 'true', t.psr_id, '-') end_switch_id from res_tab t union
select if(t.normal_open = 'true', '-', t.psr_id) psr_id, t.name, t.normal_open,
t.psr_type, t.feeder, if(t.normal_open = 'true', t.psr_id, '-') end_switch_id
from t_feeder_topo t join res_tab rt on t.start_kg_id = rt.psr_id and t.feeder = rt.feeder
where t.psr_type in #{item}
select obj_id, cl_list_json, kg_list_json from fhzg_dist_line_dynamic_svg_direct_current where obj_id = #{objId} limit 1
select psr_id, `name` psr_name, psr_type, feeder, start_kg_id switch_id
from t_feeder_topo t where psr_type = 'PD_31100000'
and t.feeder in #{item}
select psr_id, `name` psr_name, feeder, feeder_name, start_kg_id, is_start_kg
from t_feeder_topo t where t.psr_id in
#{item}
with switch_res_tab as (
select distinct b.feeder line_id,ifnull(start_switch,kg_id) kg_id,ifnull(closed_state,'-') closed_state
from (select a.psr_id kg_id, a.normal_open
from t_feeder_topo a join fhzg_plan_power_cut c on a.feeder=c.line_id and a.normal_open='true'
where c.id = #{queryDTO.objId}
join fhzg_plan_transfer_scheme ts on c.id = ts.plan_id where ts.id = #{queryDTO.objId}
) a join t_feeder_topo b on a.kg_id=b.psr_id and a.normal_open=b.normal_open
left join (
select c.line_id, s.start_switch, '0' closed_state from fhzg_plan_power_cut c
join fhzg_plan_power_cut_switch s on s.plan_id = c.id where s.plan_id = #{queryDTO.objId}
join (
select a.plan_id, b.switch_id start_switch, b.operation_content from fhzg_plan_transfer_scheme a
join fhzg_plan_transfer_scheme_switching_sequence b on b.scheme_id=a.id where a.id=#{queryDTO.objId}
union
select a.plan_id, b.start_switch, '0' closed_state from fhzg_plan_transfer_scheme a
join fhzg_plan_power_cut_switch b on b.plan_id = a.plan_id where a.id = #{queryDTO.objId}
) s on s.plan_id = c.id
) kg on b.feeder = kg.line_id
select distinct b.feeder line_id, ifnull(start_switch,kg_id) kg_id, ifnull(closed_state,'-') closed_state
from (select a.psr_id kg_id, a.normal_open
from t_feeder_topo a join fhzg_fault_power_cut c on a.feeder=c.line_id and a.normal_open='true'
where c.id = #{queryDTO.objId}
join fhzg_fault_transfer_scheme ts on c.id = ts.fault_id where ts.id = #{queryDTO.objId}
) a join t_feeder_topo b on a.kg_id=b.psr_id and a.normal_open=b.normal_open
left join (
select c.line_id, s.start_switch, '0' closed_state from fhzg_fault_power_cut c
join fhzg_fault_power_cut_switch s on s.fault_id = c.id where s.fault_id = #{queryDTO.objId}
join (
select a.fault_id, b.switch_id start_switch, b.operation_content from fhzg_fault_transfer_scheme a
join fhzg_fault_transfer_scheme_switching_sequence b on b.scheme_id=a.id where a.id=#{queryDTO.objId}
union
select a.fault_id, b.start_switch, '0' closed_state from fhzg_fault_transfer_scheme a
join fhzg_fault_power_cut_switch b on b.fault_id = a.fault_id where a.id = #{queryDTO.objId}
) s on s.fault_id = c.id
) kg on b.feeder = kg.line_id
select s.line_id, s.switch_id kg_id, s.closed_state
from fhzg_dist_line_switch_status s
where s.obj_id = #{queryDTO.objId}
left join (
select ts.id, s.switch_id from fhzg_operation_abnormality_switching_sequence s
join fhzg_operation_abnormality_transfer_scheme ts on s.oa_id = ts.oa_id
) t on s.obj_id = t.id and s.switch_id = t.switch_id
where s.obj_id = #{queryDTO.objId} and t.id is null
union all
select c.line_id, s.switch_id kg_id, if(operation_type='open','0','1') closed_state
from fhzg_grid_operation_abnormality c
join fhzg_operation_abnormality_switching_sequence s on s.oa_id = c.id
join fhzg_operation_abnormality_transfer_scheme ts on s.oa_id=ts.oa_id where ts.id=#{queryDTO.objId}
select distinct b.feeder line_id, b.psr_id kg_id, '-' closed_state
from t_feeder_topo a join t_feeder_topo b on a.psr_id=b.psr_id and a.normal_open=b.normal_open
where a.feeder = #{queryDTO.objId} and a.normal_open = 'true'
)
union
with feeder_switch_tab as (
select #{item.feeder} feeder, #{item.switchIds} switch_id from dual
)
select t.psr_id from (with recursive res_tab as (
select t.psr_id, t.name, t.psr_type, t.feeder, t.feeder_name, t.normal_open, t.start_kg_id
from t_feeder_topo t join feeder_switch_tab f on t.feeder = f.feeder and FIND_IN_SET(t.psr_id,switch_id) > 0
union all
select t.psr_id, t.name, t.psr_type, t.feeder, t.feeder_name, t.normal_open, t.start_kg_id
from t_feeder_topo t join res_tab p on t.start_kg_id = p.psr_id and t.feeder = p.feeder
where t.psr_type in #{item} )
select psr_id, name, psr_type, feeder, feeder_name, normal_open, start_kg_id from res_tab) t
select create_time from fhzg_operation_abnormality_transfer_area_result where oa_id = #{id}
with recursive res_tab as (
select t.feeder,t.psr_id,t.name, t.psr_type, t.start_kg_id ,t.normal_open
from t_feeder_topo t
where t.feeder = #{feederId} and start_kg_id is null
and t.psr_type in
#{item}
union all
select t.feeder,t.psr_id, t.name , t.psr_type,t.start_kg_id ,t.normal_open
from t_feeder_topo t join res_tab p on t.start_kg_id = p.psr_id and t.feeder = p.feeder
where (p.normal_open is null or p.normal_open = 'false') and t.feeder = #{feederId} and t.psr_type in
#{item}
)
select feeder, psr_id , name psrName, psr_type,
if(start_kg_id is null,psr_id,'-') switchId,
if(normal_open ='true',psr_id,'-') endSwitchId
from res_tab
select t.psr_id, t.name, t.psr_type, t.feeder, t.feeder_name, t.normal_open, t.start_kg_id, t.link_id, '0' direct_current
from (with recursive res_tab as (
select t.psr_id link_id, t.psr_id, t.name, t.psr_type, t.feeder, t.feeder_name, t.normal_open, t.start_kg_id
from t_feeder_topo t join (select distinct line_id
from switch_res_tab) f on t.feeder = f.line_id where t.is_start_kg = '1'
union all
select if(t.psr_id in (select kg_id from switch_res_tab where closed_state='0'),'-',t.psr_id) link_id,
t.psr_id, t.name, t.psr_type, t.feeder, t.feeder_name, t.normal_open, t.start_kg_id
from t_feeder_topo t join res_tab p on t.start_kg_id = p.link_id and t.feeder = p.feeder
where t.psr_type in #{item} )
select psr_id, name, psr_type, feeder, feeder_name, normal_open, start_kg_id, link_id from res_tab
) t
select t.psr_id, t.name, t.psr_type, t.feeder, t.feeder_name, t.normal_open, t.start_kg_id, t.link_id, '1' direct_current
from (with recursive f_res_tab as (
select t.psr_id, t.name, t.psr_type, t.feeder, t.feeder_name, t.normal_open, t.start_kg_id, t.start_kg_id link_id
from t_feeder_topo t join (select distinct line_id, kg_id from switch_res_tab
where closed_state = '1') f on t.feeder = f.line_id and t.psr_id = f.kg_id and t.normal_open = 'true'
union all
select t.psr_id, t.name, t.psr_type, t.feeder, t.feeder_name, t.normal_open, t.start_kg_id,
if(t.psr_id in (select kg_id from switch_res_tab where closed_state='0'), '-', t.start_kg_id) link_id
from t_feeder_topo t join f_res_tab p on t.psr_id = p.link_id and t.feeder = p.feeder
where t.psr_type in #{item} )
select t.psr_id, t.name, t.psr_type, t.feeder, t.feeder_name, t.normal_open, t.start_kg_id, t.link_id
from (with recursive z_res_tab as (
select t.psr_id,t.name,t.psr_type,t.feeder,t.feeder_name,t.normal_open,t.start_kg_id,ifnull(f.link_id,t.psr_id) link_id
from t_feeder_topo t join (select distinct psr_id, feeder, link_id
from f_res_tab r) f on t.feeder = f.feeder and t.psr_id = f.psr_id
union all
select t.psr_id, t.name, t.psr_type, t.feeder, t.feeder_name, t.normal_open, t.start_kg_id, t.psr_id link_id
from t_feeder_topo t join z_res_tab p on t.start_kg_id = p.link_id and t.feeder = p.feeder
where t.psr_type in #{item} )
select psr_id, name, psr_type, feeder, feeder_name, normal_open, start_kg_id, link_id from z_res_tab) t
) t