TbRWhitelistRuleSmapper.xml
11.4 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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
<?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.bill.mapper.smapper.TbRWhitelistRuleSmapper">
<resultMap id="BaseResultMap" type="com.zteits.bill.domain.TbRWhitelistRule">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="white_r_no" jdbcType="VARCHAR" property="whiteRNo"/>
<result column="white_r_name" jdbcType="VARCHAR" property="whiteRName"/>
<result column="match_type" jdbcType="INTEGER" property="matchType"/>
<result column="charge_type" jdbcType="INTEGER" property="chargeType"/>
<result column="car_color" jdbcType="VARCHAR" property="carColor"/>
<result column="car_num" jdbcType="VARCHAR" property="carNum"/>
<result column="car_owner" jdbcType="VARCHAR" property="carOwner"/>
<result column="sex" jdbcType="INTEGER" property="sex"/>
<result column="address" jdbcType="VARCHAR" property="address"/>
<result column="card_id" jdbcType="VARCHAR" property="cardId"/>
<result column="phone" jdbcType="VARCHAR" property="phone"/>
<result column="white_r_state" jdbcType="INTEGER" property="whiteRState"/>
<result column="auditor_status" jdbcType="INTEGER" property="auditorStatus"/>
<result column="remark" jdbcType="VARCHAR" property="remark"/>
<result column="data_state" jdbcType="INTEGER" property="dataState"/>
<result column="create_empid" jdbcType="VARCHAR" property="createEmpid"/>
<result column="create_name" jdbcType="VARCHAR" property="createName"/>
<result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
<result column="modify_empid" jdbcType="VARCHAR" property="modifyEmpid"/>
<result column="modify_name" jdbcType="VARCHAR" property="modifyName"/>
<result column="modify_date" jdbcType="TIMESTAMP" property="modifyDate"/>
<result column="eff_date" jdbcType="TIMESTAMP" property="effDate"/>
<result column="exp_date" jdbcType="TIMESTAMP" property="expDate"/>
<result column="max_charge_fee" jdbcType="BIGINT" property="maxChargeFee"/>
<result column="report_fee_type" jdbcType="INTEGER" property="reportFeeType" />
<result column="org_id" jdbcType="BIGINT" property="orgId" />
</resultMap>
<sql id="Base_Column_List">
id, white_r_no, white_r_name, match_type, charge_type, car_color, car_num, car_owner,
sex, address, card_id, phone, white_r_state, auditor_status, remark, data_state,
create_empid, create_name, create_date, modify_empid, modify_name, modify_date, eff_date,
exp_date, max_charge_fee, report_fee_type, org_id
</sql>
<!-- 模糊匹配查询白名单list -->
<select id="queryWhitelistByCarNum" resultType="com.zteits.bill.domain.WhitelistIsFreeDO">
select
a.white_r_no as whiteRNo,
a.white_r_name as whiteRName,
b.pl_no as plNo,
a.match_type as matchType,
b.car_number as carNum,
a.max_charge_fee as maxChargeFee,
a.eff_date as effDate,
a.exp_date as expDate
from tb_r_whitelist_rule a ,
tb_r_whitelist_park_car_rel b
where a.white_r_no=b.white_r_no
and a.data_state=b.data_state
and a.data_state=1
and a.auditor_status=2 /**审核状态:1:待审核 2:审核通过,3:审核驳回.*/
and a.white_r_state=1 /**规则状态:1、上架;2、下架.*/
and b.pl_no =#{plNo}
<![CDATA[and a.eff_date <= now()]]>
<![CDATA[and a.exp_date >= now()]]>
and a.match_type in
<foreach collection="matchTypeList" item="matchType" open="(" close=")" separator=",">
#{matchType}
</foreach>
</select>
<!-- 通过车牌号+plNo精确查询白名单 -->
<select id="queryWhitelistByCarNumAndPlNo"
parameterType="com.zteits.clouds.api.dto.bill.whitelist.param.QueryCarNumIsWhitelistRequest"
resultType="com.zteits.bill.domain.WhitelistIsFreeDO">
select a.white_r_no as whiteRNo,
a.white_r_name as whiteRName,
b.pl_no as plNo,
a.match_type as matchType,
a.charge_type as chargeType,
b.car_number as carNum,
a.max_charge_fee as maxChargeFee,
a.eff_date as effDate,
a.exp_date as expDate
from tb_r_whitelist_rule a ,
tb_r_whitelist_park_car_rel b
where a.white_r_no=b.white_r_no
and a.data_state=b.data_state
and a.data_state=1
and a.auditor_status=2 /**审核状态:1:待审核 2:审核通过,3:审核驳回.*/
and a.white_r_state=1 /**规则状态:1、上架;2、下架.*/
and a.match_type=3 /**匹配类型:1:前置匹配 2:后置匹配 3:完全匹配.*/
<if test="chargerType != null">
AND a.charge_type = #{chargerType}
</if>
and a.eff_date <= #{currentDate}
and a.exp_date >= #{currentDate}
and b.pl_no =#{plNo}
and b.car_number = #{carNumber}
order by b.id desc
limit 0,1
</select>
<!-- 通过车牌号+plNo精确查询白名单 -->
<select id="queryWhitelistByCarNumAndPlNoList"
parameterType="com.zteits.clouds.api.dto.bill.whitelist.param.QueryCarNumIsWhitelistRequest"
resultType="com.zteits.bill.domain.WhitelistIsFreeDO">
select a.white_r_no as whiteRNo,
a.white_r_name as whiteRName,
b.pl_no as plNo,
a.match_type as matchType,
a.charge_type as chargeType,
b.car_number as carNum,
a.max_charge_fee as maxChargeFee,
a.eff_date as effDate,
a.exp_date as expDate
from tb_r_whitelist_rule a ,
tb_r_whitelist_park_car_rel b
where a.white_r_no=b.white_r_no
and a.data_state=b.data_state
and a.data_state=1
and a.auditor_status=2 /**审核状态:1:待审核 2:审核通过,3:审核驳回.*/
and a.white_r_state=1 /**规则状态:1、上架;2、下架.*/
and a.match_type=3 /**匹配类型:1:前置匹配 2:后置匹配 3:完全匹配.*/
<if test="chargerType != null">
AND a.charge_type = #{chargerType}
</if>
and a.eff_date <= #{currentDate}
and a.exp_date >= #{currentDate}
and b.pl_no =#{plNo}
and b.car_number = #{carNumber}
order by b.id desc
</select>
<!--通过车牌/停车场编码等查询白名单规则-->
<select id="queryWhitelistRuleForPage" resultMap="BaseResultMap"
parameterType="com.zteits.clouds.api.dto.bill.whitelist.param.WhitelistRuleForPageRequest">
select
c.id,
c.white_r_no,
c.white_r_name,
c.match_type,
c.charge_type,
c.car_num,
c.white_r_state,
c.eff_date,
c.exp_date,
c.create_date,
c.max_charge_fee
from tb_r_whitelist_rule c
where c.id in
(select
a.id
from tb_r_whitelist_rule a
left JOIN tb_r_whitelist_park_rel b on a.white_r_no = b.white_r_no and b.data_state = 1
left JOIN tb_r_whitelist_rule_car_number d on a.white_r_no = d.white_r_no and d.data_state =1
where a.data_state = 1
<if test="whiteRName != null and whiteRName !=''">
and a.white_r_name LIKE '%${whiteRName}%'
</if>
<if test="plNos != null and plNos.size >0">
and b.pl_no in
<foreach collection="plNos" open="(" close=")" item="plNo" separator=",">
#{plNo}
</foreach>
</if>
<if test="carNum != null and carNum !=''">
and d.car_number LIKE '%${carNum}%'
</if>
<if test="matchType != null">
and a.match_type = #{matchType}
</if>
<if test="beginTime != null">
AND b.create_date >= #{beginTime}
</if>
<if test="endTime != null">
AND b.create_date <= #{endTime}
</if>
<if test="orgId != null">
AND a.org_id = #{orgId}
</if>
group by a.id)
Order by c.create_date desc
</select>
<!--查询白名单规则-->
<select id="queryWhiteRuleById" resultMap="BaseResultMap" parameterType="java.lang.Long">
select
<include refid="Base_Column_List"/>
from tb_r_whitelist_rule
where id = #{id,jdbcType=BIGINT}
and data_state = 1
</select>
<!-- 查询需要推送的白名单 -->
<select id="queryNoPustWhiteCarNoList"
resultType="com.zteits.clouds.api.dto.bill.whitelist.WhitelistParkRelPushDTO">
select a.white_r_no whiteRNo,
a.white_r_name whiteRName,
a.eff_date effDate,
a.exp_date expDate,
a.report_fee_type reportFeeType,
b.car_number carNum,
b.id id,
b.pl_no plNo,
b.white_state whiteState
from tb_r_whitelist_rule a,
tb_r_whitelist_park_car_rel b
where a.match_type = 3
and a.charge_type = 1
and a.white_r_no = b.white_r_no
<![CDATA[and a.exp_date >= #{nowDate}]]>
and b.push_state = 0
</select>
<!-- 根据车牌号码,停车场编号判断符合条件的白名单列表,包括过期数据 -->
<select id="queryAllWhiteCarInfoByParkCodeAnCarnumber"
resultMap="BaseResultMap">
select
c.id,
c.white_r_no,
c.white_r_name,
c.match_type,
c.charge_type,
c.car_num,
c.white_r_state,
c.eff_date,
c.exp_date,
c.create_date,
c.max_charge_fee
from tb_r_whitelist_rule c
where c.id in
(select
a.id
from tb_r_whitelist_rule a
left JOIN tb_r_whitelist_park_rel b on a.white_r_no = b.white_r_no and b.data_state = 1
left JOIN tb_r_whitelist_rule_car_number d on a.white_r_no = d.white_r_no and d.data_state =1
where a.data_state = 1
and b.pl_no = #{plNo}
and d.car_number = #{carNumber}
group by a.id)
</select>
<select id="queryAllActiveInfo" resultType="com.zteits.bill.domain.TbRWhitelistRule">
SELECT c.car_number as carNum FROM `tb_r_whitelist_rule_car_number` c
left join tb_r_whitelist_rule t
on c.white_r_no = t.white_r_no
where
t.org_id = #{orgId}
and c.data_state = 1
and t.data_state = 1
and t.eff_date < now()
and t.exp_date > now()
</select>
<!-- 更新已存在的历史白名单为失效 -->
<update id="updateWhiteRuleExpireDateByCarNos" parameterType="com.zteits.clouds.api.dto.bill.whitelist.param.AddWhiteRuleRequest">
update tb_r_whitelist_park_rel c,
(select b.id
from tb_r_whitelist_rule a,
tb_r_whitelist_park_rel b
where a.data_state = 1
and b.data_state = 1
and a.white_r_no = b.white_r_no
and a.car_num in
<foreach collection="carNums" open="(" close=")" item="carNum" separator=",">
#{carNum}
</foreach>
and exp_date > #{effDate}
and b.pl_no in
<foreach collection="plNos" open="(" close=")" item="plNo" separator=",">
#{plNo}
</foreach>
)d
set c.data_state = 0,
c.modify_empid = #{createEmpid},
c.modify_date = #{createDate}
where c.id = d.id
</update>
</mapper>