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

    <!-- 查询出库单统计分页列表数据 -->
    <select id="selectWarehouseOutPage" resultType="com.hys.app.model.erp.vo.WarehouseOutStatistics" useCache="false">
        select ewo.dept_name,ewo.warehouse_name,ewo.sn,ewo.out_time,ewop.* from erp_warehouse_out_item ewop
        left join erp_warehouse_out ewo on ewop.warehouse_out_id = ewo.id
        <where>
            ewop.id is not null
            <if test="param.sn != null and param.sn != ''">
                and ewo.sn like concat('%',#{param.sn},'%')
            </if>
            <if test="param.deptId != null and param.deptId != 0">
                and ewo.dept_id = #{param.deptId}
            </if>
            <if test="param.warehouseId != null and param.warehouseId != 0">
                and ewo.warehouse_id = #{param.warehouseId}
            </if>
            <if test="param.categoryId != null and param.categoryId != 0">
                and ewop.category_id = #{param.categoryId}
            </if>
            <if test="param.productName != null and param.productName != ''">
                and ewop.product_name like concat('%',#{param.productName},'%')
            </if>
            <if test="param.startTime != null and param.startTime != 0">
                and ewo.out_time &gt;= #{param.startTime}
            </if>
            <if test="param.endTime != null and param.endTime != 0">
                and ewo.out_time &lt;= #{param.endTime}
            </if>
        </where>
        order by ewo.create_time desc
    </select>

    <!-- 查询导出出库单统计列表 -->
    <select id="selectWarehouseOutList" resultType="com.hys.app.model.erp.vo.WarehouseOutStatistics" useCache="false">
        select ewo.dept_name,ewo.warehouse_name,ewo.sn,ewo.out_time,ewop.* from erp_warehouse_out_item ewop
        left join erp_warehouse_out ewo on ewop.warehouse_out_id = ewo.id
        <where>
            ewop.id is not null
            <if test="param.sn != null and param.sn != ''">
                and ewo.sn like concat('%',#{param.sn},'%')
            </if>
            <if test="param.deptId != null and param.deptId != 0">
                and ewo.dept_id = #{param.deptId}
            </if>
            <if test="param.warehouseId != null and param.warehouseId != 0">
                and ewo.warehouse_id = #{param.warehouseId}
            </if>
            <if test="param.categoryId != null and param.categoryId != 0">
                and ewop.category_id = #{param.categoryId}
            </if>
            <if test="param.productName != null and param.productName != ''">
                and ewop.product_name like concat('%',#{param.productName},'%')
            </if>
            <if test="param.startTime != null and param.startTime != 0">
                and ewo.out_time &gt;= #{param.startTime}
            </if>
            <if test="param.endTime != null and param.endTime != 0">
                and ewo.out_time &lt;= #{param.endTime}
            </if>
        </where>
        order by ewo.create_time desc
    </select>
</mapper>