| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- <?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.YdbpMapper">
- <!-- ResultMap 映射 -->
- <resultMap id="YdbpResultMap" type="com.siwei.apply.domain.Ydbp">
- <id property="id" column="id"/>
- <result property="projectId" column="project_id"/>
- <result property="tdyt" column="tdyt"/>
- <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"/>
- </resultMap>
- <select id="isExit" resultType="Boolean">
- SELECT COUNT(1) > 0
- FROM t_ydbp
- WHERE project_id = #{projectId}
- </select>
- <!-- 插入语句 -->
- <insert id="add" parameterType="com.siwei.apply.domain.Ydbp">
- INSERT INTO t_ydbp (id, project_id, tdyt, yd_area, yd_unit, zs_area, zs_unit, has_zz,
- bp_date, pfwh, pf_date, has_onchain, creator_id, created_at, updated_at)
- VALUES (#{id}, #{projectId}, #{tdyt}, #{ydArea}, #{ydUnit}, #{zsArea}, #{zsUnit}, #{hasZz},
- #{bpDate}, #{pfwh}, #{pfDate}, false, #{creatorId}, now(), now())
- </insert>
- <!-- 查询语句 -->
- <select id="get" resultMap="YdbpResultMap">
- SELECT *
- FROM t_ydbp
- WHERE project_id = #{projectId}
- </select>
- <!-- 新增:根据主键id获取记录 -->
- <select id="getById" resultMap="YdbpResultMap">
- SELECT *
- FROM t_ydbp
- WHERE id = #{id}
- </select>
- <select id="getStatisticsList" resultType="map">
- SELECT
- pro.ID AS project_id,
- bp.ID AS node_id,
- bp.zs_area,
- left(bp.pf_date,4) AS nf,
- bp.zs_unit,
- <if test="hasGeom != null and hasGeom">
- (SELECT array_to_string(array_agg(ST_AsEWKT(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>
- COALESCE (
- CASE
- WHEN bp.zs_unit = '平方米' THEN
- COALESCE ( bp.zs_area, 0 ) / 666.6666667
- WHEN bp.zs_unit = '公顷' THEN
- COALESCE ( bp.zs_area, 0 ) * 15
- WHEN bp.zs_unit = '亩' THEN
- COALESCE ( bp.zs_area, 0 ) * 1
- END,
- 0
- ) AS mj_mu
- FROM
- t_ydbp bp
- LEFT JOIN t_project pro ON bp.project_id = pro."id"
- WHERE
- pro.on_chain_num > 0
- AND 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(pro.name, '') LIKE CONCAT('%', #{keyWord}, '%')
- OR COALESCE(pro.company, '') LIKE CONCAT('%', #{keyWord}, '%')
- )
- </if>
- </select>
- <!-- 更新语句 -->
- <update id="update" parameterType="com.siwei.apply.domain.vo.YdbpUpdateVo">
- UPDATE t_ydbp
- <set>
- <if test="projectId != null">project_id = #{projectId},</if>
- <if test="tdyt != null">tdyt = #{tdyt},</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>
- <if test="hasOnchain != null">has_onchain = #{hasOnchain},</if>
- updated_at = now()
- </set>
- WHERE id = #{id}
- </update>
- <update id="updateHasOnchain">
- UPDATE t_ydbp
- SET has_onchain = #{hasOnchain}, updated_at = now()
- WHERE id = #{id}
- </update>
- </mapper>
|