<?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.hzya.frame.u9c.bom.main.dao.impl.VHzyaBomMainDaoImpl">

    <resultMap id="get-VHzyaBomMainEntity-result" type="com.hzya.frame.u9c.bom.main.entity.VHzyaBomMainEntity" >
        <result property="id" column="id" jdbcType="INTEGER"/>
        <result property="skuCode" column="sku_code" jdbcType="VARCHAR"/>
        <result property="def1" column="def1" jdbcType="VARCHAR"/>
        <result property="name" column="name" jdbcType="VARCHAR"/>
        <result property="code" column="code" jdbcType="VARCHAR"/>
        <result property="versionCode" column="version_code" jdbcType="VARCHAR"/>
        <result property="classify" column="classify" jdbcType="VARCHAR"/>
        <result property="productionPurpose" column="production_purpose" jdbcType="VARCHAR"/>
        <result property="batch" column="batch" jdbcType="VARCHAR"/>
        <result property="mainBatch" column="main_batch" jdbcType="VARCHAR"/>
        <result property="effectiveDate" column="effective_date" jdbcType="VARCHAR"/>
        <result property="loseEfficacyDate" column="lose_efficacy_date" jdbcType="VARCHAR"/>
        <result property="modifyTime" column="modify_time" jdbcType="VARCHAR"/>
    </resultMap>
    <!-- 查询的字段-->
    <sql id = "VHzyaBomMainEntity_Base_Column_List">
        id
       ,sku_code 
       ,def1
        ,name
        ,code 
        ,version_code 
        ,classify 
        ,production_purpose 
        ,batch 
        ,main_batch 
        ,effective_date 
        ,lose_efficacy_date 
        ,modify_time 
     </sql>
 <!-- 查询 采用==查询 -->
 <select id="entity_list_base" resultMap="get-VHzyaBomMainEntity-result" parameterType = "com.hzya.frame.u9c.bom.main.entity.VHzyaBomMainEntity">
    select
    <include refid="VHzyaBomMainEntity_Base_Column_List" />
    from v_hzya_bom_main
    <trim prefix="where" prefixOverrides="and"> 
        <if test="id != null"> and id = #{id} </if>
        <if test="skuCode != null and skuCode != ''"> and sku_code = #{skuCode} </if>
        <if test="name != null and name != ''"> and name = #{name} </if>
        <if test="code != null and code != ''"> and code = #{code} </if>
        <if test="versionCode != null and versionCode != ''"> and version_code = #{versionCode} </if>
        <if test="classify != null and classify != ''"> and classify = #{classify} </if>
        <if test="productionPurpose != null and productionPurpose != ''"> and production_purpose = #{productionPurpose} </if>
        <if test="batch != null and batch != ''"> and batch = #{batch} </if>
        <if test="mainBatch != null and mainBatch != ''"> and main_batch = #{mainBatch} </if>
        <if test="effectiveDate != null and effectiveDate != ''"> and effective_date = #{effectiveDate} </if>
        <if test="loseEfficacyDate != null and loseEfficacyDate != ''"> and lose_efficacy_date = #{loseEfficacyDate} </if>
        <if test="modifyTime != null and modifyTime != ''"> and modify_time = #{modifyTime} </if>
        and sts='Y'
    </trim>
    <if test=" sort == ''.toString() "> order by sorts asc</if>
    <if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
</select>

    <!-- 睿本云接口专用  相二林 -->
    <select id="VHzyaBomMainEntity_entity_list_base_reabam" resultMap="get-VHzyaBomMainEntity-result" parameterType = "com.hzya.frame.u9c.bom.main.entity.VHzyaBomMainEntity">
        select
        <include refid="VHzyaBomMainEntity_Base_Column_List" />
        from v_hzya_bom_main
        <trim prefix="where" prefixOverrides="and">
            <if test="id != null"> and id = #{id} </if>
            <if test="skuCode != null and skuCode != ''"> and sku_code = #{skuCode} </if>
            <if test="name != null and name != ''"> and name = #{name} </if>
            <if test="code != null and code != ''"> and code = #{code} </if>
            <if test="versionCode != null and versionCode != ''"> and version_code = #{versionCode} </if>
            <if test="classify != null and classify != ''"> and classify = #{classify} </if>
            <if test="productionPurpose != null and productionPurpose != ''"> and production_purpose = #{productionPurpose} </if>
            <if test="batch != null and batch != ''"> and batch = #{batch} </if>
            <if test="mainBatch != null and mainBatch != ''"> and main_batch = #{mainBatch} </if>
            <if test="effectiveDate != null and effectiveDate != ''"> and effective_date = #{effectiveDate} </if>
            <if test="loseEfficacyDate != null and loseEfficacyDate != ''"> and lose_efficacy_date = #{loseEfficacyDate} </if>
            <if test="modifyTime != null and modifyTime != ''"> and modify_time >= #{modifyTime} </if>
            and def1 = 'True'
        </trim>
    </select>

<!-- 查询符合条件的数量 -->
<select id="entity_count" resultType="Integer" parameterType = "com.hzya.frame.u9c.bom.main.entity.VHzyaBomMainEntity">
        select  count(1)   from v_hzya_bom_main
    <trim prefix="where" prefixOverrides="and"> 
        <if test="id != null"> and id = #{id} </if>
        <if test="skuCode != null and skuCode != ''"> and sku_code = #{skuCode} </if>
        <if test="name != null and name != ''"> and name = #{name} </if>
        <if test="code != null and code != ''"> and code = #{code} </if>
        <if test="versionCode != null and versionCode != ''"> and version_code = #{versionCode} </if>
        <if test="classify != null and classify != ''"> and classify = #{classify} </if>
        <if test="productionPurpose != null and productionPurpose != ''"> and production_purpose = #{productionPurpose} </if>
        <if test="batch != null and batch != ''"> and batch = #{batch} </if>
        <if test="mainBatch != null and mainBatch != ''"> and main_batch = #{mainBatch} </if>
        <if test="effectiveDate != null and effectiveDate != ''"> and effective_date = #{effectiveDate} </if>
        <if test="loseEfficacyDate != null and loseEfficacyDate != ''"> and lose_efficacy_date = #{loseEfficacyDate} </if>
        <if test="modifyTime != null and modifyTime != ''"> and modify_time = #{modifyTime} </if>

    </trim>

    </select>

    <!-- 分页查询列表 采用like格式 -->
<select id="entity_list_like" resultMap="get-VHzyaBomMainEntity-result" parameterType = "com.hzya.frame.u9c.bom.main.entity.VHzyaBomMainEntity">
    select
    <include refid="VHzyaBomMainEntity_Base_Column_List" />
    from v_hzya_bom_main
    <trim prefix="where" prefixOverrides="and"> 
        <if test="id != null"> and id like concat('%',#{id},'%') </if>
        <if test="skuCode != null and skuCode != ''"> and sku_code like concat('%',#{skuCode},'%') </if>
        <if test="name != null and name != ''"> and name like concat('%',#{name},'%') </if>
        <if test="code != null and code != ''"> and code like concat('%',#{code},'%') </if>
        <if test="versionCode != null and versionCode != ''"> and version_code like concat('%',#{versionCode},'%') </if>
        <if test="classify != null and classify != ''"> and classify like concat('%',#{classify},'%') </if>
        <if test="productionPurpose != null and productionPurpose != ''"> and production_purpose like concat('%',#{productionPurpose},'%') </if>
        <if test="batch != null and batch != ''"> and batch like concat('%',#{batch},'%') </if>
        <if test="mainBatch != null and mainBatch != ''"> and main_batch like concat('%',#{mainBatch},'%') </if>
        <if test="effectiveDate != null and effectiveDate != ''"> and effective_date like concat('%',#{effectiveDate},'%') </if>
        <if test="loseEfficacyDate != null and loseEfficacyDate != ''"> and lose_efficacy_date like concat('%',#{loseEfficacyDate},'%') </if>
        <if test="modifyTime != null and modifyTime != ''"> and modify_time like concat('%',#{modifyTime},'%') </if>

    </trim>

</select>

<!-- 查询列表 字段采用or格式 -->
<select id="VHzyaBomMainentity_list_or" resultMap="get-VHzyaBomMainEntity-result" parameterType = "com.hzya.frame.u9c.bom.main.entity.VHzyaBomMainEntity">
    select
    <include refid="VHzyaBomMainEntity_Base_Column_List" />
    from v_hzya_bom_main
    <trim prefix="where" prefixOverrides="and"> 
        <if test="id != null"> or id = #{id} </if>
        <if test="skuCode != null and skuCode != ''"> or sku_code = #{skuCode} </if>
        <if test="name != null and name != ''"> or name = #{name} </if>
        <if test="code != null and code != ''"> or code = #{code} </if>
        <if test="versionCode != null and versionCode != ''"> or version_code = #{versionCode} </if>
        <if test="classify != null and classify != ''"> or classify = #{classify} </if>
        <if test="productionPurpose != null and productionPurpose != ''"> or production_purpose = #{productionPurpose} </if>
        <if test="batch != null and batch != ''"> or batch = #{batch} </if>
        <if test="mainBatch != null and mainBatch != ''"> or main_batch = #{mainBatch} </if>
        <if test="effectiveDate != null and effectiveDate != ''"> or effective_date = #{effectiveDate} </if>
        <if test="loseEfficacyDate != null and loseEfficacyDate != ''"> or lose_efficacy_date = #{loseEfficacyDate} </if>
        <if test="modifyTime != null and modifyTime != ''"> or modify_time = #{modifyTime} </if>

    </trim>

</select>


</mapper>

