<?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.TMonthlyQualityReportS1301Mapper">
    
    <resultMap type="TMonthlyQualityReportS1301" id="TMonthlyQualityReportS1301Result">
        <result property="id"    column="id"    />
        <result property="locationName"    column="location_name"    />
        <result property="samplePoint"    column="sample_point"    />
        <result property="sampleDate"    column="sample_date"    />
        <result property="sampleName"    column="sample_name"    />
        <result property="na"    column="na"    />
        <result property="benzene"    column="benzene"    />
        <result property="toluene"    column="toluene"    />
        <result property="ethylbenzene"    column="ethylbenzene"    />
        <result property="pXylene"    column="p_xylene"    />
        <result property="mXylene"    column="m_xylene"    />
        <result property="oXylene"    column="o_xylene"    />
        <result property="styrene"    column="styrene"    />
        <result property="phenylacetylene"    column="phenylacetylene"    />
        <result property="totalAromatics"    column="total_aromatics"    />
        <result property="brNumber"    column="br_number"    />
        <result property="dieneValue"    column="diene_value"    />
        <result property="totalNitrogen"    column="total_nitrogen"    />
        <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="deptName" column="dept_name" />
        <result property="startDate" column="start_date" />
        <result property="endDate" column="end_date" />
        <result property="temperatureIn" column="temperature_in" />
        <result property="temperatureRaise" column="temperature_raise" />
    </resultMap>

    <sql id="selectTMonthlyQualityReportS1301Vo">
        select d.id, d.temperature_in, d.temperature_raise, d.location_name, d.sample_point, d.sample_date, d.sample_name, d.na, d.benzene, d.toluene, d.ethylbenzene, d.p_xylene, d.m_xylene, d.o_xylene, d.styrene, d.phenylacetylene, d.total_aromatics, d.br_number, d.diene_value, d.total_nitrogen, d.dept_id, d.del_flag, d.create_by, d.create_time, d.update_by, d.update_time ,s.dept_name from t_monthly_quality_report_s1301 d
      left join sys_dept s on s.dept_id = d.dept_id
    </sql>

    <select id="selectTMonthlyQualityReportS1301List" parameterType="TMonthlyQualityReportS1301" resultMap="TMonthlyQualityReportS1301Result">
        <include refid="selectTMonthlyQualityReportS1301Vo"/>
        <where>
            <if test="startDate != null "> and sample_date &gt;= #{startDate}</if>
            <if test="endDate != null "> and sample_date &lt;= #{endDate}</if>
            <if test="locationName != null  and locationName != ''"> and location_name like concat(concat('%', #{locationName}), '%')</if>
            <if test="samplePoint != null  and samplePoint != ''"> and sample_point = #{samplePoint}</if>
            <if test="sampleDate != null "> and sample_date = #{sampleDate}</if>
            <if test="sampleName != null  and sampleName != ''"> and sample_name like concat(concat('%', #{sampleName}), '%')</if>
            <if test="na != null  and na != ''"> and na = #{na}</if>
            <if test="benzene != null  and benzene != ''"> and benzene = #{benzene}</if>
            <if test="toluene != null  and toluene != ''"> and toluene = #{toluene}</if>
            <if test="ethylbenzene != null  and ethylbenzene != ''"> and ethylbenzene = #{ethylbenzene}</if>
            <if test="pXylene != null  and pXylene != ''"> and p_xylene = #{pXylene}</if>
            <if test="mXylene != null  and mXylene != ''"> and m_xylene = #{mXylene}</if>
            <if test="oXylene != null  and oXylene != ''"> and o_xylene = #{oXylene}</if>
            <if test="styrene != null  and styrene != ''"> and styrene = #{styrene}</if>
            <if test="phenylacetylene != null  and phenylacetylene != ''"> and phenylacetylene = #{phenylacetylene}</if>
            <if test="totalAromatics != null  and totalAromatics != ''"> and total_aromatics = #{totalAromatics}</if>
            <if test="brNumber != null  and brNumber != ''"> and br_number = #{brNumber}</if>
            <if test="dieneValue != null  and dieneValue != ''"> and diene_value = #{dieneValue}</if>
            <if test="totalNitrogen != null  and totalNitrogen != ''"> and total_nitrogen = #{totalNitrogen}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="temperatureIn != null "> and temperature_in = #{temperatureIn}</if>
            <if test="temperatureRaise != null "> and temperature_raise = #{temperatureRaise}</if>
            and d.del_flag = 0
        </where>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
    </select>
    
    <select id="selectTMonthlyQualityReportS1301ById" parameterType="Long" resultMap="TMonthlyQualityReportS1301Result">
        <include refid="selectTMonthlyQualityReportS1301Vo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTMonthlyQualityReportS1301" parameterType="TMonthlyQualityReportS1301">
        <selectKey keyProperty="id" resultType="long" order="BEFORE">
            SELECT seq_t_quality_report_s1301.NEXTVAL as id FROM DUAL
        </selectKey>
        insert into t_monthly_quality_report_s1301
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="locationName != null">location_name,</if>
            <if test="samplePoint != null">sample_point,</if>
            <if test="sampleDate != null">sample_date,</if>
            <if test="sampleName != null">sample_name,</if>
            <if test="na != null">na,</if>
            <if test="benzene != null">benzene,</if>
            <if test="toluene != null">toluene,</if>
            <if test="ethylbenzene != null">ethylbenzene,</if>
            <if test="pXylene != null">p_xylene,</if>
            <if test="mXylene != null">m_xylene,</if>
            <if test="oXylene != null">o_xylene,</if>
            <if test="styrene != null">styrene,</if>
            <if test="phenylacetylene != null">phenylacetylene,</if>
            <if test="totalAromatics != null">total_aromatics,</if>
            <if test="brNumber != null">br_number,</if>
            <if test="dieneValue != null">diene_value,</if>
            <if test="totalNitrogen != null">total_nitrogen,</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="temperatureIn != null">temperature_in,</if>
            <if test="temperatureRaise != null">temperature_raise,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="locationName != null">#{locationName},</if>
            <if test="samplePoint != null">#{samplePoint},</if>
            <if test="sampleDate != null">#{sampleDate},</if>
            <if test="sampleName != null">#{sampleName},</if>
            <if test="na != null">#{na},</if>
            <if test="benzene != null">#{benzene},</if>
            <if test="toluene != null">#{toluene},</if>
            <if test="ethylbenzene != null">#{ethylbenzene},</if>
            <if test="pXylene != null">#{pXylene},</if>
            <if test="mXylene != null">#{mXylene},</if>
            <if test="oXylene != null">#{oXylene},</if>
            <if test="styrene != null">#{styrene},</if>
            <if test="phenylacetylene != null">#{phenylacetylene},</if>
            <if test="totalAromatics != null">#{totalAromatics},</if>
            <if test="brNumber != null">#{brNumber},</if>
            <if test="dieneValue != null">#{dieneValue},</if>
            <if test="totalNitrogen != null">#{totalNitrogen},</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="temperatureIn != null">#{temperatureIn},</if>
            <if test="temperatureRaise != null">#{temperatureRaise},</if>
         </trim>
    </insert>

    <update id="updateTMonthlyQualityReportS1301" parameterType="TMonthlyQualityReportS1301">
        update t_monthly_quality_report_s1301
        <trim prefix="SET" suffixOverrides=",">
            <if test="locationName != null">location_name = #{locationName},</if>
            <if test="samplePoint != null">sample_point = #{samplePoint},</if>
            <if test="sampleDate != null">sample_date = #{sampleDate},</if>
            <if test="sampleName != null">sample_name = #{sampleName},</if>
            <if test="na != null">na = #{na},</if>
            <if test="benzene != null">benzene = #{benzene},</if>
            <if test="toluene != null">toluene = #{toluene},</if>
            <if test="ethylbenzene != null">ethylbenzene = #{ethylbenzene},</if>
            <if test="pXylene != null">p_xylene = #{pXylene},</if>
            <if test="mXylene != null">m_xylene = #{mXylene},</if>
            <if test="oXylene != null">o_xylene = #{oXylene},</if>
            <if test="styrene != null">styrene = #{styrene},</if>
            <if test="phenylacetylene != null">phenylacetylene = #{phenylacetylene},</if>
            <if test="totalAromatics != null">total_aromatics = #{totalAromatics},</if>
            <if test="brNumber != null">br_number = #{brNumber},</if>
            <if test="dieneValue != null">diene_value = #{dieneValue},</if>
            <if test="totalNitrogen != null">total_nitrogen = #{totalNitrogen},</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="temperatureIn != null">temperature_in = #{temperatureIn},</if>
            <if test="temperatureRaise != null">temperature_raise = #{temperatureRaise},</if>
        </trim>
        where id = #{id}
    </update>

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

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