From c1b448e302ae76d129eb136b698308754bf783c5 Mon Sep 17 00:00:00 2001 From: dengjunjie <dengjunjie@hnkhzn.com> Date: 星期五, 06 六月 2025 17:01:13 +0800 Subject: [PATCH] 优化AGV站点分配逻辑 --- 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_AGV.cs | 91 +++++++++++++++++++++++++-------------------- 1 files changed, 51 insertions(+), 40 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_AGV.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_AGV.cs" index 83bee59..15b03e3 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_AGV.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_AGV.cs" @@ -61,14 +61,14 @@ Dt_Task task = new Dt_Task() { - CurrentAddress = "D02",// cachePoint.PointCode, + CurrentAddress = cachePoint.PointCode, Grade = 0, - NextAddress = "C01",//endPoint, + NextAddress = endPoint, OrderNo = "", - PalletCode = "",//cachePoint.Remark, + PalletCode = cachePoint.Remark, Roadway = "", - SourceAddress = "D02",//cachePoint.PointCode, - TargetAddress = "C01",//endPoint, + SourceAddress = cachePoint.PointCode, + TargetAddress = endPoint, SourceKey = 0, TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), TaskStatus = AGVTaskStatusEnum.Create.ObjToInt(), @@ -77,18 +77,8 @@ cachePoint.PointStatus = LocationStatusEnum.Lock.ObjToInt(); Db.Ado.BeginTran(); - #region MyRegion - AGVSendTaskModel aGVSendTask = new AGVSendTaskModel - { - task_id = task.TaskNum.ToString(),// BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)).ToString(), - src_pos = task.CurrentAddress,// "C01", - site_value_type = 1, - dst_pos = task.NextAddress,// "E14" - src_level=3, - }; - #endregion - var response = HttpHelper.Post<WebResponseContent>(AGVurl + "sendTask/", aGVSendTask, "鍙枡浠诲姟涓嬪彂"); - if (response.Code != 200) + var response = SendAGVTask(task, cachePoint); + if (response.Status) { _unitOfWorkManage.RollbackTran(); return WebResponseContent.Instance.Error($"{response.Message}"); @@ -151,22 +141,19 @@ /// <exception cref="Exception"></exception> private Dt_CachePoint GetCachePointByStartPoint(string startPoint) { - Dt_AreaRouter areaRouter = _basicService.AreaRouterService.Repository.QueryFirst(x => x.StartArea == startPoint); - if (areaRouter == null) - { - throw new Exception("鏈壘鍒拌矾鐢变俊鎭�!"); - } - Dt_AreaInfo areaInfo = _basicService.AreaInfoService.Repository.QueryFirst(x => x.AreaCode == areaRouter.NextArea); - if (areaInfo == null) - { - throw new Exception("鏈壘鍒颁笅涓�鍖哄煙淇℃伅!"); - } + #region MyRegion + Dt_CachePoint? StartcachePoint = _basicService.CachePointService.Repository.QueryFirst(x => x.PointCode == startPoint); + if (StartcachePoint == null) throw new Exception("鏈壘鍒扮紦瀛樼偣!"); - Dt_CachePoint? cachePoint = _basicService.CachePointService.AssignCachePoint(areaInfo.Id); + Dt_AreaRouter areaRouter = _basicService.AreaRouterService.Repository.QueryFirst(x => x.StartArea == StartcachePoint.AreaId.ToString()); + if (areaRouter == null) throw new Exception("鏈壘鍒拌矾鐢变俊鎭�!"); + + Dt_CachePoint? cachePoint = _basicService.CachePointService.AssignCachePoint(areaRouter.NextArea.ObjToInt()); if (cachePoint == null) { throw new Exception("鏈壘鍒扮┖闂茬紦瀛樼偣!"); } + #endregion return cachePoint; } @@ -178,24 +165,48 @@ /// <exception cref="Exception"></exception> private Dt_CachePoint GetCachePointByEndPoint(string endPoint) { - Dt_AreaRouter areaRouter = _basicService.AreaRouterService.Repository.QueryFirst(x => x.NextArea == endPoint); - if (areaRouter == null) - { - throw new Exception("鏈壘鍒拌矾鐢变俊鎭�!"); - } - Dt_AreaInfo areaInfo = _basicService.AreaInfoService.Repository.QueryFirst(x => x.AreaCode == areaRouter.StartArea); - if (areaInfo == null) - { - throw new Exception("鏈壘鍒拌捣鐐圭紦瀛樺尯鍩熶俊鎭�!"); - } + #region MyRegion + Dt_CachePoint? StartcachePoint = _basicService.CachePointService.Repository.QueryFirst(x => x.PointCode == endPoint); + if (StartcachePoint == null) throw new Exception("鏈壘鍒扮紦瀛樼偣!"); - Dt_CachePoint? cachePoint = _basicService.CachePointService.GetIbStockCachePoint(areaInfo.Id); + Dt_AreaRouter areaRouter = _basicService.AreaRouterService.Repository.QueryFirst(x => x.NextArea == StartcachePoint.AreaId.ToString()); + if (areaRouter == null) throw new Exception("鏈壘鍒拌矾鐢变俊鎭�!"); + + Dt_CachePoint? cachePoint = _basicService.CachePointService.GetIbStockCachePoint(areaRouter.StartArea.ObjToInt()); if (cachePoint == null) { throw new Exception("鏈壘鍒版湁璐х紦瀛樼偣!"); } + #endregion return cachePoint; } + + /// <summary> + /// 涓嬪彂AGV浠诲姟 + /// </summary> + /// <param name="task"></param> + public WebResponseContent SendAGVTask(Dt_Task task, Dt_CachePoint? cachePoint = null) + { + try + { + AGVSendTaskModel aGVSendTask = new AGVSendTaskModel + { + task_id = task.TaskNum.ToString(), + src_pos = task.CurrentAddress, + site_value_type = 1, + dst_pos = task.NextAddress + }; + if (cachePoint != null && cachePoint.AreaId == 4) aGVSendTask.src_level = cachePoint.Remark.ObjToInt() - 1; + var response = HttpHelper.Post<WebResponseContent>(AGVurl + "sendTask/", aGVSendTask, "鍙枡浠诲姟涓嬪彂"); + if (response.Code != 200) throw new Exception(response.Message); + return WebResponseContent.Instance.OK(); + } + catch (Exception ex) + { + return WebResponseContent.Instance.Error(ex.Message); + } + } + /// <summary> /// 浠诲姟鐘舵�佷笂鎶� /// </summary> @@ -225,7 +236,7 @@ if (startCachePoint != null) { startCachePoint.PointStatus = LocationStatusEnum.Free.ObjToInt(); - if (startCachePoint.AreaId == 3)//鍒ゆ柇鏄惁涓烘ā缁勭┖鏍堟澘鍖哄煙 + if (startCachePoint.AreaId == 4)//鍒ゆ柇鏄惁涓烘ā缁勭┖鏍堟澘鍖哄煙 { var qty = (startCachePoint.Remark.ObjToInt() - 1); if (qty > 0) startCachePoint.PointStatus = LocationStatusEnum.InStock.ObjToInt(); -- Gitblit v1.9.3