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

    <resultMap type="TMeasureThickness" id="TMeasureThicknessResult">
        <result property="id"    column="id"    />
        <result property="plantCode"    column="plant_code"    />
        <result property="unitCode"    column="unit_code"    />
        <result property="tagno"    column="tagno"    />
        <result property="status"    column="status"    />
        <result property="createdate"    column="createdate"    />
        <result property="updaterCode"    column="updater_code"    />
        <result property="updatedate"    column="updatedate"    />
        <result property="deptId"    column="dept_id"    />
        <result property="remarks"    column="remarks"    />
        <result property="position"    column="position"    />
        <result property="recorder"    column="recorder"    />
        <result property="recorderDate"    column="recorder_date"    />
        <result property="equipmentName"    column="equipment_name"    />
        <result property="material"    column="material"    />
        <result property="corAllowance"    column="cor_allowance"    />
        <result property="originalThickness"    column="original_thickness"    />
        <result property="medium"    column="medium"    />
        <result property="pressure"    column="pressure"    />
        <result property="specification"    column="specification"    />
        <result property="flowRate"    column="flow_rate"    />
        <result property="temperature"    column="temperature"    />
        <result property="corrosionType"    column="corrosion_type"    />
        <result property="inspectionMethod"    column="inspection_method"    />
        <result property="photo"    column="photo"    />
        <result property="analysis"    column="analysis"    />
        <result property="nominalTickness"    column="nominal_tickness"    />
        <result property="thicknessMin"    column="thickness_min"    />
        <result property="stCorrosion"    column="st_corrosion"    />
        <result property="ltCorrosion"    column="lt_corrosion"    />
        <result property="estRemain"    column="est_remain"    />
        <result property="methodCause"    column="method_cause"    />
        <result property="effectTracing"    column="effect_tracing"    />
        <result property="raiser"    column="raiser"    />
        <result property="raiserDate"    column="raiser_date"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="locationUrl"    column="location_url"    />
        <result property="analysisUrl"    column="analysis_url"    />
        <result property="measureCycle"    column="measure_cycle"    />
        <result property="recordUrl"    column="record_url"    />
        <result property="otherContent"    column="other_content"    />
        <result property="measureNo"    column="measure_no"    />
        <result property="nextWarnDate"    column="next_warn_date"    />
        <result property="isSend"    column="is_send"    />
        <result property="deptName" column="dept_name" />
    </resultMap>

    <sql id="selectTMeasureThicknessVo">
        select d.id,d.next_warn_date, d.plant_code, d.unit_code, d.tagno, d.status, d.createdate, d.updater_code, d.updatedate, d.dept_id, d.remarks, d.position, d.recorder, d.recorder_date, d.equipment_name, d.material, d.cor_allowance, d.original_thickness, d.medium, d.pressure, d.specification, d.flow_rate, d.temperature, d.corrosion_type, d.inspection_method, d.photo, d.analysis, d.nominal_tickness, d.thickness_min, d.st_corrosion, d.lt_corrosion, d.est_remain, d.method_cause, d.effect_tracing, d.raiser, d.raiser_date, d.del_flag, d.location_url, d.analysis_url, d.measure_cycle, d.record_url, d.other_content ,d.measure_no, d.is_send,s.dept_name from t_measure_thickness d
      left join sys_dept s on s.dept_id = d.dept_id
    </sql>

    <select id="selectTMeasureThicknessList" parameterType="TMeasureThickness" resultMap="TMeasureThicknessResult">
        <include refid="selectTMeasureThicknessVo"/>
        <where>
            <if test="plantCode != null  and plantCode != ''"> and plant_code = #{plantCode}</if>
            <if test="unitCode != null  and unitCode != ''"> and unit_code = #{unitCode}</if>
            <if test="tagno != null  and tagno != ''"> and tagno = #{tagno}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
            <if test="position != null  and position != ''"> and position = #{position}</if>
            <if test="recorder != null  and recorder != ''"> and recorder = #{recorder}</if>
            <if test="recorderDate != null "> and recorder_date = #{recorderDate}</if>
            <if test="equipmentName != null  and equipmentName != ''"> and equipment_name like concat(concat('%', #{equipmentName}), '%')</if>
            <if test="material != null  and material != ''"> and material = #{material}</if>
            <if test="corAllowance != null  and corAllowance != ''"> and cor_allowance = #{corAllowance}</if>
            <if test="originalThickness != null  and originalThickness != ''"> and original_thickness = #{originalThickness}</if>
            <if test="medium != null  and medium != ''"> and medium = #{medium}</if>
            <if test="pressure != null  and pressure != ''"> and pressure = #{pressure}</if>
            <if test="specification != null  and specification != ''"> and specification = #{specification}</if>
            <if test="flowRate != null  and flowRate != ''"> and flow_rate = #{flowRate}</if>
            <if test="temperature != null  and temperature != ''"> and temperature = #{temperature}</if>
            <if test="corrosionType != null  and corrosionType != ''"> and corrosion_type = #{corrosionType}</if>
            <if test="inspectionMethod != null  and inspectionMethod != ''"> and inspection_method = #{inspectionMethod}</if>
            <if test="photo != null  and photo != ''"> and photo = #{photo}</if>
            <if test="analysis != null  and analysis != ''"> and analysis = #{analysis}</if>
            <if test="nominalTickness != null  and nominalTickness != ''"> and nominal_tickness = #{nominalTickness}</if>
            <if test="thicknessMin != null  and thicknessMin != ''"> and thickness_min = #{thicknessMin}</if>
            <if test="stCorrosion != null  and stCorrosion != ''"> and st_corrosion = #{stCorrosion}</if>
            <if test="ltCorrosion != null  and ltCorrosion != ''"> and lt_corrosion = #{ltCorrosion}</if>
            <if test="estRemain != null  and estRemain != ''"> and est_remain = #{estRemain}</if>
            <if test="methodCause != null  and methodCause != ''"> and method_cause = #{methodCause}</if>
            <if test="effectTracing != null  and effectTracing != ''"> and effect_tracing = #{effectTracing}</if>
            <if test="raiser != null  and raiser != ''"> and raiser = #{raiser}</if>
            <if test="raiserDate != null "> and raiser_date = #{raiserDate}</if>
            <if test="locationUrl != null  and locationUrl != ''"> and location_url = #{locationUrl}</if>
            <if test="analysisUrl != null  and analysisUrl != ''"> and analysis_url = #{analysisUrl}</if>
            <if test="measureCycle != null  and measureCycle != ''"> and measure_cycle = #{measureCycle}</if>
            <if test="recordUrl != null  and recordUrl != ''"> and record_url = #{recordUrl}</if>
            <if test="otherContent != null  and otherContent != ''"> and other_content = #{otherContent}</if>
            and d.del_flag = 0
        </where>
        <!-- 数据范围过滤 -->
        ${params.dataScopePlant}
    </select>

    <select id="selectTMeasureThicknessById" parameterType="Long" resultMap="TMeasureThicknessResult">
        <include refid="selectTMeasureThicknessVo"/>
        where id = #{id}
    </select>

    <select id="selectByTagNo" resultType="Long">
        select id from t_measure_thickness
            <where>
                del_flag = 0
                <if test="tagno != null  and tagno != ''"> and tagno = #{tagno}</if>
                <if test="position != null  and position != ''"> and position = #{position}</if>
            </where>

    </select>

    <select id="selectByRecord" resultType="Long" parameterType="TMeasureRecord">
        select id from t_measure_thickness
        <where>
            del_flag = 0
            <if test="plantCode != null  and plantCode != ''"> and plant_code = #{plantCode}</if>
            <if test="unitCode != null  and unitCode != ''"> and unit_code = #{unitCode}</if>
            <if test="tagno != null  and tagno != ''"> and tagno = #{tagno}</if>
            <if test="position != null  and position != ''"> and position = #{position}</if>
            <if test="measureNo != null  and measureNo != ''"> and measure_no = #{measureNo}</if>
        </where>

    </select>

    <insert id="insertTMeasureThickness" parameterType="TMeasureThickness">
        <selectKey keyProperty="id" resultType="long" order="BEFORE">
            SELECT seq_t_measure_thickness.NEXTVAL as id FROM DUAL
        </selectKey>
        insert into t_measure_thickness
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="plantCode != null and plantCode != ''">plant_code,</if>
            <if test="unitCode != null and unitCode != ''">unit_code,</if>
            <if test="tagno != null">tagno,</if>
            <if test="status != null">status,</if>
            <if test="createdate != null">createdate,</if>
            <if test="updaterCode != null">updater_code,</if>
            <if test="updatedate != null">updatedate,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="remarks != null">remarks,</if>
            <if test="position != null and position != ''">position,</if>
            <if test="recorder != null and recorder != ''">recorder,</if>
            <if test="recorderDate != null">recorder_date,</if>
            <if test="equipmentName != null and equipmentName != ''">equipment_name,</if>
            <if test="material != null and material != ''">material,</if>
            <if test="corAllowance != null and corAllowance != ''">cor_allowance,</if>
            <if test="originalThickness != null and originalThickness != ''">original_thickness,</if>
            <if test="medium != null and medium != ''">medium,</if>
            <if test="pressure != null and pressure != ''">pressure,</if>
            <if test="specification != null and specification != ''">specification,</if>
            <if test="flowRate != null and flowRate != ''">flow_rate,</if>
            <if test="temperature != null and temperature != ''">temperature,</if>
            <if test="corrosionType != null and corrosionType != ''">corrosion_type,</if>
            <if test="inspectionMethod != null and inspectionMethod != ''">inspection_method,</if>
            <if test="photo != null">photo,</if>
            <if test="analysis != null and analysis != ''">analysis,</if>
            <if test="nominalTickness != null and nominalTickness != ''">nominal_tickness,</if>
            <if test="thicknessMin != null and thicknessMin != ''">thickness_min,</if>
            <if test="stCorrosion != null and stCorrosion != ''">st_corrosion,</if>
            <if test="ltCorrosion != null and ltCorrosion != ''">lt_corrosion,</if>
            <if test="estRemain != null and estRemain != ''">est_remain,</if>
            <if test="methodCause != null and methodCause != ''">method_cause,</if>
            <if test="effectTracing != null and effectTracing != ''">effect_tracing,</if>
            <if test="raiser != null and raiser != ''">raiser,</if>
            <if test="raiserDate != null">raiser_date,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="locationUrl != null and locationUrl != ''">location_url,</if>
            <if test="analysisUrl != null">analysis_url,</if>
            <if test="measureCycle != null and measureCycle != ''">measure_cycle,</if>
            <if test="recordUrl != null">record_url,</if>
            <if test="otherContent != null and otherContent != ''">other_content,</if>
            <if test="measureNo != null">measure_no,</if>
            <if test="nextWarnDate != null">next_warn_date,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="plantCode != null and plantCode != ''">#{plantCode},</if>
            <if test="unitCode != null and unitCode != ''">#{unitCode},</if>
            <if test="tagno != null">#{tagno},</if>
            <if test="status != null">#{status},</if>
            <if test="createdate != null">#{createdate},</if>
            <if test="updaterCode != null">#{updaterCode},</if>
            <if test="updatedate != null">#{updatedate},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="remarks != null">#{remarks},</if>
            <if test="position != null and position != ''">#{position},</if>
            <if test="recorder != null and recorder != ''">#{recorder},</if>
            <if test="recorderDate != null">#{recorderDate},</if>
            <if test="equipmentName != null and equipmentName != ''">#{equipmentName},</if>
            <if test="material != null and material != ''">#{material},</if>
            <if test="corAllowance != null and corAllowance != ''">#{corAllowance},</if>
            <if test="originalThickness != null and originalThickness != ''">#{originalThickness},</if>
            <if test="medium != null and medium != ''">#{medium},</if>
            <if test="pressure != null and pressure != ''">#{pressure},</if>
            <if test="specification != null and specification != ''">#{specification},</if>
            <if test="flowRate != null and flowRate != ''">#{flowRate},</if>
            <if test="temperature != null and temperature != ''">#{temperature},</if>
            <if test="corrosionType != null and corrosionType != ''">#{corrosionType},</if>
            <if test="inspectionMethod != null and inspectionMethod != ''">#{inspectionMethod},</if>
            <if test="photo != null">#{photo},</if>
            <if test="analysis != null and analysis != ''">#{analysis},</if>
            <if test="nominalTickness != null and nominalTickness != ''">#{nominalTickness},</if>
            <if test="thicknessMin != null and thicknessMin != ''">#{thicknessMin},</if>
            <if test="stCorrosion != null and stCorrosion != ''">#{stCorrosion},</if>
            <if test="ltCorrosion != null and ltCorrosion != ''">#{ltCorrosion},</if>
            <if test="estRemain != null and estRemain != ''">#{estRemain},</if>
            <if test="methodCause != null and methodCause != ''">#{methodCause},</if>
            <if test="effectTracing != null and effectTracing != ''">#{effectTracing},</if>
            <if test="raiser != null and raiser != ''">#{raiser},</if>
            <if test="raiserDate != null">#{raiserDate},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="locationUrl != null and locationUrl != ''">#{locationUrl},</if>
            <if test="analysisUrl != null">#{analysisUrl},</if>
            <if test="measureCycle != null and measureCycle != ''">#{measureCycle},</if>
            <if test="recordUrl != null">#{recordUrl},</if>
            <if test="otherContent != null and otherContent != ''">#{otherContent},</if>
            <if test="measureNo != null">#{measureNo},</if>
            <if test="nextWarnDate != null">#{nextWarnDate},</if>
         </trim>
    </insert>

    <update id="updateTMeasureThickness" parameterType="TMeasureThickness">
        update t_measure_thickness
        <trim prefix="SET" suffixOverrides=",">
            <if test="plantCode != null and plantCode != ''">plant_code = #{plantCode},</if>
            <if test="unitCode != null and unitCode != ''">unit_code = #{unitCode},</if>
            <if test="tagno != null">tagno = #{tagno},</if>
            <if test="status != null">status = #{status},</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="deptId != null">dept_id = #{deptId},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
            <if test="position != null and position != ''">position = #{position},</if>
            <if test="recorder != null and recorder != ''">recorder = #{recorder},</if>
            <if test="recorderDate != null">recorder_date = #{recorderDate},</if>
            <if test="equipmentName != null and equipmentName != ''">equipment_name = #{equipmentName},</if>
            <if test="material != null and material != ''">material = #{material},</if>
            <if test="corAllowance != null and corAllowance != ''">cor_allowance = #{corAllowance},</if>
            <if test="originalThickness != null and originalThickness != ''">original_thickness = #{originalThickness},</if>
            <if test="medium != null and medium != ''">medium = #{medium},</if>
            <if test="pressure != null and pressure != ''">pressure = #{pressure},</if>
            <if test="specification != null and specification != ''">specification = #{specification},</if>
            <if test="flowRate != null and flowRate != ''">flow_rate = #{flowRate},</if>
            <if test="temperature != null and temperature != ''">temperature = #{temperature},</if>
            <if test="corrosionType != null and corrosionType != ''">corrosion_type = #{corrosionType},</if>
            <if test="inspectionMethod != null and inspectionMethod != ''">inspection_method = #{inspectionMethod},</if>
            <if test="photo != null">photo = #{photo},</if>
            <if test="analysis != null and analysis != ''">analysis = #{analysis},</if>
            <if test="nominalTickness != null and nominalTickness != ''">nominal_tickness = #{nominalTickness},</if>
            <if test="thicknessMin != null and thicknessMin != ''">thickness_min = #{thicknessMin},</if>
            <if test="stCorrosion != null and stCorrosion != ''">st_corrosion = #{stCorrosion},</if>
            <if test="ltCorrosion != null and ltCorrosion != ''">lt_corrosion = #{ltCorrosion},</if>
            <if test="estRemain != null and estRemain != ''">est_remain = #{estRemain},</if>
            <if test="methodCause != null and methodCause != ''">method_cause = #{methodCause},</if>
            <if test="effectTracing != null and effectTracing != ''">effect_tracing = #{effectTracing},</if>
            <if test="raiser != null and raiser != ''">raiser = #{raiser},</if>
            <if test="raiserDate != null">raiser_date = #{raiserDate},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="locationUrl != null and locationUrl != ''">location_url = #{locationUrl},</if>
            <if test="analysisUrl != null">analysis_url = #{analysisUrl},</if>
            <if test="measureCycle != null and measureCycle != ''">measure_cycle = #{measureCycle},</if>
            <if test="recordUrl != null">record_url = #{recordUrl},</if>
            <if test="otherContent != null and otherContent != ''">other_content = #{otherContent},</if>
            <if test="measureNo != null">measure_no = #{measureNo},</if>
            <if test="nextWarnDate != null">next_warn_date = #{nextWarnDate},</if>
            <if test="isSend != null">is_send = #{isSend},</if>
            </trim>
        where id = #{id}
    </update>

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

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

</mapper>
