DecisionTaskMapper.xml 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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.DecisionTaskMapper">
  6. <resultMap id="decisionTaskMap" type="com.siwei.apply.domain.DecisionTask">
  7. <id column="task_id" property="id"/>
  8. <result column="name" property="name"/>
  9. <result column="start_time" property="startTime"/>
  10. <result column="end_time" property="endTime"/>
  11. <result column="create_time" property="createTime"/>
  12. <result column="status" property="status"/>
  13. <result column="shape_area" property="shapeArea"/>
  14. <result column="geom" property="geom"/>
  15. <result column="type_id" property="typeId"/>
  16. <result column="report_path" property="reportPath"/>
  17. <result column="file_path" property="filePath"/>
  18. </resultMap>
  19. <insert id="add" parameterType="com.siwei.apply.domain.DecisionTask">
  20. INSERT INTO t_decision_task (task_id, name, start_time, end_time, create_time, status, shape_area, geom,type_id, report_path, file_path)
  21. VALUES (#{id}, #{name}, #{startTime}, #{endTime}, #{createTime}, #{status}, #{shapeArea}, ST_GeomFromEWKT(#{geom}),#{typeId}, #{reportPath}, #{filePath})
  22. </insert>
  23. <select id="get" resultMap="decisionTaskMap">
  24. SELECT task_id, name, start_time, end_time, create_time, status, shape_area, ST_AsEWKT(geom) as geom,type_id, report_path, file_path
  25. FROM t_decision_task
  26. WHERE task_id = #{id}
  27. </select>
  28. <select id="getList" parameterType="com.siwei.apply.domain.vo.DecisionTaskFilterVo" resultMap="decisionTaskMap">
  29. SELECT task_id, name, start_time, end_time, create_time, status, shape_area, ST_AsEWKT(geom) as geom,type_id, report_path, file_path
  30. FROM t_decision_task
  31. <where>
  32. <if test="name != null and name != ''">
  33. AND name LIKE CONCAT('%', #{name}, '%')
  34. </if>
  35. <if test="startTime != null and startTime != ''">
  36. AND start_time &gt;= #{startTime}
  37. </if>
  38. <if test="endTime != null and endTime != ''">
  39. AND end_time &lt;= #{endTime}
  40. </if>
  41. <if test="status != null and status != ''">
  42. AND status = #{status}
  43. </if>
  44. </where>
  45. ORDER BY create_time DESC
  46. LIMIT #{pageSize} OFFSET #{offset}
  47. </select>
  48. <select id="getCount" parameterType="com.siwei.apply.domain.vo.DecisionTaskFilterVo" resultType="int">
  49. SELECT COUNT(*)
  50. FROM t_decision_task
  51. <where>
  52. <if test="name != null and name != ''">
  53. AND name LIKE CONCAT('%', #{name}, '%')
  54. </if>
  55. <if test="startTime != null and startTime != ''">
  56. AND start_time &gt;= #{startTime}
  57. </if>
  58. <if test="endTime != null and endTime != ''">
  59. AND end_time &lt;= #{endTime}
  60. </if>
  61. <if test="status != null and status != ''">
  62. AND status = #{status}
  63. </if>
  64. </where>
  65. </select>
  66. <update id="update" parameterType="com.siwei.apply.domain.DecisionTask">
  67. UPDATE t_decision_task
  68. <set>
  69. <if test="name != null">name = #{name},</if>
  70. <if test="startTime != null">start_time = #{startTime},</if>
  71. <if test="endTime != null">end_time = #{endTime},</if>
  72. <if test="status != null">status = #{status},</if>
  73. <if test="shapeArea != null">shape_area = #{shapeArea},</if>
  74. <if test="geom != null">geom = ST_GeomFromEWKT(#{geom}),</if>
  75. <if test="typeId != null">type_id = #{typeId},</if>
  76. <if test="reportPath != null">report_path = #{reportPath},</if>
  77. <if test="filePath != null">file_path = #{filePath},</if>
  78. </set>
  79. WHERE task_id = #{id}
  80. </update>
  81. <delete id="batchDelete">
  82. DELETE FROM t_decision_task
  83. WHERE task_id IN
  84. <foreach collection="ids" item="id" open="(" separator="," close=")">
  85. #{id}
  86. </foreach>
  87. </delete>
  88. <insert id="insertDecisionIntersection">
  89. INSERT INTO t_decision_task_details (
  90. id,
  91. task_id,
  92. type,
  93. source_id,
  94. details_name,
  95. shape_area,
  96. geom
  97. )
  98. SELECT
  99. REPLACE(uuid_generate_v1()::varchar, '-', '') AS id,
  100. #{taskId},
  101. #{type},
  102. t.source_id,
  103. t.details_name,
  104. public.ST_Area(t.geom::public.geography),
  105. t.geom
  106. FROM (
  107. SELECT
  108. inTbale.${sourceId} as source_id,
  109. inTbale.${detailsName} as details_name,
  110. public.ST_Intersection(inTbale.geom,public.ST_GeomFromEWKT(#{ewkt})) AS geom
  111. FROM vector.${tableName} inTbale
  112. WHERE public.ST_Intersects( inTbale.geom,public.ST_GeomFromEWKT(#{ewkt}))
  113. <if test="tableIds != null and tableIds.size() > 0">
  114. AND inTbale.${sourceId}::varchar IN
  115. <foreach collection="tableIds" item="tableId" open="(" close=")" separator=",">
  116. #{tableId}
  117. </foreach>
  118. </if>
  119. ) t
  120. </insert>
  121. <!--
  122. 根据 taskId + type 查询决策任务详情,JOIN 对应业务表补充扩展字段。
  123. t_decision_task_details.source_id 对应业务表的 ${joinId} 字段(如 zdjbxx.zddm)。
  124. 固定查询字段:
  125. - t_decision_task_details : id, type, details_name, shape_area
  126. 动态查询字段(来自 extraFields,对应业务表列):
  127. - 由 DecisionType.extraFields 决定,如 zddm、qlrsjsyrlxm
  128. -->
  129. <select id="getDetailsList" parameterType="com.siwei.apply.domain.vo.DecisionTaskParamVo" resultType="map">
  130. SELECT
  131. d.id AS id,
  132. d.type AS type,
  133. d.details_name AS detailsName,
  134. d.shape_area AS shapeArea
  135. <if test="extraFields != null and extraFields.size() > 0">
  136. <foreach collection="extraFields" item="field" separator="">
  137. , b.${field} AS ${field}
  138. </foreach>
  139. </if>
  140. FROM public.t_decision_task_details d
  141. LEFT JOIN vector.${tableName} b
  142. ON b.${joinId}::varchar = d.source_id
  143. WHERE d.task_id = #{taskId}
  144. AND d.type = #{type}
  145. </select>
  146. </mapper>