| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- <?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.NodeLandMapper">
- <!-- 结果映射 -->
- <resultMap id="BaseResultMap" type="com.siwei.apply.domain.NodeLand">
- <id property="id" column="id"/>
- <result property="nodeId" column="node_id"/>
- <result property="geomDbId" column="geom_db_id"/>
- </resultMap>
- <!-- 基础查询字段 -->
- <sql id="Base_Column_List">
- id, node_id, geom_db_id
- </sql>
- <!-- 根据节点ID查询附件信息(只返回一条) -->
- <select id="selectByNodeId" resultMap="BaseResultMap" parameterType="String">
- SELECT
- <include refid="Base_Column_List"/>
- FROM t_node_land
- WHERE node_id = #{nodeId}
- LIMIT 1
- </select>
- <!-- 根据node_id查询地块几何信息,返回geom_db_id和并集的外边框、中心点 -->
- <select id="selectGeomByNodeId" resultType="map" parameterType="String">
- SELECT
- nl.geom_db_id as "geomDbId",
- tgd.shppath as "shppath",
- array_to_string(array_agg(gd.id), '|') as "geomIds",
- array_to_string(array_agg(ST_AsEWKT(gd.geom)), '|') as "geoms",
- ST_AsEWKT(ST_Envelope(ST_Union(gd.geom))) as "envelope",
- ST_AsEWKT(ST_Centroid(ST_Union(gd.geom))) as "centroid"
- FROM t_node_land nl
- LEFT JOIN t_geom_db_details gd ON nl.geom_db_id = gd.upload_id
- LEFT JOIN t_geom_db tgd ON nl.geom_db_id = tgd.id
- WHERE nl.node_id = #{nodeId}
- AND gd.geom IS NOT NULL
- GROUP BY nl.geom_db_id, tgd.shppath
- </select>
- <!-- 根据node_id查询地块数量信息 -->
- <select id="selectCountGeomByNodeId" >
- SELECT
- count(1) as "count"
- FROM t_node_land nl
- LEFT JOIN t_geom_db_details gd ON nl.geom_db_id = gd.upload_id
- LEFT JOIN t_geom_db tgd ON nl.geom_db_id = tgd.id
- <where>
- <if test="nodeIdList != null and nodeIdList.size() > 0">
- AND nl.node_id IN
- <foreach collection="nodeIdList" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- </where>
- AND gd.geom IS NOT NULL
- </select>
- <!-- 根据node_id和geom_db_id创建记录 -->
- <insert id="insertByNodeIdAndGeomDbId">
- INSERT INTO t_node_land (
- id,
- node_id,
- geom_db_id
- ) VALUES (
- REPLACE(gen_random_uuid()::varchar, '-', ''),
- #{param1},
- #{param2}
- )
- </insert>
- <!-- 根据node_id删除记录 -->
- <delete id="deleteByNodeId" parameterType="String">
- DELETE FROM t_node_land
- WHERE node_id = #{nodeId}
- </delete>
- <!-- 新增:根据projectId与nodeTableName查询项目流程表中的nodeId(唯一) -->
- <select id="selectNodeIdsByProjectIdAndNodeTableName" parameterType="map" resultType="string">
- SELECT node_id
- FROM t_project_workflow
- WHERE project_id = #{projectId}
- AND node_table_name = #{nodeTableName}
- ORDER BY created_at
- LIMIT 1
- </select>
- <!-- 根据nodeId,查询出当前具体的图斑ID -->
- <select id="selectGeomDbDetailsByNodeId" parameterType="String" resultType="java.util.Map">
- select details.id as "id",
- public.st_asewkt(details.geom) AS "geom",
- details.upload_id as "uploadId",
- details.geom_json as "geomJson",
- details.sort as "sort",
- details.geom_area as "geomArea"
- from t_geom_db_details details
- INNER JOIN t_node_land node on node.geom_db_id=details.upload_id
- <where>
- 1=1
- <if test="nodeId != null">
- AND node.node_id =#{nodeId}
- </if>
- <if test="geomId != null">
- AND details.id =#{geomId}
- </if>
- </where>
- </select>
- <select id="existsGeomIntersect" resultType="boolean">
- SELECT EXISTS (
- SELECT 1
- FROM t_geom_db_details source
- JOIN t_geom_db_details target ON target.id = #{targetGeomId}
- WHERE source.id = #{sourceGeomId}
- AND source.geom IS NOT NULL
- AND target.geom IS NOT NULL
- AND public.ST_Intersects(source.geom, target.geom)
- )
- </select>
- <select id="selectGeomContainsNode" parameterType="String" resultType="map">
- SELECT geom.id , node.node_id FROM "t_geom_db_details" geom
- LEFT JOIN "public"."t_geom_db" upload on geom.upload_id=upload.id
- LEFT JOIN "public"."t_node_land" node on node.geom_db_id=upload.id
- LEFT JOIN "public"."t_ydbp_data" ydbp on node.node_id=ydbp.id
- where ydbp.has_onchain=true
- AND st_contains(ST_Buffer(geom.geom::geography, 0.1)::geometry, (SELECT geom FROM "t_geom_db_details" WHERE id = #{detailsId}) )
- order by ydbp.created_at desc
- limit 1
- </select>
- <!-- 根据nodeId,查询出当前具体的图斑ID -->
- <select id="selectGeomDetailsByGeomDbId" parameterType="String" resultType="java.util.Map">
- select details.id, public.st_asewkt(details.geom) AS geom, details.upload_id, details.geom_json,
- details.sort, CAST(details.geom_area AS FLOAT) geom_area
- from t_geom_db_details details
- WHERE details.upload_id = #{geomDbId}
- </select>
- <select id="selectByGeom" parameterType="String" resultMap="BaseResultMap">
- SELECT bb.* from t_geom_db_details aa
- LEFT JOIN t_node_land bb on aa.upload_id = bb.geom_db_id
- LEFT JOIN t_tdgy cc
- on bb.node_id=cc.id
- where public.ST_Intersects(aa.geom,public.ST_GeomFromEWKT(#{ewkt})) and cc.id is not null
- </select>
- <select id="selectDjzqContainsNodeList" resultType="Map">
- SELECT
- djzq.bsm,
- djzq.ysdm,
- djzq.djzqdm,
- djzq.djzqmc,
- djzq.bz
- FROM vector.djzq
- WHERE (djzq.valid_flag IS NULL OR djzq.valid_flag = 0)
- and st_contains(ST_Buffer(djzq.geom::geography, 0.1)::geometry, (SELECT geom FROM "public".t_geom_db_details WHERE id = #{detailsId}))
- limit 1
- </select>
- <!-- 这里判断两个图形是否一致,如果一致则返回已存在的当前的节点数据 -->
- <select id="selectNodeGeomContains" parameterType="String" resultType="map">
- SELECT geom.id , node.node_id FROM "t_geom_db_details" geom
- LEFT JOIN "public"."t_geom_db" upload on geom.upload_id=upload.id
- LEFT JOIN "public"."t_node_land" node on node.geom_db_id=upload.id
- LEFT JOIN "public"."t_project_immobile_code" tpic on node.node_id=tpic.node_id
- where st_contains(ST_Buffer(geom.geom::geography, 0.1)::geometry, (SELECT geom FROM "t_geom_db_details" WHERE id = #{detailsId} ))
- <if test="nodeIdList != null and nodeIdList.size() > 0">
- AND tpic.node_id IN
- <foreach collection="nodeIdList" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- limit 1
- </select>
- <!-- 这里判断两个图形是否一致,如果一致则返回已存在的当前的节点数据 -->
- <select id="selectGeomContains" parameterType="String" resultType="map">
- SELECT geom.id , upload.id as geom_db_id FROM "t_geom_db_details" geom
- LEFT JOIN "public"."t_geom_db" upload on geom.upload_id=upload.id
- LEFT JOIN "public"."t_project_immobile_code" tpic on upload.id=tpic.geom_db_id
- where st_contains(ST_Buffer(geom.geom::geography, 0.1)::geometry, (SELECT geom FROM "t_geom_db_details" WHERE id = #{detailsId} ))
- <if test="geomDbIdList != null and geomDbIdList.size() > 0">
- AND tpic.geom_db_id IN
- <foreach collection="geomDbIdList" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- limit 1
- </select>
- </mapper>
|