<?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.predict.mapper.WtgTypeTemperatureDefMapper">

    <resultMap type="WtgTypeTemperatureDef" id="WtgTypeTemperatureDefResult">
        <result property="wtgType" column="wtg_type"/>
        <result property="hTemperature" column="h_temperature"/>
        <result property="lTemperature" column="l_temperature"/>
        <result property="reserve1" column="reserve1"/>
        <result property="reserve2" column="reserve2"/>
        <result property="reserve3" column="reserve3"/>
        <result property="reserve4" column="reserve4"/>
        <result property="reserve5" column="reserve5"/>
        <result property="reserve6" column="reserve6"/>
        <result property="reserve7" column="reserve7"/>
        <result property="reserve8" column="reserve8"/>
    </resultMap>

    <sql id="selectWtgTypeTemperatureDefVo">
        select wtg_type, h_temperature, l_temperature, reserve1, reserve2, reserve3, reserve4, reserve5, reserve6, reserve7, reserve8 from wtg_type_temperature_def
    </sql>

    <select id="selectWtgTypeTemperatureDefList" parameterType="WtgTypeTemperatureDef"
            resultMap="WtgTypeTemperatureDefResult">
        select
        wttd.*,
        wt.type_name as "wtgTypeName"
        from
        wtg_type_temperature_def wttd
        left join wtg_type wt on wt.type_no = wttd.wtg_type
        <where>
            <if test="hTemperature != null ">and wttd.h_temperature = #{hTemperature}</if>
            <if test="lTemperature != null ">and wttd.l_temperature = #{lTemperature}</if>
            <if test="reserve1 != null ">and wttd.reserve1 = #{reserve1}</if>
            <if test="reserve2 != null ">and wttd.reserve2 = #{reserve2}</if>
            <if test="reserve3 != null ">and wttd.reserve3 = #{reserve3}</if>
            <if test="reserve4 != null ">and wttd.reserve4 = #{reserve4}</if>
            <if test="reserve5 != null ">and wttd.reserve5 = #{reserve5}</if>
            <if test="reserve6 != null ">and wttd.reserve6 = #{reserve6}</if>
            <if test="reserve7 != null ">and wttd.reserve7 = #{reserve7}</if>
            <if test="reserve8 != null ">and wttd.reserve8 = #{reserve8}</if>
            <if test="wtgTypeName != null  and wtgTypeName != ''">and wt.type_name like concat(concat('%', #{wtgTypeName}), '%')
            </if>
        </where>
    </select>

    <select id="selectWtgTypeTemperatureDefById" parameterType="Long" resultMap="WtgTypeTemperatureDefResult">
        <include refid="selectWtgTypeTemperatureDefVo"/>
        where wtg_type = #{wtgType}
    </select>

    <insert id="insertWtgTypeTemperatureDef" parameterType="WtgTypeTemperatureDef">
        insert into wtg_type_temperature_def
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="wtgType != null">wtg_type,</if>
            <if test="hTemperature != null">h_temperature,</if>
            <if test="lTemperature != null">l_temperature,</if>
            <if test="reserve1 != null">reserve1,</if>
            <if test="reserve2 != null">reserve2,</if>
            <if test="reserve3 != null">reserve3,</if>
            <if test="reserve4 != null">reserve4,</if>
            <if test="reserve5 != null">reserve5,</if>
            <if test="reserve6 != null">reserve6,</if>
            <if test="reserve7 != null">reserve7,</if>
            <if test="reserve8 != null">reserve8,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="wtgType != null">#{wtgType},</if>
            <if test="hTemperature != null">#{hTemperature},</if>
            <if test="lTemperature != null">#{lTemperature},</if>
            <if test="reserve1 != null">#{reserve1},</if>
            <if test="reserve2 != null">#{reserve2},</if>
            <if test="reserve3 != null">#{reserve3},</if>
            <if test="reserve4 != null">#{reserve4},</if>
            <if test="reserve5 != null">#{reserve5},</if>
            <if test="reserve6 != null">#{reserve6},</if>
            <if test="reserve7 != null">#{reserve7},</if>
            <if test="reserve8 != null">#{reserve8},</if>
        </trim>
    </insert>

    <insert id="insertWtgTypeTemperatureDefList">
        insert into wtg_type_temperature_def(wtg_type, h_temperature, l_temperature)
        <foreach collection="list" item="item" separator="UNION ALL">
            SELECT
            #{item.wtgType},
            #{item.hTemperature},
            #{item.lTemperature}
            FROM DUAL
        </foreach>
    </insert>

    <update id="updateWtgTypeTemperatureDef" parameterType="WtgTypeTemperatureDef">
        update wtg_type_temperature_def
        <trim prefix="SET" suffixOverrides=",">
            <if test="hTemperature != null">h_temperature = #{hTemperature},</if>
            <if test="lTemperature != null">l_temperature = #{lTemperature},</if>
            <if test="reserve1 != null">reserve1 = #{reserve1},</if>
            <if test="reserve2 != null">reserve2 = #{reserve2},</if>
            <if test="reserve3 != null">reserve3 = #{reserve3},</if>
            <if test="reserve4 != null">reserve4 = #{reserve4},</if>
            <if test="reserve5 != null">reserve5 = #{reserve5},</if>
            <if test="reserve6 != null">reserve6 = #{reserve6},</if>
            <if test="reserve7 != null">reserve7 = #{reserve7},</if>
            <if test="reserve8 != null">reserve8 = #{reserve8},</if>
        </trim>
        where wtg_type = #{wtgType}
    </update>

    <delete id="deleteWtgTypeTemperatureDefById" parameterType="Long">
        delete from wtg_type_temperature_def where wtg_type = #{wtgType}
    </delete>

    <delete id="deleteWtgTypeTemperatureDefByIds" parameterType="String">
        delete from wtg_type_temperature_def where wtg_type in
        <foreach item="wtgType" collection="array" open="(" separator="," close=")">
            #{wtgType}
        </foreach>
    </delete>

</mapper>