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

    <resultMap type="NwpFileTime" id="NwpFileTimeResult">
        <result property="windplantNo" column="windplant_no"/>
        <result property="nwpNo" column="nwp_no"/>
        <result property="fileDbRecTimeAm" column="file_db_rec_time_am"/>
        <result property="fileDbRecTimePm" column="file_db_rec_time_pm"/>
        <result property="procTimeAm" column="proc_time_am"/>
        <result property="procTimePm" column="proc_time_pm"/>
    </resultMap>

    <sql id="selectNwpFileTimeVo">
        select windplant_no, nwp_no, file_db_rec_time_am, file_db_rec_time_pm, proc_time_am, proc_time_pm from nwp_file_time
    </sql>

    <select id="selectNwpFileTimeList" parameterType="NwpFileTime" resultMap="NwpFileTimeResult">
        select
        nft.*,
        w.name as "windplantName",
        emi.item_name as "nwpNoName"
        from
        nwp_file_time nft
        left join windplant w on w.windplant_no = nft.windplant_no
        left join enum_menu_item emi on emi.item_val = nft.nwp_no and emi.menu_no = 119
        <where>
            <if test="windplantNo != null ">and nft.windplant_no = #{windplantNo}</if>
            <if test="nwpNo != null ">and nft.nwp_no = #{nwpNo}</if>
            <if test="fileDbRecTimeAm != null ">and nft.file_db_rec_time_am = #{fileDbRecTimeAm}</if>
            <if test="fileDbRecTimePm != null ">and nft.file_db_rec_time_pm = #{fileDbRecTimePm}</if>
            <if test="procTimeAm != null ">and nft.proc_time_am = #{procTimeAm}</if>
            <if test="procTimePm != null ">and nft.proc_time_pm = #{procTimePm}</if>
            <if test="windplantName != null  and windplantName != ''">and w.name like concat(concat('%',
                #{windplantName}), '%')
            </if>
        </where>
        order by nft.windplant_no asc
    </select>

    <select id="selectNwpFileTimeById" parameterType="Long" resultMap="NwpFileTimeResult">
        <include refid="selectNwpFileTimeVo"/>
        where windplant_no = #{windplantNo}
    </select>

</mapper>