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

    <resultMap type="TSpecdevFixedAsset" id="TSpecdevFixedAssetResult">
        <result property="id"    column="id"    />
        <result property="assetType"    column="asset_type"    />
        <result property="assetNo"    column="asset_no"    />
        <result property="assetSubNo"    column="asset_sub_no"    />
        <result property="devName"    column="dev_name"    />
        <result property="devEnname"    column="dev_enname"    />
        <result property="costCenter"    column="cost_center"    />
        <result property="costCenterCode"    column="cost_center_code"    />
        <result property="assetTypeAp"    column="asset_type_ap"    />
        <result property="capitalizedDate"    column="capitalized_date"    />
        <result property="quantity"    column="quantity"    />
        <result property="currency"    column="currency"    />
        <result property="currentApc"    column="current_apc"    />
        <result property="serviceLife"    column="service_life"    />
        <result property="administrator"    column="administrator"    />
        <result property="devNo"    column="dev_no"    />
        <result property="assetDetail"    column="asset_detail"    />
        <result property="processSubunit"    column="process_subunit"    />
        <result property="pidNo"    column="pid_no"    />
        <result property="installPosition"    column="install_position"    />
        <result property="createReason"    column="create_reason"    />
        <result property="barcodePosition"    column="barcode_position"    />
        <result property="scrapReason"    column="scrap_reason"    />
        <result property="scrapPoseDate"    column="scrap_pose_date"    />
        <result property="scrapDoneDate"    column="scrap_done_date"    />
        <result property="scraper"    column="scraper"    />
        <result property="usingStatus"    column="using_status"    />
        <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="selectTSpecdevFixedAssetVo">
        select d.id, d.asset_type, d.asset_no, d.asset_sub_no, d.dev_name, d.dev_enname, d.cost_center, d.cost_center_code, d.asset_type_ap, d.capitalized_date, d.quantity, d.currency, d.current_apc, d.service_life, d.administrator, d.dev_no, d.asset_detail, d.process_subunit, d.pid_no, d.install_position, d.create_reason, d.barcode_position, d.scrap_reason, d.scrap_pose_date, d.scrap_done_date, d.scraper, d.using_status, 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_fixed_asset d
      left join sys_dept s on s.dept_id = d.dept_id
    </sql>

    <select id="selectTSpecdevFixedAssetList" parameterType="TSpecdevFixedAsset" resultMap="TSpecdevFixedAssetResult">
        <include refid="selectTSpecdevFixedAssetVo"/>
        <where>
            <if test="assetType != null  and assetType != ''"> and asset_type = #{assetType}</if>
            <if test="assetNo != null  and assetNo != ''"> and asset_no = #{assetNo}</if>
            <if test="assetSubNo != null  and assetSubNo != ''"> and asset_sub_no = #{assetSubNo}</if>
            <if test="devName != null  and devName != ''"> and dev_name like concat(concat('%', #{devName}), '%')</if>
            <if test="devEnname != null  and devEnname != ''"> and dev_enname like concat(concat('%', #{devEnname}), '%')</if>
            <if test="costCenter != null  and costCenter != ''"> and cost_center = #{costCenter}</if>
            <if test="costCenterCode != null  and costCenterCode != ''"> and cost_center_code = #{costCenterCode}</if>
            <if test="assetTypeAp != null  and assetTypeAp != ''"> and asset_type_ap = #{assetTypeAp}</if>
            <if test="capitalizedDate != null "> and capitalized_date = #{capitalizedDate}</if>
            <if test="quantity != null  and quantity != ''"> and quantity = #{quantity}</if>
            <if test="currency != null  and currency != ''"> and currency = #{currency}</if>
            <if test="currentApc != null  and currentApc != ''"> and current_apc = #{currentApc}</if>
            <if test="serviceLife != null  and serviceLife != ''"> and service_life = #{serviceLife}</if>
            <if test="administrator != null  and administrator != ''"> and administrator = #{administrator}</if>
            <if test="devNo != null  and devNo != ''"> and dev_no = #{devNo}</if>
            <if test="assetDetail != null  and assetDetail != ''"> and asset_detail = #{assetDetail}</if>
            <if test="processSubunit != null  and processSubunit != ''"> and process_subunit = #{processSubunit}</if>
            <if test="pidNo != null  and pidNo != ''"> and pid_no = #{pidNo}</if>
            <if test="installPosition != null  and installPosition != ''"> and install_position = #{installPosition}</if>
            <if test="createReason != null  and createReason != ''"> and create_reason = #{createReason}</if>
            <if test="barcodePosition != null  and barcodePosition != ''"> and barcode_position = #{barcodePosition}</if>
            <if test="scrapReason != null  and scrapReason != ''"> and scrap_reason = #{scrapReason}</if>
            <if test="scrapPoseDate != null "> and scrap_pose_date = #{scrapPoseDate}</if>
            <if test="scrapDoneDate != null "> and scrap_done_date = #{scrapDoneDate}</if>
            <if test="scraper != null  and scraper != ''"> and scraper = #{scraper}</if>
            <if test="usingStatus != null  and usingStatus != ''"> and using_status = #{usingStatus}</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 = #{remarks}</if>
            <if test="fuzzy != null and fuzzy != ''"> and (asset_type like concat ('%',#{fuzzy},'%')
                or asset_no like concat ('%',#{fuzzy},'%')
                or asset_sub_no like concat ('%',#{fuzzy},'%')
                or dev_name like concat ('%',#{fuzzy},'%')
                or dev_enname like concat ('%',#{fuzzy},'%')
                or cost_center like concat ('%',#{fuzzy},'%')
                or cost_center_code like concat ('%',#{fuzzy},'%')
                or asset_type_ap like concat ('%',#{fuzzy},'%')
                or capitalized_date like concat ('%',#{fuzzy},'%')
                or quantity like concat ('%',#{fuzzy},'%')
                or currency like concat ('%',#{fuzzy},'%')
                or current_apc like concat ('%',#{fuzzy},'%')
                or service_life like concat ('%',#{fuzzy},'%')
                or administrator like concat ('%',#{fuzzy},'%')
                or dev_no like concat ('%',#{fuzzy},'%')
                or asset_detail like concat ('%',#{fuzzy},'%')
                or process_subunit like concat ('%',#{fuzzy},'%')
                or pid_no like concat ('%',#{fuzzy},'%')
                or install_position like concat ('%',#{fuzzy},'%')
                or create_reason like concat ('%',#{fuzzy},'%')
                or barcode_position like concat ('%',#{fuzzy},'%')
                or scrap_reason like concat ('%',#{fuzzy},'%')
                or scrap_pose_date like concat ('%',#{fuzzy},'%')
                or scrap_done_date like concat ('%',#{fuzzy},'%')
                or scraper like concat ('%',#{fuzzy},'%')
                or using_status like concat ('%',#{fuzzy},'%')
                or remarks like concat ('%',#{fuzzy},'%'))</if>
            and d.del_flag = 0
        </where>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
    </select>

    <select id="selectTSpecdevFixedAssetById" parameterType="Long" resultMap="TSpecdevFixedAssetResult">
        <include refid="selectTSpecdevFixedAssetVo"/>
        where id = #{id}
    </select>

    <insert id="insertTSpecdevFixedAsset" parameterType="TSpecdevFixedAsset" keyProperty="id" useGeneratedKeys="true">
        insert into t_specdev_fixed_asset
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="assetType != null">asset_type,</if>
            <if test="assetNo != null">asset_no,</if>
            <if test="assetSubNo != null">asset_sub_no,</if>
            <if test="devName != null">dev_name,</if>
            <if test="devEnname != null">dev_enname,</if>
            <if test="costCenter != null">cost_center,</if>
            <if test="costCenterCode != null">cost_center_code,</if>
            <if test="assetTypeAp != null">asset_type_ap,</if>
            <if test="capitalizedDate != null">capitalized_date,</if>
            <if test="quantity != null">quantity,</if>
            <if test="currency != null">currency,</if>
            <if test="currentApc != null">current_apc,</if>
            <if test="serviceLife != null">service_life,</if>
            <if test="administrator != null">administrator,</if>
            <if test="devNo != null">dev_no,</if>
            <if test="assetDetail != null">asset_detail,</if>
            <if test="processSubunit != null">process_subunit,</if>
            <if test="pidNo != null">pid_no,</if>
            <if test="installPosition != null">install_position,</if>
            <if test="createReason != null">create_reason,</if>
            <if test="barcodePosition != null">barcode_position,</if>
            <if test="scrapReason != null">scrap_reason,</if>
            <if test="scrapPoseDate != null">scrap_pose_date,</if>
            <if test="scrapDoneDate != null">scrap_done_date,</if>
            <if test="scraper != null">scraper,</if>
            <if test="usingStatus != null">using_status,</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="assetType != null">#{assetType},</if>
            <if test="assetNo != null">#{assetNo},</if>
            <if test="assetSubNo != null">#{assetSubNo},</if>
            <if test="devName != null">#{devName},</if>
            <if test="devEnname != null">#{devEnname},</if>
            <if test="costCenter != null">#{costCenter},</if>
            <if test="costCenterCode != null">#{costCenterCode},</if>
            <if test="assetTypeAp != null">#{assetTypeAp},</if>
            <if test="capitalizedDate != null">#{capitalizedDate},</if>
            <if test="quantity != null">#{quantity},</if>
            <if test="currency != null">#{currency},</if>
            <if test="currentApc != null">#{currentApc},</if>
            <if test="serviceLife != null">#{serviceLife},</if>
            <if test="administrator != null">#{administrator},</if>
            <if test="devNo != null">#{devNo},</if>
            <if test="assetDetail != null">#{assetDetail},</if>
            <if test="processSubunit != null">#{processSubunit},</if>
            <if test="pidNo != null">#{pidNo},</if>
            <if test="installPosition != null">#{installPosition},</if>
            <if test="createReason != null">#{createReason},</if>
            <if test="barcodePosition != null">#{barcodePosition},</if>
            <if test="scrapReason != null">#{scrapReason},</if>
            <if test="scrapPoseDate != null">#{scrapPoseDate},</if>
            <if test="scrapDoneDate != null">#{scrapDoneDate},</if>
            <if test="scraper != null">#{scraper},</if>
            <if test="usingStatus != null">#{usingStatus},</if>
            <if test="status != null">#{status},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createrCode != null">#{createrCode},</if>
            <if test="createdate != null">now(),</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="updateTSpecdevFixedAsset" parameterType="TSpecdevFixedAsset">
        update t_specdev_fixed_asset
        <trim prefix="SET" suffixOverrides=",">
            <if test="assetType != null">asset_type = #{assetType},</if>
            <if test="assetNo != null">asset_no = #{assetNo},</if>
            <if test="assetSubNo != null">asset_sub_no = #{assetSubNo},</if>
            <if test="devName != null">dev_name = #{devName},</if>
            <if test="devEnname != null">dev_enname = #{devEnname},</if>
            <if test="costCenter != null">cost_center = #{costCenter},</if>
            <if test="costCenterCode != null">cost_center_code = #{costCenterCode},</if>
            <if test="assetTypeAp != null">asset_type_ap = #{assetTypeAp},</if>
            <if test="capitalizedDate != null">capitalized_date = #{capitalizedDate},</if>
            <if test="quantity != null">quantity = #{quantity},</if>
            <if test="currency != null">currency = #{currency},</if>
            <if test="currentApc != null">current_apc = #{currentApc},</if>
            <if test="serviceLife != null">service_life = #{serviceLife},</if>
            <if test="administrator != null">administrator = #{administrator},</if>
            <if test="devNo != null">dev_no = #{devNo},</if>
            <if test="assetDetail != null">asset_detail = #{assetDetail},</if>
            <if test="processSubunit != null">process_subunit = #{processSubunit},</if>
            <if test="pidNo != null">pid_no = #{pidNo},</if>
            <if test="installPosition != null">install_position = #{installPosition},</if>
            <if test="createReason != null">create_reason = #{createReason},</if>
            <if test="barcodePosition != null">barcode_position = #{barcodePosition},</if>
            <if test="scrapReason != null">scrap_reason = #{scrapReason},</if>
            <if test="scrapPoseDate != null">scrap_pose_date = #{scrapPoseDate},</if>
            <if test="scrapDoneDate != null">scrap_done_date = #{scrapDoneDate},</if>
            <if test="scraper != null">scraper = #{scraper},</if>
            <if test="usingStatus != null">using_status = #{usingStatus},</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="deleteTSpecdevFixedAssetById" parameterType="Long">
        update t_specdev_fixed_asset set del_flag = 2 where id = #{id}
    </update>

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

</mapper>
