NodeLandMapper.xml 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.siwei.apply.mapper.NodeLandMapper">
  6. <!-- 结果映射 -->
  7. <resultMap id="BaseResultMap" type="com.siwei.apply.domain.NodeLand">
  8. <id property="id" column="id"/>
  9. <result property="nodeId" column="node_id"/>
  10. <result property="geomDbId" column="geom_db_id"/>
  11. </resultMap>
  12. <!-- 基础查询字段 -->
  13. <sql id="Base_Column_List">
  14. id, node_id, geom_db_id
  15. </sql>
  16. <!-- 根据节点ID查询附件信息(只返回一条) -->
  17. <select id="selectByNodeId" resultMap="BaseResultMap" parameterType="String">
  18. SELECT
  19. <include refid="Base_Column_List"/>
  20. FROM t_node_land
  21. WHERE node_id = #{nodeId}
  22. LIMIT 1
  23. </select>
  24. <!-- 根据node_id查询地块几何信息,返回geom_db_id和并集的外边框、中心点 -->
  25. <select id="selectGeomByNodeId" resultType="map" parameterType="String">
  26. SELECT
  27. nl.geom_db_id as "geomDbId",
  28. tgd.shppath as "shppath",
  29. array_to_string(array_agg(gd.id), '|') as "geomIds",
  30. array_to_string(array_agg(ST_AsEWKT(gd.geom)), '|') as "geoms",
  31. ST_AsEWKT(ST_Envelope(ST_Union(gd.geom))) as "envelope",
  32. ST_AsEWKT(ST_Centroid(ST_Union(gd.geom))) as "centroid"
  33. FROM t_node_land nl
  34. LEFT JOIN t_geom_db_details gd ON nl.geom_db_id = gd.upload_id
  35. LEFT JOIN t_geom_db tgd ON nl.geom_db_id = tgd.id
  36. WHERE nl.node_id = #{nodeId}
  37. AND gd.geom IS NOT NULL
  38. GROUP BY nl.geom_db_id, tgd.shppath
  39. </select>
  40. <!-- 根据node_id查询地块数量信息 -->
  41. <select id="selectCountGeomByNodeId" >
  42. SELECT
  43. count(1) as "count"
  44. FROM t_node_land nl
  45. LEFT JOIN t_geom_db_details gd ON nl.geom_db_id = gd.upload_id
  46. LEFT JOIN t_geom_db tgd ON nl.geom_db_id = tgd.id
  47. <where>
  48. <if test="nodeIdList != null and nodeIdList.size() > 0">
  49. AND nl.node_id IN
  50. <foreach collection="nodeIdList" item="id" open="(" separator="," close=")">
  51. #{id}
  52. </foreach>
  53. </if>
  54. </where>
  55. AND gd.geom IS NOT NULL
  56. </select>
  57. <!-- 根据node_id和geom_db_id创建记录 -->
  58. <insert id="insertByNodeIdAndGeomDbId">
  59. INSERT INTO t_node_land (
  60. id,
  61. node_id,
  62. geom_db_id
  63. ) VALUES (
  64. REPLACE(gen_random_uuid()::varchar, '-', ''),
  65. #{param1},
  66. #{param2}
  67. )
  68. </insert>
  69. <!-- 根据node_id删除记录 -->
  70. <delete id="deleteByNodeId" parameterType="String">
  71. DELETE FROM t_node_land
  72. WHERE node_id = #{nodeId}
  73. </delete>
  74. <!-- 新增:根据projectId与nodeTableName查询项目流程表中的nodeId(唯一) -->
  75. <select id="selectNodeIdsByProjectIdAndNodeTableName" parameterType="map" resultType="string">
  76. SELECT node_id
  77. FROM t_project_workflow
  78. WHERE project_id = #{projectId}
  79. AND node_table_name = #{nodeTableName}
  80. ORDER BY created_at
  81. LIMIT 1
  82. </select>
  83. <!-- 根据nodeId,查询出当前具体的图斑ID -->
  84. <select id="selectGeomDbDetailsByNodeId" parameterType="String" resultType="java.util.Map">
  85. select details.id as "id",
  86. public.st_asewkt(details.geom) AS "geom",
  87. details.upload_id as "uploadId",
  88. details.geom_json as "geomJson",
  89. details.sort as "sort",
  90. details.geom_area as "geomArea"
  91. from t_geom_db_details details
  92. INNER JOIN t_node_land node on node.geom_db_id=details.upload_id
  93. <where>
  94. 1=1
  95. <if test="nodeId != null">
  96. AND node.node_id =#{nodeId}
  97. </if>
  98. <if test="geomId != null">
  99. AND details.id =#{geomId}
  100. </if>
  101. </where>
  102. </select>
  103. <select id="existsGeomIntersect" resultType="boolean">
  104. SELECT EXISTS (
  105. SELECT 1
  106. FROM t_geom_db_details source
  107. JOIN t_geom_db_details target ON target.id = #{targetGeomId}
  108. WHERE source.id = #{sourceGeomId}
  109. AND source.geom IS NOT NULL
  110. AND target.geom IS NOT NULL
  111. AND public.ST_Intersects(source.geom, target.geom)
  112. )
  113. </select>
  114. <select id="selectGeomContainsNode" parameterType="String" resultType="map">
  115. SELECT geom.id , node.node_id FROM "t_geom_db_details" geom
  116. LEFT JOIN "public"."t_geom_db" upload on geom.upload_id=upload.id
  117. LEFT JOIN "public"."t_node_land" node on node.geom_db_id=upload.id
  118. LEFT JOIN "public"."t_ydbp_data" ydbp on node.node_id=ydbp.id
  119. where ydbp.has_onchain=true
  120. AND st_contains(ST_Buffer(geom.geom::geography, 0.1)::geometry, (SELECT geom FROM "t_geom_db_details" WHERE id = #{detailsId}) )
  121. order by ydbp.created_at desc
  122. limit 1
  123. </select>
  124. <!-- 根据nodeId,查询出当前具体的图斑ID -->
  125. <select id="selectGeomDetailsByGeomDbId" parameterType="String" resultType="java.util.Map">
  126. select details.id, public.st_asewkt(details.geom) AS geom, details.upload_id, details.geom_json,
  127. details.sort, CAST(details.geom_area AS FLOAT) geom_area
  128. from t_geom_db_details details
  129. WHERE details.upload_id = #{geomDbId}
  130. </select>
  131. <select id="selectByGeom" parameterType="String" resultMap="BaseResultMap">
  132. SELECT bb.* from t_geom_db_details aa
  133. LEFT JOIN t_node_land bb on aa.upload_id = bb.geom_db_id
  134. LEFT JOIN t_tdgy cc
  135. on bb.node_id=cc.id
  136. where public.ST_Intersects(aa.geom,public.ST_GeomFromEWKT(#{ewkt})) and cc.id is not null
  137. </select>
  138. <select id="selectDjzqContainsNodeList" resultType="Map">
  139. SELECT
  140. djzq.bsm,
  141. djzq.ysdm,
  142. djzq.djzqdm,
  143. djzq.djzqmc,
  144. djzq.bz
  145. FROM vector.djzq
  146. WHERE (djzq.valid_flag IS NULL OR djzq.valid_flag = 0)
  147. and st_contains(ST_Buffer(djzq.geom::geography, 0.1)::geometry, (SELECT geom FROM "public".t_geom_db_details WHERE id = #{detailsId}))
  148. limit 1
  149. </select>
  150. <!-- 这里判断两个图形是否一致,如果一致则返回已存在的当前的节点数据 -->
  151. <select id="selectNodeGeomContains" parameterType="String" resultType="map">
  152. SELECT geom.id , node.node_id FROM "t_geom_db_details" geom
  153. LEFT JOIN "public"."t_geom_db" upload on geom.upload_id=upload.id
  154. LEFT JOIN "public"."t_node_land" node on node.geom_db_id=upload.id
  155. LEFT JOIN "public"."t_project_immobile_code" tpic on node.node_id=tpic.node_id
  156. where st_contains(ST_Buffer(geom.geom::geography, 0.1)::geometry, (SELECT geom FROM "t_geom_db_details" WHERE id = #{detailsId} ))
  157. <if test="nodeIdList != null and nodeIdList.size() > 0">
  158. AND tpic.node_id IN
  159. <foreach collection="nodeIdList" item="id" open="(" separator="," close=")">
  160. #{id}
  161. </foreach>
  162. </if>
  163. limit 1
  164. </select>
  165. <!-- 这里判断两个图形是否一致,如果一致则返回已存在的当前的节点数据 -->
  166. <select id="selectGeomContains" parameterType="String" resultType="map">
  167. SELECT geom.id , upload.id as geom_db_id FROM "t_geom_db_details" geom
  168. LEFT JOIN "public"."t_geom_db" upload on geom.upload_id=upload.id
  169. LEFT JOIN "public"."t_project_immobile_code" tpic on upload.id=tpic.geom_db_id
  170. where st_contains(ST_Buffer(geom.geom::geography, 0.1)::geometry, (SELECT geom FROM "t_geom_db_details" WHERE id = #{detailsId} ))
  171. <if test="geomDbIdList != null and geomDbIdList.size() > 0">
  172. AND tpic.geom_db_id IN
  173. <foreach collection="geomDbIdList" item="id" open="(" separator="," close=")">
  174. #{id}
  175. </foreach>
  176. </if>
  177. limit 1
  178. </select>
  179. </mapper>