<?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.glxp.mipsdl.thirddao.scpwxyy.A006headMapper">
    <resultMap id="BaseResultMap" type="com.glxp.mipsdl.entity.scpwxyy.A006head">
        <!--@mbg.generated-->
        <!--@Table udi_wms_ywj.a006head-->
        <id column="CODEFK" jdbcType="VARCHAR" property="codefk"/>
        <id column="BILLNO" jdbcType="VARCHAR" property="billno"/>
        <result column="BILLFLAG" jdbcType="VARCHAR" property="billflag"/>
        <result column="BILLDATE" jdbcType="DATE" property="billdate"/>
        <result column="BILLTYPE" jdbcType="VARCHAR" property="billtype"/>
        <result column="CONSIGNEECODE" jdbcType="VARCHAR" property="consigneecode"/>
        <result column="CONSIGNEENAME" jdbcType="VARCHAR" property="consigneename"/>
        <result column="CONSIGNORNAME" jdbcType="VARCHAR" property="consignorname"/>
        <result column="CONSIGNORCODE" jdbcType="VARCHAR" property="consignorcode"/>
        <result column="INOUTTYPE" jdbcType="VARCHAR" property="inouttype"/>
        <result column="CREATEUSER" jdbcType="VARCHAR" property="createuser"/>
        <result column="REVIEWUSER" jdbcType="VARCHAR" property="reviewuser"/>
        <result column="ADDRESS" jdbcType="VARCHAR" property="address"/>
        <result column="LINKMAN" jdbcType="VARCHAR" property="linkman"/>
        <result column="LINKTEL" jdbcType="VARCHAR" property="linktel"/>
        <result column="INVCODE" jdbcType="VARCHAR" property="invcode"/>
        <result column="INVNAME" jdbcType="VARCHAR" property="invname"/>
        <result column="REMARK" jdbcType="LONGVARCHAR" property="remark"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--@mbg.generated-->
        CODEFK, BILLNO, BILLFLAG, BILLDATE, BILLTYPE, CONSIGNEECODE, CONSIGNEENAME, CONSIGNORNAME,
        CONSIGNORCODE, INOUTTYPE, `CREATEUSER`, REVIEWUSER, ADDRESS, LINKMAN, LINKTEL, INVCODE,
        INVNAME, REMARK
    </sql>


    <select id="filterList" resultType="com.glxp.mipsdl.res.scwpxyy.A006headRespone">
        select *
        from a006head
        <where>
            <if test="billType != null and billType != ''">
                AND BILLTYPE = #{billType}
            </if>


            <if test="startDate != null and startDate != '' and databaseProductName == 'MySQL'">
                <![CDATA[
                and BILLDATE >= #{startDate}
                ]]>
            </if>
            <if test="endDate != null and endDate != '' and databaseProductName == 'MySQL'">
                <![CDATA[
                and BILLDATE >= #{endDate}
                ]]>
            </if>

            <if test="billNo != null and billNo != ''  and databaseProductName == 'MySQL'">
                AND  BILLNO like concat('%', #{billNo}, '%')
            </if>


            <if test="startDate != null and startDate != '' and databaseProductName == 'Oracle'">
                <![CDATA[
                and BILLDATE >= TO_DATE(#{startDate}, 'YYYY-MM-DD HH24:MI:SS')
                ]]>
            </if>
            <if test="endDate != null and endDate != '' and databaseProductName == 'Oracle'">
                <![CDATA[
                and BILLDATE <= TO_DATE(#{endDate}, 'YYYY-MM-DD HH24:MI:SS')
                ]]>
            </if>

            <if test="billNo != null and billNo != ''  and databaseProductName == 'Oracle'">
                AND  BILLNO like '%' || #{billNo} || '%'
            </if>
        </where>
        order by BILLDATE desc
    </select>
</mapper>