From 88fe391fb9ca2ccb25ab70f945e2190b95a11fb9 Mon Sep 17 00:00:00 2001
From: xxyy <cathay_xy@163.com>
Date: 星期三, 05 三月 2025 10:45:07 +0800
Subject: [PATCH] 更新配置和数据模型,添加物料管理功能

---
 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs |   47 +++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 41 insertions(+), 6 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 d25b73b..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
@@ -896,7 +896,7 @@
                 List<string> strings = stationManagers.Roadway.Split(',').ToList();
                 Console.WriteLine(strings.ToJsonString() + "b-----------------------");
                 //// 璋冪敤CreateNewTask鏂规硶锛屽垱寤烘柊浠诲姟
-                content = await CreateNewTask(input, result.ProductionLine,result.ProcessCode, strings);
+                content = await CreateNewTask(input, result.ProductionLine, result.ProcessCode, strings);
                 if (content.Status)
                 {
                     var isBox = await _boxingInfoRepository.AddDataNavAsync(boxing);
@@ -1128,7 +1128,7 @@
             }
             List<string> strings = stationManagers.Roadway.Split(',').ToList();
 
-            return await CreateNewTask(input, result.ProductionLine, result.ProcessCode,strings, 1);
+            return await CreateNewTask(input, result.ProductionLine, result.ProcessCode, strings, 1);
         }
         catch (Exception)
         {
@@ -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,9 +1293,17 @@
             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.DeviceRemark == "1")
+            .Where(x => x.DeviceCode.Contains("CWSC"))
             .ToList();
         var deviceCode = devices.Select(x => x.DeviceCode).ToList();
 
@@ -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(); // 鑾峰彇绗竴涓厓绱�
 
@@ -1734,7 +1756,7 @@
                         TaskNum = await BaseDal.GetTaskNo(),
                         Creater = "Systeam",
                         ProductionLine = result.ProductionLine,
-                        ProcessCode=result.ProcessCode,
+                        ProcessCode = result.ProcessCode,
                     };
 
                     // 鍒涘缓WMS浠诲姟
@@ -2105,19 +2127,32 @@
 
             if (stock.IsFull)
             {
+                // 鏌ヨ绗﹀悎鏉′欢鐨勫簱瀛樹俊鎭�
                 var stocks = _stockInfoRepository.QueryData(x => x.AreaCode == stock.AreaCode && x.ProductionLine == stock.ProductionLine && x.SpecialParameterDuration != stock.SpecialParameterDuration);
+
+                // 鏌ヨ浠诲姟淇℃伅
+                var tasks = BaseDal.QueryData(x => x.PalletCode != stock.PalletCode && x.ProductionLine == stock.ProductionLine).Select(x => x.PalletCode).ToList();
+
                 if (stocks != null && stocks.Count > 0)
                 {
-                    foreach (var item in stocks)
+                    // 杩囨护鍑洪渶瑕佹洿鏂扮殑搴撳瓨淇℃伅
+                    var stocksToUpdate = stocks.Where(item => !tasks.Contains(item.PalletCode)).ToList();
+                    foreach (var item in stocksToUpdate)
                     {
+                        // 鏇存柊搴撳瓨淇℃伅鐨勭壒瀹氬弬鏁�
                         item.SpecialParameterDuration = stock.SpecialParameterDuration;
                         item.ParameterInfos = stock.ParameterInfos;
                         item.OutboundTime = Convert.ToDateTime(item.LinedProcessFeedbackTime == null ? item.CreateDate : item.LinedProcessFeedbackTime).AddHours(Convert.ToDouble(stock.SpecialParameterDuration));
                     }
-                    var isUpdates = await _stockInfoRepository.UpdateDataAsync(stocks);
+                    if (stocksToUpdate.Count > 0)
+                    {
+                        // 寮傛鏇存柊搴撳瓨淇℃伅
+                        var isUpdates = await _stockInfoRepository.UpdateDataAsync(stocksToUpdate);
+                    }
                 }
             }
 
+
             // 娣诲姞鍘嗗彶浠诲姟
             var isTaskHtyAdd = await _task_HtyRepository.AddDataAsync(taskHty) > 0;
 

--
Gitblit v1.9.3