<?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.TMonthlyQualityReportS6301Mapper">
    
    <resultMap type="TMonthlyQualityReportS6301" id="TMonthlyQualityReportS6301Result">
        <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="ic5"    column="ic5"    />
        <result property="dcpd"    column="dcpd"    />
        <result property="c5"    column="c5"    />
        <result property="c5ConjugatedDienesDcpd30"    column="c5_conjugated_dienes_dcpd_30"    />
        <result property="pentadieneCycc5"    column="pentadiene_cycc5"    />
        <result property="c5ConjugatedDienesDcpd40"    column="c5_conjugated_dienes_dcpd_40"    />
        <result property="totalSulfur"    column="total_sulfur"    />
        <result property="silicon"    column="silicon"    />
        <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="totalSulfur150" column="total_sulfur150" />
        <result property="c4" column="c4" />
        <result property="c410" column="c410" />
        <result property="c250" column="c250" />
    </resultMap>

    <sql id="selectTMonthlyQualityReportS6301Vo">
        select d.id, d.c4, d.c410, d.c250, d.total_sulfur150, d.location_name, d.sample_point, d.sample_date, d.sample_name, d.ic5, d.dcpd, d.c5, d.c5_conjugated_dienes_dcpd_30, d.pentadiene_cycc5, d.c5_conjugated_dienes_dcpd_40, d.total_sulfur, d.silicon, 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_s6301 d
      left join sys_dept s on s.dept_id = d.dept_id
    </sql>

    <select id="selectTMonthlyQualityReportS6301List" parameterType="TMonthlyQualityReportS6301" resultMap="TMonthlyQualityReportS6301Result">
        <include refid="selectTMonthlyQualityReportS6301Vo"/>
        <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="ic5 != null  and ic5 != ''"> and ic5 = #{ic5}</if>
            <if test="dcpd != null  and dcpd != ''"> and dcpd = #{dcpd}</if>
            <if test="c5 != null  and c5 != ''"> and c5 = #{c5}</if>
            <if test="c5ConjugatedDienesDcpd30 != null  and c5ConjugatedDienesDcpd30 != ''"> and c5_conjugated_dienes_dcpd_30 = #{c5ConjugatedDienesDcpd30}</if>
            <if test="pentadieneCycc5 != null  and pentadieneCycc5 != ''"> and pentadiene_cycc5 = #{pentadieneCycc5}</if>
            <if test="c5ConjugatedDienesDcpd40 != null  and c5ConjugatedDienesDcpd40 != ''"> and c5_conjugated_dienes_dcpd_40 = #{c5ConjugatedDienesDcpd40}</if>
            <if test="totalSulfur != null  and totalSulfur != ''"> and total_sulfur = #{totalSulfur}</if>
            <if test="silicon != null  and silicon != ''"> and silicon = #{silicon}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="totalSulfur150 != null "> and total_sulfur150 = #{totalSulfur150}</if>
            <if test="c4 != null "> and c4 = #{c4}</if>
            <if test="c410 != null "> and c410 = #{c410}</if>
            <if test="c250 != null "> and c250 = #{c250}</if>
            and d.del_flag = 0
        </where>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
    </select>
    
    <select id="selectTMonthlyQualityReportS6301ById" parameterType="Long" resultMap="TMonthlyQualityReportS6301Result">
        <include refid="selectTMonthlyQualityReportS6301Vo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTMonthlyQualityReportS6301" parameterType="TMonthlyQualityReportS6301">
        <selectKey keyProperty="id" resultType="long" order="BEFORE">
            SELECT seq_t_quality_report_s6301.NEXTVAL as id FROM DUAL
        </selectKey>
        insert into t_monthly_quality_report_s6301
        <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="ic5 != null">ic5,</if>
            <if test="dcpd != null">dcpd,</if>
            <if test="c5 != null">c5,</if>
            <if test="c5ConjugatedDienesDcpd30 != null">c5_conjugated_dienes_dcpd_30,</if>
            <if test="pentadieneCycc5 != null">pentadiene_cycc5,</if>
            <if test="c5ConjugatedDienesDcpd40 != null">c5_conjugated_dienes_dcpd_40,</if>
            <if test="totalSulfur != null">total_sulfur,</if>
            <if test="silicon != null">silicon,</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="totalSulfur150 != null">total_sulfur150,</if>
            <if test="c4 != null">c4,</if>
            <if test="c410 != null">c410,</if>
            <if test="c250 != null">c250,</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="ic5 != null">#{ic5},</if>
            <if test="dcpd != null">#{dcpd},</if>
            <if test="c5 != null">#{c5},</if>
            <if test="c5ConjugatedDienesDcpd30 != null">#{c5ConjugatedDienesDcpd30},</if>
            <if test="pentadieneCycc5 != null">#{pentadieneCycc5},</if>
            <if test="c5ConjugatedDienesDcpd40 != null">#{c5ConjugatedDienesDcpd40},</if>
            <if test="totalSulfur != null">#{totalSulfur},</if>
            <if test="silicon != null">#{silicon},</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="totalSulfur150 != null">#{totalSulfur150},</if>
            <if test="c4 != null">#{c4},</if>
            <if test="c410 != null">#{c410},</if>
            <if test="c250 != null">#{c250},</if>
         </trim>
    </insert>

    <update id="updateTMonthlyQualityReportS6301" parameterType="TMonthlyQualityReportS6301">
        update t_monthly_quality_report_s6301
        <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="ic5 != null">ic5 = #{ic5},</if>
            <if test="dcpd != null">dcpd = #{dcpd},</if>
            <if test="c5 != null">c5 = #{c5},</if>
            <if test="c5ConjugatedDienesDcpd30 != null">c5_conjugated_dienes_dcpd_30 = #{c5ConjugatedDienesDcpd30},</if>
            <if test="pentadieneCycc5 != null">pentadiene_cycc5 = #{pentadieneCycc5},</if>
            <if test="c5ConjugatedDienesDcpd40 != null">c5_conjugated_dienes_dcpd_40 = #{c5ConjugatedDienesDcpd40},</if>
            <if test="totalSulfur != null">total_sulfur = #{totalSulfur},</if>
            <if test="silicon != null">silicon = #{silicon},</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="totalSulfur150 != null">total_sulfur150 = #{totalSulfur150},</if>
            <if test="c4 != null">c4 = #{c4},</if>
            <if test="c410 != null">c410 = #{c410},</if>
            <if test="c250 != null">c250 = #{c250},</if>
        </trim>
        where id = #{id}
    </update>

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

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