Mybatis映射文件SQL代码:
<select id="getScheduleinfo" parameterType="Scheduleinfo" resultMap="ScheduleinfoEntity">
SELECT * FROM scheduleinfo WHERE 1=1
<if test="fromstationname !=null and fromstationname!='' ">
AND fromstationname LIKE CONCAT(CONCAT('%', #{fromstationname}),'%')
</if>
<if test="reachstationname !=null and reachstationname!='' ">
AND reachstationname LIKE CONCAT(CONCAT('%', #{reachstationname}),'%')
</if>
<if test="iridedate!=null and iridedate!=''">
AND iridedate =#{iridedate}
</if>
//时间段查询处理hh:mm -——hh:mm
<if test="sixdian!=null and sixdian!=''">
AND (TIME_FORMAT(startinfirsttime, '%H:%i') between TIME_FORMAT(#{sixdian}, '%H:%i') and TIME_FORMAT(#{twelvedian}, '%H:%i')
</if>
<if test="threejieduan!=null and threejieduan!=''">
OR TIME_FORMAT(startinfirsttime, '%H:%i') between TIME_FORMAT(#{threejieduan}, '%H:%i') and TIME_FORMAT(#{fourjieduan}, '%H:%i')
</if>
<if test="five!=null and five!=''">
OR TIME_FORMAT(startinfirsttime, '%H:%i') between TIME_FORMAT(#{five}, '%H:%i') and TIME_FORMAT(#{six}, '%H:%i')
</if>
<if test="seven!=null and seven!=''">
OR TIME_FORMAT(startinfirsttime, '%H:%i') between TIME_FORMAT(#{seven}, '%H:%i') and TIME_FORMAT(#{eight}, '%H:%i')
</if>
<if test="sixdian!=null and sixdian!=''">
)
</if>
order by ${cloum} ${paixu}//升序降序列需要${}
//传一个数组
<!--
<if test="boxdate!=null and boxdate !='' ">
AND startinfirsttime IN
<foreach collection="boxdate" index="index" item="item" open="(" separator="," close=")" >
#{item}
</foreach>
</if>
-->
</select>