<?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.unis.base.server.dao.TzSlqyDao">

    <resultMap id="BaseResultMap" type="com.unis.base.server.entity.TzSlqyDO">
        <result column="id" property="id" jdbcType="DECIMAL"/>
        <result column="tyshxydm" property="tyshxydm" jdbcType="VARCHAR"/>
        <result column="zzjgdm" property="zzjgdm" jdbcType="VARCHAR"/>
        <result column="qymc" property="qymc" jdbcType="VARCHAR"/>
        <result column="qylx" property="qylx" jdbcType="VARCHAR"/>
        <result column="dwdm" property="dwdm" jdbcType="VARCHAR"/>
        <result column="qyjjlx" property="qyjjlx" jdbcType="VARCHAR"/>
        <result column="qyxz" property="qyxz" jdbcType="VARCHAR"/>
        <result column="djzclx" property="djzclx" jdbcType="VARCHAR"/>
        <result column="gsdjzch" property="gsdjzch" jdbcType="VARCHAR"/>
        <result column="fddbr" property="fddbr" jdbcType="VARCHAR"/>
        <result column="bgdh" property="bgdh" jdbcType="VARCHAR"/>
        <result column="frsjh" property="frsjh" jdbcType="VARCHAR"/>
        <result column="qydzyx" property="qydzyx" jdbcType="VARCHAR"/>
        <result column="zczb" property="zczb" jdbcType="VARCHAR"/>
        <result column="qycyrys" property="qycyrys" jdbcType="VARCHAR"/>
        <result column="zjyszcrs" property="zjyszcrs" jdbcType="VARCHAR"/>
        <result column="bgyrs" property="bgyrs" jdbcType="VARCHAR"/>
        <result column="jhyyrs" property="jhyyrs" jdbcType="VARCHAR"/>
        <result column="yzyzgzsrs" property="yzyzgzsrs" jdbcType="VARCHAR"/>
        <result column="qyczhm" property="qyczhm" jdbcType="VARCHAR"/>
        <result column="qytxdz" property="qytxdz" jdbcType="VARCHAR"/>
        <result column="qyyb" property="qyyb" jdbcType="VARCHAR"/>
        <result column="qyzyyw" property="qyzyyw" jdbcType="VARCHAR"/>
        <result column="qyzcsj" property="qyzcsj" jdbcType="VARCHAR"/>
        <result column="zzxlysry" property="zzxlysry" jdbcType="VARCHAR"/>
        <result column="qysclszypz" property="qysclszypz" jdbcType="VARCHAR"/>
        <result column="qyyjjb" property="qyyjjb" jdbcType="VARCHAR"/>
        <result column="qyjd" property="qyjd" jdbcType="VARCHAR"/>
        <result column="qywd" property="qywd" jdbcType="VARCHAR"/>
        <result column="qyszqy" property="qyszqy" jdbcType="VARCHAR"/>
        <result column="qylsgx" property="qylsgx" jdbcType="VARCHAR"/>
        <result column="status" property="status" jdbcType="VARCHAR"/>
        <result column="creator" property="creator" jdbcType="VARCHAR"/>
        <result column="creator_code" property="creatorCode" jdbcType="VARCHAR"/>
        <result column="create_date" property="createDate" jdbcType="VARCHAR"/>
        <result column="refresher" property="refresher" jdbcType="VARCHAR"/>
        <result column="refresher_code" property="refresherCode" jdbcType="VARCHAR"/>
        <result column="refresh_time" property="refreshTime" jdbcType="VARCHAR"/>
        <result column="remark" property="remark" jdbcType="VARCHAR"/>
        <result column="qyccnl" property="qyccnl" jdbcType="VARCHAR"/>
        <result column="qyzt" property="qyzt" jdbcType="DECIMAL"/>
        <result column="qyszqybh" property="qyszqybh" jdbcType="VARCHAR"/>
        <result column="QYYJLXBH" property="qyyjlxbh" jdbcType="VARCHAR"/>
        <result column="QYYJLXMC" property="qyyjlxmc" jdbcType="VARCHAR"/>
        <result column="SFDLFRZG" property="sfdlfrzg" jdbcType="DECIMAL"/>
        <result column="XSQYGS" property="xsqygs" jdbcType="DECIMAL"/>
        <result column="ZCRQ" property="zcrq" jdbcType="DATE"/>
        <result column="SFJYSGZG" property="sfjysgzg" jdbcType="DECIMAL"/>
        <result column="LSSGXKZFZJG" property="lssgxkzfzjg" jdbcType="VARCHAR"/>
        <result column="SGZGZBH" property="sgzgzbh" jdbcType="VARCHAR"/>
        <result column="SSLSXZGLBM" property="sslsxzglbm" jdbcType="VARCHAR"/>
        <result column="ZDMJ" property="zdmj" jdbcType="DECIMAL"/>
        <result column="SSZDMJ" property="sszdmj" jdbcType="DECIMAL"/>
        <result column="SQJGZDMJ" property="sqjgzdmj" jdbcType="DATE"/>
        <result column="QYGSDJJG" property="qygsdjjg" jdbcType="VARCHAR"/>
        <result column="QYLXR" property="qylxr" jdbcType="VARCHAR"/>
        <result column="qyjgdm" property="qyjgdm" jdbcType="VARCHAR"/>
        <result column="yysr" property="yysr" jdbcType="VARCHAR"/>
        <result column="lsze" property="lsze" jdbcType="VARCHAR"/>
        <result column="dnyjkftr" property="dnyjkftr" jdbcType="VARCHAR"/>
        <result column="fmzl" property="fmzl" jdbcType="VARCHAR"/>
        <result column="gyzcz" property="gyzcz" jdbcType="VARCHAR"/>
        <result column="lrze" property="lrze" jdbcType="VARCHAR"/>
        <result column="zfzctr" property="zfzctr" jdbcType="VARCHAR"/>
        <result column="cpxssr" property="cpxssr" jdbcType="VARCHAR"/>
        <result column="zcze" property="zcze" jdbcType="DECIMAL"/>
        <result column="dnzlhds" property="dnzlhds" jdbcType="VARCHAR"/>
        <result column="nclyjxzz" property="nclyjxzz" jdbcType="VARCHAR"/>
        <result column="yzjgzj" property="yzjgzj" jdbcType="VARCHAR"/>
        <result column="tysb" property="tysb" jdbcType="VARCHAR"/>
        <result column="nhxhbzm" property="nhxhbzm" jdbcType="VARCHAR"/>
        <result column="gr" property="gr" jdbcType="VARCHAR"/>
        <result column="dmjgzj" property="dmjgzj" jdbcType="VARCHAR"/>
        <result column="sljgzj" property="sljgzj" jdbcType="VARCHAR"/>
        <result column="nyhd" property="nyhd" jdbcType="VARCHAR"/>
        <result column="nyxhrj" property="nyxhrj" jdbcType="VARCHAR"/>
        <result column="xmfjgzj" property="xmfjgzj" jdbcType="VARCHAR"/>
        <result column="ccsb" property="ccsb" jdbcType="VARCHAR"/>
        <result column="nyxhs" property="nyxhs" jdbcType="VARCHAR"/>
        <result column="zcr" property="zcr" jdbcType="VARCHAR"/>
        <result column="cfd" property="cfd" jdbcType="VARCHAR"/>
        <result column="cfj" property="cfj" jdbcType="VARCHAR"/>
        <result column="bz" property="bz" jdbcType="VARCHAR"/>
        <result column="sfba" property="sfba" jdbcType="DECIMAL"/>
        <result column="jyfw" property="jyfw" jdbcType="VARCHAR"/>
        <result column="wryjyrybcs" property="wryjyrybcs" jdbcType="DECIMAL"/>
        <result column="qycj" property="qycj" jdbcType="VARCHAR"/>
        <result column="qygszcd" property="qygszcd" jdbcType="VARCHAR"/>
        <result column="rtzt" property="rtzt" jdbcType="DECIMAL"/>
        <result column="sjccqy" property="sjccqy" jdbcType="VARCHAR"/>
        <result column="qjccqy" property="qjccqy" jdbcType="VARCHAR"/>
        <result column="sjjtmc" property="sjjtmc" jdbcType="VARCHAR"/>
        <result column="sjjtjgdm" property="sjjtjgdm" jdbcType="VARCHAR"/>
        <result column="sjjttyshxydm" property="sjjttyshxydm" jdbcType="VARCHAR"/>
        <result column="cfsl" property="cfsl" jdbcType="DECIMAL"/>
        <result column="ygsl" property="ygsl" jdbcType="DECIMAL"/>
        <result column="shi" property="shi" jdbcType="VARCHAR"/>
        <result column="shi_name" property="shiName" jdbcType="VARCHAR"/>
        <result column="xian" property="xian" jdbcType="VARCHAR"/>
        <result column="xian_name" property="xianName" jdbcType="VARCHAR"/>
        <result column="shrmc" property="shrmc" jdbcType="VARCHAR"/>
        <result column="shyj" property="shyj"/>
        <result column="shsj" property="shsj" jdbcType="DATE"/>
        <result column="dwlx" property="dwlx" jdbcType="VARCHAR"/>
        <result column="distance" property="distance" jdbcType="DECIMAL"/>
        <result column="lssgxkzfzsj" property="lssgxkzfzsj" jdbcType="DATE"/>
        <result column="tbr" property="tbr" jdbcType="VARCHAR"/>
        <result column="lxdh" property="lxdh" jdbcType="VARCHAR"/>
        <result column="sjh" property="sjh" jdbcType="VARCHAR"/>
        <result column="qyfzr" property="qyfzr" jdbcType="VARCHAR"/>
        <result column="fzrq" property="fzrq" jdbcType="DATE"/>
        <result column="sgzt" property="sgzt" jdbcType="VARCHAR"/>
        <result column="sfzdzgqy" property="sfzdzgqy" jdbcType="VARCHAR"/>
        <result column="yxqz" property="yxqz" jdbcType="DATE"/>
        <result column="qfcj" property="qfcj" jdbcType="VARCHAR"/>
        <result column="sfsb" property="sfsb" jdbcType="DECIMAL"/>
        <result column="qybm" property="qybm" jdbcType="VARCHAR"/>
        <result column="file_id" property="fileId" jdbcType="VARCHAR"/>
        <result column="frsfzh" property="frsfzh" jdbcType="VARCHAR"/>
        <result column="txcounty" property="txcounty" jdbcType="VARCHAR"/>
        <result column="zccounty" property="zccounty" jdbcType="VARCHAR"/>
        <result column="sjcr" property="sjcr" jdbcType="DECIMAL"/>
        <result column="kqcq" property="kqcq" jdbcType="VARCHAR"/>
        <result column="sykqt" property="sykqt" jdbcType="VARCHAR"/>
        <result column="qyxzfl" property="qyxzfl" jdbcType="VARCHAR"/>
        <result column="sfsc" property="sfsc" jdbcType="VARCHAR"/>
        <result column="kqsl" property="kqsl" jdbcType="DECIMAL"/>

        <result column="sfbaqy" property="sfbaqy" jdbcType="VARCHAR"/>
        <result column="sflttjqy" property="sflttjqy" jdbcType="VARCHAR"/>
        <result column="qiyeleix" property="qiyeleix" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="Base_Column_List_common">
    	tz.id, tz.tyshxydm, tz.zzjgdm, tz.qymc, tz.qylx, tz.dwdm, tz.qyjjlx, tz.qyxz, tz.djzclx, tz.gsdjzch, tz.fddbr,
    	tz.bgdh, tz.frsjh, tz.qydzyx, tz.zczb, tz.qycyrys, tz.zjyszcrs, tz.bgyrs, tz.jhyyrs, tz.yzyzgzsrs, tz.qyczhm,
    	tz.qytxdz, tz.qyyb, tz.qyzyyw, tz.qyzcsj, tz.zzxlysry, tz.qysclszypz, tz.qylsgx, tz.remark,
    	tz.qyyjjb, tz.qyjd, tz.qywd, tz.qyszqy,tz.qyzt,tz.qyccnl,tz.qyszqybh, tz.QYYJLXBH, tz.QYYJLXMC, tz.SFDLFRZG,
    	tz.XSQYGS, tz.ZCRQ, tz.SFJYSGZG, tz.LSSGXKZFZJG,tz.SGZGZBH, tz.SSLSXZGLBM, tz.ZDMJ, tz.SSZDMJ, tz.SQJGZDMJ, tz.QYGSDJJG,
    	tz.qylxr, tz.YYSR, tz.LSZE, tz.DNYJKFTR, tz.FMZL, tz.GYZCZ, tz.LRZE, tz.ZFZCTR, tz.CPXSSR, tz.ZCZE, tz.DNZLHDS,
    	tz.NCLYJXZZ, tz.YZJGZJ, tz.TYSB, tz.NHXHBZM, tz.GR, tz.DMJGZJ, tz.SLJGZJ, tz.NYHD, tz.NYXHRJ, tz.XMFJGZJ,
    	tz.CCSB, tz.NYXHS, tz.ZCR, tz.CFD, tz.CFJ, tz.BZ,tz.qyjgdm ,tz.sfba, tz.jyfw, tz.wryjyrybcs, tz.qycj,
    	tz.qygszcd, tz.rtzt, tz.sjccqy, tz.qjccqy, tz.sjjtmc, tz.sjjtjgdm, tz.sjjttyshxydm, tz.cfsl, tz.ygsl, tz.shi,
    	tz.shi_name, tz.xian, tz.xian_name,tz.shrmc,tz.shyj,tz.shsj,tz.dwlx,tz.lssgxkzfzsj,tz.tbr,tz.lxdh,tz.sjh,tz.qyfzr,
    	tz.fzrq,tz.sgzt,tz.sfzdzgqy,tz.yxqz,tz.qfcj,tz.sfsb,tz.qybm,tz.txprovince,tz.txcity,tz.zcprovince,tz.zccity,tz.shzt,tz.file_id,tz.frsfzh,
        tz.txcounty,tz.zccounty,tz.sjcr,tz.kqcq,tz.sykqt,tz.qyxzfl,tz.kqlb,tz.lx,tz.sfsc,tz.data_ver,tz.sfbaqy,tz.sflttjqy,tz.qiyeleix
    </sql>

    <!-- 根据条件查询企业信息 -->
    <select id="getCompanyList" parameterType="com.unis.base.common.vo.CompanyQueryVO" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List_common"></include>,
        (select x.pjjg
            from
            (select first 1 pj.pjjg
                from qyxypjdc pj
                where pj.ztmc = tz.qymc
                and DATE_FORMAT(pj.pjyxq
                , '%Y-%m-%d') &gt;= DATE_FORMAT(now()
                , '%Y-%m-%d')
                and DATE_FORMAT(pj.pjrq
                , '%Y-%m-%d') &lt;= DATE_FORMAT(now()
                , '%Y-%m-%d')
                and zt = '已提交'
                order by pj.pjnd desc) x) as pjjg
        from
        (
        SELECT DISTINCT(tz.id)
        from TZ_SLQY tz,TZ_QYLX q
        WHERE tz.status = 1
        <!-- 企业类型 -->
        <!-- <if test="qylxbh != null and qylxbh != ''" >
            and	q.qylxbh LIKE concat(CONCAT('%',#{qylxbh,jdbcType=VARCHAR}) ,'%')
        </if> -->
        <if test="qylxbh !=null and qylxbh !=''">
            and q.qylxbh in
            <foreach collection="qylxbh" item="item" index="index" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        and tz.id = q.qyid ) xx , tz_slqy tz
        <where>
            tz.status = 1
            and xx.id=tz.id
            and (
            1=1
            <!-- 社会统一行政编码 -->
            <if test="tyshxydm != null and tyshxydm != ''">
                and tz.tyshxydm LIKE concat(CONCAT('%',#{tyshxydm,jdbcType=VARCHAR}) ,'%')
            </if>
            <!-- 企业名称 -->
            <if test="qymc != null and qymc != ''">
                and tz.qymc LIKE concat(CONCAT('%',#{qymc,jdbcType=VARCHAR}) ,'%')
            </if>
            <if test="shzt != null and shzt != ''">
                and tz.shzt = #{shzt}
            </if>
            <!-- 企业性质 -->
            <if test="qyxz != null and qyxz != ''">
                and tz.qyxz LIKE concat(CONCAT('%',#{qyxz,jdbcType=VARCHAR}) ,'%')
            </if>
            <!-- 法定代表人 -->
            <if test="fddbr != null and fddbr != ''">
                and tz.fddbr LIKE concat(CONCAT('%',#{fddbr,jdbcType=VARCHAR}) ,'%')
            </if>
            <!-- 企业状态 -->
            <if test="qyzt != null">
                and tz.qyzt= #{qyzt,jdbcType=DECIMAL}
            </if>
            <if test="qyszqybhs !=null and qyszqybhs !=''">
                and tz.qyszqybh in
                <foreach collection="qyszqybhs" item="item" index="index" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="qyzts !=null">
                and tz.qyzt in
                <foreach collection="qyzts" item="item" index="index" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="sfbas !=null">
                and tz.sfba not in
                <foreach collection="sfbas" item="item" index="index" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <!-- 企业代码-->
            <if test="qyjgdm != null and qyjgdm != ''">
                <choose>
                    <when test="querySub != null and querySub == 1">
                        and (
                        tz.sjjtjgdm = #{qyjgdm,jdbcType=VARCHAR}
                        or
                        tz.qyjgdm = #{qyjgdm,jdbcType=VARCHAR}
                        )
                    </when>
                    <otherwise>
                        and tz.qyjgdm = #{qyjgdm,jdbcType=VARCHAR}
                    </otherwise>
                </choose>
            </if>
            <if test="sslsxzglbm !=null and sslsxzglbm !=''">
                and tz.sslsxzglbm like concat(CONCAT('',#{sslsxzglbm,jdbcType=VARCHAR}) ,'%')
            </if>
            <!-- 组织机构代码 -->
            <if test=' zzjgdm != null and zzjgdm != "" '>
                and tz.zzjgdm LIKE concat(CONCAT('%', #{zzjgdm,jdbcType=VARCHAR}), '%')
            </if>
            <!-- 是否备案 -->
            <if test='sfba != null'>
                and tz.SFBA = #{sfba,jdbcType=DECIMAL}
            </if>
            <if test="sfzdzgqy!= null and sfzdzgqy!=''">
                and tz.sfzdzgqy = #{sfzdzgqy,jdbcType=VARCHAR}
            </if>
            <!-- 是否具有收购资格 -->
            <if test='sfjysgzg != null'>
                and tz.SFJYSGZG = #{sfjysgzg,jdbcType=DECIMAL}
            </if>
            <!-- 企业主要业务 -->
            <if test='qyzyyw != null and qyzyyw != ""'>
                ${qyzyywOperator} tz.QYZYYW LIKE concat(CONCAT('%',#{qyzyyw,jdbcType=DECIMAL}), '%')
            </if>
            <if test='(areaCode !=null and areaCode!="") and (sslsxzglbm==null or sslsxzglbm=="")'>
                and (
                <trim prefixOverrides="or">
                    <if test='areaCode !=null and areaCode!=""'>
                        or zcprovince = #{areaCode,jdbcType=VARCHAR} or zccity = #{areaCode,jdbcType=VARCHAR}
                        or txprovince = #{areaCode,jdbcType=VARCHAR} or txcity = #{areaCode,jdbcType=VARCHAR}
                        or lssgcode = #{areaCode,jdbcType=VARCHAR}
                    </if>
                    <if test='sslsxzglbm !=null and sslsxzglbm!=""'>
                        or sslsxzglbm = #{sslsxzglbm,jdbcType=VARCHAR}
                    </if>
                </trim>
                )
            </if>
            )
        </where>
        ORDER BY tz.REFRESH_TIME desc
    </select>

    <!--	根据统一社会信用代码获取企业相关信息-->
    <select id="getqyxxBytyshxydm" parameterType="java.lang.String" resultMap="BaseResultMap">
    SELECT qymc, fddbr, create_date,refresh_time,zcr,
        concat((select distinct p.provin_name from usercenter.BAS_AREA p where p.provin_code= txprovince),
	    (select distinct p.county_name from usercenter.BAS_AREA p where p.county_code= txcity) ,
         (select distinct p.city_name from usercenter.BAS_AREA p where p.city_code= txcity) , qytxdz) as qytxdz
        FROM TZ_SLQY
		WHERE tyshxydm = #{kddm}
	</select>

    <!--	根据企业id修改企业状态-->
    <update id="updateQyzt" parameterType="java.util.Map">
		update TZ_SLQY
		set qyzt = #{qyzt}
		where id = #{id}
	</update>

    <!-- 新增企业信息 -->
    <insert id="insert" parameterType="com.unis.base.server.entity.TzSlqyDO">
        insert into TZ_SLQY
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="tyshxydm != null">
                tyshxydm,
            </if>
            <if test="zzjgdm != null">
                zzjgdm,
            </if>
            <if test="qymc != null">
                qymc,
            </if>
            <if test="qylx != null">
                qylx,
            </if>
            <if test="dwdm != null">
                dwdm,
            </if>
            <if test="qyjjlx != null">
                qyjjlx,
            </if>
            <if test="qyxz != null">
                qyxz,
            </if>
            <if test="djzclx != null">
                djzclx,
            </if>
            <if test="gsdjzch != null">
                gsdjzch,
            </if>
            <if test="fddbr != null">
                fddbr,
            </if>
            <if test="bgdh != null">
                bgdh,
            </if>
            <if test="frsjh != null">
                frsjh,
            </if>
            <if test="qydzyx != null">
                qydzyx,
            </if>
            <if test="zczb != null">
                zczb,
            </if>
            <if test="qycyrys != null">
                qycyrys,
            </if>
            <if test="zjyszcrs != null">
                zjyszcrs,
            </if>
            <if test="bgyrs != null">
                bgyrs,
            </if>
            <if test="jhyyrs != null">
                jhyyrs,
            </if>
            <if test="yzyzgzsrs != null">
                yzyzgzsrs,
            </if>
            <if test="qyczhm != null">
                qyczhm,
            </if>
            <if test="qytxdz != null">
                qytxdz,
            </if>
            <if test="qyyb != null">
                qyyb,
            </if>
            <if test="qyzyyw != null">
                qyzyyw,
            </if>
            <if test="qyzcsj != null">
                qyzcsj,
            </if>
            <if test="zzxlysry != null">
                zzxlysry,
            </if>
            <if test="qysclszypz != null">
                qysclszypz,
            </if>
            <if test="qylsgx != null">
                qylsgx,
            </if>
            <if test="qyyjjb != null">
                QYYJJB,
            </if>
            <if test="qyjd != null">
                QYJD,
            </if>
            <if test="qywd != null">
                QYWD,
            </if>
            <if test="qyszqy != null">
                QYSZQY,
            </if>
            <if test="creator != null">
                creator,
            </if>
            <if test="creatorCode != null">
                creator_code,
            </if>
            <if test="status != null">
                status,
            </if>
            <if test="qyccnl != null">
                qyccnl,
            </if>
            <if test="qyzt != null">
                qyzt,
            </if>
            <if test="qyszqybh != null">
                qyszqybh,
            </if>
            <if test="qyyjlxbh != null">
                QYYJLXBH,
            </if>
            <if test="qyyjlxmc != null">
                QYYJLXMC,
            </if>
            <if test="sfdlfrzg != null">
                SFDLFRZG,
            </if>
            <if test="xsqygs != null">
                XSQYGS,
            </if>
            <if test="zcrq != null">
                ZCRQ,
            </if>
            <if test="sfjysgzg != null">
                SFJYSGZG,
            </if>
            <if test="lssgxkzfzjg != null">
                LSSGXKZFZJG,
            </if>
            <if test="sgzgzbh != null">
                SGZGZBH,
            </if>
            <if test="sslsxzglbm != null">
                SSLSXZGLBM,
            </if>
            <if test="zdmj != null">
                ZDMJ,
            </if>
            <if test="sszdmj != null">
                SSZDMJ,
            </if>
            <if test="sqjgzdmj != null">
                SQJGZDMJ,
            </if>
            <if test="qygsdjjg != null">
                QYGSDJJG,
            </if>
            <if test="qylxr != null">
                QYLXR,
            </if>
            <if test="yysr !=null">
                yysr,
            </if>
            <if test="lsze !=null">
                lsze,
            </if>
            <if test="dnyjkftr != null">
                dnyjkftr,
            </if>
            <if test="fmzl != null">
                fmzl,
            </if>
            <if test="gyzcz != null">
                gyzcz,
            </if>
            <if test="lrze != null">
                lrze,
            </if>
            <if test="zfzctr != null">
                zfzctr,
            </if>
            <if test="cpxssr != null">
                cpxssr,
            </if>
            <if test="zcze !=null">
                zcze,
            </if>
            <if test="dnzlhds !=null">
                dnzlhds,
            </if>
            <if test="nclyjxzz != null">
                nclyjxzz,
            </if>
            <if test="yzjgzj != null">
                yzjgzj,
            </if>
            <if test="tysb != null">
                tysb,
            </if>
            <if test="nhxhbzm !=null">
                nhxhbzm,
            </if>
            <if test="gr !=null">
                gr,
            </if>
            <if test="dmjgzj != null">
                dmjgzj,
            </if>
            <if test="sljgzj != null">
                sljgzj,
            </if>
            <if test="nyhd !=null">
                nyhd,
            </if>
            <if test="nyxhrj !=null">
                nyxhrj,
            </if>
            <if test="xmfjgzj != null">
                xmfjgzj,
            </if>
            <if test="ccsb != null">
                ccsb,
            </if>
            <if test="nyxhs != null">
                nyxhs,
            </if>
            <if test="zcr !=null">
                zcr,
            </if>
            <if test="cfd !=null">
                cfd,
            </if>
            <if test="cfj !=null">
                cfj,
            </if>
            <if test="bz !=null">
                bz,
            </if>
            <if test="sfba !=null">
                sfba,
            </if>
            <if test="jyfw !=null">
                jyfw,
            </if>
            <if test="wryjyrybcs !=null">
                wryjyrybcs,
            </if>
            <if test="qycj !=null">
                qycj,
            </if>
            <if test="qygszcd !=null">
                qygszcd,
            </if>
            <if test="rtzt !=null">
                rtzt,
            </if>
            <if test="sjccqy !=null">
                sjccqy,
            </if>
            <if test="qjccqy !=null">
                qjccqy,
            </if>
            <if test="sjjtmc !=null">
                sjjtmc,
            </if>
            <if test="sjjtjgdm !=null">
                sjjtjgdm,
            </if>
            <if test="sjjttyshxydm !=null">
                sjjttyshxydm,
            </if>
            <if test="cfsl !=null">
                cfsl,
            </if>
            <if test="ygsl !=null">
                ygsl,
            </if>
            <if test="shi !=null">
                shi,
            </if>
            <if test="shiName !=null">
                shi_name,
            </if>
            <if test="xian !=null">
                xian,
            </if>
            <if test="xianName !=null">
                xian_name,
            </if>
            <if test="qyjgdm !=null">
                qyjgdm,
            </if>
            <if test="dwlx !=null">
                dwlx,
            </if>
            <if test="sfzdzgqy !=null">
                sfzdzgqy,
            </if>
            <if test="qybm !=null">
                qybm,
            </if>
            <if test="txprovince !=null">
                txprovince,
            </if>
            <if test="txcity !=null">
                txcity,
            </if>
            <if test="zcprovince !=null">
                zcprovince,
            </if>
            <if test="zccity !=null">
                zccity,
            </if>
            <if test="shzt !=null">
                shzt,
            </if>
            <if test="remark !=null">
                remark,
            </if>
            <if test="frsfzh !=null and frsfzh !=''">
                frsfzh,
            </if>
            <if test="txcounty !=null and txcounty !=''">
                txcounty,
            </if>
            <if test="zccounty !=null and zccounty !=''">
                zccounty,
            </if>
            <if test="sjcr !=null and sjcr !=''">
                sjcr,
            </if>
            <if test="kqcq !=null and kqcq !=''">
                kqcq,
            </if>
            <if test="sykqt !=null and sykqt !=''">
                sykqt,
            </if>
            <if test="qyxzfl !=null and qyxzfl !=''">
                qyxzfl,
            </if>
            <if test="createDate !=null">
                create_date,
            </if>
            <if test="refreshTime !=null">
                refresh_time,
            </if>
            <if test="kqlb !=null and kqlb !=''">
                kqlb,
            </if>
            <if test="lx !=null and lx !=''">
                lx,
            </if>
            <if test="sfbaqy !=null and sfbaqy !=''">
                sfbaqy,
            </if>
            <if test="sflttjqy !=null and sflttjqy !=''">
                sflttjqy,
            </if>
            <if test="qiyeleix !=null and qiyeleix !=''">
                qiyeleix,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=VARCHAR},
            </if>
            <if test="tyshxydm != null">
                #{tyshxydm,jdbcType=VARCHAR},
            </if>
            <if test="zzjgdm != null">
                #{zzjgdm,jdbcType=VARCHAR},
            </if>
            <if test="qymc != null">
                #{qymc,jdbcType=VARCHAR},
            </if>
            <if test="qylx != null">
                #{qylx,jdbcType=VARCHAR},
            </if>
            <if test="dwdm != null">
                #{dwdm,jdbcType=VARCHAR},
            </if>
            <if test="qyjjlx != null">
                #{qyjjlx,jdbcType=VARCHAR},
            </if>
            <if test="qyxz != null">
                #{qyxz,jdbcType=VARCHAR},
            </if>
            <if test="djzclx != null">
                #{djzclx,jdbcType=VARCHAR},
            </if>
            <if test="gsdjzch != null">
                #{gsdjzch,jdbcType=VARCHAR},
            </if>
            <if test="fddbr != null">
                #{fddbr,jdbcType=VARCHAR},
            </if>
            <if test="bgdh != null">
                #{bgdh,jdbcType=VARCHAR},
            </if>
            <if test="frsjh != null">
                #{frsjh,jdbcType=VARCHAR},
            </if>
            <if test="qydzyx != null">
                #{qydzyx,jdbcType=VARCHAR},
            </if>
            <if test="zczb != null">
                #{zczb,jdbcType=VARCHAR},
            </if>
            <if test="qycyrys != null">
                #{qycyrys,jdbcType=VARCHAR},
            </if>
            <if test="zjyszcrs != null">
                #{zjyszcrs,jdbcType=VARCHAR},
            </if>
            <if test="bgyrs != null">
                #{bgyrs,jdbcType=VARCHAR},
            </if>
            <if test="jhyyrs != null">
                #{jhyyrs,jdbcType=VARCHAR},
            </if>
            <if test="yzyzgzsrs != null">
                #{yzyzgzsrs,jdbcType=VARCHAR},
            </if>
            <if test="qyczhm != null">
                #{qyczhm,jdbcType=VARCHAR},
            </if>
            <if test="qytxdz != null">
                #{qytxdz,jdbcType=VARCHAR},
            </if>
            <if test="qyyb != null">
                #{qyyb,jdbcType=VARCHAR},
            </if>
            <if test="qyzyyw != null">
                #{qyzyyw,jdbcType=VARCHAR},
            </if>
            <if test="qyzcsj != null">
                #{qyzcsj,jdbcType=VARCHAR},
            </if>
            <if test="zzxlysry != null">
                #{zzxlysry,jdbcType=VARCHAR},
            </if>
            <if test="qysclszypz != null">
                #{qysclszypz,jdbcType=VARCHAR},
            </if>
            <if test="qylsgx != null">
                #{qylsgx,jdbcType=VARCHAR},
            </if>
            <if test="qyyjjb != null">
                #{qyyjjb,jdbcType=VARCHAR},
            </if>
            <if test="qyjd != null">
                #{qyjd,jdbcType=VARCHAR},
            </if>
            <if test="qywd != null">
                #{qywd,jdbcType=VARCHAR},
            </if>
            <if test="qyszqy != null">
                #{qyszqy,jdbcType=VARCHAR},
            </if>
            <if test="creator != null">
                #{creator,jdbcType=VARCHAR},
            </if>
            <if test="creatorCode != null">
                #{creatorCode,jdbcType=VARCHAR},
            </if>
            <if test="status != null">
                #{status,jdbcType=VARCHAR},
            </if>
            <if test="qyccnl != null">
                #{qyccnl,jdbcType=VARCHAR},
            </if>
            <if test="qyzt != null">
                #{qyzt,jdbcType=DECIMAL},
            </if>
            <if test="qyszqybh != null">
                #{qyszqybh,jdbcType=VARCHAR},
            </if>
            <if test="qyyjlxbh != null">
                #{qyyjlxbh,jdbcType=VARCHAR},
            </if>
            <if test="qyyjlxmc != null">
                #{qyyjlxmc,jdbcType=VARCHAR},
            </if>
            <if test="sfdlfrzg != null">
                #{sfdlfrzg,jdbcType=DECIMAL},
            </if>
            <if test="xsqygs != null">
                #{xsqygs,jdbcType=DECIMAL},
            </if>
            <if test="zcrq != null">
                #{zcrq,jdbcType=DATE},
            </if>
            <if test="sfjysgzg != null">
                #{sfjysgzg,jdbcType=DECIMAL},
            </if>
            <if test="lssgxkzfzjg != null">
                #{lssgxkzfzjg,jdbcType=VARCHAR},
            </if>
            <if test="sgzgzbh != null">
                #{sgzgzbh,jdbcType=VARCHAR},
            </if>
            <if test="sslsxzglbm != null">
                #{sslsxzglbm,jdbcType=VARCHAR},
            </if>
            <if test="zdmj != null">
                #{zdmj,jdbcType=DECIMAL},
            </if>
            <if test="sszdmj != null">
                #{sszdmj,jdbcType=DECIMAL},
            </if>
            <if test="sqjgzdmj != null">
                #{sqjgzdmj,jdbcType=DATE},
            </if>
            <if test="qygsdjjg != null">
                #{qygsdjjg,jdbcType=VARCHAR},
            </if>
            <if test="qylxr != null">
                #{qylxr,jdbcType=VARCHAR},
            </if>
            <if test="yysr !=null">
                #{yysr,jdbcType=VARCHAR},
            </if>
            <if test="lsze !=null">
                #{lsze,jdbcType=VARCHAR},
            </if>
            <if test="dnyjkftr != null">
                #{dnyjkftr,jdbcType=VARCHAR},
            </if>
            <if test="fmzl != null">
                #{fmzl,jdbcType=VARCHAR},
            </if>
            <if test="gyzcz != null">
                #{gyzcz,jdbcType=VARCHAR},
            </if>
            <if test="lrze != null">
                #{lrze,jdbcType=VARCHAR},
            </if>
            <if test="zfzctr != null">
                #{zfzctr,jdbcType=VARCHAR},
            </if>
            <if test="cpxssr != null">
                #{cpxssr,jdbcType=VARCHAR},
            </if>
            <if test="zcze !=null">
                #{zcze},
            </if>
            <if test="dnzlhds !=null">
                #{dnzlhds,jdbcType=VARCHAR},
            </if>
            <if test="nclyjxzz != null">
                #{nclyjxzz,jdbcType=VARCHAR},
            </if>
            <if test="yzjgzj != null">
                #{yzjgzj,jdbcType=VARCHAR},
            </if>
            <if test="tysb != null">
                #{tysb,jdbcType=VARCHAR},
            </if>
            <if test="nhxhbzm !=null">
                #{nhxhbzm,jdbcType=VARCHAR},
            </if>
            <if test="gr !=null">
                #{gr,jdbcType=VARCHAR},
            </if>
            <if test="dmjgzj != null">
                #{dmjgzj,jdbcType=VARCHAR},
            </if>
            <if test="sljgzj != null">
                #{sljgzj,jdbcType=VARCHAR},
            </if>
            <if test="nyhd !=null">
                #{nyhd,jdbcType=VARCHAR},
            </if>
            <if test="nyxhrj !=null">
                #{nyxhrj,jdbcType=VARCHAR},
            </if>
            <if test="xmfjgzj != null">
                #{xmfjgzj,jdbcType=VARCHAR},
            </if>
            <if test="ccsb != null">
                #{ccsb,jdbcType=VARCHAR},
            </if>
            <if test="nyxhs != null">
                #{nyxhs,jdbcType=VARCHAR},
            </if>
            <if test="zcr !=null">
                #{zcr,jdbcType=VARCHAR},
            </if>
            <if test="cfd !=null">
                #{cfd,jdbcType=VARCHAR},
            </if>
            <if test="cfj !=null">
                #{cfj,jdbcType=VARCHAR},
            </if>
            <if test="bz !=null">
                #{bz,jdbcType=VARCHAR},
            </if>
            <if test="sfba !=null">
                #{sfba,jdbcType=DECIMAL},
            </if>
            <if test="jyfw !=null">
                #{jyfw,jdbcType=VARCHAR},
            </if>
            <if test="wryjyrybcs !=null">
                #{wryjyrybcs,jdbcType=DECIMAL},
            </if>
            <if test="qycj !=null">
                #{qycj,jdbcType=VARCHAR},
            </if>
            <if test="qygszcd !=null">
                #{qygszcd,jdbcType=VARCHAR},
            </if>
            <if test="rtzt !=null">
                #{rtzt,jdbcType=DECIMAL},
            </if>
            <if test="sjccqy !=null">
                #{sjccqy,jdbcType=VARCHAR},
            </if>
            <if test="qjccqy !=null">
                #{qjccqy,jdbcType=VARCHAR},
            </if>
            <if test="sjjtmc !=null">
                #{sjjtmc,jdbcType=VARCHAR},
            </if>
            <if test="sjjtjgdm !=null">
                #{sjjtjgdm,jdbcType=VARCHAR},
            </if>
            <if test="sjjttyshxydm !=null">
                #{sjjttyshxydm,jdbcType=VARCHAR},
            </if>
            <if test="cfsl !=null">
                #{cfsl,jdbcType=DECIMAL},
            </if>
            <if test="ygsl !=null">
                #{ygsl,jdbcType=DECIMAL},
            </if>
            <if test="shi !=null">
                #{shi,jdbcType=VARCHAR},
            </if>
            <if test="shiName !=null">
                #{shiName,jdbcType=VARCHAR},
            </if>
            <if test="xian !=null">
                #{xian,jdbcType=VARCHAR},
            </if>
            <if test="xianName !=null">
                #{xianName,jdbcType=VARCHAR},
            </if>
            <if test="qyjgdm !=null">
                #{qyjgdm,jdbcType=VARCHAR},
            </if>
            <if test="dwlx !=null">
                #{dwlx,jdbcType=VARCHAR},
            </if>
            <if test="sfzdzgqy !=null">
                #{sfzdzgqy,jdbcType=VARCHAR},
            </if>
            <if test="qybm !=null">
                #{qybm,jdbcType=VARCHAR},
            </if>
            <if test="txprovince !=null">
                #{txprovince,jdbcType=VARCHAR},
            </if>
            <if test="txcity !=null">
                #{txcity,jdbcType=VARCHAR},
            </if>
            <if test="zcprovince !=null">
                #{zcprovince,jdbcType=VARCHAR},
            </if>
            <if test="zccity !=null">
                #{zccity,jdbcType=VARCHAR},
            </if>
            <if test="shzt !=null">
                #{shzt},
            </if>
            <if test="remark !=null">
                #{remark},
            </if>
            <if test="frsfzh !=null and frsfzh !=''">
                #{frsfzh},
            </if>
            <if test="txcounty !=null and txcounty !=''">
                #{txcounty,jdbcType=VARCHAR},
            </if>
            <if test="zccounty !=null and zccounty !=''">
                #{zccounty,jdbcType=VARCHAR},
            </if>
            <if test="sjcr !=null and sjcr !=''">
                #{sjcr,jdbcType=DECIMAL},
            </if>
            <if test="kqcq !=null and kqcq !=''">
                #{kqcq,jdbcType=VARCHAR},
            </if>
            <if test="sykqt !=null and sykqt !=''">
                #{sykqt,jdbcType=VARCHAR},
            </if>
            <if test="qyxzfl !=null and qyxzfl !=''">
                #{qyxzfl,jdbcType=VARCHAR},
            </if>
            <if test="createDate !=null">
                #{createDate,jdbcType=TIMESTAMP},
            </if>
            <if test="refreshTime !=null">
                #{refreshTime,jdbcType=TIMESTAMP},
            </if>
            <if test="kqlb !=null">
                #{kqlb,jdbcType=VARCHAR},
            </if>
            <if test="lx !=null and lx !=''">
                #{lx,jdbcType=VARCHAR},
            </if>
            <if test="sfbaqy !=null and sfbaqy !=''">
                #{sfbaqy,jdbcType=VARCHAR},
            </if>
            <if test="sflttjqy !=null and sflttjqy !=''">
                #{sflttjqy,jdbcType=VARCHAR},
            </if>
            <if test="qiyeleix !=null and qiyeleix !=''">
                #{qiyeleix,jdbcType=VARCHAR},
            </if>
        </trim>
    </insert>

    <!-- 更新企业信息 -->
    <update id="update" parameterType="com.unis.base.server.entity.TzSlqyDO">
        update TZ_SLQY
        <set>
            <if test="zzjgdm != null">
                zzjgdm = #{zzjgdm,jdbcType=VARCHAR},
            </if>
            <if test="qymc != null">
                qymc = #{qymc,jdbcType=VARCHAR},
            </if>
            <if test="qylx != null">
                qylx = #{qylx,jdbcType=VARCHAR},
            </if>
            <if test="dwdm != null">
                dwdm = #{dwdm,jdbcType=VARCHAR},
            </if>
            <if test="qyjjlx != null">
                qyjjlx = #{qyjjlx,jdbcType=VARCHAR},
            </if>
            <if test="qyxz != null">
                qyxz = #{qyxz,jdbcType=VARCHAR},
            </if>
            <if test="djzclx != null">
                djzclx = #{djzclx,jdbcType=VARCHAR},
            </if>
            <if test="gsdjzch != null">
                gsdjzch = #{gsdjzch,jdbcType=VARCHAR},
            </if>
            <if test="fddbr != null">
                fddbr = #{fddbr,jdbcType=VARCHAR},
            </if>
            <if test="bgdh != null">
                bgdh = #{bgdh,jdbcType=VARCHAR},
            </if>
            <if test="frsjh != null">
                frsjh = #{frsjh,jdbcType=VARCHAR},
            </if>
            <if test="qydzyx != null">
                qydzyx = #{qydzyx,jdbcType=VARCHAR},
            </if>
            <if test="zczb != null">
                zczb = #{zczb,jdbcType=VARCHAR},
            </if>
            <if test="qycyrys != null">
                qycyrys = #{qycyrys,jdbcType=VARCHAR},
            </if>
            <if test="zjyszcrs != null">
                zjyszcrs = #{zjyszcrs,jdbcType=VARCHAR},
            </if>
            <if test="bgyrs != null">
                bgyrs = #{bgyrs,jdbcType=VARCHAR},
            </if>
            <if test="jhyyrs != null">
                jhyyrs = #{jhyyrs,jdbcType=VARCHAR},
            </if>
            <if test="yzyzgzsrs != null">
                yzyzgzsrs = #{yzyzgzsrs,jdbcType=VARCHAR},
            </if>
            <if test="qyczhm != null">
                qyczhm = #{qyczhm,jdbcType=VARCHAR},
            </if>
            <if test="qytxdz != null">
                qytxdz = #{qytxdz,jdbcType=VARCHAR},
            </if>
            <if test="qyyb != null">
                qyyb = #{qyyb,jdbcType=VARCHAR},
            </if>
            <if test="qyzyyw != null">
                qyzyyw = #{qyzyyw,jdbcType=VARCHAR},
            </if>
            <if test="qyzcsj != null">
                qyzcsj = #{qyzcsj,jdbcType=VARCHAR},
            </if>
            <if test="zzxlysry != null">
                zzxlysry = #{zzxlysry,jdbcType=VARCHAR},
            </if>
            <if test="qysclszypz != null">
                qysclszypz = #{qysclszypz,jdbcType=VARCHAR},
            </if>
            <if test="qylsgx != null">
                qylsgx = #{qylsgx,jdbcType=VARCHAR},
            </if>
            <if test="qyyjjb != null">
                qyyjjb = #{qyyjjb,jdbcType=VARCHAR},
            </if>
            <if test="qyjd != null">
                qyjd = #{qyjd,jdbcType=VARCHAR},
            </if>
            <if test="qywd != null">
                qywd = #{qywd,jdbcType=VARCHAR},
            </if>
            <if test="qyszqy != null">
                qyszqy = #{qyszqy,jdbcType=VARCHAR},
            </if>
            <if test="refresher != null">
                refresher = #{refresher,jdbcType=VARCHAR},
            </if>
            <if test="refresherCode != null">
                refresher_code = #{refresherCode,jdbcType=VARCHAR},
            </if>
            <if test="status != null">
                status = #{status,jdbcType=VARCHAR},
            </if>
            <if test="qyccnl != null">
                qyccnl = #{qyccnl,jdbcType=VARCHAR},
            </if>
            <if test="qyzt != null">
                qyzt = #{qyzt,jdbcType=DECIMAL},
            </if>
            <if test="qyszqybh != null">
                qyszqybh = #{qyszqybh,jdbcType=VARCHAR},
            </if>
            <if test="qyyjlxbh != null">
                QYYJLXBH = #{qyyjlxbh,jdbcType=VARCHAR},
            </if>
            <if test="qyyjlxmc != null">
                QYYJLXMC = #{qyyjlxmc,jdbcType=VARCHAR},
            </if>
            <if test="sfdlfrzg != null">
                SFDLFRZG = #{sfdlfrzg,jdbcType=DECIMAL},
            </if>
            <if test="xsqygs != null">
                XSQYGS = #{xsqygs,jdbcType=DECIMAL},
            </if>
            <if test="zcrq != null">
                ZCRQ = #{zcrq,jdbcType=DATE},
            </if>
            <if test="sfjysgzg != null">
                SFJYSGZG = #{sfjysgzg,jdbcType=DECIMAL},
            </if>
            <if test="lssgxkzfzjg != null">
                LSSGXKZFZJG = #{lssgxkzfzjg,jdbcType=VARCHAR},
            </if>
            <if test="sgzgzbh != null">
                SGZGZBH = #{sgzgzbh,jdbcType=VARCHAR},
            </if>
            <if test="sslsxzglbm != null">
                SSLSXZGLBM = #{sslsxzglbm,jdbcType=VARCHAR},
            </if>
            <if test="zdmj != null">
                ZDMJ = #{zdmj,jdbcType=DECIMAL},
            </if>
            <if test="sszdmj != null">
                SSZDMJ = #{sszdmj,jdbcType=DECIMAL},
            </if>
            <if test="sqjgzdmj != null">
                SQJGZDMJ = #{sqjgzdmj,jdbcType=DATE},
            </if>
            <if test="qygsdjjg != null">
                QYGSDJJG = #{qygsdjjg,jdbcType=VARCHAR},
            </if>
            <if test="qylxr != null">
                QYLXR = #{qylxr,jdbcType=VARCHAR},
            </if>
            <if test="yysr !=null">
                YYSR = #{yysr,jdbcType=VARCHAR},
            </if>
            <if test="lsze !=null">
                LSZE = #{lsze,jdbcType=VARCHAR},
            </if>
            <if test="dnyjkftr != null">
                DNYJKFTR = #{dnyjkftr,jdbcType=VARCHAR},
            </if>
            <if test="fmzl != null">
                FMZL = #{fmzl,jdbcType=VARCHAR},
            </if>
            <if test="gyzcz != null">
                GYZCZ = #{gyzcz,jdbcType=VARCHAR},
            </if>
            <if test="lrze != null">
                LRZE = #{lrze,jdbcType=VARCHAR},
            </if>
            <if test="zfzctr != null">
                ZFZCTR = #{zfzctr,jdbcType=VARCHAR},
            </if>
            <if test="cpxssr != null">
                CPXSSR = #{cpxssr,jdbcType=VARCHAR},
            </if>
            <if test="zcze !=null">
                ZCZE = #{zcze},
            </if>
            <if test="dnzlhds !=null">
                DNZLHDS = #{dnzlhds,jdbcType=VARCHAR},
            </if>
            <if test="nclyjxzz != null">
                NCLYJXZZ = #{nclyjxzz,jdbcType=VARCHAR},
            </if>
            <if test="yzjgzj != null">
                YZJGZJ = #{yzjgzj,jdbcType=VARCHAR},
            </if>
            <if test="tysb != null">
                TYSB = #{tysb,jdbcType=VARCHAR},
            </if>
            <if test="nhxhbzm !=null">
                NHXHBZM = #{nhxhbzm,jdbcType=VARCHAR},
            </if>
            <if test="gr !=null">
                GR = #{gr,jdbcType=VARCHAR},
            </if>
            <if test="dmjgzj != null">
                DMJGZJ = #{dmjgzj,jdbcType=VARCHAR},
            </if>
            <if test="sljgzj != null">
                SLJGZJ = #{sljgzj,jdbcType=VARCHAR},
            </if>
            <if test="nyhd !=null">
                NYHD = #{nyhd,jdbcType=VARCHAR},
            </if>
            <if test="nyxhrj !=null">
                NYXHRJ = #{nyxhrj,jdbcType=VARCHAR},
            </if>
            <if test="xmfjgzj != null">
                XMFJGZJ = #{xmfjgzj,jdbcType=VARCHAR},
            </if>
            <if test="ccsb != null">
                CCSB = #{ccsb,jdbcType=VARCHAR},
            </if>
            <if test="nyxhs != null">
                NYXHS = #{nyxhs,jdbcType=VARCHAR},
            </if>
            <if test="zcr !=null">
                ZCR = #{zcr,jdbcType=VARCHAR},
            </if>
            <if test="cfd !=null">
                CFD = #{cfd,jdbcType=VARCHAR},
            </if>
            <if test="cfj !=null">
                CFJ = #{cfj,jdbcType=VARCHAR},
            </if>
            <if test="bz !=null">
                BZ = #{bz,jdbcType=VARCHAR},
            </if>
            <if test="sfba !=null">
                SFBA = #{sfba,jdbcType=DECIMAL},
            </if>
            <if test="jyfw !=null">
                JYFW = #{jyfw,jdbcType=VARCHAR},
            </if>
            <if test="wryjyrybcs !=null">
                WRYJYRYBCS = #{wryjyrybcs,jdbcType=DECIMAL},
            </if>
            <if test="qycj !=null">
                QYCJ = #{qycj,jdbcType=VARCHAR},
            </if>
            <if test="qygszcd !=null">
                QYGSZCD = #{qygszcd,jdbcType=VARCHAR},
            </if>
            <if test="rtzt !=null">
                RTZT = #{rtzt,jdbcType=DECIMAL},
            </if>
            <if test="sjccqy !=null">
                SJCCQY = #{sjccqy,jdbcType=VARCHAR},
            </if>
            <if test="qjccqy !=null">
                QJCCQY = #{qjccqy,jdbcType=VARCHAR},
            </if>
            <if test="sjjtmc !=null">
                SJJTMC = #{sjjtmc,jdbcType=VARCHAR},
            </if>
            <if test="sjjtjgdm !=null">
                SJJTJGDM = #{sjjtjgdm,jdbcType=VARCHAR},
            </if>
            <if test="sjjttyshxydm !=null">
                SJJTTYSHXYDM = #{sjjttyshxydm,jdbcType=VARCHAR},
            </if>
            <if test="cfsl !=null">
                CFSL = #{cfsl,jdbcType=DECIMAL},
            </if>
            <if test="ygsl !=null">
                YGSL = #{ygsl,jdbcType=DECIMAL},
            </if>
            <if test="shi !=null">
                SHI = #{shi,jdbcType=VARCHAR},
            </if>
            <if test="shiName !=null">
                SHI_NAME = #{shiName,jdbcType=VARCHAR},
            </if>
            <if test="xian !=null">
                XIAN = #{xian,jdbcType=VARCHAR},
            </if>
            <if test="xianName !=null">
                XIAN_NAME = #{xianName,jdbcType=VARCHAR},
            </if>
            <if test=" shrmc != null">
                shrmc = #{ shrmc, jdbcType=DECIMAL},
            </if>
            <if test=" shyj != null">
                shyj = #{ shyj, jdbcType=DECIMAL},
            </if>
            <if test=" shsj != null">
                shsj = #{ shsj, jdbcType=DECIMAL},
            </if>
            <if test=" dwlx != null">
                dwlx = #{ dwlx, jdbcType=VARCHAR},
            </if>
            <if test="sfzdzgqy !=null">
                sfzdzgqy = #{sfzdzgqy,jdbcType=VARCHAR},
            </if>
            <if test="txprovince !=null">
                txprovince = #{txprovince,jdbcType=VARCHAR},
            </if>
            <if test="txcity !=null">
                txcity = #{txcity,jdbcType=VARCHAR},
            </if>
            <if test="zcprovince !=null">
                zcprovince = #{zcprovince,jdbcType=VARCHAR},
            </if>
            <if test="zccity !=null">
                zccity = #{zccity,jdbcType=VARCHAR},
            </if>
            <if test=" remark != null">
                remark = #{ remark, jdbcType=VARCHAR},
            </if>
            <if test=" fileId != null">
                file_id = #{ fileId, jdbcType=VARCHAR},
            </if>
            <if test="frsfzh !=null and frsfzh !=''">
                frsfzh = #{frsfzh, jdbcType=VARCHAR},
            </if>
            <if test="txcounty !=null and txcounty !=''">
                txcounty = #{txcounty,jdbcType=VARCHAR},
            </if>
            <if test="zccounty !=null and zccounty !=''">
                zccounty = #{zccounty,jdbcType=VARCHAR},
            </if>
            <if test="sjcr !=null and sjcr !=''">
                sjcr = #{sjcr,jdbcType=DECIMAL},
            </if>
            <if test="kqcq !=null and kqcq !=''">
                kqcq = #{kqcq,jdbcType=VARCHAR},
            </if>
            <if test="sykqt !=null and sykqt !=''">
                sykqt = #{sykqt,jdbcType=VARCHAR},
            </if>
            <if test="qyxzfl !=null and qyxzfl !=''">
                qyxzfl = #{qyxzfl,jdbcType=VARCHAR},
            </if>
            <if test="refreshTime !=null">
                refresh_time = #{refreshTime,jdbcType=TIMESTAMP},
            </if>
            <if test="kqlb !=null">
                kqlb = #{kqlb,jdbcType=VARCHAR},
            </if>
            <if test="lx !=null and lx !=''">
                lx = #{lx,jdbcType=VARCHAR},
            </if>
            <if test="dataVer != null and dataVer !=''">
                data_ver = #{dataVer, jdbcType=INTEGER},
            </if>
            <if test="sfbaqy != null and sfbaqy !=''">
                sfbaqy = #{sfbaqy, jdbcType=VARCHAR},
            </if>
            <if test="sflttjqy != null and sflttjqy !=''">
                sflttjqy = #{sflttjqy, jdbcType=VARCHAR},
            </if>
            <if test="qiyeleix != null and qiyeleix !=''">
                qiyeleix = #{qiyeleix, jdbcType=VARCHAR},
            </if>
        </set>
        <where>
            tyshxydm = #{tyshxydm,jdbcType=VARCHAR}
        </where>
    </update>
    <select id="getCompanyBytyshxydm" parameterType="java.lang.String" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List_common"></include>
        ,(select ifnull(count(0),0) from base.d_kdxxsjy where tyshxydm=tz.tyshxydm and status=1) as kqsl
        ,(select ifnull(count(distinct(gfcfdm)),0) from base.d_cfxxsjy where tyshxydm=tz.tyshxydm and status=1 and sfba=5) as cfsl
        ,(select ifnull(count(0),0) from base.d_ygxxsjy where tyshxydm=tz.tyshxydm and status=1 and sfba=5 ) as ygsl
        from
        TZ_SLQY tz
        <where>
            tz.tyshxydm = #{tyshxydm,jdbcType=VARCHAR}
            and tz.status=1
        </where>
    </select>

    <select id="selectMaxId" resultType="java.lang.Integer">
  	    SELECT MAX(ID) AS ID FROM TZ_SLQY
--   	    SELECT MAX(CAST(ID AS SIGNED)) AS ID FROM TZ_SLQY
  </select>

    <select id="selectByEntity" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List_common"></include>
        from
        TZ_SLQY tz
        <where>
            <if test='tyshxydm!=null and tyshxydm!=""'>
                and tz.tyshxydm = #{tyshxydm,jdbcType=VARCHAR}
            </if>
            <if test='qymc!=null and qymc!=""'>
                and tz.qymc like CONCAT('%', CONCAT(#{qymc,jdbcType=VARCHAR}, '%'))
            </if>
            and tz.status=1
        </where>
    </select>

    <select id="selectById" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List_common"></include>
        from
        TZ_SLQY tz
        <where>
            <if test='tyshxydm!=null and tyshxydm!=""'>
                and tz.tyshxydm = #{tyshxydm,jdbcType=VARCHAR}
            </if>
            and tz.status=1
        </where>
    </select>


    <select id="getSlqy" parameterType="java.lang.String" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List_common"></include>
        from
        TZ_SLQY tz
        <where>
            tz.qyjgdm = #{qyjgdm,jdbcType=VARCHAR}
            and tz.status=1
        </where>
    </select>

    <!--	在企业表中添加QYJGDM-->
    <update id="updateQyjg" parameterType="com.unis.base.common.vo.TzQyjgVO">
		UPDATE TZ_SLQY
		SET qyjgdm = #{qyjgdm}
		WHERE tyshxydm = #{tyshxydm}
	</update>

    <!--	更改备案状态-->
    <update id="updateFilingStatus" parameterType="com.unis.base.common.vo.CompanyVO">
		UPDATE TZ_SLQY
		SET SFBA = #{sfba,jdbcType=DECIMAL}
		WHERE id = #{id,jdbcType=DECIMAL}
	</update>

    <select id="getQyjgDm" resultType="java.lang.Integer">
        SELECT
        id
        from
        TZ_SLQY
        <where>
            tyshxydm=#{tyshxydm,jdbcType=VARCHAR}
            AND
            status = 1
        </where>

    </select>

    <select id="selectMaxIdFormQyjg" resultType="java.lang.Integer">
  	select max(id)
    from TZ_QYJG
  </select>

    <select id="selectQyjg" resultType="com.unis.base.common.vo.TzQyjgVO">
        SELECT * FROM TZ_QYJG  WHERE status ＝１
    </select>

    <select id="selectKdxx" resultType="com.unis.base.common.vo.DKdxxsjyVO">
         SELECT b.*,a.qyjgdm FROM  tz_qyjg a join D_KDXXSJY b on a.tyshxydm=b.tyshxydm WHERE a.status=1
    </select>

    <!-- 新增企业信息 -->
    <insert id="insertQyjg" parameterType="com.unis.base.server.entity.TzQyjgDO">
        insert into TZ_QYJG
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="tyshxydm != null">
                tyshxydm,
            </if>
            <if test="qyjgdm != null">
                qyjgdm,
            </if>
            <if test="status != null">
                status,
            </if>
            <if test="creator != null">
                creator,
            </if>
            <if test="creatorCode != null">
                creator_code,
            </if>
            <if test="refresher != null">
                refresher,
            </if>
            <if test="refresherCode != null">
                refresher_code,
            </if>
            <if test="remark != null">
                remark,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=VARCHAR},
            </if>
            <if test="tyshxydm != null">
                #{tyshxydm,jdbcType=VARCHAR},
            </if>
            <if test="qyjgdm != null">
                #{qyjgdm,jdbcType=VARCHAR},
            </if>
            <if test="status != null">
                #{status,jdbcType=VARCHAR},
            </if>
            <if test="creator != null">
                #{creator,jdbcType=VARCHAR},
            </if>
            <if test="creatorCode != null">
                #{creatorCode,jdbcType=VARCHAR},
            </if>
            <if test="refresher != null">
                #{refresher,jdbcType=VARCHAR},
            </if>
            <if test="refresherCode != null">
                #{refresherCode,jdbcType=VARCHAR},
            </if>
            <if test="remark != null">
                #{remark,jdbcType=VARCHAR},
            </if>
        </trim>
    </insert>

    <!-- 根据条件查询企业信息 -->
    <select id="randomCompany" parameterType="com.unis.base.common.vo.RandomCompanyQuery" resultMap="BaseResultMap">
        SELECT
        tz.id, tz.tyshxydm, tz.zzjgdm,tz.qymc,tz.qyjgdm, tz.QYTXDZ, tz.ZZJGDM, tz.FDDBR, tz.BGDH
        from
        <!-- (SELECT DISTINCT(tz.id) from TZ_SLQY tz,TZ_QYLX q WHERE tz.status = 1 and tz.id = q.qyid ) xx ,-->
        tz_slqy tz
        <where>
            tz.status = 1
           <!-- and xx.id=tz.id-->
            <!--bjqyxzfs   0单一   1组合-->
            <if test="bjqyxzfs == 0">
                and (
                <trim prefixOverrides="and |or ">
                    <if test="qylxList !=null and qylxList.length>0">
                        <trim prefixOverrides="or">
                            <foreach collection="qylxList" item="item" index="index" separator=" ">
                                or tz.qyzyyw like concat(CONCAT('%',#{item}) ,'%')
                            </foreach>
                        </trim>
                    </if>
                    <if test="sfjysgzg !=null">
                        or sfjysgzg = #{sfjysgzg,jdbcType=VARCHAR}
                    </if>
                    <if test="sfzdzgqy !=null">
                        or sfzdzgqy = #{sfzdzgqy,jdbcType=VARCHAR}
                    </if>
                    <if test="rtzt !=null">
                        or rtzt = #{rtzt,jdbcType=VARCHAR}
                    </if>
                </trim>
                )
                <if test="orgId != null and orgId != ''">
                    <if test="(qylxList !=null and qylxList.length >0 or sfzdzgqy !=null or rtzt !=null) and sfjysgzg !=null">
                        and (tz.qyjgdm LIKE concat(CONCAT('%',#{orgId,jdbcType=VARCHAR}) ,'%')
                        or tz.lssgxkzfzjg LIKE concat(CONCAT('%',#{orgId,jdbcType=VARCHAR}) ,'%') )
                    </if>
                    <if test="((qylxList ==null or qylxList.length ==0) and sfzdzgqy ==null and rtzt ==null) and sfjysgzg !=null">
                        and tz.lssgxkzfzjg LIKE concat(CONCAT('%',#{orgId,jdbcType=VARCHAR}) ,'%')
                    </if>
                    <if test="(qylxList !=null and qylxList.length >0 or sfzdzgqy !=null or rtzt !=null) and sfjysgzg ==null">
                        and tz.qyjgdm LIKE concat(CONCAT('%',#{orgId,jdbcType=VARCHAR}) ,'%')
                    </if>
                </if>
            </if>
            <if test="bjqyxzfs == 1">
                <if test="qylxList !=null and qylxList.length>0">
                    and (
                    <trim prefixOverrides="or">
                        <foreach collection="qylxList" item="item" index="index"  separator=" ">
                            or tz.qyzyyw like  concat(CONCAT('%',#{item}) ,'%')
                        </foreach>
                    </trim>
                    )
                </if>
                <if test="sfjysgzg !=null">
                    and sfjysgzg = #{sfjysgzg,jdbcType=VARCHAR}
                </if>
                <if test="orgId != null and orgId != ''">
                    <if test="(qylxList !=null and qylxList.length >0 or sfzdzgqy !=null or rtzt !=null) and sfjysgzg !=null">
                        and (tz.qyjgdm LIKE concat(CONCAT('%',#{orgId,jdbcType=VARCHAR}) ,'%')
                        or tz.lssgxkzfzjg LIKE concat(CONCAT('%',#{orgId,jdbcType=VARCHAR}) ,'%') )
                    </if>
                    <if test="((qylxList ==null or qylxList.length ==0) and sfzdzgqy ==null and rtzt ==null) and sfjysgzg !=null">
                        and tz.lssgxkzfzjg LIKE concat(CONCAT('%',#{orgId,jdbcType=VARCHAR}) ,'%')
                    </if>
                    <if test="(qylxList !=null and qylxList.length >0 or sfzdzgqy !=null or rtzt !=null) and sfjysgzg ==null">
                        and tz.qyjgdm LIKE concat(CONCAT('%',#{orgId,jdbcType=VARCHAR}) ,'%')
                    </if>
                </if>
                <if test="sfzdzgqy !=null">
                    and sfzdzgqy = #{sfzdzgqy,jdbcType=VARCHAR}
                </if>
                <if test="rtzt !=null">
                    and rtzt = #{rtzt,jdbcType=VARCHAR}
                </if>
                <if test="sslsxzglbm !=null and sslsxzglbm !=''">
                    and sslsxzglbm like concat(CONCAT('',#{sslsxzglbm,jdbcType=VARCHAR}) ,'%')
                </if>
                <if test='(areaCode !=null and areaCode!="") and (sslsxzglbm==null or sslsxzglbm=="")'>
                    and (
                    <trim prefixOverrides="or">
                        <if test='areaCode !=null and areaCode!=""'>
                            or zcprovince = #{areaCode,jdbcType=VARCHAR} or zccity = #{areaCode,jdbcType=VARCHAR}
                            or txprovince = #{areaCode,jdbcType=VARCHAR} or txcity = #{areaCode,jdbcType=VARCHAR}
                            or lssgcode = #{areaCode,jdbcType=VARCHAR}
                        </if>
                        <if test='sslsxzglbm !=null and sslsxzglbm!=""'>
                            or sslsxzglbm = #{sslsxzglbm,jdbcType=VARCHAR}
                        </if>
                    </trim>
                    )
                </if>
            </if>
            <!-- 企业规避区域 -->
            <if test="qyjgdmList !=null and qyjgdmList.length>0">
                <if test="sfjysgzg !=null">
                    and tz.lssgxkzfzjg not in
                    <foreach collection="qyjgdmList" item="item" index="index" open="(" separator="," close=")">
                        #{item}
                    </foreach>
                </if>
                <if test="qylxList !=null and qylxList.length>0">
                    and tz.sslsxzglbm not in
                    <foreach collection="qyjgdmList" item="item" index="index" open="(" separator="," close=")">
                        #{item}
                    </foreach>
                </if>
            </if>
            <!-- 规避企业机构代码 -->
            <if test="qyxxList !=null and qyxxList.length>0">
                and tz.qyjgdm not in
                <foreach collection="qyxxList" item="item" index="index" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
        </where>
        <!-- GROUP BY tz.id, tz.tyshxydm, tz.zzjgdm,tz.qymc,tz.qyjgdm, tz.QYTXDZ, tz.ZZJGDM, tz.FDDBR, tz.BGDH-->
    </select>


<!-- 根据条件查询企业信息 -->
    <select id="getCompanyListByLaLo" parameterType="com.unis.base.common.vo.CompanyQueryVO" resultMap="BaseResultMap">

        SELECT a.* FROM(
        SELECT
        <include refid="Base_Column_List_common"></include>,
        (ACOS(SIN((#{qyjd} * 3.1415) / 180) * SIN((tz.qyjd * 3.1415) / 180) + COS((#{qyjd} * 3.1415) / 180) *
        COS((tz.qyjd * 3.1415) / 180) * COS((#{qywd} * 3.1415) / 180 - (tz.qywd * 3.1415) / 180)) * 6380) as distance
        FROM (
            SELECT DISTINCT(tz.id)
            from TZ_SLQY tz
            left join TZ_QYLX q on tz.id = q.qyid
            WHERE tz.status = 1 AND if(tz.qyjd = null, 0, 1)  =1 and if(tz.qywd =null, 0, 1) = 1
            <!-- 企业类型 -->
            <if test="qylxbh != null and qylxbh != ''">
                and q.qylxbh LIKE concat(CONCAT('%',#{qylxbh,jdbcType=VARCHAR}) ,'%')
            </if>
        ) xx , tz_slqy tz
        where
        tz.status = 1
        and xx.id=tz.id
        <!-- 社会统一行政编码 -->
        <if test="tyshxydm != null and tyshxydm != ''">
            and tz.tyshxydm LIKE concat(CONCAT('%',#{tyshxydm,jdbcType=VARCHAR}) ,'%')
        </if>
        <!-- 企业名称 -->
        <if test="qymc != null and qymc != ''">
            and tz.qymc LIKE concat(CONCAT('%',#{qymc,jdbcType=VARCHAR}) ,'%')
        </if>

        <!-- 企业性质 -->
        <if test="qyxz != null and qyxz != ''">
            and tz.qyxz LIKE concat(CONCAT('%',#{qyxz,jdbcType=VARCHAR}) ,'%')
        </if>
        <!-- 法定代表人 -->
        <if test="fddbr != null and fddbr != ''">
            and tz.fddbr LIKE concat(CONCAT('%',#{fddbr,jdbcType=VARCHAR}) ,'%')
        </if>
        <!-- 企业状态 -->
        <if test="qyzt != null">
            and tz.qyzt= #{qyzt,jdbcType=DECIMAL}
        </if>
        <if test="qyszqybhs !=null and qyszqybhs !=''">
            and tz.qyszqybh in
            <foreach collection="qyszqybhs" item="item" index="index" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <!-- 企业名称 -->
        <if test="qyjgdm != null and qyjgdm != ''">
            and tz.qyjgdm LIKE concat(CONCAT('%',#{qyjgdm,jdbcType=VARCHAR}) ,'%')
        </if>
        <!-- 组织机构代码 -->
        <if test=' zzjgdm != null and zzjgdm != "" '>
            and tz.zzjgdm LIKE concat(CONCAT('%', #{zzjgdm,jdbcType=VARCHAR}), '%')
        </if>
        <!-- 是否备案 -->
        <if test='sfba != null'>
            and tz.SFBA = #{sfba,jdbcType=DECIMAL}
        </if>
        AND tz.qyjd is not null
        AND tz.qywd is not null
        )a
        ORDER BY a.distance desc
    </select>

    <update id="updateById" parameterType="com.unis.base.server.entity.TzSlqyDO">
        update TZ_SLQY
        <set>

            bz=#{bz},qyzt=#{qyzt}

        </set>

        where id =#{id}

    </update>


    <!-- 根据条件查询企业信息-应急 -->
    <select id="getYjCompanyList" parameterType="com.unis.base.common.vo.CompanyQueryVO" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List_common"></include>
        from
        (
        SELECT DISTINCT(tz.id)
        from TZ_SLQY tz,TZ_QYLX q
        WHERE tz.status = 1
        <!-- 企业类型 -->
        <!-- <if test="qylxbh != null and qylxbh != ''" >
            and	q.qylxbh LIKE concat(CONCAT('%',#{qylxbh,jdbcType=VARCHAR}) ,'%')
        </if> -->
        <if test="qylxbh !=null and qylxbh !=''">
            and q.qylxbh in
            <foreach collection="qylxbh" item="item" index="index" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        and tz.id = q.qyid ) xx , tz_slqy tz
        <where>
            tz.status = 1
            and xx.id=tz.id
            <!-- 社会统一行政编码 -->
            <if test="tyshxydm != null and tyshxydm != ''">
                and tz.tyshxydm LIKE concat(CONCAT('%',#{tyshxydm,jdbcType=VARCHAR}) ,'%')
            </if>
            <!-- 企业名称 -->
            <if test="qymc != null and qymc != ''">
                and tz.qymc LIKE concat(CONCAT('%',#{qymc,jdbcType=VARCHAR}) ,'%')
            </if>

            <!-- 企业性质 -->
            <if test="qyxz != null and qyxz != ''">
                and tz.qyxz LIKE concat(CONCAT('%',#{qyxz,jdbcType=VARCHAR}) ,'%')
            </if>
            <!-- 法定代表人 -->
            <if test="fddbr != null and fddbr != ''">
                and tz.fddbr LIKE concat(CONCAT('%',#{fddbr,jdbcType=VARCHAR}) ,'%')
            </if>
            <!-- 企业状态 -->
            <if test="qyzt != null">
                and tz.qyzt= #{qyzt,jdbcType=DECIMAL}
            </if>
            <if test="qyszqybhs !=null and qyszqybhs !=''">
                and tz.qyszqybh in
                <foreach collection="qyszqybhs" item="item" index="index" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>

            <if test="qyzts !=null and qyzts !=''">
                and tz.qyzt in
                <foreach collection="qyzts" item="item" index="index" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>

            <if test="sslsxzglbm !=null and sslsxzglbm !=''">
                and tz.sslsxzglbm=#{sslsxzglbm}

            </if>
            <!-- 企业名称 -->
            <if test="qyjgdm != null and qyjgdm != ''">
                and tz.qyjgdm LIKE concat(CONCAT('%',#{qyjgdm,jdbcType=VARCHAR}) ,'%')
            </if>
            <!-- 组织机构代码 -->
            <if test=' zzjgdm != null and zzjgdm != "" '>
                and tz.zzjgdm LIKE concat(CONCAT('%', #{zzjgdm,jdbcType=VARCHAR}), '%')
            </if>
            <!-- 是否备案 -->
            <if test='sfba != null'>
                and tz.SFBA = #{sfba,jdbcType=DECIMAL}
            </if>
            <!-- 是否具有收购资格 -->
            <if test='sfjysgzg != null'>
                and tz.SFJYSGZG = #{sfjysgzg,jdbcType=DECIMAL}
            </if>
            <if test='yjAreaCode != null'>
                and tz.qyszqybh LIKE concat(CONCAT('', #{yjAreaCode,jdbcType=VARCHAR}), '%')
            </if>
        </where>
        ORDER BY tz.REFRESH_TIME desc
    </select>

    <!--获取最大企业编码-->
    <select id="getMaxById" parameterType="java.lang.String" resultType="java.lang.String">
        SELECT
        max(tz.qybm)
        from
        TZ_SLQY tz
    </select>


    <!--获取承储库点企业-->
    <select id="getCompanyKdList" parameterType="com.unis.base.common.vo.CompanyKdVO" resultType="com.unis.base.common.vo.CompanyKdVO">
        select distinct
        d.kddm,tz.qymc,tz.qyszqy,tz.qymc,tz.qyjgdm,tz.qylxr,tz.bgdh,tz.qytxdz,tz.zcrq
        from
            tz_slqy tz,d_kdxxsjy d
          where
           tz.tyshxydm = d.tyshxydm
            and  (tz.qyzyyw like('%70%')
            or tz.qyzyyw like('%80%')
            or tz.qyzyyw like('%81%'))
    </select>

    <update id="updateCompanySfba" parameterType="com.unis.base.server.entity.TzSlqyDO">
        update TZ_SLQY
        <set>
            <if test="shyj != null">
                shyj = #{shyj,jdbcType=VARCHAR},
            </if>
            <if test="sfba != null">
                sfba = #{sfba,jdbcType=DECIMAL},
            </if>
            <if test="shzt != null">
                shzt = #{shzt},
            </if>
            <if test="qyzt != null">
                qyzt = #{qyzt,jdbcType=DECIMAL},
            </if>
        </set>
        where id =#{id}
    </update>

    <select id="getCompanyByQymc" parameterType="java.lang.String" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List_common"></include>
        from
        TZ_SLQY tz
        <where>
            tz.qymc = #{qymc,jdbcType=VARCHAR}
            and tz.status=1
        </where>
    </select>
    <select id="getQyxxByXydm" resultType="com.unis.base.server.entity.TzSlqyDO">
        	SELECT qymc, qytxdz, fddbr, create_date
		FROM TZ_SLQY
		WHERE tyshxydm = #{kddm}
    </select>
    <select id="getSlqyByQybm" resultType="com.unis.base.server.entity.TzSlqyDO">
          	SELECT *
		FROM TZ_SLQY
		WHERE qybm = #{qybm}
    </select>
    <select id="getSlqyByQybmAll" resultType="com.unis.base.server.entity.TzSlqyDO">
         	SELECT *
		FROM TZ_SLQY
    </select>
    <select id="getSlqyByKddm" resultType="com.unis.base.server.entity.TzSlqyDO">
        SELECT tyshxydm,qyxz
		FROM TZ_SLQY
		WHERE zzjgdm = #{kddm}
    </select>
    <select id="companyType" resultType="com.unis.base.server.entity.TzQylxDO">
      select DISTINCT(lx.qylxbh) qylxbh from TZ_QYLX lx,tz_slqy qy where qy.id = lx.qyid and qy.qyjgdm = #{qyjgdm}
    </select>
    <select id="selectKdxxLgd" resultType="com.unis.base.common.vo.DKdxxsjyVO">
        SELECT b.*,a.qyjgdm FROM  tz_qyjg a join D_KDXXSJY b on a.tyshxydm=b.tyshxydm WHERE a.status=1 and b.kddm in
        (select sskd from db_utf8.ty_lhzxsqzb a where a.status = 1 and a.pfzt='3')
    </select>
    <select id="selectKdxxLgdForQc" resultType="com.unis.base.common.vo.DKdxxsjyVO">
        SELECT b.*,a.qyjgdm FROM  tz_qyjg a join D_KDXXSJY b on a.tyshxydm=b.tyshxydm WHERE a.status=1 and b.kddm in
        (select sskd from db_utf8.ty_lhzxsqzbqc a where a.status = 1 and a.pfzt='3')
    </select>


    <select id="sgzgBar" resultType="com.unis.base.common.vo.SimpeCompanyBarVO">
        SELECT
        sum(1) as num,TZ.QYXZ
        from
        TZ_SLQY tz join TY_SHOUGOUZIGE C  ON tz.TYSHXYDM=C.TYSHXYDM
         <where>
             <if test='sfjysgzg!=null and sfjysgzg!="" '>
                 AND TZ.sfjysgzg = #{sfjysgzg,jdbcType=DECIMAL}
             </if>
             <if test='yxDateNum!=null'>
                 <![CDATA[
                          AND C.yxqz >= #{yxDateNum,jdbcType=DECIMAL}
                          AND C.yxqq <= #{yxDateNum,jdbcType=DECIMAL}
                        ]]>
             </if>
             <if test="qyxzList != null and qyxzList.size()>0">
                 and TZ.QYXZ in
                 <foreach collection="qyxzList" index="index" item="item" open="("	separator="," close=")">
                     #{item}
                 </foreach>
             </if>
             <if test='status!=null'>
                 AND TZ.STATUS = #{status,jdbcType=DECIMAL}
             </if>
         </where>
         group by TZ.QYXZ
    </select>

    <!--这个会只查询最新的,历史的查询会有问题-->
<!--
    <select id="sgzgBar" resultType="com.unis.base.common.vo.SimpeCompanyBarVO">
        SELECT
        sum(1) as num,TZ.QYXZ
        from
        TZ_SLQY tz join
        (
            SELECT
            A.TYSHXYDM
            FROM TY_SHOUGOUZIGE A
            JOIN (
                SELECT MAX(SGZGID) AS SGZGID FROM TY_SHOUGOUZIGE
                <where>
                    <if test='status!=null'>
                        AND STATUS = #{status,jdbcType=DECIMAL}
                    </if>
                    <if test='yxDateNum!=null'>
                        <![CDATA[
                          AND yxqz >= #{yxDateNum,jdbcType=DECIMAL}
                          AND yxqq <= #{yxDateNum,jdbcType=DECIMAL}
                        ]]>
                    </if>
                </where>
                GROUP BY  TYSHXYDM
             ) B ON A.SGZGID = B.SGZGID
         )C ON tz.TYSHXYDM=C.TYSHXYDM
         <where>
             <if test='sfjysgzg!=null and sfjysgzg!="" '>
                 AND TZ.sfjysgzg = #{sfjysgzg,jdbcType=DECIMAL}
             </if>
             <if test="qyxzList != null and qyxzList.size()>0">
                 and TZ.QYXZ in
                 <foreach collection="qyxzList" index="index" item="item" open="("	separator="," close=")">
                     #{item}
                 </foreach>
             </if>
             <if test='status!=null'>
                 AND TZ.STATUS = #{status,jdbcType=DECIMAL}
             </if>
         </where>
         group by TZ.QYXZ
    </select>
-->

    <select id="sgzgLine" resultType="com.unis.base.common.vo.CompanyLineVO">
        SELECT
        TZ.QYXZ,C.YXQQ,C.YXQZ
        from
        TZ_SLQY tz join TY_SHOUGOUZIGE C  ON tz.TYSHXYDM=C.TYSHXYDM
         <where>
             <if test='sfjysgzg!=null and sfjysgzg!="" '>
                 AND TZ.sfjysgzg = #{sfjysgzg,jdbcType=DECIMAL}
             </if>
             <if test='yxDateNum!=null'>
                 <![CDATA[
                          AND C.yxqz >= #{yxDateNum,jdbcType=DECIMAL}
                          AND C.yxqq <= #{yxDateNum,jdbcType=DECIMAL}
                        ]]>
             </if>
             <if test="qyxzList != null and qyxzList.size()>0">
                 and TZ.QYXZ in
                 <foreach collection="qyxzList" index="index" item="item" open="("	separator="," close=")">
                     #{item}
                 </foreach>
             </if>
             <if test='status!=null'>
                 AND TZ.STATUS = #{status,jdbcType=DECIMAL}
             </if>
         </where>
    </select>

    <!--这个会只查询最新的,历史的查询会有问题-->
<!--
    <select id="sgzgLine" resultType="com.unis.base.common.vo.CompanyLineVO">
        SELECT
        TZ.QYXZ,C.YXQQ,C.YXQZ
        from
        TZ_SLQY tz join
        (
            SELECT
            A.TYSHXYDM,A.YXQQ,A.YXQZ
            FROM TY_SHOUGOUZIGE A
            <where>
                <if test='status!=null'>
                    AND A.STATUS = #{status,jdbcType=DECIMAL}
                </if>
                <if test='yxDateNum!=null'>
                    <![CDATA[
                      AND A.yxqz >= #{yxDateNum,jdbcType=DECIMAL}
                      AND A.yxqq <= #{yxDateNum,jdbcType=DECIMAL}
                    ]]>
                </if>
            </where>
         )C ON tz.TYSHXYDM=C.TYSHXYDM
         <where>
             <if test='sfjysgzg!=null and sfjysgzg!="" '>
                 AND TZ.sfjysgzg = #{sfjysgzg,jdbcType=DECIMAL}
             </if>
             <if test="qyxzList != null and qyxzList.size()>0">
                 and TZ.QYXZ in
                 <foreach collection="qyxzList" index="index" item="item" open="("	separator="," close=")">
                     #{item}
                 </foreach>
             </if>
             <if test='status!=null'>
                 AND TZ.STATUS = #{status,jdbcType=DECIMAL}
             </if>
         </where>
    </select>
-->

    <!--根据实体的唯一属性查询数量-->
    <select id='selectCountById' resultType='java.lang.Integer'>
        SELECT
        COUNT(1)
        FROM TZ_SLQY
        <where>
            <if test='id !=null and id != ""'>
                OR ID = #{id,jdbcType=VARCHAR}
            </if>
            <if test='tyshxydm !=null and tyshxydm != ""'>
                OR TYSHXYDM = #{tyshxydm,jdbcType=VARCHAR}
            </if>
        </where>
    </select>
    <select id="getCompanyByqymc" resultType="com.unis.base.server.entity.TzSlqyDO">
        SELECT
        <include refid="Base_Column_List_common"></include>
        ,(select ifnull(count(0),0) from base.d_kdxxsjy where tyshxydm=tz.tyshxydm and status=1) as kqsl
        ,(select ifnull(count(distinct(gfcfdm)),0) from base.d_cfxxsjy where tyshxydm=tz.tyshxydm and status=1 and sfba=5) as cfsl
        ,(select ifnull(count(0),0) from base.d_ygxxsjy where tyshxydm=tz.tyshxydm and status=1 and sfba=5 ) as ygsl
        from
        TZ_SLQY tz
        <where>
            tz.qymc = #{qymc,jdbcType=VARCHAR}
            and tz.status=1
        </where>
    </select>

    <!--根据实体不为空的属性,选择性更新字段-->
    <update id='updateByEntitySelective'>
        update TZ_SLQY
        <set>
            <if test='tyshxydm != null'>
                TYSHXYDM = #{tyshxydm,jdbcType=VARCHAR},
            </if>
            <if test='zzjgdm != null'>
                ZZJGDM = #{zzjgdm,jdbcType=VARCHAR},
            </if>
            <if test='qymc != null'>
                QYMC = #{qymc,jdbcType=VARCHAR},
            </if>
            <if test='qylx != null'>
                QYLX = #{qylx,jdbcType=VARCHAR},
            </if>
            <if test='dwdm != null'>
                DWDM = #{dwdm,jdbcType=VARCHAR},
            </if>
            <if test='qyjjlx != null'>
                QYJJLX = #{qyjjlx,jdbcType=VARCHAR},
            </if>
            <if test='qyxz != null'>
                QYXZ = #{qyxz,jdbcType=VARCHAR},
            </if>
            <if test='djzclx != null'>
                DJZCLX = #{djzclx,jdbcType=VARCHAR},
            </if>
            <if test='gsdjzch != null'>
                GSDJZCH = #{gsdjzch,jdbcType=VARCHAR},
            </if>
            <if test='fddbr != null'>
                FDDBR = #{fddbr,jdbcType=VARCHAR},
            </if>
            <if test='bgdh != null'>
                BGDH = #{bgdh,jdbcType=VARCHAR},
            </if>
            <if test='frsjh != null'>
                FRSJH = #{frsjh,jdbcType=VARCHAR},
            </if>
            <if test='qydzyx != null'>
                QYDZYX = #{qydzyx,jdbcType=VARCHAR},
            </if>
            <if test='qycyrys != null'>
                QYCYRYS = #{qycyrys,jdbcType=DECIMAL},
            </if>
            <if test='zjyszcrs != null'>
                ZJYSZCRS = #{zjyszcrs,jdbcType=DECIMAL},
            </if>
            <if test='bgyrs != null'>
                BGYRS = #{bgyrs,jdbcType=DECIMAL},
            </if>
            <if test='jhyyrs != null'>
                JHYYRS = #{jhyyrs,jdbcType=DECIMAL},
            </if>
            <if test='yzyzgzsrs != null'>
                YZYZGZSRS = #{yzyzgzsrs,jdbcType=DECIMAL},
            </if>
            <if test='qyczhm != null'>
                QYCZHM = #{qyczhm,jdbcType=VARCHAR},
            </if>
            <if test='qytxdz != null'>
                QYTXDZ = #{qytxdz,jdbcType=VARCHAR},
            </if>
            <if test='qyyb != null'>
                QYYB = #{qyyb,jdbcType=VARCHAR},
            </if>
            <if test='qyzyyw != null'>
                QYZYYW = #{qyzyyw,jdbcType=VARCHAR},
            </if>
            <if test='qyzcsj != null'>
                QYZCSJ = #{qyzcsj,jdbcType=DATE},
            </if>
            <if test='zzxlysry != null'>
                ZZXLYSRY = #{zzxlysry,jdbcType=DECIMAL},
            </if>
            <if test='qysclszypz != null'>
                QYSCLSZYPZ = #{qysclszypz,jdbcType=VARCHAR},
            </if>
            <if test='qylsgx != null'>
                QYLSGX = #{qylsgx,jdbcType=VARCHAR},
            </if>
            <if test='qyyjjb != null'>
                QYYJJB = #{qyyjjb,jdbcType=VARCHAR},
            </if>
            <if test='qyjd != null'>
                QYJD = #{qyjd,jdbcType=VARCHAR},
            </if>
            <if test='qywd != null'>
                QYWD = #{qywd,jdbcType=VARCHAR},
            </if>
            <if test='qyszqy != null'>
                QYSZQY = #{qyszqy,jdbcType=VARCHAR},
            </if>
            <if test='status != null'>
                STATUS = #{status,jdbcType=DECIMAL},
            </if>
            <if test='refresher != null'>
                REFRESHER = #{refresher,jdbcType=VARCHAR},
            </if>
            <if test='refresherCode != null'>
                REFRESHER_CODE = #{refresherCode,jdbcType=VARCHAR},
            </if>
            <if test='refreshTime != null'>
                REFRESH_TIME = #{refreshTime,jdbcType=TIMESTAMP},
            </if>
            <if test='remark != null'>
                REMARK = #{remark,jdbcType=CLOB},
            </if>
            <if test='qyccnl != null'>
                QYCCNL = #{qyccnl,jdbcType=DECIMAL},
            </if>
            <if test='qyzt != null'>
                QYZT = #{qyzt,jdbcType=DECIMAL},
            </if>
            <if test='qyszqybh != null'>
                QYSZQYBH = #{qyszqybh,jdbcType=VARCHAR},
            </if>
            <if test='qyyjlxbh != null'>
                QYYJLXBH = #{qyyjlxbh,jdbcType=VARCHAR},
            </if>
            <if test='qyyjlxmc != null'>
                QYYJLXMC = #{qyyjlxmc,jdbcType=VARCHAR},
            </if>
            <if test='sfdlfrzg != null'>
                SFDLFRZG = #{sfdlfrzg,jdbcType=DECIMAL},
            </if>
            <if test='xsqygs != null'>
                XSQYGS = #{xsqygs,jdbcType=DECIMAL},
            </if>
            <if test='zcrq != null'>
                ZCRQ = #{zcrq,jdbcType=DATE},
            </if>
            <if test='sfjysgzg != null'>
                SFJYSGZG = #{sfjysgzg,jdbcType=DECIMAL},
            </if>
            <if test='lssgxkzfzjg != null'>
                LSSGXKZFZJG = #{lssgxkzfzjg,jdbcType=VARCHAR},
            </if>
            <if test='sgzgzbh != null'>
                SGZGZBH = #{sgzgzbh,jdbcType=VARCHAR},
            </if>
            <if test='sslsxzglbm != null'>
                SSLSXZGLBM = #{sslsxzglbm,jdbcType=VARCHAR},
            </if>
            <if test='zdmj != null'>
                ZDMJ = #{zdmj,jdbcType=DECIMAL},
            </if>
            <if test='sszdmj != null'>
                SSZDMJ = #{sszdmj,jdbcType=DECIMAL},
            </if>
            <if test='sqjgzdmj != null'>
                SQJGZDMJ = #{sqjgzdmj,jdbcType=DATE},
            </if>
            <if test='qygsdjjg != null'>
                QYGSDJJG = #{qygsdjjg,jdbcType=VARCHAR},
            </if>
            <if test='qylxr != null'>
                QYLXR = #{qylxr,jdbcType=VARCHAR},
            </if>
            <if test='qyjgdm != null'>
                QYJGDM = #{qyjgdm,jdbcType=VARCHAR},
            </if>
            <if test='yysr != null'>
                YYSR = #{yysr,jdbcType=DECIMAL},
            </if>
            <if test='lsze != null'>
                LSZE = #{lsze,jdbcType=DECIMAL},
            </if>
            <if test='dnyjkftr != null'>
                DNYJKFTR = #{dnyjkftr,jdbcType=DECIMAL},
            </if>
            <if test='fmzl != null'>
                FMZL = #{fmzl,jdbcType=VARCHAR},
            </if>
            <if test='gyzcz != null'>
                GYZCZ = #{gyzcz,jdbcType=DECIMAL},
            </if>
            <if test='lrze != null'>
                LRZE = #{lrze,jdbcType=DECIMAL},
            </if>
            <if test='zfzctr != null'>
                ZFZCTR = #{zfzctr,jdbcType=DECIMAL},
            </if>
            <if test='cpxssr != null'>
                CPXSSR = #{cpxssr,jdbcType=DECIMAL},
            </if>
            <if test='zcze != null'>
                ZCZE = #{zcze,jdbcType=DECIMAL},
            </if>
            <if test='dnzlhds != null'>
                DNZLHDS = #{dnzlhds,jdbcType=DECIMAL},
            </if>
            <if test='nclyjxzz != null'>
                NCLYJXZZ = #{nclyjxzz,jdbcType=DECIMAL},
            </if>
            <if test='yzjgzj != null'>
                YZJGZJ = #{yzjgzj,jdbcType=VARCHAR},
            </if>
            <if test='tysb != null'>
                TYSB = #{tysb,jdbcType=VARCHAR},
            </if>
            <if test='nhxhbzm != null'>
                NHXHBZM = #{nhxhbzm,jdbcType=DECIMAL},
            </if>
            <if test='gr != null'>
                GR = #{gr,jdbcType=DECIMAL},
            </if>
            <if test='dmjgzj != null'>
                DMJGZJ = #{dmjgzj,jdbcType=VARCHAR},
            </if>
            <if test='sljgzj != null'>
                SLJGZJ = #{sljgzj,jdbcType=VARCHAR},
            </if>
            <if test='nyhd != null'>
                NYHD = #{nyhd,jdbcType=DECIMAL},
            </if>
            <if test='nyxhrj != null'>
                NYXHRJ = #{nyxhrj,jdbcType=VARCHAR},
            </if>
            <if test='xmfjgzj != null'>
                XMFJGZJ = #{xmfjgzj,jdbcType=VARCHAR},
            </if>
            <if test='ccsb != null'>
                CCSB = #{ccsb,jdbcType=VARCHAR},
            </if>
            <if test='nyxhs != null'>
                NYXHS = #{nyxhs,jdbcType=VARCHAR},
            </if>
            <if test='zcr != null'>
                ZCR = #{zcr,jdbcType=DECIMAL},
            </if>
            <if test='cfd != null'>
                CFD = #{cfd,jdbcType=DECIMAL},
            </if>
            <if test='cfj != null'>
                CFJ = #{cfj,jdbcType=DECIMAL},
            </if>
            <if test='bz != null'>
                BZ = #{bz,jdbcType=VARCHAR},
            </if>
            <if test='sfba != null'>
                SFBA = #{sfba,jdbcType=DECIMAL},
            </if>
            <if test='jyfw != null'>
                JYFW = #{jyfw,jdbcType=VARCHAR},
            </if>
            <if test='wryjyrybcs != null'>
                WRYJYRYBCS = #{wryjyrybcs,jdbcType=DECIMAL},
            </if>
            <if test='qycj != null'>
                QYCJ = #{qycj,jdbcType=VARCHAR},
            </if>
            <if test='qygszcd != null'>
                QYGSZCD = #{qygszcd,jdbcType=VARCHAR},
            </if>
            <if test='rtzt != null'>
                RTZT = #{rtzt,jdbcType=DECIMAL},
            </if>
            <if test='sjccqy != null'>
                SJCCQY = #{sjccqy,jdbcType=VARCHAR},
            </if>
            <if test='qjccqy != null'>
                QJCCQY = #{qjccqy,jdbcType=VARCHAR},
            </if>
            <if test='sjjtmc != null'>
                SJJTMC = #{sjjtmc,jdbcType=VARCHAR},
            </if>
            <if test='sjjtjgdm != null'>
                SJJTJGDM = #{sjjtjgdm,jdbcType=VARCHAR},
            </if>
            <if test='sjjttyshxydm != null'>
                SJJTTYSHXYDM = #{sjjttyshxydm,jdbcType=VARCHAR},
            </if>
            <if test='cfsl != null'>
                CFSL = #{cfsl,jdbcType=DECIMAL},
            </if>
            <if test='ygsl != null'>
                YGSL = #{ygsl,jdbcType=DECIMAL},
            </if>
            <if test='shi != null'>
                SHI = #{shi,jdbcType=VARCHAR},
            </if>
            <if test='shiName != null'>
                SHI_NAME = #{shiName,jdbcType=VARCHAR},
            </if>
            <if test='xian != null'>
                XIAN = #{xian,jdbcType=VARCHAR},
            </if>
            <if test='xianName != null'>
                XIAN_NAME = #{xianName,jdbcType=VARCHAR},
            </if>
            <if test='shrmc != null'>
                SHRMC = #{shrmc,jdbcType=VARCHAR},
            </if>
            <if test='shyj != null'>
                SHYJ = #{shyj,jdbcType=LONGVARCHAR},
            </if>
            <if test='shsj != null'>
                SHSJ = #{shsj,jdbcType=DATE},
            </if>
            <if test='dwlx != null'>
                DWLX = #{dwlx,jdbcType=VARCHAR},
            </if>
            <if test='distance != null'>
                DISTANCE = #{distance,jdbcType=DECIMAL},
            </if>
            <if test='lssgxkzfzsj != null'>
                LSSGXKZFZSJ = #{lssgxkzfzsj,jdbcType=TIMESTAMP},
            </if>
            <if test='tbr != null'>
                TBR = #{tbr,jdbcType=VARCHAR},
            </if>
            <if test='lxdh != null'>
                LXDH = #{lxdh,jdbcType=VARCHAR},
            </if>
            <if test='sjh != null'>
                SJH = #{sjh,jdbcType=DECIMAL},
            </if>
            <if test='qyfzr != null'>
                QYFZR = #{qyfzr,jdbcType=VARCHAR},
            </if>
            <if test='frsfzh != null'>
                FRSFZH = #{frsfzh,jdbcType=VARCHAR},
            </if>
            <if test="cfsl !=null">
                CFSL = #{cfsl,jdbcType=DECIMAL},
            </if>
            <if test="ygsl !=null">
                YGSL = #{ygsl,jdbcType=DECIMAL},
            </if>
            <if test="shi !=null">
                SHI = #{shi,jdbcType=VARCHAR},
            </if>
            <if test="shiName !=null">
                SHI_NAME = #{shiName,jdbcType=VARCHAR},
            </if>
            <if test="xian !=null">
                XIAN = #{xian,jdbcType=VARCHAR},
            </if>
            <if test="xianName !=null">
                XIAN_NAME = #{xianName,jdbcType=VARCHAR},
            </if>
            <if test=" shrmc != null">
                shrmc = #{ shrmc, jdbcType=DECIMAL},
            </if>
            <if test=" shyj != null">
                shyj = #{ shyj, jdbcType=DECIMAL},
            </if>
            <if test=" shsj != null">
                shsj = #{ shsj, jdbcType=DECIMAL},
            </if>
            <if test=" dwlx != null">
                dwlx = #{ dwlx, jdbcType=VARCHAR},
            </if>
            <if test="sfzdzgqy !=null">
                sfzdzgqy = #{sfzdzgqy,jdbcType=VARCHAR},
            </if>
            <if test="txprovince !=null">
                txprovince = #{txprovince,jdbcType=VARCHAR},
            </if>
            <if test="txcity !=null">
                txcity = #{txcity,jdbcType=VARCHAR},
            </if>
            <if test="zcprovince !=null">
                zcprovince = #{zcprovince,jdbcType=VARCHAR},
            </if>
            <if test="zccity !=null">
                zccity = #{zccity,jdbcType=VARCHAR},
            </if>
            <if test=" remark != null">
                remark = #{ remark, jdbcType=VARCHAR},
            </if>
            <if test=" fileId != null">
                file_id = #{ fileId, jdbcType=VARCHAR},
            </if>
            <if test="frsfzh !=null and frsfzh !=''">
                frsfzh = #{frsfzh, jdbcType=VARCHAR},
            </if>
            <if test="txcounty !=null and txcounty !=''">
                txcounty = #{txcounty,jdbcType=VARCHAR},
            </if>
            <if test="zccounty !=null and zccounty !=''">
                zccounty = #{zccounty,jdbcType=VARCHAR},
            </if>
            <if test="sjcr !=null and sjcr !=''">
                sjcr = #{sjcr,jdbcType=DECIMAL},
            </if>
            <if test="kqcq !=null and kqcq !=''">
                kqcq = #{kqcq,jdbcType=VARCHAR},
            </if>
            <if test="sykqt !=null and sykqt !=''">
                sykqt = #{sykqt,jdbcType=VARCHAR},
            </if>
            <if test="qyxzfl !=null and qyxzfl !=''">
                qyxzfl = #{qyxzfl,jdbcType=VARCHAR},
            </if>
            <if test="refreshTime !=null">
                refresh_time = #{refreshTime,jdbcType=TIMESTAMP},
            </if>
            <if test="kqlb !=null">
                kqlb = #{kqlb,jdbcType=VARCHAR},
            </if>
            <if test="lx !=null and lx !=''">
                lx = #{lx,jdbcType=VARCHAR},
            </if>
            <if test='sendResult != null'>
                SEND_RESULT = #{sendResult,jdbcType=VARCHAR},
            </if>
            <if test="sfbaqy !=null">
                sfbaqy = #{sfbaqy,jdbcType=VARCHAR},
            </if>
            <if test="sflttjqy !=null">
                sflttjqy = #{sflttjqy,jdbcType=VARCHAR},
            </if>
            <if test="qiyeleix !=null">
                qiyeleix = #{qiyeleix,jdbcType=VARCHAR},
            </if>
        </set>
        <where>
            <!--此处为必填条件,如不满足则不执行,以免更新全部-->
            <choose>
                <when test='id !=null and id != ""'>
                    AND ID = #{id,jdbcType=VARCHAR}
                </when>
                <when test='tyshxydm !=null and tyshxydm != ""'>
                    AND TYSHXYDM = #{tyshxydm,jdbcType=VARCHAR}
                </when>
                <otherwise>
                    AND 1=0
                </otherwise>
            </choose>
            <!--此处可添加状态条件等-->
            <if test='status!=null'>
                AND STATUS = #{status,jdbcType=DECIMAL}
            </if>
        </where>
    </update>

    <update id="updateTimeAndQyCr" parameterType="com.unis.base.server.entity.TzSlqyDO">
        update TZ_SLQY
        set
            <if test="sjcr != null">
                sjcr = (select ifnull(sum(sjcr),0)
                        from (select a.sjcr,
                                row_number() over(partition by a.gfcfdm order by a.refresh_time desc) as rn
                              from  base.D_CFXXSJY a
                              where a.gfcfdm is not null
                              and a.sfba = '5'
                              and tyshxydm = #{tyshxydm,jdbcType=VARCHAR})
                        where rn=1),
                zcr = (select ifnull(sum(dczlrj),0)
                        from (select a.dczlrj,
                                 row_number() over(partition by a.gfcfdm order by a.refresh_time desc) as rn
                              from  base.D_CFXXSJY a
                              where a.gfcfdm is not null
                              and a.sfba = '5'
                              and tyshxydm = #{tyshxydm,jdbcType=VARCHAR})
                        where rn=1),
            </if>
            <if test="gr != null">
                gr = (select ifnull(sum(sjgr),0)
                     from d_ygxxsjy
                     where sfba = '5'
                     and tyshxydm = #{tyshxydm,jdbcType=VARCHAR}),
            </if>
        refresh_time = #{refreshTime,jdbcType=TIMESTAMP}
        where tyshxydm = #{tyshxydm,jdbcType=VARCHAR}
    </update>
</mapper>
