DurationStatisticParkDaySMapper.xml
7.2 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
<?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.zteits.order.mapper.smapper.DurationStatisticParkDaySMapper">
<resultMap id="BaseResultMap" type="com.zteits.order.domain.DurationStatisticParkDay">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="static_date" jdbcType="DATE" property="staticDate" />
<result column="static_date_str" jdbcType="VARCHAR" property="staticDateStr" />
<result column="org_id" jdbcType="INTEGER" property="orgId" />
<result column="area_id" jdbcType="VARCHAR" property="areaId" />
<result column="area_name" jdbcType="VARCHAR" property="areaName" />
<result column="pl_no" jdbcType="VARCHAR" property="plNo" />
<result column="pl_name" jdbcType="VARCHAR" property="plName" />
<result column="berth_num" jdbcType="INTEGER" property="berthNum" />
<result column="total_duration" jdbcType="BIGINT" property="totalDuration" />
<result column="total_parking_times" jdbcType="INTEGER" property="totalParkingTimes" />
<result column="avg_berth_duration" jdbcType="BIGINT" property="avgBerthDuration" />
<result column="avg_times_duration" jdbcType="BIGINT" property="avgTimesDuration" />
<result column="min_15" jdbcType="INTEGER" property="min15" />
<result column="min_30" jdbcType="INTEGER" property="min30" />
<result column="hour_1" jdbcType="INTEGER" property="hour1" />
<result column="hour_6" jdbcType="INTEGER" property="hour6" />
<result column="hour_12" jdbcType="INTEGER" property="hour12" />
<result column="hour_24" jdbcType="INTEGER" property="hour24" />
<result column="day_1" jdbcType="INTEGER" property="day1" />
<result column="data_state" jdbcType="INTEGER" property="dataState" />
<result column="create_emp_id" jdbcType="VARCHAR" property="createEmpId" />
<result column="create_emp_name" jdbcType="VARCHAR" property="createEmpName" />
<result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
<result column="modfiy_emp_id" jdbcType="VARCHAR" property="modfiyEmpId" />
<result column="modfiy_emp_name" jdbcType="VARCHAR" property="modfiyEmpName" />
<result column="modfiy_date" jdbcType="TIMESTAMP" property="modfiyDate" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="pl_type" jdbcType="INTEGER" property="plType" />
</resultMap>
<!-- 停车时长汇总(按天) -->
<select id="queryDurationStatisticParkDayTotal" resultType="com.zteits.clouds.api.dto.order.duration.dto.DurationParkTotalDTO"
parameterType="com.zteits.clouds.api.dto.order.duration.param.DurationParkReq">
SELECT b.*,
IFNULL(b.totalDuration/b.berthNum,0) avgBerthDuration,
IFNULL(b.totalDuration/b.totalParkingTimes,0) avgTimesDuration
from(
SELECT
count(DISTINCT(a.pl_no)) as parkNum,
a.pl_type as plType,
MAX(a.static_date_str) as staticDateStr,
sum((IFNULL(a.berth_num,0))) as berthNum,
sum(IFNULL(a.total_duration,0)) as totalDuration,
sum(IFNULL(a.total_parking_times,0)) as totalParkingTimes
FROM
duration_statistic_park_day a
where 1=1
and a.data_state=1
and a.static_date between #{beginTime} and #{endTime}
and a.pl_no in
<foreach collection="plNos" open="(" close=")" item="plNo" separator=",">
#{plNo}
</foreach>
group by a.pl_type)b
</select>
<!-- 停车时长汇总(按周) -->
<select id="queryDurationStatisticParkWeekTotal" resultType="com.zteits.clouds.api.dto.order.duration.dto.DurationParkTotalDTO"
parameterType="com.zteits.clouds.api.dto.order.duration.param.DurationParkReq">
SELECT
COUNT(b.plNo) parkNum,
b.plType plType,
max(b.staticDateStr) staticDateStr,
sum(b.totalDuration) totalDuration,
sum(b.totalParkingTimes) totalParkingTimes,
SUM(b.berthNum) berthNum,
IFNULL(sum(b.totalDuration)/sum(b.berthNum),0) avgBerthDuration,
IFNULL(sum(b.totalDuration)/sum(b.totalParkingTimes),0) avgTimesDuration
from(
SELECT
a.pl_no as plNo,
a.pl_name as plName,
a.pl_type as plType,
MAX(a.static_date_str) as staticDateStr,
max((IFNULL(a.berth_num,0))) as berthNum,
sum(IFNULL(a.total_duration,0)) as totalDuration,
sum(IFNULL(a.total_parking_times,0)) as totalParkingTimes
FROM
duration_statistic_park_day a
where 1=1
and a.data_state=1
and a.static_date between #{beginTime} and #{endTime}
and a.pl_no in
<foreach collection="plNos" open="(" close=")" item="plNo" separator=",">
#{plNo}
</foreach>
group by a.pl_no,a.pl_name,a.pl_type)b GROUP BY b.plType
</select>
<!-- 停车时长分页(按周) -->
<select id="queryParkDurationForkWeek" resultMap="BaseResultMap">
SELECT
a.pl_no,
a.pl_name,
a.pl_type as pl_type,
MAX(a.static_date_str) as static_date_str,
sum(IFNULL(a.total_duration,0)) as total_duration,
MAX(IFNULL(a.berth_num,0)) as berth_num,
sum(IFNULL(a.total_parking_times,0)) as total_parking_times
FROM
duration_statistic_park_day a
where 1=1
and a.data_state=1
and a.static_date between #{beginTime} and #{endTime}
and a.pl_no in
<foreach collection="plNos" open="(" close=")" item="plNo" separator=",">
#{plNo}
</foreach>
group by a.pl_no,a.pl_name,a.pl_type
ORDER BY convert(pl_name USING gbk) ASC
</select>
<!-- 停车时长分布(按天) -->
<select id="queryParkDurationDayDistribute" resultType="com.zteits.clouds.api.dto.order.duration.dto.DurationParkDistDTO"
parameterType="com.zteits.clouds.api.dto.order.duration.param.DurationParkReq">
SELECT
a.pl_type as plType,
MAX(a.static_date_str) as staticDateStr,
sum((IFNULL(a.min_15,0))) as min15,
sum(IFNULL(a.min_30,0)) as min30,
sum(IFNULL(a.hour_1,0)) as hour1,
sum(IFNULL(a.hour_6,0)) as hour6,
sum(IFNULL(a.hour_12,0)) as hour12,
sum(IFNULL(a.hour_24,0)) as hour24,
sum(IFNULL(a.day_1,0)) as day1,
sum(IFNULL(a.total_parking_times,0)) as totalParkingTimes
FROM
duration_statistic_park_day a
where 1=1
and a.data_state=1
and a.static_date between #{beginTime} and #{endTime}
and a.pl_no in
<foreach collection="plNos" open="(" close=")" item="plNo" separator=",">
#{plNo}
</foreach>
group by a.pl_type
</select>
</mapper>