<?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.wzzx.mapper.TbQwXfbbMapper">
    <resultMap id="BaseResultMap" type="com.mosty.base.model.entity.qwzx.TbQwXfbb">
        <id column="id" property="id" jdbcType="VARCHAR"/>
        <result column="xfpb_id" property="xfpbId"/>
        <result column="qwdj_id" property="qwdjId"/>
        <result column="qwdj" property="qwdj"/>
        <result column="qwbc_id" property="qwbcId"/>
        <result column="jz_id" property="jzId"/>
        <result column="jz_mc" property="jzMc"/>
        <result column="xfbm" property="xfbm"/>
        <result column="xfbmdm" property="xfbmdm"/>
        <result column="fzr_sfzh" property="fzrSfzh"/>
        <result column="fzr_xm" property="fzrXm"/>
        <result column="fzr_id" property="fzrId"/>
        <result column="fzr_lxdh" property="fzrLxdh"/>
        <result column="xfrq" property="xfrq"/>
        <result column="kssj" property="kssj"/>
        <result column="jssj" property="jssj"/>
        <result column="zqsc" property="zqsc"/>
        <result column="jgts" property="jgts"/>
        <result column="mjsl" property="mjsl"/>
        <result column="pbmj" property="pbmj"/>
        <result column="fjsl" property="fjsl"/>
        <result column="pbfj" property="pbfj"/>
        <result column="jcsl" property="jcsl"/>
        <result column="pbcl" property="pbcl"/>
        <result column="txzbsl" property="txzbsl"/>
        <result column="txzb" property="txzb"/>
        <result column="jyqxsl" property="jyqxsl"/>
        <result column="jyqx" property="jyqx"/>
        <result column="wzlx" property="wzlx"/>
        <result column="zzlx" property="zzlx"/>
        <result column="xlfs" property="xlfs"/>
        <result column="xfzt" property="xfzt"/>
        <result column="bbkssj" property="bbkssj"/>
        <result column="bbjssj" property="bbjssj"/>
        <result column="bbzt" property="bbzt"/>
        <result column="dqwz" property="dqwz"/>
        <result column="jd" property="jd"/>
        <result column="wd" property="wd"/>
        <result column="zb" property="zb" typeHandler="com.mosty.base.feign.handle.PointTypeHandler"/>
        <result column="zbhash" property="zbhash"/>
        <result column="zbsj" property="zbsj"/>
        <result column="xfsc" property="xfsc"/>
        <result column="xflc" property="xflc"/>
        <result column="xffwlx" property="xffwlx"/>
        <result column="xffwid" property="xffwid"/>
        <result column="ssbm" property="ssbm"/>
        <result column="ssbmid" property="ssbmid"/>
        <result column="ssbmdm" property="ssbmdm"/>
        <result column="ssxgaj" property="ssxgaj"/>
        <result column="ssxgajid" property="ssxgajid"/>
        <result column="ssxgajdm" property="ssxgajdm"/>
        <result column="sssgaj" property="sssgaj"/>
        <result column="sssgajid" property="sssgajid"/>
        <result column="sssgajdm" property="sssgajdm"/>
        <result column="bz" property="bz"/>
        <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="TIMESTAMP"/>
        <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_cjbmmc" jdbcType="VARCHAR"/>
        <result property="xtZhgxip" column="xt_zhgxip" jdbcType="VARCHAR"/>
        <result property="xtZhgxsj" column="xt_zhgxsj" jdbcType="TIMESTAMP"/>
        <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"/>
    </resultMap>

    <sql id="base_column_list">
        id, xfpb_id, qwdj_id, qwdj, qwbc_id, jz_id, jz_mc,
       xfbm, xfbmdm, fzr_sfzh, fzr_xm, fzr_id, fzr_lxdh, xfrq, kssj, jssj,
       zqsc, jgts, mjsl, pbmj, fjsl, pbfj, jcsl, pbcl, txzbsl, txzb, jyqxsl,
       jyqx, wzlx, zzlx, xlfs, xfzt, bbkssj, bbjssj, bbzt, dqwz, jd, wd,
       zbhash, zbsj, xfsc, xflc, xffwlx, xffwid, ssbm, ssbmdm, ssxgaj, ssxgajdm,ssbmid,ssxgajid,sssgajid,
       sssgaj, sssgajdm, bz, 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
    </sql>

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

    <!--id查询-->
    <select id="queryById" resultMap="BaseResultMap">
        select
        <include refid="base_column_list"/>,
        <include refid="zb_sql"/>
        from mosty_qwgl.tb_qw_xfbb
        where xt_scbz = '0' and id = #{id,jdbcType=VARCHAR}
    </select>
    <!--    gx_mosty_qwgl.-->
    <!--更新报备坐标-->
    <update id="updateXfbb">
        update mosty_qwgl.tb_qw_xfbb
        <set>
            <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="dqwz != null and dqwz != ''">
                dqwz = #{dqwz},
            </if>
            <if test="zbsj != null">
                zbsj = #{zbsj},
            </if>
<!--            <if test="xfsc != null">-->
<!--                xfsc = #{xfsc},-->
<!--            </if>-->
            <if test="xflc != null">
                xflc = #{xflc},
            </if>
            <if test="xfzt != null and xfzt != ''">
                xfzt = #{xfzt},
            </if>
            <if test="bz != null and bz != ''">
                bz = #{bz}
            </if>
        </set>
        where id = #{id}
    </update>

    <select id="getsfbb" resultType="java.lang.Integer">
        SELECT COUNT(1) FROM mosty_qwgl.tb_qw_xfbb where xt_scbz = '0' and bbzt = '0'
        <if test="id != null and id != ''">
            and id = #{id}
        </if>
    </select>
</mapper>
