<?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.ems.mapper.AdmOpInspectionReportMapper">

    <resultMap type="com.ruoyi.ems.domain.AdmOpInspectionReport" id="AdmOpInspectionReportResult">
        <result property="id"    column="id"    />
        <result property="taskCode"    column="task_code"    />
        <result property="resultStatus"    column="result_status"    />
        <result property="resultMsg"    column="result_msg"    />
        <result property="finishTime"    column="finish_time"    />
        <result property="subTime"    column="sub_time"    />
        <result property="submitter"    column="submitter"    />
    </resultMap>

    <sql id="selectAdmOpInspectionReportVo">
        select id, task_code, result_status, result_msg, finish_time, sub_time, submitter from adm_op_inspection_report
    </sql>

    <select id="selectAdmOpInspectionReportList" parameterType="com.ruoyi.ems.domain.AdmOpInspectionReport" resultMap="AdmOpInspectionReportResult">
        <include refid="selectAdmOpInspectionReportVo"/>
        <where>
            <if test="taskCode != null  and taskCode != ''"> and task_code = #{taskCode}</if>
            <if test="resultStatus != null "> and result_status = #{resultStatus}</if>
            <if test="submitter != null  and submitter != ''"> and submitter like concat('%', #{submitter}, '%')</if>
        </where>
    </select>

    <select id="selectAdmOpInspectionReportById" parameterType="Long" resultMap="AdmOpInspectionReportResult">
        <include refid="selectAdmOpInspectionReportVo"/>
        where id = #{id}
    </select>

    <insert id="insertAdmOpInspectionReport" parameterType="com.ruoyi.ems.domain.AdmOpInspectionReport" useGeneratedKeys="true" keyProperty="id">
        insert into adm_op_inspection_report
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="taskCode != null and taskCode != ''">task_code,</if>
            <if test="resultStatus != null">result_status,</if>
            <if test="resultMsg != null">result_msg,</if>
            <if test="finishTime != null">finish_time,</if>
            <if test="subTime != null">sub_time,</if>
            <if test="submitter != null">submitter,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="taskCode != null and taskCode != ''">#{taskCode},</if>
            <if test="resultStatus != null">#{resultStatus},</if>
            <if test="resultMsg != null">#{resultMsg},</if>
            <if test="finishTime != null">#{finishTime},</if>
            <if test="subTime != null">#{subTime},</if>
            <if test="submitter != null">#{submitter},</if>
         </trim>
    </insert>

    <update id="updateAdmOpInspectionReport" parameterType="com.ruoyi.ems.domain.AdmOpInspectionReport">
        update adm_op_inspection_report
        <trim prefix="SET" suffixOverrides=",">
            <if test="taskCode != null and taskCode != ''">task_code = #{taskCode},</if>
            <if test="resultStatus != null">result_status = #{resultStatus},</if>
            <if test="resultMsg != null">result_msg = #{resultMsg},</if>
            <if test="finishTime != null">finish_time = #{finishTime},</if>
            <if test="subTime != null">sub_time = #{subTime},</if>
            <if test="submitter != null">submitter = #{submitter},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAdmOpInspectionReportById" parameterType="Long">
        delete from adm_op_inspection_report where id = #{id}
    </delete>

    <delete id="deleteAdmOpInspectionReportByIds" parameterType="String">
        delete from adm_op_inspection_report where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>
