TGdbhRwGeomMapper.xml 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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.onemap.apply.mapper.gdbh.TGdbhRwGeomMapper">
  6. <resultMap type="TGdbhRwGeom" id="TGdbhRwGeomResult">
  7. <result property="id" column="id" />
  8. <result property="geom" column="geom" />
  9. <result property="rwbsm" column="rwbsm" />
  10. <result property="geomJson" column="geom_json" />
  11. <result property="sort" column="sort" />
  12. <result property="geomarea" column="geomarea" />
  13. </resultMap>
  14. <sql id="selectTGdbhRwGeomVo">
  15. select id, geom, rwbsm, geom_json, sort, geomarea from t_gdbh_rw_geom
  16. </sql>
  17. <select id="selectTGdbhRwGeomList" parameterType="TGdbhRwGeom" resultMap="TGdbhRwGeomResult">
  18. <include refid="selectTGdbhRwGeomVo"/>
  19. <where>
  20. <if test="geom != null and geom != ''"> and geom = #{geom}</if>
  21. <if test="rwbsm != null and rwbsm != ''"> and rwbsm = #{rwbsm}</if>
  22. <if test="geomJson != null and geomJson != ''"> and geom_json = #{geomJson}</if>
  23. <if test="sort != null and sort != ''"> and sort = #{sort}</if>
  24. <if test="geomarea != null and geomarea != ''"> and geomarea = #{geomarea}</if>
  25. </where>
  26. </select>
  27. <select id="selectTGdbhRwGeomById" parameterType="String" resultMap="TGdbhRwGeomResult">
  28. <include refid="selectTGdbhRwGeomVo"/>
  29. where id = #{id}
  30. </select>
  31. <select id="sumTGdbhRwGeomByRwbsm" parameterType="String" resultType="map">
  32. select public.st_asewkt(public.st_union(geom)) geom, sum(geomarea) geomarea, count(*) geomnumber,STRING_AGG(id, ',') AS ids from t_gdbh_rw_geom
  33. where rwbsm = #{rwbsm}
  34. </select>
  35. <insert id="insertTGdbhRwGeom" parameterType="TGdbhRwGeom">
  36. insert into t_gdbh_rw_geom
  37. <trim prefix="(" suffix=")" suffixOverrides=",">
  38. <if test="id != null and id != ''">id,</if>
  39. <if test="geom != null">geom,</if>
  40. <if test="rwbsm != null and rwbsm != ''">rwbsm,</if>
  41. <if test="geomJson != null">geom_json,</if>
  42. <if test="sort != null">sort,</if>
  43. <if test="geomarea != null">geomarea,</if>
  44. </trim>
  45. <trim prefix="values (" suffix=")" suffixOverrides=",">
  46. <if test="id != null and id != ''">#{id},</if>
  47. <if test="geom != null">public.st_transform(public.st_geomfromewkt(#{geom}), 4326),</if>
  48. <if test="rwbsm != null and rwbsm != ''">#{rwbsm},</if>
  49. <if test="geomJson != null">#{geomJson},</if>
  50. <if test="sort != null">#{sort},</if>
  51. <if test="geomarea != null">#{geomarea},</if>
  52. </trim>
  53. </insert>
  54. <update id="updateTGdbhRwGeom" parameterType="TGdbhRwGeom">
  55. update t_gdbh_rw_geom
  56. <trim prefix="SET" suffixOverrides=",">
  57. <if test="geom != null">geom = #{geom},</if>
  58. <if test="rwbsm != null and rwbsm != ''">rwbsm = #{rwbsm},</if>
  59. <if test="geomJson != null">geom_json = #{geomJson},</if>
  60. <if test="sort != null">sort = #{sort},</if>
  61. <if test="geomarea != null">geomarea = #{geomarea},</if>
  62. </trim>
  63. where id = #{id}
  64. </update>
  65. <delete id="deleteTGdbhRwGeomById" parameterType="String">
  66. delete from t_gdbh_rw_geom where id = #{id}
  67. </delete>
  68. <delete id="deleteTGdbhRwGeomByIds" parameterType="String">
  69. delete from t_gdbh_rw_geom where id in
  70. <foreach item="id" collection="array" open="(" separator="," close=")">
  71. #{id}
  72. </foreach>
  73. </delete>
  74. </mapper>