<?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.cf.imes.module.executor.dal.mysql.orderItem.OrderItemTempMapper">
    <select id="selectOrderItemTempForItem"
            resultType="com.cf.imes.module.executor.dal.dataobject.orderItem.OrderItemTempDO">

        SELECT *
        FROM order_item_temp
        WHERE id > #{lastId}
        AND order_id = #{orderId}
        AND organ_id = #{organId}
        AND source_id = 0

        <if test="bodyIds != null and bodyIds.size() > 0">
            AND body_id IN
            <foreach item="bodyId"
                     collection="bodyIds"
                     open="("
                     separator=","
                     close=")">
                #{bodyId}
            </foreach>
        </if>

        <if test="compIds != null and compIds.size() > 0">
            AND comp_id IN
            <foreach item="compId"
                     collection="compIds"
                     open="("
                     separator=","
                     close=")">
                #{compId}
            </foreach>
        </if>

        ORDER BY id
        LIMIT #{pageSize}

    </select>
</mapper>