ActivationDataMapper.xml 2.82 KB
<?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 &lt; #{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 &lt;= #{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>