TBillingParkRuleRelSMapper.xml
4.99 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
<?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.TBillingParkRuleRelSMapper">
<resultMap id="BaseResultMap" type="com.zteits.bill.domain.TBillingParkRuleRel">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="pl_no" property="plNo" jdbcType="VARCHAR"/>
<result column="rule_collect_no" property="ruleCollectNo" jdbcType="VARCHAR"/>
<result column="data_state" property="dataState" jdbcType="INTEGER"/>
<result column="effect_time" property="effectTime" jdbcType="TIMESTAMP"/>
<result column="expire_time" property="expireTime" jdbcType="TIMESTAMP"/>
<result column="check_state" property="checkState" jdbcType="INTEGER"/>
<result column="create_op" property="createOp" jdbcType="BIGINT"/>
<result column="create_op_name" property="createOpName" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="modify_op" property="modifyOp" jdbcType="BIGINT"/>
<result column="modify_op_name" property="modifyOpName" jdbcType="VARCHAR"/>
<result column="modify_time" property="modifyTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, pl_no, rule_collect_no, data_state, effect_time, expire_time, check_state, create_op,
create_op_name, create_time, modify_op, modify_op_name, modify_time
</sql>
<sql id="Base_Column_List_No_Id">
pl_no, rule_collect_no, data_state, effect_time, expire_time, check_state, create_op,
create_op_name, create_time, modify_op, modify_op_name, modify_time
</sql>
<update id="deleteBillingRuleCollectParkRel">
UPDATE t_billing_park_rule_rel
SET data_state = 0
WHERE
data_state = 1
AND rule_collect_no =#{ruleCollectNo}
</update>
<!-- 分页查询计费规则与停车场管理关系表 langlw 2017-11-22 -->
<select id="queryBillingParkRuleRelForPage"
parameterType="com.zteits.clouds.api.dto.bill.billingrule.param.BillingParkRuleRelQueryForPageReq"
resultType="com.zteits.clouds.api.dto.bill.billingrule.dto.BillingParkRuleRelDTO">
SELECT
DISTINCT a.rule_collect_no as ruleCollectNo,
a.id as id,
a.pl_no as plNo,
a.effect_time as effectTime,
a.expire_time as expireTime,
b.rule_collect_name as ruleCollectName,
a.create_time
FROM
t_billing_park_rule_rel a
LEFT JOIN t_billing_rule_collect b
ON a.rule_collect_no = b.rule_collect_no
where a.data_state = 1
AND b.data_state = 1
<if test="ruleCollectName !=null ">
AND b.rule_collect_name like CONCAT('%',#{ruleCollectName},'%')
</if>
<if test="effectTime !=null ">
and DATE_FORMAT(a.effect_time ,'%Y-%m-%d') >= DATE_FORMAT(#{effectTime} ,'%Y-%m-%d')
</if>
<if test="expireTime !=null ">
AND DATE_FORMAT(a.expire_time ,'%Y-%m-%d') <= DATE_FORMAT(#{expireTime} ,'%Y-%m-%d')
</if>
<!-- 生效中 -->
<if test="isEff != null and isEff==1 ">
<![CDATA[ and a.effect_time <= now() and now() <= a.expire_time ]]>
</if>
<!-- 已失效 -->
<if test="isEff != null and isEff==2 ">
<![CDATA[ and now() > a.expire_time ]]>
</if>
<!-- 未生效 -->
<if test="isEff != null and isEff==3 ">
<![CDATA[ and a.effect_time > now() AND now() < a.expire_time and a.effect_time < a.expire_time ]]>
</if>
<if test="plNos != null and plNos.size()>0">
and a.pl_no IN
<foreach collection="plNos" open="(" close=")" separator="," item="plNo">
#{plNo}
</foreach>
</if>
ORDER BY a.create_time DESC
</select>
<update id="updateBillingRuleCollectExpireTimeByPlNos">
update t_billing_park_rule_rel SET expire_time =
#{expireTime},modify_op=#{opId},modify_op_name=#{opName},modify_time=now()
WHERE pl_no IN
<foreach collection="plNos" index="index" item="plno" open="(" separator="," close=")">
#{plno}
</foreach>
AND expire_time >= #{newEffectTime}
</update>
<insert id="batchSaveBillingRuleCollectParkRel">
INSERT INTO t_billing_park_rule_rel(
<include refid="Base_Column_List_No_Id"/>
) VALUES
<foreach collection="plNos" separator="," item="plNo" index="index">
(
#{plNo},
#{ruleCollectNo},
1,
#{effectTime},
'2999-01-01 00:00:00',
3,
#{opId},
#{opName},
now(),
#{opId},
#{opName},
now()
)
</foreach>
</insert>
<select id="queryBillingCollectionNoByPlNo" >
</select>
</mapper>