TSpecialDeviceRecordMapper.xml 5.42 KB
Newer Older
耿迪迪's avatar
耿迪迪 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
<?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.zehong.system.mapper.TSpecialDeviceRecordMapper">
    
    <resultMap type="TSpecialDeviceRecordVo" id="TSpecialDeviceRecordResult">
        <result property="id"    column="id"    />
        <result property="operateCode"    column="operate_code"    />
        <result property="operateType"    column="operate_type"    />
        <result property="deviceCode"    column="device_code"    />
        <result property="deviceName"    column="device_name"    />
        <result property="deviceType"    column="device_type"    />
        <result property="effectiveDate"    column="effective_date"    />
        <result property="recordStatus"    column="record_status"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="isDel"    column="is_del"    />
    </resultMap>

    <sql id="selectTSpecialDeviceRecordVo">
        select t.id, t.operate_code, t.operate_type, t.device_code, t.effective_date, t.record_status, t.create_time, t.update_time, t.is_del,
        d.device_name, d.device_type
        from t_special_device_record t
25
        left join t_device_info d on t.device_id = d.id
耿迪迪's avatar
耿迪迪 committed
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
    </sql>

    <select id="selectTSpecialDeviceRecordList" parameterType="TSpecialDeviceRecord" resultMap="TSpecialDeviceRecordResult">
        <include refid="selectTSpecialDeviceRecordVo"/>
        <where>  t.is_del = '0'
            <if test="operateCode != null "> and t.operate_code = #{operateCode}</if>
            <if test="operateType != null "> and t.operate_type = #{operateType}</if>
            <if test="deviceCode != null  and deviceCode != ''"> and t.device_code like concat('%', #{deviceCode}, '%')</if>
            <if test="effectiveDate != null "> and t.effective_date = #{effectiveDate}</if>
            <if test="recordStatus != null  and recordStatus != ''"> and t.record_status = #{recordStatus}</if>
            <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
                AND date_format(t.effective_date,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
            </if>
            <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
                AND date_format(t.effective_date,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
            </if>
        </where>
    </select>
    
    <select id="selectTSpecialDeviceRecordById" parameterType="Long" resultMap="TSpecialDeviceRecordResult">
        <include refid="selectTSpecialDeviceRecordVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTSpecialDeviceRecord" parameterType="TSpecialDeviceRecord">
        insert into t_special_device_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="operateCode != null">operate_code,</if>
            <if test="operateType != null">operate_type,</if>
            <if test="deviceCode != null">device_code,</if>
57
            <if test="deviceId != null">device_id,</if>
耿迪迪's avatar
耿迪迪 committed
58 59 60 61 62 63 64 65 66 67 68
            <if test="effectiveDate != null">effective_date,</if>
            <if test="recordStatus != null">record_status,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="isDel != null">is_del,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="operateCode != null">#{operateCode},</if>
            <if test="operateType != null">#{operateType},</if>
            <if test="deviceCode != null">#{deviceCode},</if>
69
            <if test="deviceId != null">#{deviceId},</if>
耿迪迪's avatar
耿迪迪 committed
70 71 72 73 74 75 76 77 78 79 80 81 82
            <if test="effectiveDate != null">#{effectiveDate},</if>
            <if test="recordStatus != null">#{recordStatus},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="isDel != null">#{isDel},</if>
         </trim>
    </insert>

    <update id="updateTSpecialDeviceRecord" parameterType="TSpecialDeviceRecord">
        update t_special_device_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="operateType != null">operate_type = #{operateType},</if>
            <if test="deviceCode != null">device_code = #{deviceCode},</if>
83
            <if test="deviceId != null">device_id = #{deviceId},</if>
耿迪迪's avatar
耿迪迪 committed
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
            <if test="effectiveDate != null">effective_date = #{effectiveDate},</if>
            <if test="recordStatus != null">record_status = #{recordStatus},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
        </trim>
        where operate_code = #{operateCode}
    </update>

    <delete id="deleteTSpecialDeviceRecordById" parameterType="Long">
        delete from t_special_device_record where id = #{id}
    </delete>

    <delete id="deleteTSpecialDeviceRecordByIds" parameterType="String">
        delete from t_special_device_record where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>