<?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.ruoyi.ems.mapper.AdmBoxElecEqptMapper">

    <resultMap type="com.ruoyi.ems.domain.AdmBoxElecEqpt" id="AdmBoxElecEqptResult">
        <result property="id"    column="id"    />
        <result property="boxCode"    column="box_code"    />
        <result property="eqptCode"    column="eqpt_code"    />
        <result property="extEqptCode"    column="ext_eqpt_code"    />
        <result property="eqptType"    column="eqpt_type"    />
        <result property="eqptSpec"    column="eqpt_spec"    />
        <result property="ratedVoltage"    column="rated_voltage"    />
        <result property="ratedCurrent"    column="rated_current"    />
        <result property="ancestors"    column="ancestors"    />
        <result property="parentEqpt"    column="parent_eqpt"    />
        <result property="subCircuit"    column="sub_circuit"    />
    </resultMap>

    <sql id="selectAdmBoxElecEqptVo">
        select id, box_code, eqpt_code, ext_eqpt_code, eqpt_type, eqpt_spec, rated_voltage, rated_current, ancestors, parent_eqpt, sub_circuit from adm_box_elec_eqpt
    </sql>

    <select id="selectAdmBoxElecEqptList" parameterType="com.ruoyi.ems.domain.AdmBoxElecEqpt" resultMap="AdmBoxElecEqptResult">
        <include refid="selectAdmBoxElecEqptVo"/>
        <where>
            <if test="boxCode != null  and boxCode != ''"> and box_code = #{boxCode}</if>
            <if test="eqptCode != null  and eqptCode != ''"> and eqpt_code = #{eqptCode}</if>
        </where>
    </select>


    <select id="selectAdmBoxElecEqptById" parameterType="Long" resultMap="AdmBoxElecEqptResult">
        <include refid="selectAdmBoxElecEqptVo"/>
        where id = #{id}
    </select>

    <insert id="insertAdmBoxElecEqpt" parameterType="com.ruoyi.ems.domain.AdmBoxElecEqpt" useGeneratedKeys="true" keyProperty="id">
        insert into adm_box_elec_eqpt
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="boxCode != null and boxCode != ''">box_code,</if>
            <if test="eqptCode != null and eqptCode != ''">eqpt_code,</if>
            <if test="extEqptCode != null">ext_eqpt_code,</if>
            <if test="eqptType != null">eqpt_type,</if>
            <if test="eqptSpec != null">eqpt_spec,</if>
            <if test="ratedVoltage != null">rated_voltage,</if>
            <if test="ratedCurrent != null">rated_current,</if>
            <if test="ancestors != null">ancestors,</if>
            <if test="parentEqpt != null">parent_eqpt,</if>
            <if test="subCircuit != null">sub_circuit,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="boxCode != null and boxCode != ''">#{boxCode},</if>
            <if test="eqptCode != null and eqptCode != ''">#{eqptCode},</if>
            <if test="extEqptCode != null">#{extEqptCode},</if>
            <if test="eqptType != null">#{eqptType},</if>
            <if test="eqptSpec != null">#{eqptSpec},</if>
            <if test="ratedVoltage != null">#{ratedVoltage},</if>
            <if test="ratedCurrent != null">#{ratedCurrent},</if>
            <if test="ancestors != null">#{ancestors},</if>
            <if test="parentEqpt != null">#{parentEqpt},</if>
            <if test="subCircuit != null">#{subCircuit},</if>
         </trim>
    </insert>

    <update id="updateAdmBoxElecEqpt" parameterType="com.ruoyi.ems.domain.AdmBoxElecEqpt">
        update adm_box_elec_eqpt
        <trim prefix="SET" suffixOverrides=",">
            <if test="boxCode != null and boxCode != ''">box_code = #{boxCode},</if>
            <if test="eqptCode != null and eqptCode != ''">eqpt_code = #{eqptCode},</if>
            <if test="extEqptCode != null">ext_eqpt_code = #{extEqptCode},</if>
            <if test="eqptType != null">eqpt_type = #{eqptType},</if>
            <if test="eqptSpec != null">eqpt_spec = #{eqptSpec},</if>
            <if test="ratedVoltage != null">rated_voltage = #{ratedVoltage},</if>
            <if test="ratedCurrent != null">rated_current = #{ratedCurrent},</if>
            <if test="ancestors != null">ancestors = #{ancestors},</if>
            <if test="parentEqpt != null">parent_eqpt = #{parentEqpt},</if>
            <if test="subCircuit != null">sub_circuit = #{subCircuit},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAdmBoxElecEqptById" parameterType="Long">
        delete from adm_box_elec_eqpt where id = #{id}
    </delete>

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