<?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.DCfxxsjyDao" >

	<resultMap id="BaseResultMap" type="com.unis.base.server.entity.DCfxxsjyDO" >
        <result column="cfbh" property="cfbh" jdbcType="VARCHAR" />
		<!-- 仓房名称+货位名称 -->
        <result column="cfmc" property="cfmc" jdbcType="VARCHAR" />
		<!-- 货位名称 -->
		<result column="cfmc01" property="cfmc01" jdbcType="VARCHAR" />
        <result column="kddm" property="kddm" jdbcType="VARCHAR" />
        <result column="cflx" property="cflx" jdbcType="VARCHAR" />
        <result column="cfjg" property="cfjg" jdbcType="VARCHAR" />
        <result column="jzlx" property="jzlx" jdbcType="VARCHAR" />
        <result column="cfcd" property="cfcd" jdbcType="VARCHAR" />
        <result column="cfkd" property="cfkd" jdbcType="VARCHAR" />
        <result column="cfgd" property="cfgd" jdbcType="VARCHAR" />
        <result column="sjcr" property="sjcr" jdbcType="VARCHAR" />
        <result column="sjcr01" property="sjcr01" jdbcType="VARCHAR" />
        <result column="lxdh" property="lxdh" jdbcType="VARCHAR" />
        <result column="rybh" property="rybh" jdbcType="VARCHAR" />
	    <result column="ryxm" property="ryxm" jdbcType="VARCHAR" />
	    <result column="cfqt" property="cfqt" jdbcType="VARCHAR" />
	    <result column="cfyg" property="cfyg" jdbcType="DECIMAL" />
	    <result column="cfwm" property="cfwm" jdbcType="VARCHAR" />
	    <result column="cfdm" property="cfdm" jdbcType="VARCHAR" />
	    <result column="fwkd" property="fwkd" jdbcType="DECIMAL" />
	    <result column="zlxgd" property="zlxgd" jdbcType="DECIMAL" />
	    <result column="tczj" property="tczj" jdbcType="DECIMAL" />
	    <result column="cmsl" property="cmsl" jdbcType="DECIMAL" />
	    <result column="cmgd" property="cmgd" jdbcType="DECIMAL" />
	    <result column="cmkd" property="cmkd" jdbcType="DECIMAL" />
	    <result column="tffs" property="tffs" jdbcType="VARCHAR" />
	    <result column="grfs" property="grfs" jdbcType="VARCHAR" />
	    <result column="kwcs" property="kwcs" jdbcType="VARCHAR" />
        <result column="jd" property="jd" jdbcType="VARCHAR" />
        <result column="wd" property="wd" jdbcType="VARCHAR" />
        <result column="qyrq" property="qyrq" jdbcType="VARCHAR" />
        <result column="cfzt" property="cfzt" jdbcType="VARCHAR" />
        <result column="jsnd" property="jsnd" jdbcType="VARCHAR" />
        <result column="dczlrj" property="dczlrj" 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="kdmc" property="kdmc" jdbcType="VARCHAR" />

		<result column="cflxbh" property="cflxbh" jdbcType="VARCHAR" />
		<result column="dwc" property="dwc" jdbcType="INTEGER" />
		<result column="cfyt" property="cfyt" jdbcType="VARCHAR" />
		<result column="qtyt" property="qtyt" jdbcType="VARCHAR" />
		<result column="cfnc" property="cfnc" jdbcType="DECIMAL" />
		<result column="cfnk" property="cfnk" jdbcType="DECIMAL" />
		<result column="cfnj" property="cfnj" jdbcType="INTEGER" />
		<result column="ccfs" property="ccfs" jdbcType="INTEGER" />
		<result column="bwm" property="bwm" jdbcType="VARCHAR" />
		<result column="bwc" property="bwc" jdbcType="INTEGER" />
		<result column="scbwc" property="scbwc" jdbcType="INTEGER" />
		<result column="wknkc" property="wknkc" jdbcType="INTEGER" />
		<result column="cndd" property="cndd" jdbcType="INTEGER" />
		<result column="cdbwdd" property="cdbwdd" jdbcType="INTEGER" />
		<result column="gcpjr" property="gcpjr" jdbcType="INTEGER" />
		<result column="cdwgrc" property="cdwgrc" jdbcType="INTEGER" />
		<result column="bwqt" property="bwqt" jdbcType="INTEGER" />
		<result column="bwtl" property="bwtl" jdbcType="INTEGER" />
		<result column="zlsb" property="zlsb" jdbcType="INTEGER" />
		<result column="dltf" property="dltf" jdbcType="INTEGER" />
		<result column="zltf" property="zltf" jdbcType="INTEGER" />
		<result column="dzcw" property="dzcw" jdbcType="INTEGER" />
		<result column="zdllk" property="zdllk" jdbcType="INTEGER" />
		<result column="hlxz" property="hlxz" jdbcType="INTEGER" />
		<result column="cnhl" property="cnhl" jdbcType="INTEGER" />
		<result column="sfba" property="sfba" jdbcType="DECIMAL" />
		<result column="cfxh" property="cfxh" jdbcType="VARCHAR" />
		<result column="ajxh" property="ajxh" jdbcType="VARCHAR" />
		<result column="hwxh" property="hwxh" jdbcType="VARCHAR" />
		<result column="jssj" property="jssj" jdbcType="DATE" />
		<result column="jfsyrq" property="jfsyrq" jdbcType="DATE" />
		<result column="fyfcxn" property="fyfcxn" jdbcType="VARCHAR" />
		<result column="mbscxn" property="mbscxn" jdbcType="VARCHAR" />
		<result column="grblxn" property="grblxn" jdbcType="VARCHAR" />
		<result column="sfszcc" property="sfszcc" jdbcType="DECIMAL" />
		<result column="ywlqckqk" property="ywlqckqk" jdbcType="DECIMAL" />
		<result column="cfsyqk" property="cfsyqk" jdbcType="DECIMAL" />
		<result column="qthd" property="qthd" jdbcType="DECIMAL" />
		<result column="cmmc" property="cmmc" jdbcType="VARCHAR" />
		<result column="qtgr" property="qtgr" jdbcType="DECIMAL" />
		<result column="shrmc" property="shrmc" jdbcType="VARCHAR"/>
		<result column="shyj" property="shyj" />
		<result column="shsj" property="shsj" jdbcType="DATE"/>
		<result column="tyshxydm" property="tyshxydm" jdbcType="VARCHAR"/>
		<result column="lspzmc" property="lspzmc" jdbcType="VARCHAR" />
		<result column="fcsl" property="fcsl" jdbcType="DECIMAL" />

		<result column="rcny" property="rcny" jdbcType="VARCHAR" />
		<result column="cfww" property="cfww" jdbcType="DECIMAL" />
		<result column="cfnw" property="cfnw" jdbcType="DECIMAL" />
		<result column="cfws" property="cfws" jdbcType="DECIMAL" />
		<result column="cfns" property="cfns" jdbcType="DECIMAL" />

		<result column="chbw" property="chbw" jdbcType="INTEGER" />
		<result column="zlfj" property="zlfj" jdbcType="INTEGER" />
		<result column="nfxlsc" property="nfxlsc" jdbcType="INTEGER" />
		<result column="cnsxt" property="cnsxt" jdbcType="INTEGER" />
		<result column="dwclx" property="dwclx" jdbcType="INTEGER" />
		<result column="ywjxtfss" property="ywjxtfss" jdbcType="INTEGER" />
		<result column="cfbm" property="cfbm" jdbcType="VARCHAR" />
		<result column="qybm" property="qybm" jdbcType="VARCHAR" />

		<result column="clgx" property="clgx" jdbcType="VARCHAR" />
		<result column="jgcl" property="jgcl" jdbcType="VARCHAR" />
		<result column="qmx" property="qmx" jdbcType="VARCHAR" />
		<result column="lqjs" property="lqjs" jdbcType="VARCHAR" />
		<result column="tfjs" property="tfjs" jdbcType="VARCHAR" />
		<result column="scjs" property="scjs" jdbcType="VARCHAR" />
		<result column="kwjs" property="kwjs" jdbcType="VARCHAR" />
		<result column="sjnx" property="sjnx" jdbcType="VARCHAR" />
		<result column="bgr" property="bgr" jdbcType="VARCHAR" />
		<result column="grcs" property="grcs" jdbcType="VARCHAR" />
		<result column="acceptance_qualified" property="acceptanceQualified" jdbcType="INTEGER" />
		<result column="real_estate_certificate" property="realEstateCertificate" jdbcType="INTEGER" />
		<result column="window_num" property="windowNum" jdbcType="INTEGER" />

		<result column="cwtcwj" property="cwtcwj" jdbcType="DECIMAL" />
		<result column="cntcnj" property="cntcnj" jdbcType="DECIMAL" />
		<result column="dlmxs" property="dlmxs" jdbcType="VARCHAR" />
		<result column="grxn" property="grxn" jdbcType="VARCHAR" />
		<result column="sfyjxxxhgz" property="sfyjxxxhgz" jdbcType="VARCHAR" />
		<result column="tfxtxs" property="tfxtxs" jdbcType="VARCHAR" />
		<result column="hcjcfs" property="hcjcfs" jdbcType="VARCHAR" />
		<result column="hwrl" property="hwrl" jdbcType="DECIMAL" />
		<result column="ajdh" property="ajdh" jdbcType="VARCHAR" />
		<result column="hwdm" property="hwdm" jdbcType="VARCHAR" />

		<result column="gfcfdm" property="gfcfdm" jdbcType="VARCHAR" />
		<result column="gfcfmc" property="gfcfmc" jdbcType="VARCHAR" />
		<result column="cnc" property="cnc" jdbcType="DECIMAL" />
		<result column="cnk" property="cnk" jdbcType="DECIMAL" />
		<result column="cnzlxg" property="cnzlxg" jdbcType="DECIMAL" />
		<result column="cntj" property="cntj" jdbcType="DECIMAL" />
		<result column="cwc" property="cwc" jdbcType="DECIMAL" />
		<result column="cwk" property="cwk" jdbcType="DECIMAL" />
		<result column="cwyg" property="cwyg" jdbcType="DECIMAL" />
		<result column="cwdg" property="cwdg" jdbcType="DECIMAL" />
		<result column="cnyg" property="cnyg" jdbcType="DECIMAL" />
		<result column="qtjg" property="qtjg" jdbcType="VARCHAR" />
		<result column="fdjg" property="fdjg" jdbcType="VARCHAR" />
		<result column="fjjg" property="fjjg" jdbcType="VARCHAR" />
		<result column="dmjg" property="dmjg" jdbcType="VARCHAR" />
		<result column="nfgrbw" property="nfgrbw" jdbcType="VARCHAR" />
		<result column="ywfsfqfczz" property="ywfsfqfczz" jdbcType="VARCHAR" />
		<result column="ywfhfbfdss" property="ywfhfbfdss" jdbcType="VARCHAR" />
		<result column="nffddyqtcl" property="nffddyqtcl" jdbcType="VARCHAR" />
		<result column="hcjcfs" property="hcjcfs" jdbcType="VARCHAR" />
		<result column="cfsfwh" property="cfsfwh" jdbcType="VARCHAR" />
		<result column="grbwcs" property="grbwcs" jdbcType="VARCHAR" />
		<result column="grain_type" property="grainType" jdbcType="VARCHAR" />
		<result column="sjdw" property="sjdw" jdbcType="VARCHAR" />
		<result column="jsdw" property="jsdw" jdbcType="VARCHAR" />
		<result column="jldw" property="jldw" jdbcType="VARCHAR" />
		<result column="sjsynx" property="sjsynx" jdbcType="VARCHAR" />
		<result column="cfqyrq" property="cfqyrq" jdbcType="DATE" />
        <result column="data_ver" property="dataVer" jdbcType="INTEGER" />
		<result column="cf_type" property="cfType" jdbcType="VARCHAR"/>
		<result column="package_type" property="packageType" jdbcType="VARCHAR"/>
	</resultMap>

    <resultMap id="DCfxxsjyVOMap" type="com.unis.base.common.vo.DCfxxsjyVO" extends="BaseResultMap">

    </resultMap>

    <sql id="Base_Column_List_common">
    	cf.cfbh, cf.gfcfdm, cf.gfcfmc as cfmc, cf.cfmc as cfmc01, cf.kddm, cf.cflx, cf.cfjg, cf.jzlx, cf.cfcd, cf.cfkd, cf.cfgd,
    	cf.sjcr, cf.sjcr01, cf.lxdh, cf.rybh, cf.ryxm, cf.cfqt, cf.cfyg, cf.cfwm, cf.cfdm,
    	cf.fwkd, cf.zlxgd, cf.tczj, cf.cmsl, cf.cmgd, cf.cmkd, cf.tffs, cf.grfs, cf.kwcs,
    	cf.jd, cf.wd, cf.qyrq, cf.cfzt, cf.jsnd, cf.dczlrj, cf.remark,
    	cf.cflxbh,cf.dwc,cf.cfyt, cf.qtyt, cf.cfnc,cf.cfnk,cf.cfnj,cf.ccfs,cf.bwm,cf.bwc,cf.scbwc,cf.wknkc,
		cf.cndd,cf.cdbwdd,cf.gcpjr,cf.cdwgrc,cf.bwqt,cf.bwtl,cf.zlsb,cf.dltf,cf.zltf,cf.dzcw,
		cf.zdllk,cf.hlxz,cf.cnhl,cf.sfba,cf.cfxh,cf.ajxh,cf.hwxh,cf.jssj,cf.jfsyrq,cf.fyfcxn,cf.mbscxn,
		cf.grblxn,cf.sfszcc,cf.ywlqckqk,cf.cfsyqk,cf.qthd,cf.cmmc,cf.qtgr,cf.shrmc,cf.shyj,cf.shsj,cf.tyshxydm,cf.chbw,
		cf.zlfj,cf.nfxlsc,cf.cnsxt,cf.dwclx,cf.ywjxtfss,cf.cfbm,cf.qybm,
        cf.clgx, cf.jgcl, cf.qmx, cf.lqjs, cf.tfjs, cf.scjs, cf.kwjs, cf.sjnx, cf.bgr,cf.hwxh,cf.ajxh,cf.grcs,
		cf.acceptance_qualified,cf.real_estate_certificate,cf.window_num, cwtcwj, cntcnj, dlmxs, grxn, sfyjxxxhgz,
		tfxtxs, hcjcfs, hwrl, ajdh, hwdm,cf.gfcfmc,cf.cnc,cf.cnk,cf.cnzlxg,cf.cntj,cf.cwc,cf.cwk,cf.cwyg,cf.cwdg,cf.cnyg,
		cf.qtjg,cf.fdjg,cf.fjjg,cf.dmjg,cf.nfgrbw,cf.ywfsfqfczz,cf.ywfhfbfdss,cf.nffddyqtcl,cf.cfsfwh,cf.grbwcs,cf.status,cf.grain_type,
		cf.sjdw,cf.jsdw,cf.jldw,cf.sjsynx,cf.cfqyrq,data_ver
    </sql>

	<!-- 根据信息获取唯一仓房 -->
	<select id="selectById" resultMap="BaseResultMap">
		SELECT
		<include refid="Base_Column_List_common"></include>
		from D_CFXXSJY cf
		<where>
			<choose>
				<when test='cfbh!=null and cfbh!=""'>
					AND cf.cfbh = #{cfbh,jdbcType=VARCHAR}
				</when>
				<when test='cfbm!=null and cfbm!=""'>
					AND cf.cfbm = #{cfbm,jdbcType=VARCHAR}
				</when>
				<otherwise>
					AND 1=0
				</otherwise>
			</choose>
			and cf.status = 1
		</where>
	</select>


	<!-- 根据条件查询仓房信息 -->
    <select id="getDCfxxxsjy" parameterType="com.unis.base.server.entity.DCfxxsjyDO" resultMap="BaseResultMap">
		SELECT
		<include refid="Base_Column_List_common"></include>,kd.kdmc,xx.lspzmc,xx.FCSL
		from
		D_CFXXSJY cf
		left join TY_LSKCXX xx on xx.sscfbh = cf.cfbh
		left join D_KDXXSJY kd on cf.KDDM = kd.KDDM
		<where>
			cf.status = 1
            <choose>
                <when test="grainType != null and grainType != ''">
                    and cf.grain_type = #{grainType, jdbcType=VARCHAR}
                </when>
                <otherwise>
                    and cf.grain_type = '0'
                </otherwise>
            </choose>
			<!-- 仓房编号 -->
			<if test="cfbh != null and cfbh != ''" >
				and	cf.cfbh LIKE concat(CONCAT('%',#{cfbh,jdbcType=VARCHAR}) ,'%')
			</if>
			<!-- 仓房名称 -->
			<if test="cfmc != null and cfmc != ''" >
				and	cf.cfmc LIKE concat(CONCAT('%',#{cfmc,jdbcType=VARCHAR}) ,'%')
			</if>
			<!-- 仓房类型 -->
			<if test="cflx != null and cflx != ''" >
				and	cf.cflx LIKE concat(CONCAT('%',#{cflx,jdbcType=VARCHAR}) ,'%')
			</if>
			<!-- 建筑类型 -->
			<if test="jzlx != null and jzlx != ''" >
				and	cf.jzlx LIKE concat(CONCAT('%',#{jzlx,jdbcType=VARCHAR}) ,'%')
			</if>
			<!-- 仓房状态 -->
			<if test="cfzt != null and cfzt != ''" >
				and	cf.cfzt LIKE concat(CONCAT('%',#{cfzt,jdbcType=VARCHAR}) ,'%')
			</if>
			<!-- 库点编号 -->
			<if test="kddm != null and kddm != ''" >
				and	cf.kddm LIKE concat(CONCAT('%',#{kddm,jdbcType=VARCHAR}) ,'%')
			</if>
			<!-- 库点名称 -->
			<if test="kdmc != null and kdmc != ''" >
				and	kd.kdmc LIKE concat(CONCAT('%',#{kdmc,jdbcType=VARCHAR}) ,'%')
			</if>
			<if test="cfxh != null and cfxh != ''" >
				and	cf.cfxh =#{cfxh,jdbcType=VARCHAR}
			</if>
			<if test="ajxh != null and ajxh != ''" >
				and	cf.ajxh =#{ajxh,jdbcType=VARCHAR}
			</if>
			<if test="hwxh != null and hwxh != ''" >
				and	cf.hwxh =#{hwxh,jdbcType=VARCHAR}
			</if>
			<!-- 是否备案 -->
			<if test='sfba != null'>
				and cf.SFBA = #{sfba,jdbcType=DECIMAL}
			</if>
			<if test='jssj !=null'>
				and DATE_FORMAT(cf.jssj,'%Y-%m-%d')=#{cxsj}
			</if>
			<if test='tyshxydm !=null'>
				and cf.tyshxydm=#{tyshxydm}
			</if>
			<if test='qybm !=null'>
				and cf.qybm=#{qybm}
			</if>
			<if test='zts !=null'>
				and cf.SFBA in
				<foreach collection="zts" item="zt" open="(" close=")" separator=",">
					#{zt}
				</foreach>
			</if>
		</where>
		ORDER BY cf.CFBH desc
	</select>

    <select id="getDCfxxxsjy_ver2" parameterType="com.unis.base.server.entity.DCfxxsjyDO" resultMap="BaseResultMap">
        select * from (
            SELECT
            <include refid="Base_Column_List_common"/>,kd.kdmc,xx.lspzmc,xx.FCSL,
            d.dict_name as cflx,
            e.dict_name as cfzt,
            e2.dict_name as cfyt,
            ROW_NUMBER() OVER (PARTITION BY cf.gfcfdm ORDER BY cast(cf.cfxh as SIGNED), cf.cfbh) as rn
            from D_CFXXSJY cf
            left join TY_LSKCXX xx on xx.sscfbh = cf.cfbh
            left join D_KDXXSJY kd on cf.KDDM = kd.KDDM
            left join usercenter.sys_dictionary d on d.dict_code=cf.cflx and d.group_id='CFLX'
            left join usercenter.sys_dictionary e on e.dict_code=cf.cfzt and e.group_id='CFZT'
            left join usercenter.sys_dictionary e2 on e2.dict_code=cf.cfyt and e2.group_id='CFYT'
            <where>
                <if test="grainType != null and grainType != ''">
                    and cf.grain_type = #{grainType, jdbcType=VARCHAR}
                </if>
                <!-- 仓房编号 -->
                <if test="cfbh != null and cfbh != ''" >
                    and	cf.cfbh LIKE concat(CONCAT('%',#{cfbh,jdbcType=VARCHAR}) ,'%')
                </if>
                <!-- 仓房名称 -->
                <if test="cfmc != null and cfmc != ''" >
                    and	cf.cfmc LIKE concat(CONCAT('%',#{cfmc,jdbcType=VARCHAR}) ,'%')
                </if>
                <!-- 仓房类型 -->
                <if test="cflx != null and cflx != ''" >
                    and	cf.cflx LIKE concat(CONCAT('%',#{cflx,jdbcType=VARCHAR}) ,'%')
                </if>
                <!-- 建筑类型 -->
                <if test="jzlx != null and jzlx != ''" >
                    and	cf.jzlx LIKE concat(CONCAT('%',#{jzlx,jdbcType=VARCHAR}) ,'%')
                </if>
                <!-- 仓房状态 -->
                <if test="cfzt != null and cfzt != ''" >
                    and	cf.cfzt LIKE concat(CONCAT('%',#{cfzt,jdbcType=VARCHAR}) ,'%')
                </if>
                <!-- 库点编号 -->
                <if test="kddm != null and kddm != ''" >
                    and	cf.kddm LIKE concat(CONCAT('%',#{kddm,jdbcType=VARCHAR}) ,'%')
                </if>
                <!-- 库点名称 -->
                <if test="kdmc != null and kdmc != ''" >
                    and	kd.kdmc LIKE concat(CONCAT('%',#{kdmc,jdbcType=VARCHAR}) ,'%')
                </if>
                <if test="cfxh != null and cfxh != ''" >
                    and	cf.cfxh =#{cfxh,jdbcType=VARCHAR}
                </if>
                <!-- 是否备案 -->
                <if test='sfba != null'>
                    and cf.SFBA = #{sfba,jdbcType=DECIMAL}
                </if>
                <if test='jssj !=null'>
                    and DATE_FORMAT(cf.jssj,'%Y-%m-%d')=#{cxsj}
                </if>
                <if test='tyshxydm !=null'>
                    and cf.tyshxydm=#{tyshxydm}
                </if>
                <if test='qybm !=null'>
                    and cf.qybm = #{qybm}
                </if>
                <if test='zts !=null'>
                    and cf.SFBA in
                    <foreach collection="zts" item="zt" open="(" close=")" separator=",">
                        #{zt}
                    </foreach>
                </if>
            </where>
            ORDER BY cast(cf.cfxh as SIGNED), cfbh
        ) t1
        where t1.rn = 1
        ORDER BY cast(t1.cfxh as SIGNED), t1.cfbh
    </select>

<!--            <if test="status != null" >-->
<!--                and cf.status = #{status,jdbcType=INTEGER}-->
<!--            </if>-->
    <select id="listGfcfdm" parameterType="com.unis.base.server.entity.DCfxxsjyDO" resultType="java.lang.String">
        select gfcfdm from D_CFXXSJY cf
        <where>
            <if test="grainType != null and grainType != ''">
                and cf.grain_type = #{grainType, jdbcType=VARCHAR}
            </if>
            <!-- 仓房编号 -->
            <if test="cfbh != null and cfbh != ''" >
                and	cf.cfbh LIKE concat(CONCAT('%',#{cfbh,jdbcType=VARCHAR}) ,'%')
            </if>
            <!-- 仓房名称 -->
            <if test="cfmc != null and cfmc != ''" >
                and	cf.cfmc LIKE concat(CONCAT('%',#{cfmc,jdbcType=VARCHAR}) ,'%')
            </if>
            <!-- 仓房类型 -->
            <if test="cflx != null and cflx != ''" >
                and	cf.cflx LIKE concat(CONCAT('%',#{cflx,jdbcType=VARCHAR}) ,'%')
            </if>
            <!-- 建筑类型 -->
            <if test="jzlx != null and jzlx != ''" >
                and	cf.jzlx LIKE concat(CONCAT('%',#{jzlx,jdbcType=VARCHAR}) ,'%')
            </if>
            <!-- 仓房状态 -->
            <if test="cfzt != null and cfzt != ''" >
                and	cf.cfzt LIKE concat(CONCAT('%',#{cfzt,jdbcType=VARCHAR}) ,'%')
            </if>
            <!-- 库点编号 -->
            <if test="kddm != null and kddm != ''" >
                and	cf.kddm LIKE concat(CONCAT('%',#{kddm,jdbcType=VARCHAR}) ,'%')
            </if>
            <!-- 库点名称 -->
            <if test="kdmc != null and kdmc != ''" >
                and	kd.kdmc LIKE concat(CONCAT('%',#{kdmc,jdbcType=VARCHAR}) ,'%')
            </if>
            <if test="cfxh != null and cfxh != ''" >
                and	cf.cfxh =#{cfxh,jdbcType=VARCHAR}
            </if>
            <!-- 是否备案 -->
            <if test='sfba != null'>
                and cf.SFBA = #{sfba,jdbcType=DECIMAL}
            </if>
            <if test='jssj !=null'>
                and DATE_FORMAT(cf.jssj,'%Y-%m-%d')=#{cxsj}
            </if>
            <if test='tyshxydm !=null'>
                and cf.tyshxydm=#{tyshxydm}
            </if>
            <if test='qybm !=null'>
                and cf.qybm = #{qybm}
            </if>
            <if test='zts !=null'>
                and cf.SFBA in
                <foreach collection="zts" item="zt" open="(" close=")" separator=",">
                    #{zt}
                </foreach>
            </if>
        </where>
        group by gfcfdm
        ORDER BY cast(min(cfxh) as SIGNED)
    </select>

	<!-- 根据条件查询仓房信息 成品粮-->
    <select id="getDCfxxxsjyList" parameterType="com.unis.base.server.entity.DCfxxsjyDO" resultMap="BaseResultMap">
        SELECT
		<include refid="Base_Column_List_common"></include>,kd.kdmc,(select enumname from depot_qh.basic_enum where enumid=xx.pzbm) as lspzmc,xx.kcsl as fcsl,
		date_format(rksj,'%Y%m') as rcny,lq1.outtemp as cfww,lq1.outh as cfws,lq1.intemp as cfnw,lq1.inh as cfns
 		from
			D_CFXXSJY cf
			left join up.xwk_kcxx xx on xx.hwbm = cf.cfbm
			left join D_KDXXSJY kd on cf.KDDM = kd.KDDM
			left join (
		select td.intemp,td.inh,td.outtemp,td.outh,lq.hwbm from

		(select a.id as id, a.t_time as times,a.intemp,a.inh,
		a.outtemp,a.outh,a.t_max as tMax,
		ws.hwbm
		from depot_qh.t_testdata a, depot.basic_warehouse  ws, depot.basic_storehouse b1
		where b1.storehouse_code = a.storehouse
		and ws.storehouse_id = b1.storehouse_id
		and a.org_id = b1.org_id and ws.hwbm is not null
		) td
		inner join
		(select lw.hwbm,max(tTime) as t_times from
		(select c.id as id, c.t_time as tTime,c.intemp,c.inh,
		c.outtemp,c.outh,c.t_max as tMax,
		w.hwbm
		from depot.t_testdata c, depot.basic_warehouse  w, depot.basic_storehouse b
		where b.storehouse_code = c.storehouse
		and w.storehouse_id = b.storehouse_id
		and c.org_id = b.org_id and w.hwbm is not null
		) lw group by lw.hwbm) lq on lq.hwbm = td.hwbm and lq.t_times = td.times
			) lq1 on cf.cfbm=lq1.hwbm
		<where>
			cf.status = 1
			<!-- 仓房编号 -->
	    	<if test="cfbh != null and cfbh != ''" >
	         	and	cf.cfbh LIKE concat(CONCAT('%',#{cfbh,jdbcType=VARCHAR}) ,'%')
	      	</if>
	      	<!-- 仓房名称 -->
	    	<if test="cfmc != null and cfmc != ''" >
	         	and	cf.cfmc LIKE concat(CONCAT('%',#{cfmc,jdbcType=VARCHAR}) ,'%')
	      	</if>
	      	<!-- 仓房类型 -->
	    	<if test="cflx != null and cflx != ''" >
	         	and	cf.cflx LIKE concat(CONCAT('%',#{cflx,jdbcType=VARCHAR}) ,'%')
	      	</if>
	      	<!-- 建筑类型 -->
	    	<if test="jzlx != null and jzlx != ''" >
	         	and	cf.jzlx LIKE concat(CONCAT('%',#{jzlx,jdbcType=VARCHAR}) ,'%')
	      	</if>
	      	<!-- 仓房状态 -->
	    	<if test="cfzt != null and cfzt != ''" >
	         	and	cf.cfzt LIKE concat(CONCAT('%',#{cfzt,jdbcType=VARCHAR}) ,'%')
	      	</if>
	      	<!-- 库点编号 -->
	    	<if test="kddm != null and kddm != ''" >
	         	and	cf.kddm LIKE concat(CONCAT('%',#{kddm,jdbcType=VARCHAR}) ,'%')
	      	</if>
	      	<!-- 库点名称 -->
	    	<if test="kdmc != null and kdmc != ''" >
	         	and	kd.kdmc LIKE concat(CONCAT('%',#{kdmc,jdbcType=VARCHAR}) ,'%')
	      	</if>

	      	<if test="cfxh != null and cfxh != ''" >
	         	and	cf.cfxh =#{cfxh,jdbcType=VARCHAR}
	      	</if>

	      	<if test="ajxh != null and ajxh != ''" >
	         	and	cf.ajxh =#{ajxh,jdbcType=VARCHAR}
	      	</if>

	      	<if test="hwxh != null and hwxh != ''" >
	         	and	cf.hwxh =#{hwxh,jdbcType=VARCHAR}
	      	</if>

			<!-- 是否备案 -->
			<if test='sfba != null'>
				and cf.SFBA = #{sfba,jdbcType=DECIMAL}
			</if>

			<if test='jssj !=null'>

			    and DATE_FORMAT(cf.jssj,'%Y-%m-%d')=#{cxsj}

			</if>

			<if test='tyshxydm !=null'>

			    and cf.tyshxydm=#{tyshxydm}

			</if>
			<if test='qybm !=null'>

				and cf.qybm=#{qybm}

			</if>
			<if test='zts !=null'>
			     and cf.SFBA in
			<foreach collection="zts" item="zt" open="(" close=")" separator=",">
		                #{zt}
		   </foreach>

			</if>


		</where>
		ORDER BY cf.CFBH desc
    </select>

    <!-- 根据条件查询仓房信息 成品粮-->
    <select id="getChengPinList" parameterType="com.unis.base.server.entity.DCfxxsjyDO" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List_common">
        </include>,
		kd.kdmc,
		concat(cf.gfcfmc,',',cf.cfmc) as cfmc,
		(select enumname from depot_qh.basic_enum where enumid=xx.pzbm) as lspzmc,xx.kcsl as fcsl,
		date_fromat(rksj,'%Y%m') as rcny,lq1.outtemp as cfww,lq1.outh as cfws,lq1.intemp as cfnw,lq1.inh as cfns,package_type,
		case lq1.datatype when '0' then '仓房' when '1' then '油罐' end cf_type
		from
		base.D_CFXXSJY cf
		left join up.xwk_kcxx xx
		on xx.hwbm = cf.cfbm
		left join base.D_KDXXSJY kd on cf.KDDM = kd.KDDM
		left join (
		select td.intemp,td.inh,td.outtemp,td.outh,lq.hwbm,td.datatype from
		(select a.id as id, a.t_time as times,a.intemp,a.inh,
		a.outtemp,a.outh,a.t_max as tMax,
		ws.hwbm, b1.datatype
		from depot_qh.t_testdata a, depot_qh.basic_warehouse ws, depot_qh.basic_storehouse b1
		where b1.storehouse_code = a.storehouse
		and ws.storehouse_id = b1.storehouse_id
		and a.org_id = b1.org_id and ws.hwbm is not null
		) td
		inner join
		(select lw.hwbm, max (tTime) as t_times from
		(select c.id as id, c.t_time as tTime, c.intemp, c.inh,
		c.outtemp, c.outh, c.t_max as tMax,
		w.hwbm
		from depot_qh.t_testdata c, depot_qh.basic_warehouse w, depot_qh.basic_storehouse b
		where b.storehouse_code = c.storehouse
		and w.storehouse_id = b.storehouse_id
		and c.org_id = b.org_id and w.hwbm is not null
		) lw group by lw.hwbm) lq on lq.hwbm = td.hwbm and lq.t_times = td.times
		) lq1 on cf.cfbm=lq1.hwbm
		left join (
		select
		a.house_id,a.warehouse_id,cfbm,
		case c.storage when '1' then '包装垛存' when '2' then '散存' when '3' then '油罐' end package_type
		from depot_qh.storage_product_kcsl a
		left join depot_qh.basic_storehouse b on b.storehouse_id=a.house_id
		left join (
		select fcbgz.house_id,fcbgz.warehouse_id,fcbgz.lspz,fcbgz.storage from (
		select *, Row_Number() OVER (partition by house_id,warehouse_id,lspz order by record_date desc) as "rank" from depot_qh.storage_product_fcbgz
		where 1=1 and zylx='0' and lspz in (7050, 7052)
		) as fcbgz
		where 1=1
		and fcbgz.rank=1
		) c on c.house_id=a.house_id
		where a.lypz in (7050, 7052)) ff on ff.cfbm = cf.cfbm
        <where>
            cf.status = 1
            and xx.lsxzbm='6877'
            <!--  and xx.hwzt!=1 and xx.hwzt!=2 and xx.hwzt!=4 -->
            <!-- 仓房编号 -->
            <if test="cfbh != null and cfbh != ''">
                and cf.cfbh LIKE concat(CONCAT('%'
                  , #{cfbh,jdbcType=VARCHAR})
                  , '%')
            </if>
            <!-- 仓房名称 -->
            <if test="cfmc != null and cfmc != ''">
                and cf.cfmc LIKE concat(CONCAT('%'
                  , #{cfmc,jdbcType=VARCHAR})
                  , '%')
            </if>
            <!-- 仓房类型 -->
            <if test="cflx != null and cflx != ''">
                and cf.cflx LIKE concat(CONCAT('%'
                  , #{cflx,jdbcType=VARCHAR})
                  , '%')
            </if>
            <!-- 建筑类型 -->
            <if test="jzlx != null and jzlx != ''">
                and cf.jzlx LIKE concat(CONCAT('%'
                  , #{jzlx,jdbcType=VARCHAR})
                  , '%')
            </if>
            <!-- 仓房状态 -->
            <if test="cfzt != null and cfzt != ''">
                and cf.cfzt LIKE concat(CONCAT('%'
                  , #{cfzt,jdbcType=VARCHAR})
                  , '%')
            </if>
            <!-- 库点编号 -->
            <if test="kddm != null and kddm != ''">
                and cf.kddm LIKE concat(CONCAT('%'
                  , #{kddm,jdbcType=VARCHAR})
                  , '%')
            </if>
            <!-- 库点名称 -->
            <if test="kdmc != null and kdmc != ''">
                and kd.kdmc LIKE concat(CONCAT('%'
                  , #{kdmc,jdbcType=VARCHAR})
                  , '%')
            </if>

            <if test="cfxh != null and cfxh != ''">
                and cf.cfxh =#{cfxh,jdbcType=VARCHAR}
            </if>

            <if test="ajxh != null and ajxh != ''">
                and cf.ajxh =#{ajxh,jdbcType=VARCHAR}
            </if>

            <if test="hwxh != null and hwxh != ''">
                and cf.hwxh =#{hwxh,jdbcType=VARCHAR}
            </if>

            <!-- 是否备案 -->
            <if test='sfba != null'>
                and cf.SFBA = #{sfba,jdbcType=DECIMAL}
            </if>

            <if test='jssj != null'>
                and DATE_FORMAT(cf.jssj
                  , '%Y-%m-%d')=#{cxsj}
            </if>

            <if test='tyshxydm != null'>
                and cf.tyshxydm=#{tyshxydm}
            </if>
            <if test='qybm != null'>
                and cf.qybm=#{qybm}
            </if>
            <if test='zts != null'>
                and cf.SFBA in
                <foreach collection="zts" item="zt" open="(" close=")" separator=",">
                    #{zt}
                </foreach>
            </if>
        </where>
        ORDER BY cf.CFBH desc
    </select>

	<!-- 根据条件查询仓房信息 原粮-->
	<select id="getYuanLiangList" resultType="com.unis.base.common.vo.BaseKcVO" >
		select cf.cfbh, cf.gfcfmc as cfmc,cf.cflx as cfxh,kc.ND as shnd,kc.pzbm as lspz,kc.rksj,kc.kcsl,kc.lslb,kc.cfzt as zyzt,kc.hwzt,kc.LSXZBMmc,kc.LSXZBM,
		(select
		zj.jyjg
		from
		quality.wt wt,
		quality.zjbg bg,
		quality.ty_zjxxzb zj
		where wt.sscfbh = cf.cfbh
		and wt.zjbh = '强检'
		and wt.id = bg.wtid
		and bg.zjbgbh = zj.zjbgbh
		and wt.wtsj = (select max(wt.wtsj) from  quality.wt wt where wt.sscfbh = cf.cfbh and wt.zjbh = '强检' and wt.id in (select bg.wtid from quality.zjbg bg))) as zl
		from base.D_CFXXSJY cf
		left join
		(select  KCXXID, k.HWBM, ND, QJ, lsxzbm,hwzt,
		(select enumname from up.basic_enum where enumid= k.pzbm) as pzbm,
        (select enumname from up.basic_enum where enumid= k.lsxzbm)  as LSXZBMMC,
		(select enumname from up.basic_enum where enumid= k.DJBM) as DJBM,
		RKSJ, SHND, FCSJ, FCSL, KCSL, (case when k.hwzt = '1' then '空仓' when k.hwzt = '2' then '入库' when k.hwzt = '4' then '出库' else '满仓' end) as cfzt,
		(select distinct  enumitemname from up.enumitem where  enumitemid=k.gb) as gb,k.lslb,c.zyzt
		from up.xwk_kcxx k,
		(
		SELECT
		ware.hwbm,case when count(task.id)>0 then '通风' when count(plan.id)>0 then '熏蒸' when count(notice.id)>0 then '入库' when count(notice1.id)>0 then '出库' else '无' end as zyzt
		FROM
		depot_qh.basic_warehouse ware
		LEFT JOIN depot_qh.storage_aeration_task_record task ON task.house_id = ware.storehouse_id AND task.task_end_time IS NULL
		LEFT JOIN depot_qh.t_fumigation_plan plan ON ware.storehouse_id = plan.house_id AND plan.state = '5'
		LEFT JOIN depot_qh.business_store_ware_detail detail ON detail.house_id = ware.storehouse_id AND type = 'notice'
		LEFT JOIN depot_qh.business_delivery_storage_notice notice ON detail.zid = notice.id AND notice.bill_type = 1 AND notice.in_application = '1'
		LEFT JOIN depot_qh.business_delivery_storage_notice notice1 ON detail.zid = notice.id AND notice.bill_type = 3 AND notice.in_application = '1'
		GROUP BY
		ware.hwbm
		) c
		where k.hwbm = c.hwbm
		<!--and k.lsxzbm = '6877'-->
		) kc on cf.cfbm = kc.hwbm
		where
		<!--kc.lslb = '0'  and kc.lsxzbm='6877' and-->
		cf.status=1  and kc.hwzt!=1
		and cf.cfbh like CONCAT(CONCAT('%',#{tyshxydm, jdbcType=VARCHAR}) ,'%')
		order by hwbm asc
	</select>

    <select id="getDCfxxxsjyInfo" parameterType="java.lang.String" resultMap="BaseResultMap">
        SELECT
		<include refid="Base_Column_List_common"></include>,kd.kdmc,xx.lspzmc,xx.FCSL,
		date_format(rksj,'%Y%m') as rcny,lq.cfww,lq.cfws,lq.cfnw,lq.cfns
 		from
			D_CFXXSJY cf
			left join TY_LSKCXX xx on xx.sscfbh = cf.cfbh
			left join D_KDXXSJY kd on cf.KDDM = kd.KDDM
		    left join (
				select lq.cfbh,lq.cfww,lq.cfws,lq.cfnw,lq.cfns
				from ty_lqxx lq inner join (
					select cfbh,max(JCSJ) as jcsj from ty_lqxx group by cfbh
				) mxlq on lq.cfbh=mxlq.cfbh and lq.jcsj=mxlq.jcsj
			) lq on cf.cfbh=lq.cfbh
		<where>
			cf.cfbh = #{cfbh,jdbcType=VARCHAR}
			and cf.status = 1
		</where>
    </select>

    <!--根据仓房编号获取仓房信息-任何状态-->
    <select id="getWarehouseInfo" parameterType="java.lang.String" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List_common"></include>
        from
        D_CFXXSJY cf
        <where>
            cf.cfbh = #{cfbh,jdbcType=VARCHAR}
        </where>
    </select>

	<!-- 根据库点代码获取仓房列表 -->
	<select id="getWarehouseListByKddm" parameterType="java.lang.String" resultMap="BaseResultMap">
		SELECT
		<include refid="Base_Column_List_common"></include>
		from
		D_CFXXSJY cf
		<where>
			cf.kddm like CONCAT(#{kddm,jdbcType=VARCHAR},'%')
			and cf.status = 1
		    and cf.sfba = 5
		    <if test="grainType != null and grainType !=''">
				and cf.grain_type = #{grainType}
			</if>
		</where>
		ORDER BY cf.gfcfdm asc
	</select>

	<sql id="cfxxSql">
		SELECT
        <include refid="Base_Column_List_common"></include>,
        d.kqdm,cf.send_result, cf.data_ver as dataVer, cf.change_reason changeReason
		from
		D_CFXXSJY cf
		left join
		D_KDXXSJY d on cf.kddm=d.kddm
	</sql>

	<select id="selectByEntity"  resultType="com.unis.base.common.vo.DCfxxsjyVO">
		<include refid="cfxxSql"></include>
		<where>
			<if test='kddm!=null and kddm!=""'>
				AND cf.kddm like CONCAT(#{kddm,jdbcType=VARCHAR},'%')
			</if>
			<if test='sfba!=null and sfba!=""'>
				AND cf.sfba =  #{sfba,jdbcType=DECIMAL}
			</if>
			<if test='cfxh!=null and cfxh!=""'>
				AND cf.cfxh =  #{cfxh,jdbcType=VARCHAR}
			</if>
			<if test='cfbh!=null and cfbh!=""'>
				AND cf.cfbh =  #{cfbh,jdbcType=VARCHAR}
			</if>
			<if test='hwxh!=null and hwxh!=""'>
				AND cf.hwxh =  #{hwxh,jdbcType=VARCHAR}
			</if>
			<if test='gfcfdm!=null and gfcfdm!=""'>
				AND cf.gfcfdm =  #{gfcfdm,jdbcType=VARCHAR}
			</if>
			<if test="zts == null">
				AND cf.status = 1
			</if>
		</where>
		ORDER BY cf.gfcfdm asc
	</select>

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

	<!-- 更新企业信息 -->
	<update id="update" parameterType="com.unis.base.server.entity.DCfxxsjyDO">
		update D_CFXXSJY
        <set>
            <if test="cfmc != null">
                cfmc = #{cfmc,jdbcType=VARCHAR},
            </if>
            <if test="kddm != null">
                kddm = #{kddm,jdbcType=VARCHAR},
            </if>
            <if test="cflx != null">
                cflx = #{cflx,jdbcType=VARCHAR},
            </if>
            <if test="cfjg != null">
                cfjg = #{cfjg,jdbcType=VARCHAR},
            </if>
            <if test="jzlx != null">
                jzlx = #{jzlx,jdbcType=VARCHAR},
            </if>
            <if test="cfcd != null">
                cfcd = #{cfcd,jdbcType=VARCHAR},
            </if>
            <if test="cfkd != null">
                cfkd = #{cfkd,jdbcType=VARCHAR},
            </if>
            <if test="cfgd != null">
                cfgd = #{cfgd,jdbcType=VARCHAR},
            </if>
            <if test="sjcr != null">
                sjcr = #{sjcr,jdbcType=VARCHAR},
            </if>
            <if test="sjcr01 != null">
                sjcr01 = #{sjcr01,jdbcType=VARCHAR},
            </if>
            <if test="lxdh != null">
                lxdh = #{lxdh,jdbcType=VARCHAR},
            </if>
            <if test="rybh != null">
                rybh = #{rybh,jdbcType=VARCHAR},
            </if>
            <if test="ryxm != null">
                ryxm = #{ryxm,jdbcType=VARCHAR},
            </if>
            <if test="cfqt != null">
                cfqt = #{cfqt,jdbcType=VARCHAR},
            </if>
            <if test="cfyg != null">
                cfyg = #{cfyg,jdbcType=DECIMAL},
            </if>
            <if test="cfwm != null">
                cfwm = #{cfwm,jdbcType=VARCHAR},
            </if>
            <if test="cfdm != null">
                cfdm = #{cfdm,jdbcType=VARCHAR},
            </if>
            <if test="fwkd != null">
                fwkd = #{fwkd,jdbcType=DECIMAL},
            </if>
            <if test="zlxgd != null">
                zlxgd = #{zlxgd,jdbcType=DECIMAL},
            </if>
            <if test="tczj != null">
                tczj = #{tczj,jdbcType=DECIMAL},
            </if>
            <if test="cmsl != null">
                cmsl = #{cmsl,jdbcType=DECIMAL},
            </if>
            <if test="cmgd != null">
                cmgd = #{cmgd,jdbcType=DECIMAL},
            </if>
            <if test="cmkd != null">
                cmkd = #{cmkd,jdbcType=DECIMAL},
            </if>
            <if test="tffs != null">
                tffs = #{tffs,jdbcType=VARCHAR},
            </if>
            <if test="grfs != null">
                grfs = #{grfs,jdbcType=VARCHAR},
            </if>
            <if test="kwcs != null">
                kwcs = #{kwcs,jdbcType=VARCHAR},
            </if>
            <if test="jd != null">
                jd = #{jd,jdbcType=VARCHAR},
            </if>
            <if test="wd != null">
                wd = #{wd,jdbcType=VARCHAR},
            </if>
            <if test="qyrq != null">
                qyrq = #{qyrq,jdbcType=VARCHAR},
            </if>
            <if test="cfzt != null">
                cfzt = #{cfzt,jdbcType=VARCHAR},
            </if>
            <if test="jsnd != null">
                jsnd = #{jsnd,jdbcType=VARCHAR},
            </if>
            <if test="dczlrj != null">
                dczlrj = #{dczlrj,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=" cflxbh != null">
                cflxbh = #{ cflxbh, jdbcType=VARCHAR},
            </if>
            <if test=" dwc != null">
                dwc = #{dwc,jdbcType=INTEGER},
            </if>
            <if test=" cfyt != null">
                cfyt = #{ cfyt , jdbcType=VARCHAR},
            </if>
			<if test=" qtyt != null">
				qtyt = #{ qtyt , jdbcType=VARCHAR},
            </if>
            <if test=" cfnc != null">
                cfnc = #{ cfnc, jdbcType=INTEGER},
            </if>
            <if test=" cfnk != null">
                cfnk = #{ cfnk, jdbcType=INTEGER},
            </if>
            <if test=" cfnj != null">
                cfnj = #{ cfnj, jdbcType=INTEGER},
            </if>
            <if test=" ccfs != null">
                ccfs = #{ ccfs, jdbcType=VARCHAR},
            </if>
            <if test=" bwm != null">
                bwm = #{ bwm, jdbcType=INTEGER},
            </if>
            <if test=" bwc != null">
                bwc = #{ bwc, jdbcType=INTEGER},
            </if>
            <if test=" scbwc != null">
                scbwc = #{ scbwc, jdbcType=INTEGER},
            </if>
            <if test=" wknkc != null">
                wknkc = #{ wknkc, jdbcType=INTEGER},
            </if>
            <if test=" cndd != null">
                cndd = #{ cndd, jdbcType=INTEGER},
            </if>
            <if test=" cdbwdd != null">
                cdbwdd = #{ cdbwdd, jdbcType=INTEGER},
            </if>
            <if test=" gcpjr != null">
                gcpjr = #{ gcpjr, jdbcType=INTEGER},
            </if>
            <if test=" cdwgrc != null">
                cdwgrc = #{cdwgrc, jdbcType=INTEGER},
            </if>
            <if test="bwqt  != null">
                bwqt = #{ bwqt, jdbcType=INTEGER},
            </if>
            <if test=" bwtl != null">
                bwtl = #{ bwtl, jdbcType=INTEGER},
            </if>
            <if test=" zlsb != null">
                zlsb = #{ zlsb, jdbcType=INTEGER},
            </if>
            <if test=" dltf != null">
                dltf = #{ dltf, jdbcType=INTEGER},
            </if>
            <if test=" zltf != null">
                zltf = #{ zltf, jdbcType=INTEGER},
            </if>
            <if test=" dzcw != null">
                dzcw = #{ dzcw, jdbcType=INTEGER},
            </if>
            <if test=" zdllk != null">
                zdllk = #{ zdllk, jdbcType=INTEGER},
            </if>
            <if test=" hlxz != null">
                hlxz = #{ hlxz, jdbcType=INTEGER},
            </if>
            <if test=" cnhl != null">
                cnhl = #{ cnhl, jdbcType=INTEGER},
            </if>
            <if test=" sfba != null">
                sfba = #{ sfba, jdbcType=DECIMAL},
            </if>
            <if test=" cfxh != null">
                cfxh = #{ cfxh, jdbcType=VARCHAR},
            </if>
            <if test=" ajxh != null">
                ajxh = #{ ajxh, jdbcType=VARCHAR},
            </if>
            <if test=" hwxh != null">
                hwxh = #{ hwxh, jdbcType=VARCHAR},
            </if>
            <if test=" jssj != null">
                jssj = #{ jssj, jdbcType=DATE},
            </if>
            <if test=" jfsyrq != null">
                jfsyrq = #{ jfsyrq, jdbcType=DATE},
            </if>
            <if test=" fyfcxn != null">
                fyfcxn = #{ fyfcxn, jdbcType=VARCHAR},
            </if>
            <if test=" mbscxn != null">
                mbscxn = #{ mbscxn, jdbcType=VARCHAR},
            </if>
            <if test=" grblxn != null">
                grblxn = #{ grblxn, jdbcType=VARCHAR},
            </if>
            <if test=" sfszcc != null">
                sfszcc = #{ sfszcc, jdbcType=DECIMAL},
            </if>
            <if test=" ywlqckqk != null">
                ywlqckqk = #{ ywlqckqk, jdbcType=DECIMAL},
            </if>
            <if test=" cfsyqk != null">
                cfsyqk = #{ cfsyqk, jdbcType=DECIMAL},
            </if>
            <if test=" qthd != null">
                qthd = #{ qthd, jdbcType=DECIMAL},
            </if>
            <if test=" cmmc != null">
                cmmc = #{ cmmc, jdbcType=VARCHAR},
            </if>
            <if test=" qtgr != null">
                qtgr = #{ qtgr, jdbcType=DECIMAL},
            </if>
            <if test=" shrmc != null">
                shrmc = #{ shrmc, jdbcType=VARCHAR},
            </if>
            <if test=" shyj != null">
                shyj = #{ shyj, jdbcType=VARCHAR},
            </if>
            <if test=" shsj != null">
                shsj = #{ shsj, jdbcType=DATE},
            </if>
            <if test=" tyshxydm != null">
                tyshxydm = #{ tyshxydm, jdbcType=DATE},
            </if>
            <if test=" chbw != null">
                chbw = #{ chbw, jdbcType=INTEGER},
            </if>
            <if test=" zlfj != null">
                zlfj = #{ zlfj, jdbcType=INTEGER},
            </if>
            <if test=" nfxlsc != null">
                nfxlsc = #{ nfxlsc, jdbcType=INTEGER},
            </if>
            <if test=" cnsxt != null">
                cnsxt = #{ cnsxt, jdbcType=INTEGER},
            </if>
            <if test=" dwclx != null">
                dwclx = #{ dwclx, jdbcType=INTEGER},
            </if>
            <if test=" ywjxtfss != null">
                ywjxtfss = #{ ywjxtfss, jdbcType=INTEGER},
            </if>
            <if test="clgx != null">
                clgx= #{clgx, jdbcType=VARCHAR},
            </if>
            <if test="jgcl != null">
                jgcl= #{jgcl, jdbcType=VARCHAR},
            </if>
            <if test="qmx != null">
                qmx= #{qmx, jdbcType=VARCHAR},
            </if>
            <if test="lqjs != null">
                lqjs= #{lqjs, jdbcType=VARCHAR},
            </if>
            <if test="tfjs != null">
                tfjs= #{tfjs, jdbcType=VARCHAR},
            </if>
            <if test=" scjs != null">
                scjs = #{scjs, jdbcType=VARCHAR},
            </if>
            <if test="kwjs != null">
                kwjs = #{kwjs, jdbcType=VARCHAR},
            </if>
            <if test="sjnx != null">
                sjnx = #{sjnx, jdbcType=VARCHAR},
            </if>
            <if test="bgr != null">
                bgr = #{bgr, jdbcType=VARCHAR},
            </if>
            <if test="grcs != null">
                grcs = #{grcs, jdbcType=VARCHAR},
            </if>
            <if test="cwtcwj != null ">
                cwtcwj = #{cwtcwj, jdbcType=DECIMAL},
            </if>
            <if test="cntcnj != null ">
                cntcnj = #{cntcnj, jdbcType=DECIMAL},
            </if>
			<if test="hwrl != null">
				hwrl = #{hwrl, jdbcType=DECIMAL},
			</if>
			<if test="gfcfdm != null">
				gfcfdm = #{gfcfdm, jdbcType=VARCHAR},
			</if>
			<if test="gfcfmc != null">
				gfcfmc = #{gfcfmc, jdbcType=VARCHAR},
			</if>
			<if test="status != null">
				status = #{status, jdbcType=DECIMAL},
			</if>
			<if test="refreshTime != null">
				refresh_time = #{refreshTime,jdbcType=TIMESTAMP},
			</if>
        </set>
		<where>
			cfbh = #{cfbh,jdbcType=VARCHAR}
		</where>
	</update>

	<update id="updateAll" parameterType="com.unis.base.server.entity.DCfxxsjyDO">
	    update D_CFXXSJY
		set cfmc = #{cfmc}, kddm = #{kddm}, cflx = #{cflx}, cfjg = #{cfjg},
		jzlx = #{jzlx}, cfcd = #{cfcd}, cfkd = #{cfkd}, cfgd = #{cfgd}, sjcr
		= #{sjcr}, sjcr01 = #{sjcr01}, lxdh = #{lxdh}, rybh = #{rybh}, ryxm =
		#{ryxm}, cfqt = #{cfqt}, cfyg = #{cfyg}, cfwm = #{cfwm}, cfdm =
		#{cfdm}, fwkd = #{fwkd}, zlxgd = #{zlxgd}, tczj = #{tczj}, cmsl =
		#{cmsl}, cmgd = #{cmgd}, cmkd = #{cmkd}, tffs = #{tffs}, grfs =
		#{grfs}, kwcs = #{kwcs}, jd = #{jd}, wd = #{wd}, qyrq = #{qyrq}, cfzt
		= #{cfzt}, jsnd = #{jsnd}, dczlrj = #{dczlrj}, refresher =
		#{refresher}, refresher_code = #{refresherCode}, status = #{status},
		cflxbh = #{ cflxbh}, dwc = #{dwc}, cfyt = #{ cfyt }, qtyt = #{ qtyt }, cfnc = #{ cfnc},
		cfnk = #{ cfnk}, cfnj = #{ cfnj}, ccfs = #{ ccfs}, bwm = #{ bwm}, bwc
		= #{ bwc}, scbwc = #{ scbwc}, wknkc = #{ wknkc}, cndd = #{ cndd},
		cdbwdd = #{ cdbwdd}, gcpjr = #{ gcpjr}, cdwgrc = #{cdwgrc}, bwqt = #{
		bwqt}, bwtl = #{ bwtl}, zlsb = #{ zlsb}, dltf = #{ dltf}, zltf = #{
		zltf}, dzcw = #{ dzcw}, zdllk = #{ zdllk}, hlxz = #{ hlxz}, cnhl = #{
		cnhl}, sfba = #{ sfba}, cfxh = #{ cfxh}, ajxh = #{ ajxh}, hwxh = #{
		hwxh}, jssj = #{ jssj}, jfsyrq = #{ jfsyrq}, fyfcxn = #{ fyfcxn},
		mbscxn = #{ mbscxn}, grblxn = #{ grblxn}, sfszcc = #{ sfszcc},
		ywlqckqk = #{ ywlqckqk}, cfsyqk = #{ cfsyqk}, qthd = #{ qthd}, cmmc =
		#{ cmmc}, qtgr = #{ qtgr}, shrmc = #{ shrmc}, shyj = #{ shyj}, shsj =
		#{ shsj}, tyshxydm = #{ tyshxydm}, chbw = #{ chbw}, zlfj = #{ zlfj},
		nfxlsc = #{ nfxlsc}, cnsxt = #{ cnsxt}, dwclx = #{ dwclx}, ywjxtfss = #{ ywjxtfss},
		    refresh_time = NOW(),
            clgx= #{clgx, jdbcType=VARCHAR},
            jgcl= #{jgcl, jdbcType=VARCHAR},
            qmx= #{qmx, jdbcType=VARCHAR},
            lqjs= #{lqjs, jdbcType=VARCHAR},
            tfjs= #{tfjs, jdbcType=VARCHAR},
            scjs = #{scjs, jdbcType=VARCHAR},
            kwjs = #{kwjs, jdbcType=VARCHAR},
            sjnx = #{sjnx, jdbcType=VARCHAR},
            bgr = #{bgr, jdbcType=VARCHAR},
            grcs = #{grcs, jdbcType=VARCHAR},
			acceptance_qualified = #{acceptanceQualified, jdbcType=INTEGER},
			real_estate_certificate = #{realEstateCertificate, jdbcType=INTEGER},
			window_num = #{windowNum, jdbcType=INTEGER},
		cwtcwj = #{cwtcwj, jdbcType=DECIMAL},
		cntcnj = #{cntcnj, jdbcType=DECIMAL},
		dlmxs = #{dlmxs, jdbcType=VARCHAR},
		grxn = #{grxn, jdbcType=VARCHAR},
		sfyjxxxhgz = #{sfyjxxxhgz, jdbcType=VARCHAR},
		tfxtxs = #{tfxtxs, jdbcType=VARCHAR},
		hcjcfs = #{hcjcfs, jdbcType=VARCHAR},
		gfcfdm = #{gfcfdm, jdbcType=VARCHAR},
		gfcfmc = #{gfcfmc, jdbcType=VARCHAR},
		cnc = #{cnc},
		cnk = #{cnk},
		cnzlxg = #{cnzlxg},
		cntj = #{cntj},
		cwc = #{cwc},
		cwk = #{cwk},
		cwyg = #{cwyg},
		cwdg = #{cwdg},
		cnyg = #{cnyg},
		qtjg = #{qtjg},
		fdjg = #{fdjg},
		fjjg = #{fjjg},
		dmjg = #{dmjg},
		nfgrbw = #{nfgrbw},
		ywfsfqfczz = #{ywfsfqfczz},
		ywfhfbfdss = #{ywfhfbfdss},
		nffddyqtcl = #{nffddyqtcl},
		cfsfwh = #{cfsfwh},
		grbwcs = #{grbwcs},
		hwrl = #{hwrl},
		grain_type = #{grainType},
		sjdw = #{sjdw},
		jsdw = #{jsdw},
		jldw = #{jldw},
		sjsynx = #{sjsynx},
		cfqyrq = #{cfqyrq},
            change_reason = #{changeReason, jdbcType=VARCHAR}
	where cfbh = #{cfbh}
	</update>
  <!-- 添加库点信息 -->
    <insert id="insert" parameterType="com.unis.base.server.entity.DCfxxsjyDO">
    	insert into D_CFXXSJY
	    <trim prefix="(" suffix=")" suffixOverrides="," >
            <if test="cfbh != null">
                cfbh,
            </if>
            <if test="cfmc != null">
                cfmc,
            </if>
            <if test="kddm != null">
                kddm,
            </if>
            <if test="cflx != null">
                cflx,
            </if>
            <if test="cfjg != null">
                cfjg,
            </if>
            <if test="jzlx != null">
                jzlx,
            </if>
            <if test="cfcd != null">
                cfcd,
            </if>
            <if test="cfkd != null">
                cfkd,
            </if>
            <if test="cfgd != null">
                cfgd,
            </if>
            <if test="sjcr != null">
                sjcr,
            </if>
            <if test="sjcr01 != null">
                sjcr01,
            </if>
            <if test="lxdh != null">
                lxdh,
            </if>
            <if test="rybh != null">
                rybh,
            </if>
            <if test="ryxm != null">
                ryxm,
            </if>
            <if test="cfqt != null">
                cfqt,
            </if>
            <if test="cfyg != null">
                cfyg,
            </if>
            <if test="cfwm != null">
                cfwm,
            </if>
            <if test="cfdm != null">
                cfdm,
            </if>
            <if test="fwkd != null">
                fwkd,
            </if>
            <if test="zlxgd != null">
                zlxgd,
            </if>
            <if test="tczj != null">
                tczj,
            </if>
            <if test="cmsl != null">
                cmsl,
            </if>
            <if test="cmgd != null">
                cmgd,
            </if>
            <if test="cmkd != null">
                cmkd,
            </if>
            <if test="tffs != null">
                tffs,
            </if>
            <if test="grfs != null">
                grfs,
            </if>
            <if test="kwcs != null">
                kwcs,
            </if>
            <if test="jd != null">
                jd,
            </if>
            <if test="wd != null">
                wd,
            </if>
            <if test="qyrq != null">
                qyrq,
            </if>
            <if test="cfzt != null">
                cfzt,
            </if>
            <if test="jsnd != null">
                jsnd,
            </if>
            <if test="dczlrj != null">
                dczlrj,
            </if>
            <if test="creator != null">
                creator,
            </if>
            <if test="creatorCode != null">
                creator_code,
            </if>
            <if test="refresher != null">
                refresher,
            </if>
            <if test="remark != null">
                remark,
            </if>
            <if test=" cflxbh != null">
                cflxbh,
            </if>
            <if test=" dwc != null">
                dwc,
            </if>
            <if test=" cfyt != null">
                cfyt,
            </if>
			<if test=" qtyt != null">
				qtyt,
            </if>
            <if test=" cfnc != null">
                cfnc,
            </if>
            <if test=" cfnk != null">
                cfnk,
            </if>
            <if test=" cfnj != null">
                cfnj,
            </if>
            <if test=" ccfs != null">
                ccfs,
            </if>
            <if test=" bwm != null">
                bwm,
            </if>
            <if test=" bwc != null">
                bwc,
            </if>
            <if test=" scbwc != null">
                scbwc,
            </if>
            <if test=" wknkc != null">
                wknkc,
            </if>
            <if test=" cndd != null">
                cndd,
            </if>
            <if test=" cdbwdd != null">
                cdbwdd,
            </if>
            <if test=" gcpjr != null">
                gcpjr,
            </if>
            <if test=" cdwgrc != null">
                cdwgrc,
            </if>
            <if test="bwqt  != null">
                bwqt,
            </if>
            <if test=" bwtl != null">
                bwtl,
            </if>
            <if test=" zlsb != null">
                zlsb,
            </if>
            <if test=" dltf != null">
                dltf,
            </if>
            <if test=" zltf != null">
                zltf,
            </if>
            <if test=" dzcw != null">
                dzcw,
            </if>
            <if test=" zdllk != null">
                zdllk,
            </if>
            <if test=" hlxz != null">
                hlxz,
            </if>
            <if test=" cnhl != null">
                cnhl,
            </if>
            <if test=" sfba != null">
                sfba,
            </if>
            <if test=" cfxh != null">
                cfxh,
            </if>
            <if test=" ajxh != null">
                ajxh,
            </if>
            <if test=" hwxh != null">
                hwxh,
            </if>
            <if test=" jssj != null">
                jssj,
            </if>
            <if test=" jfsyrq != null">
                jfsyrq,
            </if>
            <if test=" fyfcxn != null">
                fyfcxn,
            </if>
            <if test=" mbscxn != null">
                mbscxn,
            </if>
            <if test=" grblxn != null">
                grblxn,
            </if>
            <if test=" sfszcc != null">
                sfszcc,
            </if>
            <if test=" ywlqckqk != null">
                ywlqckqk,
            </if>
            <if test=" cfsyqk != null">
                cfsyqk,
            </if>
            <if test=" qthd != null">
                qthd,
            </if>
            <if test=" cmmc != null">
                cmmc,
            </if>
            <if test=" qtgr != null">
                qtgr,
            </if>
            <if test=" tyshxydm != null">
                tyshxydm,
            </if>
            <if test=" chbw != null">
                chbw,
            </if>
            <if test=" zlfj != null">
                zlfj,
            </if>
            <if test=" nfxlsc != null">
                nfxlsc,
            </if>
            <if test=" cnsxt != null">
                cnsxt,
            </if>
            <if test=" dwclx != null">
                dwclx,
            </if>

            <if test=" ywjxtfss != null">
                ywjxtfss,
            </if>
            <if test=" cfbm != null">
                cfbm,
            </if>
            <if test=" qybm != null">
                qybm,
            </if>
            <if test="clgx != null">
                clgx,
            </if>
            <if test="jgcl != null">
                jgcl,
            </if>
            <if test="qmx != null">
                qmx,
            </if>
            <if test="lqjs != null">
                lqjs,
            </if>
            <if test="tfjs != null">
                tfjs,
            </if>
            <if test=" scjs != null">
                scjs,
            </if>
            <if test="kwjs != null">
                kwjs,
            </if>
            <if test="sjnx != null">
                sjnx,
            </if>
            <if test="bgr != null">
                bgr,
            </if>
            <if test="grcs != null">
                grcs,
            </if>
			<if test="acceptanceQualified != null">
				acceptance_qualified,
			</if>
			<if test="realEstateCertificate != null">
				real_estate_certificate,
			</if>
			<if test="windowNum != null">
				window_num,
			</if>
			<if test="cwtcwj != null">
				cwtcwj,
			</if>
			<if test="cntcnj != null">
                cntcnj,
			</if>
			<if test="dlmxs != null and dlmxs != ''">
				dlmxs,
			</if>
			<if test="grxn != null and grxn != ''">
				grxn,
			</if>
			<if test="sfyjxxxhgz != null and sfyjxxxhgz != ''">
				sfyjxxxhgz,
			</if>
			<if test="tfxtxs !=null and tfxtxs != ''">
				tfxtxs,
			</if>
			<if test="hcjcfs != null and hcjcfs != ''">
				hcjcfs,
			</if>
			<if test="hwrl != null">
				hwrl,
			</if>
			<if test="ajdh != null and ajdh != ''">
				ajdh,
			</if>
			<if test="hwdm != null and hwdm != ''">
				hwdm,
			</if>
			<if test="gfcfdm != null and gfcfdm != ''">
				gfcfdm,
			</if>
			<if test="gfcfmc != null and gfcfmc != ''">
				gfcfmc,
			</if>
			<if test="status != null">
				status,
			</if>
			<if test=" cnc != null">
				cnc,
			</if>
			<if test=" cnk != null">
				cnk,
			</if>
			<if test=" cnzlxg != null">
				cnzlxg,
			</if>
			<if test=" cntj != null">
				cntj,
			</if>
			<if test=" cwc != null">
				cwc,
			</if>
			<if test=" cwk != null">
				cwk,
			</if>
			<if test=" cwyg != null">
				cwyg,
			</if>
			<if test=" cwdg != null">
				cwdg,
			</if>
			<if test=" cnyg != null">
				cnyg,
			</if>
			<if test=" qtjg != null">
				qtjg,
			</if>
			<if test=" fdjg != null">
				fdjg,
			</if>
			<if test=" fjjg != null">
				fjjg,
			</if>
			<if test=" dmjg != null">
				dmjg,
			</if>
			<if test=" nfgrbw != null and nfgrbw !=''">
				nfgrbw,
			</if>
			<if test=" ywfsfqfczz != null and ywfsfqfczz !=''">
				ywfsfqfczz,
			</if>
			<if test=" ywfhfbfdss != null and ywfhfbfdss !=''">
				ywfhfbfdss,
			</if>
			<if test=" nffddyqtcl != null and nffddyqtcl !=''">
				nffddyqtcl,
			</if>
			<if test=" cfsfwh != null and cfsfwh !=''">
				cfsfwh,
			</if>
			<if test=" grbwcs != null and grbwcs !=''">
				grbwcs,
			</if>
			<if test=" grainType != null and grainType !=''">
				grain_type,
			</if>
			<if test=" sjdw != null and sjdw !=''">
				sjdw,
			</if>
			<if test=" jsdw != null and jsdw !=''">
				jsdw,
			</if>
			<if test=" jldw != null and jldw !=''">
				jldw,
			</if>
			<if test=" sjsynx != null and sjsynx !=''">
				sjsynx,
			</if>
			<if test="cfqyrq != null">
				cfqyrq,
			</if>
            <if test="changeReason != null">
                change_reason ,
            </if>
	    </trim>
	    <trim prefix="values (" suffix=")" suffixOverrides="," >
            <if test="cfbh != null">
                #{cfbh,jdbcType=VARCHAR},
            </if>
            <if test="cfmc != null">
                #{cfmc,jdbcType=VARCHAR},
            </if>
            <if test="kddm != null">
                #{kddm,jdbcType=VARCHAR},
            </if>
            <if test="cflx != null">
                #{cflx,jdbcType=VARCHAR},
            </if>
            <if test="cfjg != null">
                #{cfjg,jdbcType=VARCHAR},
            </if>
            <if test="jzlx != null">
                #{jzlx,jdbcType=VARCHAR},
            </if>
            <if test="cfcd != null">
                #{cfcd,jdbcType=VARCHAR},
            </if>
            <if test="cfkd != null">
                #{cfkd,jdbcType=VARCHAR},
            </if>
            <if test="cfgd != null">
                #{cfgd,jdbcType=VARCHAR},
            </if>
            <if test="sjcr != null">
                #{sjcr,jdbcType=VARCHAR},
            </if>
            <if test="sjcr01 != null">
                #{sjcr01,jdbcType=VARCHAR},
            </if>
            <if test="lxdh != null">
                #{lxdh,jdbcType=VARCHAR},
            </if>
            <if test="rybh != null">
                #{rybh,jdbcType=VARCHAR},
            </if>
            <if test="ryxm != null">
                #{ryxm,jdbcType=VARCHAR},
            </if>
            <if test="cfqt != null">
                #{cfqt,jdbcType=VARCHAR},
            </if>
            <if test="cfyg != null">
                #{cfyg,jdbcType=DECIMAL},
            </if>
            <if test="cfwm != null">
                #{cfwm,jdbcType=VARCHAR},
            </if>
            <if test="cfdm != null">
                #{cfdm,jdbcType=VARCHAR},
            </if>
            <if test="fwkd != null">
                #{fwkd,jdbcType=DECIMAL},
            </if>
            <if test="zlxgd != null">
                #{zlxgd,jdbcType=DECIMAL},
            </if>
            <if test="tczj != null">
                #{tczj,jdbcType=DECIMAL},
            </if>
            <if test="cmsl != null">
                #{cmsl,jdbcType=DECIMAL},
            </if>
            <if test="cmgd != null">
                #{cmgd,jdbcType=DECIMAL},
            </if>
            <if test="cmkd != null">
                #{cmkd,jdbcType=DECIMAL},
            </if>
            <if test="tffs != null">
                #{tffs,jdbcType=VARCHAR},
            </if>
            <if test="grfs != null">
                #{grfs,jdbcType=VARCHAR},
            </if>
            <if test="kwcs != null">
                #{kwcs,jdbcType=VARCHAR},
            </if>
            <if test="jd != null">
                #{jd,jdbcType=VARCHAR},
            </if>
            <if test="wd != null">
                #{wd,jdbcType=VARCHAR},
            </if>
            <if test="qyrq != null">
                #{qyrq,jdbcType=VARCHAR},
            </if>
            <if test="cfzt != null">
                #{cfzt,jdbcType=VARCHAR},
            </if>
            <if test="jsnd != null">
                #{jsnd,jdbcType=VARCHAR},
            </if>
            <if test="dczlrj != null">
                #{dczlrj,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="remark != null">
                #{remark,jdbcType=VARCHAR},
            </if>

            <if test=" cflxbh != null">
                #{ cflxbh, jdbcType=VARCHAR},
            </if>
            <if test=" dwc != null">
                #{ dwc,jdbcType=INTEGER},
            </if>
            <if test=" cfyt != null">
                #{ cfyt , jdbcType=VARCHAR},
            </if>
			<if test=" qtyt != null">
                #{ qtyt , jdbcType=VARCHAR},
            </if>
            <if test=" cfnc != null">
                #{ cfnc, jdbcType=DECIMAL},
            </if>
            <if test=" cfnk != null">
                #{ cfnk, jdbcType=DECIMAL},
            </if>
            <if test=" cfnj != null">
                #{ cfnj, jdbcType=INTEGER},
            </if>
            <if test=" ccfs != null">
                #{ ccfs, jdbcType=VARCHAR},
            </if>
            <if test=" bwm != null">
                #{ bwm, jdbcType=INTEGER},
            </if>
            <if test=" bwc != null">
                #{ bwc, jdbcType=INTEGER},
            </if>
            <if test=" scbwc != null">
                #{ scbwc, jdbcType=INTEGER},
            </if>
            <if test=" wknkc != null">
                #{ wknkc, jdbcType=INTEGER},
            </if>
            <if test=" cndd != null">
                #{ cndd, jdbcType=INTEGER},
            </if>
            <if test=" cdbwdd != null">
                #{ cdbwdd, jdbcType=INTEGER},
            </if>
            <if test=" gcpjr != null">
                #{ gcpjr, jdbcType=INTEGER},
            </if>
            <if test=" cdwgrc != null">
                #{cdwgrc, jdbcType=INTEGER},
            </if>
            <if test="bwqt  != null">
                #{ bwqt, jdbcType=INTEGER},
            </if>
            <if test=" bwtl != null">
                #{ bwtl, jdbcType=INTEGER},
            </if>
            <if test=" zlsb != null">
                #{ zlsb, jdbcType=INTEGER},
            </if>
            <if test=" dltf != null">
                #{ dltf, jdbcType=INTEGER},
            </if>
            <if test=" zltf != null">
                #{ zltf, jdbcType=INTEGER},
            </if>
            <if test=" dzcw != null">
                #{ dzcw, jdbcType=INTEGER},
            </if>
            <if test=" zdllk != null">
                #{ zdllk, jdbcType=INTEGER},
            </if>
            <if test=" hlxz != null">
                #{ hlxz, jdbcType=INTEGER},
            </if>
            <if test=" cnhl != null">
                #{ cnhl, jdbcType=INTEGER},
            </if>
            <if test=" sfba != null">
                #{sfba, jdbcType=DECIMAL},
            </if>
            <if test=" cfxh != null">
                #{ cfxh, jdbcType=VARCHAR},
            </if>
            <if test=" ajxh != null">
                #{ ajxh, jdbcType=VARCHAR},
            </if>
            <if test=" hwxh != null">
                #{ hwxh, jdbcType=VARCHAR},
            </if>
            <if test=" jssj != null">
                #{ jssj, jdbcType=DATE},
            </if>
            <if test=" jfsyrq != null">
                #{ jfsyrq, jdbcType=DATE},
            </if>
            <if test=" fyfcxn != null">
                #{ fyfcxn, jdbcType=VARCHAR},
            </if>
            <if test=" mbscxn != null">
                #{ mbscxn, jdbcType=VARCHAR},
            </if>
            <if test=" grblxn != null">
                #{ grblxn, jdbcType=VARCHAR},
            </if>
            <if test=" sfszcc != null">
                #{ sfszcc, jdbcType=DECIMAL},
            </if>
            <if test=" ywlqckqk != null">
                #{ ywlqckqk, jdbcType=DECIMAL},
            </if>
            <if test=" cfsyqk != null">
                #{ cfsyqk, jdbcType=DECIMAL},
            </if>
            <if test=" qthd != null">
                #{ qthd, jdbcType=DECIMAL},
            </if>
            <if test=" cmmc != null">
                #{ cmmc, jdbcType=VARCHAR},
            </if>
            <if test=" qtgr != null">
                #{ qtgr, jdbcType=DECIMAL},
            </if>
            <if test=" tyshxydm != null">
                #{ tyshxydm, jdbcType=DATE},
            </if>

            <if test=" chbw != null">
                #{ chbw, jdbcType=INTEGER},
            </if>
            <if test=" zlfj != null">
                #{ zlfj, jdbcType=INTEGER},
            </if>
            <if test=" nfxlsc != null">
                #{ nfxlsc, jdbcType=INTEGER},
            </if>
            <if test=" cnsxt != null">
                #{ cnsxt, jdbcType=INTEGER},
            </if>
            <if test=" dwclx != null">
                #{ dwclx, jdbcType=INTEGER},
            </if>
            <if test=" ywjxtfss != null">
                #{ ywjxtfss, jdbcType=INTEGER},
            </if>
            <if test=" cfbm != null">
                #{ cfbm, jdbcType=VARCHAR},
            </if>
            <if test=" qybm != null">
                #{ qybm, jdbcType=VARCHAR},
            </if>
            <if test="clgx != null">
                #{clgx, jdbcType=VARCHAR},
            </if>
            <if test="jgcl != null">
                #{jgcl, jdbcType=VARCHAR},
            </if>
            <if test="qmx != null">
                #{qmx, jdbcType=VARCHAR},
            </if>
            <if test="lqjs != null">
                #{lqjs, jdbcType=VARCHAR},
            </if>
            <if test="tfjs != null">
                #{tfjs, jdbcType=VARCHAR},
            </if>
            <if test=" scjs != null">
                #{scjs, jdbcType=VARCHAR},
            </if>
            <if test="kwjs != null">
                #{kwjs, jdbcType=VARCHAR},
            </if>
            <if test="sjnx != null">
                #{sjnx, jdbcType=VARCHAR},
            </if>
            <if test="bgr != null">
                #{bgr, jdbcType=VARCHAR},
            </if>
            <if test="grcs != null">
                #{grcs, jdbcType=VARCHAR},
            </if>
			<if test="acceptanceQualified != null">
				#{acceptanceQualified, jdbcType=INTEGER},
			</if>
			<if test="realEstateCertificate != null">
				#{realEstateCertificate, jdbcType=INTEGER},
			</if>
			<if test="windowNum != null">
				#{windowNum, jdbcType=INTEGER},
			</if>
            <if test="cwtcwj != null">
                #{cwtcwj, jdbcType=DECIMAL},
            </if>
            <if test="cntcnj != null">
                #{cntcnj, jdbcType=DECIMAL},
            </if>
			<if test="dlmxs != null and dlmxs != ''">
				#{dlmxs, jdbcType=VARCHAR},
			</if>
			<if test="grxn != null and grxn != ''">
				#{grxn, jdbcType=VARCHAR},
			</if>
			<if test="sfyjxxxhgz != null and sfyjxxxhgz != ''">
				#{sfyjxxxhgz, jdbcType=VARCHAR},
			</if>
			<if test="tfxtxs !=null and tfxtxs != ''">
				#{tfxtxs, jdbcType=VARCHAR},
			</if>
			<if test="hcjcfs != null and hcjcfs != ''">
				#{hcjcfs, jdbcType=VARCHAR},
			</if>
			<if test="hwrl != null">
				#{hwrl, jdbcType=DECIMAL},
			</if>
			<if test="ajdh != null and ajdh != ''">
				#{ajdh, jdbcType=VARCHAR},
			</if>
			<if test="hwdm != null and hwdm != ''">
				#{hwdm, jdbcType=VARCHAR},
			</if>
			<if test="gfcfdm != null and gfcfdm != ''">
				#{gfcfdm, jdbcType=VARCHAR},
			</if>
			<if test="gfcfmc != null and gfcfmc != ''">
				#{gfcfmc, jdbcType=VARCHAR},
			</if>
			<if test="status != null">
				#{status, jdbcType=DECIMAL},
			</if>
			<if test=" cnc != null">
				#{cnc, jdbcType=DECIMAL},
			</if>
			<if test=" cnk != null">
				#{cnk, jdbcType=DECIMAL},
			</if>
			<if test=" cnzlxg != null">
				#{cnzlxg, jdbcType=DECIMAL},
			</if>
			<if test=" cntj != null">
				#{cntj, jdbcType=DECIMAL},
			</if>
			<if test=" cwc != null">
				#{cwc, jdbcType=DECIMAL},
			</if>
			<if test=" cwk != null">
				#{cwk, jdbcType=DECIMAL},
			</if>
			<if test=" cwyg != null">
				#{cwyg, jdbcType=DECIMAL},
			</if>
			<if test=" cwdg != null">
				#{cwdg, jdbcType=DECIMAL},
			</if>
			<if test=" cnyg != null">
				#{cnyg, jdbcType=DECIMAL},
			</if>
			<if test=" qtjg != null">
				#{qtjg, jdbcType=VARCHAR},
			</if>
			<if test=" fdjg != null">
				#{fdjg, jdbcType=VARCHAR},
			</if>
			<if test=" fjjg != null">
				#{fjjg, jdbcType=VARCHAR},
			</if>
			<if test=" dmjg != null">
				#{dmjg, jdbcType=VARCHAR},
			</if>
			<if test=" nfgrbw != null and nfgrbw !=''">
				#{nfgrbw, jdbcType=VARCHAR},
			</if>
			<if test=" ywfsfqfczz != null and ywfsfqfczz !=''">
				#{ywfsfqfczz, jdbcType=VARCHAR},
			</if>
			<if test=" ywfhfbfdss != null and ywfhfbfdss !=''">
				#{ywfhfbfdss, jdbcType=VARCHAR},
			</if>
			<if test=" nffddyqtcl != null and nffddyqtcl !=''">
				#{nffddyqtcl, jdbcType=VARCHAR},
			</if>
			<if test=" cfsfwh != null and cfsfwh !=''">
				#{cfsfwh, jdbcType=VARCHAR},
			</if>
			<if test=" grbwcs != null and grbwcs !=''">
				#{grbwcs, jdbcType=VARCHAR},
			</if>
			<if test=" grainType != null and grainType !=''">
				#{grainType, jdbcType=VARCHAR},
			</if>
			<if test=" sjdw != null and sjdw !=''">
				#{sjdw, jdbcType=VARCHAR},
			</if>
			<if test=" jsdw != null and jsdw !=''">
				#{jsdw, jdbcType=VARCHAR},
			</if>
			<if test=" jldw != null and jldw !=''">
				#{jldw, jdbcType=VARCHAR},
			</if>
			<if test=" sjsynx != null and sjsynx !=''">
				#{sjsynx, jdbcType=VARCHAR},
			</if>
			<if test="cfqyrq != null">
				#{cfqyrq,jdbcType=DATE},
			</if>
            <if test="changeReason != null">
                #{changeReason, jdbcType=VARCHAR},
            </if>
	    </trim>
    </insert>

  <select id="getMaxCodeById" parameterType="java.lang.String" resultType="java.lang.String">
        SELECT
        	max(cf.cfbh)
        from
			D_CFXXSJY cf
    </select>

    <!--获取最大设备编号-->
    <select id="getMaxById" parameterType="java.lang.String" resultType="java.lang.String">
        SELECT
        max(cf.cfbh)
        from
        D_CFXXSJY cf
        <where>
            cf.cfbh like CONCAT(#{prefix,jdbcType=VARCHAR},'%')
        </where>
    </select>
	<select id="getDCfxxxsjyLists" resultType="com.unis.base.common.vo.DCfxxsjyVO">
		SELECT
		<include refid="Base_Column_List_common"></include>,kd.kdmc,xx.lspzmc,xx.FCSL,
		date_format(rksj,'%Y%m') as rcny,lq.cfww,lq.cfws,lq.cfnw,lq.cfns
		from
		D_CFXXSJY cf
		left join TY_LSKCXX xx on xx.sscfbh = cf.cfbh
		left join D_KDXXSJY kd on cf.KDDM = kd.KDDM
		left join (
		select lq.cfbh,lq.cfww,lq.cfws,lq.cfnw,lq.cfns
		from ty_lqxx lq inner join (
		select cfbh,max(JCSJ) as jcsj from ty_lqxx group by cfbh
		) mxlq on lq.cfbh=mxlq.cfbh and lq.jcsj=mxlq.jcsj
		) lq on cf.cfbh=lq.cfbh
		<where>
			cf.status = 1
			<!-- 仓房编号 -->
			<if test="cfbh != null and cfbh != ''" >
				and	cf.cfbh LIKE concat(CONCAT('%',#{cfbh,jdbcType=VARCHAR}) ,'%')
			</if>
			<!-- 仓房名称 -->
			<if test="cfmc != null and cfmc != ''" >
				and	cf.cfmc LIKE concat(CONCAT('%',#{cfmc,jdbcType=VARCHAR}) ,'%')
			</if>
			<!-- 仓房类型 -->
			<if test="cflx != null and cflx != ''" >
				and	cf.cflx LIKE concat(CONCAT('%',#{cflx,jdbcType=VARCHAR}) ,'%')
			</if>
			<!-- 建筑类型 -->
			<if test="jzlx != null and jzlx != ''" >
				and	cf.jzlx LIKE concat(CONCAT('%',#{jzlx,jdbcType=VARCHAR}) ,'%')
			</if>
			<!-- 仓房状态 -->
			<if test="cfzt != null and cfzt != ''" >
				and	cf.cfzt LIKE concat(CONCAT('%',#{cfzt,jdbcType=VARCHAR}) ,'%')
			</if>
			<!-- 库点编号 -->
			<if test="kddm != null and kddm != ''" >
				and	cf.kddm LIKE concat(CONCAT('%',#{kddm,jdbcType=VARCHAR}) ,'%')
			</if>
			<!-- 库点名称 -->
			<if test="kdmc != null and kdmc != ''" >
				and	kd.kdmc LIKE concat(CONCAT('%',#{kdmc,jdbcType=VARCHAR}) ,'%')
			</if>

			<if test="cfxh != null and cfxh != ''" >
				and	cf.cfxh =#{cfxh,jdbcType=VARCHAR}
			</if>
			<if test="sjcrStart != null">
				and	cf.sjcr &gt; #{sjcrStart}
			</if>
			<if test="sjcrEnd != null">
				and	cf.sjcr &lt; #{sjcrEnd}
			</if>
			<if test="startJssj != null">
				and	DATE_FORMAT(cf.jssj,'%Y-%m-%d %H:%i:%s') &gt; #{startJssj}
			</if>
			<if test="endJssj != null">
				and	DATE_FORMAT(cf.jssj,'%Y-%m-%d %H:%i:%s') &lt; #{endJssj}
			</if>

			<if test="ajxh != null and ajxh != ''" >
				and	cf.ajxh =#{ajxh,jdbcType=VARCHAR}
			</if>

			<if test="hwxh != null and hwxh != ''" >
				and	cf.hwxh =#{hwxh,jdbcType=VARCHAR}
			</if>

			<!-- 是否备案 -->
			<if test='sfba != null'>
				and cf.SFBA = #{sfba,jdbcType=DECIMAL}
			</if>

			<if test='jssj !=null'>

				and DATE_FORMAT(cf.jssj,'%Y-%m-%d')=#{cxsj}

			</if>

			<if test='tyshxydm !=null'>

				and cf.tyshxydm=#{tyshxydm}

			</if>
			<if test='qybm !=null'>

				and cf.qybm=#{qybm}

			</if>
			<if test='zts !=null'>
				and cf.SFBA in
				<foreach collection="zts" item="zt" open="(" close=")" separator=",">
					#{zt}
				</foreach>

			</if>


		</where>
		ORDER BY cf.CFBH desc
	</select>
	<select id="warehouseListNew" resultType="com.unis.base.server.entity.DCfxxsjyDO">
		select cf.cfbh, cf.gfcfmc||','||cf.cfmc as cfmc, cf.kddm, cf.cflx,cf.sjcr from D_CFXXSJY cf
		<where>
			<!-- 库点编号 -->
			<if test="kddm != null and kddm != ''" >
				and	cf.kddm LIKE concat(CONCAT('%',#{kddm,jdbcType=VARCHAR}) ,'%')
			</if>
			<!-- 库点名称 -->
			<if test="kdmc != null and kdmc != ''" >
				and	kd.kdmc LIKE concat(CONCAT('%',#{kdmc,jdbcType=VARCHAR}) ,'%')
			</if>
			<if test='tyshxydm !=null'>
				and cf.tyshxydm=#{tyshxydm}
			</if>
			<if test='qybm !=null'>
				and cf.qybm=#{qybm}
			</if>
			<if test='hwxh!=null and hwxh!=""'>
				AND cf.hwxh =  #{hwxh,jdbcType=VARCHAR}
			</if>
			<if test='gfcfdm!=null and gfcfdm!=""'>
				AND cf.gfcfdm =  #{gfcfdm,jdbcType=VARCHAR}
			</if>
			<if test='cfxh!=null and cfxh!=""'>
				AND cf.cfxh =  #{cfxh,jdbcType=VARCHAR}
			</if>
		</where>
		order by cf.cfbh
	</select>
	<select id="getDCfxxxsjyCbl" resultType="com.unis.base.server.entity.DCfxxsjyDO">
		SELECT
		cf.cfbh,concat(cf.gfcfmc,',',cf.cfmc) as cfmc
		from
		D_CFXXSJY cf
		<where>
			cf.status = 1 and cf.sfba ='5' and cf.cfbh in (select kc.sscfbh from db_utf8.ty_kccxgssw kc where fcsl>0
			and
			sskddm like  concat('%' , #{tyshxydm} , '%'))
			<!-- 库点编号 -->
			<if test="kddm != null and kddm != ''" >
				and	cf.kddm LIKE concat(CONCAT('%',#{kddm,jdbcType=VARCHAR}) ,'%')
			</if>
			<if test='tyshxydm !=null'>
				and cf.tyshxydm=#{tyshxydm}
			</if>
		</where>
		ORDER BY cf.CFBH desc
	</select>

	<!--根据库点代码删除仓房信息列表-->
	<update id="deleteList" parameterType="java.lang.String">
		UPDATE
		D_CFXXSJY cf
		SET
		cf.status = 0
		<where>
			cf.kddm like CONCAT(#{kddm,jdbcType=VARCHAR},'%')
		</where>
	</update>

	<update id="updateDCfxxsjy" parameterType="com.unis.base.common.vo.DCfxxsjyVO">
		UPDATE
		D_CFXXSJY
		<set>
			<if test="sendResult != null and sendResult != ''" >
				send_result = #{sendResult,jdbcType=VARCHAR},
			</if>
			<if test="sfba != null and sfba != ''" >
				sfba = #{sfba,jdbcType=DECIMAL},
			</if>
			<if test=" shrmc != null">
				shrmc = #{ shrmc, jdbcType=VARCHAR},
			</if>
			<if test=" shsj != null">
				shsj = #{ shsj, jdbcType=DATE},
			</if>
			<if test=" shyj != null">
				shyj = #{ shyj, jdbcType=VARCHAR},
			</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="dataVer != null">
                data_ver = #{dataVer, jdbcType=INTEGER},
            </if>
            <if test="changeReason != null">
                change_reason = #{changeReason, jdbcType=VARCHAR},
            </if>
		</set>
		<where>
		    <if test="kddm != null and kddm !=''">
				and kddm = #{kddm,jdbcType=VARCHAR}
			</if>
			<if test="cfxh != null and cfxh !=''">
				and cfxh = #{cfxh,jdbcType=VARCHAR}
			</if>
		</where>
	</update>

	<delete id="deleteByKddmAndCfxh" parameterType="java.lang.String" >
		delete from base.D_CMXXSJY where cfbh in (
			select gfcfdm from base.D_CFXXSJY
			where kddm = #{kddm}
			and cfxh = #{cfxh}
		);
		delete from D_CFXXSJY
		where kddm = #{kddm}
		and cfxh = #{cfxh};
	</delete>

	<sql id="getDCfxxxListWhere">
		and cf.gfcfmc is not null
		<!-- 仓房编号 -->
		<if test="cfbh != null and cfbh != ''" >
			and	cf.cfbh LIKE concat(CONCAT('%',#{cfbh,jdbcType=VARCHAR}) ,'%')
		</if>
		<!-- 仓房名称 -->
		<if test="gfcfmc != null and gfcfmc != ''" >
			and	cf.gfcfmc LIKE concat(CONCAT('%',#{gfcfmc,jdbcType=VARCHAR}) ,'%')
		</if>
		<!-- 仓房类型 -->
		<if test="cflx != null and cflx != ''" >
			and	cf.cflx LIKE concat(CONCAT('%',#{cflx,jdbcType=VARCHAR}) ,'%')
		</if>
		<!-- 建筑类型 -->
		<if test="jzlx != null and jzlx != ''" >
			and	cf.jzlx LIKE concat(CONCAT('%',#{jzlx,jdbcType=VARCHAR}) ,'%')
		</if>
		<!-- 仓房状态 -->
		<if test="cfzt != null and cfzt != ''" >
			and	cf.cfzt LIKE concat(CONCAT('%',#{cfzt,jdbcType=VARCHAR}) ,'%')
		</if>
		<!-- 库点编号 -->
		<if test="kddm != null and kddm != ''" >
			and	cf.kddm LIKE concat(CONCAT('%',#{kddm,jdbcType=VARCHAR}) ,'%')
		</if>
		<!-- 库点名称 -->
		<if test="kdmc != null and kdmc != ''" >
			and	kd.kdmc LIKE concat(CONCAT('%',#{kdmc,jdbcType=VARCHAR}) ,'%')
		</if>
		<if test="cfxh != null and cfxh != ''" >
			and	cf.cfxh LIKE concat(CONCAT('%',#{cfxh,jdbcType=VARCHAR}) ,'%')
		</if>
		<if test="hwxh != null and hwxh != ''" >
			and	cf.hwxh =#{hwxh,jdbcType=VARCHAR}
		</if>
		<!-- 是否备案 -->
		<if test='sfba != null'>
			and cf.SFBA = #{sfba,jdbcType=DECIMAL}
		</if>
		<if test="jssj != null">
			and	cf.jssj = #{jssj}
		</if>
		<if test='tyshxydm !=null'>
			and cf.tyshxydm=#{tyshxydm}
		</if>
		<if test='qybm !=null'>
			and cf.qybm=#{qybm}
		</if>
		<if test='zts !=null'>
			and cf.SFBA in
			<foreach collection="zts" item="zt" open="(" close=")" separator=",">
				#{zt}
			</foreach>
		</if>
	</sql>
	<select id="getDCfxxxList" resultType="com.unis.base.common.vo.DCfxxsjyVO">
		select cf.gfcfmc,
			   cf.cfxh,
			   d.dict_name as cflx,
			   e.dict_name as cfzt,
			   cf.sfba,
		       cf.tyshxydm,
		       cf.kddm,
		       cf.delFlag,
			   cf.jssj,
			   cf.sjcr,
			   cf.dczlrj,
			   e2.dict_name as cfyt,
		(IFNULL(t1.cl_cr, 0) + IFNULL(t2.xz_cr, 0)) AS clzcr,
		IFNULL(t2.xz_cr, 0) AS clkcr,
				status
		from (
				select distinct gfcfmc,
				                cfxh,
				                cflx,
				                cfzt,
				                sfba,
				                tyshxydm,
				                kddm,
								case
								when max(length(send_result)) is null then '0'
								else '1'
								end delFlag,
								jssj,
								sjcr,
								dczlrj,
								cfyt,
								max(status) status
				from d_cfxxsjy
				group by tyshxydm,gfcfdm,gfcfmc,cfxh,cflx,cfzt,sfba,tyshxydm,kddm,jssj,sjcr,dczlrj,cfyt
		)cf
		left join usercenter.sys_dictionary d
			on d.dict_code=cf.cflx and d.group_id='CFLX'
		left join usercenter.sys_dictionary e
		    on e.dict_code=cf.cfzt and e.group_id='CFZT'
		left join usercenter.sys_dictionary e2
		on e2.dict_code=cf.cfyt and e2.group_id='CFYT'
		left join (
			select tyshxydm,sum(ifnull(sjcr, 0)) cl_cr from  (
				select cf.tyshxydm, cf.gfcfdm, cf.sjcr, cf.gfcfmc
				from base.d_cfxxsjy cf
					where cf.cfzt = 1 and cf.status = 1 and cf.cfyt = 0
					and cf.sfba = 5
					<include refid="getDCfxxxListWhere"></include>
				group by cf.tyshxydm,cf.gfcfdm, cf.sjcr, cf.gfcfmc
			) group by tyshxydm
		) t1 on t1.tyshxydm=cf.tyshxydm
		left join (
			select tyshxydm,sum(ifnull(sjcr, 0)) xz_cr from  (
				select cf.tyshxydm, cf.gfcfdm, cf.sjcr, cf.gfcfmc
				from base.d_cfxxsjy cf
				where cf.cfzt = 1 and cf.status = 1 and cf.cfyt = 1
				and cf.sfba = 5
				<include refid="getDCfxxxListWhere"></include>
				group by cf.tyshxydm,cf.gfcfdm, cf.sjcr, cf.gfcfmc
			) group by tyshxydm
		) t2 on t2.tyshxydm=cf.tyshxydm
		where 1=1
		<include refid="getDCfxxxListWhere"></include>
		ORDER BY cf.cfxh desc
	</select>

	<select id="selectCfxxsjy"  resultType="com.unis.base.common.vo.DCfxxsjyVO">
		<include refid="cfxxSql"/>
		<where>
			<if test='kddm!=null and kddm!=""'>
				AND cf.kddm like CONCAT(#{kddm,jdbcType=VARCHAR},'%')
			</if>
			<choose>
				<when test='cfxh!=null and cfxh!=""'>
					AND cf.cfxh =  #{cfxh,jdbcType=VARCHAR}
					<if test='gfcfdm!=null and gfcfdm!=""'>
						AND cf.gfcfdm !=  #{gfcfdm,jdbcType=VARCHAR}
					</if>
				</when>
				<otherwise>
					<if test='gfcfdm!=null and gfcfdm!=""'>
						AND cf.gfcfdm = #{gfcfdm,jdbcType=VARCHAR}
					</if>
				</otherwise>
			</choose>
			<if test='hwxh!=null and hwxh!=""'>
				AND cf.hwxh =  #{hwxh,jdbcType=VARCHAR}
			</if>
			<if test='cfbh!=null and cfbh!=""'>
				AND cf.cfbh !=  #{cfbh,jdbcType=VARCHAR}
			</if>
		</where>
		ORDER BY cf.CFBH desc
	</select>

	<select id="getWarehouseDetail"  resultType="com.unis.base.common.vo.DCfxxsjyVO">
		<include refid="cfxxSql"></include>
		<where>
			<if test='kddm!=null and kddm!=""'>
				AND cf.kddm like CONCAT(#{kddm,jdbcType=VARCHAR},'%')
			</if>
			<if test='sfba!=null and sfba!=""'>
				AND cf.sfba =  #{sfba,jdbcType=DECIMAL}
			</if>
			<if test='cfxh!=null and cfxh!=""'>
				AND cf.cfxh =  #{cfxh,jdbcType=VARCHAR}
			</if>
			<if test='cfbh!=null and cfbh!=""'>
				AND cf.cfbh =  #{cfbh,jdbcType=VARCHAR}
			</if>
			<if test='hwxh!=null and hwxh!=""'>
				AND cf.hwxh =  #{hwxh,jdbcType=VARCHAR}
			</if>
			<if test='gfcfdm!=null and gfcfdm!=""'>
				AND cf.gfcfdm =  #{gfcfdm,jdbcType=VARCHAR}
			</if>
			<if test="zts == null">
				AND cf.status = 1
			</if>
		</where>
		ORDER BY cf.CFBH desc
	</select>

    <select id="getFirstData" resultType="com.unis.base.common.vo.DCfxxsjyVO">
        select first 1 *
        from base.d_cfxxsjy
        where  gfcfdm = #{gfcfdm,jdbcType=VARCHAR}
    </select>
</mapper>
