chen.lin
19 小时以前 8d5c50656d81dc3eb04a841ecd259adebf99424a
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
<?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.LocItemMapper">
    <select id="listByMatnr" resultType="com.vincent.rsf.server.manager.entity.LocItem">
        SELECT
            *
        FROM
            (
                SELECT
                    li.id,
                    li.loc_id,
                    li.loc_code,
                    l.barcode,
                    l.channel,
                    li.matnr_id,
                    li.matnr_code,
                    li.maktx,
                    li.batch,
                    li.unit,
                    SUM( li.anfme ) anfme,
                    li.fields_index
                FROM
                    man_loc_item li
                        INNER JOIN man_loc l ON l.id = li.loc_id
                    WHERE l.use_status = #{type}
                    <if test="channel != null">
                        AND l.channel = #{channel}
                    </if>
                GROUP BY
                    loc_id,
                    matnr_id,
                    batch,
                    fields_index
            )t
            ${ew.customSqlSegment}
    </select>
 
    <select id="listStockByMatnrIds" resultType="java.util.HashMap">
        SELECT
            li.matnr_id AS matnrId,
            COALESCE(SUM(li.anfme), 0) AS stockQty,
            GROUP_CONCAT(DISTINCT li.loc_code ORDER BY li.loc_code) AS locCodes
        <if test="locUseStatus == null or locUseStatus == ''">
            , GROUP_CONCAT(DISTINCT l.use_status ORDER BY l.use_status) AS locStatuses
        </if>
        FROM man_loc_item li
        INNER JOIN man_loc l ON l.id = li.loc_id AND (l.deleted = 0 OR l.deleted IS NULL)
        WHERE li.deleted = 0
        AND li.matnr_id IN
        <foreach collection="matnrIds" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
        <if test="locUseStatus != null and locUseStatus != ''">
            AND l.use_status = #{locUseStatus}
        </if>
        GROUP BY li.matnr_id
    </select>
</mapper>