自动化立体仓库 - WMS系统
pang.jiabao
2024-07-05 07c572bea979dbd3ee46ec24083cb1bdcc014e3a
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
<?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.zy.asrs.mapper.LocDetlMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.zy.asrs.entity.LocDetl">
        <result column="loc_no" property="locNo" />
        <result column="mat_no" property="matNo" />
        <result column="mat_name" property="matName" />
        <result column="specs" property="specs" />
        <result column="size" property="size" />
        <result column="color" property="color" />
        <result column="weight" property="weight" />
        <result column="supplier" property="supplier" />
        <result column="warehouse" property="warehouse" />
        <result column="brand" property="brand" />
        <result column="qty" property="qty" />
        <result column="unit" property="unit" />
        <result column="zpallet" property="zpallet" />
        <result column="bname" property="bname" />
        <result column="memo" property="memo" />
        <result column="modi_user" property="modiUser" />
        <result column="modi_time" property="modiTime" />
        <result column="appe_user" property="appeUser" />
        <result column="appe_time" property="appeTime" />
        <result column="all_qty" property="allQty"/>
        <result column="all_weight" property="allWeight"/>
        <result column="source" property="source" />
        <result column="vendor" property="vendor" />
        <result column="qty_box" property="qtyBox"/>
        <result column="str3" property="str3" />
        <result column="str4" property="str4" />
        <result column="str5" property="str5"/>
    </resultMap>
 
    <sql id="stockOutCondition">
        <if test="loc_no!=null and loc_no!='' ">
            and a.loc_no like '%' + #{loc_no} + '%'
        </if>
        <if test="mat_no!=null and mat_no!='' ">
            and a.mat_no like '%' + #{mat_no} + '%'
        </if>
        <if test="mat_name!=null and mat_name!='' ">
            and a.mat_name like '%' + #{mat_name} + '%'
        </if>
        <if test="str3!=null and str3!=''" >
            and a.str3 like '%'+#{str3}+'%'
        </if>
        <if test="qty!=null and qty!='' ">
            and a.qty = #{qty}
        </if>
        <if test="altme!=null and altme!='' ">
            and a.unit like '%' + #{unit} + '%'
        </if>
        <if test="startTime!=null and endTime!=null">
            and a.modi_time between #{startTime} and #{endTime}
        </if>
        <if test="memo!=null and memo!='' ">
            and (
               a.loc_no like '%' + #{memo} + '%'
            or a.mat_no like '%' + #{memo} + '%'
            or a.mat_name like '%' + #{memo} + '%'
            or a.qty like '%' + #{memo} + '%'
            or a.str3 like '%' + #{memo} + '%'
            or a.unit like '%' + #{memo} + '%'
            or a.specs like '%' + #{memo} + '%'
            or a.size like '%' + #{memo} + '%'
            or a.color like '%' + #{memo} + '%'
            or a.supplier like '%' + #{memo} + '%'
            or a.zpallet like '%' + #{memo} + '%'
            or a.source like '%' + #{memo} + '%'
            or a.vendor like '%' + #{memo} + '%'
            or a.qty_box like '%' + #{memo} + '%'
            or a.str3 like '%' + #{memo} + '%'
            or a.str4 like '%' + #{memo} + '%'
            or a.str5 like '%' + #{memo} + '%'
            or a.memo like '%' + #{memo} + '%'
            )
        </if>
        <if test="crnNo!=null and crnNo!='' ">
            and b.crn_no=#{crnNo}
        </if>
    </sql>
 
    <sql id="stockOutCondition1">
    <if test="mat_no!=null and mat_no!='' ">
        and c.mat_no like '%' + #{mat_no} + '%'
    </if>
    <if test="mat_name!=null and mat_name!='' ">
        and c.mat_name like '%' + #{mat_name} + '%'
    </if>
    <if test="supplier!=null and supplier!=''" >
        and c.supplier like '%'+#{supplier}+'%'
    </if>
    <if test="str3!=null and str3!=''" >
        and c.str3 like '%'+#{str3}+'%'
    </if>
    <if test="str4!=null and str4!=''" >
        and c.str4 like '%'+#{str4}+'%'
    </if>
    <if test="memo!=null and memo!='' ">
        and (
        c.mat_no like '%' + #{memo} + '%'
        or c.mat_name like '%' + #{memo} + '%'
        or c.qty like '%' + #{memo} + '%'
        or c.str3 like '%' + #{memo} + '%'
        or c.unit like '%' + #{memo} + '%'
        or c.specs like '%' + #{memo} + '%'
        or c.size like '%' + #{memo} + '%'
        or c.color like '%' + #{memo} + '%'
        or c.supplier like '%' + #{memo} + '%'
        or c.source like '%' + #{memo} + '%'
        or c.vendor like '%' + #{memo} + '%'
        or c.qty_box like '%' + #{memo} + '%'
        or c.str3 like '%' + #{memo} + '%'
        or c.str4 like '%' + #{memo} + '%'
        or c.str5 like '%' + #{memo} + '%'
        or c.memo like '%' + #{memo} + '%'
        )
    </if>
    </sql>
 
    <sql id="stockOutCondition2">
        <if test="matNo!=null and matNo!='' ">
            and mat_no like '%' + #{matNo} + '%'
        </if>
        <if test="matName!=null and matName!='' ">
            and mat_name like '%' + #{matName} + '%'
        </if>
        <if test="supplier!=null and supplier!=''" >
            and supplier like '%'+#{supplier}+'%'
        </if>
        <if test="str3!=null and str3!=''" >
            and str3 like '%'+#{str3}+'%'
        </if>
        <if test="str4!=null and str4!=''" >
            and str4 like '%'+#{str4}+'%'
        </if>
        <if test="memo!=null and memo!='' ">
            and (
            mat_no like '%' + #{memo} + '%'
            or mat_name like '%' + #{memo} + '%'
            or qty like '%' + #{memo} + '%'
            or str3 like '%' + #{memo} + '%'
            or unit like '%' + #{memo} + '%'
            or specs like '%' + #{memo} + '%'
            or size like '%' + #{memo} + '%'
            or color like '%' + #{memo} + '%'
            or supplier like '%' + #{memo} + '%'
            or source like '%' + #{memo} + '%'
            or vendor like '%' + #{memo} + '%'
            or qty_box like '%' + #{memo} + '%'
            or str3 like '%' + #{memo} + '%'
            or str4 like '%' + #{memo} + '%'
            or str5 like '%' + #{memo} + '%'
            or memo like '%' + #{memo} + '%'
            )
        </if>
    </sql>
 
    <select id="getStockOutPage" resultMap="BaseResultMap">
        select * from
        (
            select
            ROW_NUMBER() over (order by a.supplier,a.mat_no,a.loc_no) as row,
            a.*
            from asr_loc_detl a
            left join asr_loc_mast b on a.loc_no = b.loc_no
            where 1=1
            and b.loc_sts = 'F'
            <include refid="stockOutCondition"></include>
        ) t where t.row between ((#{pageNumber}-1)*#{pageSize}+1) and (#{pageNumber}*#{pageSize})
        order by supplier,appe_time,loc_no
    </select>
 
    <select id="getStockOutPageCount" parameterType="java.util.Map" resultType="java.lang.Integer">
        select
        count(1)
        from asr_loc_detl a
        left join asr_loc_mast b on a.loc_no = b.loc_no
        where 1=1
        and b.loc_sts = 'F'
        <include refid="stockOutCondition"></include>
    </select>
 
    <select id="selectLocDetlList" resultMap="BaseResultMap">
        select a.*
        from asr_loc_detl a
        left join asr_loc_mast b on a.loc_no = b.loc_no
        where 1=1
        and b.loc_sts = 'F' and a.mat_no= #{mat_no}
        order by a.appe_time
    </select>
    <select id="selectLocDetlSumQty" resultType="double">
        select SUM(qty) qty
        from asr_loc_detl
        where loc_no=#{locNo}
    </select>
    <select id="getStockStatis" resultMap="BaseResultMap">
        select  * ,str6 as qty_box,(qty * str6) as all_qty from
        (
        select ROW_NUMBER() over (order by a.mat_no) as row,
        a.mat_name,a.mat_no,a.str3,sum(a.qty) qty, specs,unit,color,weight,str4,str5,num1,str6  from
        (
        select
        c.mat_name,c.mat_no,c.str3,c.qty,c.all_qty,c.specs,c.unit,c.color,c.weight,c.str4,c.str5,m.num1,m.str6
        from asr_loc_detl c
        LEFT JOIN bas_mat_code m ON c.mat_no = m.mat_no
        where 1=1
        <include refid="stockOutCondition1"></include>
        ) a
        group by a.mat_no,a.mat_name,a.str3,a.specs,a.unit,a.color,a.weight,a.str4,a.str5,num1,str6
        ) d
        where 1=1
        and row between ((#{pageNumber}-1)*#{pageSize}+1) and (#{pageNumber}*#{pageSize})
        order by mat_no,specs
<!--        select * from-->
<!--        (-->
<!--        select ROW_NUMBER() over (order by a.mat_no) as row,-->
<!--        a.mat_name,a.mat_no,a.supplier,a.str3,sum(a.qty) qty,specs,unit,color,qty_box,weight,str4,str5  from-->
<!--        (-->
<!--        select-->
<!--        mat_name,mat_no,supplier,str3,qty,specs,unit,color,qty_box,weight,str4,str5-->
<!--        from asr_loc_detl c-->
<!--        where 1=1-->
<!--        <include refid="stockOutCondition1"></include>-->
<!--        ) a-->
<!--        group by a.mat_no,a.mat_name,a.supplier,a.str3,a.specs,a.unit,a.color,a.qty_box,a.weight,a.str4,a.str5-->
<!--        ) d-->
<!--        where 1=1-->
<!--        and row between ((#{pageNumber}-1)*#{pageSize}+1) and (#{pageNumber}*#{pageSize})-->
<!--        order by a.mat_no,a.supplier-->
    </select>
    <select id="getStockStatisCount" resultType="integer">
        select count(1) from
        (
        select ROW_NUMBER() over (order by a.mat_no) as row,
        a.mat_name,a.mat_no,a.str3,sum(a.qty) qty, specs,unit,color,qty_box,weight,str4,str5,num1,str6  from
        (
        select
        c.mat_name,c.mat_no,c.str3,c.qty,c.all_qty,c.specs,c.unit,c.color,c.qty_box,c.weight,c.str4,c.str5,m.num1,m.str6
        from asr_loc_detl c
        LEFT JOIN bas_mat_code m ON c.mat_no = m.mat_no
        where 1=1
        <include refid="stockOutCondition1"></include>
        ) a
        group by a.mat_no,a.mat_name,a.str3,a.specs,a.unit,a.color,a.qty_box,a.weight,a.str4,a.str5,num1,str6
        ) d
        where 1=1
 
<!--        select count(1) from-->
<!--        (-->
<!--        select ROW_NUMBER() over (order by a.mat_no) as row,-->
<!--        a.mat_name,a.mat_no,a.supplier,a.str3,sum(a.qty) qty,specs,unit,color,qty_box,weight,str4,str5  from-->
<!--        (-->
<!--        select-->
<!--        mat_name,mat_no,supplier,str3,qty,specs,unit,color,qty_box,weight,str4,str5-->
<!--        from asr_loc_detl c-->
<!--        where 1=1-->
<!--        <include refid="stockOutCondition1"></include>-->
<!--        ) a-->
<!--        group by a.mat_no,a.mat_name,a.supplier,a.str3,a.specs,a.unit,a.color,a.qty_box,a.weight,a.str4,a.str5-->
<!--        ) d-->
    </select>
<!--    <select id="getStockStatisExcel" resultType="com.zy.asrs.entity.LocDetl">-->
    <select id="getStockStatisExcel" resultMap="BaseResultMap">
     select
        ROW_NUMBER() over (order by a.mat_no, sum(a.qty) desc) as row
        , a.mat_no, a.mat_name,a.supplier,str3,specs,unit,color,qty_box as qtyBox,weight,str4,str5
        , sum(a.qty) as qty
        from asr_loc_detl a
        where 1=1
        <include refid="stockOutCondition2"></include>
        group by a.mat_no,a.mat_name,a.supplier,a.str3,a.specs,a.unit,a.color,a.qty_box,a.weight,a.str4,a.str5
    </select>
 
    <sql id="selectAllWarningSql">
        <if test="mat_name != null and mat_name != '' ">
            and c.mat_name like '%' + #{mat_name} + '%'
        </if>
        <if test="mat_no != null and mat_no !='' ">
            and c.mat_no like '%' + #{mat_no} + '%'
        </if>
 
    </sql>
    <select id="selectAllWarning" resultType="com.zy.asrs.entity.LocDetlWarningDTO">
        SELECT
        *,(qty * str6) as all_qty
        FROM
        (
        SELECT
        ROW_NUMBER ( ) OVER ( ORDER BY a.mat_no ) AS row,
        a.mat_name,
        a.mat_no,
        a.str3,
        SUM ( a.qty ) qty,
        specs,
        unit,
        color,
        qty_box,
        weight,
        str4,
        str5,
        num1,
        str6
        FROM
        (
        SELECT
        c.mat_name,
        c.mat_no,
        c.str3,
        c.qty,
        c.all_qty,
        c.specs,
        c.unit,
        c.color,
        c.qty_box,
        c.weight,
        c.str4,
        c.str5,
        m.num1,
        str6
        FROM
        asr_loc_detl c
        LEFT JOIN bas_mat_code m ON c.mat_no = m.mat_no
        WHERE
        1 = 1
        <include refid="selectAllWarningSql"></include>
        ) a
        GROUP BY
        a.mat_no,
        a.mat_name,
        a.str3,
        a.specs,
        a.unit,
        a.color,
        a.qty_box,
        a.weight,
        a.str4,
        a.str5,
        a.num1,
        str6
        ) d
        WHERE
        1 = 1
        AND qty &lt;= num1
        AND d.row BETWEEN ((#{pageNumber}-1)*#{pageSize}+1) and (#{pageNumber}*#{pageSize})
    </select>
 
    <select id="getAllWarningCount" resultType="java.lang.Integer">
        SELECT
            COUNT(1)
        FROM
            (
        SELECT
            ROW_NUMBER ( ) OVER ( ORDER BY a.mat_no ) AS row,
                a.mat_name,
            a.mat_no,
            a.str3,
            SUM ( a.qty ) qty,
            SUM ( all_qty ) all_qty,
            specs,
            unit,
            color,
            qty_box,
            weight,
            str4,
            str5,
            num1
        FROM
            (
            SELECT
                c.mat_name,
                c.mat_no,
                c.str3,
                c.qty,
                c.all_qty,
                c.specs,
                c.unit,
                c.color,
                c.qty_box,
                c.weight,
                c.str4,
                c.str5,
                m.num1
            FROM
                asr_loc_detl c
                    LEFT JOIN bas_mat_code m ON c.mat_no = m.mat_no
            WHERE
                1 = 1
            <include refid="selectAllWarningSql"></include>
            ) a
        GROUP BY
            a.mat_no,
            a.mat_name,
            a.str3,
            a.specs,
            a.unit,
            a.color,
            a.qty_box,
            a.weight,
            a.str4,
            a.str5,
            a.num1
            ) d
        WHERE
            1 = 1
          AND qty &lt;= num1
    </select>
 
 
 
    <!--    <select id="getStockSum" resultMap="BaseResultMap">-->
<!--        select mat_no,mat_name,sum(qty) qty  from asr_loc_detl-->
<!--        group by mat_no,mat_name-->
<!--    </select>-->
 
</mapper>