<?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.shinsoft.sto.mapper.ware.HProdMasterMapper" >
  <resultMap id="BaseResultMap" type="com.shinsoft.sto.model.ware.HProdMaster" >
    <id column="id" property="id" jdbcType="VARCHAR" />
    <result column="belong_id" property="belongId" jdbcType="VARCHAR" />
    <result column="prod_no" property="prodNo" jdbcType="VARCHAR" />
    <result column="owner_company" property="ownerCompany" jdbcType="VARCHAR" />
    <result column="receiving_company" property="receivingCompany" jdbcType="VARCHAR" />
    <result column="customer_company" property="customerCompany" jdbcType="VARCHAR" />
    <result column="material_id" property="materialId" jdbcType="VARCHAR" />
    <result column="st_grade" property="stGrade" jdbcType="VARCHAR" />
    <result column="weight" property="weight" jdbcType="DECIMAL" />
    <result column="quantity" property="quantity" jdbcType="DECIMAL" />
    <result column="delivery_address" property="deliveryAddress" jdbcType="VARCHAR" />
    <result column="in_truck_no" property="inTruckNo" jdbcType="VARCHAR" />
    <result column="in_dtm" property="inDtm" jdbcType="TIMESTAMP" />
    <result column="in_user_name" property="inUserName" jdbcType="VARCHAR" />
    <result column="lock_flag" property="lockFlag" jdbcType="VARCHAR" />
    <result column="in_flag" property="inFlag" jdbcType="VARCHAR" />
    <result column="out_flag" property="outFlag" jdbcType="VARCHAR" />
    <result column="attrib_01" property="attrib_01" jdbcType="VARCHAR" />
    <result column="attrib_02" property="attrib_02" jdbcType="VARCHAR" />
    <result column="attrib_03" property="attrib_03" jdbcType="VARCHAR" />
    <result column="attrib_04" property="attrib_04" jdbcType="VARCHAR" />
    <result column="attrib_05" property="attrib_05" jdbcType="VARCHAR" />
    <result column="attrib_06" property="attrib_06" jdbcType="VARCHAR" />
    <result column="attrib_07" property="attrib_07" jdbcType="VARCHAR" />
    <result column="attrib_08" property="attrib_08" jdbcType="VARCHAR" />
    <result column="attrib_09" property="attrib_09" jdbcType="VARCHAR" />
    <result column="attrib_10" property="attrib_10" jdbcType="VARCHAR" />
    <result column="attrib_11" property="attrib_11" jdbcType="VARCHAR" />
    <result column="attrib_12" property="attrib_12" jdbcType="VARCHAR" />
    <result column="attrib_13" property="attrib_13" jdbcType="VARCHAR" />
    <result column="attrib_14" property="attrib_14" jdbcType="VARCHAR" />
    <result column="attrib_15" property="attrib_15" jdbcType="VARCHAR" />
    <result column="attrib_16" property="attrib_16" jdbcType="VARCHAR" />
    <result column="attrib_17" property="attrib_17" jdbcType="VARCHAR" />
    <result column="attrib_18" property="attrib_18" jdbcType="VARCHAR" />
    <result column="attrib_19" property="attrib_19" jdbcType="VARCHAR" />
    <result column="attrib_20" property="attrib_20" jdbcType="VARCHAR" />
    <result column="attrib_21" property="attrib_21" jdbcType="VARCHAR" />
    <result column="attrib_22" property="attrib_22" jdbcType="VARCHAR" />
    <result column="attrib_23" property="attrib_23" jdbcType="VARCHAR" />
    <result column="attrib_24" property="attrib_24" jdbcType="VARCHAR" />
    <result column="attrib_25" property="attrib_25" jdbcType="VARCHAR" />
    <result column="remark_1" property="remark_1" jdbcType="VARCHAR" />
    <result column="remark_2" property="remark_2" jdbcType="VARCHAR" />
    <result column="remark_3" property="remark_3" jdbcType="VARCHAR" />
    <result column="remark_4" property="remark_4" jdbcType="VARCHAR" />
    <result column="remark_5" property="remark_5" jdbcType="VARCHAR" />
    <result column="add_id" property="addId" jdbcType="VARCHAR" />
    <result column="add_time" property="addTime" jdbcType="TIMESTAMP" />
    <result column="modify_id" property="modifyId" jdbcType="VARCHAR" />
    <result column="modify_time" property="modifyTime" jdbcType="TIMESTAMP" />
    <result column="cancel_id" property="cancelId" jdbcType="VARCHAR" />
    <result column="cancel_time" property="cancelTime" jdbcType="TIMESTAMP" />
    <result column="cancel_flag" property="cancelFlag" jdbcType="VARCHAR" />
  </resultMap>

    <sql id="QueryWhere">
        where 1=1
        <if test="parms.prodNo != null and parms.prodNo != ''">
            and hpm.prod_no like '%' || #{parms.prodNo} || '%'
        </if>
        <if test="parms.ownerCompany != null and parms.ownerCompany != ''">
            and hpm.owner_company = #{parms.ownerCompany}
        </if>
        <if test="parms.receivingCompany != null and parms.receivingCompany != ''">
            and hpm.receiving_company = #{parms.receivingCompany}
        </if>
        <if test="parms.customerCompany != null and parms.customerCompany != ''">
            and hpm.customer_company = #{parms.customerCompany}
        </if>
        <if test="parms.materialId != null and parms.materialId != ''">
            and hpm.material_id = #{parms.materialId}
        </if>
        <if test="parms.stGrade != null and parms.stGrade != ''">
            and hpm.st_grade like '%' || #{parms.stGrade} || '%'
        </if>
        <if test="parms.inTruckNo != null and parms.inTruckNo != ''">
            and hpm.in_truck_no like '%' || #{parms.inTruckNo} || '%'
        </if>
        <if test="parms.inFlag != null and parms.inFlag != ''">
            and hpm.in_flag = #{parms.inFlag}
        </if>
        <if test="parms.outFlag != null and parms.outFlag != ''">
            and hpm.out_flag = #{parms.outFlag}
        </if>
        and hpm.cancel_flag = '0'
    </sql>

    <select id="selectHProdMasterPage" resultMap="BaseResultMap" parameterType="map">
        select
            hpm.id,
            hpm.belong_id,
            hpm.prod_no,
            hpm.owner_company,
            hpm.receiving_company,
            hpm.customer_company,
            hpm.material_id,
            hpm.st_grade,
            hpm.weight,
            hpm.quantity,
            hpm.delivery_address,
            hpm.in_truck_no,
            hpm.in_dtm,
            hpm.in_user_name,
            hpm.lock_flag,
            hpm.in_flag,
            hpm.out_flag,
            hpm.attrib_01,
            hpm.attrib_02,
            hpm.attrib_03,
            hpm.attrib_04,
            hpm.attrib_05,
            hpm.attrib_06,
            hpm.attrib_07,
            hpm.attrib_08,
            hpm.attrib_09,
            hpm.attrib_10,
            hpm.attrib_11,
            hpm.attrib_12,
            hpm.attrib_13,
            hpm.attrib_14,
            hpm.attrib_15,
            hpm.attrib_16,
            hpm.attrib_17,
            hpm.attrib_18,
            hpm.attrib_19,
            hpm.attrib_20,
            hpm.attrib_21,
            hpm.attrib_22,
            hpm.attrib_23,
            hpm.attrib_24,
            hpm.attrib_25,
            hpm.remark_1,
            hpm.remark_2,
            hpm.remark_3,
            hpm.remark_4,
            hpm.remark_5,
            hpm.add_id,
            hpm.add_time,
            hpm.modify_id,
            hpm.modify_time,
            hpm.cancel_id,
            hpm.cancel_time,
            hpm.cancel_flag
        from H_PROD_MASTER hpm
        <include refid="QueryWhere"/>
        order by hpm.add_time desc
    </select>
</mapper>

