<?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.mosty.base.manager.mapper.TbJcglXlfaXldwMapper">

    <resultMap type="com.mosty.base.model.entity.jcgl.TbJcglXlfaXldw" id="resultMap">
        <result property="id" column="id" jdbcType="VARCHAR"/>
        <result property="faId" column="fa_id" jdbcType="VARCHAR"/>
        <result property="jd" column="jd" jdbcType="NUMERIC"/>
        <result property="wd" column="wd" jdbcType="NUMERIC"/>
        <result property="zb" column="zb" typeHandler="com.mosty.base.feign.handle.PointTypeHandler"/>
        <result property="zbhash" column="zbhash" jdbcType="VARCHAR"/>
        <result property="qy" column="qy" typeHandler="com.mosty.base.feign.handle.PolygonTypeHandler"/>
        <result property="dwmc" column="dwmc" jdbcType="VARCHAR"/>
        <result property="dwsj" column="dwsj" jdbcType="TIMESTAMP"/>
        <result property="tlsc" column="tlsc" jdbcType="INTEGER"/>
        <result property="pcrys" column="pcrys" jdbcType="INTEGER"/>
        <result property="pccls" column="pccls" jdbcType="INTEGER"/>
        <result property="xtSjly" column="xt_sjly" jdbcType="VARCHAR"/>
        <result property="xtSjzt" column="xt_sjzt" jdbcType="VARCHAR"/>
        <result property="xtScbz" column="xt_scbz" jdbcType="VARCHAR"/>
        <result property="xtCjip" column="xt_cjip" jdbcType="VARCHAR"/>
        <result property="xtCjsj" column="xt_cjsj" jdbcType="VARCHAR"/>
        <result property="xtCjrId" column="xt_cjr_id" jdbcType="VARCHAR"/>
        <result property="xtCjr" column="xt_cjr" jdbcType="VARCHAR"/>
        <result property="xtCjbmdm" column="xt_cjbmdm" jdbcType="VARCHAR"/>
        <result property="xtCjbmmc" column="xt_cjbm" jdbcType="VARCHAR"/>
        <result property="xtZhgxip" column="xt_zhgxip" jdbcType="VARCHAR"/>
        <result property="xtZhgxsj" column="xt_zhgxsj" jdbcType="VARCHAR"/>
        <result property="xtZhgxrid" column="xt_zhgxrid" jdbcType="VARCHAR"/>
        <result property="xtZhgxr" column="xt_zhgxr" jdbcType="VARCHAR"/>
        <result property="xtZhgxbmdm" column="xt_zhgxbmdm" jdbcType="VARCHAR"/>
        <result property="xtZhgxbm" column="xt_zhgxbm" jdbcType="VARCHAR"/>
        <result property="bz" column="bz" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="base_column_list">
        id
        , fa_id, dwlx, jd, wd, zbhash, dwmc, dwsj, tlsc,
     pcrys, pccls, xt_sjly, xt_sjzt,
     xt_scbz, xt_cjip, xt_cjsj, xt_cjr_id, xt_cjr, xt_cjbmdm, xt_cjbmmc, xt_zhgxip,
     xt_zhgxsj, xt_zhgxrid, xt_zhgxr, xt_zhgxbmdm, xt_zhgxbm, bz
    </sql>

    <sql id="zb_sql">
        ST_ASWKT
        (zb) as zb,
        ST_ASWKT(qy) as qy
    </sql>

    <!--保存快反点信息-->
    <insert id="insertEntity" parameterType="com.mosty.base.model.entity.jcgl.TbJcglXlfaXldw">
        insert into tb_jcgl_xlfa_xldw (id, fa_id, dwlx, jd, wd, zb, zbhash, qy, dwmc, dwsj, tlsc,
                                       pcrys, pccls, xt_sjly, xt_sjzt,
                                       xt_scbz, xt_cjip, xt_cjsj, xt_cjr_id, xt_cjr, xt_cjbmdm, xt_cjbmmc, xt_zhgxip,
                                       xt_zhgxsj, xt_zhgxrid, xt_zhgxr, xt_zhgxbmdm, xt_zhgxbm, bz)
        values (#{id}, #{faId}, #{dwlx}, #{jd}, #{wd},
                ST_GEOMFROMTEXT(#{zb,typeHandler = com.mosty.base.feign.handle.PointTypeHandler}), #{zbhash},
                ST_GEOMFROMTEXT(#{qy,typeHandler = com.mosty.base.feign.handle.PolygonTypeHandler}),
                #{dwmc}, #{dwsj}, #{tlsc}, #{pcrys}, #{pccls}, #{xtSjly}, #{xtSjzt}, #{xtScbz}, #{xtCjip},
                #{xtCjsj}, #{xtCjrId}, #{xtCjr},
                #{xtCjbmdm}, #{xtCjbmmc}, #{xtZhgxip}, #{xtZhgxsj}, #{xtZhgxrid}, #{xtZhgxr}, #{xtZhgxbmdm},
                #{xtZhgxbm}, #{bz})
    </insert>

    <!--修改-->
    <update id="updateEntity" parameterType="com.mosty.base.model.entity.jcgl.TbJcglXlfaXldw">
        update tb_jcgl_xlfa_xldw
        <set>
            <if test="faId != null and faId != ''">
                fa_id = #{faId},
            </if>
            <if test="dwlx != null and dwlx != ''">
                dwlx = #{dwlx},
            </if>
            <if test="jd != null">
                jd = #{jd},
            </if>
            <if test="wd != null">
                wd = #{wd},
            </if>
            <if test="zb != null">
                zb = ST_GEOMFROMTEXT(#{zb,typeHandler=com.mosty.base.feign.handle.PointTypeHandler}),
            </if>
            <if test="zbhash != null and zbhash != ''">
                zbhash = #{zbhash},
            </if>
            <if test="qy != null">
                qy = ST_GEOMFROMTEXT(#{qy,typeHandler = com.mosty.base.feign.handle.PolygonTypeHandler}),
            </if>
            <if test="dwmc != null and dwmc != ''">
                dwmc = #{dwmc},
            </if>
            <if test="dwsj != null">
                dwsj = #{dwsj},
            </if>
            <if test="tlsc != null">
                tlsc = #{tlsc},
            </if>
            <if test="pcrys != null">
                pcrys = #{pcrys},
            </if>
            <if test="pccls != null">
                pccls = #{pccls},
            </if>
            <if test="xtSjly != null and xtSjly != ''">
                xt_sjly = #{xtSjly},
            </if>
            <if test="xtSjzt != null and xtSjzt != ''">
                xt_sjzt = #{xtSjzt},
            </if>
            <if test="xtScbz != null and xtScbz != ''">
                xt_scbz = #{xtScbz},
            </if>
            <if test="xtCjip != null and xtCjip != ''">
                xt_cjip = #{xtCjip},
            </if>
            <if test="xtCjsj != null">
                xt_cjsj = #{xtCjsj},
            </if>
            <if test="xtCjrId != null and xtCjrId != ''">
                xt_cjr_id = #{xtCjrId},
            </if>
            <if test="xtCjr != null and xtCjr != ''">
                xt_cjr = #{xtCjr},
            </if>
            <if test="xtCjbmdm != null and xtCjbmdm != ''">
                xt_cjbmdm = #{xtCjbmdm},
            </if>
            <if test="xtCjbmmc != null and xtCjbmmc != ''">
                xt_cjbmmc = #{xtCjbmmc},
            </if>
            <if test="xtZhgxip != null and xtZhgxip != ''">
                xt_zhgxip = #{xtZhgxip},
            </if>
            <if test="xtZhgxsj != null">
                xt_zhgxsj = #{xtZhgxsj},
            </if>
            <if test="xtZhgxrid != null and xtZhgxrid != ''">
                xt_zhgxrid = #{xtZhgxrid},
            </if>
            <if test="xtZhgxr != null and xtZhgxr != ''">
                xt_zhgxr = #{xtZhgxr},
            </if>
            <if test="xtZhgxbmdm != null and xtZhgxbmdm != ''">
                xt_zhgxbmdm = #{xtZhgxbmdm},
            </if>
            <if test="xtZhgxbm != null and xtZhgxbm != ''">
                xt_zhgxbm = #{xtZhgxbm},
            </if>
            <if test="bz != null and bz != ''">
                bz = #{bz}
            </if>
        </set>
        where id = #{id}
    </update>

    <!--获取列表-->
    <select id="getListByFaId" resultMap="resultMap">
        select
        <include refid="base_column_list"/>,
        <include refid="zb_sql"/>
        from tb_jcgl_xlfa_xldw where xt_sjzt = '1' and xt_scbz = '0'
        and fa_id = #{faid}
    </select>

    <!--获取详情-->
    <select id="getById" resultMap="resultMap">
        select
        <include refid="base_column_list"/>,
        <include refid="zb_sql"/>
        from tb_jcgl_xlfa_xldw where xt_sjzt = '1' and xt_scbz = '0'
        and id = #{id}
    </select>

    <!--根据方案Id删除数据-->
    <delete id="deleteEntity" parameterType="String">
        delete
        from tb_jcgl_xlfa_xldw
        where fa_id = #{faid}
    </delete>
</mapper>
