ChargerIncomeDiffSMapper.xml
8.95 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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<?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.ChargerIncomeDiffSMapper">
<resultMap id="BaseResultMap" type="com.zteits.park.domain.ChargerIncomeDiff">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="static_date" jdbcType="DATE" property="staticDate"/>
<result column="org_id" jdbcType="BIGINT" property="orgId"/>
<result column="pl_no" jdbcType="VARCHAR" property="plNo"/>
<result column="pl_name" jdbcType="VARCHAR" property="plName"/>
<result column="berth_range_no" jdbcType="VARCHAR" property="berthRangeNo"/>
<result column="berth_range_name" jdbcType="VARCHAR" property="berthRangeName"/>
<result column="berth_range_eqp_num" jdbcType="INTEGER" property="berthRangeEqpNum"/>
<result column="berth_range_berth_num" jdbcType="INTEGER" property="berthRangeBerthNum"/>
<result column="charger_code" jdbcType="VARCHAR" property="chargerCode"/>
<result column="charger_name" jdbcType="VARCHAR" property="chargerName"/>
<result column="group_start_time" jdbcType="TIMESTAMP" property="groupStartTime"/>
<result column="group_start_time_str" jdbcType="VARCHAR" property="groupStartTimeStr"/>
<result column="group_end_time" jdbcType="TIMESTAMP" property="groupEndTime"/>
<result column="group_end_time_str" jdbcType="VARCHAR" property="groupEndTimeStr"/>
<result column="pda_eqp_park_num" jdbcType="INTEGER" property="pdaEqpParkNum"/>
<result column="pda_eqp_park_fee" jdbcType="INTEGER" property="pdaEqpParkFee"/>
<result column="eqp_park_num" jdbcType="INTEGER" property="eqpParkNum"/>
<result column="eqp_total_fee" jdbcType="INTEGER" property="eqpTotalFee"/>
<result column="park_and_eqp_diff_fee" jdbcType="INTEGER" property="parkAndEqpDiffFee"/>
<result column="park_and_eqp_diff_rate" jdbcType="VARCHAR" property="parkAndEqpDiffRate"/>
<result column="order_total_fee" jdbcType="BIGINT" property="orderTotalFee"/>
<result column="order_act_fee" jdbcType="BIGINT" property="orderActFee"/>
<result column="order_diff_fee" jdbcType="BIGINT" property="orderDiffFee"/>
<result column="order_diff_rate" jdbcType="VARCHAR" property="orderDiffRate"/>
<result column="data_status" jdbcType="INTEGER" property="dataStatus"/>
<result column="remark" jdbcType="VARCHAR" property="remark"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="create_op" jdbcType="VARCHAR" property="createOp"/>
<result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime"/>
<result column="modify_op" jdbcType="VARCHAR" property="modifyOp"/>
</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,
static_date,
org_id,
pl_no,
pl_name,
berth_range_no,
berth_range_name,
berth_range_eqp_num,
berth_range_berth_num,
charger_code,
charger_name,
group_start_time,
group_start_time_str,
group_end_time,
group_end_time_str,
pda_eqp_park_num,
pda_eqp_park_fee,
eqp_park_num,
eqp_total_fee,
park_and_eqp_diff_fee,
park_and_eqp_diff_rate,
order_total_fee,
order_act_fee,
order_diff_fee,
order_diff_rate,
data_status,
remark,
create_time,
create_op,
modify_time,
modify_op
</sql>
<select id="queryChargerIncomeDiffForSummary"
resultType="com.zteits.clouds.api.dto.park.dto.ChargerIncomeDiffSummaryDTO">
SELECT
sum(result.parkNum) parkNum,
sum(result.chargerCodeNum) chargerCodeNum,
sum(result.orderTotalFee) orderTotalFee,
sum(result.eqpTotalFee) eqpTotalFee,
sum(result.eqpNum) eqpNum,
sum(result.berthNum) berthNum
FROM (
SELECT
count(DISTINCT pl_no) parkNum,
count(DISTINCT charger_code) chargerCodeNum,
sum(pda_eqp_park_fee) orderTotalFee,
sum(eqp_total_fee) eqpTotalFee,
0 eqpNum,
0 berthNum
FROM charger_income_diff
WHERE data_status = 1
AND pl_no IN
<foreach collection="plNos" item="plNo" separator="," open="(" close=")" index="index">
#{plNo}
</foreach>
<if test="chargerCode != null">
AND charger_code = #{chargerCode}
</if>
<if test="berthRangeNos != null and berthRangeNos.size() >0">
AND berth_range_no In
<foreach collection="berthRangeNos" item="berthRangeNo" separator="," open="(" close=")" index="index">
#{berthRangeNo}
</foreach>
</if>
AND static_date BETWEEN #{startDate} AND #{endDate}
UNION ALL
SELECT
0 parkNum,
0 chargerCodeNum,
0 orderTotalFee,
0 eqpTotalFee,
sum(temp.eqpNum) eqpNum,
sum(temp.berthNum) berthNum
FROM (
SELECT
max(berth_range_eqp_num) eqpNum,
max(berth_range_berth_num) berthNum
FROM charger_income_diff
WHERE data_status = 1
AND pl_no IN
<foreach collection="plNos" item="plNo" separator="," open="(" close=")" index="index">
#{plNo}
</foreach>
<if test="chargerCode != null">
AND charger_code = #{chargerCode}
</if>
<if test="berthRangeNos != null and berthRangeNos.size() >0">
AND berth_range_no In
<foreach collection="berthRangeNos" item="berthRangeNo" separator="," open="(" close=")" index="index">
#{berthRangeNo}
</foreach>
</if>
AND static_date BETWEEN #{startDate} AND #{endDate}
GROUP BY berth_range_no) temp) result
</select>
</mapper>