| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- <?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.YdbpDataMapper">
- <resultMap id="YdbpDataResultMap" type="com.siwei.apply.domain.YdbpData">
- <id property="id" column="id"/>
- <result property="name" column="name"/>
- <result property="ydArea" column="yd_area"/>
- <result property="ydUnit" column="yd_unit"/>
- <result property="zsArea" column="zs_area"/>
- <result property="zsUnit" column="zs_unit"/>
- <result property="hasZz" column="has_zz"/>
- <result property="bpDate" column="bp_date"/>
- <result property="pfwh" column="pfwh"/>
- <result property="pfDate" column="pf_date"/>
- <result property="hasOnchain" column="has_onchain"/>
- <result property="creatorId" column="creator_id"/>
- <result property="createdAt" column="created_at"/>
- <result property="updatedAt" column="updated_at"/>
- <result property="batchType" column="batch_type"/>
- <result property="projectPropertyId" column="project_property_id"/>
- </resultMap>
- <insert id="add" parameterType="com.siwei.apply.domain.YdbpData">
- INSERT INTO t_ydbp_data (
- id, name, yd_area, yd_unit, zs_area, zs_unit, has_zz, bp_date, pfwh, pf_date, creator_id, created_at, updated_at
- ) VALUES (
- #{id}, #{name}, #{ydArea}, #{ydUnit}, #{zsArea}, #{zsUnit}, #{hasZz}, #{bpDate}, #{pfwh}, #{pfDate}, #{creatorId}, now(), now()
- )
- </insert>
- <select id="getById" parameterType="string" resultMap="YdbpDataResultMap">
- SELECT id, name, yd_area, yd_unit, zs_area, zs_unit, has_zz, bp_date, pfwh, pf_date, creator_id, created_at, updated_at,has_onchain
- FROM t_ydbp_data
- WHERE id = #{id}
- </select>
- <select id="selectPage" resultMap="YdbpDataResultMap">
- SELECT id, name, yd_area, yd_unit, zs_area, zs_unit, has_zz, bp_date, pfwh, pf_date, creator_id, created_at, updated_at
- FROM t_ydbp_data
- where 1=1
- <if test="name != null and name != ''">
- AND name LIKE CONCAT('%', #{name}, '%')
- </if>
- <if test="ids != null and ids.size() > 0">
- AND id IN
- <foreach collection="ids" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- <if test="shape != null and shape != ''">
- AND EXISTS (
- SELECT 1
- FROM t_node_land nl
- JOIN t_geom_db_details gd ON gd.upload_id = nl.geom_db_id
- WHERE nl.node_id = t_ydbp_data.id
- AND public.ST_Intersects(gd.geom, public.ST_GeomFromEWKT(#{shape}))
- )
- </if>
- ORDER BY updated_at DESC
- LIMIT #{pageSize} OFFSET #{offset}
- </select>
- <update id="update" parameterType="com.siwei.apply.domain.YdbpData">
- UPDATE t_ydbp_data
- <set>
- <if test="name != null">name = #{name},</if>
- <if test="ydArea != null">yd_area = #{ydArea},</if>
- <if test="ydUnit != null">yd_unit = #{ydUnit},</if>
- <if test="zsArea != null">zs_area = #{zsArea},</if>
- <if test="zsUnit != null">zs_unit = #{zsUnit},</if>
- <if test="hasZz != null">has_zz = #{hasZz},</if>
- <if test="bpDate != null">bp_date = #{bpDate},</if>
- <if test="pfwh != null">pfwh = #{pfwh},</if>
- <if test="pfDate != null">pf_date = #{pfDate},</if>
- updated_at = #{updatedAt}
- </set>
- WHERE id = #{id}
- </update>
- <select id="countAll" resultType="int">
- SELECT COUNT(1)
- FROM t_ydbp_data
- where 1=1
- <if test="name != null and name != ''">
- AND name LIKE CONCAT('%', #{name}, '%')
- </if>
- <if test="ids != null and ids.size() > 0">
- AND id IN
- <foreach collection="ids" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- <if test="shape != null and shape != ''">
- AND EXISTS (
- SELECT 1
- FROM t_node_land nl
- JOIN t_geom_db_details gd ON gd.upload_id = nl.geom_db_id
- WHERE nl.node_id = t_ydbp_data.id
- AND public.ST_Intersects(gd.geom, public.ST_GeomFromEWKT(#{shape}))
- )
- </if>
- </select>
- <delete id="batchDelete">
- DELETE FROM t_ydbp_data
- WHERE id IN
- <foreach collection="ids" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- <update id="updateHasOnchain">
- UPDATE t_ydbp_data
- SET has_onchain = #{hasOnchain}, updated_at = now()
- WHERE id = #{id}
- </update>
- <select id="getStatisticsList" resultMap="YdbpDataResultMap">
- SELECT
- id, name, yd_unit,
- '2' AS batch_type,
- COALESCE (
- CASE
- WHEN yd_unit = '平方米' THEN
- COALESCE ( yd_area, 0 ) / 666.6666667
- WHEN yd_unit = '公顷' THEN
- COALESCE ( yd_area, 0 ) * 15
- WHEN yd_unit = '亩' THEN
- COALESCE ( yd_area, 0 ) * 1
- END,
- 0
- ) AS yd_area ,
- COALESCE (
- CASE
- WHEN zs_unit = '平方米' THEN
- COALESCE ( zs_area, 0 ) / 666.6666667
- WHEN zs_unit = '公顷' THEN
- COALESCE ( zs_area, 0 ) * 15
- WHEN zs_unit = '亩' THEN
- COALESCE ( zs_area, 0 ) * 1
- END,
- 0
- ) AS zs_area,
- <if test="hasGeom != null and hasGeom">
- COALESCE((
- SELECT ST_AsEWKT(ST_Union(gd.geom))
- FROM t_node_land nl
- LEFT JOIN t_geom_db_details gd ON nl.geom_db_id = gd.upload_id
- WHERE nl.node_id = bp.id AND gd.geom IS NOT NULL
- ), '') AS geom,
- </if>
- -- left(pf_date,4) AS nf,
- '亩' as zs_unit,
- has_zz, bp_date, pfwh, pf_date, creator_id, created_at, updated_at,has_onchain
- FROM t_ydbp_data bp
- WHERE bp.has_onchain='t'
- <if test="year != null and year != '' ">
- AND left(bp.pf_date,4) = #{year}
- </if>
- <if test="keyWord != null and keyWord != ''">
- AND (
- COALESCE(bp.name, '') LIKE CONCAT('%', #{keyWord}, '%')
- )
- </if>
- </select>
- </mapper>
|