<?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.zbf.system.mapper.TAgvMapper">

    <resultMap type="TAgv" id="TAgvResult">
            <result property="id"    column="id"    />
            <result property="agvId"    column="agv_id"    />
            <result property="agvIp"    column="agv_ip"    />
            <result property="agvSts"    column="agv_sts"    />
            <result property="agvErrSts"    column="agv_err_sts"    />
            <result property="agvSpeed"    column="agv_speed"    />
            <result property="agvPower"    column="agv_power"    />
            <result property="agvLine"    column="agv_line"    />
            <result property="agvWteLoc"    column="agv_wte_loc"    />
            <result property="agvCharge"    column="agv_charge"    />
            <result property="agvMileage"    column="agv_mileage"    />
            <result property="agvRunSts"    column="agv_run_sts"    />
            <result property="agvLineSts"    column="agv_line_sts"    />
            <result property="agvNetSts"    column="agv_net_sts"    />
            <result property="agvLocTime"    column="agv_loc_time"    />
            <result property="agvType"    column="agv_type"    />
            <result property="agvGo"    column="agv_go"    />
            <result property="agvTkId"    column="agv_tk_id"    />
            <result property="agvView"    column="agv_view"    />
            <result property="agvRunId"    column="agv_run_id"    />
            <result property="agvFtupSts"    column="agv_ftup_sts"    />
            <result property="agvUbkSts"    column="agv_ubk_sts"    />
            <result property="agvUftSts"    column="agv_uft_sts"    />
            <result property="agvStop"    column="agv_stop"    />
            <result property="endValAgv"    column="end_val_agv"    />
    </resultMap>

    <sql id="selectTAgvVo">
        select id, agv_id, agv_ip, agv_sts, agv_err_sts, agv_speed, agv_power, agv_line, agv_wte_loc, agv_charge, agv_mileage, agv_run_sts, agv_line_sts, agv_net_sts, agv_loc_time, agv_type, agv_go, agv_tk_id, agv_view, agv_run_id, agv_ftup_sts, agv_ubk_sts, agv_uft_sts, agv_stop, end_val_agv from t_agv
    </sql>

    <select id="selectTAgvList" parameterType="TAgv" resultMap="TAgvResult">
        <include refid="selectTAgvVo"/>
        <where>
                        <if test="agvId != null  and agvId != ''"> and agv_id = #{agvId}</if>
                        <if test="agvIp != null  and agvIp != ''"> and agv_ip = #{agvIp}</if>
                        <if test="agvSts != null  and agvSts != ''"> and agv_sts = #{agvSts}</if>
                        <if test="agvErrSts != null  and agvErrSts != ''"> and agv_err_sts = #{agvErrSts}</if>
                        <if test="agvSpeed != null  and agvSpeed != ''"> and agv_speed = #{agvSpeed}</if>
                        <if test="agvPower != null  and agvPower != ''"> and agv_power = #{agvPower}</if>
                        <if test="agvLine != null  and agvLine != ''"> and agv_line = #{agvLine}</if>
                        <if test="agvWteLoc != null  and agvWteLoc != ''"> and agv_wte_loc = #{agvWteLoc}</if>
                        <if test="agvCharge != null  and agvCharge != ''"> and agv_charge = #{agvCharge}</if>
                        <if test="agvMileage != null  and agvMileage != ''"> and agv_mileage = #{agvMileage}</if>
                        <if test="agvRunSts != null  and agvRunSts != ''"> and agv_run_sts = #{agvRunSts}</if>
                        <if test="agvLineSts != null  and agvLineSts != ''"> and agv_line_sts = #{agvLineSts}</if>
                        <if test="agvNetSts != null  and agvNetSts != ''"> and agv_net_sts = #{agvNetSts}</if>
                        <if test="agvLocTime != null "> and agv_loc_time = #{agvLocTime}</if>
                        <if test="agvType != null  and agvType != ''"> and agv_type = #{agvType}</if>
                        <if test="agvGo != null  and agvGo != ''"> and agv_go = #{agvGo}</if>
                        <if test="agvTkId != null  and agvTkId != ''"> and agv_tk_id = #{agvTkId}</if>
                        <if test="agvView != null  and agvView != ''"> and agv_view = #{agvView}</if>
                        <if test="agvRunId != null  and agvRunId != ''"> and agv_run_id = #{agvRunId}</if>
                        <if test="agvFtupSts != null  and agvFtupSts != ''"> and agv_ftup_sts = #{agvFtupSts}</if>
                        <if test="agvUbkSts != null  and agvUbkSts != ''"> and agv_ubk_sts = #{agvUbkSts}</if>
                        <if test="agvUftSts != null  and agvUftSts != ''"> and agv_uft_sts = #{agvUftSts}</if>
                        <if test="agvStop != null  and agvStop != ''"> and agv_stop = #{agvStop}</if>
                        <if test="endValAgv != null  and endValAgv != ''"> and end_val_agv = #{endValAgv}</if>
        </where>
    </select>

    <select id="selectTAgvById" parameterType="Long" resultMap="TAgvResult">
            <include refid="selectTAgvVo"/>
            where id = #{id}
    </select>

    <insert id="insertTAgv" parameterType="TAgv">
        insert into t_agv
        <trim prefix="(" suffix=")" suffixOverrides=",">
                    <if test="id != null">id,</if>
                    <if test="agvId != null and agvId != ''">agv_id,</if>
                    <if test="agvIp != null">agv_ip,</if>
                    <if test="agvSts != null">agv_sts,</if>
                    <if test="agvErrSts != null">agv_err_sts,</if>
                    <if test="agvSpeed != null">agv_speed,</if>
                    <if test="agvPower != null">agv_power,</if>
                    <if test="agvLine != null">agv_line,</if>
                    <if test="agvWteLoc != null">agv_wte_loc,</if>
                    <if test="agvCharge != null">agv_charge,</if>
                    <if test="agvMileage != null">agv_mileage,</if>
                    <if test="agvRunSts != null">agv_run_sts,</if>
                    <if test="agvLineSts != null">agv_line_sts,</if>
                    <if test="agvNetSts != null">agv_net_sts,</if>
                    <if test="agvLocTime != null">agv_loc_time,</if>
                    <if test="agvType != null">agv_type,</if>
                    <if test="agvGo != null">agv_go,</if>
                    <if test="agvTkId != null">agv_tk_id,</if>
                    <if test="agvView != null">agv_view,</if>
                    <if test="agvRunId != null">agv_run_id,</if>
                    <if test="agvFtupSts != null">agv_ftup_sts,</if>
                    <if test="agvUbkSts != null">agv_ubk_sts,</if>
                    <if test="agvUftSts != null">agv_uft_sts,</if>
                    <if test="agvStop != null">agv_stop,</if>
                    <if test="endValAgv != null">end_val_agv,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                    <if test="id != null">#{id},</if>
                    <if test="agvId != null and agvId != ''">#{agvId},</if>
                    <if test="agvIp != null">#{agvIp},</if>
                    <if test="agvSts != null">#{agvSts},</if>
                    <if test="agvErrSts != null">#{agvErrSts},</if>
                    <if test="agvSpeed != null">#{agvSpeed},</if>
                    <if test="agvPower != null">#{agvPower},</if>
                    <if test="agvLine != null">#{agvLine},</if>
                    <if test="agvWteLoc != null">#{agvWteLoc},</if>
                    <if test="agvCharge != null">#{agvCharge},</if>
                    <if test="agvMileage != null">#{agvMileage},</if>
                    <if test="agvRunSts != null">#{agvRunSts},</if>
                    <if test="agvLineSts != null">#{agvLineSts},</if>
                    <if test="agvNetSts != null">#{agvNetSts},</if>
                    <if test="agvLocTime != null">#{agvLocTime},</if>
                    <if test="agvType != null">#{agvType},</if>
                    <if test="agvGo != null">#{agvGo},</if>
                    <if test="agvTkId != null">#{agvTkId},</if>
                    <if test="agvView != null">#{agvView},</if>
                    <if test="agvRunId != null">#{agvRunId},</if>
                    <if test="agvFtupSts != null">#{agvFtupSts},</if>
                    <if test="agvUbkSts != null">#{agvUbkSts},</if>
                    <if test="agvUftSts != null">#{agvUftSts},</if>
                    <if test="agvStop != null">#{agvStop},</if>
                    <if test="endValAgv != null">#{endValAgv},</if>
        </trim>
    </insert>

    <update id="updateTAgv" parameterType="TAgv">
        update t_agv
        <trim prefix="SET" suffixOverrides=",">
                    <if test="agvId != null and agvId != ''">agv_id = #{agvId},</if>
                    <if test="agvIp != null">agv_ip = #{agvIp},</if>
                    <if test="agvSts != null">agv_sts = #{agvSts},</if>
                    <if test="agvErrSts != null">agv_err_sts = #{agvErrSts},</if>
                    <if test="agvSpeed != null">agv_speed = #{agvSpeed},</if>
                    <if test="agvPower != null">agv_power = #{agvPower},</if>
                    <if test="agvLine != null">agv_line = #{agvLine},</if>
                    <if test="agvWteLoc != null">agv_wte_loc = #{agvWteLoc},</if>
                    <if test="agvCharge != null">agv_charge = #{agvCharge},</if>
                    <if test="agvMileage != null">agv_mileage = #{agvMileage},</if>
                    <if test="agvRunSts != null">agv_run_sts = #{agvRunSts},</if>
                    <if test="agvLineSts != null">agv_line_sts = #{agvLineSts},</if>
                    <if test="agvNetSts != null">agv_net_sts = #{agvNetSts},</if>
                    <if test="agvLocTime != null">agv_loc_time = #{agvLocTime},</if>
                    <if test="agvType != null">agv_type = #{agvType},</if>
                    <if test="agvGo != null">agv_go = #{agvGo},</if>
                    <if test="agvTkId != null">agv_tk_id = #{agvTkId},</if>
                    <if test="agvView != null">agv_view = #{agvView},</if>
                    <if test="agvRunId != null">agv_run_id = #{agvRunId},</if>
                    <if test="agvFtupSts != null">agv_ftup_sts = #{agvFtupSts},</if>
                    <if test="agvUbkSts != null">agv_ubk_sts = #{agvUbkSts},</if>
                    <if test="agvUftSts != null">agv_uft_sts = #{agvUftSts},</if>
                    <if test="agvStop != null">agv_stop = #{agvStop},</if>
                    <if test="endValAgv != null">end_val_agv = #{endValAgv},</if>
        </trim>
        where id = #{id}
    </update>

    <update id="enableTAgvByIds" parameterType="String">
        update t_agv set status=0 where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>
    <update id="disabledTAgvByIds" parameterType="String">
        update t_agv set status=1 where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>

    <delete id="deleteTAgvById" parameterType="Long">
        delete from t_agv  where id = #{id}
    </delete>

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