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

    <resultMap type="TReportHiYlrq" id="TReportHiYlrqResult">
        <result property="id"    column="id"    />
        <result property="reportId"    column="report_id"    />
        <result property="plantCode"    column="plant_code"    />
        <result property="unit"    column="unit"    />
        <result property="devno"    column="devno"    />
        <result property="devname"    column="devname"    />
        <result property="useno"    column="useno"    />
        <result property="regno"    column="regno"    />
        <result property="medium"    column="medium"    />
        <result property="desPressure"    column="des_pressure"    />
        <result property="desTemp"    column="des_temp"    />
        <result property="optPressure"    column="opt_pressure"    />
        <result property="optTemp"    column="opt_temp"    />
        <result property="safeClass"    column="safe_class"    />
        <result property="nextWarnDate"    column="next_warn_date"    />
        <result property="yearReportNo"    column="year_report_no"    />
        <result property="pj1"    column="pj1"    />
        <result property="pj2"    column="pj2"    />
        <result property="pj3"    column="pj3"    />
        <result property="pj4"    column="pj4"    />
        <result property="pj5"    column="pj5"    />
        <result property="pj6"    column="pj6"    />
        <result property="pj7"    column="pj7"    />
        <result property="pj8"    column="pj8"    />
        <result property="pj9"    column="pj9"    />
        <result property="pj10"    column="pj10"    />
        <result property="pj11"    column="pj11"    />
        <result property="pj12"    column="pj12"    />
        <result property="pj13"    column="pj13"    />
        <result property="pj14"    column="pj14"    />
        <result property="pj15"    column="pj15"    />
        <result property="pj16"    column="pj16"    />
        <result property="pj17"    column="pj17"    />
        <result property="pj18"    column="pj18"    />
        <result property="pj19"    column="pj19"    />
        <result property="pj20"    column="pj20"    />
        <result property="pj21"    column="pj21"    />
        <result property="pj22"    column="pj22"    />
        <result property="pj23"    column="pj23"    />
        <result property="pj24"    column="pj24"    />
        <result property="pj25"    column="pj25"    />
        <result property="pj26"    column="pj26"    />
        <result property="pj27"    column="pj27"    />
        <result property="pj28"    column="pj28"    />
        <result property="pj29"    column="pj29"    />
        <result property="pj30"    column="pj30"    />
        <result property="pj31"    column="pj31"    />
        <result property="pj32"    column="pj32"    />
        <result property="remarks"    column="remarks"    />
        <result property="checkDate"    column="check_date"    />
        <result property="nextCheckDate"    column="next_check_date"    />
        <result property="problem"    column="problem"    />
        <result property="con"    column="con"    />
        <result property="buildDate"    column="build_date"    />
        <result property="approveId"    column="approve_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="reportUrl"    column="report_url"    />
    </resultMap>

    <sql id="selectTReportHiYlrqVo">
        select d.id, d.report_id, d.plant_code,d.report_url, d.unit, d.devno, d.devname, d.useno, d.regno, d.medium, d.des_pressure, d.des_temp, d.opt_pressure, d.opt_temp, d.safe_class, d.next_warn_date, d.year_report_no, d.pj1, d.pj2, d.pj3, d.pj4, d.pj5, d.pj6, d.pj7, d.pj8, d.pj9, d.pj10, d.pj11, d.pj12, d.pj13, d.pj14, d.pj15, d.pj16, d.pj17, d.pj18, d.pj19, d.pj20, d.pj21, d.pj22, d.pj23, d.pj24, d.pj25, d.pj26, d.pj27, d.pj28, d.pj29, d.pj30, d.pj31, d.pj32, d.remarks, d.check_date, d.next_check_date, d.problem, d.con, d.build_date, d.approve_id, d.del_flag, d.creater_code, d.createdate, d.updater_code, d.updatedate from t_report_hi_ylrq d
    </sql>

    <select id="selectTReportHiYlrqList" parameterType="TReportHiYlrq" resultMap="TReportHiYlrqResult">
        <include refid="selectTReportHiYlrqVo"/>
        <where>
            <if test="reportId != null "> and report_id = #{reportId}</if>
            and d.del_flag = 0
        </where>
        <!-- 数据范围过滤 -->
        ${params.dataScopePlant}
    </select>

    <select id="selectTReportHiYlrqById" parameterType="Long" resultMap="TReportHiYlrqResult">
        <include refid="selectTReportHiYlrqVo"/>
        where id = #{id}
    </select>

    <select id="selectTReportHiYlrqForYear" parameterType="String" resultMap="TReportHiYlrqResult">
        <include refid="selectTReportHiYlrqVo"/>
        where TO_CHAR(check_date,'yyyy') = #{params.year}
        and d.del_flag = 0
        <!-- 数据范围过滤 -->
        ${params.dataScopePlant}
    </select>

    <insert id="insertTReportHiYlrq" parameterType="TReportHiYlrq">
        <selectKey keyProperty="id" resultType="long" order="BEFORE">
            SELECT seq_t_report_hi_ylrq.NEXTVAL as id FROM DUAL
        </selectKey>
        insert into t_report_hi_ylrq
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="reportId != null">report_id,</if>
            <if test="plantCode != null">plant_code,</if>
            <if test="unit != null">unit,</if>
            <if test="devno != null">devno,</if>
            <if test="devname != null">devname,</if>
            <if test="useno != null">useno,</if>
            <if test="regno != null">regno,</if>
            <if test="medium != null">medium,</if>
            <if test="desPressure != null">des_pressure,</if>
            <if test="desTemp != null">des_temp,</if>
            <if test="optPressure != null">opt_pressure,</if>
            <if test="optTemp != null">opt_temp,</if>
            <if test="safeClass != null">safe_class,</if>
            <if test="nextWarnDate != null">next_warn_date,</if>
            <if test="yearReportNo != null">year_report_no,</if>
            <if test="pj1 != null">pj1,</if>
            <if test="pj2 != null">pj2,</if>
            <if test="pj3 != null">pj3,</if>
            <if test="pj4 != null">pj4,</if>
            <if test="pj5 != null">pj5,</if>
            <if test="pj6 != null">pj6,</if>
            <if test="pj7 != null">pj7,</if>
            <if test="pj8 != null">pj8,</if>
            <if test="pj9 != null">pj9,</if>
            <if test="pj10 != null">pj10,</if>
            <if test="pj11 != null">pj11,</if>
            <if test="pj12 != null">pj12,</if>
            <if test="pj13 != null">pj13,</if>
            <if test="pj14 != null">pj14,</if>
            <if test="pj15 != null">pj15,</if>
            <if test="pj16 != null">pj16,</if>
            <if test="pj17 != null">pj17,</if>
            <if test="pj18 != null">pj18,</if>
            <if test="pj19 != null">pj19,</if>
            <if test="pj20 != null">pj20,</if>
            <if test="pj21 != null">pj21,</if>
            <if test="pj22 != null">pj22,</if>
            <if test="pj23 != null">pj23,</if>
            <if test="pj24 != null">pj24,</if>
            <if test="pj25 != null">pj25,</if>
            <if test="pj26 != null">pj26,</if>
            <if test="pj27 != null">pj27,</if>
            <if test="pj28 != null">pj28,</if>
            <if test="pj29 != null">pj29,</if>
            <if test="pj30 != null">pj30,</if>
            <if test="pj31 != null">pj31,</if>
            <if test="pj32 != null">pj32,</if>
            <if test="remarks != null">remarks,</if>
            <if test="checkDate != null">check_date,</if>
            <if test="nextCheckDate != null">next_check_date,</if>
            <if test="problem != null">problem,</if>
            <if test="con != null">con,</if>
            <if test="buildDate != null">build_date,</if>
            <if test="approveId != null">approve_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>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="reportId != null">#{reportId},</if>
            <if test="plantCode != null">#{plantCode},</if>
            <if test="unit != null">#{unit},</if>
            <if test="devno != null">#{devno},</if>
            <if test="devname != null">#{devname},</if>
            <if test="useno != null">#{useno},</if>
            <if test="regno != null">#{regno},</if>
            <if test="medium != null">#{medium},</if>
            <if test="desPressure != null">#{desPressure},</if>
            <if test="desTemp != null">#{desTemp},</if>
            <if test="optPressure != null">#{optPressure},</if>
            <if test="optTemp != null">#{optTemp},</if>
            <if test="safeClass != null">#{safeClass},</if>
            <if test="nextWarnDate != null">#{nextWarnDate},</if>
            <if test="yearReportNo != null">#{yearReportNo},</if>
            <if test="pj1 != null">#{pj1},</if>
            <if test="pj2 != null">#{pj2},</if>
            <if test="pj3 != null">#{pj3},</if>
            <if test="pj4 != null">#{pj4},</if>
            <if test="pj5 != null">#{pj5},</if>
            <if test="pj6 != null">#{pj6},</if>
            <if test="pj7 != null">#{pj7},</if>
            <if test="pj8 != null">#{pj8},</if>
            <if test="pj9 != null">#{pj9},</if>
            <if test="pj10 != null">#{pj10},</if>
            <if test="pj11 != null">#{pj11},</if>
            <if test="pj12 != null">#{pj12},</if>
            <if test="pj13 != null">#{pj13},</if>
            <if test="pj14 != null">#{pj14},</if>
            <if test="pj15 != null">#{pj15},</if>
            <if test="pj16 != null">#{pj16},</if>
            <if test="pj17 != null">#{pj17},</if>
            <if test="pj18 != null">#{pj18},</if>
            <if test="pj19 != null">#{pj19},</if>
            <if test="pj20 != null">#{pj20},</if>
            <if test="pj21 != null">#{pj21},</if>
            <if test="pj22 != null">#{pj22},</if>
            <if test="pj23 != null">#{pj23},</if>
            <if test="pj24 != null">#{pj24},</if>
            <if test="pj25 != null">#{pj25},</if>
            <if test="pj26 != null">#{pj26},</if>
            <if test="pj27 != null">#{pj27},</if>
            <if test="pj28 != null">#{pj28},</if>
            <if test="pj29 != null">#{pj29},</if>
            <if test="pj30 != null">#{pj30},</if>
            <if test="pj31 != null">#{pj31},</if>
            <if test="pj32 != null">#{pj32},</if>
            <if test="remarks != null">#{remarks},</if>
            <if test="checkDate != null">#{checkDate},</if>
            <if test="nextCheckDate != null">#{nextCheckDate},</if>
            <if test="problem != null">#{problem},</if>
            <if test="con != null">#{con},</if>
            <if test="buildDate != null">#{buildDate},</if>
            <if test="approveId != null">#{approveId},</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>
         </trim>
    </insert>

    <update id="updateTReportHiYlrq" parameterType="TReportHiYlrq">
        update t_report_hi_ylrq
        <trim prefix="SET" suffixOverrides=",">
            <if test="reportId != null">report_id = #{reportId},</if>
            <if test="plantCode != null">plant_code = #{plantCode},</if>
            <if test="unit != null">unit = #{unit},</if>
            <if test="devno != null">devno = #{devno},</if>
            <if test="devname != null">devname = #{devname},</if>
            <if test="useno != null">useno = #{useno},</if>
            <if test="regno != null">regno = #{regno},</if>
            <if test="medium != null">medium = #{medium},</if>
            <if test="desPressure != null">des_pressure = #{desPressure},</if>
            <if test="desTemp != null">des_temp = #{desTemp},</if>
            <if test="optPressure != null">opt_pressure = #{optPressure},</if>
            <if test="optTemp != null">opt_temp = #{optTemp},</if>
            <if test="safeClass != null">safe_class = #{safeClass},</if>
            <if test="nextWarnDate != null">next_warn_date = #{nextWarnDate},</if>
            <if test="yearReportNo != null">year_report_no = #{yearReportNo},</if>
            <if test="pj1 != null">pj1 = #{pj1},</if>
            <if test="pj2 != null">pj2 = #{pj2},</if>
            <if test="pj3 != null">pj3 = #{pj3},</if>
            <if test="pj4 != null">pj4 = #{pj4},</if>
            <if test="pj5 != null">pj5 = #{pj5},</if>
            <if test="pj6 != null">pj6 = #{pj6},</if>
            <if test="pj7 != null">pj7 = #{pj7},</if>
            <if test="pj8 != null">pj8 = #{pj8},</if>
            <if test="pj9 != null">pj9 = #{pj9},</if>
            <if test="pj10 != null">pj10 = #{pj10},</if>
            <if test="pj11 != null">pj11 = #{pj11},</if>
            <if test="pj12 != null">pj12 = #{pj12},</if>
            <if test="pj13 != null">pj13 = #{pj13},</if>
            <if test="pj14 != null">pj14 = #{pj14},</if>
            <if test="pj15 != null">pj15 = #{pj15},</if>
            <if test="pj16 != null">pj16 = #{pj16},</if>
            <if test="pj17 != null">pj17 = #{pj17},</if>
            <if test="pj18 != null">pj18 = #{pj18},</if>
            <if test="pj19 != null">pj19 = #{pj19},</if>
            <if test="pj20 != null">pj20 = #{pj20},</if>
            <if test="pj21 != null">pj21 = #{pj21},</if>
            <if test="pj22 != null">pj22 = #{pj22},</if>
            <if test="pj23 != null">pj23 = #{pj23},</if>
            <if test="pj24 != null">pj24 = #{pj24},</if>
            <if test="pj25 != null">pj25 = #{pj25},</if>
            <if test="pj26 != null">pj26 = #{pj26},</if>
            <if test="pj27 != null">pj27 = #{pj27},</if>
            <if test="pj28 != null">pj28 = #{pj28},</if>
            <if test="pj29 != null">pj29 = #{pj29},</if>
            <if test="pj30 != null">pj30 = #{pj30},</if>
            <if test="pj31 != null">pj31 = #{pj31},</if>
            <if test="pj32 != null">pj32 = #{pj32},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
            <if test="checkDate != null">check_date = #{checkDate},</if>
            <if test="nextCheckDate != null">next_check_date = #{nextCheckDate},</if>
            <if test="problem != null">problem = #{problem},</if>
            <if test="con != null">con = #{con},</if>
            <if test="buildDate != null">build_date = #{buildDate},</if>
            <if test="approveId != null">approve_id = #{approveId},</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="reportUrl != null">report_url = #{reportUrl},</if>
        </trim>
        where id = #{id}
    </update>

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

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

</mapper>
