<?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.AreaMapper">

    <resultMap type="Area" id="AreaResult">
        <result property="areaNo" column="area_no"/>
        <result property="areaType" column="area_type"/>
        <result property="status" column="status"/>
        <result property="power" column="power"/>
        <result property="wfCnt" column="wf_cnt"/>
        <result property="runWf" column="run_wf"/>
        <result property="stopWf" column="stop_wf"/>
        <result property="installWtg" column="install_wtg"/>
        <result property="installPower" column="install_power"/>
        <result property="putintoWtg" column="putinto_wtg"/>
        <result property="putintoPower" column="putinto_power"/>
        <result property="joinWtg" column="join_wtg"/>
        <result property="joinPower" column="join_power"/>
        <result property="runWtg" column="run_wtg"/>
        <result property="stopWtg" column="stop_wtg"/>
        <result property="procTime" column="proc_time"/>
        <result property="procDayTime" column="proc_day_time"/>
        <result property="procMonthTime" column="proc_month_time"/>
        <result property="name" column="name"/>
        <result property="pathname" column="pathname"/>
        <result property="aliasname" column="aliasname"/>
        <result property="description" column="description"/>
    </resultMap>

    <sql id="selectAreaVo">
        select area_no, area_type, status, power, wf_cnt, run_wf, stop_wf, install_wtg, install_power, putinto_wtg, putinto_power, join_wtg, join_power, run_wtg, stop_wtg, proc_time, proc_day_time, proc_month_time, name, pathname, aliasname, description from area
    </sql>

    <select id="selectAreaList" parameterType="Area" resultMap="AreaResult">
        <include refid="selectAreaVo"/>
        <where>
            <if test="areaType != null ">and area_type = #{areaType}</if>
            <if test="status != null ">and status = #{status}</if>
            <if test="power != null ">and power = #{power}</if>
            <if test="wfCnt != null ">and wf_cnt = #{wfCnt}</if>
            <if test="runWf != null ">and run_wf = #{runWf}</if>
            <if test="stopWf != null ">and stop_wf = #{stopWf}</if>
            <if test="installWtg != null ">and install_wtg = #{installWtg}</if>
            <if test="installPower != null ">and install_power = #{installPower}</if>
            <if test="putintoWtg != null ">and putinto_wtg = #{putintoWtg}</if>
            <if test="putintoPower != null ">and putinto_power = #{putintoPower}</if>
            <if test="joinWtg != null ">and join_wtg = #{joinWtg}</if>
            <if test="joinPower != null ">and join_power = #{joinPower}</if>
            <if test="runWtg != null ">and run_wtg = #{runWtg}</if>
            <if test="stopWtg != null ">and stop_wtg = #{stopWtg}</if>
            <if test="procTime != null ">and proc_time = #{procTime}</if>
            <if test="procDayTime != null ">and proc_day_time = #{procDayTime}</if>
            <if test="procMonthTime != null ">and proc_month_time = #{procMonthTime}</if>
            <if test="name != null  and name != ''">and name like concat(concat('%', #{name}), '%')</if>
            <if test="pathname != null  and pathname != ''">and pathname like concat(concat('%', #{pathname}), '%')</if>
            <if test="aliasname != null  and aliasname != ''">and aliasname like concat(concat('%', #{aliasname}),
                '%')
            </if>
            <if test="description != null  and description != ''">and description = #{description}</if>
        </where>
        order by area_no desc
    </select>

    <select id="selectAreaById" parameterType="Long" resultMap="AreaResult">
        <include refid="selectAreaVo"/>
        where area_no = #{areaNo}
    </select>

    <select id="selectNewData" resultType="Long">
        SELECT * FROM ( SELECT area_no FROM area ORDER BY area_no DESC ) WHERE ROWNUM = 1
    </select>

    <insert id="insertArea" parameterType="Area">
        insert into area
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="areaNo != null">area_no,</if>
            <if test="areaType != null">area_type,</if>
            <if test="status != null">status,</if>
            <if test="power != null">power,</if>
            <if test="wfCnt != null">wf_cnt,</if>
            <if test="runWf != null">run_wf,</if>
            <if test="stopWf != null">stop_wf,</if>
            <if test="installWtg != null">install_wtg,</if>
            <if test="installPower != null">install_power,</if>
            <if test="putintoWtg != null">putinto_wtg,</if>
            <if test="putintoPower != null">putinto_power,</if>
            <if test="joinWtg != null">join_wtg,</if>
            <if test="joinPower != null">join_power,</if>
            <if test="runWtg != null">run_wtg,</if>
            <if test="stopWtg != null">stop_wtg,</if>
            <if test="procTime != null">proc_time,</if>
            <if test="procDayTime != null">proc_day_time,</if>
            <if test="procMonthTime != null">proc_month_time,</if>
            <if test="name != null">name,</if>
            <if test="pathname != null">pathname,</if>
            <if test="aliasname != null">aliasname,</if>
            <if test="description != null">description,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="areaNo != null">#{areaNo},</if>
            <if test="areaType != null">#{areaType},</if>
            <if test="status != null">#{status},</if>
            <if test="power != null">#{power},</if>
            <if test="wfCnt != null">#{wfCnt},</if>
            <if test="runWf != null">#{runWf},</if>
            <if test="stopWf != null">#{stopWf},</if>
            <if test="installWtg != null">#{installWtg},</if>
            <if test="installPower != null">#{installPower},</if>
            <if test="putintoWtg != null">#{putintoWtg},</if>
            <if test="putintoPower != null">#{putintoPower},</if>
            <if test="joinWtg != null">#{joinWtg},</if>
            <if test="joinPower != null">#{joinPower},</if>
            <if test="runWtg != null">#{runWtg},</if>
            <if test="stopWtg != null">#{stopWtg},</if>
            <if test="procTime != null">#{procTime},</if>
            <if test="procDayTime != null">#{procDayTime},</if>
            <if test="procMonthTime != null">#{procMonthTime},</if>
            <if test="name != null">#{name},</if>
            <if test="pathname != null">#{pathname},</if>
            <if test="aliasname != null">#{aliasname},</if>
            <if test="description != null">#{description},</if>
        </trim>
    </insert>

    <update id="updateArea" parameterType="Area">
        update area
        <trim prefix="SET" suffixOverrides=",">
            <if test="areaType != null">area_type = #{areaType},</if>
            <if test="status != null">status = #{status},</if>
            <if test="power != null">power = #{power},</if>
            <if test="wfCnt != null">wf_cnt = #{wfCnt},</if>
            <if test="runWf != null">run_wf = #{runWf},</if>
            <if test="stopWf != null">stop_wf = #{stopWf},</if>
            <if test="installWtg != null">install_wtg = #{installWtg},</if>
            <if test="installPower != null">install_power = #{installPower},</if>
            <if test="putintoWtg != null">putinto_wtg = #{putintoWtg},</if>
            <if test="putintoPower != null">putinto_power = #{putintoPower},</if>
            <if test="joinWtg != null">join_wtg = #{joinWtg},</if>
            <if test="joinPower != null">join_power = #{joinPower},</if>
            <if test="runWtg != null">run_wtg = #{runWtg},</if>
            <if test="stopWtg != null">stop_wtg = #{stopWtg},</if>
            <if test="procTime != null">proc_time = #{procTime},</if>
            <if test="procDayTime != null">proc_day_time = #{procDayTime},</if>
            <if test="procMonthTime != null">proc_month_time = #{procMonthTime},</if>
            <if test="name != null">name = #{name},</if>
            <if test="pathname != null">pathname = #{pathname},</if>
            <if test="aliasname != null">aliasname = #{aliasname},</if>
            <if test="description != null">description = #{description},</if>
        </trim>
        where area_no = #{areaNo}
    </update>

    <delete id="deleteAreaById" parameterType="Long">
        delete from area where area_no = #{areaNo}
    </delete>

</mapper>