FaultAwaitTransferAreaResultMapper.xml 5.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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.mq.mapper.fault.FaultAwaitTransferAreaResultMapper">
  4. <insert id="saveBreakerSvgAfterBatch">
  5. <if test='breakerSvgAfterList != null and !breakerSvgAfterList.isEmpty()'>
  6. insert into fhzg_info_breaker_svg_after(scheme_id, start_switch_id, after_p, after_q, after_i, create_time,last_time)
  7. values
  8. <foreach collection='breakerSvgAfterList' item='item' separator=','>
  9. (#{item.schemeId},#{item.startSwitchId},#{item.afterP},#{item.afterQ},#{item.afterI},#{item.createTime},#{item.lastTime})
  10. </foreach>
  11. </if>
  12. </insert>
  13. <select id="getSwitchSectionInfo" resultType="com.hdkj.lt.modle.dto.jsty.SwitchInfoDTO">
  14. with recursive res_tab as (
  15. select t.psr_id link_id, t.psr_id, t.name, t.start_kg_id from t_feeder_topo t
  16. where t.psr_id = #{startSwitchId} and t.feeder = #{lineId}
  17. union
  18. select if((t.normal_open='true' and t.psr_id != #{linkSwitchId})
  19. <if test='endSwitchIds != null and !endSwitchIds.isEmpty()'>
  20. or t.psr_id in
  21. <foreach collection='endSwitchIds' item='item' open='(' separator=',' close=')'>#{item}</foreach>
  22. </if>,'-',t.psr_id) link_id, t.psr_id, t.name, t.start_kg_id
  23. from t_feeder_topo t join res_tab p on t.start_kg_id = p.link_id
  24. and t.psr_type in
  25. <foreach collection = 'switchTypes' item = 'item' open = '(' separator = ',' close = ')'>#{item}</foreach>
  26. ) select psr_id switch_id,`name` switch_name,if(link_id='-','end','mid') switch_type
  27. from res_tab where psr_id != #{startSwitchId}
  28. </select>
  29. <select id="getTransformerCustomerInfo"
  30. resultType="com.hdkj.lt.core.bizms.modle.po.FhzgDistTransformerCustomer">
  31. <if test='trans != null and !trans.isEmpty()'>
  32. select t.transformer_no, t.transformer_name, max(t.is_sensitive_user) is_sensitive_user,
  33. max(t.is_critical_user) is_critical_user, max(t.is_dual_power) is_dual_power,
  34. max(if(c.protection_start_time &lt; #{faultEndTime} and #{faultStartTime} &lt; c.protection_end_time,'1','0')) is_protect_power
  35. from fhzg_dist_transformer_customer t
  36. left join fhzg_customer_power_protection_config c on t.transformer_no = c.transformer_no
  37. where t.transformer_no in <foreach collection='trans' item='item' open='(' separator=',' close=')'>#{item}</foreach>
  38. group by t.transformer_no, t.transformer_name
  39. </if>
  40. <if test='trans != null and !trans.isEmpty() and customers != null and !customers.isEmpty()'>
  41. union all
  42. </if>
  43. <if test='customers != null and !customers.isEmpty()'>
  44. select f.join_ec transformer_no, f.join_ec transformer_name, max(t.is_sensitive_user) is_sensitive_user,
  45. max(t.is_critical_user) is_critical_user, max(t.is_dual_power) is_dual_power,
  46. max(if(c.protection_start_time &lt; #{faultEndTime} and #{faultStartTime} &lt; c.protection_end_time, '1','0')) is_protect_power
  47. from fhzg_dist_transformer_customer t join dwd_shb_ds_joinec_transformer_base f on t.transformer_no = f.psr_id
  48. left join fhzg_customer_power_protection_config c on t.transformer_no = c.transformer_no
  49. where f.join_ec in <foreach collection='customers' item='item' open='(' separator=',' close=')'>#{item}</foreach>
  50. group by f.join_ec
  51. </if>
  52. </select>
  53. <select id="selectFaultAndFaultTime" resultType="com.hdkj.lt.mq.entity.vo.FaultPowerCutVO">
  54. select cut.line_id, cut.line_name, res.fault_id,
  55. res.transfer_area_json, cut.fault_start_time, cut.fault_end_time,
  56. date_add(date(cut.create_time), interval '-7 0:0:0' day_second) period_start_time,
  57. date_add(date(cut.create_time), interval -1 second) period_end_time
  58. from fhzg_fault_power_cut cut
  59. join fhzg_fault_await_transfer_area_result res on cut.id = res.fault_id
  60. where res.fault_id = #{faultId}
  61. </select>
  62. <select id="getBreakerSvgAfter" resultType="com.hdkj.lt.mq.entity.dto.SwitchTreeNode">
  63. with recursive res_tab as (
  64. select d.scheme_id, d.end_switch_id, t.feeder, t.feeder_name, t.psr_id, t.name, t.psr_type,
  65. t.psr_id link_id, cast(concat('scheme_id_',d.scheme_id) as char(100)) start_kg_id
  66. from t_feeder_topo t join fhzg_fault_transfer_scheme_path_detail d on t.psr_id=d.start_switch_id
  67. join fhzg_fault_transfer_scheme s on d.scheme_id = s.id and s.fault_id = #{faultId}
  68. where t.feeder = #{feeder}
  69. union all
  70. select p.scheme_id, p.end_switch_id, t.feeder, t.feeder_name, t.psr_id, t.name, t.psr_type,
  71. if(find_in_set(t.psr_id, p.end_switch_id) > 0, '-', t.psr_id) link_id, t.start_kg_id
  72. from t_feeder_topo t join res_tab p on t.start_kg_id = p.link_id
  73. where t.feeder = #{feeder}
  74. and t.psr_type in <foreach collection = 'deviceTypes' item = 'item' open = '(' separator = ',' close = ')'>#{item}</foreach>
  75. ) select x.scheme_id, x.start_kg_id pid, x.psr_type, x.psr_id id, y.transformer_name name,
  76. y.active_power after_p, y.user_reactive_power after_q, y.user_current after_i
  77. from (select distinct a.scheme_id, if(b.psr_id is null, a.psr_id, b.join_ec) psr_id,
  78. a.start_kg_id, if(b.psr_id is null, a.psr_type, 'PD_37000000') psr_type from res_tab a
  79. left join dwd_shb_ds_joinec_transformer_base b on a.psr_id = b.psr_id where a.link_id != '-') x
  80. left join fhzg_fault_transferable_scheme_users y on x.scheme_id=y.scheme_id and x.psr_id=y.transformer_no
  81. </select>
  82. </mapper>