ActivationDataMapper.xml
2.82 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
<?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.com.glsx.openplatform.mapper.ActivationDataMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.openplatform.model.ActivationData">
<!--@mbg.generated-->
<!--@Table t_activation_data-->
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="month" jdbcType="VARCHAR" property="month"/>
<result column="customer_id" jdbcType="INTEGER" property="customerId"/>
<result column="customer" jdbcType="VARCHAR" property="customer"/>
<result column="num" jdbcType="INTEGER" property="num"/>
<result column="type" jdbcType="TINYINT" property="type"/>
</resultMap>
<select id="selectActivationList" resultType="cn.com.glsx.openplatform.model.ActivationData">
select id, month, customer_id customerId, customer, num, type
from t_activation_data
order by month;
</select>
<select id="countByDate" resultType="integer">
select count(1)
from t_platform_device
<where>
<if test="startDate != null">
and create_time >= #{startDate,jdbcType=TIMESTAMP}
</if>
<if test="endDate != null">
and create_time < #{endDate,jdbcType=TIMESTAMP}
</if>
</where>
</select>
<update id="updateDeviceActivation">
update t_platform_device
set customer_id = #{data.customerId,jdbcType=INTEGER},
activat_time = from_unixtime(
unix_timestamp(#{data.month,jdbcType=VARCHAR}) + floor(
rand() * (
unix_timestamp(#{data.endMonth,jdbcType=VARCHAR})
- unix_timestamp(#{data.month,jdbcType=VARCHAR}) + 1
)
)
)
where customer_id is null
and create_time > #{startTimeStr,jdbcType=VARCHAR}
and create_time <= #{endTimeStr,jdbcType=VARCHAR}
and device_type = #{data.typeName,jdbcType=VARCHAR}
order by rand()
limit #{num,jdbcType=INTEGER}
</update>
<select id="selectDeviceTypeList" resultType="java.lang.String">
select distinct device_type
from t_shipment_data
</select>
<select id="selectShipmentByType" resultType="cn.com.glsx.openplatform.model.ShipmentData">
select id, goods_time goodsTime, goods_num goodsNum, device_type deviceType,
customer_id customerId, customer_name customerName, version
from t_shipment_data
<where>
<if test="deviceType != null and deviceType != ''">
and device_type = #{deviceType,jdbcType=VARCHAR}
</if>
</where>
</select>
</mapper>