<?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.yjzl.mapper.TbYjxxMxyjMapper">
    <insert id="insertEntity">
        insert into mosty_yjzl.tb_yjxx_mxyj(id, yjid, mxid, yjids, yj_lx, yj_gzyid, yj_gzymc, yj_fsnf, yj_fsyf, yj_fsny,
                                            yj_fszs,ssbmid,ssxgajid,sssgajid,
                                            yj_fsxs,
                                            yj_fsrq, yjsl,
                                            yj_fssj, yj_sj, yj_jb, yj_bt, yj_nr, jd, wd, zb, zbhash,jl,
                                            yj_dz_xzqh, yj_dz, yj_ryxm, yj_rysfzh, xsd,
                                            yj_hplx, yj_clcph, yjbq, yjbqmc, sf_fszl, sf_wb, yjlyid,
                                            yjly_bqmc,
                                            ssbm, ssbmdm, ssxgaj, ssxgajdm, sssgaj, sssgajdm, 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}, #{yjid}, #{mxid}, #{yjids}, #{yjLx}, #{yjGzyid}, #{yjGzymc}, #{yjFsnf}, #{yjFsyf}, #{yjFsny},
                #{yjFszs},#{ssbmid},#{ssxgajid},#{sssgajid},
                #{yjFsxs},
                #{yjFsrq}, #{yjsl},
                #{yjFssj}, #{yjSj}, #{yjJb}, #{yjBt}, #{yjNr}, #{jd}, #{wd},
                ST_GEOMFROMTEXT(#{zb,typeHandler = com.mosty.base.feign.handle.PointTypeHandler}),
                #{zbhash},#{jl}, #{yjDzXzqh}, #{yjDz}, #{yjRyxm}, #{yjRysfzh}, #{xsd},
                #{yjHplx}, #{yjClcph}, #{yjbq}, #{yjbqmc}, #{sfFszl}, #{sfWb}, #{yjlyid},
                #{yjlyBqmc},
                #{ssbm}, #{ssbmdm}, #{ssxgaj}, #{ssxgajdm}, #{sssgaj}, #{sssgajdm}, #{xtSjly}, #{xtSjzt},
                #{xtScbz}, #{xtCjip}, #{xtCjsj}, #{xtCjrId}, #{xtCjr}, #{xtCjbmdm}, #{xtCjbmmc}, #{xtZhgxip},
                #{xtZhgxsj}, #{xtZhgxrid}, #{xtZhgxr}, #{xtZhgxbmdm}, #{xtZhgxbm}, #{bz})
    </insert>

    <update id="updateEntity">
        update tb_yjxx_mxyj
        <set>
            <if test="yjLx != null and yjLx != ''">
                yj_lx = #{yjLx},
            </if>
            <if test="jl != null">
                jl = #{jl},
            </if>
            <if test="mxid != null and mxid != ''">
                mxid = #{mxid},
            </if>
            <if test="yjid != null and yjid != ''">
                yjid = #{yjid},
            </if>
            <if test="yjids != null and yjids != ''">
                yjids = #{yjids},
            </if>
            <if test="yjGzyid != null and yjGzyid != ''">
                yj_gzyid = #{yjGzyid},
            </if>
            <if test="yjGzymc != null and yjGzymc != ''">
                yj_gzymc = #{yjGzymc},
            </if>
            <if test="yjFsnf != null">
                yj_fsnf = #{yjFsnf},
            </if>
            <if test="yjFsyf != null">
                yj_fsyf = #{yjFsyf},
            </if>
            <if test="yjFsny != null">
                yj_fsny = #{yjFsny},
            </if>
            <if test="yjFszs != null">
                yj_fszs = #{yjFszs},
            </if>
            <if test="yjsl != null">
                yjsl = #{yjsl},
            </if>
            <if test="yjFsrq != null">
                yj_fsrq = #{yjFsrq},
            </if>
            <if test="yjFssj != null">
                yj_fssj = #{yjFssj},
            </if>
            <if test="yjSj != null">
                yj_sj = #{yjSj},
            </if>
            <if test="yjJb != null">
                yj_jb = #{yjJb},
            </if>
            <if test="yjBt != null and yjBt != ''">
                yj_bt = #{yjBt},
            </if>
            <if test="yjNr != null and yjNr != ''">
                yj_nr = #{yjNr},
            </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.PolygonTypeHandler}),
            </if>
            <if test="zbhash != null and zbhash != ''">
                zbhash = #{zbhash},
            </if>
            <if test="yjDzXzqh != null and yjDzXzqh != ''">
                yj_dz_xzqh = #{yjDzXzqh},
            </if>
            <if test="yjDz != null and yjDz != ''">
                yj_dz = #{yjDz},
            </if>
            <if test="yjRyxm != null and yjRyxm != ''">
                yj_ryxm = #{yjRyxm},
            </if>
            <if test="yjRysfzh != null and yjRysfzh != ''">
                yj_rysfzh = #{yjRysfzh},
            </if>
            <if test="xsd != null">
                xsd = #{xsd},
            </if>
            <if test="yjHplx != null and yjHplx != ''">
                yj_hplx = #{yjHplx},
            </if>
            <if test="yjClcph != null and yjClcph != ''">
                yj_clcph = #{yjClcph},
            </if>
            <if test="yjbq != null and yjbq != ''">
                yjbq = #{yjbq},
            </if>
            <if test="yjbqmc != null and yjbqmc != ''">
                yjbqmc = #{yjbqmc},
            </if>
            <if test="sfFszl != null and sfFszl != ''">
                sf_fszl = #{sfFszl},
            </if>
            <if test="sfWb != null and sfWb != ''">
                sf_wb = #{sfWb},
            </if>
            <if test="yjlyid != null and yjlyid != ''">
                yjlyid = #{yjlyid},
            </if>
            <if test="yjlyBqmc != null and yjlyBqmc != ''">
                yjly_bqmc = #{yjlyBqmc},
            </if>
            <if test="ssbm != null and ssbm != ''">
                ssbm = #{ssbm},
            </if>
            <if test="ssbmdm != null and ssbmdm != ''">
                ssbmdm = #{ssbmdm},
            </if>
            <if test="ssxgaj != null and ssxgaj != ''">
                ssxgaj = #{ssxgaj},
            </if>
            <if test="ssbmid != null and ssbmid != ''">
                ssbmid = #{ssbmid},
            </if>
            <if test="ssxgajid != null and ssxgajid != ''">
                ssxgajid = #{ssxgajid},
            </if>
            <if test="sssgajid != null and sssgajid != ''">
                sssgajid = #{sssgajid},
            </if>
            <if test="ssxgajdm != null and ssxgajdm != ''">
                ssxgajdm = #{ssxgajdm},
            </if>
            <if test="sssgaj != null and sssgaj != ''">
                sssgaj = #{sssgaj},
            </if>
            <if test="sssgajdm != null and sssgajdm != ''">
                sssgajdm = #{sssgajdm},
            </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="selectbyMxId" resultType="com.mosty.base.model.entity.yjzl.TbYjxxMxyj">
        select * from tb_yjxx_mxyj a where a.xt_sjzt = '1' and a.xt_scbz = '0'
        and a.mxid = #{mxid}
        <![CDATA[ and a.yj_fssj >= #{kssj} and a.yj_fssj <= #{jssj} ]]>
        <![CDATA[ and st_distance_sphere(POINT(a.jd,a.wd),POINT(#{jd},#{wd})) <= #{radius} ]]>
        order by st_distance_sphere(POINT(a.jd,a.wd),POINT(#{jd},#{wd})) asc
        limit 1
    </select>
</mapper>