Explorar o código

人工满托入库任务分配

xu.lu hai 5 meses
pai
achega
611088194e
Modificáronse 1 ficheiros con 72 adicións e 48 borrados
  1. 72 48
      wms.service/Service/FJService.cs

+ 72 - 48
wms.service/Service/FJService.cs

@@ -823,8 +823,8 @@ namespace wms.service.Service
             var res = new SRes { ResCode = ResponseStatusCodeEnum.Fail.GetHashCode(), ResMsg = "失败" };
 
 
-            var taskMax = Convert.ToInt32(_sysconfigrepository.AsQueryable().With(SqlWith.NoLock)
-                .First(x => x.Code == "FullPalletInMax").SContent);
+            //var taskMax = Convert.ToInt32(_sysconfigrepository.AsQueryable().With(SqlWith.NoLock)
+            //    .First(x => x.Code == "FullPalletInMax").SContent);
             var sameSideTaskNum = Convert.ToInt32(_sysconfigrepository.AsQueryable().With(SqlWith.NoLock)
                 .First(x => x.Code == "SameSideTaskInNum").SContent);
             //var station_Use = _sysconfigrepository.AsQueryable().With(SqlWith.NoLock)
@@ -1054,51 +1054,76 @@ namespace wms.service.Service
                 var count_1S = invnowCount_1S - taskInfoCount_1S;
                 var count_2S = invnowCount_2S - taskInfoCount_2S;
 
-                var wCode = Max(count_1N,count_1S,count_2N,count_2S);
-                if ( taskCount > 0)
-                    if ((wCode == "1N" && taskMax <= taskInfoCount_1N) ||
-                        (wCode == "1S" && taskMax <= taskInfoCount_1S) ||
-                        (wCode == "2N" && taskMax <= taskInfoCount_2N) ||
-                        (wCode == "2S" && taskMax <= taskInfoCount_2S))
-                    {
-                        res.ResCode = ResponseStatusCodeEnum.Fail.GetHashCode();
-                        res.ResMsg = $"禁止入库,最大入库任务数量已达{taskMax}";
-                        return res;
-                    }
-                if (wCode == "1N" && taskInfoCount_1N > sameSideTaskNum)
+                //获取空货位最多的仓库
+                var wCode = Max(count_1N,count_1S,count_2N,count_2S);               
+                if (taskCount > 0)
                 {
-                    wCode = taskInfoCount_1N > taskInfoCount_1S ? "1S" : "1N";
-                }
-                else if (wCode == "1S" && taskInfoCount_1S > sameSideTaskNum)
-                {
-                    wCode = taskInfoCount_1S > taskInfoCount_1N ? "1N" : "1S";
-                }
-                else if (wCode == "2N" && taskInfoCount_2N > sameSideTaskNum)
-                {
-                    wCode = taskInfoCount_2N > taskInfoCount_2S ? "2S" : "2N";
-                }
-                else if (wCode == "2S" && taskInfoCount_2S > sameSideTaskNum)
-                {
-                    wCode = taskInfoCount_2S > taskInfoCount_2N ? "2N" : "2S";
-                }
-                //增加一个入库口配置,判断是否往这里分配任务
-                var noIn = "";
-                if (wCode == "1N" && noIn.Contains("1N") && !noIn.Contains("1S"))
-                {
-                    wCode = "1S";
-                }
-
-                //if (station_Use != null && !string.IsNullOrEmpty(station_Use))
-                //{
-                //    if (station_Use == "2535")
-                //    {
-                //        wCode = "1N";
-                //    }
-                //    else if (station_Use == "2735")
-                //    {
-                //        wCode = "1S";
-                //    }
-                //}
+                    if ((wCode == "1N" && sameSideTaskNum <= taskInfoCount_1N) || (wCode == "1S" && sameSideTaskNum <= taskInfoCount_1S) ||
+                        (wCode == "2N" && sameSideTaskNum <= taskInfoCount_2N) || (wCode == "2S" && sameSideTaskNum <= taskInfoCount_2S))
+                    {                        
+                        if (wCode == "1N")
+                        {
+                            if (count_1S > count_2N && count_1S > count_2S)
+                            {
+                                wCode = (taskInfoCount_1S < sameSideTaskNum) ? "1S" : (taskInfoCount_2N < sameSideTaskNum ? "2N" : "2S");                                                           
+                            }
+                            else if (count_2N > count_1S && count_2N > count_2S)
+                            {
+                                wCode = (taskInfoCount_2N < sameSideTaskNum) ? "2N" : (taskInfoCount_1S < sameSideTaskNum ? "1S" : "2S");
+                            }
+                            else if (count_2S > count_1S && count_2S > count_2N)
+                            {
+                                wCode = (taskInfoCount_2S < sameSideTaskNum) ? "2S" : (taskInfoCount_1S < sameSideTaskNum ? "1S" : "2N");
+                            }
+                        }
+                        else if (wCode == "1S")
+                        {
+                            if (count_1N > count_2N && count_1N > count_2S && taskInfoCount_1N < sameSideTaskNum)
+                            {
+                                wCode = (taskInfoCount_1N < sameSideTaskNum) ? "1N" : (taskInfoCount_2N < sameSideTaskNum ? "2N" : "2S");
+                            }
+                            else if (count_2N > count_1N && count_2N > count_2S && taskInfoCount_2N < sameSideTaskNum)
+                            {
+                                wCode = (taskInfoCount_2N < sameSideTaskNum) ? "2N" : (taskInfoCount_1N < sameSideTaskNum ? "1N" : "2S");
+                            }
+                            else if (count_2S > count_1N && count_2S > count_2N && taskInfoCount_2S < sameSideTaskNum)
+                            {
+                                wCode = (taskInfoCount_2S < sameSideTaskNum) ? "2S" : (taskInfoCount_1N < sameSideTaskNum ? "1N" : "2N");
+                            }
+                        }
+                        else if (wCode == "2N")
+                        {
+                            if (count_2S > count_1N && count_2S > count_1S && taskInfoCount_2S < sameSideTaskNum)
+                            {
+                                wCode = (taskInfoCount_2S < sameSideTaskNum) ? "2S" : (taskInfoCount_1N < sameSideTaskNum ? "1N" : "1S");
+                            }
+                            else if (count_1N > count_1S && count_1N > count_2S && taskInfoCount_1N < sameSideTaskNum)
+                            {
+                                wCode = (taskInfoCount_1N < sameSideTaskNum) ? "1N" : (taskInfoCount_1S < sameSideTaskNum ? "1S" : "2S");
+                            }
+                            else if (count_1S > count_1N && count_1S > count_2S && taskInfoCount_1S < sameSideTaskNum)
+                            {
+                                wCode = (taskInfoCount_1S < sameSideTaskNum) ? "1S" : (taskInfoCount_2N < sameSideTaskNum ? "1N" : "2S");
+                            }
+                        }
+                        else if (wCode == "2S")
+                        {
+                            if (count_2N > count_1S && count_2N > count_1N && taskInfoCount_2N < sameSideTaskNum)
+                            {
+                                wCode = (taskInfoCount_2N < sameSideTaskNum) ? "2N" : (taskInfoCount_1N < sameSideTaskNum ? "1N" : "1S");
+                            }
+                            else if (count_1N > count_1S && count_1N > count_2N && taskInfoCount_1N < sameSideTaskNum)
+                            {
+                                wCode = (taskInfoCount_1N < sameSideTaskNum) ? "1N" : (taskInfoCount_1S < sameSideTaskNum ? "1S" : "2N");
+                            }
+                            else if (count_1S > count_1N && count_1S > count_2N && taskInfoCount_1S < sameSideTaskNum)
+                            {
+                                wCode = (taskInfoCount_1S < sameSideTaskNum) ? "1S" : (taskInfoCount_2N < sameSideTaskNum ? "1N" : "2N");
+                            }
+                        }
+                    }
+                }                           
+                                   
                 //创建入库记录
                 var createStockInWcsTaskReqest = new FJCreateStockInWcsTaskRequest
                 {
@@ -1111,7 +1136,7 @@ namespace wms.service.Service
                     Type = TaskType.EnterDepot,
                     DocCode = "",
                     WorkBench = task.WorkBench,
-                    WarehouseCode = wCode /*(count_1N <= count_2N) ? "1N" : "2N"*/
+                    WarehouseCode = wCode
                 };
 
                 //下发wcs任务 - 分解方法
@@ -1134,7 +1159,6 @@ namespace wms.service.Service
 
                 return res;
             }
-
             res.ResCode = ResponseStatusCodeEnum.Sucess.GetHashCode();
             res.ResMsg = ResponseStatusCodeEnum.Sucess.ToString();
             return res;