<?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.asset.mapper.TSpecdevAssetMapper">

    <resultMap type="TSpecdevAsset" id="TSpecdevAssetResult">
        <result property="id"    column="id"    />
        <result property="type"    column="type"    />
        <result property="content"    column="content"    />
        <result property="pidNo"    column="pid_no"    />
        <result property="positionDescribe"    column="position_describe"    />
        <result property="accordingTo"    column="according_to"    />
        <result property="asset"    column="asset"    />
        <result property="dcsOperation"    column="dcs_operation"    />
        <result property="inSceneOperation"    column="in_scene_operation"    />
        <result property="outSceneOperation"    column="out_scene_operation"    />
        <result property="inInspection"    column="in_inspection"    />
        <result property="outInspection"    column="out_inspection"    />
        <result property="inRepair"    column="in_repair"    />
        <result property="outRepair"    column="out_repair"    />
        <result property="inMaintenanceCoordination"    column="in_maintenance_coordination"    />
        <result property="outMaintenanceCoordination"    column="out_maintenance_coordination"    />
        <result property="inTechnicalManagement"    column="in_technical_management"    />
        <result property="outTechnicalManagement"    column="out_technical_management"    />
        <result property="position"    column="position"    />
        <result property="pipeDiameter"    column="pipe_diameter"    />
        <result property="picUrl"    column="pic_url"    />
        <result property="picName"    column="pic_Name"    />
        <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="deptName" column="dept_name" />
    </resultMap>

    <sql id="selectTSpecdevAssetVo">
        select d.pic_name,d.id, d.type, d.content, d.pid_no, d.position_describe, d.according_to, d.asset, d.dcs_operation, d.in_scene_operation, d.out_scene_operation, d.in_inspection, d.out_inspection, d.in_repair, d.out_repair, d.in_maintenance_coordination, d.out_maintenance_coordination, d.in_technical_management, d.out_technical_management, d.position, d.pipe_diameter, d.pic_url, d.status, d.del_flag, d.creater_code, d.createdate, d.updater_code, d.updatedate, d.dept_id, d.remarks ,s.dept_name from t_specdev_asset d
      left join sys_dept s on s.dept_id = d.dept_id
    </sql>

    <select id="selectTSpecdevAssetList" parameterType="TSpecdevAsset" resultMap="TSpecdevAssetResult">
        <include refid="selectTSpecdevAssetVo"/>
        <where>
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="pidNo != null  and pidNo != ''"> and pid_no = #{pidNo}</if>
            <if test="positionDescribe != null  and positionDescribe != ''"> and position_describe = #{positionDescribe}</if>
            <if test="accordingTo != null  and accordingTo != ''"> and according_to = #{accordingTo}</if>
            <if test="asset != null  and asset != ''"> and asset = #{asset}</if>
            <if test="dcsOperation != null  and dcsOperation != ''"> and dcs_operation = #{dcsOperation}</if>
            <if test="inSceneOperation != null  and inSceneOperation != ''"> and in_scene_operation = #{inSceneOperation}</if>
            <if test="outSceneOperation != null  and outSceneOperation != ''"> and out_scene_operation = #{outSceneOperation}</if>
            <if test="inInspection != null  and inInspection != ''"> and in_inspection = #{inInspection}</if>
            <if test="outInspection != null  and outInspection != ''"> and out_inspection = #{outInspection}</if>
            <if test="inRepair != null  and inRepair != ''"> and in_repair = #{inRepair}</if>
            <if test="outRepair != null  and outRepair != ''"> and out_repair = #{outRepair}</if>
            <if test="inMaintenanceCoordination != null  and inMaintenanceCoordination != ''"> and in_maintenance_coordination = #{inMaintenanceCoordination}</if>
            <if test="outMaintenanceCoordination != null  and outMaintenanceCoordination != ''"> and out_maintenance_coordination = #{outMaintenanceCoordination}</if>
            <if test="inTechnicalManagement != null  and inTechnicalManagement != ''"> and in_technical_management = #{inTechnicalManagement}</if>
            <if test="outTechnicalManagement != null  and outTechnicalManagement != ''"> and out_technical_management = #{outTechnicalManagement}</if>
            <if test="position != null  and position != ''"> and position = #{position}</if>
            <if test="pipeDiameter != null  and pipeDiameter != ''"> and pipe_diameter = #{pipeDiameter}</if>
            <if test="picUrl != null  and picUrl != ''"> and pic_url = #{picUrl}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="createrCode != null "> and creater_code = #{createrCode}</if>
            <if test="createdate != null "> and createdate = #{createdate}</if>
            <if test="updaterCode != null "> and updater_code = #{updaterCode}</if>
            <if test="updatedate != null "> and updatedate = #{updatedate}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
            <if test="fuzzy != null  and fuzzy != ''"> and
             (
                type like concat ('%', #{fuzzy},'%')
                or content like concat ('%', #{fuzzy},'%')
                or pid_no like concat ('%', #{fuzzy},'%')
                or position_describe like concat ('%', #{fuzzy},'%')
                or according_to like concat ('%', #{fuzzy},'%')
                or asset like concat ('%', #{fuzzy},'%')
                or dcs_operation like concat ('%', #{fuzzy},'%')
                or in_scene_operation like concat ('%', #{fuzzy},'%')
                or out_scene_operation like concat ('%', #{fuzzy},'%')
                or in_inspection like concat ('%', #{fuzzy},'%')
                or out_inspection like concat ('%', #{fuzzy},'%')
                or in_repair like concat ('%', #{fuzzy},'%')
                or out_repair like concat ('%', #{fuzzy},'%')
                or in_maintenance_coordination like concat ('%', #{fuzzy},'%')
                or out_maintenance_coordination like concat ('%', #{fuzzy},'%')
                or in_technical_management like concat ('%', #{fuzzy},'%')
                or out_technical_management like concat ('%', #{fuzzy},'%')
                or position like concat ('%', #{fuzzy},'%')
                or pipe_diameter like concat ('%', #{fuzzy},'%')
                or remarks like concat ('%', #{fuzzy},'%')
                )
            </if>
            and d.del_flag = 0
        </where>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
    </select>

    <select id="selectTSpecdevAssetById" parameterType="Long" resultMap="TSpecdevAssetResult">
        <include refid="selectTSpecdevAssetVo"/>
        where id = #{id}
    </select>

    <insert id="insertTSpecdevAsset" parameterType="TSpecdevAsset" useGeneratedKeys="true" keyProperty="id">
        insert into t_specdev_asset
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="type != null">type,</if>
            <if test="content != null">content,</if>
            <if test="pidNo != null">pid_no,</if>
            <if test="positionDescribe != null">position_describe,</if>
            <if test="accordingTo != null">according_to,</if>
            <if test="asset != null">asset,</if>
            <if test="dcsOperation != null">dcs_operation,</if>
            <if test="inSceneOperation != null">in_scene_operation,</if>
            <if test="outSceneOperation != null">out_scene_operation,</if>
            <if test="inInspection != null">in_inspection,</if>
            <if test="outInspection != null">out_inspection,</if>
            <if test="inRepair != null">in_repair,</if>
            <if test="outRepair != null">out_repair,</if>
            <if test="inMaintenanceCoordination != null">in_maintenance_coordination,</if>
            <if test="outMaintenanceCoordination != null">out_maintenance_coordination,</if>
            <if test="inTechnicalManagement != null">in_technical_management,</if>
            <if test="outTechnicalManagement != null">out_technical_management,</if>
            <if test="position != null">position,</if>
            <if test="pipeDiameter != null">pipe_diameter,</if>
            <if test="picUrl != null">pic_url,</if>
            <if test="picName != null">pic_name,</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>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="type != null">#{type},</if>
            <if test="content != null">#{content},</if>
            <if test="pidNo != null">#{pidNo},</if>
            <if test="positionDescribe != null">#{positionDescribe},</if>
            <if test="accordingTo != null">#{accordingTo},</if>
            <if test="asset != null">#{asset},</if>
            <if test="dcsOperation != null">#{dcsOperation},</if>
            <if test="inSceneOperation != null">#{inSceneOperation},</if>
            <if test="outSceneOperation != null">#{outSceneOperation},</if>
            <if test="inInspection != null">#{inInspection},</if>
            <if test="outInspection != null">#{outInspection},</if>
            <if test="inRepair != null">#{inRepair},</if>
            <if test="outRepair != null">#{outRepair},</if>
            <if test="inMaintenanceCoordination != null">#{inMaintenanceCoordination},</if>
            <if test="outMaintenanceCoordination != null">#{outMaintenanceCoordination},</if>
            <if test="inTechnicalManagement != null">#{inTechnicalManagement},</if>
            <if test="outTechnicalManagement != null">#{outTechnicalManagement},</if>
            <if test="position != null">#{position},</if>
            <if test="pipeDiameter != null">#{pipeDiameter},</if>
            <if test="picUrl != null">#{picUrl},</if>
            <if test="picName != null">#{picName},</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>
         </trim>
    </insert>

    <update id="updateTSpecdevAsset" parameterType="TSpecdevAsset">
        update t_specdev_asset
        <trim prefix="SET" suffixOverrides=",">
            <if test="type != null">type = #{type},</if>
            <if test="content != null">content = #{content},</if>
            <if test="pidNo != null">pid_no = #{pidNo},</if>
            <if test="positionDescribe != null">position_describe = #{positionDescribe},</if>
            <if test="accordingTo != null">according_to = #{accordingTo},</if>
            <if test="asset != null">asset = #{asset},</if>
            <if test="dcsOperation != null">dcs_operation = #{dcsOperation},</if>
            <if test="inSceneOperation != null">in_scene_operation = #{inSceneOperation},</if>
            <if test="outSceneOperation != null">out_scene_operation = #{outSceneOperation},</if>
            <if test="inInspection != null">in_inspection = #{inInspection},</if>
            <if test="outInspection != null">out_inspection = #{outInspection},</if>
            <if test="inRepair != null">in_repair = #{inRepair},</if>
            <if test="outRepair != null">out_repair = #{outRepair},</if>
            <if test="inMaintenanceCoordination != null">in_maintenance_coordination = #{inMaintenanceCoordination},</if>
            <if test="outMaintenanceCoordination != null">out_maintenance_coordination = #{outMaintenanceCoordination},</if>
            <if test="inTechnicalManagement != null">in_technical_management = #{inTechnicalManagement},</if>
            <if test="outTechnicalManagement != null">out_technical_management = #{outTechnicalManagement},</if>
            <if test="position != null">position = #{position},</if>
            <if test="pipeDiameter != null">pipe_diameter = #{pipeDiameter},</if>
            <if test="picUrl != null and picUrl!=''">pic_url = #{picUrl},</if>
            <if test="picName != null">pic_name = #{picName},</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>
        </trim>
        where id = #{id}
    </update>

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

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

</mapper>
