无关风月
1 天以前 6999d4114eb6d64d0775e2f9ff00572b0e60ee31
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?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.assetMainIds != null and query.assetMainIds.size()>0">
            AND t1.id IN
            <foreach collection="query.assetMainIds" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="query.assetTypeIds != null and query.assetTypeIds.size()>0">
            AND t1.asset_type_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 t1
        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.category != null">
            AND t1.category = #{query.category}
        </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>
        <if test="query.deptIds != null and query.deptIds.size()>0">
            AND t1.ownership_dept_id IN
            <foreach collection="query.deptIds" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
 
        order by t1.create_time desc
 
    </select>
    <select id="pageListInventory" resultType="com.ruoyi.system.vo.AssetInventoryVO">
        select t1.name as assetTypeNameSecond,t1.id as assetTypeIdSecond,
        t2.name as assetTypeNameFirst,t2.id as assetTypeIdFirst
        from asset_type t1
        left join asset_type t2 on t1.parent_id = t2.id
        where 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="pageListInventoryDetail" resultType="com.ruoyi.system.vo.AssetStatisticsDetailVO">
        select t1.*,t2.*,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_inventory_record t1
                 left join asset_main t2 on t1.asset_main_id = t2.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.category != null and query.category!=''">
            AND t2.category = #{query.category}
        </if>
 
        <if test="query.assetStatus != null and query.assetStatus!=''">
            and t2.asset_status like concat('%',#{query.assetStatus},'%')
        </if>
        <if test="query.deptIds != null and query.deptIds.size()>0">
            AND t2.ownership_dept_id IN
            <foreach collection="query.deptIds" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
          <if test="query.assetMainIds != null and query.assetMainIds.size()>0">
            AND t2.id IN
            <foreach collection="query.assetMainIds" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        order by t1.create_time desc
 
    </select>
 
</mapper>