From 3311f02194604247c1fb0384ecc43cc3ef3f04be Mon Sep 17 00:00:00 2001 From: dengjunjie <dengjunjie@hnkhzn.com> Date: 星期日, 08 六月 2025 20:59:31 +0800 Subject: [PATCH] 1 --- 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_AGV.cs | 165 +++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 125 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..8c780fe 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" @@ -49,6 +49,61 @@ } /// <summary> + /// 璐т綅缁戝畾 + /// </summary> + /// <param name="qty"></param> + /// <param name="Point"></param> + /// <returns></returns> + public WebResponseContent Bind(string qty, string point) + { + try + { + if (Repository.QueryFirst(x => x.SourceAddress == point && + x.TaskStatus < AGVTaskStatusEnum.DoneFetch.ObjToInt() || + x.TargetAddress == point) != null) + throw new Exception($"绔欑偣銆恵point}銆戝瓨鍦ㄤ换鍔★紒"); + Dt_CachePoint? cachePoint = _basicService.CachePointService.Repository.QueryFirst(x => x.PointCode == point); + if (cachePoint == null) throw new Exception("鏈壘鍒扮紦瀛樼偣!"); + if (cachePoint.AreaId != 4) throw new Exception("褰撳墠缂撳瓨鐐瑰尯鍩熸棤缁戝畾鏉冮檺!"); + cachePoint.PointStatus = LocationStatusEnum.InStock.ObjToInt(); + cachePoint.Remark = qty; + cachePoint.Modifier = App.User.UserName; + _basicService.CachePointService.Repository.UpdateData(cachePoint); + return WebResponseContent.Instance.OK(); + } + catch (Exception ex) + { + return WebResponseContent.Instance.Error(ex.Message); + } + } + /// <summary> + /// 閲婃斁缂撳瓨鐐� + /// </summary> + /// <param name="point"></param> + /// <returns></returns> + public WebResponseContent AcrossFloorCallMat(string point) + { + try + { + if (Repository.QueryFirst(x => x.SourceAddress == point && + x.TaskStatus < AGVTaskStatusEnum.DoneFetch.ObjToInt() || + x.TargetAddress == point) != null) + throw new Exception($"绔欑偣銆恵point}銆戝瓨鍦ㄤ换鍔★紒"); + Dt_CachePoint? cachePoint = _basicService.CachePointService.Repository.QueryFirst(x => x.PointCode == point); + if (cachePoint == null) throw new Exception("鏈壘鍒扮紦瀛樼偣!"); + if (cachePoint.AreaId != 2 && cachePoint.AreaId != 5 && cachePoint.AreaId != 8) + throw new Exception("褰撳墠缂撳瓨鐐瑰尯鍩熸棤閲婃斁鏉冮檺!"); + cachePoint.PointStatus = LocationStatusEnum.Free.ObjToInt(); + _basicService.CachePointService.Repository.UpdateData(cachePoint); + return WebResponseContent.Instance.OK(); + } + catch (Exception ex) + { + return WebResponseContent.Instance.Error(ex.Message); + } + } + + /// <summary> /// 鍙枡 /// </summary> /// <param name="endPoint"></param> @@ -57,18 +112,23 @@ { try { + if (Repository.QueryFirst(x => x.SourceAddress == endPoint && + x.TaskStatus < AGVTaskStatusEnum.DoneFetch.ObjToInt() || + x.TargetAddress == endPoint) != null) + throw new Exception($"绔欑偣銆恵endPoint}銆戝瓨鍦ㄤ换鍔★紒"); + Dt_CachePoint cachePoint = GetCachePointByEndPoint(endPoint); 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 +137,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}"); @@ -115,6 +165,11 @@ { try { + if (Repository.QueryFirst(x => x.SourceAddress == startPoint && + x.TaskStatus < AGVTaskStatusEnum.DoneFetch.ObjToInt() || + x.TargetAddress == startPoint) != null) + throw new Exception($"绔欑偣銆恵startPoint}銆戝瓨鍦ㄤ换鍔★紒"); + Dt_CachePoint cachePoint = GetCachePointByStartPoint(startPoint); Dt_Task task = new() @@ -134,12 +189,21 @@ }; cachePoint.PointStatus = LocationStatusEnum.Lock.ObjToInt(); + Db.Ado.BeginTran(); + var response = SendAGVTask(task, cachePoint); + if (!response.Status) + { + _unitOfWorkManage.RollbackTran(); + return WebResponseContent.Instance.Error($"{response.Message}"); + } _basicService.CachePointService.Repository.UpdateData(cachePoint); Repository.AddData(task); + Db.Ado.CommitTran(); return WebResponseContent.Instance.OK(); } catch (Exception ex) { + Db.Ado.RollbackTran(); return WebResponseContent.Instance.Error(ex.Message); } } @@ -151,22 +215,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 +239,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 +310,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