<?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.production.mapper.TFurnancePressureMapper">
    
    <resultMap type="TFurnancePressure" id="TFurnancePressureResult">
        <result property="id"    column="id"    />
        <result property="furnanceName"    column="furnance_name"    />
        <result property="recordTime"    column="record_time"    />
        <result property="pass1"    column="pass1"    />
        <result property="pass2"    column="pass2"    />
        <result property="pass3"    column="pass3"    />
        <result property="pass4"    column="pass4"    />
        <result property="pass5"    column="pass5"    />
        <result property="pass6"    column="pass6"    />
        <result property="pass7"    column="pass7"    />
        <result property="pass8"    column="pass8"    />
        <result property="pass9"    column="pass9"    />
        <result property="pass10"    column="pass10"    />
        <result property="pass11"    column="pass11"    />
        <result property="pass12"    column="pass12"    />
        <result property="pass13"    column="pass13"    />
        <result property="pass14"    column="pass14"    />
        <result property="pass15"    column="pass15"    />
        <result property="pass16"    column="pass16"    />
        <result property="deptId"    column="dept_id"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="status"    column="status"    />
        <result property="team"    column="team"    />
        <result property="photoUrl"    column="photo_url"    />
        <result property="recorder"    column="recorder"    />
        <result property="startDate"    column="start_date"    />
        <result property="endDate"    column="end_date"    />
    </resultMap>

    <sql id="selectTFurnancePressureVo">
        select d.id, d.recorder, d.team, d.photo_url, d.status, d.furnance_name, d.record_time, d.pass1, d.pass2, d.pass3, d.pass4, d.pass5, d.pass6, d.pass7, d.pass8, d.pass9, d.pass10, d.pass11, d.pass12, d.pass13, d.pass14, d.pass15, d.pass16, d.dept_id, d.del_flag, d.create_by, d.create_time, d.update_by, d.update_time from t_furnance_pressure d
      left join sys_dept s on s.dept_id = d.dept_id
    </sql>

    <select id="selectTFurnancePressureList" parameterType="TFurnancePressure" resultMap="TFurnancePressureResult">
        <include refid="selectTFurnancePressureVo"/>
        <where>  
            <if test="furnanceName != null  and furnanceName != ''"> and furnance_name = #{furnanceName}</if>
            <if test="recordTime != null ">
                and extract (year from record_time) = extract (year from #{recordTime})
                and extract (month from record_time) = extract (month from #{recordTime})
            </if>
            <if test="pass1 != null  and pass1 != ''"> and pass1 = #{pass1}</if>
            <if test="pass2 != null  and pass2 != ''"> and pass2 = #{pass2}</if>
            <if test="pass3 != null  and pass3 != ''"> and pass3 = #{pass3}</if>
            <if test="pass4 != null  and pass4 != ''"> and pass4 = #{pass4}</if>
            <if test="pass5 != null  and pass5 != ''"> and pass5 = #{pass5}</if>
            <if test="pass6 != null  and pass6 != ''"> and pass6 = #{pass6}</if>
            <if test="pass7 != null  and pass7 != ''"> and pass7 = #{pass7}</if>
            <if test="pass8 != null  and pass8 != ''"> and pass8 = #{pass8}</if>
            <if test="pass9 != null  and pass9 != ''"> and pass9 = #{pass9}</if>
            <if test="pass10 != null  and pass10 != ''"> and pass10 = #{pass10}</if>
            <if test="pass11 != null  and pass11 != ''"> and pass11 = #{pass11}</if>
            <if test="pass12 != null  and pass12 != ''"> and pass12 = #{pass12}</if>
            <if test="pass13 != null  and pass13 != ''"> and pass13 = #{pass13}</if>
            <if test="pass14 != null  and pass14 != ''"> and pass14 = #{pass14}</if>
            <if test="pass15 != null  and pass15 != ''"> and pass15 = #{pass15}</if>
            <if test="pass16 != null  and pass16 != ''"> and pass16 = #{pass16}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="team != null "> and team = #{team}</if>
            <if test="photoUrl != null "> and photo_url = #{photoUrl}</if>
            <if test="recorder != null and recorder != 0"> and recorder = #{recorder}</if>
            and d.del_flag = 0
        </where>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
        order by record_time asc
    </select>

    <select id="selectTFurnancePressureAnalysis" parameterType="TFurnancePressure" resultMap="TFurnancePressureResult">
        <include refid="selectTFurnancePressureVo"/>
        <where>
            and furnance_name = #{furnanceName}
            and RECORD_TIME &gt;= #{startDate}
            and RECORD_TIME &lt; #{endDate}
            and d.del_flag = 0
        </where>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
        order by record_time asc
    </select>

    <select id="selectTFurnancePressureByDate" parameterType="TFurnancePressure" resultMap="TFurnancePressureResult">
        <include refid="selectTFurnancePressureVo"/>
        <where>
            <if test="furnanceName != null  and furnanceName != ''"> and furnance_name = #{furnanceName}</if>
            <if test="recordTime != null "> and trunc(record_time, 'dd') = #{recordTime}</if>
            and d.del_flag = 0
        </where>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
    </select>
    
    <select id="selectTFurnancePressureById" parameterType="Long" resultMap="TFurnancePressureResult">
        <include refid="selectTFurnancePressureVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTFurnancePressure" parameterType="TFurnancePressure">
        <selectKey keyProperty="id" resultType="long" order="BEFORE">
            SELECT seq_t_furnance_pressure.NEXTVAL as id FROM DUAL
        </selectKey>
        insert into t_furnance_pressure
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="furnanceName != null">furnance_name,</if>
            <if test="recordTime != null">record_time,</if>
            <if test="pass1 != null">pass1,</if>
            <if test="pass2 != null">pass2,</if>
            <if test="pass3 != null">pass3,</if>
            <if test="pass4 != null">pass4,</if>
            <if test="pass5 != null">pass5,</if>
            <if test="pass6 != null">pass6,</if>
            <if test="pass7 != null">pass7,</if>
            <if test="pass8 != null">pass8,</if>
            <if test="pass9 != null">pass9,</if>
            <if test="pass10 != null">pass10,</if>
            <if test="pass11 != null">pass11,</if>
            <if test="pass12 != null">pass12,</if>
            <if test="pass13 != null">pass13,</if>
            <if test="pass14 != null">pass14,</if>
            <if test="pass15 != null">pass15,</if>
            <if test="pass16 != null">pass16,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="status != null">status,</if>
            <if test="team != null">team,</if>
            <if test="photoUrl != null">photo_url,</if>
            <if test="recorder != null and recorder != 0">recorder,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="furnanceName != null">#{furnanceName},</if>
            <if test="recordTime != null">#{recordTime},</if>
            <if test="pass1 != null">#{pass1},</if>
            <if test="pass2 != null">#{pass2},</if>
            <if test="pass3 != null">#{pass3},</if>
            <if test="pass4 != null">#{pass4},</if>
            <if test="pass5 != null">#{pass5},</if>
            <if test="pass6 != null">#{pass6},</if>
            <if test="pass7 != null">#{pass7},</if>
            <if test="pass8 != null">#{pass8},</if>
            <if test="pass9 != null">#{pass9},</if>
            <if test="pass10 != null">#{pass10},</if>
            <if test="pass11 != null">#{pass11},</if>
            <if test="pass12 != null">#{pass12},</if>
            <if test="pass13 != null">#{pass13},</if>
            <if test="pass14 != null">#{pass14},</if>
            <if test="pass15 != null">#{pass15},</if>
            <if test="pass16 != null">#{pass16},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="status != null">#{status},</if>
            <if test="team != null">#{team},</if>
            <if test="photoUrl != null">#{photoUrl},</if>
            <if test="recorder != null and recorder != 0">#{recorder},</if>
         </trim>
    </insert>

    <update id="updateTFurnancePressure" parameterType="TFurnancePressure">
        update t_furnance_pressure
        <trim prefix="SET" suffixOverrides=",">
            <if test="furnanceName != null">furnance_name = #{furnanceName},</if>
            <if test="recordTime != null">record_time = #{recordTime},</if>
            <if test="pass1 != null">pass1 = #{pass1},</if>
            <if test="pass2 != null">pass2 = #{pass2},</if>
            <if test="pass3 != null">pass3 = #{pass3},</if>
            <if test="pass4 != null">pass4 = #{pass4},</if>
            <if test="pass5 != null">pass5 = #{pass5},</if>
            <if test="pass6 != null">pass6 = #{pass6},</if>
            <if test="pass7 != null">pass7 = #{pass7},</if>
            <if test="pass8 != null">pass8 = #{pass8},</if>
            <if test="pass9 != null">pass9 = #{pass9},</if>
            <if test="pass10 != null">pass10 = #{pass10},</if>
            <if test="pass11 != null">pass11 = #{pass11},</if>
            <if test="pass12 != null">pass12 = #{pass12},</if>
            <if test="pass13 != null">pass13 = #{pass13},</if>
            <if test="pass14 != null">pass14 = #{pass14},</if>
            <if test="pass15 != null">pass15 = #{pass15},</if>
            <if test="pass16 != null">pass16 = #{pass16},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="status != null">status = #{status},</if>
            <if test="team != null">team = #{team},</if>
            <if test="photoUrl != null">photo_url = #{photoUrl},</if>
            <if test="recorder != null and recorder != 0">recorder = #{recorder},</if>
        </trim>
        where id = #{id}
    </update>

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

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