From 79edfec1f6e6789d3f6cc57db3cb0cfdffd64c32 Mon Sep 17 00:00:00 2001
From: chen.lin <1442464845@qq.com>
Date: 星期二, 24 二月 2026 15:50:32 +0800
Subject: [PATCH] 库位拣料出库数量调整

---
 rsf-server/src/main/resources/mapper/manager/LocItemMapper.xml |  123 ++++++++++++++++++++++++----------------
 1 files changed, 73 insertions(+), 50 deletions(-)

diff --git a/rsf-server/src/main/resources/mapper/manager/LocItemMapper.xml b/rsf-server/src/main/resources/mapper/manager/LocItemMapper.xml
index 852c4b5..e400a7a 100644
--- a/rsf-server/src/main/resources/mapper/manager/LocItemMapper.xml
+++ b/rsf-server/src/main/resources/mapper/manager/LocItemMapper.xml
@@ -1,56 +1,79 @@
 <?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="pageByStock" resultType="com.vincent.rsf.server.manager.entity.LocItem">
-        SELECT *
-        FROM (SELECT id,
-                     loc_id,
-                     loc_code,
-                     type,
-                     order_item_id,
-                     wk_type,
-                     matnr_id,
-                     maktx,
-                     matnr_code,
-                     unit,
-                     SUM(anfme)    anfme,
-                     SUM(qty)      qty,
-                     SUM(work_qty) work_qty,
-                     batch,
-                     spec,
-                     model,
-                     fields_index,
-                     update_by,
-                     create_by,
-                     update_time,
-                     create_time
-              FROM man_loc_item
-              GROUP BY matnr_id
-              UNION ALL
-              SELECT id,
-                     ''          AS loc_id,
-                     ''          AS loc_code,
-                     type,
-                     asn_item_id AS order_item_id,
-                     wk_type,
-                     matnr_id,
-                     maktx,
-                     matnr_code,
-                     unit,
-                     SUM(anfme)     anfme,
-                     SUM(qty)       qty,
-                     SUM(work_qty)  work_qty,
-                     batch,
-                     spec,
-                     model,
-                     fields_index,
-                     update_by,
-                     create_by,
-                     update_time,
-                     create_time
-              FROM man_warehouse_areas_item
-              GROUP BY matnr_id) t
-                ${ew.customSqlSegment}
+    <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>
+
+    <!-- 鎸夌墿鏂�+鐘舵��+搴撲綅鍒嗙粍锛氭瘡琛屼竴涓簱浣嶅強鍏舵暟閲忥紝姹囨�讳笌鎷兼帴鍦� Java 涓畬鎴愪互鍑忚交搴撳帇鍔� -->
+    <select id="listStockByMatnrIdsGroupByStatusAndLoc" resultType="java.util.HashMap">
+        SELECT
+            li.matnr_id AS matnrId,
+            l.use_status AS useStatus,
+            li.loc_code AS locCode,
+            COALESCE(SUM(li.anfme), 0) AS locQty
+        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, l.use_status, li.loc_code
+        ORDER BY li.matnr_id, l.use_status, li.loc_code
     </select>
 </mapper>

--
Gitblit v1.9.1