소스 검색

Merge branch 'master' of http://120.77.11.229:3000/zuolinhao/ZT-FJ-WMS

xu.lu 1 년 전
부모
커밋
75c971c846
1개의 변경된 파일114개의 추가작업 그리고 10개의 파일을 삭제
  1. 114 10
      wms.service/Service/FJService.cs

+ 114 - 10
wms.service/Service/FJService.cs

@@ -4795,20 +4795,34 @@ namespace wms.service.Service
 
                 #region 分区计算
 
-                
+                //获取最佳码垛位
+                var findBestStackingPosition = FindBestStackingPosition(wareCellList);
+                if (findBestStackingPosition.IsNullOrEmpty())
+                {
+                    res.ResCode = ResponseStatusCodeEnum.Fail.GetHashCode();
+                    res.ResMsg = "分区计算异常无对应结果";
+                    return res;
+                }
+
+                if (findBestStackingPosition!=req.EquCode)//当前码垛位不是最近码垛位置
+                {
+                    //查看最近码垛位是否存在未结束的码垛任务
+                    var used = _taskrepository.AsQueryable().With(SqlWith.NoLock).Any(x => x.AddrTo==findBestStackingPosition&&x.BusType== FJTaskBusType.环形库出库码垛任务.GetDescription());
+                    //无正在执行的任务,报错返回
+                    if (!used)
+                    {
+                        res.ResCode = ResponseStatusCodeEnum.Fail.GetHashCode();
+                        res.ResMsg = "优先最近码垛位执行";
+                        return res;
+                    }
+                }
 
                 #endregion
                 foreach (var doc in bomSetGrpList)
                 {
                     //找到对应的垛形信息
                     var bomSetGrp = _BillBomsetgrpRepository.GetSingle(x => doc.Id == x.Id);
-                    //var bomSetGrpInfo = _billBomsetinfoRepository.GetList(x => x.BomSetHdrId == bomSetGrp.Id && x.IsEmpty == 0).OrderBy(x => x.XYNo.ObjToInt());
-
-                    ////南侧需要反转
-                    //if (wareHouse.Code.Contains("S"))
-                    //{
-                    //    bomSetGrpInfo = bomSetGrpInfo.OrderByDescending(x => x.XYNo.ObjToInt());
-                    //}
+                    
 
                     //是否可以码垛,默认可以码垛
                     var isPalletize = true;
@@ -7279,6 +7293,59 @@ namespace wms.service.Service
                 return res;
             }
         }
+
+        /// <summary>
+        ///  计算最佳码垛位置
+        /// </summary>
+        /// <param name="cellInfos"></param>
+        /// <returns></returns>
+        public string FindBestStackingPosition(List<CellInfo> cellInfos)
+        {
+            //0表示1-9列任务居多,1表示10-17列任务居多
+            var colType = cellInfos.GroupBy(p => p.Col).OrderByDescending(p => p.Count()).First().Key > 9 ? 1 : 0;
+            //在cellInfos中获取一个仓库号
+            var warehouseCode = cellInfos.First().WarehouseCode;
+
+            return warehouseCode switch
+            {
+                "1NR" => colType == 0 ? "1666" : "1661",
+                "1SR" => colType == 0 ? "1681" : "1679",
+                "2NR" => colType == 0 ? "1696" : "1691",
+                "2SR" => colType == 0 ? "1711" : "1706",
+                "3NR" => colType == 0 ? "1726" : "1721",
+                "3SR" => colType == 0 ? "1741" : "1736",
+                _ => ""
+            }; 
+
+            //var res = new Tuple<string, string>("","");
+
+            //switch (warehouseCode)
+            //{
+            //    case "1NR":
+            //        res = colType==0 ? new Tuple<string, string>("1666", "1661") : new Tuple<string, string>("1661", "1666");
+            //        break;
+            //    case "1SR":
+            //        res = colType == 0 ? new Tuple<string, string>("1681", "1679") : new Tuple<string, string>("1679", "1681");
+            //        break;
+            //    case "2NR":
+            //        res = colType == 0 ? new Tuple<string, string>("1696", "1691") : new Tuple<string, string>("1691", "1696");
+            //        break;
+            //    case "2SR":
+            //        res = colType == 0 ? new Tuple<string, string>("1711", "1706") : new Tuple<string, string>("1706", "1711");
+            //        break;
+            //    case "3NR":
+            //        res = colType == 0 ? new Tuple<string, string>("1726", "1721") : new Tuple<string, string>("1721", "1726");
+            //        break;
+            //    case "3SR":
+            //        res = colType == 0 ? new Tuple<string, string>("1741", "1736") : new Tuple<string, string>("1736", "1741");
+            //        break;
+            //}
+
+            //return res;
+
+
+
+        }
     }
 
     public static class TaslEx
@@ -7474,22 +7541,59 @@ namespace wms.service.Service
 
     public class CellInfo
     {
+        /// <summary>
+        /// 货位ID
+        /// </summary>
         public long Id { get; set; }
+        /// <summary>
+        /// 组盘条码
+        /// </summary>
         public string ContGrpBarCode { get; set; }
+        /// <summary>
+        /// 仓库ID
+        /// </summary>
         public long WarehouseId { get; set; }
+        /// <summary>
+        /// 仓库号
+        /// </summary>
         public string WarehouseCode { get; set; }
+        /// <summary>
+        /// 货位号
+        /// </summary>
         public string Code { get; set; }
+        /// <summary>
+        /// 行
+        /// </summary>
         public int Row { get; set; }
+        /// <summary>
+        /// 列
+        /// </summary>
         public int Col { get; set; }
+        /// <summary>
+        /// 层
+        /// </summary>
         public int Layer { get; set; }
+        /// <summary>
+        /// 深
+        /// </summary>
         public int Depth { get; set; }
+        /// <summary>
+        /// 物料号
+        /// </summary>
         public string MatCode { get; set; }
+        /// <summary>
+        /// 正反面
+        /// </summary>
         public int SideNum { get; set; }
 
         public string CLBarCode { get; set; }
-
+        /// <summary>
+        /// 码垛位置
+        /// </summary>
         public int XYNo { get; set; }
-
+        /// <summary>
+        /// 编辑时间
+        /// </summary>
         public DateTime EditTime { get; set; }
 
         /// <summary>