EqpVirtualParkRecordSMapper.xml
7.21 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<?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.park.mapper.smapper.EqpVirtualParkRecordSMapper">
<resultMap id="BaseResultMap" type="com.zteits.park.domain.EqpVirtualParkRecord">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="eqp_type" jdbcType="INTEGER" property="eqpType" />
<result column="eqp_no" jdbcType="VARCHAR" property="eqpNo" />
<result column="pl_no" jdbcType="VARCHAR" property="plNo" />
<result column="berth_no" jdbcType="VARCHAR" property="berthNo" />
<result column="berth_range_no" jdbcType="VARCHAR" property="berthRangeNo" />
<result column="pl_name" jdbcType="VARCHAR" property="plName" />
<result column="pl_type" jdbcType="INTEGER" property="plType" />
<result column="eqp_in_time" jdbcType="TIMESTAMP" property="eqpInTime" />
<result column="eqp_out_time" jdbcType="TIMESTAMP" property="eqpOutTime" />
<result column="park_duration" jdbcType="BIGINT" property="parkDuration" />
<result column="park_fee" jdbcType="INTEGER" property="parkFee" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="("
separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="("
separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, eqp_out_time, eqp_type, eqp_no, berth_no, berth_range_no, pl_no, pl_name, pl_type,
eqp_in_time, park_duration, park_fee, remark, create_date
</sql>
<select id="queryEqpVirtualParkRecordForStatistic"
resultType="com.zteits.park.domain.EqpVirtualParkRecordStatistic">
SELECT
pl_no plNo,
eqp_type eqpType,
max(pl_name) plName,
count(0) parkNum,
sum(CASE
WHEN park_fee = NULL || park_fee = 0
THEN 1
ELSE 0 END) freeParknum,
sum(park_fee) income
FROM eqp_virtual_park_record
WHERE pl_no = #{plNo}
AND eqp_out_time BETWEEN #{startDate} AND #{endDate}
GROUP BY pl_no, eqp_type
</select>
<select id="queryRecentIncome" parameterType="com.zteits.clouds.api.dto.park.param.EqpVirtualParkRecordRequest"
resultType="com.zteits.clouds.api.dto.park.dto.EqpVirtualParkRecordRecentStatisticDTO">
SELECT
DATE_FORMAT(eqp_out_time,'%Y-%m-%d %H') timeStr,
sum(park_fee) parkFee,
sum(park_duration) parkDuration
FROM eqp_virtual_park_record
WHERE
eqp_type = 1
AND
eqp_out_time BETWEEN #{eqpOutTimeStart} AND #{eqpOutTimeEnd}
AND pl_no IN
<foreach collection="plNos" index="index" separator="," item="plNo" open="(" close=")">
#{plNo}
</foreach>
GROUP BY timeStr
</select>
<select id="queryRecentIncomeforSummary" parameterType="com.zteits.clouds.api.dto.park.param.EqpVirtualParkRecordRequest"
resultType="com.zteits.clouds.api.dto.park.dto.EqpVirtualParkRecordRecentStatisticDTO">
SELECT
sum(park_fee) parkFee,
sum(park_duration) parkDuration
FROM eqp_virtual_park_record
WHERE
eqp_type = 1
AND
eqp_out_time BETWEEN #{eqpOutTimeStart} AND #{eqpOutTimeEnd}
AND pl_no IN
<foreach collection="plNos" index="index" separator="," item="plNo" open="(" close=")">
#{plNo}
</foreach>
</select>
<select id="queryChargerIncomeDiffInfo" resultType="com.zteits.park.domain.ChargerIncomeDiff">
SELECT
berth_range_no berthRangeNo,
count(0) eqpParkNum,
IFNULL(sum(park_fee),0 ) eqpTotalFee
FROM eqp_virtual_park_record
where berth_no IN
<foreach collection="berthNos" item="berthNo" open="(" close=")" separator="," >
#{berthNo}
</foreach>
AND eqp_out_time BETWEEN #{startDate} AND #{endDate}
and berth_range_no = #{berthRangeNo}
GROUP BY berth_range_no
</select>
</mapper>