<?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.sems.mapper.TSpecCheckMapper">

    <resultMap type="TSpecCheck" id="TSpecCheckResult">
        <result property="id"    column="id"    />
        <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="checkUnit"    column="check_unit"    />
        <result property="warnDate"    column="warn_date"    />
        <result property="nextWarnDate"    column="next_warn_date"    />
        <result property="reportNo"    column="report_no"    />
        <result property="yearWarnDate"    column="year_warn_date"    />
        <result property="checkConclusion"    column="check_conclusion"    />
        <result property="yearNextWarnDate"    column="year_next_warn_date"    />
        <result property="yearReportNo"    column="year_report_no"    />
        <result property="outWarnDate"    column="out_warn_date"    />
        <result property="outNextWarnDate"    column="out_next_warn_date"    />
        <result property="outCheckConclusion"    column="out_check_conclusion"    />
        <result property="outReportNo"    column="out_report_no"    />
        <result property="devId"    column="dev_id"    />
        <result property="devType"    column="dev_type"    />
        <result property="safeClass"    column="safe_class"    />
    </resultMap>

    <sql id="selectTSpecCheckVo">
        select d.id, d.del_flag, d.creater_code, d.createdate, d.updater_code, d.updatedate, d.check_unit, d.warn_date, d.next_warn_date, d.report_no, d.year_warn_date, d.check_conclusion, d.year_next_warn_date, d.year_report_no, d.out_warn_date, d.out_next_warn_date, d.out_check_conclusion, d.out_report_no, d.dev_type, d.safe_class from t_spec_check d
    </sql>

    <select id="selectTSpecCheckList" parameterType="TSpecCheck" resultMap="TSpecCheckResult">
        <include refid="selectTSpecCheckVo"/>
        <where>
            <if test="createrCode != null "> and creater_code = #{createrCode}</if>
            <if test="createdate != null "> and createdate = #{createdate}</if>
            <if test="updaterCode != null "> and updater_code = #{updaterCode}</if>
            <if test="updatedate != null "> and updatedate = #{updatedate}</if>
            <if test="checkUnit != null  and checkUnit != ''"> and check_unit = #{checkUnit}</if>
            <if test="warnDate != null "> and warn_date = #{warnDate}</if>
            <if test="nextWarnDate != null "> and next_warn_date = #{nextWarnDate}</if>
            <if test="reportNo != null  and reportNo != ''"> and report_no = #{reportNo}</if>
            <if test="yearWarnDate != null "> and year_warn_date = #{yearWarnDate}</if>
            <if test="checkConclusion != null  and checkConclusion != ''"> and check_conclusion = #{checkConclusion}</if>
            <if test="yearNextWarnDate != null "> and year_next_warn_date = #{yearNextWarnDate}</if>
            <if test="yearReportNo != null  and yearReportNo != ''"> and year_report_no = #{yearReportNo}</if>
            <if test="outWarnDate != null "> and out_warn_date = #{outWarnDate}</if>
            <if test="outNextWarnDate != null "> and out_next_warn_date = #{outNextWarnDate}</if>
            <if test="outCheckConclusion != null  and outCheckConclusion != ''"> and out_check_conclusion = #{outCheckConclusion}</if>
            <if test="outReportNo != null  and outReportNo != ''"> and out_report_no = #{outReportNo}</if>
            <if test="devId != null "> and dev_id = #{devId}</if>
            <if test="devType != null "> and dev_type = #{devType}</if>
            <if test="safeClass != null  and safeClass != ''"> and safe_class = #{safeClass}</if>
            and d.del_flag = 0
        </where>
        <!-- 数据范围过滤 -->
    </select>

    <select id="selectTSpecCheckById" parameterType="Long" resultMap="TSpecCheckResult">
        <include refid="selectTSpecCheckVo"/>
        where id = #{id}
    </select>

    <insert id="insertTSpecCheck" parameterType="TSpecCheck">
        <selectKey keyProperty="id" resultType="long" order="BEFORE">
            SELECT seq_t_spec_check.NEXTVAL as id FROM DUAL
        </selectKey>
        insert into t_spec_check
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</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="checkUnit != null">check_unit,</if>
            <if test="warnDate != null">warn_date,</if>
            <if test="nextWarnDate != null">next_warn_date,</if>
            <if test="reportNo != null">report_no,</if>
            <if test="yearWarnDate != null">year_warn_date,</if>
            <if test="checkConclusion != null">check_conclusion,</if>
            <if test="yearNextWarnDate != null">year_next_warn_date,</if>
            <if test="yearReportNo != null">year_report_no,</if>
            <if test="outWarnDate != null">out_warn_date,</if>
            <if test="outNextWarnDate != null">out_next_warn_date,</if>
            <if test="outCheckConclusion != null">out_check_conclusion,</if>
            <if test="outReportNo != null">out_report_no,</if>
            <if test="devId != null">dev_id,</if>
            <if test="devType != null">dev_type,</if>
            <if test="safeClass != null">safe_class,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</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="checkUnit != null">#{checkUnit},</if>
            <if test="warnDate != null">#{warnDate},</if>
            <if test="nextWarnDate != null">#{nextWarnDate},</if>
            <if test="reportNo != null">#{reportNo},</if>
            <if test="yearWarnDate != null">#{yearWarnDate},</if>
            <if test="checkConclusion != null">#{checkConclusion},</if>
            <if test="yearNextWarnDate != null">#{yearNextWarnDate},</if>
            <if test="yearReportNo != null">#{yearReportNo},</if>
            <if test="outWarnDate != null">#{outWarnDate},</if>
            <if test="outNextWarnDate != null">#{outNextWarnDate},</if>
            <if test="outCheckConclusion != null">#{outCheckConclusion},</if>
            <if test="outReportNo != null">#{outReportNo},</if>
            <if test="devId != null">#{devId},</if>
            <if test="devType != null">#{devType},</if>
            <if test="safeClass != null">#{safeClass},</if>
         </trim>
    </insert>

    <update id="updateTSpecCheck" parameterType="TSpecCheck">
        update t_spec_check
        <trim prefix="SET" suffixOverrides=",">
            <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="checkUnit != null">check_unit = #{checkUnit},</if>
            <if test="warnDate != null">warn_date = #{warnDate},</if>
            <if test="nextWarnDate != null">next_warn_date = #{nextWarnDate},</if>
            <if test="reportNo != null">report_no = #{reportNo},</if>
            <if test="yearWarnDate != null">year_warn_date = #{yearWarnDate},</if>
            <if test="checkConclusion != null">check_conclusion = #{checkConclusion},</if>
            <if test="yearNextWarnDate != null">year_next_warn_date = #{yearNextWarnDate},</if>
            <if test="yearReportNo != null">year_report_no = #{yearReportNo},</if>
            <if test="outWarnDate != null">out_warn_date = #{outWarnDate},</if>
            <if test="outNextWarnDate != null">out_next_warn_date = #{outNextWarnDate},</if>
            <if test="outCheckConclusion != null">out_check_conclusion = #{outCheckConclusion},</if>
            <if test="outReportNo != null">out_report_no = #{outReportNo},</if>
            <if test="devId != null">dev_id = #{devId},</if>
            <if test="devType != null">dev_type = #{devType},</if>
            <if test="safeClass != null">safe_class = #{safeClass},</if>
        </trim>
        where id = #{id}
    </update>

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

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

</mapper>
