|  | @@ -7,6 +7,7 @@ using AutoMapper;
 | 
	
		
			
				|  |  |  using Castle.Core.Internal;
 | 
	
		
			
				|  |  |  using Microsoft.Extensions.Logging;
 | 
	
		
			
				|  |  |  using Newtonsoft.Json;
 | 
	
		
			
				|  |  | +using NPOI.SS.Formula.Functions;
 | 
	
		
			
				|  |  |  using SqlSugar;
 | 
	
		
			
				|  |  |  using SqlSugar.Extensions;
 | 
	
		
			
				|  |  |  using WCS.Entity.fj;
 | 
	
	
		
			
				|  | @@ -825,6 +826,8 @@ namespace wms.service.Service
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              var taskMax = Convert.ToInt32(_sysconfigrepository.AsQueryable().With(SqlWith.NoLock)
 | 
	
		
			
				|  |  |                  .First(x => x.Code == "FullPalletInMax").SContent);
 | 
	
		
			
				|  |  | +            //var station_Use = _sysconfigrepository.AsQueryable().With(SqlWith.NoLock)
 | 
	
		
			
				|  |  | +            //    .First(x => x.Code == "InStation" && x.SContent == "1").Name;
 | 
	
		
			
				|  |  |              var taskCount = _taskrepository.AsQueryable().With(SqlWith.NoLock).Count(x =>
 | 
	
		
			
				|  |  |                  x.BusType == FJTaskBusType.人工满托入库.GetDescription() && x.Status < TaskStatus.Finish);
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -1027,25 +1030,52 @@ namespace wms.service.Service
 | 
	
		
			
				|  |  |                      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 invnowCount_1S = _basewarecellrepository.AsQueryable().With(SqlWith.NoLock).Count(x =>
 | 
	
		
			
				|  |  | +                    x.WarehouseCode == "1S" && x.IsStop == 0 && x.StateNum == FjLocationState.Empty && x.Layer < 9);
 | 
	
		
			
				|  |  | +                var invnowCount_2S = _basewarecellrepository.AsQueryable().With(SqlWith.NoLock).Count(x =>
 | 
	
		
			
				|  |  | +                    x.WarehouseCode == "2S" && 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");
 | 
	
		
			
				|  |  |                  var taskInfoCount_2N = _taskrepository.AsQueryable().With(SqlWith.NoLock).Count(x =>
 | 
	
		
			
				|  |  |                      x.Status < TaskStatus.Finish && x.BusType == FJTaskBusType.人工满托入库.GetDescription() &&
 | 
	
		
			
				|  |  |                      x.WarehouseCode == "2N");
 | 
	
		
			
				|  |  | +                var taskInfoCount_1S = _taskrepository.AsQueryable().With(SqlWith.NoLock).Count(x =>
 | 
	
		
			
				|  |  | +                    x.Status < TaskStatus.Finish && x.BusType == FJTaskBusType.人工满托入库.GetDescription() &&
 | 
	
		
			
				|  |  | +                    x.WarehouseCode == "1S");
 | 
	
		
			
				|  |  | +                var taskInfoCount_2S = _taskrepository.AsQueryable().With(SqlWith.NoLock).Count(x =>
 | 
	
		
			
				|  |  | +                    x.Status < TaskStatus.Finish && x.BusType == FJTaskBusType.人工满托入库.GetDescription() &&
 | 
	
		
			
				|  |  | +                    x.WarehouseCode == "2S");
 | 
	
		
			
				|  |  |                  //创建对应任务
 | 
	
		
			
				|  |  |                  var count_1N = invnowCount_1N - taskInfoCount_1N;
 | 
	
		
			
				|  |  |                  var count_2N = invnowCount_2N - taskInfoCount_2N;
 | 
	
		
			
				|  |  | -                var wCode = count_1N >= count_2N ? "1N" : "2N";
 | 
	
		
			
				|  |  | +                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);//count_1N >= count_2N ? "1N" : "2N";
 | 
	
		
			
				|  |  |                  if ( taskCount > 0)
 | 
	
		
			
				|  |  |                      if ((wCode == "1N" && taskMax <= taskInfoCount_1N) ||
 | 
	
		
			
				|  |  | -                        (wCode == "2N" && taskMax <= taskInfoCount_2N))
 | 
	
		
			
				|  |  | +                        (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 (station_Use != null && !string.IsNullOrEmpty(station_Use))
 | 
	
		
			
				|  |  | +                //{
 | 
	
		
			
				|  |  | +                //    if (station_Use == "2535")
 | 
	
		
			
				|  |  | +                //    {
 | 
	
		
			
				|  |  | +                //        wCode = "1N";
 | 
	
		
			
				|  |  | +                //    }
 | 
	
		
			
				|  |  | +                //    else if (station_Use == "2735")
 | 
	
		
			
				|  |  | +                //    {
 | 
	
		
			
				|  |  | +                //        wCode = "1S";
 | 
	
		
			
				|  |  | +                //    }
 | 
	
		
			
				|  |  | +                //}
 | 
	
		
			
				|  |  |                  //创建入库记录
 | 
	
		
			
				|  |  |                  var createStockInWcsTaskReqest = new FJCreateStockInWcsTaskRequest
 | 
	
		
			
				|  |  |                  {
 | 
	
	
		
			
				|  | @@ -1087,6 +1117,28 @@ namespace wms.service.Service
 | 
	
		
			
				|  |  |              return res;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        public string Max(int count_1N,int count_1S, int count_2N, int count_2S)
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +            string wareHouse = "1N";
 | 
	
		
			
				|  |  | +            int max = count_1N;
 | 
	
		
			
				|  |  | +            if (count_1S > max)
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                max = count_1S;
 | 
	
		
			
				|  |  | +                wareHouse = "1S";
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (count_2N > max)
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                max = count_2N;
 | 
	
		
			
				|  |  | +                wareHouse = "2N";
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (count_2S > max)
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                max = count_2S;
 | 
	
		
			
				|  |  | +                wareHouse = "2S";
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            return wareHouse;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          /// <summary>
 | 
	
		
			
				|  |  |          ///     人工创建UT满托入库任务
 | 
	
		
			
				|  |  |          /// </summary>
 | 
	
	
		
			
				|  | @@ -1692,14 +1744,14 @@ namespace wms.service.Service
 | 
	
		
			
				|  |  |                  if (stock != null && stock.InvStateCode == InvState.InvEcecState_In.ToString())
 | 
	
		
			
				|  |  |                  {
 | 
	
		
			
				|  |  |                      res.ResCode = ResponseStatusCodeEnum.Fail.GetHashCode();
 | 
	
		
			
				|  |  | -                    res.ResMsg = "该工字轮条码号已在库中,请检查工字轮条码号是否重复";
 | 
	
		
			
				|  |  | +                    res.ResMsg = $"工字轮条码{spool.SpoolCode}已在库中,请检查工字轮条码号是否重复";
 | 
	
		
			
				|  |  |                      return res;
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  if (stock != null && stock.InvStateCode == InvState.InvEcecState_OutGoing.ToString())
 | 
	
		
			
				|  |  |                  {
 | 
	
		
			
				|  |  |                      res.ResCode = ResponseStatusCodeEnum.Fail.GetHashCode();
 | 
	
		
			
				|  |  | -                    res.ResMsg = "该工字轮条码号存在出库中任务,请检查上一个任务是否已经完成";
 | 
	
		
			
				|  |  | +                    res.ResMsg = $"工字轮条码{spool.SpoolCode}存在出库中任务,请检查上一个任务是否已经完成";
 | 
	
		
			
				|  |  |                      return res;
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -1897,7 +1949,7 @@ namespace wms.service.Service
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              //托盘库存
 | 
	
		
			
				|  |  | -            var trayCode = _billInvnowrepository.GetSingle(p => p.ContGrpBarCode == reqDto.TrayCode);
 | 
	
		
			
				|  |  | +            var trayCode = _billInvnowrepository.GetFirst(p => p.ContGrpBarCode == reqDto.TrayCode);
 | 
	
		
			
				|  |  |              if (trayCode != null && trayCode.InvStateCode == InvState.InvEcecState_In.ToString())
 | 
	
		
			
				|  |  |              {
 | 
	
		
			
				|  |  |                  res.ResCode = ResponseStatusCodeEnum.Fail.GetHashCode();
 | 
	
	
		
			
				|  | @@ -1912,6 +1964,13 @@ namespace wms.service.Service
 | 
	
		
			
				|  |  |                  return res;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +            if (trayCode != null && trayCode.InvStateCode == InvState.InvEcecState_BuildUp.ToString())
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                res.ResCode = ResponseStatusCodeEnum.Fail.GetHashCode();
 | 
	
		
			
				|  |  | +                res.ResMsg = "该托盘条码号存在已组盘中任务,请检查库存信息";
 | 
	
		
			
				|  |  | +                return res;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              var mac = _basemachinforepository.GetFirst(x => x.MachNo == reqDto.LocCode);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              try
 | 
	
	
		
			
				|  | @@ -8750,8 +8809,14 @@ namespace wms.service.Service
 | 
	
		
			
				|  |  |                          var wareHouse = _basewarehouserepository.GetSingle(x => x.Id == stocklist.First().WarehouseId);
 | 
	
		
			
				|  |  |                          if (wareHouse.TypeNum == FjLocationType.Pingku)
 | 
	
		
			
				|  |  |                          {
 | 
	
		
			
				|  |  | -                            _db.BeginTran();                          
 | 
	
		
			
				|  |  | -                            _billInvinitrepository.Delete(x => x.ContGrpBarCode == task.BarCode && x.InvStateCode == InvState.InvEcecState_BuildUp.ToString());                          
 | 
	
		
			
				|  |  | +                            _db.BeginTran();                                                     
 | 
	
		
			
				|  |  | +                            _billInvnowrepository.Delete(p => p.ContGrpBarCode == task.BarCode && p.InvStateCode == InvState.InvEcecState_BuildUp.ToString());
 | 
	
		
			
				|  |  | +                           
 | 
	
		
			
				|  |  | +                            //_billInvinitrepository.Delete(p =>
 | 
	
		
			
				|  |  | +                            //    hWBarCode.Contains(p.HWBarCode) &&
 | 
	
		
			
				|  |  | +                            //    p.InvStateCode == InvState.InvEcecState_OutGoing.ToString());
 | 
	
		
			
				|  |  | +                            //contGrpBarCode = stocklist.Select(p => p.ContGrpBarCode).ToList();
 | 
	
		
			
				|  |  | +                          
 | 
	
		
			
				|  |  |                              _db.CommitTran();                           
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  |                      }
 |