left join branch_company bc on v.park_branch_company_id = bc.id
left join branch_company bc on v.park_branch_company_id = bc.id
<iftest="startCompanyId != null and endCompanyId != null ">
left join (
<includerefid="aroundBookRecord"></include>
) abr on v.`id` = abr.vehicle_id
</if>
<iftest=" catas != null ">
<iftest=" catas != null ">
left join vehicle_cata vc on vm.id = vc.vehicle_model_id
left join vehicle_cata vc on vm.id = vc.vehicle_model_id
</if>
</if>
<where>
<where>
<!-- 若需根据预定日期条件查询,针对换为位操作 -->
<!-- yearNo4Where 标识时间参数是否用于where条件 -->
(abr.to_lift_company = null or (abr.to_lift_company = ))
<!-- 若需根据预定日期条件查询,针对换为位操作 -->
<!-- 若需根据预定日期条件查询,针对换为位操作 -->
<!-- yearNo4Where 标识时间参数是否用于where条件 -->
<!-- yearNo4Where 标识时间参数是否用于where条件 -->
<iftest=" yearMonthAndParam !=null and yearNo4Where == null">
<iftest=" yearMonthAndParam !=null and yearNo4Where == null">
...
@@ -585,7 +594,13 @@
...
@@ -585,7 +594,13 @@
<includerefid="yearMonthAndParamSql"></include>
<includerefid="yearMonthAndParamSql"></include>
</foreach>
</foreach>
</if>
</if>
<iftest="startCompanyId != null and endCompanyId != null ">
and (
(abr.to_lift_company = null or abr.to_lift_company = #{startCompanyId})
and
(abr.to_return_company = null or abr.to_return_company = #{endCompanyId})
)
</if>
<iftest=" modelId != null ">
<iftest=" modelId != null ">
and v.model_id = #{modelId}
and v.model_id = #{modelId}
</if>
</if>
...
@@ -611,4 +626,17 @@
...
@@ -611,4 +626,17 @@
)
)
</sql>
</sql>
<!-- 前后被预定的情况 -->
<sqlid ="aroundBookRecord">
select sevbr.*
, vbre.ret_company as to_lift_company
, vbrs.lift_company as to_return_company
from
(select vehicle_id, max(if(book_end_date < #{start_date_extend}, book_end_date, null)) as max_book_end_date, min(if(book_start_date > #{end_date_extend}, book_start_date, null)) as min_book_start_date from vehicle_book_record where status != 4 and status != 6 group by vehicle_id) sevbr
left join vehicle_book_record vbre
on sevbr.vehicle_id = vbre.vehicle_id and sevbr.max_book_end_date = vbre.book_end_date and vbre.status != 4 and vbre.status != 6
left join vehicle_book_record vbrs
on sevbr.vehicle_id = vbrs.vehicle_id and sevbr.min_book_start_date = vbrs.book_start_date and vbrs.status != 4 and vbrs.status != 6;