From fb6414b4ee8ba0d65c037536da5d02eff24f60d0 Mon Sep 17 00:00:00 2001
From: tjx <t2856754968@163.com>
Date: 星期一, 22 十二月 2025 09:33:20 +0800
Subject: [PATCH] 11

---
 StandardPda/MES.Service/service/Warehouse/MesInvItemStocksManager.cs |  106 +++-------------------------------------------------
 1 files changed, 7 insertions(+), 99 deletions(-)

diff --git a/StandardPda/MES.Service/service/Warehouse/MesInvItemStocksManager.cs b/StandardPda/MES.Service/service/Warehouse/MesInvItemStocksManager.cs
index ab4db63..337b325 100644
--- a/StandardPda/MES.Service/service/Warehouse/MesInvItemStocksManager.cs
+++ b/StandardPda/MES.Service/service/Warehouse/MesInvItemStocksManager.cs
@@ -204,6 +204,7 @@
             .Select((stock, item, depot, org, unit) => new
             {
                 stock.IqcStatus,
+                stock.Visible,
                 DepotCode = stock.DepotsCode,
                 depot.DepotName,
                 stock.DepotSectionsCode,
@@ -242,9 +243,13 @@
                 stockStatus = rackingTask?.Code == "200" ? "宸插湪绔嬪簱涓�" : "杩涘叆绔嬪簱鐨勮矾涓�";
             }
 
+            // 鍐荤粨鏍囪瘑涓�1鏃讹紝IqcStatus涓�0锛涘惁鍒欐牴鎹甀qcStatus鍒ゆ柇
+            var iqcStatusValue = x.Visible == 1 ? "0" :
+                (x.IqcStatus == "鐗归噰鐩存帴浣跨敤" || x.IqcStatus == "宸叉" || x.IqcStatus == "鍏嶆" ? "1" : "0");
+
             return new
             {
-                IqcStatus = x.IqcStatus == "宸叉" ? "1" : "0",
+                IqcStatus = iqcStatusValue,
                 ItemType = x.DepotName == "鍘熸潗鏂欎粨" ? "0" : "1",
                 StackCode = rackingTask?.PalletCode,
                 x.DepotCode,
@@ -346,104 +351,7 @@
             }
         };
     }
-
-    /// <summary>
-    ///     鏌ヨ鍙互閫�璐х殑鐗╂枡(鏃х増鏈�,淇濈暀鍏煎)
-    /// </summary>
-    /// <returns>鍙��璐х墿鏂欏簱瀛樺垪琛�</returns>
-    public List<ReturnableStockDto> GetReturnableStocks()
-    {
-        // 浼樺寲鐐�1: 浣跨敤鍘熺敓SQL鍦ㄦ暟鎹簱绔畬鎴愬幓閲嶅拰鎺掑簭锛岄伩鍏嶅叏琛ㄥ姞杞藉埌鍐呭瓨
-        // Oracle 11g浣跨敤ROW_NUMBER()绐楀彛鍑芥暟鑾峰彇姣忎釜鏉$爜鐨勬渶鏂拌褰�
-        var rackingTaskSql = @"
-            SELECT ITEM_BARCODE AS ItemBarcode, PALLETCODE AS PalletCode, CODE AS Code
-            FROM (
-                SELECT ITEM_BARCODE, PALLETCODE, CODE,
-                       ROW_NUMBER() OVER (PARTITION BY ITEM_BARCODE ORDER BY ID DESC) AS RN
-                FROM XB_RACKING_TASK_SYXT_LOG
-                WHERE ITEM_BARCODE IS NOT NULL AND (CODE IS NULL OR CODE != '500')
-            ) WHERE RN = 1";
-
-        var rackingTaskData = Db.Ado.SqlQuery<RackingTaskDto>(rackingTaskSql);
-        
-        if (rackingTaskData == null || !rackingTaskData.Any())
-        {
-            return new List<ReturnableStockDto>();
-        }
-
-        // 浼樺寲鐐�2: 杩囨护null鍊煎苟浣跨敤瀛楀吀鎻愰珮鏉$爜鍖归厤鏁堢巼锛屼粠O(n)闄嶄綆鍒癘(1)
-        var validRackingData = rackingTaskData.Where(x => !string.IsNullOrEmpty(x.ItemBarcode)).ToList();
-        var rackingTaskDict = validRackingData.ToDictionary(x => x.ItemBarcode);
-        var distinctBarcodes = validRackingData.Select(x => x.ItemBarcode).ToList();
-
-        // 浼樺寲鐐�3: 鍦ㄦ暟鎹簱灞傞潰瀹屾垚鍏宠仈鏌ヨ锛屼竴娆℃�ц幏鍙栨墍鏈夐渶瑕佺殑鏁版嵁
-        var queryResult = Db.Queryable<MesInvItemStocks>()
-            .LeftJoin<MesItems>((stock, item) => stock.ItemId == item.Id)
-            .LeftJoin<MesDepots>((stock, item, depot) =>
-                stock.DepotsCode == depot.DepotCode)
-            .LeftJoin<Organize>((stock, item, depot, org) =>
-                item.UseOrg == org.Id.ToString())
-            .LeftJoin<MesUnit>((stock, item, depot, org, unit) =>
-                item.ItemUnit == unit.Id.ToString())
-            .Where((stock, item, depot, org, unit) =>
-                distinctBarcodes.Contains(stock.ItemBarcode) &&
-                stock.Quantity > 0)
-            .Select((stock, item, depot, org, unit) => new
-            {
-                stock.IqcStatus,
-                stock.StackCode,
-                DepotCode = stock.DepotsCode,
-                depot.DepotName,
-                stock.DepotSectionsCode,
-                item.ItemNo,
-                item.ItemName,
-                item.ItemModel,
-                stock.Quantity,
-                item.ItemUnit,
-                ItemUnitName = unit.Fname,
-                stock.IndepDate,
-                OrgCode = org.Fnumber,
-                OrgName = org.Fname,
-                stock.ItemBarcode
-            })
-            .ToList();
-
-        // 浼樺寲鐐�4: 浣跨敤瀛楀吀鏌ユ壘鏇夸唬Where().FirstOrDefault()锛屾彁楂樺尮閰嶆�ц兘
-        var result = queryResult.Select(x =>
-        {
-            rackingTaskDict.TryGetValue(x.ItemBarcode, out var rackingTask);
-
-            string stockStatus = "0";
-            if (rackingTask?.Code != null)
-            {
-                stockStatus = rackingTask.Code == "200" ? "1" : "2";
-            }
-
-            return new ReturnableStockDto
-            {
-                IqcStatus = x.IqcStatus == "宸叉" ? "1" : "0",
-                ItemType = x.DepotName == "鍘熸潗鏂欎粨" ? "0" : "1",
-                StackCode = x.StackCode,
-                DepotCode = x.DepotCode,
-                DepotName = x.DepotName,
-                DepotSectionsCode = x.DepotSectionsCode,
-                ItemNo = x.ItemNo,
-                ItemName = x.ItemName,
-                ItemModel = x.ItemModel,
-                Quantity = x.Quantity,
-                ItemUnit = x.ItemUnit,
-                ItemUnitName = x.ItemUnitName,
-                IndepDate = x.IndepDate,
-                OrgCode = x.OrgCode,
-                OrgName = x.OrgName,
-                ItemBarcode = x.ItemBarcode,
-                StockStatus = stockStatus
-            };
-        }).ToList();
-
-        return result;
-    }
-
+    
     private class RackingTaskDto
     {
         public string ItemBarcode { get; set; }

--
Gitblit v1.9.3