<?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.hys.app.mapper.erp.WarehouseEntryMapper">

    <!-- 查询入库单统计分页列表数据 -->
    <select id="selectWarehouseEntryPage" resultType="com.hys.app.model.erp.vo.WarehouseEntryStatistics" useCache="false">
        select ewe.dept_name,ewe.warehouse_name,ewe.supplier_name,ewe.sn as entry_sn,ewe.entry_time,ewep.* from erp_warehouse_entry_product ewep
        left join erp_warehouse_entry ewe on ewep.warehouse_entry_id = ewe.id
        <where>
            ewep.id is not null
            <if test="param.sn != null and param.sn != ''">
                and ewe.sn like concat('%',#{param.sn},'%')
            </if>
            <if test="param.deptId != null and param.deptId != 0">
                and ewe.dept_id = #{param.deptId}
            </if>
            <if test="param.warehouseId != null and param.warehouseId != 0">
                and ewe.warehouse_id = #{param.warehouseId}
            </if>
            <if test="param.supplierId != null and param.supplierId != 0">
                and ewe.supplier_id = #{param.supplierId}
            </if>
            <if test="param.categoryId != null and param.categoryId != 0">
                and ewep.category_id = #{param.categoryId}
            </if>
            <if test="param.productName != null and param.productName != ''">
                and ewep.`name` like concat('%',#{param.productName},'%')
            </if>
            <if test="param.supplierName != null and param.supplierName != ''">
                and ewe.supplier_name like concat('%',#{param.supplierName},'%')
            </if>
            <if test="param.entryTimeBegin != null and param.entryTimeBegin != 0">
                and ewe.entry_time &gt;= #{param.startTime}
            </if>
            <if test="param.entryTimeEnd != null and param.entryTimeEnd != 0">
                and ewe.entry_time &lt;= #{param.endTime}
            </if>
        </where>
        order by ewe.create_time desc
    </select>

    <!-- 查询导出入库单统计列表 -->
    <select id="selectWarehouseEntryList" resultType="com.hys.app.model.erp.vo.WarehouseEntryStatistics" useCache="false">
        select ewe.dept_name,ewe.warehouse_name,ewe.supplier_name,ewe.sn as entry_sn,ewe.entry_time,ewep.* from erp_warehouse_entry_product ewep
        left join erp_warehouse_entry ewe on ewep.warehouse_entry_id = ewe.id
        <where>
            ewep.id is not null
            <if test="param.sn != null and param.sn != ''">
                and ewe.sn like concat('%',#{param.sn},'%')
            </if>
            <if test="param.deptId != null and param.deptId != 0">
                and ewe.dept_id = #{param.deptId}
            </if>
            <if test="param.warehouseId != null and param.warehouseId != 0">
                and ewe.warehouse_id = #{param.warehouseId}
            </if>
            <if test="param.supplierId != null and param.supplierId != 0">
                and ewe.supplier_id = #{param.supplierId}
            </if>
            <if test="param.categoryId != null and param.categoryId != 0">
                and ewep.category_id = #{param.categoryId}
            </if>
            <if test="param.productName != null and param.productName != ''">
                and ewep.`name` like concat('%',#{param.productName},'%')
            </if>
            <if test="param.supplierName != null and param.supplierName != ''">
                and ewe.supplier_name like concat('%',#{param.supplierName},'%')
            </if>
            <if test="param.entryTimeBegin != null and param.entryTimeBegin != 0">
                and ewe.entry_time &gt;= #{param.startTime}
            </if>
            <if test="param.entryTimeEnd != null and param.entryTimeEnd != 0">
                and ewe.entry_time &lt;= #{param.endTime}
            </if>
        </where>
        order by ewe.create_time desc
    </select>
</mapper>