cuijian
2025-06-05 c17e36e49be715a3305c79625187631184278c19
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<?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="org.jeecg.modules.tms.mapper.ToolLedgerDetailMapper">
 
    <select id="queryPageList" resultType="org.jeecg.modules.tms.entity.ToolLedgerDetail">
        SELECT
            t.id,
            t.tool_code toolCode,
            p.tool_code toolNum,
            t.tool_id toolId,
            p.chinese_name toolName,
            p.tool_model toolModel,
            t.quantity,
            t.warehouse_id warehouseId,
            ISNULL(q.warehouse_id, '') + '/' + ISNULL(q.warehouse_name, '') warehouseName,
            t.position_code positionCode
        FROM tms_tool_ledger_detail t
        LEFT JOIN tms_base_tools p on t.tool_code = p.id
        LEFT JOIN tms_warehouse q on t.warehouse_id = q.id
        ${ew.customSqlSegment}
    </select>
 
    <!--<select id="queryToolByStatus"  resultType="map" parameterType="String">
        SELECT
            t.id,
            t.tool_code toolCodeId,
            p.tool_code toolCode,
            t.tool_id onlyCode,
            p.chinese_name chineseName,
            p.accuracy_class accuracyClass,
            p.tool_model toolModel,
            t.quantity,
            t.warehouse_id warehouseId,
            ISNULL(q.warehouse_id, '') + '/' + ISNULL(q.warehouse_name, '') warehouseName,
            t.position_code positionCode,
            t2.item_text applicationTypeName
        FROM tms_tool_ledger_detail t
                 LEFT JOIN tms_base_tools p on t.tool_code = p.id
                 LEFT JOIN tms_warehouse q on t.warehouse_id = q.id
                 left join tms_tools_config_property t1 on t1.tool_code = p.id
                 left join (select * from v_sys_dict where dict_code = 'application_type') t2 on t2.item_value = t1.application_type
            ${ew.customSqlSegment}
    </select>-->
 
    <select id="queryLendTool"  resultType="map" parameterType="String">
        SELECT
            temp.id,
            temp.toolCodeId,
            temp.toolCode,
            temp.onlyCode,
            temp.chineseName,
            temp.accuracyClass,
            temp.toolModel,
            temp.quantity,
            temp.warehouseId,
            temp.warehouseName,
            temp.positionCode,
            temp.applicationTypeName
        FROM
            (
                SELECT
                    t.id,
                    t.tool_code toolCodeId,
                    p.tool_code toolCode,
                    t.tool_id onlyCode,
                    p.chinese_name chineseName,
                    p.accuracy_class accuracyClass,
                    p.tool_model toolModel,
                    1 quantity,
                    t.warehouse_id warehouseId,
                    ISNULL( q.warehouse_id, '' ) + '/' + ISNULL( q.warehouse_name, '' ) warehouseName,
                    t.position_code positionCode,
                    t2.item_text applicationTypeName
                FROM
                    tms_tool_ledger_detail t
                        LEFT JOIN tms_base_tools p ON t.tool_code = p.id
                        LEFT JOIN tms_warehouse q ON t.warehouse_id = q.id
                        LEFT JOIN tms_tools_config_property t1 ON t1.tool_code = p.id
                        LEFT JOIN ( SELECT * FROM v_sys_dict WHERE dict_code = 'application_type' ) t2 ON t2.item_value = t1.application_type
                        ${ew.customSqlSegment}
                    UNION ALL
                    (
                    SELECT
                        t.id,
                        t.tool_code toolCodeId,
                        p.tool_code toolCode,
                        t.tool_id onlyCode,
                        p.chinese_name chineseName,
                        p.accuracy_class accuracyClass,
                        p.tool_model toolModel,
                        t3.lend_count quantity,
                        t.warehouse_id warehouseId,
                        ISNULL( q.warehouse_id, '' ) + '/' + ISNULL( q.warehouse_name, '' ) warehouseName,
                        t.position_code positionCode,
                        t2.item_text applicationTypeName
                    FROM
                        tms_tool_ledger_detail t
                            LEFT JOIN tms_tool_ledger t3 ON t3.tool_id = t.tool_code
                            LEFT JOIN tms_base_tools p ON t.tool_code = p.id
                            LEFT JOIN tms_warehouse q ON t.warehouse_id = q.id
                            LEFT JOIN tms_tools_config_property t1 ON t1.tool_code = p.id
                            LEFT JOIN ( SELECT * FROM v_sys_dict WHERE dict_code = 'application_type' ) t2 ON t2.item_value = t1.application_type
                            WHERE
                        p.accuracy_class != 1
            AND t3.lend_count != 0
                )
            ) temp
    </select>
 
    <select id="querySharpenTool"  resultType="map" parameterType="String">
        SELECT
            temp.id,
            temp.toolCodeId,
            temp.toolCode,
            temp.onlyCode,
            temp.chineseName,
            temp.accuracyClass,
            temp.toolModel,
            temp.quantity,
            temp.warehouseId,
            temp.warehouseName,
            temp.positionCode,
            temp.applicationTypeName
        FROM
            (
                SELECT
                    t.id,
                    t.tool_code toolCodeId,
                    p.tool_code toolCode,
                    t.tool_id onlyCode,
                    p.chinese_name chineseName,
                    p.accuracy_class accuracyClass,
                    p.tool_model toolModel,
                    1 quantity,
                    t.warehouse_id warehouseId,
                    ISNULL( q.warehouse_id, '' ) + '/' + ISNULL( q.warehouse_name, '' ) warehouseName,
                    t.position_code positionCode,
                    t2.item_text applicationTypeName
                FROM
                    tms_tool_ledger_detail t
                        LEFT JOIN tms_base_tools p ON t.tool_code = p.id
                        LEFT JOIN tms_warehouse q ON t.warehouse_id = q.id
                        LEFT JOIN tms_tools_config_property t1 ON t1.tool_code = p.id
                        LEFT JOIN ( SELECT * FROM v_sys_dict WHERE dict_code = 'application_type' ) t2 ON t2.item_value = t1.application_type
                    ${ew.customSqlSegment}
                UNION ALL
                (
                SELECT
                    t.id,
                    t.tool_code toolCodeId,
                    p.tool_code toolCode,
                    t.tool_id onlyCode,
                    p.chinese_name chineseName,
                    p.accuracy_class accuracyClass,
                    p.tool_model toolModel,
                    t3.sharpening_count quantity,
                    t.warehouse_id warehouseId,
                    ISNULL( q.warehouse_id, '' ) + '/' + ISNULL( q.warehouse_name, '' ) warehouseName,
                    t.position_code positionCode,
                    t2.item_text applicationTypeName
                FROM
                    tms_tool_ledger_detail t
                    LEFT JOIN tms_tool_ledger t3 ON t3.tool_id = t.tool_code
                    LEFT JOIN tms_base_tools p ON t.tool_code = p.id
                    LEFT JOIN tms_warehouse q ON t.warehouse_id = q.id
                    LEFT JOIN tms_tools_config_property t1 ON t1.tool_code = p.id
                    LEFT JOIN ( SELECT * FROM v_sys_dict WHERE dict_code = 'application_type' ) t2 ON t2.item_value = t1.application_type
                WHERE
                    p.accuracy_class != 1
                  AND t3.sharpening_count != 0
                    )
            ) temp
    </select>
</mapper>