FeederTopoMapper.xml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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.base.FeederTopoMapper">
  4. <insert id="saveDistLineSwitchSection">
  5. INSERT INTO fhzg_dist_line_switch_section(line_id, load_switch_id, load_switch_name, start_switch_id,
  6. start_switch_name,
  7. start_switch_type, end_switch_id, end_switch_name, create_time, users_count)
  8. WITH res_tab AS (SELECT count(psr_id) zxkg_count FROM t_feeder_topo
  9. WHERE feeder = #{feeder} AND zxfz_type='主线' group by feeder)
  10. SELECT t.*, ifnull(v.user_count,0) user_count FROM (
  11. WITH RECURSIVE hierarchy AS (
  12. SELECT psr_id switch_id, name switch_name, zxfz_type, psr_id, name, start_kg_id, psr_type
  13. FROM t_feeder_topo WHERE is_start_kg = '1' and feeder = #{feeder}
  14. UNION ALL
  15. SELECT if(child.zxfz_type='主线' or (select * from res_tab)=0, child.psr_id, parent.switch_id) switch_id,
  16. if(child.zxfz_type='主线' or (select * from res_tab)=0, child.name, parent.switch_name) switch_name,
  17. child.zxfz_type, child.psr_id, child.name, child.start_kg_id, child.psr_type
  18. FROM t_feeder_topo child JOIN hierarchy parent ON child.start_kg_id = parent.psr_id
  19. WHERE child.feeder = #{feeder}
  20. AND child.psr_type IN
  21. <foreach collection='kgPsrType' item='item' open='(' separator=',' close=')'>
  22. #{item}
  23. </foreach>
  24. ) SELECT #{feeder} lineId, parent.switch_id AS loadSwitchId, parent.switch_name AS loadSwitchName,
  25. parent.psr_id AS startSwitchId, parent.name AS startSwitchName,parent.psr_type as startSwitchType,
  26. GROUP_CONCAT(child.psr_id SEPARATOR ',') AS endSwitchId,
  27. GROUP_CONCAT(child.name SEPARATOR ',') AS endSwitchName, now() nowTime
  28. FROM hierarchy child RIGHT JOIN hierarchy parent ON child.start_kg_id = parent.psr_id
  29. GROUP BY parent.psr_id, parent.name , parent.psr_type, parent.switch_id, parent.switch_name) t
  30. left join (select start_kg_id, count(distinct if(d.psr_id is null,t.psr_id,d.join_ec)) user_count
  31. from t_feeder_topo t left join dwd_shb_ds_joinec_transformer_base d on t.psr_id = d.psr_id
  32. where t.psr_type in
  33. <foreach collection='pbPsrType' item='item' open='(' separator=',' close=')'>
  34. #{item}
  35. </foreach>
  36. and t.feeder = #{feeder} group by t.start_kg_id) v on t.startSwitchId = v.start_kg_id
  37. </insert>
  38. <insert id="insertDisableLlkgConfig">
  39. insert into t_disable_llkg_config(LLSB_ID, CITY_CODE, CREATE_TIME, LAST_TIME, LLSB_TYPE)
  40. select distinct t.psr_id,
  41. t.city_code,
  42. now() c_time,
  43. now() u_time,
  44. if(t.sszf_type not in ('PD_30000004', 'PD_32400000', 'PD_20400000'), '0', '2') l_type
  45. from t_feeder_topo t
  46. left join t_disable_llkg_config f on t.psr_id = f.llsb_id
  47. where t.normal_open = 'true'
  48. and f.id is null
  49. </insert>
  50. <update id="updateDisableLlkgConfig">
  51. update t_disable_llkg_config x, (select distinct t.psr_id,
  52. case
  53. when f.llsb_type in ('1', '3') then f.llsb_type
  54. when sszf_type not in ('PD_30000004', 'PD_32400000', 'PD_20400000')
  55. then '0'
  56. else '2' end llsb_type
  57. from t_feeder_topo t
  58. join t_disable_llkg_config f on t.psr_id = f.llsb_id
  59. where t.normal_open = 'true') y
  60. set x.llsb_type = y.llsb_type,
  61. x.last_time = now()
  62. where x.llsb_id = y.psr_id
  63. </update>
  64. <delete id="deleteDistLineSwitchSectionByLineId">
  65. delete
  66. from fhzg_dist_line_switch_section
  67. where line_id = #{feeder}
  68. </delete>
  69. <delete id="deleteDisableLlkgConfig">
  70. delete f.*
  71. from t_disable_llkg_config f
  72. join t_feeder_topo t on t.psr_id = f.llsb_id
  73. where t.normal_open = 'false'
  74. </delete>
  75. <select id="getDeviceType" resultType="com.hdkj.lt.mq.entity.dto.DeviceTypeDto">
  76. SELECT
  77. a.psr_id, b.dwd_psr_type, a.start_kg_id,a.is_start_kg
  78. FROM
  79. t_feeder_topo a
  80. LEFT JOIN fhzg_device_type_mapping b ON a.psr_type = b.topo_psr_type
  81. <where>
  82. <if test="psrIds != null and psrIds.size() > 0">
  83. and a.psr_id in
  84. <foreach item="item" collection="psrIds" open="(" separator="," close=")">
  85. #{item, jdbcType=BIGINT}
  86. </foreach>
  87. </if>
  88. </where>
  89. </select>
  90. <select id="getFeederCheckRule" resultType="com.hdkj.lt.modle.dto.simulation.FeederCheckRule">
  91. SELECT DISTINCT(a.feeder)
  92. FROM t_feeder_topo a
  93. JOIN(SELECT *
  94. from t_feeder_topo
  95. WHERE feeder = #{lineId}
  96. and normal_open = 'true') b
  97. ON a.psr_id = b.psr_id
  98. </select>
  99. <select id="getFeederInfoById" resultType="com.hdkj.lt.core.bizms.modle.po.FeederTopo">
  100. SELECT *
  101. FROM t_feeder_topo
  102. where feeder = #{lineId}
  103. and is_start_kg = '1'
  104. </select>
  105. <select id="getCityShortListByIds" resultType="java.lang.String">
  106. select distinct a.tab_suffix
  107. from fhzg_dist_organ_table_suffix_config a
  108. join dwd_shb_ds_feeder_base b on a.org_id=b.city
  109. where b.psr_id in
  110. <foreach item="item" collection="psrIds" open="(" separator="," close=")">#{item}</foreach>
  111. </select>
  112. <select id="getSwitchInfoByPsrID" resultType="com.hdkj.lt.mq.entity.dto.BreakerInfo">
  113. select distinct name as breakerName, dtm.dwd_psr_type as breakerPsrType, psr_id as breakerPsrId
  114. from t_feeder_topo ft
  115. left join fhzg_device_type_mapping dtm on ft.psr_type = dtm.topo_psr_type
  116. where psr_id = #{psrId}
  117. </select>
  118. </mapper>