From 319c4fe3fb3656ba33903d8c9364ae3d548dd038 Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期四, 06 三月 2025 09:33:29 +0800
Subject: [PATCH] 2

---
 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
index efea336..cad83fa 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
@@ -1251,6 +1251,18 @@
     private async Task<DtStockInfo> QueryStockInfoForRealTrayAsync(string areaCode, List<string> devices, string productionLine)
     {
         var area = await _areaInfoRepository.QueryFirstAsync(x => x.AreaCode == areaCode);
+        if (area == null)
+        {
+            ConsoleHelper.WriteErrorLine($"鏌ヨ瀹炵洏搴撳瓨淇℃伅鏃�,鏈壘鍒板尯鍩熶唬鐮佷负{areaCode}鐨勬暟鎹�");
+            return null;
+        }
+
+        var outBoundMateriel = AppSettings.app<OutBoundMateriel>("OutBoundMateriel");
+        List<string> materielCodes = null;
+        if (outBoundMateriel.Count != 0)
+        {
+            materielCodes = outBoundMateriel.Where(x => x.ProductionLine == productionLine && x.ProcessCode == area.AreaCode).Select(x => x.MaterielCode).ToList();
+        }
 
         var result = await _stockInfoRepository.Db.Queryable<DtStockInfo>()
             .Includes(x => x.LocationInfo) // 棰勫姞杞絃ocationInfo
@@ -1259,6 +1271,7 @@
             .WhereIF(!productionLine.IsNullOrEmpty(), x => x.ProductionLine == productionLine)
             .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && x.LocationInfo.AreaId == area.AreaID && x.LocationInfo.EnalbeStatus == (int)EnableEnum.Enable) // 杩囨护鏉′欢
             .WhereIF(!devices.IsNullOrEmpty(), x => devices.Contains(x.LocationInfo.RoadwayNo))
+            .WhereIF(!materielCodes.IsNullOrEmpty(), x => x.StockInfoDetails.Any(y => materielCodes.Contains(y.MaterielCode)))
             .OrderBy(x => x.OutboundTime) // 鎺掑簭
             .FirstAsync(); // 鑾峰彇绗竴涓厓绱�
 
@@ -1280,6 +1293,14 @@
             return null;
         }
 
+
+        var outBoundMateriel = AppSettings.app<OutBoundMateriel>("OutBoundMateriel");
+        List<string> materielCodes = null;
+        if (outBoundMateriel.Count != 0)
+        {
+            materielCodes = outBoundMateriel.Where(x => x.ProductionLine == productionLine && x.ProcessCode == areaCodes[0]).Select(x => x.MaterielCode).ToList();
+        }
+
         var devices = SqlSugarHelper.DbWCS.Queryable<Dt_DeviceInfo>()
             .Where(x => x.DeviceStatus == "1")
             .Where(x => x.DeviceCode.Contains("CWSC"))
@@ -1293,6 +1314,7 @@
             .WhereIF(!productionLine.IsNullOrEmpty(), x => x.ProductionLine == productionLine)
             .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && areaId.Contains(x.LocationInfo.AreaId) && x.LocationInfo.EnalbeStatus == (int)EnableEnum.Enable) // 杩囨护鏉′欢
             .WhereIF(!deviceCode.IsNullOrEmpty(), x => deviceCode.Contains(x.LocationInfo.RoadwayNo))
+            .WhereIF(!materielCodes.IsNullOrEmpty(), x => x.StockInfoDetails.Any(y => materielCodes.Contains(y.MaterielCode)))
             .OrderBy(x => x.OutboundTime) // 鎺掑簭
             .FirstAsync(); // 鑾峰彇绗竴涓厓绱�
 

--
Gitblit v1.9.3