<?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.xjrsoft.module.asset.mapper.WfAssetManageMapper">
    <select id="getPage" parameterType="com.xjrsoft.module.asset.dto.WfAssetManagePageDto"
            resultType="com.xjrsoft.module.asset.vo.WfAssetManagePageVo">
        select
            t.*,
            t1.name as assetTypeCn,
            t2.name as assetCategoryCn,
            t3.name as assetSpeciesCn,
            t4.name as deptIdCn,
            t5.name as userIdCn
        from wf_asset_manage t
                 left join xjr_dictionary_detail t1 on t1.code = t.asset_type and t1.item_id = '1773620475495190530'
                 left join xjr_dictionary_detail t2 on t2.code = t.asset_category and t2.item_id = '1773620610862157826'
                 left join xjr_dictionary_detail t3 on t3.code = t.asset_species and t3.item_id = '1773620783726202882'
                 left join xjr_department t4 on t4.id = t.dept_id
                 left join xjr_user t5 on t5.id = t.user_id
        where t.delete_mark = 0
        <if test="dto.assetType != null and dto.assetType != ''">
            and t.asset_type = #{dto.assetType}
        </if>
        <if test="dto.assetCategory != null and dto.assetCategory != ''">
            and t.asset_category = #{dto.assetCategory}
        </if>
        <if test="dto.assetSpecies != null and dto.assetSpecies != ''">
            and t.asset_species = #{dto.assetSpecies}
        </if>
        <if test="dto.name != null and dto.name != ''">
            and t.name like concat('%', #{dto.name}, '%')
        </if>
        <if test="dto.deptId != null and dto.deptId != ''">
            and t.dept_id = #{dto.deptId}
        </if>
        <if test="dto.userId != null and dto.userId != ''">
            and t.user_id = #{dto.userId}
        </if>
    </select>

    <select id="listWfAssetManageSelectRecordQuery" parameterType="com.xjrsoft.module.asset.dto.WfAssetManageSelectRecordQueryDto"
            resultType="com.xjrsoft.module.asset.vo.WfAssetManageQueryVo">
        select
        t.*,
        t1.name as assetTypeCn,
        t2.name as assetCategoryCn,
        t3.name as assetSpeciesCn,
        t4.name as deptIdCn,
        t5.name as userIdCn
        from wf_asset_manage t
        left join xjr_dictionary_detail t1 on t1.code = t.asset_type and t1.item_id = '1773620475495190530'
        left join xjr_dictionary_detail t2 on t2.code = t.asset_category and t2.item_id = '1773620610862157826'
        left join xjr_dictionary_detail t3 on t3.code = t.asset_species and t3.item_id = '1773620783726202882'
        left join xjr_department t4 on t4.id = t.dept_id
        left join xjr_user t5 on t5.id = t.user_id
        where t.delete_mark = 0
        <if test="dto.ids != null and !dto.ids.isEmpty()">
            and t.id in
            <foreach item="id" index="index" collection="dto.ids" open="(" close=")"
                                  separator=",">
            #{id}
            </foreach>
        </if>
    </select>

    <select id="listWfAssetManageConditionalSearchQuery" parameterType="com.xjrsoft.module.asset.dto.WfAssetManageConditionalSearchQueryDto"
            resultType="com.xjrsoft.module.asset.vo.WfAssetManageQueryVo">
        select
        t.*,
        t1.name as assetTypeCn,
        t2.name as assetCategoryCn,
        t3.name as assetSpeciesCn,
        t4.name as deptIdCn,
        t5.name as userIdCn
        from wf_asset_manage t
        left join xjr_dictionary_detail t1 on t1.code = t.asset_type and t1.item_id = '1773620475495190530'
        left join xjr_dictionary_detail t2 on t2.code = t.asset_category and t2.item_id = '1773620610862157826'
        left join xjr_dictionary_detail t3 on t3.code = t.asset_species and t3.item_id = '1773620783726202882'
        left join xjr_department t4 on t4.id = t.dept_id
        left join xjr_user t5 on t5.id = t.user_id
        where t.delete_mark = 0
        <if test="dto.assetType != null and dto.assetType != ''">
            and t.asset_type = #{dto.assetType}
        </if>
        <if test="dto.assetCategory != null and dto.assetCategory != ''">
            and t.asset_category = #{dto.assetCategory}
        </if>
        <if test="dto.assetSpecies != null and dto.assetSpecies != ''">
            and t.asset_species = #{dto.assetSpecies}
        </if>
        <if test="dto.name != null and dto.name != ''">
            and t.name like concat('%', #{dto.name}, '%')
        </if>
        <if test="dto.deptId != null and dto.deptId != ''">
            and t.dept_id = #{dto.deptId}
        </if>
        <if test="dto.userId != null and dto.userId != ''">
            and t.user_id = #{dto.userId}
        </if>
    </select>
</mapper>