ElectricOilMileageMapper.xml
3.68 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
<?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.ElectricOilMileageMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.admin.modules.entity.ElectricOilMileage">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="sn" column="sn" jdbcType="VARCHAR"/>
<result property="facId" column="fac_id" jdbcType="VARCHAR"/>
<result property="beginTime" column="begin_time" jdbcType="TIMESTAMP"/>
<result property="endTime" column="end_time" jdbcType="TIMESTAMP"/>
<result property="totalTime" column="total_time" jdbcType="INTEGER"/>
<result property="mileage" column="mileage" jdbcType="INTEGER"/>
<result property="oil" column="oil" jdbcType="INTEGER"/>
<result property="idleTime" column="idle_time" jdbcType="INTEGER"/>
<result property="rushUpCount" column="rush_up_count" jdbcType="INTEGER"/>
<result property="rushSlowCount" column="rush_slow_count" jdbcType="INTEGER"/>
<result property="rushTurnCount" column="rush_turn_count" jdbcType="INTEGER"/>
<result property="overSpeedCount" column="over_speed_count" jdbcType="INTEGER"/>
<result property="time" column="time" jdbcType="TIMESTAMP"/>
<result property="vdId" column="vd_id" jdbcType="INTEGER"/>
<result property="createdTime" column="created_time" jdbcType="TIMESTAMP"/>
<result property="updatedTime" column="updated_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,sn,fac_id,
begin_time,end_time,total_time,
mileage,oil,idle_time,
rush_up_count,rush_slow_count,rush_turn_count,
over_speed_count,time,vd_id,
created_time,updated_time
</sql>
<select id="getAllTestDrive" resultType="cn.com.glsx.admin.modules.model.export.OilReportExport">
SELECT
tu.account shopCode,
tu.username shopName,
tv.vin,
tv.id as vehicleId,
tv.model_name as modelName,
GROUP_CONCAT(td.sn) as sn,
tv.created_by as createdBy
FROM t_vehicle tv
LEFT JOIN t_vehicle_device tvd on tvd.vehicle_id = tv.id
LEFT JOIN t_device td on td.sn = tvd.sn
LEFT JOIN t_user tu ON tu.id = tv.created_by
WHERE tu.del_flag = 0
AND tv.del_flag = 0
AND tvd.his_type = 1
AND td.device_type = 1
<if test="keywords != null and keywords!='' ">
and (
tu.account like '%${keywords}%'
or tu.username like '%${keywords}%'
or tv.vin like '%${keywords}%'
or tv.model_name like '%${keywords}%'
)
</if>
group by tv.id
order by tu.account
</select>
<select id="getStatisticalData" resultType="cn.com.glsx.admin.modules.model.export.OilReportExport">
select
convert(sum(teom.oil)/1000, decimal(12, 3)) as oilCnt,
left(teom.begin_time,7) as statDate,
day(teom.begin_time) as dayCount
from t_electric_oil_mileage teom
left join t_vehicle_device tvd on tvd.id = teom.vd_id
<where>
<if test="year != null and year != '' and month != null and month != '' ">
left(teom.begin_time,7) = CONCAT(#{year},'-',#{month})
</if>
and tvd.vehicle_id = #{vehicleId}
</where>
group by tvd.vehicle_id, left(teom.begin_time,10)
</select>
<select id="getYearWithData" resultType="java.lang.String">
select distinct left (begin_time, 4)
from t_electric_oil_mileage
</select>
</mapper>