liujie
2023-07-25 9b1188a004df6585d1836e85e22ee24a91b5fd62
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
<?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.dsh.course.mapper.TCarMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.dsh.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.extension.plugins.pagination.Page">
        SELECT * FROM (SELECT ds.serverStr,
 
        <if test="language==1">
            cb.`name` as brandName,
            cm.`name` as modelName,
            tcr.`name` as color,
        </if>
        <if test="language==2">
            cb.`ename` as brandName,
            cm.`ename` as modelName,
            tcr.`ename` as color,
        </if>
        <if test="language==3">
            cb.`yname` as brandName,
            cm.`yname` as modelName,
            tcr.`yname` as color,
        </if>
 
 
        cm.seat,cc.* ,tcs.type 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 t_colour tcr on tcr.id = cc.carColor
        LEFT JOIN (
        SELECT
        GROUP_CONCAT(case when type = 1 then 'Motorcycle'
        when type = 4 then 'Express in the same city'
        else '' end ) as serverStr,carId from t_car_service GROUP BY carId) as ds on ds.carId = cc.id
 
        left join t_car_service tcs on tcs.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,(#{ids})))
            </if>
            <if test="roleType != null and roleType != '' and roleType == 3">
                and o.franchiseeId = #{nowUserId}
            </if>
        </where>
        group by o.id
        order by o.id desc
    </select>
    <select id="getCarListAuth" resultType="map" parameterType="com.baomidou.mybatisplus.extension.plugins.pagination.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 = 4 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 and authState=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 = 4 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>
    <select id="getCarList1" resultType="java.util.Map">
        SELECT * FROM (SELECT ds.serverStr,cb.`name` as brandName,cm.`name` as modelName,cm.seat,cc.* ,tcs.type 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
        GROUP_CONCAT(case when type = 1 then '摩托车'
        when type = 4 then '同城快送'
        else '' end ) as serverStr,carId from t_car_service GROUP BY carId) as ds on ds.carId = cc.id
 
        left join t_car_service tcs on tcs.carId = cc.id
        ) as o
        <where>
            o.state = 1 and o.id in
            <foreach collection="integers" close=")" index="index" item="id" open="(" separator=",">
                 #{id}
            </foreach>
            <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,(#{ids})))
            </if>
            <if test="roleType != null and roleType != '' and roleType == 3">
                and o.franchiseeId = #{nowUserId}
            </if>
        </where>
        order by o.id desc
    </select>
    <select id="getById1" resultType="com.dsh.guns.modular.system.model.TCar">
        select * from t_car where id =#{carId1}
    </select>
    <select id="getCarID" resultType="com.dsh.guns.modular.system.model.TCar">
        select * from t_car where carLicensePlate =#{newCarId}
    </select>
</mapper>