<?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="cn.iocoder.yudao.module.stockOperate.mapper.DlRepairSoiMapper">

    <resultMap id="BaseResultMap" type="cn.iocoder.yudao.module.stockOperate.entity.DlRepairSoi">
        <id property="id" column="id" jdbcType="VARCHAR"/>
        <result property="soId" column="so_id" jdbcType="VARCHAR"/>
        <result property="soiType" column="soi_type" jdbcType="VARCHAR"/>
        <result property="goodsId" column="goods_id" jdbcType="VARCHAR"/>
        <result property="goodsType" column="goods_type" jdbcType="VARCHAR"/>
        <result property="wareId" column="ware_id" jdbcType="VARCHAR"/>
        <result property="goodsCount" column="goods_count" jdbcType="INTEGER"/>
        <result property="goodsPrice" column="goods_price" jdbcType="DECIMAL"/>
        <result property="remark" column="remark" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="Base_SQL">
        select soi.id,
               so_id,
               soi_type,
               goods_id,
               goods_type,
               ware_id,
               goods_count,
               goods_price,
               soi.remark,
               so.create_time,
               so.so_status,
               so.corp_id
        from dl_repair_soi soi
                 left join
             dl_repair_so so
             on soi.so_id = so.id
        where soi.deleted = '0'
    </sql>

    <select id="getRepairSoiPage" resultMap="BaseResultMap">
        <include refid="Base_SQL" />
        <if test="map.goodsType != null and map.goodsType != ''">
            and soi.goods_type = #{map.goodsType}
        </if>
        <if test="map.soiType != null and map.soiType != ''">
            and soi.soi_type = #{map.soiType}
        </if>
        <if test="map.searchTimeArray != null and map.searchTimeArray.length > 0">
            and (so.create_time between #{map.searchTimeArray[0]} and #{map.searchTimeArray[1]})
        </if>
        <if test="map.soStatus != null and map.soStatus != ''">
            and so.so_status = #{map.soStatus}
        </if>
        <if test="map.corpId != null and map.corpId != ''">
            and so.corp_id = #{map.corpId}
        </if>
    </select>
</mapper>
