无关风月
2 天以前 030201887b4690e20b1f9ffae548ccd840e7077f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?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.system.mapper.AssetTypeMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ruoyi.system.model.AssetType">
        <id column="id" property="id" />
        <result column="type_name" property="typeName" />
        <result column="type_code" property="typeCode" />
        <result column="parent_id" property="parentId" />
        <result column="level" property="level" />
        <result column="create_time" property="createTime" />
        <result column="create_by" property="createBy" />
        <result column="update_time" property="updateTime" />
        <result column="update_by" property="updateBy" />
        <result column="disabled" property="disabled" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, type_name, type_code, parent_id, level, create_time, create_by, update_time, update_by, disabled
    </sql>
    <select id="pageList" resultType="com.ruoyi.system.vo.AssetStatisticsVO">
        select t1.id as assetTypeIdSecond,t1.type_name as assetTypeNameSecond,
               t2.id as assetTypeIdFirst,t2.type_name as assetTypeNameFirst
        FROM asset_type t1
        left join asset_type t2 on t1.parent_id = t2.id
        where 1=1
        and
        t1.parent_id != 0
        <if test="query.assetTypeIds != null and query.assetTypeIds.size()>0">
            AND t1.id IN
            <foreach collection="query.assetTypeIds" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
               AND t1.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
               AND t2.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
 
    </select>
    <select id="pageListNoLimit" resultType="com.ruoyi.system.vo.AssetStatisticsVO">
        select t1.id as assetTypeIdSecond,t1.type_name as assetTypeNameSecond,
        t2.id as assetTypeIdFirst,t2.type_name as assetTypeNameFirst
        FROM asset_type t1
        left join asset_type t2 on t1.parent_id = t2.id
        where 1=1
        and
        t1.parent_id != 0
        <if test="query.assetTypeIds != null and query.assetTypeIds.size()>0">
            AND t1.id IN
            <foreach collection="query.assetTypeIds" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        AND t1.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
        AND t2.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
    </select>
    <select id="pageListDetail" resultType="com.ruoyi.system.vo.AssetStatisticsDetailVO">
        select t1.* ,t2.type_name    as assetTypeName,t4.dept_name as ownershipDeptName,
        case
        when t1.use_dept_id is not null and t1.use_dept_id != '' then t3.dept_name
        when t1.address is not null and t1.address != '' then t1.address
        when t1.warehouse_name is not null and t1.warehouse_name != '' then t1.warehouse_name
        else null
        end as useName from asset_main
        left join asset_type t2 on t2.id = t1.asset_type_id
        left join t_dept t3 on t3.id = t1.use_dept_id
        left join t_dept t4 on t4.id = t1.ownership_dept_id
 
        where 1=1
          <if test="query.assetTypeIdSecond != null">
            AND t1.asset_type_id = #{query.assetTypeIdSecond}
        </if>
        <if test="query.deptId != null">
            AND t1.asset_type_id = #{query.assetTypeIdSecond}
        </if>
          AND t1.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
        <if test="query.assetMainIds != null and query.assetMainIds.size()>0">
            AND t1.id IN
            <foreach collection="query.assetMainIds" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
 
        order by t1.create_time  desc
 
    </select>
 
</mapper>