|  | @@ -1351,7 +1351,13 @@ 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_BuildUp.ToString())
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                res.ResCode = ResponseStatusCodeEnum.Fail.GetHashCode();
 | 
	
		
			
				|  |  | +                res.ResMsg = $"{reqDto.TrayCode}已有组盘信息,请确认库存信息";
 | 
	
		
			
				|  |  | +                return res;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |              if (trayCode != null && trayCode.InvStateCode == InvState.InvEcecState_In.ToString())
 | 
	
		
			
				|  |  |              {
 | 
	
		
			
				|  |  |                  res.ResCode = ResponseStatusCodeEnum.Fail.GetHashCode();
 | 
	
	
		
			
				|  | @@ -1368,6 +1374,7 @@ namespace wms.service.Service
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              var SpoolNoGroup = reqDto.SpoolGroup.Select(x => x.SpoolCode).ToList();
 | 
	
		
			
				|  |  |              var stackHeaderSet = new List<BillBomsetgrp>();
 | 
	
		
			
				|  |  | +            var matCodes = "";
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              #region 校验工字轮信息并获取对应垛型
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -1433,15 +1440,25 @@ namespace wms.service.Service
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  //获取垛型主表
 | 
	
		
			
				|  |  |                  var stack = _BillBomsetgrpRepository.GetSingle(p => p.Id == stackDetail.BomSetHdrId && p.IsStop == 0);
 | 
	
		
			
				|  |  | +                var mat = _basematerrepository.GetSingle(p => p.Code == spool.MatCode);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                if (mat != null && string.IsNullOrEmpty(matCodes))
 | 
	
		
			
				|  |  | +                {
 | 
	
		
			
				|  |  | +                    matCodes += mat.Code;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                else if(mat != null && !string.IsNullOrEmpty(matCodes) && !matCodes.Contains(mat.Code))
 | 
	
		
			
				|  |  | +                {
 | 
	
		
			
				|  |  | +                    matCodes += "," + mat.Code;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  |                  stackHeaderSet.Add(stack);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            if (stackHeaderSet.GroupBy(x => x.Id).Count() != 1)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                res.ResCode = ResponseStatusCodeEnum.Fail.GetHashCode();
 | 
	
		
			
				|  |  | -                res.ResMsg = "扫描托盘不属于同一个垛型,请手动处理后重新组盘";
 | 
	
		
			
				|  |  | -                return res;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | +            //if (stackHeaderSet.GroupBy(x => x.Id).Count() != 1)
 | 
	
		
			
				|  |  | +            //{
 | 
	
		
			
				|  |  | +            //    res.ResCode = ResponseStatusCodeEnum.Fail.GetHashCode();
 | 
	
		
			
				|  |  | +            //    res.ResMsg = "扫描托盘不属于同一个垛型,请手动处理后重新组盘";
 | 
	
		
			
				|  |  | +            //    return res;
 | 
	
		
			
				|  |  | +            //}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              #endregion
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -1481,6 +1498,8 @@ namespace wms.service.Service
 | 
	
		
			
				|  |  |                      invnow.ContGrpBarCode = reqDto.TrayCode;
 | 
	
		
			
				|  |  |                      invnow.Id = IdFactory.NewId();
 | 
	
		
			
				|  |  |                      invnow.WarehouseId = wareHouse.Id;
 | 
	
		
			
				|  |  | +                    invnow.MatCode = matCodes;
 | 
	
		
			
				|  |  | +                    invnow.Memo = mater.Code;
 | 
	
		
			
				|  |  |                      invNowList.Add(invnow);
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -2191,12 +2210,14 @@ namespace wms.service.Service
 | 
	
		
			
				|  |  |                      return res;
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                var warehouse = _basewarehouserepository
 | 
	
		
			
				|  |  | -                    .GetList(x =>x.TypeNum == FjLocationType.Storage).Select(x => x.Id).ToList();
 | 
	
		
			
				|  |  | +                var warehouse = reqDto.Grade == "A" ?  _basewarehouserepository
 | 
	
		
			
				|  |  | +                    .GetList(x =>x.TypeNum == FjLocationType.Storage || x.TypeNum == FjLocationType.Virtual).Select(x => x.Id).ToList() : _basewarehouserepository
 | 
	
		
			
				|  |  | +                    .GetList(x => x.TypeNum == FjLocationType.Pingku).Select(x => x.Id).ToList();
 | 
	
		
			
				|  |  |                  //判断平库是否有该物料,如有先取平库料
 | 
	
		
			
				|  |  | -                var sotck1 = _billInvnowrepository.AsQueryable().With(SqlWith.NoLock).Where(x => x.WarehouseId == 1703346265607246826 && x.MatCode == reqDto.Materialcodecall && x.InvStateCode ==
 | 
	
		
			
				|  |  | +                var sotck1 = _billInvnowrepository.AsQueryable().With(SqlWith.NoLock).Where(x => x.WarehouseId == 1703346265607246826 && x.MatCode.Contains(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))
 | 
	
		
			
				|  |  | +                if (sotck1 != null && _basewarecellrepository.AsQueryable().With(SqlWith.NoLock).Any(x => x.ContGrpBarCode == sotck1.ContGrpBarCode && x.IsStop == 0 && x.StateNum == FjLocationState.Full)
 | 
	
		
			
				|  |  | +                    && reqDto.Grade == "B")
 | 
	
		
			
				|  |  |                  {
 | 
	
		
			
				|  |  |                      warehouse = _basewarehouserepository
 | 
	
		
			
				|  |  |                     .GetList(x => x.TypeNum == FjLocationType.Pingku).Select(x => x.Id).ToList();
 | 
	
	
		
			
				|  | @@ -2227,7 +2248,7 @@ namespace wms.service.Service
 | 
	
		
			
				|  |  |                      .Where((loc, inv) => warehouse.Contains(loc.WarehouseId) && loc.IsStop == 0 &&
 | 
	
		
			
				|  |  |                                           loc.StateNum == FjLocationState.Full &&
 | 
	
		
			
				|  |  |                                           inv.InvStateCode == InvState.InvEcecState_In.ToString() &&
 | 
	
		
			
				|  |  | -                                         inv.MatCode == reqDto.Materialcodecall &&
 | 
	
		
			
				|  |  | +                                         inv.MatCode.Contains(reqDto.Materialcodecall) &&
 | 
	
		
			
				|  |  |                                           (!inv.Secondary || inv.ProductTime < DateTime.Now.AddHours(-6)))
 | 
	
		
			
				|  |  |                      .Where((loc, inv) => inv.IsTorsChk == true)
 | 
	
		
			
				|  |  |                      .Select((loc, inv) => new
 | 
	
	
		
			
				|  | @@ -6084,14 +6105,7 @@ namespace wms.service.Service
 | 
	
		
			
				|  |  |                  res.ResCode = ResponseStatusCodeEnum.ErrParam.GetHashCode();
 | 
	
		
			
				|  |  |                  res.ResMsg = "该任务是出库任务,不能分配货位;任务号" + wcstask.Id;
 | 
	
		
			
				|  |  |                  return res;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            if (!string.IsNullOrEmpty(wcstask.AddrTo) && wcstask.AddrTo != "SRM") //如果目标地址不是堆垛机
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                res.ResData.TunnelNum = wcstask.Tunnel;
 | 
	
		
			
				|  |  | -                res.ResData.CellNo = wcstask.AddrTo;
 | 
	
		
			
				|  |  | -                return res;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | +            }          
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              //验证仓库信息
 | 
	
		
			
				|  |  |              var warehouse = _basewarehouserepository.GetFirst(p => p.Code == wcstask.WarehouseCode);
 | 
	
	
		
			
				|  | @@ -6142,22 +6156,18 @@ namespace wms.service.Service
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            //预留货位数量
 | 
	
		
			
				|  |  | -            var emptyLoc = _basewarecellrepository.GetList(p => p.IsStop == 0
 | 
	
		
			
				|  |  | -                                                                && p.StateNum == FjLocationState.Empty
 | 
	
		
			
				|  |  | -                                                                && p.TypeNum == FjLocationType.Storage
 | 
	
		
			
				|  |  | -                                                                && p.WarehouseId == warehouse.Id);
 | 
	
		
			
				|  |  | +          
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              //找到可用货位
 | 
	
		
			
				|  |  |              var loc1ist = _basewarecellrepository.Context
 | 
	
		
			
				|  |  |                  .Queryable<BaseWarecell>()
 | 
	
		
			
				|  |  |                  .Where(loc1 => loc1.IsStop == 0
 | 
	
		
			
				|  |  |                                 && loc1.StateNum == FjLocationState.Empty
 | 
	
		
			
				|  |  | -                               && loc1.TypeNum == FjLocationType.Storage
 | 
	
		
			
				|  |  | -                               && loc1.Tunnel == reqEntity.TunnelNum
 | 
	
		
			
				|  |  | +                               && loc1.TypeNum == FjLocationType.Pingku
 | 
	
		
			
				|  |  | +                               && loc1.Code == reqEntity.PickUpEquipmentNo
 | 
	
		
			
				|  |  |                                 && loc1.WarehouseId == warehouse.Id
 | 
	
		
			
				|  |  |                                 && loc1.Depth == 1)
 | 
	
		
			
				|  |  | -                .Where(loc1 => loc1.Tunnel == reqEntity.TunnelNum)
 | 
	
		
			
				|  |  | +                //.Where(loc1 => loc1.Tunnel == reqEntity.TunnelNum)
 | 
	
		
			
				|  |  |                  .Select(loc1 => new
 | 
	
		
			
				|  |  |                  {
 | 
	
		
			
				|  |  |                      loc1.Code,
 | 
	
	
		
			
				|  | @@ -7353,6 +7363,7 @@ namespace wms.service.Service
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                      try
 | 
	
		
			
				|  |  |                      {
 | 
	
		
			
				|  |  | +                        //退料
 | 
	
		
			
				|  |  |                          if (isBackRewind)
 | 
	
		
			
				|  |  |                          {
 | 
	
		
			
				|  |  |                              var warehouse = _basewarehouserepository.GetSingle(p => p.Code == task.WarehouseCode);
 | 
	
	
		
			
				|  | @@ -7361,13 +7372,42 @@ namespace wms.service.Service
 | 
	
		
			
				|  |  |                              {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                              }
 | 
	
		
			
				|  |  | -                            else
 | 
	
		
			
				|  |  | +                            else if(task.AddrTo.StartsWith("92"))//退料缓存区
 | 
	
		
			
				|  |  |                              {
 | 
	
		
			
				|  |  | +                                //检查库存信息是否正确
 | 
	
		
			
				|  |  | +                                var stock = _billInvnowrepository.GetFirst(p =>
 | 
	
		
			
				|  |  | +                                    (p.ContGrpBarCode == task.BarCode || p.HWBarCode == task.BarCode)
 | 
	
		
			
				|  |  | +                                    && p.InvStateCode == InvState.InvEcecState_BuildUp.ToString());
 | 
	
		
			
				|  |  | +                                if (stock == null)
 | 
	
		
			
				|  |  | +                                {
 | 
	
		
			
				|  |  | +                                    result.ResMsg = task.BarCode + "没有已组盘的信息";
 | 
	
		
			
				|  |  | +                                    return result;
 | 
	
		
			
				|  |  | +                                }                             
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +                                //更新库存
 | 
	
		
			
				|  |  | +                                _billInvnowrepository.UpdateModelColumns(p => new BillInvnow
 | 
	
		
			
				|  |  | +                                {
 | 
	
		
			
				|  |  | +                                    InvStateCode = InvState.InvEcecState_In.ToString(),
 | 
	
		
			
				|  |  | +                                    WarehouseId = warehouse.Id,
 | 
	
		
			
				|  |  | +                                    OneInTime = DateTime.Now,
 | 
	
		
			
				|  |  | +                                    EditTime = DateTime.Now
 | 
	
		
			
				|  |  | +                                },
 | 
	
		
			
				|  |  | +                                 p => p.ContGrpBarCode == task.BarCode &&
 | 
	
		
			
				|  |  | +                                 p.InvStateCode == InvState.InvEcecState_BuildUp.ToString());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                                //更新货位
 | 
	
		
			
				|  |  | +                                _basewarecellrepository.UpdateModelColumns(p => new BaseWarecell
 | 
	
		
			
				|  |  | +                                {
 | 
	
		
			
				|  |  | +                                    StateNum = FjLocationState.Full,
 | 
	
		
			
				|  |  | +                                    ContGrpBarCode = stock.ContGrpBarCode,
 | 
	
		
			
				|  |  | +                                    ContGrpId = stock.ContGrpId,
 | 
	
		
			
				|  |  | +                                    EditTime = DateTime.Now
 | 
	
		
			
				|  |  | +                                }, p => p.Code.Contains(task.AddrTo) && p.WarehouseId == warehouse.Id);
 | 
	
		
			
				|  |  |                              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                              _db.CommitTran();
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  | +                        //组盘入库
 | 
	
		
			
				|  |  |                          else if (isRewindIn)
 | 
	
		
			
				|  |  |                          {
 | 
	
		
			
				|  |  |                              //检查库存信息是否正确
 |