FhzgGridOperationAbnormalityMapper.xml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.hdkj.lt.bf.mapper.FhzgGridOperationAbnormalityMapper">
  4. <select id="getOperationAbnormalityList" resultType="com.hdkj.lt.bf.entity.vo.FhzgGridOperationAbnormalityVO">
  5. select t1.*, t3.short_name countyName, t4.id schemeId, t4.file_id schemeFileId
  6. from fhzg_grid_operation_abnormality t1
  7. left join dwd_shb_ds_feeder_base t2 on t1.line_id = t2.psr_id
  8. left join sys_dept t3 on t3.isc_org_id = t2.maint_org
  9. left join fhzg_operation_abnormality_transfer_scheme t4 on t1.id =t4.oa_id
  10. <where>
  11. <if test="queryDTO.countyCode != null and queryDTO.countyCode != ''">
  12. and t3.dept_id = #{queryDTO.countyCode}
  13. </if>
  14. <if test="queryDTO.countyCodeList != null and queryDTO.countyCodeList.size > 0">
  15. AND t3.dept_id IN
  16. <foreach collection="queryDTO.countyCodeList" open="(" item="item" separator="," close=")">
  17. #{item}
  18. </foreach>
  19. </if>
  20. <if test="queryDTO.feederName != null and queryDTO.feederName != ''">
  21. and t1.line_name like concat('%',#{queryDTO.feederName},'%')
  22. </if>
  23. <if test="queryDTO.volStartTime != null ">
  24. and t1.alarm_start_time > #{queryDTO.volStartTime}
  25. </if>
  26. <if test="queryDTO.volEndTime != null ">
  27. and t1.alarm_end_time &lt; #{queryDTO.volEndTime}
  28. </if>
  29. </where>
  30. order by t1.alarm_start_time desc
  31. </select>
  32. <select id="getBreakerAreaInfo" resultType="com.hdkj.lt.bf.entity.vo.FeederDeviceVO">
  33. <!-- 首先根据转供路径开关分合动作,确定开关被带供、带供线路、开关开合信息 -->
  34. with line_switch_tab as (
  35. 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
  36. from fhzg_operation_abnormality_switching_sequence s
  37. join fhzg_operation_abnormality_await_transfer_path_detail d on d.oa_id=s.oa_id and d.close_switch_id=s.switch_id
  38. 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
  39. join (select oa_id, (switching_seq - 1) switch_seq, switch_id, switching_seq
  40. from fhzg_operation_abnormality_switching_sequence where operation_type = 'open'
  41. ) 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} )
  42. <!-- 第一部分查被带供线路的开关,通过被带供线路的分开开关,查级联开关母线设备并归属到带供线路 -->
  43. select after_feeder, psr_id, psr_name, psr_type, feeder, switch_id, end_switch_id, switching_seq
  44. from (with recursive res_tab as (
  45. select t.psr_id, t.name, t.psr_type, feeder, st.dk_kg_id switch_id, st.switching_seq, st.dg_line_id
  46. 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
  47. union all
  48. select t.psr_id, t.name, t.psr_type, t.feeder, p.switch_id, p.switching_seq, p.dg_line_id
  49. from t_feeder_topo t join res_tab p on t.start_kg_id = p.psr_id and t.feeder = p.feeder
  50. where t.psr_type in <foreach collection='kgPsrTypes' item='item' open="('PD_31100000'," separator=',' close=')'>#{item}</foreach>
  51. ) select feeder after_feeder,psr_id,name psr_name,psr_type,dg_line_id feeder,switch_id,null end_switch_id,switching_seq
  52. from res_tab where psr_id != switch_id) t
  53. union all
  54. <!-- 第一部分查带供线路的开关,通过带供线路的出线开关查到闭合开关截止(闭合开一部分已经查过所以屏蔽) -->
  55. select after_feeder, psr_id, psr_name, psr_type, feeder, switch_id, end_switch_id, switching_seq
  56. from (with recursive res_tab as (
  57. 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
  58. from t_feeder_topo t join line_switch_tab st on t.feeder = st.dg_line_id
  59. 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)
  60. union all
  61. 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
  62. from t_feeder_topo t join res_tab p on t.start_kg_id = p.psr_id and t.feeder = p.feeder
  63. where t.psr_type in <foreach collection='kgPsrTypes' item='item' open="('PD_31100000'," separator=',' close=')'>#{item}</foreach>
  64. ) select bdg_line_id after_feeder, psr_id, name psr_name, psr_type, feeder, switch_id, null end_switch_id, switching_seq
  65. from res_tab where psr_id not in ('-', kg_id)) t
  66. </select>
  67. <select id="getDefaultBreakerAreaInfo" resultType="com.hdkj.lt.bf.entity.vo.FeederDeviceVO">
  68. with recursive res_tab as (
  69. select t.feeder, t.feeder_name, t.psr_id, t.name, t.psr_type, t.normal_open, t.start_kg_id
  70. from t_feeder_topo t join t_feeder_topo f on t.psr_id = f.psr_id and t.feeder != f.feeder
  71. where f.normal_open = 'true' and f.feeder = #{feederId}
  72. union all
  73. select t.feeder, t.feeder_name, t.psr_id, t.name, t.psr_type, t.normal_open, t.start_kg_id
  74. from t_feeder_topo t join res_tab p on t.psr_id = p.start_kg_id and t.feeder = p.feeder
  75. where t.psr_type in <foreach collection='kgPsrTypes' item='item' open="('PD_31100000'," separator=',' close=')'>#{item}</foreach>
  76. ) select if(t.normal_open = 'true', '-', t.psr_id) psr_id, t.name, t.normal_open,
  77. t.psr_type, t.feeder, if(t.normal_open = 'true', t.psr_id, '-') end_switch_id from res_tab t union
  78. select if(t.normal_open = 'true', '-', t.psr_id) psr_id, t.name, t.normal_open,
  79. t.psr_type, t.feeder, if(t.normal_open = 'true', t.psr_id, '-') end_switch_id
  80. from t_feeder_topo t join res_tab rt on t.start_kg_id = rt.psr_id and t.feeder = rt.feeder
  81. where t.psr_type in <foreach collection='kgPsrTypes' item='item' open="('PD_31100000'," separator=',' close=')'>#{item}</foreach>
  82. </select>
  83. <select id="getDistLineDynamicSvgDirectCurrent" resultType="com.hdkj.lt.bf.entity.vo.DynamicSvgDirectVO">
  84. select obj_id, cl_list_json, kg_list_json from fhzg_dist_line_dynamic_svg_direct_current where obj_id = #{objId} limit 1
  85. </select>
  86. <select id="getFeederSwitchBusbar" resultType="com.hdkj.lt.bf.entity.vo.FeederDeviceVO">
  87. select psr_id, `name` psr_name, psr_type, feeder, start_kg_id switch_id
  88. from t_feeder_topo t where psr_type = 'PD_31100000'
  89. and t.feeder in <foreach collection='feederList' item='item' open="(" separator=',' close=')'>#{item}</foreach>
  90. </select>
  91. <select id="getFeederSwitchByPsrId" resultType="com.hdkj.lt.bf.entity.vo.FeederSwitchVO">
  92. select psr_id, `name` psr_name, feeder, feeder_name, start_kg_id, is_start_kg
  93. from t_feeder_topo t where t.psr_id in
  94. <foreach collection='psrIdList' item='item' open="(" separator=',' close=')'>#{item}</foreach>
  95. </select>
  96. <select id="getDistDynamicSvgDirectCurrentInfo" resultType="com.hdkj.lt.bf.entity.vo.DirectCurrentSwitchVO">
  97. with switch_res_tab as (
  98. <choose>
  99. <!-- objType:1-计划场景,2-计划方案场景,3-故障场景,4-故障方案场景,5-运行调优场景,6-运行调优方案场景 -->
  100. <when test='queryDTO.objType == "1" or queryDTO.objType == "2"'>
  101. select distinct b.feeder line_id,ifnull(start_switch,kg_id) kg_id,ifnull(closed_state,'-') closed_state
  102. from (select a.psr_id kg_id, a.normal_open
  103. from t_feeder_topo a join fhzg_plan_power_cut c on a.feeder=c.line_id and a.normal_open='true'
  104. <choose>
  105. <when test='queryDTO.objType == "1"'>
  106. where c.id = #{queryDTO.objId}
  107. </when>
  108. <otherwise>
  109. join fhzg_plan_transfer_scheme ts on c.id = ts.plan_id where ts.id = #{queryDTO.objId}
  110. </otherwise>
  111. </choose>
  112. ) a join t_feeder_topo b on a.kg_id=b.psr_id and a.normal_open=b.normal_open
  113. left join (
  114. select c.line_id, s.start_switch, '0' closed_state from fhzg_plan_power_cut c
  115. <choose>
  116. <when test='queryDTO.objType == "1"'>
  117. join fhzg_plan_power_cut_switch s on s.plan_id = c.id where s.plan_id = #{queryDTO.objId}
  118. </when>
  119. <otherwise>
  120. join (
  121. select a.plan_id, b.switch_id start_switch, b.operation_content from fhzg_plan_transfer_scheme a
  122. join fhzg_plan_transfer_scheme_switching_sequence b on b.scheme_id=a.id where a.id=#{queryDTO.objId}
  123. union
  124. select a.plan_id, b.start_switch, '0' closed_state from fhzg_plan_transfer_scheme a
  125. join fhzg_plan_power_cut_switch b on b.plan_id = a.plan_id where a.id = #{queryDTO.objId}
  126. ) s on s.plan_id = c.id
  127. </otherwise>
  128. </choose>
  129. ) kg on b.feeder = kg.line_id
  130. </when>
  131. <when test='queryDTO.objType == "3" or queryDTO.objType == "4"'>
  132. select distinct b.feeder line_id, ifnull(start_switch,kg_id) kg_id, ifnull(closed_state,'-') closed_state
  133. from (select a.psr_id kg_id, a.normal_open
  134. from t_feeder_topo a join fhzg_fault_power_cut c on a.feeder=c.line_id and a.normal_open='true'
  135. <choose>
  136. <when test='queryDTO.objType == "3"'>
  137. where c.id = #{queryDTO.objId}
  138. </when>
  139. <otherwise>
  140. join fhzg_fault_transfer_scheme ts on c.id = ts.fault_id where ts.id = #{queryDTO.objId}
  141. </otherwise>
  142. </choose>
  143. ) a join t_feeder_topo b on a.kg_id=b.psr_id and a.normal_open=b.normal_open
  144. left join (
  145. select c.line_id, s.start_switch, '0' closed_state from fhzg_fault_power_cut c
  146. <choose>
  147. <when test='queryDTO.objType == "3"'>
  148. join fhzg_fault_power_cut_switch s on s.fault_id = c.id where s.fault_id = #{queryDTO.objId}
  149. </when>
  150. <otherwise>
  151. join (
  152. select a.fault_id, b.switch_id start_switch, b.operation_content from fhzg_fault_transfer_scheme a
  153. join fhzg_fault_transfer_scheme_switching_sequence b on b.scheme_id=a.id where a.id=#{queryDTO.objId}
  154. union
  155. select a.fault_id, b.start_switch, '0' closed_state from fhzg_fault_transfer_scheme a
  156. join fhzg_fault_power_cut_switch b on b.fault_id = a.fault_id where a.id = #{queryDTO.objId}
  157. ) s on s.fault_id = c.id
  158. </otherwise>
  159. </choose>
  160. ) kg on b.feeder = kg.line_id
  161. </when>
  162. <when test='queryDTO.objType == "5" or queryDTO.objType == "6"'>
  163. select s.line_id, s.switch_id kg_id, s.closed_state
  164. from fhzg_dist_line_switch_status s
  165. <choose>
  166. <when test='queryDTO.objType == "5"'>
  167. where s.obj_id = #{queryDTO.objId}
  168. </when>
  169. <otherwise>
  170. left join (
  171. select ts.id, s.switch_id from fhzg_operation_abnormality_switching_sequence s
  172. join fhzg_operation_abnormality_transfer_scheme ts on s.oa_id = ts.oa_id
  173. ) t on s.obj_id = t.id and s.switch_id = t.switch_id
  174. where s.obj_id = #{queryDTO.objId} and t.id is null
  175. union all
  176. select c.line_id, s.switch_id kg_id, if(operation_type='open','0','1') closed_state
  177. from fhzg_grid_operation_abnormality c
  178. join fhzg_operation_abnormality_switching_sequence s on s.oa_id = c.id
  179. join fhzg_operation_abnormality_transfer_scheme ts on s.oa_id=ts.oa_id where ts.id=#{queryDTO.objId}
  180. </otherwise>
  181. </choose>
  182. </when>
  183. <otherwise>
  184. <!-- 线路场景时,开关状态设置成非开合状态,保证不影响开关朝流判断,仅需要对侧线路信息 -->
  185. select distinct b.feeder line_id, b.psr_id kg_id, '-' closed_state
  186. from t_feeder_topo a join t_feeder_topo b on a.psr_id=b.psr_id and a.normal_open=b.normal_open
  187. where a.feeder = #{queryDTO.objId} and a.normal_open = 'true'
  188. </otherwise>
  189. </choose>)
  190. <include refid="forwardCurrentSql"/>
  191. union
  192. <include refid="reverseCurrentSql"/>
  193. </select>
  194. <select id="getFilterDirectCurrentSwitchInfo" resultType="java.lang.String">
  195. with feeder_switch_tab as (
  196. <foreach collection='filterLineSwitch' item='item' separator=' union all '>
  197. select #{item.feeder} feeder, #{item.switchIds} switch_id from dual
  198. </foreach>)
  199. select t.psr_id from (with recursive res_tab as (
  200. select t.psr_id, t.name, t.psr_type, t.feeder, t.feeder_name, t.normal_open, t.start_kg_id
  201. 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
  202. union all
  203. select t.psr_id, t.name, t.psr_type, t.feeder, t.feeder_name, t.normal_open, t.start_kg_id
  204. from t_feeder_topo t join res_tab p on t.start_kg_id = p.psr_id and t.feeder = p.feeder
  205. where t.psr_type in <foreach collection='kgPsrTypes' item='item' open="(" separator=',' close=')'>#{item}</foreach>)
  206. select psr_id, name, psr_type, feeder, feeder_name, normal_open, start_kg_id from res_tab) t
  207. </select>
  208. <select id="getPlanCreateTimeById" resultType="java.time.LocalDateTime">
  209. select create_time from fhzg_operation_abnormality_transfer_area_result where oa_id = #{id}
  210. </select>
  211. <sql id="forwardCurrentSql">
  212. <!-- 正向朝流经过的开关信息 -->
  213. 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
  214. from (with recursive res_tab as (
  215. 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
  216. from t_feeder_topo t join (select distinct line_id
  217. from switch_res_tab) f on t.feeder = f.line_id where t.is_start_kg = '1'
  218. union all
  219. select if(t.psr_id in (select kg_id from switch_res_tab where closed_state='0'),'-',t.psr_id) link_id,
  220. t.psr_id, t.name, t.psr_type, t.feeder, t.feeder_name, t.normal_open, t.start_kg_id
  221. from t_feeder_topo t join res_tab p on t.start_kg_id = p.link_id and t.feeder = p.feeder
  222. where t.psr_type in <foreach collection='kgPsrTypes' item='item' open="(" separator=',' close=')'>#{item}</foreach>)
  223. select psr_id, name, psr_type, feeder, feeder_name, normal_open, start_kg_id, link_id from res_tab
  224. ) t
  225. </sql>
  226. <sql id="reverseCurrentSql">
  227. <!-- 反向朝流经过的开关信息 -->
  228. 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
  229. from (with recursive f_res_tab as (
  230. 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
  231. from t_feeder_topo t join (select distinct line_id, kg_id from switch_res_tab
  232. where closed_state = '1') f on t.feeder = f.line_id and t.psr_id = f.kg_id and t.normal_open = 'true'
  233. union all
  234. select t.psr_id, t.name, t.psr_type, t.feeder, t.feeder_name, t.normal_open, t.start_kg_id,
  235. if(t.psr_id in (select kg_id from switch_res_tab where closed_state='0'), '-', t.start_kg_id) link_id
  236. from t_feeder_topo t join f_res_tab p on t.psr_id = p.link_id and t.feeder = p.feeder
  237. where t.psr_type in <foreach collection='kgPsrTypes' item='item' open="(" separator=',' close=')'>#{item}</foreach>)
  238. select t.psr_id, t.name, t.psr_type, t.feeder, t.feeder_name, t.normal_open, t.start_kg_id, t.link_id
  239. from (with recursive z_res_tab as (
  240. 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
  241. from t_feeder_topo t join (select distinct psr_id, feeder, link_id
  242. from f_res_tab r) f on t.feeder = f.feeder and t.psr_id = f.psr_id
  243. union all
  244. 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
  245. from t_feeder_topo t join z_res_tab p on t.start_kg_id = p.link_id and t.feeder = p.feeder
  246. where t.psr_type in <foreach collection='kgPsrTypes' item='item' open="(" separator=',' close=')'>#{item}</foreach>)
  247. select psr_id, name, psr_type, feeder, feeder_name, normal_open, start_kg_id, link_id from z_res_tab) t
  248. ) t
  249. </sql>
  250. </mapper>