<?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.stylefeng.guns.modular.system.dao.TCarMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.TCar">
|
<id column="id" property="id" />
|
<result column="isPlatCar" property="isPlatCar" />
|
<result column="companyId" property="companyId" />
|
<result column="franchiseeId" property="franchiseeId" />
|
<result column="carColor" property="carColor" />
|
<result column="carModelId" property="carModelId" />
|
<result column="carBrandId" property="carBrandId" />
|
<result column="carLicensePlate" property="carLicensePlate" />
|
<result column="carPhoto" property="carPhoto" />
|
<result column="drivingLicenseNumber" property="drivingLicenseNumber" />
|
<result column="drivingLicensePhoto" property="drivingLicensePhoto" />
|
<result column="annualInspectionTime" property="annualInspectionTime" />
|
<result column="commercialInsuranceTime" property="commercialInsuranceTime" />
|
<result column="createTime" property="createTime" />
|
<result column="state" property="state" />
|
<result column="addType" property="addType" />
|
<result column="addObjectId" property="addObjectId" />
|
<result column="plateColor" property="plateColor"/>
|
<result column="vehicleType" property="vehicleType"/>
|
<result column="ownerName" property="ownerName"/>
|
<result column="engineId" property="engineId"/>
|
<result column="VIN" property="VIN"/>
|
<result column="certifyDateA" property="certifyDateA"/>
|
<result column="fuelType" property="fuelType"/>
|
<result column="engineDisplace" property="engineDisplace"/>
|
<result column="certificate" property="certificate"/>
|
<result column="transAgency" property="transAgency"/>
|
<result column="transArea" property="transArea"/>
|
<result column="transDateStart" property="transDateStart"/>
|
<result column="transDateStop" property="transDateStop"/>
|
<result column="certifyDateB" property="certifyDateB"/>
|
<result column="fixState" property="fixState"/>
|
<result column="nextFixDate" property="nextFixDate"/>
|
<result column="checkState" property="checkState"/>
|
<result column="feePrintId" property="feePrintId"/>
|
<result column="GPSBrand" property="GPSBrand"/>
|
<result column="GPSModel" property="GPSModel"/>
|
<result column="GPSIMEI" property="GPSIMEI"/>
|
<result column="GPSInstallDate" property="GPSInstallDate"/>
|
<result column="registerDate" property="registerDate"/>
|
<result column="commercialType" property="commercialType"/>
|
</resultMap>
|
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
id, isPlatCar, companyId, franchiseeId, carColor, carModelId, carBrandId, carLicensePlate, carPhoto, drivingLicenseNumber, drivingLicensePhoto, annualInspectionTime, commercialInsuranceTime, createTime, state, addType, addObjectId
|
</sql>
|
|
<!--根据条件查询车辆列表-->
|
<select id="getCarList" resultType="map" parameterType="com.baomidou.mybatisplus.plugins.Page">
|
SELECT * FROM (SELECT ds.serverStr,cb.`name` as brandName,cm.`name` as modelName,c1.`name` as companyName,c2.`name` as franchiseeName,cm.seat,dd.`name` as driverName,cc.* from t_car as cc
|
LEFT JOIN (select * from t_car_brand where state = 1) as cb on cb.id = cc.carBrandId
|
LEFT JOIN (select * from t_car_model where state = 1) as cm on cm.id = cc.carModelId
|
LEFT JOIN (select * from t_company where type = 2 and flag != 3) as c1 on c1.id = cc.companyId
|
LEFT JOIN (select * from t_company where type = 3 and flag != 3) as c2 on c2.id = cc.franchiseeId
|
LEFT JOIN (
|
SELECT
|
GROUP_CONCAT(case when type = 1 then '专车'
|
when type = 2 then '出租车'
|
when type = 3 then '跨城出行'
|
when type = 4 then '小件物流-同城'
|
when type = 5 then '小件物流-跨城'
|
when type = 6 then '包车'
|
else '' end ) as serverStr,carId from t_car_service GROUP BY carId) as ds on ds.carId = cc.id
|
LEFT JOIN (select * from t_driver where flag != 3) AS dd on dd.carId = cc.id) as o
|
<where>
|
o.state = 1
|
<if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
|
AND (o.insertTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
|
</if>
|
<if test="id != null and id != ''">
|
and o.id LIKE CONCAT('%',#{id},'%')
|
</if>
|
<if test="brandName != null and brandName != ''">
|
and o.brandName LIKE CONCAT('%',#{brandName},'%')
|
</if>
|
<if test="modelName != null and modelName != ''">
|
and o.modelName LIKE CONCAT('%',#{modelName},'%')
|
</if>
|
<if test="carColor != null and carColor != ''">
|
and o.carColor LIKE CONCAT('%',#{carColor},'%')
|
</if>
|
<if test="serverStr != null and serverStr != ''">
|
and o.serverStr LIKE CONCAT('%',#{serverStr},'%')
|
</if>
|
<if test="carLicensePlate != null and carLicensePlate != ''">
|
and o.carLicensePlate LIKE CONCAT('%',#{carLicensePlate},'%')
|
</if>
|
<if test="driverName != null and driverName != ''">
|
and o.driverName LIKE CONCAT('%',#{driverName},'%')
|
</if>
|
<if test="companyName != null and companyName != ''">
|
and o.companyName LIKE CONCAT('%',#{companyName},'%')
|
</if>
|
<if test="franchiseeName != null and franchiseeName != ''">
|
and o.franchiseeName LIKE CONCAT('%',#{franchiseeName},'%')
|
</if>
|
<if test="roleType != null and roleType != '' and roleType == 2">
|
and (o.companyId = #{nowUserId} or FIND_IN_SET(o.franchiseeId,(SELECT GROUP_CONCAT(id) as ids FROM t_company where superiorId = #{nowUserId} GROUP BY superiorId)))
|
</if>
|
<if test="roleType != null and roleType != '' and roleType == 3">
|
and o.franchiseeId = #{nowUserId}
|
</if>
|
</where>
|
order by o.id desc
|
</select>
|
|
|
<!--根据条件查询车辆列表不分页-->
|
<select id="getCarListNoPage" resultType="map">
|
SELECT * FROM (SELECT ds.serverStr,cb.`name` as brandName,cm.`name` as modelName,c1.`name` as companyName,c2.`name` as franchiseeName,cm.seat,dd.`name` as driverName,cc.* from t_car as cc
|
LEFT JOIN (select * from t_car_brand where state = 1) as cb on cb.id = cc.carBrandId
|
LEFT JOIN (select * from t_car_model where state = 1) as cm on cm.id = cc.carModelId
|
LEFT JOIN (select * from t_company where type = 2 and flag != 3) as c1 on c1.id = cc.companyId
|
LEFT JOIN (select * from t_company where type = 3 and flag != 3) as c2 on c2.id = cc.franchiseeId
|
LEFT JOIN (
|
SELECT
|
GROUP_CONCAT(case when type = 1 then '专车'
|
when type = 2 then '出租车'
|
when type = 3 then '跨城出行'
|
when type = 4 then '小件物流-同城'
|
when type = 5 then '小件物流-跨城'
|
when type = 6 then '包车'
|
else '' end ) as serverStr,carId from t_car_service GROUP BY carId) as ds on ds.carId = cc.id
|
LEFT JOIN (select * from t_driver where flag != 3) AS dd on dd.carId = cc.id) as o
|
<where>
|
o.state = 1
|
<if test="roleType != null and roleType != '' and roleType == 2">
|
and (o.companyId = #{nowUserId} or FIND_IN_SET(o.franchiseeId,(SELECT GROUP_CONCAT(id) as ids FROM t_company where superiorId = #{nowUserId} GROUP BY superiorId)))
|
</if>
|
<if test="roleType != null and roleType != '' and roleType == 3">
|
and o.franchiseeId = #{nowUserId}
|
</if>
|
</where>
|
order by o.id desc
|
</select>
|
|
</mapper>
|