EffectiveTestDriveReportMapper.xml
5.57 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
<?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.EffectiveTestDriveReportMapper">
<resultMap id="BaseResultMap"
type="cn.com.glsx.admin.modules.model.excel.EffectiveTestDriveReportExcel">
<result column="shopCode" jdbcType="VARCHAR" property="shopCode"/>
<result column="shopName" jdbcType="VARCHAR" property="shopName"/>
<result column="vehicleTypeName" jdbcType="VARCHAR" property="vehicleTypeName"/>
<result column="sn" jdbcType="VARCHAR" property="sn"/>
<result column="standno" jdbcType="VARCHAR" property="standno"/>
<result column="statDate" jdbcType="VARCHAR" property="statDate"/>
<result column="cnt" jdbcType="INTEGER" property="cnt"/>
<result column="dayCount" jdbcType="INTEGER" property="dayCount"/>
<result column="cnttotal" jdbcType="INTEGER" property="cnttotal"/>
</resultMap>
<resultMap id="PageBaseMap"
type="cn.com.glsx.admin.modules.model.excel.EffectiveTestDriveReportExcel">
<result column="fenceId" jdbcType="INTEGER" property="fenceId"/>
<result column="electricFenceName" jdbcType="VARCHAR" property="electricFenceName"/>
<result column="shopCode" jdbcType="VARCHAR" property="shopCode"/>
<result column="shopName" jdbcType="VARCHAR" property="shopName"/>
<result column="sn" jdbcType="VARCHAR" property="sn"/>
<result column="standno" jdbcType="VARCHAR" property="standno"/>
<result column="vehicleTypeName" jdbcType="VARCHAR" property="vehicleTypeName"/>
</resultMap>
<select id="getTestDrivePageList"
parameterType="cn.com.glsx.admin.modules.model.EffectiveTestDriveDTO"
resultMap="PageBaseMap">
SELECT
du.username shopCode,
du.userRemark shopName,
defs.sn,
defs.standno,
dvts.vehicle_type_name vehicleTypeName
from d_electric_fence_sns defs
inner join d_electric_fence def on def.id = defs.fenceId
left join d_user du on du.d_LoginUserId = def.loginUserId
left join d_vehicle dv on dv.standno = defs.standno
left join d_vehicle_type_standno dvts on dvts.standno = dv.standno
left join d_class dc on dv.classId = dc.classid
where defs.fenceId = def.id
and def.bizFenceType = 1
<if test="shopCode!=null and shopCode!=''">
and du.username like '%${shopCode}%'
</if>
<if test="shopName!=null and shopName!=''">
and du.userRemark like '%${shopName}%'
</if>
<if test="guangBenClassId != null and guangBenClassId != '' ">
and dc.vehicleGroupId = #{guangBenClassId,jdbcType=INTEGER}
</if>
and dvts.vehicle_type_name IN
<foreach collection="splitList" item="vehicleTypeName" index="index" open="(" close=")" separator=",">
#{vehicleTypeName}
</foreach>
order by def.id
</select>
<select id="getEffectiveTestDriveData"
parameterType="cn.com.glsx.admin.modules.model.EffectiveTestDriveDTO"
resultMap="BaseResultMap">
SELECT tall.shopCode, tall.shopName, tall.vehicleTypeName, tall.sn, tall.standno, left(tall.statDate,7)
statDate, tall.cnt, day(tall.statDate) dayCount , sum(cnt) cnttotal FROM
(select du.username shopCode, du.userRemark shopName, dvts.vehicle_type_name vehicleTypeName,
defdd.sn,
dv.standno, DATE_FORMAT(defdd.journey_time,'%Y-%m-%d') statDate, sum(case when defdd.percent >= 80 then 1 else 0
end) cnt
from d_electric_fence_drive defdd
left join d_electric_fence def on def.id = defdd.fence_id
left join d_track_info dti on dti.sn = defdd.sn
left join d_vehicle dv on dv.vehicleId = dti.vehicleId
left join d_vehicle_type_standno dvts on dvts.standno = dv.standno
left join d_user du on du.d_LoginUserId = def.loginUserId
<where>
<choose>
<when test="year != null and year != '' and month != null and month != '' ">
left(defdd.journey_time,7) = CONCAT(#{year,jdbcType=VARCHAR},'-',#{month,jdbcType=VARCHAR})
</when>
<otherwise>
<if test="year != null and year != '' ">
left(defdd.journey_time,4) = #{year,jdbcType=VARCHAR}
</if>
<if test="month != null and month != '' ">
right(left(journey_time,7),2) = #{month,jdbcType=VARCHAR}
</if>
</otherwise>
</choose>
<if test="shopCode !=null and shopCode != ''">
and du.username like '%${shopCode}%'
</if>
<if test="shopName !=null and shopName != ''">
and du.userRemark like '%${shopName}%'
</if>
<if test="sn !=null and sn != ''">
and defdd.sn = #{sn,jdbcType=VARCHAR}
</if>
and dvts.vehicle_type_name IN
<foreach collection="splitList" item="vehicleTypeName" index="index" open="(" close=")" separator=",">
#{vehicleTypeName}
</foreach>
</where>
GROUP BY defdd.sn,defdd.fence_id,statDate order by du.username) tall GROUP BY tall.shopCode, tall.sn,
tall.statDate ORDER BY tall.shopCode
</select>
<select id="getYearWithData" resultType="java.lang.String">
select distinct left(journey_time,4) from d_electric_fence_drive
</select>
</mapper>