<?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.tievd.jyz.mapper.CarInfoMapper">
|
|
<select id="pageCarAllInfo" resultType="com.tievd.jyz.entity.vo.CarInfoRespVo">
|
select t.*, if(t.monthCount>3,3, IF(t.monthCount=0, 1,2)) client_type
|
,o.oil_position oilPosition, o.higher_phrase higherPhrase
|
from (
|
select c.*,
|
c.img_path as imgPath2,
|
GROUP_CONCAT(DISTINCT lc.label_name) label_name,r.org_code,
|
count(if(r.behavior=1 and r.create_time>DATE_SUB(CURRENT_TIMESTAMP,INTERVAL 3 MONTH),1,null)) monthCount,
|
count(r.id) appear_count,
|
count(IF(r.behavior=1,1,null)) oil_count,
|
SUM(r.oil_volume) oil_sum,
|
sum(r.spand_time) stay_time,
|
count(IF(r.standard=2,1,null)) event_count,
|
max(r.start_time) update_time
|
from t_car_info c
|
left join t_label_car lc on c.license_num=lc.license_num
|
LEFT JOIN t_oil_record r on c.license_num=r.license_num
|
<where>
|
<if test="car.licenseNum != null and car.licenseNum!=''">and c.license_num like concat('%', #{car.licenseNum},'%')</if>
|
<if test="car.licensePlace != null and car.licensePlace!=''">and c.license_place like concat('%', #{car.licensePlace},'%') </if>
|
<if test="car.modelId != null and car.modelId!=''">and c.model_id = #{car.modelId}</if>
|
<if test="car.labelName != null and car.labelName!=''">and lc.label_name = #{car.labelName}</if>
|
<if test="car.orgCode != null and car.orgCode!=''">and r.org_code like concat(#{car.orgCode},'%')</if>
|
</where>
|
GROUP BY c.license_num
|
) t
|
left join t_oil_statis o on o.license_num=t.license_num and o.org_code=t.org_code
|
<where>
|
<if test="car.oilCountLeft != null">and t.oil_count >= #{car.oilCountLeft}</if>
|
<if test="car.oilCountRight != null">and t.oil_count <= #{car.oilCountRight}</if>
|
<if test="car.oilSumLeft != null ">and t.oil_sum >= #{car.oilSumLeft}</if>
|
<if test="car.oilSumRight != null ">and t.oil_sum <= #{car.oilSumRight}</if>
|
<if test="car.clientType != null">and o.client_type = #{car.clientType}</if>
|
</where>
|
order by t.update_time desc
|
</select>
|
|
</mapper>
|