cl
4 天以前 f21530d33ca23aeeba2ef073ac6b64422e4e26ca
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
<?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.vincent.rsf.server.manager.mapper.LocMapper">
 
    <select id="getLocPies" resultType="com.vincent.rsf.server.manager.controller.dto.LocUsageDto">
            SELECT
                use_status AS `name`,
                COUNT(`code`) `value`,
                SUM(loi.anfme) anfme
            FROM
                man_loc l
                INNER JOIN man_loc_item loi ON l.id = loi.loc_id
            WHERE l.deleted = 0 AND loi.deleted = 0
           GROUP BY
                use_status
    </select>
    <select id="getLocDetls" resultType="com.vincent.rsf.server.manager.controller.dto.LocStockDto">
        SELECT
            li.loc_code,
            li.loc_id,
            l.barcode,
            li.matnr_code AS matnr,
            li.matnr_id,
            li.maktx,
            li.spec,
            li.batch,
            SUM(li.anfme) AS anfme,
            li.splr_id,
            li.unit,
            l.update_time
        FROM
            man_loc l
                LEFT JOIN man_loc_item li ON l.id = li.loc_id
        <where>
            l.deleted = 0 AND li.deleted = 0
            <if test="conds != null">
                <if test="conds.code != null and conds.code != ''">
                    AND l.code LIKE CONCAT('%', #{conds.code}, '%')
                </if>
                <if test="conds.barcode != null and conds.barcode != ''">
                    AND l.barcode = #{conds.barcode}
                </if>
                <if test="conds.warehouseId != null">
                    AND l.warehouse_id = #{conds.warehouseId}
                </if>
                <if test="conds.areaId != null">
                    AND l.area_id = #{conds.areaId}
                </if>
                <choose>
                    <when test="conds.matnrCode != null and conds.matnrCode != ''">
                        AND li.matnr_code = #{conds.matnrCode}
                    </when>
                    <when test="conds.matnr != null and conds.matnr != ''">
                        AND li.matnr_code = #{conds.matnr}
                    </when>
                </choose>
                <if test="conds.batch != null and conds.batch != ''">
                    AND li.batch = #{conds.batch}
                </if>
            </if>
        </where>
        GROUP BY
            li.loc_code,
            li.loc_id,
            l.barcode,
            li.matnr_code,
            li.matnr_id,
            li.maktx,
            li.spec,
            li.batch,
            li.splr_id,
            li.unit,
            l.update_time
        ORDER BY
            l.update_time DESC
    </select>
</mapper>