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

	<resultMap id="BaseResultMap" type="com.unis.base.server.entity.DYgxxsjyDO" >
        <result column="ygbh" property="ygbh" jdbcType="VARCHAR" />
        <result column="ygmc" property="ygmc" jdbcType="VARCHAR" />
        <result column="kddm" property="kddm" jdbcType="VARCHAR" />
        <result column="kdmc" property="kdmc" jdbcType="VARCHAR" />
        <result column="sjgr" property="sjgr" jdbcType="VARCHAR" />
        <result column="sjgr01" property="sjgr01" jdbcType="VARCHAR" />
        <result column="ygzj" property="ygzj" jdbcType="VARCHAR" />
        <result column="yggd" property="yggd" jdbcType="VARCHAR" />
        <result column="zygd" property="zygd" jdbcType="VARCHAR" />
        <result column="sjnd" property="sjnd" jdbcType="VARCHAR" />
        <result column="ygjd" property="ygjd" jdbcType="VARCHAR" />
        <result column="ygwd" property="ygwd" jdbcType="VARCHAR" />
        <result column="ygzt" property="ygzt" jdbcType="VARCHAR" />
        <result column="ygsyzt" property="ygsyzt" jdbcType="VARCHAR" />
        <result column="yglx" property="yglx" jdbcType="VARCHAR" />
        <result column="ygdmj" property="ygdmj" jdbcType="VARCHAR" />
        <result column="ygnzj" property="ygnzj" jdbcType="VARCHAR" />
        <result column="ygcykgd" property="ygcykgd" jdbcType="VARCHAR" />
        <result column="ygjckgd" property="ygjckgd" jdbcType="VARCHAR" />
        <result column="ygpmt" property="ygpmt" jdbcType="VARCHAR" />
        <result column="ygkqt" property="ygkqt" jdbcType="VARCHAR" />
		<result column="SFBA" property="sfba" jdbcType="DECIMAL" />
		<result column="sqzt" property="sqzt" jdbcType="VARCHAR" />
		<result column="lspzmc" property="lspzmc" jdbcType="VARCHAR" />
		<result column="lspzbm" property="lspzbm" jdbcType="VARCHAR" />
		<result column="fcsl" property="fcsl" jdbcType="DECIMAL" />
		<result column="rcny" property="rcny" jdbcType="VARCHAR" />
		<result column="yglxmc" property="yglxmc" jdbcType="VARCHAR" />
		<result column="crk_status" property="crkStatus" jdbcType="VARCHAR" />
		<result column="approval_comments" property="approvalComments" jdbcType="VARCHAR" />
		<result column="approval_date" property="approvalDate" jdbcType="DATE" />
		<result column="creator_code" property="creatorCode" jdbcType="VARCHAR" />
		<result column="create_date" property="createDate" jdbcType="TIMESTAMP" />
		<result column="refresher_code" property="refresherCode" jdbcType="VARCHAR" />
		<result column="refresh_time" property="refreshTime" jdbcType="TIMESTAMP" />
		<result column="approval_result" property="approvalResult" jdbcType="VARCHAR" />
		<result column="sfbaName" property="sfbaName" jdbcType="VARCHAR" />
		<result column="kqdm" property="kqdm" jdbcType="VARCHAR" />
		<result column="realYgbh" property="realYgbh" jdbcType="VARCHAR" />
		<result column="data_ver" property="dataVer" jdbcType="VARCHAR" />
    </resultMap>

    <sql id="Base_Column_List_common">
    	yg.id,yg.id as ygbh, yg.ygmc, yg.kddm,yg.kdmc, yg.sjgr, yg.sjgr01, yg.ygzj, yg.yggd, yg.zygd,
    	yg.sjnd, yg.ygjd, yg.ygwd, yg.ygzt, yg.ygsyzt, yg.yglx, yg.ygdmj, yg.ygnzj,
    	yg.ygcykgd, yg.ygjckgd, yg.ygpmt, yg.ygkqt,yg.sfba , yg.remark,yg.sqzt
		,yg.crk_status,yg.sjdw,yg.jsdw,yg.jldw,yg.lylx,yg.approver,yg.approval_comments,yg.approval_date
        ,yg.ygdm,yg.ajdh,yg.hwdm,yg.creator_code,yg.refresher_code
		,yg.ygjfssssfwh,yg.ywjrzz,yg.jdfs,yg.hjfs,yg.approval_result,yg.ygbh as realYgbh, yg.data_ver
    </sql>
	<delete id="deleteAll">
		delete from D_YGXXSJY
	</delete>

	<!-- 根据条件查询仓房信息 -->
    <select id="getOiltankList" parameterType="com.unis.base.common.vo.OiltankQueryVO" resultMap="BaseResultMap">
        SELECT
		<include refid="Base_Column_List_common"></include>,kd.kdmc
		<!-- 查库存 -->
		,xx.kcsl as fcsl, DATE_FORMAT(rksj,'%Y%m') as rcny,
		(select enumname from depot_qh.basic_enum where enumid = xx.pzbm) as lspzmc,xx.pzbm as lspzbm,
		(select enumname from depot_qh.basic_enum where enumid = yg.yglx) as yglxmc,
        -- trim(decode(yg.sfba,'1','待提交','2','待审核','3','驳回','5','审核通过')) as sfbaName,
		case
		when yg.sfba = '1' then '待提交'
		when yg.sfba = '2' then '待审核'
		when yg.sfba = '3' then '驳回'
		when yg.sfba = '53' then '审核通过' ELSE '' END as  sfbaName,
		case
			when send_result is null then '0'
			else '1'
		end delFlag
 		from D_YGXXSJY yg
		left join D_KDXXSJY kd on yg.KDDM = kd.KDDM
		<!-- 查库存 -->
		left join up.xwk_kcxx xx on xx.hwbm = yg.id
		<where>
			<choose>
				<when test="zts != null">
					and yg.status in
					<foreach collection="zts" item="zt" open="(" close=")" separator=",">
						#{zt}
					</foreach>
				</when>
		        <otherwise>
					and yg.status = 1
				</otherwise>
			</choose>
			<!-- 油罐编号 -->
	    	<if test="ygbh != null and ygbh != ''" >
	         	and	yg.ygbh LIKE concat(CONCAT('%',#{ygbh,jdbcType=VARCHAR}) ,'%')
	      	</if>
	      	<!-- 油罐名称 -->
	    	<if test="ygmc != null and ygmc != ''" >
	         	and	yg.ygmc LIKE concat(CONCAT('%',#{ygmc,jdbcType=VARCHAR}) ,'%')
	      	</if>
			<!-- 建造日期 -->
			<if test="jzksrq != null and jzksrq != ''">
				and date_format(yg.sjnd,'%Y-%d-%m') &gt;= #{jzksrq}
			</if>
			<if test="jzjsrq != null and jzjsrq != ''">
				and date_format(yg.sjnd,'%Y-%d-%m') &lt;= #{jzjsrq}
			</if>
	      	<!-- 库点编号 -->
	    	<if test="kddm != null and kddm != ''" >
	         	and	yg.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="ygzt != null and ygzt != ''" >
	         	and	yg.ygzt LIKE concat(CONCAT('%',#{ygzt,jdbcType=VARCHAR}) ,'%')
	      	</if>
			<!-- 是否备案 -->
			<if test='sfba != null'>
				and yg.SFBA = #{sfba,jdbcType=DECIMAL}
			</if>
		    <!--油罐类别-->
			<if test="yglb != null and yglb !=''">
				and xx.ygly = #{yglb,jdbcType=VARCHAR}
				and xx.lsxzbm='6877'
			</if>
		</where>
	<!--order by yg.ygbh desc-->
</select>

<!--	ORDER BY yg.ygbh,yg.kddm asc-->

	<select id="getOiltank" parameterType="java.lang.String" resultMap="BaseResultMap">
		SELECT
		<include refid="Base_Column_List_common"></include>,k.kqdm, yg.data_ver, yg.change_reason changeReason
		from
		D_YGXXSJY yg
		inner join base.d_kdxxsjy k on yg.kddm=k.kddm
		<where>
			yg.id = #{ygbh,jdbcType=VARCHAR}
			and yg.status = 1
		</where>
	</select>

    <!-- 更新企业信息 -->
    <update id="update" parameterType="com.unis.base.server.entity.DYgxxsjyDO">
	  	update D_YGXXSJY
	  	<set>
	  		<if test="ygmc != null">
	  			ygmc = #{ygmc,jdbcType=VARCHAR},
	  		</if>
	  		<if test="kddm != null">
	  			kddm = #{kddm,jdbcType=VARCHAR},
	  		</if>
	  		<if test="sjgr != null">
	  			sjgr = #{sjgr,jdbcType=VARCHAR},
	  		</if>
	  		<if test="sjgr01 != null">
	  			sjgr01 = #{sjgr01,jdbcType=VARCHAR},
	  		</if>
	  		<if test="ygzj != null">
	  			ygzj = #{ygzj,jdbcType=VARCHAR},
	  		</if>
	  		<if test="yggd != null">
	  			yggd = #{yggd,jdbcType=VARCHAR},
	  		</if>
	  		<if test="zygd != null">
	  			zygd = #{zygd,jdbcType=VARCHAR},
	  		</if>
	  		<if test="sjnd != null">
	  			sjnd = #{sjnd,jdbcType=VARCHAR},
	  		</if>
	  		<if test="ygjd != null">
	  			ygjd = #{ygjd,jdbcType=VARCHAR},
	  		</if>
	  		<if test="ygwd != null">
	  			ygwd = #{ygwd,jdbcType=VARCHAR},
	  		</if>
	  		<if test="ygzt != null">
	  			ygzt = #{ygzt,jdbcType=VARCHAR},
	  		</if>
	  		<if test="ygsyzt != null">
	  			ygsyzt = #{ygsyzt,jdbcType=VARCHAR},
	  		</if>
	  		<if test="yglx != null">
	  			yglx = #{yglx,jdbcType=VARCHAR},
	  		</if>
	  		<if test="ygdmj != null">
	  			ygdmj = #{ygdmj,jdbcType=VARCHAR},
	  		</if>
	  		<if test="ygnzj != null">
	  			ygnzj = #{ygnzj,jdbcType=VARCHAR},
	  		</if>
	  		<if test="ygcykgd != null">
	  			ygcykgd = #{ygcykgd,jdbcType=VARCHAR},
	  		</if>
	  		<if test="ygjckgd != null">
	  			ygjckgd = #{ygjckgd,jdbcType=VARCHAR},
	  		</if>
	  		<if test="ygpmt != null">
	  			ygpmt = #{ygpmt,jdbcType=VARCHAR},
	  		</if>
	  		<if test="ygkqt != null">
	  			ygkqt = #{ygkqt,jdbcType=VARCHAR},
	  		</if>
			<if test="sfba != null" >
				sfba = #{sfba,jdbcType=DECIMAL},
			</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="sqzt != null">
				sqzt = #{sqzt,jdbcType=VARCHAR},
			</if>
			<if test="sjdw != null and sjdw !=''" >
				sjdw = #{sjdw,jdbcType=VARCHAR},
			</if>
			<if test="jsdw != null and jsdw !=''" >
				jsdw = #{jsdw,jdbcType=VARCHAR},
			</if>
			<if test="jldw != null and jldw !=''" >
				jldw = #{jldw,jdbcType=VARCHAR},
			</if>
			<if test="lylx != null and lylx !=''" >
				lylx = #{lylx,jdbcType=VARCHAR},
			</if>
			<if test="kdmc != null and kdmc !=''" >
				kdmc = #{kdmc,jdbcType=VARCHAR},
			</if>
			<if test="approver != null and approver !=''" >
				approver = #{approver,jdbcType=VARCHAR},
			</if>
			<if test="approvalComments != null and approvalComments !=''" >
				approval_comments = #{approvalComments,jdbcType=VARCHAR},
			</if>
			<if test="approvalDate != null" >
				approval_date = #{approvalDate,jdbcType=VARCHAR},
			</if>
			<if test="crkStatus != null and crkStatus !=''" >
				crk_status = #{crkStatus,jdbcType=VARCHAR},
			</if>
			<if test="refreshTime != null" >
				refresh_time = #{refreshTime,jdbcType=TIMESTAMP},
			</if>
			<if test="sendResult != null and sendResult != ''" >
				send_result = #{sendResult,jdbcType=VARCHAR},
			</if>
			<if test="ygjfssssfwh != null and ygjfssssfwh != ''" >
				ygjfssssfwh = #{ygjfssssfwh,jdbcType=VARCHAR},
			</if>
			<if test="ywjrzz != null and ywjrzz != ''" >
				ywjrzz = #{ywjrzz,jdbcType=VARCHAR},
			</if>
			<if test="jdfs != null and jdfs != ''" >
				jdfs = #{jdfs,jdbcType=VARCHAR},
			</if>
			<if test="hjfs != null and hjfs != ''" >
				hjfs = #{hjfs,jdbcType=VARCHAR},
			</if>
			<if test="tyshxydm != null and tyshxydm != ''" >
				tyshxydm = #{tyshxydm,jdbcType=VARCHAR},
			</if>
			<if test="approvalResult != null and approvalResult != ''" >
				approval_result = #{approvalResult,jdbcType=VARCHAR},
			</if>
			<if test="realYgbh != null and realYgbh != ''" >
				ygbh = #{realYgbh,jdbcType=VARCHAR},
			</if>
            <if test="dataVer != null and dataVer !=''">
                data_ver = #{dataVer, jdbcType=INTEGER},
            </if>
            <if test="changeReason != null">
                change_reason = #{changeReason, jdbcType=VARCHAR},
            </if>
	  	</set>
	  	where id = #{id,jdbcType=VARCHAR}
  </update>

  <!-- 添加库点信息 -->
    <insert id="insert" parameterType="com.unis.base.server.entity.DYgxxsjyDO">
    	insert into D_YGXXSJY
	    <trim prefix="(" suffix=")" suffixOverrides="," >
	      <if test="realYgbh != null" >
	        ygbh,
	      </if>
	      <if test="ygmc != null" >
	        ygmc,
	      </if>
	      <if test="kddm != null" >
	        kddm,
	      </if>
	      <if test="sjgr != null" >
	        sjgr,
	      </if>
	      <if test="sjgr01 != null" >
	        sjgr01,
	      </if>
	      <if test="ygzj != null" >
	        ygzj,
	      </if>
	      <if test="yggd != null" >
	        yggd,
	      </if>
	      <if test="zygd != null" >
	        zygd,
	      </if>
	      <if test="sjnd != null" >
	        sjnd,
	      </if>
	      <if test="ygjd != null" >
	        ygjd,
	      </if>
	      <if test="ygwd != null" >
	        ygwd,
	      </if>
	      <if test="ygzt != null" >
	        ygzt,
	      </if>

	      <if test="ygsyzt != null" >
	        ygsyzt,
	      </if>
	      <if test="yglx != null" >
	        yglx,
	      </if>
	      <if test="ygdmj != null" >
	        ygdmj,
	      </if>
	      <if test="ygnzj != null" >
	        ygnzj,
	      </if>
	      <if test="ygcykgd != null" >
	        ygcykgd,
	      </if>
	      <if test="ygjckgd != null" >
	        ygjckgd,
	      </if>
	      <if test="ygpmt != null" >
	        ygpmt,
	      </if>
	      <if test="ygkqt != null" >
	        ygkqt,
	      </if>
			<if test="sfba != null" >
				SFBA,
			</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="sqzt != null" >
			sqzt,
		</if>
		<if test="ygdm != null and ygdm !=''" >
			ygdm,
		</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="ajdh != null and ajdh !=''" >
			ajdh,
		</if>
		<if test="hwdm != null and hwdm !=''" >
			hwdm,
		</if>
		<if test="lylx != null and lylx !=''" >
			lylx,
		</if>
		<if test="id != null and id !=''" >
			id,
		</if>
		<if test="kdmc != null and kdmc !=''" >
			kdmc,
		</if>
		<if test="crkStatus != null and crkStatus !=''" >
			crk_status,
		</if>
		<if test="createDate != null" >
			create_date,
		</if>
		<if test="ygjfssssfwh != null and ygjfssssfwh != ''" >
			ygjfssssfwh,
		</if>
		<if test="ywjrzz != null and ywjrzz != ''" >
			ywjrzz,
		</if>
		<if test="jdfs != null and jdfs != ''" >
			jdfs,
		</if>
		<if test="hjfs != null and hjfs != ''" >
			hjfs,
		</if>
		<if test="tyshxydm != null and tyshxydm != ''" >
			tyshxydm,
		</if>
		<if test="approvalResult != null and approvalResult != ''" >
			approval_result,
		</if>
            <if test="changeReason != null">
                change_reason ,
            </if>
	    </trim>
	    <trim prefix="values (" suffix=")" suffixOverrides="," >
	      <if test="realYgbh != null" >
	        #{realYgbh,jdbcType=VARCHAR},
	      </if>
	      <if test="ygmc != null" >
	        #{ygmc,jdbcType=VARCHAR},
	      </if>
	      <if test="kddm != null" >
	        #{kddm,jdbcType=VARCHAR},
	      </if>
	      <if test="sjgr != null" >
	        #{sjgr,jdbcType=VARCHAR},
	      </if>
	      <if test="sjgr01 != null" >
	        #{sjgr01,jdbcType=VARCHAR},
	      </if>
	      <if test="ygzj != null" >
	        #{ygzj,jdbcType=VARCHAR},
	      </if>
	      <if test="yggd != null" >
	        #{yggd,jdbcType=VARCHAR},
	      </if>
	      <if test="zygd != null" >
	        #{zygd,jdbcType=VARCHAR},
	      </if>
	      <if test="sjnd != null" >
	        #{sjnd,jdbcType=VARCHAR},
	      </if>
	      <if test="ygjd != null" >
	        #{ygjd,jdbcType=VARCHAR},
	      </if>
	      <if test="ygwd != null" >
	        #{ygwd,jdbcType=VARCHAR},
	      </if>
	      <if test="ygzt != null" >
	        #{ygzt,jdbcType=VARCHAR},
	      </if>

	      <if test="ygsyzt != null" >
	        #{ygsyzt,jdbcType=VARCHAR},
	      </if>
	      <if test="yglx != null" >
	        #{yglx,jdbcType=VARCHAR},
	      </if>
	      <if test="ygdmj != null" >
	        #{ygdmj,jdbcType=VARCHAR},
	      </if>
	      <if test="ygnzj != null" >
	        #{ygnzj,jdbcType=VARCHAR},
	      </if>
	      <if test="ygcykgd != null" >
	        #{ygcykgd,jdbcType=VARCHAR},
	      </if>
	      <if test="ygjckgd != null" >
	        #{ygjckgd,jdbcType=VARCHAR},
	      </if>

	       <if test="ygpmt != null" >
	        #{ygpmt,jdbcType=VARCHAR},
	      </if>
	       <if test="ygkqt != null" >
	        #{ygkqt,jdbcType=VARCHAR},
	      </if>
			<if test="sfba != null" >
				#{sfba,jdbcType=DECIMAL},
			</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="sqzt != null" >
				#{sqzt,jdbcType=VARCHAR},
			</if>
			<if test="ygdm != null and ygdm !=''" >
				#{ygdm,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="ajdh != null and ajdh !=''" >
				#{ajdh,jdbcType=VARCHAR},
			</if>
			<if test="hwdm != null and hwdm !=''" >
				#{hwdm,jdbcType=VARCHAR},
			</if>
			<if test="lylx != null and lylx !=''" >
				#{lylx,jdbcType=VARCHAR},
			</if>
			<if test="id != null and id !=''" >
				#{id,jdbcType=VARCHAR},
			</if>
			<if test="kdmc != null and kdmc !=''" >
				#{kdmc,jdbcType=VARCHAR},
			</if>
			<if test="crkStatus != null and crkStatus !=''" >
				#{crkStatus,jdbcType=VARCHAR},
			</if>
			<if test="createDate != null" >
				#{createDate,jdbcType=TIMESTAMP},
			</if>
			<if test="ygjfssssfwh != null and ygjfssssfwh != ''" >
				#{ygjfssssfwh,jdbcType=VARCHAR},
			</if>
			<if test="ywjrzz != null and ywjrzz != ''" >
				#{ywjrzz,jdbcType=VARCHAR},
			</if>
			<if test="jdfs != null and jdfs != ''" >
				#{jdfs,jdbcType=VARCHAR},
			</if>
			<if test="hjfs != null and hjfs != ''" >
				#{hjfs,jdbcType=VARCHAR},
			</if>
			<if test="tyshxydm != null and tyshxydm != ''" >
				#{tyshxydm,jdbcType=VARCHAR},
			</if>
			<if test="approvalResult != null and approvalResult != ''" >
				#{approvalResult,jdbcType=VARCHAR},
			</if>
            <if test="changeReason != null">
                #{changeReason, jdbcType=VARCHAR},
            </if>
	    </trim>
    </insert>

  <select id="getMaxCodeById" parameterType="java.lang.String" resultType="java.lang.String">
        SELECT
        	max(yg.ygbh)
        from
			D_YGXXSJY yg
			WHERE yg.ygbh like CONCAT(#{kddm,jdbcType=VARCHAR},'%')
    </select>
	<select id="updateSqzt" parameterType="java.lang.String">
		update
		D_YGXXSJY
		set sqzt=#{sqzt,jdbcType=VARCHAR}
		WHERE ygbh =#{ygbh,jdbcType=VARCHAR}
	</select>
	<select id="selectTankList" resultType="com.unis.base.server.entity.DTankDO">
		select tank.id id,
		tank.storagetank_code storagetankCode,
		tank.storagetank_name storagetankName,
		tank.org_code orgCode,
		tank.tank_capacity tankCapacity,
		tank.createdate createdate,
		tank.facilities_type facilitiesType,
		tank.heating_type heatingType,
		tank.tank_type tankType,
		tank.diameter diameter,
		tank.height height,
		tank.builddate builddate,
		tank.tank_apply tankApply,
		tank.tank_status tankStatus,
		tank.org_id orgId,
		tank.updatetime updatetime,
		tank.bottom_area bottomArea,
		tank.design_height designHeight,
		tank.oil_height oilHeight,
		tank.insport_height insportHeight,
		tank.tank_chart tankChart,
		tank.tanklib_chart tanklibChart,
		tank.library_type libraryType,
		info.citycouncil_code org,
		enum.enumname yglx, tank.crk_status crkStatus from
		depot_qh.basic_tank tank,depot_qh.org_info
		info,depot_qh.basic_enum enum
		where
		tank.org_id =
		info.org_id and tank.tank_type = enum.enumid and tank.del_flag = 1
	</select>
	<select id="getOiltankPages" resultType="com.unis.base.common.vo.OiltankVO">
		select qy.*,tz.tyshxydm,tz.qyxz from (select yg.kddm,yg.kdmc from D_YGXXSJY yg group by yg.kddm,yg.kdmc) qy,tz_slqy tz
		<where>
			CONCAT(tz.zzjgdm, '001') = qy.kddm
			<!-- 库点名称 -->
			<if test="kdmc != null and kdmc != ''" >
				and	qy.kdmc LIKE concat(CONCAT('%',#{kdmc,jdbcType=VARCHAR}) ,'%')
			</if>
		</where>
	</select>
	<select id="selectYgList" resultType="com.unis.base.server.entity.DYgxxsjyDO">
		   SELECT
        	yg.id,yg.ygbh, yg.ygmc, yg.kddm,yg.kdmc,yg.yglx,yg.sjgr
        from
			D_YGXXSJY yg
			<where>
				<if test="kddm != null and kddm != ''" >
					and	yg.kddm LIKE concat(CONCAT('%',#{kddm,jdbcType=VARCHAR}) ,'%')
				</if>
				<!-- 库点名称 -->
				<if test="kdmc != null and kdmc != ''" >
					and	kd.kdmc LIKE concat(CONCAT('%',#{kdmc,jdbcType=VARCHAR}) ,'%')
				</if>
			</where>
	</select>

	<select id="getOilTankInfo" resultType="com.unis.base.server.entity.DYgxxsjyDO">
		select
			<include refid="Base_Column_List_common"></include>
		from D_YGXXSJY yg
		<where>
			status = 1
			<if test="kddm != null and kddm != ''" >
				and	yg.kddm = #{kddm,jdbcType=VARCHAR}
			</if>
			<if test="ygbh != null and ygbh != ''" >
				and	yg.ygbh = #{ygbh,jdbcType=VARCHAR}
			</if>
            <if test="ygdm != null and ygdm != ''" >
                and	yg.ygdm = #{ygdm, jdbcType=VARCHAR}
            </if>
		</where>
	</select>

	<select id="getOilTankInfoList" resultType="com.unis.base.server.entity.DYgxxsjyDO">
		select
			<include refid="Base_Column_List_common"></include>
		from D_YGXXSJY yg
		<where>
			status = 1
			<if test="kddm != null and kddm != ''" >
				and	yg.kddm = #{kddm,jdbcType=VARCHAR}
			</if>
		</where>
	</select>

	<select id="getMaxCode" parameterType="java.lang.String" resultType="java.lang.String">
		SELECT
		max(${columnName})
		from
		D_YGXXSJY
		<where>
			<if test="kddm != null and kddm !=''">
				kddm = #{kddm,jdbcType=VARCHAR}
			</if>
		</where>
	</select>

	<delete id="deleteById">
		delete from D_YGXXSJY  where id= #{id}
	</delete>
</mapper>
