<?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.base.plan.mapper.AreaOptimizationResultInfoMapper">

    <select id="selectAreaOptimizationResultInfoList" parameterType="com.base.plan.model.dto.request.AreaOptimizationResultReqDTO" resultType="com.base.plan.model.entity.AreaOptimizationResultInfo">
        select * from area_optimization_result_info
        <where>

            <if test="req.ids != null and req.ids.size()>0">
                id in
                <foreach collection="req.ids" index="index" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>


            <if test="req.reqIds != null and req.reqIds.size()>0">
                and req_id in
                <foreach collection="req.reqIds" index="index" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="req.startTime!=null and req.endTime!=null" >
                and  (start_time &gt;= #{req.startTime} and end_time &lt;= #{req.endTime}) or (start_time &lt;= #{req.startTime} and end_time &gt;= #{req.startTime})

             or (start_time &gt;= #{req.startTime} and start_time &lt;= #{req.endTime})
            </if>


        </where>
    </select>
</mapper>