PointsItemMapper.xml
7.05 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
<?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="cn.runsa.crmapp.points.mapper.PointsItemMapper">
<resultMap id="BaseResultMap" type="cn.runsa.crmapp.points.entity.PointsItem">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<id column="ITM_ID" jdbcType="BIGINT" property="itmId" />
<result column="PNT_ID" jdbcType="BIGINT" property="pntId" />
<result column="PNT_VAL" jdbcType="DOUBLE" property="pntVal" />
<result column="BLC_ACT" jdbcType="BIGINT" property="blcAct" />
<result column="S_TIME" jdbcType="TIMESTAMP" property="sTime" />
<result column="E_TIME" jdbcType="TIMESTAMP" property="eTime" />
<result column="REC_TIME" jdbcType="TIMESTAMP" property="recTime" />
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
`ITM_ID`, `PNT_ID`, `PNT_VAL`, `BLC_ACT`, `S_TIME`, `E_TIME`, `REC_TIME`
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<include refid="Base_Column_List" />
from crm_points_item
where `ITM_ID` = #{itmId,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from crm_points_item
where `ITM_ID` = #{itmId,jdbcType=BIGINT}
</delete>
<delete id="deleteListByPrimaryKey">
delete from crm_points_item
where `ITM_ID` in
<foreach collection="list" open="(" close=")" separator="," item="it">
#{it.itmId}
</foreach>
</delete>
<insert id="insert" parameterType="cn.runsa.crmapp.points.entity.PointsItem">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<selectKey keyProperty="itmId" order="AFTER" resultType="java.lang.Long">
SELECT LAST_INSERT_ID()
</selectKey>
insert into crm_points_item (`ITM_ID`, `PNT_ID`, `PNT_VAL`,
`BLC_ACT`, `S_TIME`, `E_TIME`,
`REC_TIME`)
values (#{itmId,jdbcType=BIGINT}, #{pntId,jdbcType=BIGINT}, #{pntVal,jdbcType=DOUBLE},
#{blcAct,jdbcType=BIGINT}, #{sTime,jdbcType=TIMESTAMP}, #{eTime,jdbcType=TIMESTAMP},
#{recTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="cn.runsa.crmapp.points.entity.PointsItem">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<selectKey keyProperty="itmId" order="AFTER" resultType="java.lang.Long">
SELECT LAST_INSERT_ID()
</selectKey>
insert into crm_points_item
<trim prefix="(" suffix=")" suffixOverrides=",">
`ITM_ID`,
<if test="pntId != null">
`PNT_ID`,
</if>
<if test="pntVal != null">
`PNT_VAL`,
</if>
<if test="blcAct != null">
`BLC_ACT`,
</if>
<if test="sTime != null">
`S_TIME`,
</if>
<if test="eTime != null">
`E_TIME`,
</if>
<if test="recTime != null">
`REC_TIME`,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{itmId,jdbcType=BIGINT},
<if test="pntId != null">
#{pntId,jdbcType=BIGINT},
</if>
<if test="pntVal != null">
#{pntVal,jdbcType=DOUBLE},
</if>
<if test="blcAct != null">
#{blcAct,jdbcType=BIGINT},
</if>
<if test="sTime != null">
#{sTime,jdbcType=TIMESTAMP},
</if>
<if test="eTime != null">
#{eTime,jdbcType=TIMESTAMP},
</if>
<if test="recTime != null">
#{recTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<insert id="insertOrUpdate" parameterType="map">
insert into crm_points_item (`PNT_ID`, `PNT_VAL`, `BLC_ACT`, `S_TIME`, `E_TIME`)
values
<foreach collection="list" item="it" separator=",">
(#{it.pntId,jdbcType=BIGINT}, #{it.pntVal,jdbcType=DOUBLE}, #{it.blcAct,jdbcType=BIGINT}, #{it.sTime,jdbcType=TIMESTAMP}, #{it.eTime,jdbcType=TIMESTAMP})
</foreach>
ON DUPLICATE KEY UPDATE
<choose>
<when test="plus == true">
`PNT_VAL`=`PNT_VAL`+values(`PNT_VAL`)
</when>
<otherwise>
`PNT_VAL`= values(`PNT_VAL`)
</otherwise>
</choose>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="cn.runsa.crmapp.points.entity.PointsItem">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update crm_points_item
<set>
<if test="pntId != null">
`PNT_ID` = #{pntId,jdbcType=BIGINT},
</if>
<if test="pntVal != null">
`PNT_VAL` = #{pntVal,jdbcType=DOUBLE},
</if>
<if test="blcAct != null">
`BLC_ACT` = #{blcAct,jdbcType=BIGINT},
</if>
<if test="sTime != null">
`S_TIME` = #{sTime,jdbcType=TIMESTAMP},
</if>
<if test="eTime != null">
`E_TIME` = #{eTime,jdbcType=TIMESTAMP},
</if>
<if test="recTime != null">
`REC_TIME` = #{recTime,jdbcType=TIMESTAMP},
</if>
</set>
where `ITM_ID` = #{itmId,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="cn.runsa.crmapp.points.entity.PointsItem">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update crm_points_item
set `PNT_ID` = #{pntId,jdbcType=BIGINT},
`PNT_VAL` = #{pntVal,jdbcType=DOUBLE},
`BLC_ACT` = #{blcAct,jdbcType=BIGINT},
`S_TIME` = #{sTime,jdbcType=TIMESTAMP},
`E_TIME` = #{eTime,jdbcType=TIMESTAMP},
`REC_TIME` = #{recTime,jdbcType=TIMESTAMP}
where `ITM_ID` = #{itmId,jdbcType=BIGINT}
</update>
<select id="countPointsAvaliable" statementType="CALLABLE" parameterType="map" resultType="double">
{call crm_pdu_points_total(#{pntId,mode=IN,jdbcType=BIGINT},#{date,mode=IN,jdbcType=TIMESTAMP})}
</select>
<select id="countPointsWithNoLocking" parameterType="map" resultType="double">
SELECT SUM(PNT_VAL) FROM crm_points_item WHERE PNT_ID = #{pntId} AND `E_TIME` > #{date} AND `S_TIME` < #{date};
</select>
<select id="selectAvaliable" parameterType="map" resultMap="BaseResultMap">
SELECT *
FROM crm_points_item
WHERE ITM_ID IN
(SELECT ITM_ID
FROM crm_points_item
WHERE PNT_ID = #{pntId}
AND `E_TIME` > #{date}
AND `S_TIME` < #{date} ) ORDER BY `E_TIME` ASC
LIMIT #{start},#{pageSize}
</select>
<select id="selectByItem" resultMap="BaseResultMap">
SELECT *
FROM crm_points_item
WHERE ITM_ID IN (
<foreach collection="list" item="it" separator=",">
#{it}
</foreach>
)
FOR UPDATE
</select>
</mapper>