Files
sczx_car/src/main/resources/mapper/CarMapper.xml

78 lines
2.3 KiB
XML

<?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.sczx.car.mapper.CarMapper">
<select id="pageStoreCar" resultType="com.sczx.car.dto.StoreCarDTO">
select
*
from
(
select
zc.id,
zc.vin,
zc.license_plate,
zc.brand_name,
zc.model_name,
zc.battery_type ,
ifnull(zom.overdue_days, 0) overdue_days,
(case
when ifnull(zc.package_id, 0)>0 then 'NON_PACKAGE'
when zc.brs_status = '9'
and ifnull(zom.overdue_days, 0) > 0
and zom.order_status = 'RENT_OVERDUE' then 'OVERDUE'
when zc.brs_status = '9'
and ifnull(zom.overdue_days, 0) = 0
and zom.order_status = 'RENT_ING' then 'RENTING'
when zc.brs_status = '0' then 'FREE'
when zc.brs_status = '1' then 'REMOVED'
END ) store_car_status,
zc.brs_status,
zcm.image,
zom.order_status,
zom.order_no,
zom.pick_car_time,
zc.update_time,
zc.store_id,
zc.iot_code,
zc.iot_status,
zcm.max_speed,
zcm.weight
from
zc_car zc
left join (
select
*
from
zc_order_main
where
del_flag = 0
AND order_status not in ('AUTO_END', 'MANUAL_END')
and vehicle_id in (
select
id
from
zc_car
where
del_flag = 0
and status = 0
and store_id = #{storeCarReq.storeId}) )zom
on
zc.id = zom.vehicle_id
LEFT join zc_car_model zcm on zc.model_id = zcm.id
) a
where
a.store_id = #{storeCarReq.storeId}
<if test="storeCarReq.storeCarStatusList != null and storeCarReq.storeCarStatusList.size() > 0">
and a.store_car_status
in <foreach collection="storeCarReq.storeCarStatusList" item="carStatus" open="(" separator="," close=")">
#{carStatus}
</foreach>
</if>
<if test="storeCarReq.licensePlate != null and storeCarReq.licensePlate != ''">
and a.license_plate like concat('%', #{storeCarReq.licensePlate}, '%')
</if>
order by
a.update_time desc
</select>
</mapper>