VehicleMapper.xml
8.84 KB
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
<?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="cn.com.glsx.admin.modules.mapper.VehicleMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.admin.modules.entity.Vehicle">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="workorder_id" jdbcType="INTEGER" property="workorderId"/>
<result column="owner_name" jdbcType="VARCHAR" property="ownerName"/>
<result column="vin" jdbcType="VARCHAR" property="vin"/>
<result column="owner_sex" jdbcType="VARCHAR" property="ownerSex"/>
<result column="owner_tel" jdbcType="VARCHAR" property="ownerTel"/>
<result column="brand_id" jdbcType="INTEGER" property="brandId"/>
<result column="brand_name" jdbcType="VARCHAR" property="brandName"/>
<result column="series_id" jdbcType="INTEGER" property="seriesId"/>
<result column="series_name" jdbcType="VARCHAR" property="seriesName"/>
<result column="model_id" jdbcType="INTEGER" property="modelId"/>
<result column="model_name" jdbcType="VARCHAR" property="modelName"/>
<result column="config_desc" jdbcType="VARCHAR" property="configDesc"/>
<result column="color" jdbcType="VARCHAR" property="color"/>
<result column="inner_color" jdbcType="VARCHAR" property="innerColor"/>
<result column="license_plate" jdbcType="VARCHAR" property="licensePlate"/>
<result column="vehicle_type" jdbcType="TINYINT" property="vehicleType"/>
<result column="engine" jdbcType="VARCHAR" property="engine"/>
<result column="displacement" jdbcType="VARCHAR" property="displacement"/>
<result column="mileage" jdbcType="VARCHAR" property="mileage"/>
<result column="buy_date" jdbcType="DATE" property="buyDate"/>
<result column="description" jdbcType="VARCHAR" property="description"/>
<result column="remark" jdbcType="VARCHAR" property="remark"/>
<result column="serve_type" jdbcType="TINYINT" property="serveType"/>
<result column="validate_status" jdbcType="TINYINT" property="validateStatus"/>
<result column="validate_info" jdbcType="VARCHAR" property="validateInfo"/>
<result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
<result column="created_date" jdbcType="TIMESTAMP" property="createdDate"/>
<result column="created_by" jdbcType="INTEGER" property="createdBy"/>
<result column="updated_date" jdbcType="TIMESTAMP" property="updatedDate"/>
<result column="updated_by" jdbcType="INTEGER" property="updatedBy"/>
</resultMap>
<resultMap id="TearDownAlarmMap" type="cn.com.glsx.admin.modules.model.export.TearDownModelExport">
<result column="area" jdbcType="VARCHAR" property="area"/>
<result column="province" jdbcType="VARCHAR" property="province"/>
<result column="city" jdbcType="VARCHAR" property="city"/>
<result column="shop_name" jdbcType="VARCHAR" property="shopName"/>
<result column="shop_code" jdbcType="VARCHAR" property="shopCode"/>
<result column="shop_level" jdbcType="INTEGER" property="shopLevel"/>
<result column="model_name" jdbcType="VARCHAR" property="modelName"/>
<result column="config_desc" jdbcType="INTEGER" property="configDesc"/>
<result column="vin" jdbcType="VARCHAR" property="vin"/>
<result column="sn" jdbcType="INTEGER" property="sn"/>
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
id, workorder_id, owner_name, vin, owner_sex, owner_tel, brand_id, brand_name, series_id,
series_name, model_id, model_name, config_desc, color, inner_color, license_plate,
vehicle_type, engine, displacement, mileage, buy_date, description, remark, serve_type,
validate_status, validate_info, del_flag, created_date, created_by, updated_date,
updated_by
</sql>
<sql id="search_sql_condition" >
<if test="searchKey != null and searchKey != '' ">
and (
ttds.shop_code like concat('%',#{searchKey},'%')
or ttds.shop_name like concat('%',#{searchKey},'%')
or tv.vin like concat('%',#{searchKey},'%')
or tvd.sn like concat('%',#{searchKey},'%')
or tv.model_name like concat('%',#{searchKey},'%')
)
</if>
</sql>
<select id="linkSnsSearch" resultType="cn.com.glsx.admin.modules.model.VehicleLinkSnsDTO">
select tv.owner_name name, tv.vin, tv.owner_tel userTel, group_concat(tvd.sn) sns
from t_vehicle tv
left join t_vehicle_device tvd on tv.id = tvd.vehicle_id
left join t_device td on tvd.sn = td.sn
where tv.del_flag = 0
and tvd.bind_status = 1
<if test="deviceSource != null">
and td.source = #{deviceSource}
</if>
group by tv.id
</select>
<select id="searchTrialDrive" resultType="cn.com.glsx.admin.modules.model.TrialDriveVehiclePageDTO">
select tv.id tempId, tv.vin, tv.model_name modelName, tv.config_desc configDesc,
tv.license_plate licensePlate,
ttds.area, ttds.province, ttds.city, ttds.shop_name shopName, ttds.shop_code shopCode, ttds.shop_level shopLevel,
group_concat(tvd.sn) sns, tvd.created_date installedTime
from t_vehicle tv
left join t_vehicle_device tvd on tv.id = tvd.vehicle_id and tvd.bind_status = 1 and tvd.del_flag = 0
left join t_user tu on tv.created_by = tu.id and tu.del_flag = 0
left join t_trial_drive_shop ttds on tu.account = ttds.shop_code and ttds.del_flag = 0
where tv.del_flag = 0
<include refid="search_sql_condition" />
group by tvd.vehicle_id
</select>
<select id="exportDriveVehicle" resultType="cn.com.glsx.admin.modules.model.export.TrialDriveVehicleExport">
select tv.vin, tv.model_name modelName, tv.config_desc configDesc, tv.license_plate licensePlate, tv.model_name modelName,
tv.color, tv.inner_color innerColor, tv.serve_type serveType,
ttds.shop_name shopName, ttds.shop_code shopCode,
group_concat(tvd.sn) sns
from t_vehicle tv
left join t_vehicle_device tvd on tv.id = tvd.vehicle_id and tvd.bind_status = 1 and tvd.del_flag = 0
left join t_user tu on tv.created_by = tu.id and tu.del_flag = 0
left join t_trial_drive_shop ttds on tu.account = ttds.shop_code and ttds.del_flag = 0
where tv.del_flag = 0
<include refid="search_sql_condition" />
group by tvd.vehicle_id
</select>
<select id="searchTearDownAlarmList" resultMap="TearDownAlarmMap">
SELECT
ttds.area,
ttds.province,
ttds.city,
ttds.shop_name,
ttds.shop_code,
ttds.shop_level,
tv.model_name,
tv.config_desc,
tv.vin,
tvd.sn
FROM t_vehicle tv
left join t_vehicle_device tvd on tvd.vehicle_id = tv.id
left join t_electric_fence_sns tefs on tefs.sn = tvd.sn
left join t_trial_drive_shop ttds on ttds.fence_id = tefs.fence_id
where tv.del_flag = 0 and tvd.bind_status = 1
<if test="searchCondition != null and searchCondition !=''">
and (
ttds.shop_code like '%${searchCondition}%'
or ttds.shop_name like '%${searchCondition}%'
or tvd.sn like '%${searchCondition}%'
or tv.model_name like '%${searchCondition}%'
)
</if>
</select>
<select id="findVehicleInfoBySn" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from t_vehicle tv
inner join t_vehicle_device tvd on tvd.vehicle_id = tv.id
where tv.del_flag = 0 and tvd.bind_status = 1 and tvd.del_flag = 0
<if test="sn != null and sn != ''">
tvd.sn = #{sn}
</if>
</select>
<select id="selectVehicleSns" parameterType="cn.com.glsx.admin.modules.model.param.VehicleTreeSearch"
resultType="cn.com.glsx.admin.modules.model.OrgVehicleModel">
select tv.id, tv.vin label, group_concat(tvd.sn) sns, 2 as type,tv.created_by creatorId
from t_vehicle tv
left join t_vehicle_device tvd on tv.id = tvd.vehicle_id
where tv.del_flag = 0
and tvd.bind_status = 1
<choose>
<when test="termType != 1">
and tv.vin like concat('%',#{term},'%')
</when>
<when test="termType != 2">
and tvd.sn like concat('%',#{term},'%')
</when>
<otherwise>
and 1=0
</otherwise>
</choose>
group by tv.id
</select>
<select id="selectById" resultMap="BaseResultMap">
select * from t_vehicle where id = #{vehicleId} and del_flag = 0
</select>
</mapper>