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

    <resultMap type="TMtActionlist" id="TMtActionlistResult">
        <result property="id"    column="id"    />
        <result property="plantCode"    column="plant_code"    />
        <result property="responsible"    column="responsible"    />
        <result property="action"    column="action"    />
        <result property="deadline"    column="deadline"    />
        <result property="status"    column="status"    />
        <result property="inputdate"    column="inputdate"    />
        <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="remarks"    column="remarks"    />
        <result property="meetingId"    column="meeting_id"    />
        <result property="isHis"    column="is_his"    />
        <result property="deptName" column="dept_name" />
    </resultMap>

    <sql id="selectTMtActionlistVo">
        select d.id, d.plant_code, d.responsible, d.action, d.deadline, d.status, d.inputdate, d.del_flag, d.creater_code, d.createdate, d.updater_code, d.updatedate, d.dept_id, d.remarks, d.meeting_id, d.is_his ,s.dept_name from t_mt_actionlist d
      left join sys_dept s on s.dept_id = d.dept_id
    </sql>

    <select id="selectTMtActionlistList" parameterType="TMtActionlist" resultMap="TMtActionlistResult">
        <include refid="selectTMtActionlistVo"/>
        <where>
            <if test="responsible != null  and responsible != ''"> and responsible = #{responsible}</if>
            <if test="action != null  and action != ''"> and action = #{action}</if>
            <if test="deadline != null "> and deadline = #{deadline}</if>
            <if test="status != null  and status != ''"> and d.status = #{status}</if>
            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
            <if test="meetingId != null  and meetingId != ''"> and meeting_id = #{meetingId}</if>
            <if test="meetingId == null  or meetingId == ''"> and is_his = 0</if>
            and d.del_flag = 0
        </where>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
    </select>

    <select id="selectList" parameterType="TMtActionlist" resultMap="TMtActionlistResult">
        <include refid="selectTMtActionlistVo"/>
        <where>
            and d.del_flag = 0
        </where>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
    </select>

    <select id="selectTMtActionlistById" parameterType="Long" resultMap="TMtActionlistResult">
        <include refid="selectTMtActionlistVo"/>
        where id = #{id}
    </select>

    <insert id="insertTMtActionlist" parameterType="TMtActionlist">
        <selectKey keyProperty="id" resultType="long" order="BEFORE">
            SELECT seq_t_mt_actionlist.NEXTVAL as id FROM DUAL
        </selectKey>
        insert into t_mt_actionlist
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="plantCode != null and plantCode != ''">plant_code,</if>
            <if test="responsible != null">responsible,</if>
            <if test="action != null">action,</if>
            <if test="deadline != null">deadline,</if>
            <if test="status != null">status,</if>
            <if test="inputdate != null">inputdate,</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="remarks != null">remarks,</if>
            <if test="meetingId != null">meeting_id,</if>
            <if test="isHis != null">is_his,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="plantCode != null and plantCode != ''">#{plantCode},</if>
            <if test="responsible != null">#{responsible},</if>
            <if test="action != null">#{action},</if>
            <if test="deadline != null">#{deadline},</if>
            <if test="status != null">#{status},</if>
            <if test="inputdate != null">#{inputdate},</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="remarks != null">#{remarks},</if>
            <if test="meetingId != null">#{meetingId},</if>
            <if test="isHis != null">#{isHis},</if>
         </trim>
    </insert>

    <update id="updateTMtActionlist" parameterType="TMtActionlist">
        update t_mt_actionlist
        <trim prefix="SET" suffixOverrides=",">
            <if test="plantCode != null and plantCode != ''">plant_code = #{plantCode},</if>
            <if test="responsible != null">responsible = #{responsible},</if>
            <if test="action != null">action = #{action},</if>
            <if test="deadline != null">deadline = #{deadline},</if>
            <if test="status != null">status = #{status},</if>
            <if test="inputdate != null">inputdate = #{inputdate},</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="remarks != null">remarks = #{remarks},</if>
            <if test="meetingId != null">meeting_id = #{meetingId},</if>
            <if test="isHis != null">is_his = #{isHis},</if>
        </trim>
        where id = #{id}
    </update>

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

    <update id="deleteTMtActionlistByIds" parameterType="String">
        update t_mt_actionlist set del_flag = 2 where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>
    <select id="selectAcitonStatusData" resultType="com.ruoyi.project.common.domain.DataEntity">
        SELECT count(1) as dataNum,d.status as dataName FROM t_mt_actionlist d
        <where>
            and d.del_flag = 0
            <if test="meetingId != null  and meetingId != ''"> and meeting_id = #{meetingId}</if>
            <if test="meetingId == null  or meetingId == ''"> and is_his = 0</if>
        </where>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
        GROUP BY d.status
        order by dataName
    </select>

</mapper>
