<?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.project.plant.mapper.TMtdDailyMapper">

    <resultMap type="TMtdDaily" id="TMtdDailyResult">
        <result property="id"    column="id"    />
        <result property="recorder"    column="recorder"    />
        <result property="meetingNo"    column="meeting_no"    />
        <result property="meetingDate"    column="meeting_date"    />
        <result property="venue"    column="venue"    />
        <result property="subject"    column="subject"    />
        <result property="attendCracker"    column="attend_cracker"    />
        <result property="attendCtm"    column="attend_ctm"    />
        <result property="attendCta"    column="attend_cta"    />
        <result property="attendLab"    column="attend_lab"    />
        <result property="safetyTopic"    column="safety_topic"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createrCode"    column="creater_code"    />
        <result property="createdate"    column="createdate"    />
        <result property="updaterCode"    column="updater_code"    />
        <result property="updatedate"    column="updatedate"    />
        <result property="deptId"    column="dept_id"    />
        <result property="deptName" column="dept_name" />
        <result property="optMode"    column="opt_mode"    />
        <result property="optItem"    column="opt_item"    />
        <result property="split"    column="split"    />
        <result property="pgu"    column="pgu"    />
        <result property="aeu"    column="aeu"    />
        <result property="wordUrl"    column="word_url"    />
        <result property="emailStatus"    column="email_status"    />
    </resultMap>

    <sql id="selectTMtdDailyVo">
        select d.id, d.recorder, d.meeting_no, d.meeting_date, d.venue, d.subject, d.attend_cracker, d.attend_ctm
             , d.attend_cta, d.attend_lab, d.safety_topic, d.del_flag, d.creater_code, d.createdate, d.updater_code
             , d.updatedate, d.dept_id , d.opt_mode, d.opt_item, d.split, d.pgu, d.aeu,d.word_url ,email_status
             ,s.dept_name from t_mtd_daily d
      left join sys_dept s on s.dept_id = d.dept_id
    </sql>

    <select id="selectTMtdDailyList" parameterType="TMtdDaily" resultMap="TMtdDailyResult">
        <include refid="selectTMtdDailyVo"/>
        <where>
            <if test="recorder != null  and recorder != ''"> and recorder = #{recorder}</if>
            <if test="meetingNo != null  and meetingNo != ''"> and meeting_no = #{meetingNo}</if>
            <if test="meetingDate != null "> and meeting_date = #{meetingDate}</if>
            <if test="venue != null  and venue != ''"> and venue = #{venue}</if>
            <if test="subject != null  and subject != ''"> and subject = #{subject}</if>
            <if test="attendCracker != null  and attendCracker != ''"> and attend_cracker = #{attendCracker}</if>
            <if test="attendCtm != null  and attendCtm != ''"> and attend_ctm = #{attendCtm}</if>
            <if test="attendCta != null  and attendCta != ''"> and attend_cta = #{attendCta}</if>
            <if test="attendLab != null  and attendLab != ''"> and attend_lab = #{attendLab}</if>
            <if test="safetyTopic != null  and safetyTopic != ''"> and safety_topic = #{safetyTopic}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            and d.del_flag = 0
        </where>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
        order by d.meeting_date desc
    </select>

    <select id="selectTMtdDailyById" parameterType="Long" resultMap="TMtdDailyResult">
        <include refid="selectTMtdDailyVo"/>
        where id = #{id}
    </select>

    <select id="selectTMtdDailyLast" parameterType="TMtdDaily" resultMap="TMtdDailyResult">
        <include refid="selectTMtdDailyVo"/>
        where d.DEL_FLAG = 0
        ORDER BY d.id DESC
        FETCH FIRST 1 ROW ONLY
    </select>


    <insert id="insertTMtdDaily" parameterType="TMtdDaily">
        <selectKey keyProperty="id" resultType="long" order="BEFORE">
            SELECT seq_t_mtd_daily.NEXTVAL as id FROM DUAL
        </selectKey>
        insert into t_mtd_daily
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="recorder != null">recorder,</if>
            <if test="meetingNo != null">meeting_no,</if>
            <if test="meetingDate != null">meeting_date,</if>
            <if test="venue != null">venue,</if>
            <if test="subject != null">subject,</if>
            <if test="attendCracker != null">attend_cracker,</if>
            <if test="attendCtm != null">attend_ctm,</if>
            <if test="attendCta != null">attend_cta,</if>
            <if test="attendLab != null">attend_lab,</if>
            <if test="safetyTopic != null">safety_topic,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createrCode != null">creater_code,</if>
            <if test="createdate != null">createdate,</if>
            <if test="updaterCode != null">updater_code,</if>
            <if test="updatedate != null">updatedate,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="optMode != null">opt_mode,</if>
            <if test="optItem != null">opt_item,</if>
            <if test="split != null">split,</if>
            <if test="pgu != null">pgu,</if>
            <if test="aeu != null">aeu,</if>
            <if test="wordUrl != null">word_url,</if>
            <if test="emailStatus != null">email_status,</if>

         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="recorder != null">#{recorder},</if>
            <if test="meetingNo != null">#{meetingNo},</if>
            <if test="meetingDate != null">#{meetingDate},</if>
            <if test="venue != null">#{venue},</if>
            <if test="subject != null">#{subject},</if>
            <if test="attendCracker != null">#{attendCracker},</if>
            <if test="attendCtm != null">#{attendCtm},</if>
            <if test="attendCta != null">#{attendCta},</if>
            <if test="attendLab != null">#{attendLab},</if>
            <if test="safetyTopic != null">#{safetyTopic},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createrCode != null">#{createrCode},</if>
            <if test="createdate != null">#{createdate},</if>
            <if test="updaterCode != null">#{updaterCode},</if>
            <if test="updatedate != null">#{updatedate},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="optMode != null">#{optMode},</if>
            <if test="optItem != null">#{optItem},</if>
            <if test="split != null">#{split},</if>
            <if test="pgu != null">#{pgu},</if>
            <if test="aeu != null">#{aeu},</if>
            <if test="wordUrl != null">#{wordUrl},</if>
            <if test="emailStatus != null">#{emailStatus},</if>

         </trim>
    </insert>

    <update id="updateTMtdDaily" parameterType="TMtdDaily">
        update t_mtd_daily
        <trim prefix="SET" suffixOverrides=",">
            <if test="recorder != null">recorder = #{recorder},</if>
            <if test="meetingNo != null">meeting_no = #{meetingNo},</if>
            <if test="meetingDate != null">meeting_date = #{meetingDate},</if>
            <if test="venue != null">venue = #{venue},</if>
            <if test="subject != null">subject = #{subject},</if>
            <if test="attendCracker != null">attend_cracker = #{attendCracker},</if>
            <if test="attendCtm != null">attend_ctm = #{attendCtm},</if>
            <if test="attendCta != null">attend_cta = #{attendCta},</if>
            <if test="attendLab != null">attend_lab = #{attendLab},</if>
            <if test="safetyTopic != null">safety_topic = #{safetyTopic},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createrCode != null">creater_code = #{createrCode},</if>
            <if test="createdate != null">createdate = #{createdate},</if>
            <if test="updaterCode != null">updater_code = #{updaterCode},</if>
            <if test="updatedate != null">updatedate = #{updatedate},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="optMode != null">opt_mode = #{optMode},</if>
            <if test="optItem != null">opt_item = #{optItem},</if>
            <if test="split != null">split = #{split},</if>
            <if test="pgu != null">pgu = #{pgu},</if>
            <if test="aeu != null">aeu = #{aeu},</if>
            <if test="wordUrl != null">word_url = #{wordUrl},</if>
            <if test="emailStatus != null">email_status = #{emailStatus},</if>

        </trim>
        where id = #{id}
    </update>

    <update id="deleteTMtdDailyById" parameterType="Long">
        update t_mtd_daily set del_flag = 2 where id = #{id}
    </update>

    <update id="deleteTMtdDailyByIds" parameterType="String">
        update t_mtd_daily set del_flag = 2 where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>

</mapper>
