mengshunguo 3 months ago
parent
commit
9a6feb459d
1 changed files with 6 additions and 9 deletions
  1. 6 9
      SCADA_DAQ/Customer/Service/Wcs_WmsService.cs

+ 6 - 9
SCADA_DAQ/Customer/Service/Wcs_WmsService.cs

@@ -262,13 +262,10 @@ namespace SCADA_DAQ.Customer.Service
             {
                 var inventory = inventoryList.Where(i => i.ItemCode == task.ItemCode && i.WarehouseCode == task.WarehouseCode && i.Qty > 0).FirstOrDefault();
                 decimal? actualQty = 0m;
-                if (inventory != null)
+                if (inventory != null && inventory?.Qty >= task.Qty)
                 {
-                    if (inventory.Qty >= task.Qty)
-                    {
-                        actualQty = task.Qty;
-                        inventory.Qty -= actualQty;
-                    }
+                    actualQty = task.Qty;
+                    inventory.Qty -= actualQty;
                 }
                 taskNos = $"{taskNos} {task.No} ";
                 var newTask = new AppBCItemTaskModel
@@ -320,7 +317,7 @@ namespace SCADA_DAQ.Customer.Service
             });
             wmsTasks.Sort((item1, item2) => item1.TaskNo.CompareTo(item2.TaskNo)); //排序
             var dbRes = Env.DAL.Insert(wmsTasks);
-            wmsUpLoadService(wmsHaveSourceLocationTask);
+            wmsUpLoad(wmsHaveSourceLocationTask);
             Log.Info(taskNos);
             if (dbRes.IsSucceed == true)
             {
@@ -336,9 +333,9 @@ namespace SCADA_DAQ.Customer.Service
         /// 回传任务信息
         /// </summary>
         /// <param name="task"></param>
-        public static void wmsUpLoadService(List<AppBCItemTaskModel> task)
+        public static void wmsUpLoad(List<AppBCItemTaskModel> task)
         {
-            var sourceLocations = task.Select(i => i.SourceLocation).ToList();
+            var sourceLocations = task.ToLookup(i=>i.SourceLocation).Select(j=>j.Key).ToList();
             AddDeviceTaskList(sourceLocations);
         }