puzhibing
2023-06-30 f58cca364b731eac2d60a440ffaa804be3cd43fd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?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>