FlowMapper.xml
5.07 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
<?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.viontech.fanxing.query.mapper.FlowMapper">
<resultMap id="baseMap" type="com.viontech.fanxing.query.model.TrafficFlowEventModel">
<result column="id" property="id"/>
<result column="event_dt" property="event_dt"/>
</resultMap>
<resultMap id="dataMap" type="com.viontech.fanxing.query.model.TrafficFlowDataModel">
<result column="flow_event_id" property="eventId"/>
<result column="event_time" property="eventTime"/>
<result column="road" property="road"/>
<result column="device_name" property="deviceName"/>
<result column="location_name" property="locationName"/>
<result column="velocity" property="velocity"/>
<result column="occupy" property="occupy"/>
<result column="distance" property="distance"/>
<result column="sample_dura" property="sampleDura"/>
<result column="queue_length" property="queueLength"/>
<result column="sample_num" property="sampleNum"/>
<result column="direction" property="direction"/>
<result column="time_occupy" property="timeOccupy"/>
<result column="dist_time" property="distTime"/>
</resultMap>
<select id="selectEvents" parameterType="com.viontech.fanxing.query.model.TrafficFlowRequestVo" resultMap="baseMap">
select date_format(te.event_time, '%Y-%m-%d %H:%i:%s') as event_dt,
date_format(te.event_time, '%Y-%m-%d %H:%i:%s') as gevent_dt,
te.id
from d_flow_event te
, d_flow_data
<where>
and d_flow_data.flow_event_id = te.id
AND d_flow_data.road_code != '0'
<if test="task_id != null and task_id != ''">
and te.task_id = #{task_id}
</if>
<if test="vchan_refid != null and vchan_refid != ''">
and te.channel_unid = #{vchan_refid}
</if>
<if test="event_dt__gte != null and event_dt__lt != null">
and te.event_time <![CDATA[>=]]> #{event_dt__gte}
and te.event_time <![CDATA[<=]]> #{event_dt__lt}
</if>
</where>
GROUP BY gevent_dt, te.id
<if test="statistic_type == 'road'">
, d_flow_data.road_code
</if>
order by event_dt desc
<if test="offset != null and limit != null">
LIMIT #{limit} offset #{offset}
</if>
</select>
<select id="counts" parameterType="com.viontech.fanxing.query.model.TrafficFlowRequestVo" resultType="int">
select count(1) as count from (
select date_format(te.event_time, '%Y-%m-%d %H:%i:%s') as gevent_dt
from d_flow_event te
, d_flow_data
<where>
and d_flow_data.flow_event_id = te.id
AND d_flow_data.road_code != '0'
<if test="task_id != null and task_id != ''">
and te.task_id = #{task_id}
</if>
<if test="vchan_refid != null and vchan_refid != ''">
and te.channel_unid = #{vchan_refid}
</if>
<if test="event_dt__gte != null and event_dt__lt != null">
and te.event_time <![CDATA[>=]]> #{event_dt__gte}
and te.event_time <![CDATA[<=]]> #{event_dt__lt}
</if>
</where>
GROUP BY gevent_dt, te.id
) as con
</select>
<select id="flowstatistics" parameterType="com.viontech.fanxing.query.model.TrafficFlowRequestVo"
resultMap="dataMap">
select ${column_List}
from d_flow_event te,
d_flow_data td
<where>
<if test="idSet != null">
and td.flow_event_id in
<foreach collection="idSet" item="id" index="index" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
and te.id = td.flow_event_id
<if test="task_id != null">
and td.task_id = #{task_id}
</if>
<if test="vchan_refid != null and vchan_refid != ''">
and te.channel_unid = #{vchan_refid}
</if>
<if test="detection_type != null and detection_type.size > 0">
and detection_type in
<foreach item="item" index="index" collection="detection_type" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="vehicle_type != null and vehicle_type.length != 0">
and td.detection_type in
<foreach item="item" index="index" collection="vehicle_type"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
and road_code != '0'
</where>
GROUP BY ${groupByClause}
ORDER BY ${orderByClause}
<if test="limit != null">
LIMIT #{limit}
</if>
</select>
</mapper>