TGeomDbDetailsMapper.xml 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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.spatial.mapper.file.TGeomDbDetailsMapper">
  6. <resultMap type="TGeomDbDetails" id="TGeomDbDetailsResult">
  7. <result property="id" column="id" />
  8. <result property="geom" column="geom" />
  9. <result property="uploadId" column="upload_id" />
  10. <result property="geomJson" column="geom_json" />
  11. <result property="sort" column="sort" />
  12. <result property="geomArea" column="geom_area" />
  13. </resultMap>
  14. <resultMap type="TGeomDb" id="TGeomDbResult">
  15. <result property="id" column="id" />
  16. <result property="name" column="name" />
  17. <result property="createBy" column="create_by" />
  18. <result property="createTime" column="create_time" />
  19. <result property="shppath" column="shppath" />
  20. <result property="filetype" column="filetype" />
  21. <result property="geom" column="geom" />
  22. <result property="geomNumber" column="geom_number" />
  23. <result property="geomArea" column="geom_area" />
  24. <result property="fromroute" column="fromroute" />
  25. </resultMap>
  26. <sql id="selectTGeomDbDetailsVo">
  27. select id, public.st_asewkt(geom) AS geom, upload_id, geom_json, sort, geom_area from t_geom_db_details
  28. </sql>
  29. <select id="selectTGeomDbDetailsList" parameterType="TGeomDbDetails" resultMap="TGeomDbDetailsResult">
  30. <include refid="selectTGeomDbDetailsVo"/>
  31. <where>
  32. <if test="geom != null and geom != ''"> and geom = #{geom}</if>
  33. <if test="uploadId != null and uploadId != ''"> and upload_id = #{uploadId}</if>
  34. <if test="geomJson != null and geomJson != ''"> and geom_json = #{geomJson}</if>
  35. <if test="sort != null and sort != ''"> and sort = #{sort}</if>
  36. <if test="geomArea != null and geomArea != ''"> and geom_area = #{geomArea}</if>
  37. </where>
  38. </select>
  39. <select id="selectTGeomDbDetailsById" parameterType="String" resultMap="TGeomDbDetailsResult">
  40. <include refid="selectTGeomDbDetailsVo"/>
  41. where id = #{id}
  42. </select>
  43. <select id="selectTGeomDbDetailsByNodeId" parameterType="String" resultMap="TGeomDbDetailsResult">
  44. select details.id, public.st_asewkt(details.geom) AS geom, details.upload_id, details.geom_json, details.sort, details.geom_area
  45. from t_geom_db_details details
  46. INNER JOIN t_node_land node on node.geom_db_id=details.upload_id
  47. WHERE node.node_id =#{nodeId}
  48. </select>
  49. <insert id="insertTGeomDbDetails" parameterType="TGeomDbDetails">
  50. insert into t_geom_db_details
  51. <trim prefix="(" suffix=")" suffixOverrides=",">
  52. <if test="id != null and id != ''">id,</if>
  53. <if test="geom != null">geom,</if>
  54. <if test="uploadId != null and uploadId != ''">upload_id,</if>
  55. <if test="geomJson != null">geom_json,</if>
  56. <if test="sort != null">sort,</if>
  57. <if test="geom != null">geom_area,</if>
  58. </trim>
  59. <trim prefix="values (" suffix=")" suffixOverrides=",">
  60. <if test="id != null and id != ''">#{id},</if>
  61. <if test="geom != null">public.st_transform(public.st_geomfromewkt(#{geom}), #{shpDbSRID}),</if>
  62. <if test="uploadId != null and uploadId != ''">#{uploadId},</if>
  63. <if test="geomJson != null">#{geomJson},</if>
  64. <if test="sort != null">#{sort},</if>
  65. <if test="geom != null">
  66. public.st_area(public.st_transform(public.st_geomfromewkt(#{geom}), #{shpAreaSRID})
  67. <if test="shpAreaGeography != null and shpAreaGeography==true ">::PUBLIC.geography</if>
  68. ),
  69. </if>
  70. </trim>
  71. </insert>
  72. <update id="updateTGeomDbDetails" parameterType="TGeomDbDetails">
  73. update t_geom_db_details
  74. <trim prefix="SET" suffixOverrides=",">
  75. <if test="geom != null">geom = #{geom},</if>
  76. <if test="uploadId != null and uploadId != ''">upload_id = #{uploadId},</if>
  77. <if test="geomJson != null">geom_json = #{geomJson},</if>
  78. <if test="sort != null">sort = #{sort},</if>
  79. <if test="geomArea != null">geom_area = #{geomArea},</if>
  80. </trim>
  81. where id = #{id}
  82. </update>
  83. <delete id="deleteTGeomDbDetailsById" parameterType="String">
  84. delete from t_geom_db_details where id = #{id}
  85. </delete>
  86. <delete id="deleteTGeomDbDetailsByIds" parameterType="String">
  87. delete from t_geom_db_details where id in
  88. <foreach item="id" collection="array" open="(" separator="," close=")">
  89. #{id}
  90. </foreach>
  91. </delete>
  92. <select id="sumGeomDetailsByUploadId" parameterType="String" resultMap="TGeomDbResult" >
  93. select public.st_asewkt(public.st_union(geom)) AS geom, count(*) geom_number, sum(geom_area) geom_area
  94. from t_geom_db_details where upload_id = #{id}
  95. </select>
  96. <insert id="batchInsertDjzq">
  97. INSERT INTO vector.djzq (bsm, ysdm, djzqdm, djzqmc, bz, geom, valid_flag)
  98. VALUES
  99. <foreach collection="list" item="item" separator=",">
  100. (
  101. #{item.bsm},
  102. #{item.ysdm},
  103. #{item.djzqdm},
  104. #{item.djzqmc},
  105. #{item.projectid},
  106. <choose>
  107. <when test="item.the_geom != null and item.the_geom != ''">
  108. public.st_transform(public.st_geomfromewkt(#{item.the_geom}), #{shpDbSRID})
  109. </when>
  110. <otherwise>
  111. null
  112. </otherwise>
  113. </choose>,
  114. 1
  115. )
  116. </foreach>
  117. </insert>
  118. <insert id="batchInsertDjq">
  119. INSERT INTO vector.djq (bsm, ysdm, djqdm, djqmc, bz, geom, valid_flag)
  120. VALUES
  121. <foreach collection="list" item="item" separator=",">
  122. (
  123. #{item.bsm},
  124. #{item.ysdm},
  125. #{item.djqdm},
  126. #{item.djqmc},
  127. #{item.projectid},
  128. <choose>
  129. <when test="item.the_geom != null and item.the_geom != ''">
  130. public.st_transform(public.st_geomfromewkt(#{item.the_geom}), #{shpDbSRID})
  131. </when>
  132. <otherwise>
  133. null
  134. </otherwise>
  135. </choose>,
  136. 1
  137. )
  138. </foreach>
  139. </insert>
  140. <select id="selectTableDataAndGeom" resultType="Map">
  141. SELECT * ,public.st_asewkt(geom) AS geom2
  142. FROM vector.${tableName}
  143. WHERE 1=1
  144. </select>
  145. </mapper>