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

    <resultMap type="TSpecdevYlgd" id="TSpecdevYlgdResult">
        <result property="id" column="id"/>
        <result property="plantCode" column="plant_code"/>
        <result property="unit" column="unit"/>
        <result property="devname" column="devname"/>
        <result property="devno" column="devno"/>
        <result property="submitdate" column="submitdate"/>
        <result property="status" column="status"/>
        <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="deptId" column="dept_id"/>
        <result property="remarks" column="remarks"/>
        <result property="approveStatus" column="approve_status"/>
        <result property="regno" column="regno"/>
        <result property="useno" column="useno"/>
        <result property="warnDate" column="warn_date"/>
        <result property="warnCycle" column="warn_cycle"/>
        <result property="nextWarnDate" column="next_warn_date"/>
        <result property="warnFlag" column="warn_flag"/>
        <result property="grade" column="grade"/>
        <result property="designer" column="designer"/>
        <result property="installer" column="installer"/>
        <result property="material" column="material"/>
        <result property="dia" column="dia"/>
        <result property="scheduleNo" column="schedule_no"/>
        <result property="length" column="length"/>
        <result property="starting" column="starting"/>
        <result property="ending" column="ending"/>
        <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="medium" column="medium"/>
        <result property="checkConclusion" column="check_conclusion"/>
        <result property="checkUnit" column="check_unit"/>
        <result property="safeClass" column="safe_class"/>
        <result property="reportNo" column="report_no"/>
        <result property="approveTime" column="approve_time"/>
        <result property="changeTime" column="change_time"/>
        <result property="plantMaint" column="plant_maint"/>
        <result property="engineer" column="engineer"/>
        <result property="weldNumber" column="weld_number"/>
        <result property="layingMethod" column="laying_method"/>
        <result property="adiabatic" column="adiabatic"/>
        <result property="antiCorrosion" column="anti_corrosion"/>
        <result property="adiabaticThickness" column="adiabatic_thickness"/>
        <result property="isDanger" column="is_danger"/>
        <result property="installDate" column="install_date"/>
        <result property="yearWarnDate" column="year_warn_date"/>
        <result property="yearNextWarnDate" column="year_next_warn_date"/>
        <result property="yearReportNo" column="year_report_no"/>
        <result property="deptName" column="dept_name"/>
        <result property="hiFlag" column="hiFlag"/>
        <result property="isRepeat" column="is_repeat"/>
    </resultMap>

    <sql id="selectTSpecdevYlgdVo">
        select d.id,
               d.plant_code,
               d.unit,
               d.devname,
               d.devno,
               d.submitdate,
               d.status,
               d.del_flag,
               d.creater_code,
               d.createdate,
               d.updater_code,
               d.updatedate,
               d.dept_id,
               d.remarks,
               d.approve_status,
               d.regno,
               d.useno,
               d.warn_date,
               d.warn_cycle,
               d.next_warn_date,
               d.warn_flag,
               d.grade,
               d.designer,
               d.installer,
               d.material,
               d.dia,
               d.schedule_no,
               d.length,
               d.starting,
               d.ending,
               d.des_pressure,
               d.des_temp,
               d.opt_pressure,
               d.opt_temp,
               d.medium,
               d.check_conclusion,
               d.check_unit,
               d.safe_class,
               d.report_no,
               d.approve_time,
               d.change_time,
               d.plant_maint,
               d.engineer,
               d.weld_number,
               d.laying_method,
               d.adiabatic,
               d.anti_corrosion,
               d.adiabatic_thickness,
               d.is_danger,
               d.install_date,
               d.year_warn_date,
               d.year_next_warn_date,
               d.year_report_no,
               s.dept_name,
               (SELECT COUNT(1) from T_SPECHI_YLGD h  where h.DEV_ID = d.id and HI_TYPE = 0 ) as hiFlag,
               d.is_repeat
        from t_specdev_ylgd d
                 left join sys_dept s on s.dept_id = d.dept_id
    </sql>

    <select id="selectTSpecdevYlgdList" parameterType="TSpecdevYlgd" resultMap="TSpecdevYlgdResult">
        <include refid="selectTSpecdevYlgdVo"/>
        <where>
            <if test="plantCode != null  and plantCode != ''">and plant_code like concat(concat('%', #{plantCode}), '%') </if>
            <if test="unit != null  and unit != ''">and unit like concat(concat('%', #{unit}), '%') </if>
            <if test="devname != null  and devname != ''">and devname like concat(concat('%', #{devname}), '%')</if>
            <if test="devno != null  and devno != ''">and devno like concat(concat('%', #{devno}), '%') </if>
            <if test="submitdate != null ">and submitdate = #{submitdate}</if>
            <if test="material != null  and material != ''">and material like concat(concat('%', #{material}), '%') </if>
            <if test="dia != null  and dia != ''">and dia like concat(concat('%', #{dia}), '%') </if>
            <if test="scheduleNo != null  and scheduleNo != ''">and schedule_no like concat(concat('%', #{scheduleNo}), '%') </if>
            <if test="length != null  and length != ''">and length like concat(concat('%', #{length}), '%') </if>
            <if test="starting != null  and starting != ''">and starting like concat(concat('%', #{starting}), '%') </if>
            <if test="ending != null  and ending != ''">and ending like concat(concat('%', #{ending}), '%') </if>
            <if test="desPressure != null  and desPressure != ''">and des_pressure = #{desPressure}</if>
            <if test="desTemp != null  and desTemp != ''">and des_temp = #{desTemp}</if>
            <if test="optPressure != null  and optPressure != ''">and opt_pressure = #{optPressure}</if>
            <if test="optTemp != null  and optTemp != ''">and opt_temp = #{optTemp}</if>
            <if test="medium != null  and medium != ''">and medium = #{medium}</if>
            <if test="checkConclusion != null ">and check_conclusion = #{checkConclusion}</if>
            <if test="checkUnit != null  and checkUnit != ''">and check_unit = #{checkUnit}</if>
            <if test="safeClass != null  and safeClass != ''">and safe_class = #{safeClass}</if>
            <if test="reportNo != null  and reportNo != ''">and report_no = #{reportNo}</if>
            <if test="approveTime != null ">and approve_time = #{approveTime}</if>
            <if test="changeTime != null ">and change_time = #{changeTime}</if>
            <if test="plantMaint != null  and plantMaint != ''">and plant_maint = #{plantMaint}</if>
            <if test="engineer != null  and engineer != ''">and engineer = #{engineer}</if>
            <if test="weldNumber != null  and weldNumber != ''">and weld_number = #{weldNumber}</if>
            <if test="layingMethod != null  and layingMethod != ''">and laying_method = #{layingMethod}</if>
            <if test="adiabatic != null  and adiabatic != ''">and adiabatic = #{adiabatic}</if>
            <if test="antiCorrosion != null  and antiCorrosion != ''">and anti_corrosion = #{antiCorrosion}</if>
            <if test="adiabaticThickness != null  and adiabaticThickness != ''">and adiabatic_thickness =
                #{adiabaticThickness}
            </if>
            <if test="isDanger != null ">and is_danger = #{isDanger}</if>
            <if test="status != null ">and d.status = #{status}</if>
            <if test="approveStatus != null ">and approve_status = #{approveStatus}</if>
            <if test="warnFlag != null ">and warn_Flag = #{warnFlag}</if>
            <if test="searchValue != null  and searchValue != ''">
                and
                (plant_code like concat(concat('%', #{searchValue}), '%')
                or unit like concat(concat('%', #{searchValue}), '%')
                or devname like concat(concat('%', #{searchValue}), '%')
                or material like concat(concat('%', #{searchValue}), '%')
                or devno like concat(concat('%', #{searchValue}), '%')
                or dia like concat(concat('%', #{searchValue}), '%')
                or schedule_no like concat(concat('%', #{searchValue}), '%')
                or length like concat(concat('%', #{searchValue}), '%')
                or starting like concat(concat('%', #{searchValue}), '%')
                or ending like concat(concat('%', #{searchValue}), '%')
                or des_pressure like concat(concat('%', #{searchValue}), '%')
                or des_temp like concat(concat('%', #{searchValue}), '%')
                or opt_pressure like concat(concat('%', #{searchValue}), '%')
                or opt_temp like concat(concat('%', #{searchValue}), '%')
                )
            </if>
            <if test="isRepeat != null  and isRepeat != ''">
                <if test="isRepeat == 2 ">
                    and  (d.DEVNO,d.USENO, d.PLANT_CODE, d.DEL_FLAG, d.APPROVE_STATUS) IN (
                    SELECT DEVNO,USENO, PLANT_CODE, DEL_FLAG, APPROVE_STATUS
                    FROM T_SPECDEV_DZSB
                    WHERE DEL_FLAG = 0 AND APPROVE_STATUS = 0
                    GROUP BY DEVNO,USENO, PLANT_CODE, DEL_FLAG, APPROVE_STATUS
                    HAVING COUNT(*) > 1
                    )
                </if>
            </if>
            and d.del_flag = 0
        </where>
        <!-- 数据范围过滤 -->
        ${params.dataScopePlant}
        order by d.is_repeat desc, d.plant_code, d.unit, d.id
    </select>


    <select id="selectTSpecdevYlgdListByYear" parameterType="TSpecdevYlgd" resultMap="TSpecdevYlgdResult">
        <include refid="selectTSpecdevYlgdVo"/>
        <where>
            <if test="status != null ">and d.status = #{status}</if>
            <if test="checkYear != null ">and to_char(NEXT_WARN_DATE,'yyyy') = #{checkYear}</if>
            <if test="plantIds != null  and plantIds != ''">
                and
                d.plant_code in
                <foreach collection="plantIds.split(',')" item="item" index="index"
                         open="(" close=")" separator=",">
                    #{item}
                </foreach>
            </if>
            <!--<if test="unitIds != null  and unitIds != ''">
                and
                (
                d.unit in
                <foreach collection="unitIds.split(',')" item="item" index="index"
                         open="(" close=")" separator=",">
                    #{item}
                </foreach>
                )
            </if>-->
            and d.del_flag = 0
        </where>
    </select>

    <select id="selectTSpecdevYlgdById" parameterType="Long" resultMap="TSpecdevYlgdResult">
        <include refid="selectTSpecdevYlgdVo"/>
        where id = #{id}
    </select>

    <select id="selectTSpecdevYlgdByIds" parameterType="Long" resultMap="TSpecdevYlgdResult">
        <include refid="selectTSpecdevYlgdVo"/>
        where id in
        <foreach collection="ids" open="(" close=")" item="id" index="index">
            <if test="index != 0">
                <choose>
                    <when test="index % 1000 == 999">) OR id in (</when>
                    <otherwise>,</otherwise>
                </choose>
            </if>
            #{id}
        </foreach>
    </select>


    <insert id="insertTSpecdevYlgd" parameterType="TSpecdevYlgd">
        <selectKey keyProperty="id" resultType="long" order="BEFORE">
            SELECT seq_t_specdev_ylrq.NEXTVAL as id FROM DUAL
        </selectKey>
        insert into t_specdev_ylgd
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="plantCode != null">plant_code,</if>
            <if test="unit != null">unit,</if>
            <if test="devname != null">devname,</if>
            <if test="devno != null">devno,</if>
            <if test="submitdate != null">submitdate,</if>
            <if test="status != null">status,</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>
            <if test="deptId != null">dept_id,</if>
            <if test="remarks != null">remarks,</if>
            <if test="approveStatus != null">approve_status,</if>
            <if test="regno != null">regno,</if>
            <if test="useno != null">useno,</if>
            <if test="warnDate != null">warn_date,</if>
            <if test="warnCycle != null">warn_cycle,</if>
            <if test="nextWarnDate != null">next_warn_date,</if>
            <if test="warnFlag != null">warn_flag,</if>
            <if test="grade != null">grade,</if>
            <if test="designer != null">designer,</if>
            <if test="installer != null">installer,</if>
            <if test="material != null">material,</if>
            <if test="dia != null">dia,</if>
            <if test="scheduleNo != null">schedule_no,</if>
            <if test="length != null">length,</if>
            <if test="starting != null">starting,</if>
            <if test="ending != null">ending,</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="medium != null">medium,</if>
            <if test="checkConclusion != null">check_conclusion,</if>
            <if test="checkUnit != null">check_unit,</if>
            <if test="safeClass != null">safe_class,</if>
            <if test="reportNo != null">report_no,</if>
            <if test="approveTime != null">approve_time,</if>
            <if test="changeTime != null">change_time,</if>
            <if test="plantMaint != null">plant_maint,</if>
            <if test="engineer != null">engineer,</if>
            <if test="weldNumber != null">weld_number,</if>
            <if test="layingMethod != null">laying_method,</if>
            <if test="adiabatic != null">adiabatic,</if>
            <if test="antiCorrosion != null">anti_corrosion,</if>
            <if test="adiabaticThickness != null">adiabatic_thickness,</if>
            <if test="isDanger != null">is_danger,</if>
            <if test="installDate != null">install_date,</if>
            <if test="yearWarnDate != null">year_warn_date,</if>
            <if test="yearNextWarnDate != null">year_next_warn_date,</if>
            <if test="yearReportNo != null">year_report_no,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="plantCode != null">#{plantCode},</if>
            <if test="unit != null">#{unit},</if>
            <if test="devname != null">#{devname},</if>
            <if test="devno != null">#{devno},</if>
            <if test="submitdate != null">#{submitdate},</if>
            <if test="status != null">#{status},</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>
            <if test="deptId != null">#{deptId},</if>
            <if test="remarks != null">#{remarks},</if>
            <if test="approveStatus != null">#{approveStatus},</if>
            <if test="regno != null">#{regno},</if>
            <if test="useno != null">#{useno},</if>
            <if test="warnDate != null">#{warnDate},</if>
            <if test="warnCycle != null">#{warnCycle},</if>
            <if test="nextWarnDate != null">#{nextWarnDate},</if>
            <if test="warnFlag != null">#{warnFlag},</if>
            <if test="grade != null">#{grade},</if>
            <if test="designer != null">#{designer},</if>
            <if test="installer != null">#{installer},</if>
            <if test="material != null">#{material},</if>
            <if test="dia != null">#{dia},</if>
            <if test="scheduleNo != null">#{scheduleNo},</if>
            <if test="length != null">#{length},</if>
            <if test="starting != null">#{starting},</if>
            <if test="ending != null">#{ending},</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="medium != null">#{medium},</if>
            <if test="checkConclusion != null">#{checkConclusion},</if>
            <if test="checkUnit != null">#{checkUnit},</if>
            <if test="safeClass != null">#{safeClass},</if>
            <if test="reportNo != null">#{reportNo},</if>
            <if test="approveTime != null">#{approveTime},</if>
            <if test="changeTime != null">#{changeTime},</if>
            <if test="plantMaint != null">#{plantMaint},</if>
            <if test="engineer != null">#{engineer},</if>
            <if test="weldNumber != null">#{weldNumber},</if>
            <if test="layingMethod != null">#{layingMethod},</if>
            <if test="adiabatic != null">#{adiabatic},</if>
            <if test="antiCorrosion != null">#{antiCorrosion},</if>
            <if test="adiabaticThickness != null">#{adiabaticThickness},</if>
            <if test="isDanger != null">#{isDanger},</if>
            <if test="installDate != null">#{installDate},</if>
            <if test="yearWarnDate != null">#{yearWarnDate},</if>
            <if test="yearNextWarnDate != null">#{yearNextWarnDate},</if>
            <if test="yearReportNo != null">#{yearReportNo},</if>
        </trim>
    </insert>

    <update id="updateTSpecdevYlgd" parameterType="TSpecdevYlgd">
        update t_specdev_ylgd
        <trim prefix="SET" suffixOverrides=",">
            <if test="plantCode != null">plant_code = #{plantCode},</if>
            <if test="unit != null">unit = #{unit},</if>
            <if test="devname != null">devname = #{devname},</if>
            <if test="devno != null">devno = #{devno},</if>
            <if test="submitdate != null">submitdate = #{submitdate},</if>
            <if test="status != null">status = #{status},</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="deptId != null">dept_id = #{deptId},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
            <if test="approveStatus != null">approve_status = #{approveStatus},</if>
            <if test="regno != null">regno = #{regno},</if>
            <if test="useno != null">useno = #{useno},</if>
            <if test="warnDate != null">warn_date = #{warnDate},</if>
            <if test="warnCycle != null">warn_cycle = #{warnCycle},</if>
            <if test="nextWarnDate != null">next_warn_date = #{nextWarnDate},</if>
            <if test="warnFlag != null">warn_flag = #{warnFlag},</if>
            <if test="grade != null">grade = #{grade},</if>
            <if test="designer != null">designer = #{designer},</if>
            <if test="installer != null">installer = #{installer},</if>
            <if test="material != null">material = #{material},</if>
            <if test="dia != null">dia = #{dia},</if>
            <if test="scheduleNo != null">schedule_no = #{scheduleNo},</if>
            <if test="length != null">length = #{length},</if>
            <if test="starting != null">starting = #{starting},</if>
            <if test="ending != null">ending = #{ending},</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="medium != null">medium = #{medium},</if>
            <if test="checkConclusion != null">check_conclusion = #{checkConclusion},</if>
            <if test="checkUnit != null">check_unit = #{checkUnit},</if>
            <if test="safeClass != null">safe_class = #{safeClass},</if>
            <if test="reportNo != null">report_no = #{reportNo},</if>
            <if test="approveTime != null">approve_time = #{approveTime},</if>
            <if test="changeTime != null">change_time = #{changeTime},</if>
            <if test="plantMaint != null">plant_maint = #{plantMaint},</if>
            <if test="engineer != null">engineer = #{engineer},</if>
            <if test="weldNumber != null">weld_number = #{weldNumber},</if>
            <if test="layingMethod != null">laying_method = #{layingMethod},</if>
            <if test="adiabatic != null">adiabatic = #{adiabatic},</if>
            <if test="antiCorrosion != null">anti_corrosion = #{antiCorrosion},</if>
            <if test="adiabaticThickness != null">adiabatic_thickness = #{adiabaticThickness},</if>
            <if test="isDanger != null">is_danger = #{isDanger},</if>
            <if test="installDate != null">install_date = #{installDate},</if>
            <if test="yearWarnDate != null">year_warn_date = #{yearWarnDate},</if>
            <if test="yearNextWarnDate != null">year_next_warn_date = #{yearNextWarnDate},</if>
            <if test="yearReportNo != null">year_report_no = #{yearReportNo},</if>
            <if test="isRepeat != null">is_repeat = #{isRepeat},</if>
        </trim>
        where id = #{id}
    </update>

    <!--ylgd updateByHi-->
    <update id="updateTSpecdevYlgdByHi" parameterType="TSpechiYlgd">
        update t_specdev_ylgd
        <trim prefix="SET" suffixOverrides=",">
            <if test="plantCode != null and plantCode != ''">plant_code = #{plantCode},</if>
            <if test="unit != null">unit = #{unit},</if>
            <if test="devname != null">devname = #{devname},</if>
            <if test="devno != null">devno = #{devno},</if>
            <if test="submitdate != null">submitdate = #{submitdate},</if>
            <if test="status != null">status = #{status},</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="deptId != null">dept_id = #{deptId},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
            <if test="approveStatus != null">approve_status = #{approveStatus},</if>
            <if test="regno != null">regno = #{regno},</if>
            <if test="useno != null">useno = #{useno},</if>
            <if test="warnDate != null">warn_date = #{warnDate},</if>
            <if test="warnCycle != null">warn_cycle = #{warnCycle},</if>
            <if test="nextWarnDate != null">next_warn_date = #{nextWarnDate},</if>
            <if test="warnFlag != null">warn_flag = #{warnFlag},</if>
            <if test="grade != null">grade = #{grade},</if>
            <if test="designer != null">designer = #{designer},</if>
            <if test="installer != null">installer = #{installer},</if>
            <if test="material != null">material = #{material},</if>
            <if test="dia != null">dia = #{dia},</if>
            <if test="scheduleNo != null">schedule_no = #{scheduleNo},</if>
            <if test="length != null">length = #{length},</if>
            <if test="starting != null">starting = #{starting},</if>
            <if test="ending != null">ending = #{ending},</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="medium != null">medium = #{medium},</if>
            <if test="checkConclusion != null">check_conclusion = #{checkConclusion},</if>
            <if test="checkUnit != null">check_unit = #{checkUnit},</if>
            <if test="safeClass != null">safe_class = #{safeClass},</if>
            <if test="reportNo != null">report_no = #{reportNo},</if>
            <if test="approveTime != null">approve_time = #{approveTime},</if>
            <if test="changeTime != null">change_time = #{changeTime},</if>
            <if test="plantMaint != null">plant_maint = #{plantMaint},</if>
            <if test="engineer != null">engineer = #{engineer},</if>
            <if test="weldNumber != null">weld_number = #{weldNumber},</if>
            <if test="layingMethod != null">laying_method = #{layingMethod},</if>
            <if test="adiabatic != null">adiabatic = #{adiabatic},</if>
            <if test="antiCorrosion != null">anti_corrosion = #{antiCorrosion},</if>
            <if test="adiabaticThickness != null">adiabatic_thickness = #{adiabaticThickness},</if>
            <if test="isDanger != null">is_danger = #{isDanger},</if>
            <if test="installDate != null">install_date = #{installDate},</if>
            <if test="yearWarnDate != null">year_warn_date = #{yearWarnDate},</if>
            <if test="yearNextWarnDate != null">year_next_warn_date = #{yearNextWarnDate},</if>
            <if test="yearReportNo != null">year_report_no = #{yearReportNo},</if>
        </trim>
        where id = #{devId}
    </update>

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

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

    <update id="duplicateTSpecdevYlgd" >
        UPDATE  T_SPECDEV_YLGD set DEL_FLAG = 2
        where rowid !=( select max(rowid)
        from T_SPECDEV_YLGD b
        where b.useno = T_SPECDEV_YLGD.useno and b.DEVNO = T_SPECDEV_YLGD.DEVNO and b.plant_code = T_SPECDEV_YLGD.plant_code and T_SPECDEV_YLGD.DEL_FLAG = 0 and b.DEL_FLAG = 0
            and T_SPECDEV_YLGD.APPROVE_STATUS = 0
        )
    </update>

    <select id="selectYlgdLengthList" fetchSize="1000" parameterType="TSpecdevYlgd" resultMap="TSpecdevYlgdResult">
        SELECT *
        FROM T_SPECDEV_YLGD
        <where>
            and del_flag=0
            and status=1
            and plant_code in
            <foreach collection="plantCodes" item="item" open="(" separator="," close=")" index="index">
                #{item}
            </foreach>
        </where>
        --${params.dataScopePlant}
    </select>



</mapper>
