<?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.inspect.metadata.montdata.mapper.BasedataMontNestRunDataMapper">

    <resultMap type="BasedataMontNestRunData" id="BasedataMontNestRunDataResult">
        <result property="dataId" column="data_id"/>
        <result property="eqpBookId" column="eqp_book_id"/>
        <result property="nestCode" column="nest_code"/>
        <result property="nestName" column="nest_name"/>
        <result property="moduleNo" column="module_no"/>
        <result property="time" column="time"/>
        <result property="type" column="type"/>
        <result property="typeName" column="type_name"/>
        <result property="value" column="value"/>
        <result property="valueName" column="value_name"/>
        <result property="valueUnit" column="value_unit"/>
        <result property="unit" column="unit"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="deleteFlag" column="delete_flag"/>
    </resultMap>

    <sql id="selectBasedataMontNestRunDataVo">
        select data_id,
               eqp_book_id,
               nest_code,
               nest_name,
               module_no, time, type, type_name, value, value_name, value_unit, unit, create_by, create_time, update_by, update_time, delete_flag
        from basedata_mont_nestrundata
    </sql>

    <select id="selectBasedataMontNestRunDataList" parameterType="BasedataMontNestRunData"
            resultMap="BasedataMontNestRunDataResult">
        <include refid="selectBasedataMontNestRunDataVo"/>
        <where>
            <if test="eqpBookId != null ">and eqp_book_id = #{eqpBookId}</if>
            <if test="nestCode != null  and nestCode != ''">and nest_code = #{nestCode}</if>
            <if test="nestName != null  and nestName != ''">and nest_name like concat('%', #{nestName}, '%')</if>
            <if test="moduleNo != null  and moduleNo != ''">and module_no = #{moduleNo}</if>
            <if test="time != null  and time != ''">and time = #{time}</if>
            <if test="type != null  and type != ''">and type = #{type}</if>
            <if test="typeName != null  and typeName != ''">and type_name like concat('%', #{typeName}, '%')</if>
            <if test="value != null  and value != ''">and value = #{value}</if>
            <if test="valueName != null  and valueName != ''">and value_name like concat('%', #{valueName}, '%')</if>
            <if test="valueUnit != null  and valueUnit != ''">and value_unit = #{valueUnit}</if>
            <if test="unit != null  and unit != ''">and unit = #{unit}</if>
            <if test="deleteFlag != null  and deleteFlag != ''">and delete_flag = #{deleteFlag}</if>
        </where>
    </select>

    <select id="selectBasedataMontNestRunDataByMontNestRunDataId" parameterType="Long"
            resultMap="BasedataMontNestRunDataResult">
        <include refid="selectBasedataMontNestRunDataVo"/>
        where data_id = #{dataId}
    </select>

    <insert id="insertBasedataMontNestRunData" parameterType="BasedataMontNestRunData" useGeneratedKeys="true"
            keyProperty="dataId">
        insert into basedata_mont_nestrundata
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="eqpBookId != null ">eqp_book_id,</if>
            <if test="nestCode != null">nest_code,</if>
            <if test="nestName != null">nest_name,</if>
            <if test="moduleNo != null">module_no,</if>
            <if test="time != null">time,</if>
            <if test="type != null">type,</if>
            <if test="typeName != null">type_name,</if>
            <if test="value != null">value,</if>
            <if test="valueName != null">value_name,</if>
            <if test="valueUnit != null">value_unit,</if>
            <if test="unit != null">unit,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="deleteFlag != null">delete_flag,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="eqpBookId != null ">#{eqpBookId},</if>
            <if test="nestCode != null">#{nestCode},</if>
            <if test="nestName != null">#{nestName},</if>
            <if test="moduleNo != null">#{moduleNo},</if>
            <if test="time != null">#{time},</if>
            <if test="type != null">#{type},</if>
            <if test="typeName != null">#{typeName},</if>
            <if test="value != null">#{value},</if>
            <if test="valueName != null">#{valueName},</if>
            <if test="valueUnit != null">#{valueUnit},</if>
            <if test="unit != null">#{unit},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="deleteFlag != null">#{deleteFlag},</if>
        </trim>
    </insert>

    <update id="updateBasedataMontNestRunData" parameterType="BasedataMontNestRunData">
        update basedata_mont_nestrundata
        <trim prefix="SET" suffixOverrides=",">
            <if test="eqpBookId != null ">eqp_book_id = #{eqpBookId},</if>
            <if test="nestCode != null">nest_code = #{nestCode},</if>
            <if test="nestName != null">nest_name = #{nestName},</if>
            <if test="moduleNo != null">module_no = #{moduleNo},</if>
            <if test="time != null">time = #{time},</if>
            <if test="type != null">type = #{type},</if>
            <if test="typeName != null">type_name = #{typeName},</if>
            <if test="value != null">value = #{value},</if>
            <if test="valueName != null">value_name = #{valueName},</if>
            <if test="valueUnit != null">value_unit = #{valueUnit},</if>
            <if test="unit != null">unit = #{unit},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="deleteFlag != null">delete_flag = #{deleteFlag},</if>
        </trim>
        where data_id = #{dataId}
    </update>

    <delete id="deleteBasedataMontNestRunDataByMontNestRunDataId" parameterType="Long">
        delete
        from basedata_mont_nestrundata
        where data_id = #{dataId}
    </delete>

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