Browse Source

叫料优先重绕区

xu.lu 8 months ago
parent
commit
72afebc279
1 changed files with 37 additions and 18 deletions
  1. 37 18
      wms.service/Service/FJService.cs

+ 37 - 18
wms.service/Service/FJService.cs

@@ -1022,13 +1022,11 @@ namespace wms.service.Service
                     //TODO:最优验证算法
                 }
 
-                //判断对应仓库中是否存在指定缓存数量的空托盘
-                var invnowCount_1N = _billInvnowrepository.AsQueryable().With(SqlWith.NoLock).Count(x =>
-                    x.ContGrpType == FJContGrpType.Material && x.InvStateCode == InvState.InvEcecState_In.ToString() &&
-                    x.WarehouseId == 1688761422269517825);
-                var invnowCount_2N = _billInvnowrepository.AsQueryable().With(SqlWith.NoLock).Count(x =>
-                    x.ContGrpType == FJContGrpType.Material && x.InvStateCode == InvState.InvEcecState_In.ToString() &&
-                    x.WarehouseId == 1703345891785707520);
+                //判断对应仓库中空货位数量
+                var invnowCount_1N = _basewarecellrepository.AsQueryable().With(SqlWith.NoLock).Count(x =>
+                    x.WarehouseCode == "1N" && x.IsStop == 0 && x.StateNum == FjLocationState.Empty && x.Layer < 9);
+                var invnowCount_2N = _basewarecellrepository.AsQueryable().With(SqlWith.NoLock).Count(x =>
+                    x.WarehouseCode == "2N" && x.IsStop == 0 && x.StateNum == FjLocationState.Empty && x.Layer < 9);
                 var taskInfoCount_1N = _taskrepository.AsQueryable().With(SqlWith.NoLock).Count(x =>
                     x.Status < TaskStatus.Finish && x.BusType == FJTaskBusType.人工满托入库.GetDescription() &&
                     x.WarehouseCode == "1N");
@@ -1036,9 +1034,9 @@ namespace wms.service.Service
                     x.Status < TaskStatus.Finish && x.BusType == FJTaskBusType.人工满托入库.GetDescription() &&
                     x.WarehouseCode == "2N");
                 //创建对应任务
-                var count_1N = invnowCount_1N + taskInfoCount_1N;
-                var count_2N = invnowCount_2N + taskInfoCount_2N;
-                var wCode = count_1N <= count_2N ? "1N" : "2N";
+                var count_1N = invnowCount_1N - taskInfoCount_1N;
+                var count_2N = invnowCount_2N - taskInfoCount_2N;
+                var wCode = count_1N >= count_2N ? "1N" : "2N";
                 if (taskMax > 0 && taskCount > 0)
                     if ((wCode == "1N" && taskMax <= taskInfoCount_1N) ||
                         (wCode == "2N" && taskMax <= taskInfoCount_2N))
@@ -1567,7 +1565,7 @@ namespace wms.service.Service
             if (taskInfo != null)
             {
                 res.ResCode = ResponseStatusCodeEnum.Fail.GetHashCode();
-                res.ResMsg = reqDto.TrayCode + "已有任务,请联系智能制造人员进行处理!!!!!!";
+                res.ResMsg = reqDto.TrayCode + "已有任务,不要重复申请,请联系智能制造人员确认处理!!!!!!";
                 return res;
             }
 
@@ -2184,11 +2182,26 @@ namespace wms.service.Service
                     return res;
                 }
 
-                //找到所有的立库/虚拟货位
                 var warehouse = _basewarehouserepository
-                    .GetList(x =>
-                        x.TypeNum == FjLocationType.Storage || x.TypeNum == FjLocationType.Virtual ||
-                        x.TypeNum == FjLocationType.Pingku).Select(x => x.Id).ToList();
+                    .GetList(x =>x.TypeNum == FjLocationType.Storage).Select(x => x.Id).ToList();
+                //判断平库是否有该物料,如有先取平库料
+                var sotck1 = _billInvnowrepository.AsQueryable().With(SqlWith.NoLock).Where(x => x.WarehouseId == 1703346265607246828 && x.MatCode == reqDto.Materialcodecall && x.InvStateCode ==
+                InvState.InvEcecState_In.ToString()).First();
+                if (sotck1 != null && _basewarecellrepository.AsQueryable().With(SqlWith.NoLock).Any(x => x.ContGrpBarCode == sotck1.ContGrpBarCode && x.IsStop == 0 && x.StateNum == FjLocationState.Full))
+                {
+                    warehouse = _basewarehouserepository
+                   .GetList(x => x.TypeNum == FjLocationType.Pingku).Select(x => x.Id).ToList();
+                }
+                else
+                {
+                    //找到所有的立库/虚拟货位/平库货位
+                    warehouse = _basewarehouserepository
+                   .GetList(x =>
+                       x.TypeNum == FjLocationType.Storage || x.TypeNum == FjLocationType.Virtual
+                       ).Select(x => x.Id).ToList();
+                }
+                 
+                
                 var task = _wcstaskoldrepository.AsQueryable().With(SqlWith.NoLock)
                     .Where(p => p.WorkBench == mach.Station && p.Status < TaskStatus.Finish)
                     .SplitTable(tabs => tabs.Take(2));
@@ -4263,6 +4276,12 @@ namespace wms.service.Service
                 {
                     var bomsetGrp =
                         _billBomsetgrpRepository.GetFirst(x => x.IsStop == 0 && x.BomCode.Contains(wcsTask.MatCode));
+                    if (bomsetGrp == null)
+                    {
+                        res.ResCode = ResponseStatusCodeEnum.Fail.GetHashCode();
+                        res.ResMsg = "未找到对应垛型信息,请确认是否被禁用";
+                        return res;
+                    }
                     var xyNo = _billBomsetinfoRepository.GetList(x => x.BomSetHdrId == bomsetGrp.Id && x.IsEmpty == 0)
                         .ToList().Select(x => Convert.ToInt32(x.XYNo)).OrderByDescending(x => x).First();
                     //跟据垛形信息生成
@@ -6040,7 +6059,7 @@ namespace wms.service.Service
                 ResData = new FJApplyStockInLocResponse()
             };
 
-            //检任务是否异常
+            //检任务是否异常
             var wcstask = _wcstaskoldrepository.AsQueryable().With(SqlWith.NoLock).Where(p => p.Id == reqEntity.TaskNum)
                 .SplitTable(tabs => tabs.Take(2)).First();
             ;
@@ -6264,7 +6283,7 @@ namespace wms.service.Service
                 ResMsg = ResponseStatusCodeEnum.Sucess.GetDescription(),
                 ResData = new FJApplyStockInLocResponse()
             };
-            //检任务是否异常
+            //检任务是否异常
             var wcstask = _wcstaskoldrepository.AsQueryable().With("WITH(READPAST,ROWLOCK)")
                 .Where(p => p.Id == reqEntity.TaskNum).SplitTable(tabs => tabs.Take(2)).First();
             ;
@@ -7250,7 +7269,7 @@ namespace wms.service.Service
                 case TaskType.SetPlate:
                     try
                     {
-                        //检库存信息是否正确
+                        //检库存信息是否正确
                         var stock = _billInvnowrepository.GetFirst(p =>
                             p.ContGrpBarCode == task.BarCode || p.HWBarCode == task.BarCode);
                         if (stock == null)