| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.siwei.apply.mapper.DecisionTaskMapper">
- <resultMap id="decisionTaskMap" type="com.siwei.apply.domain.DecisionTask">
- <id column="task_id" property="id"/>
- <result column="name" property="name"/>
- <result column="start_time" property="startTime"/>
- <result column="end_time" property="endTime"/>
- <result column="create_time" property="createTime"/>
- <result column="status" property="status"/>
- <result column="shape_area" property="shapeArea"/>
- <result column="geom" property="geom"/>
- <result column="type_id" property="typeId"/>
- <result column="report_path" property="reportPath"/>
- <result column="file_path" property="filePath"/>
- </resultMap>
- <insert id="add" parameterType="com.siwei.apply.domain.DecisionTask">
- INSERT INTO t_decision_task (task_id, name, start_time, end_time, create_time, status, shape_area, geom,type_id, report_path, file_path)
- VALUES (#{id}, #{name}, #{startTime}, #{endTime}, #{createTime}, #{status}, #{shapeArea}, ST_GeomFromEWKT(#{geom}),#{typeId}, #{reportPath}, #{filePath})
- </insert>
- <select id="get" resultMap="decisionTaskMap">
- SELECT task_id, name, start_time, end_time, create_time, status, shape_area, ST_AsEWKT(geom) as geom,type_id, report_path, file_path
- FROM t_decision_task
- WHERE task_id = #{id}
- </select>
- <select id="getList" parameterType="com.siwei.apply.domain.vo.DecisionTaskFilterVo" resultMap="decisionTaskMap">
- SELECT task_id, name, start_time, end_time, create_time, status, shape_area, ST_AsEWKT(geom) as geom,type_id, report_path, file_path
- FROM t_decision_task
- <where>
- <if test="name != null and name != ''">
- AND name LIKE CONCAT('%', #{name}, '%')
- </if>
- <if test="startTime != null and startTime != ''">
- AND start_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND end_time <= #{endTime}
- </if>
- <if test="status != null and status != ''">
- AND status = #{status}
- </if>
- </where>
- ORDER BY create_time DESC
- LIMIT #{pageSize} OFFSET #{offset}
- </select>
- <select id="getCount" parameterType="com.siwei.apply.domain.vo.DecisionTaskFilterVo" resultType="int">
- SELECT COUNT(*)
- FROM t_decision_task
- <where>
- <if test="name != null and name != ''">
- AND name LIKE CONCAT('%', #{name}, '%')
- </if>
- <if test="startTime != null and startTime != ''">
- AND start_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND end_time <= #{endTime}
- </if>
- <if test="status != null and status != ''">
- AND status = #{status}
- </if>
- </where>
- </select>
- <update id="update" parameterType="com.siwei.apply.domain.DecisionTask">
- UPDATE t_decision_task
- <set>
- <if test="name != null">name = #{name},</if>
- <if test="startTime != null">start_time = #{startTime},</if>
- <if test="endTime != null">end_time = #{endTime},</if>
- <if test="status != null">status = #{status},</if>
- <if test="shapeArea != null">shape_area = #{shapeArea},</if>
- <if test="geom != null">geom = ST_GeomFromEWKT(#{geom}),</if>
- <if test="typeId != null">type_id = #{typeId},</if>
- <if test="reportPath != null">report_path = #{reportPath},</if>
- <if test="filePath != null">file_path = #{filePath},</if>
- </set>
- WHERE task_id = #{id}
- </update>
- <delete id="batchDelete">
- DELETE FROM t_decision_task
- WHERE task_id IN
- <foreach collection="ids" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- <insert id="insertDecisionIntersection">
- INSERT INTO t_decision_task_details (
- id,
- task_id,
- type,
- source_id,
- details_name,
- shape_area,
- geom
- )
- SELECT
- REPLACE(uuid_generate_v1()::varchar, '-', '') AS id,
- #{taskId},
- #{type},
- t.source_id,
- t.details_name,
- public.ST_Area(t.geom::public.geography),
- t.geom
- FROM (
- SELECT
- inTbale.${sourceId} as source_id,
- inTbale.${detailsName} as details_name,
- public.ST_Intersection(inTbale.geom,public.ST_GeomFromEWKT(#{ewkt})) AS geom
- FROM vector.${tableName} inTbale
- WHERE public.ST_Intersects( inTbale.geom,public.ST_GeomFromEWKT(#{ewkt}))
- <if test="tableIds != null and tableIds.size() > 0">
- AND inTbale.${sourceId}::varchar IN
- <foreach collection="tableIds" item="tableId" open="(" close=")" separator=",">
- #{tableId}
- </foreach>
- </if>
- ) t
- </insert>
- <!--
- 根据 taskId + type 查询决策任务详情,JOIN 对应业务表补充扩展字段。
- t_decision_task_details.source_id 对应业务表的 ${joinId} 字段(如 zdjbxx.zddm)。
- 固定查询字段:
- - t_decision_task_details : id, type, details_name, shape_area
- 动态查询字段(来自 extraFields,对应业务表列):
- - 由 DecisionType.extraFields 决定,如 zddm、qlrsjsyrlxm
- -->
- <select id="getDetailsList" parameterType="com.siwei.apply.domain.vo.DecisionTaskParamVo" resultType="map">
- SELECT
- d.id AS id,
- d.type AS type,
- d.details_name AS detailsName,
- d.shape_area AS shapeArea
- <if test="extraFields != null and extraFields.size() > 0">
- <foreach collection="extraFields" item="field" separator="">
- , b.${field} AS ${field}
- </foreach>
- </if>
- FROM public.t_decision_task_details d
- LEFT JOIN vector.${tableName} b
- ON b.${joinId}::varchar = d.source_id
- WHERE d.task_id = #{taskId}
- AND d.type = #{type}
- </select>
- </mapper>
|