FakeOfflineVinMapper.xml
5.85 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
<?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.FakeOfflineVinMapper">
<resultMap id="BaseMap" type="cn.com.glsx.admin.modules.entity.FakeOfflineVin">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="vin" property="vin" jdbcType="VARCHAR"/>
<result column="merchant_type" property="merchantType" jdbcType="TINYINT"/>
<result column="home_addr" property="homeAddr" jdbcType="VARCHAR"/>
<result column="work_addr" property="workAddr" jdbcType="VARCHAR"/>
<result column="del_flag" property="delFlag" jdbcType="TINYINT"/>
<result column="created_date" property="createdDate" jdbcType="TIMESTAMP"/>
<result column="created_by" property="createdBy" jdbcType="INTEGER"/>
<result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP"/>
<result column="updated_by" property="updatedBy" jdbcType="INTEGER"/>
</resultMap>
<sql id="BaseColumns">
id
, vin, merchant_type, home_addr, work_addr, del_flag, created_date, created_by, updated_date, updated_by
</sql>
<select id="getFakeOfflineVinByFence" resultType="String">
select distinct tv.vin
from t_fake_offline_fence_sn tfofs
left join t_vehicle_device tvd on tvd.sn = tfofs.sn
left join t_vehicle tv on tv.id = tvd.vehicle_id
where tfofs.status = 1
and tfofs.del_flag = 0
and tvd.del_flag = 0
and tvd.bind_status = 1
and tv.vin in
<foreach collection="allDeviceOfficeVinList" separator="," open="(" close=")" item="item">
#{item}
</foreach>
</select>
<select id="getVehicleNumMap" resultType="cn.com.glsx.admin.modules.model.FakeOfficeMapDto">
select tv.vin as vin,
count(1) as num
from t_vehicle tv
left 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
group by tv.id
</select>
<select id="getOfflineVehicleNumMap" resultType="cn.com.glsx.admin.modules.model.FakeOfficeMapDto">
select tv.vin as vin,
count(tvd.sn) as num
from t_vehicle tv
left join t_vehicle_device tvd on tvd.vehicle_id = tv.id
left join t_device_location tdl on tdl.sn = tvd.sn
where tv.del_flag = 0
and tvd.bind_status = 1
and tvd.del_flag = 0
and ((timestampdiff(SECOND, tdl.last_gps_time, now()) > 259200 and
timestampdiff(SECOND, tdl.last_bs_time, now()) > 259200)
or (tdl.last_gps_time is null and tdl.last_bs_time is null)
or (tdl.last_gps_time is null and timestampdiff(SECOND, tdl.last_bs_time, now()) > 259200)
or (timestampdiff(SECOND, tdl.last_gps_time, now()) > 259200 and tdl.last_bs_time is null)
)
group by tv.id
</select>
<select id="searchFakeOfficeList" resultType="cn.com.glsx.admin.modules.model.export.FakeOfficeExport">
select tv.id, tw.partner_order_no bizOrderNo,
tv.owner_name ownerName,
tv.vin as vin,
group_concat(tvd.sn) sns,
tv.license_plate licensePlate
from t_vehicle tv
left join t_vehicle_device tvd on tvd.vehicle_id = tv.id
left join t_workorder tw on tw.id = tv.workorder_id
where tv.del_flag = 0
and tvd.bind_status = 1
and tvd.del_flag = 0
<if test="vinStrs != null and vinStrs != '' ">
and tv.vin in (${vinStrs})
</if>
<if test="checkedUserIdsStr != null and checkedUserIdsStr !=''">
and find_in_set(tv.created_by,#{checkedUserIdsStr})
</if>
<if test="keywords != null and keywords !=''">
and (
tw.partner_order_no like '%${keywords}%'
or tv.vin like '%${keywords}%'
or tv.owner_name like '%${keywords}%'
or tv.id in (select vehicle_id from t_vehicle_device where del_flag = 0 and bind_status = 1 and sn like
'%${keywords}%')
)
</if>
group by tv.id
order by tv.id desc
</select>
<select id="getAddrByVin" resultMap="BaseMap">
select
<include refid="BaseColumns"/>
from t_fake_offline_vin
where vin = #{vin}
and del_flag = 0
</select>
<select id="getFakeOfflineSnList" resultType="java.lang.String">
select tfofs.sn
from t_fake_offline_fence_sn tfofs
left join t_vehicle_device tvd on tvd.sn = tfofs.sn
where tfofs.del_flag = 0
and tfofs.status = 1
and tvd.id in
<foreach collection="allOfflineDevices" item="itemId" index="index" open="(" close=")" separator=",">
#{itemId}
</foreach>
union
select tfocf.sn
from t_fake_offline_change_frequently tfocf
left join t_vehicle_device tvd on tvd.sn = tfocf.sn
where tfocf.del_flag = 0
and tfocf.status = 1
and tvd.id in
<foreach collection="allOfflineDevices" item="itemId" index="index" open="(" close=")" separator=",">
#{itemId}
</foreach>
union
select tws.sn
from t_whitelist_sn tws
left join t_vehicle_device tvd on tvd.sn = tws.sn
where tws.del_flag = 0
and tvd.id in
<foreach collection="allOfflineDevices" item="itemId" index="index" open="(" close=")" separator=",">
#{itemId}
</foreach>
<if test="deptIds != null and deptIds.size() > 0">
and tws.department_id IN
<foreach collection="deptIds" separator="," open="(" close=")" item="item">
#{item}
</foreach>
</if>
</select>
</mapper>