From 29cd467ba62b2bdf49c6546e78ae3ec809c4a723 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期四, 19 六月 2025 17:50:28 +0800
Subject: [PATCH] 1

---
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_AGV.cs |   92 +++++++++++++++++++++++++++++++++++----------
 1 files changed, 71 insertions(+), 21 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 e780012..03a0580 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"
@@ -22,17 +22,26 @@
         public WebResponseContent ShelfOutboundCarry(Dt_Task outTask)
         {
             //鍒ゆ柇鏄惁涓虹數鑺簱锛岃緟鏂欏簱浜哄伐澶勭悊(绔嬪簱鐩爣鍦板潃杞崲鎴怉GV绔欑偣鍦板潃)
-            Dt_CachePoint cachePoint = GetCachePointByStartPoint(outTask.TargetAddress);
-
+            Dt_RoadwayInfo dt_RoadwayInfo = _basicService.RoadwayInfoService.Repository.QueryFirst(x => x.OutSCStationCode == outTask.TargetAddress);
+            if (dt_RoadwayInfo == null || dt_RoadwayInfo.AreaId == 11) return WebResponseContent.Instance.OK();
+            Dt_CachePoint startcachePoint = new Dt_CachePoint();
+            Dt_CachePoint cachePoint = GetCachePointByStartPoint(dt_RoadwayInfo.OutStationCode, "", ref startcachePoint);
+            if (startcachePoint.EnableStatus == EnableStatusEnum.Disable.ObjToInt()) return WebResponseContent.Instance.OK();
+            //if (dt_RoadwayInfo.AreaId == 11)//杈呮枡涓嶇敤AGV鎼繍
+            //{
+            //    startcachePoint.PointStatus = LocationStatusEnum.Lock.ObjToInt();
+            //    _basicService.CachePointService.Repository.UpdateData(startcachePoint);
+            //    return WebResponseContent.Instance.OK();
+            //}
             Dt_Task task = new()
             {
-                CurrentAddress = outTask.TargetAddress,
+                CurrentAddress = startcachePoint.PointCode,
                 Grade = 0,
                 NextAddress = cachePoint.PointCode,
                 OrderNo = outTask.OrderNo,
                 PalletCode = outTask.PalletCode + "-AGV",
                 Roadway = "",
-                SourceAddress = outTask.TargetAddress,
+                SourceAddress = startcachePoint.PointCode,
                 TargetAddress = cachePoint.PointCode,
                 SourceKey = outTask.TaskId,
                 TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
@@ -42,9 +51,12 @@
                 Creater = App.User.UserId > 0 ? App.User.UserName : "System",
             };
             cachePoint.PointStatus = LocationStatusEnum.Lock.ObjToInt();
+            //startcachePoint.PointStatus = LocationStatusEnum.Lock.ObjToInt();
 
             _basicService.CachePointService.Repository.UpdateData(cachePoint);
+            //_basicService.CachePointService.Repository.UpdateData(startcachePoint);
             Repository.AddData(task);
+            SendAGVTask(task, cachePoint);
             return WebResponseContent.Instance.OK();
         }
 
@@ -61,12 +73,23 @@
                 if (Repository.QueryFirst(x => x.SourceAddress == point &&
                 x.TaskStatus < AGVTaskStatusEnum.DoneFetch.ObjToInt() ||
                 x.TargetAddress == point) != null)
-                    throw new Exception($"绔欑偣銆恵point}銆戝瓨鍦ㄤ换鍔★紒");
+                    throw new Exception($"缂撳瓨鐐广�恵point}銆戝瓨鍦ˋGV浠诲姟锛�");
                 Dt_CachePoint? cachePoint = _basicService.CachePointService.Repository.QueryFirst(x => x.PointCode == point);
                 if (cachePoint == null) throw new Exception("鏈壘鍒扮紦瀛樼偣!");
-                if (cachePoint.AreaId != 4) throw new Exception("褰撳墠缂撳瓨鐐瑰尯鍩熸棤缁戝畾鏉冮檺!");
+                if (cachePoint.Depth == 1)
+                {
+                    Dt_CachePoint? cachePoint1 = _basicService.CachePointService.Repository.QueryFirst(x => x.AreaId == cachePoint.AreaId && x.Column == cachePoint.Column && cachePoint.Row - x.Row == 1);
+                    if (cachePoint1 != null)
+                    {
+                        if (Repository.QueryFirst(x => x.SourceAddress == cachePoint1.PointCode &&
+                x.TaskStatus < AGVTaskStatusEnum.DoneFetch.ObjToInt() ||
+                x.TargetAddress == cachePoint1.PointCode) != null)
+                            throw new Exception($"鍐呯疆缂撳瓨鐐广�恵cachePoint1.PointCode}銆戝瓨鍦ˋGV浠诲姟锛�");
+                    }
+                }
+                //if (cachePoint.AreaId != 4) throw new Exception("褰撳墠缂撳瓨鐐瑰尯鍩熸棤缁戝畾鏉冮檺!");
                 cachePoint.PointStatus = LocationStatusEnum.InStock.ObjToInt();
-                cachePoint.Remark = qty;
+                if (cachePoint.AreaId == 4) cachePoint.Remark = qty;
                 cachePoint.Modifier = App.User.UserName;
                 _basicService.CachePointService.Repository.UpdateData(cachePoint);
                 return WebResponseContent.Instance.OK();
@@ -88,12 +111,13 @@
                 if (Repository.QueryFirst(x => x.SourceAddress == point &&
                 x.TaskStatus < AGVTaskStatusEnum.DoneFetch.ObjToInt() ||
                 x.TargetAddress == point) != null)
-                    throw new Exception($"绔欑偣銆恵point}銆戝瓨鍦ㄤ换鍔★紒");
+                    throw new Exception($"缂撳瓨鐐广�恵point}銆戝瓨鍦ˋGV浠诲姟锛�");
                 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("褰撳墠缂撳瓨鐐瑰尯鍩熸棤閲婃斁鏉冮檺!");
+                //if (cachePoint.AreaId != 2 && cachePoint.AreaId != 5 && cachePoint.AreaId != 8)
+                //    throw new Exception("褰撳墠缂撳瓨鐐瑰尯鍩熸棤閲婃斁鏉冮檺!");
                 cachePoint.PointStatus = LocationStatusEnum.Free.ObjToInt();
+                cachePoint.Modifier = App.User.UserName;
                 _basicService.CachePointService.Repository.UpdateData(cachePoint);
                 return WebResponseContent.Instance.OK();
             }
@@ -108,7 +132,7 @@
         /// </summary>
         /// <param name="endPoint"></param>
         /// <returns></returns>
-        public WebResponseContent CallMateriel(string endPoint)
+        public WebResponseContent CallMateriel(string endPoint, string startPoint)
         {
             try
             {
@@ -117,7 +141,7 @@
                 x.TargetAddress == endPoint) != null)
                     throw new Exception($"绔欑偣銆恵endPoint}銆戝瓨鍦ㄤ换鍔★紒");
 
-                Dt_CachePoint cachePoint = GetCachePointByEndPoint(endPoint);
+                Dt_CachePoint cachePoint = GetCachePointByEndPoint(endPoint, startPoint);
 
                 Dt_Task task = new Dt_Task()
                 {
@@ -161,7 +185,7 @@
         /// </summary>
         /// <param name="startPoint"></param>
         /// <returns></returns>
-        public WebResponseContent MaterielCarry(string startPoint)
+        public WebResponseContent MaterielCarry(string startPoint, string endPoint)
         {
             try
             {
@@ -169,8 +193,8 @@
                 x.TaskStatus < AGVTaskStatusEnum.DoneFetch.ObjToInt() ||
                 x.TargetAddress == startPoint) != null)
                     throw new Exception($"绔欑偣銆恵startPoint}銆戝瓨鍦ㄤ换鍔★紒");
-
-                Dt_CachePoint cachePoint = GetCachePointByStartPoint(startPoint);
+                Dt_CachePoint startcachePoint = new Dt_CachePoint();
+                Dt_CachePoint cachePoint = GetCachePointByStartPoint(startPoint, endPoint, ref startcachePoint);
 
                 Dt_Task task = new()
                 {
@@ -213,12 +237,23 @@
         /// <param name="startPoint"></param>
         /// <returns></returns>
         /// <exception cref="Exception"></exception>
-        private Dt_CachePoint GetCachePointByStartPoint(string startPoint)
+        private Dt_CachePoint GetCachePointByStartPoint(string startPoint, string endPoint, ref Dt_CachePoint startcachePoint)
         {
             #region MyRegion
             Dt_CachePoint? StartcachePoint = _basicService.CachePointService.Repository.QueryFirst(x => x.PointCode == startPoint);
-            if (StartcachePoint == null) throw new Exception("鏈壘鍒扮紦瀛樼偣!");
-
+            if (StartcachePoint == null) throw new Exception($"鏈壘鍒扮紦瀛樼偣{startPoint}!");
+            startcachePoint = StartcachePoint;
+            endPoint = "";
+            if (!string.IsNullOrEmpty(endPoint))
+            {
+                Dt_CachePoint? cachePoint1 = _basicService.CachePointService.Repository.QueryFirst(x => x.PointCode == endPoint);
+                if (cachePoint1 == null) throw new Exception($"鏈壘鍒扮紦瀛樼偣{endPoint}!");
+                if (Repository.QueryFirst(x => x.SourceAddress == endPoint &&
+                x.TaskStatus < AGVTaskStatusEnum.DoneFetch.ObjToInt() ||
+                x.TargetAddress == endPoint) != null)
+                    throw new Exception($"缂撳瓨鐐广�恵endPoint}銆戝瓨鍦ㄤ换鍔★紒");
+                return cachePoint1;
+            }
             Dt_AreaRouter areaRouter = _basicService.AreaRouterService.Repository.QueryFirst(x => x.StartArea == StartcachePoint.AreaId.ToString());
             if (areaRouter == null) throw new Exception("鏈壘鍒拌矾鐢变俊鎭�!");
 
@@ -237,11 +272,22 @@
         /// <param name="endPoint"></param>
         /// <returns></returns>
         /// <exception cref="Exception"></exception>
-        private Dt_CachePoint GetCachePointByEndPoint(string endPoint)
+        private Dt_CachePoint GetCachePointByEndPoint(string endPoint, string startPoint)
         {
             #region MyRegion
             Dt_CachePoint? StartcachePoint = _basicService.CachePointService.Repository.QueryFirst(x => x.PointCode == endPoint);
-            if (StartcachePoint == null) throw new Exception("鏈壘鍒扮紦瀛樼偣!");
+            if (StartcachePoint == null) throw new Exception($"鏈壘鍒扮紦瀛樼偣{endPoint}!");
+
+            if (!string.IsNullOrEmpty(endPoint))
+            {
+                Dt_CachePoint? cachePoint1 = _basicService.CachePointService.Repository.QueryFirst(x => x.PointCode == startPoint);
+                if (cachePoint1 == null) throw new Exception($"鏈壘鍒扮紦瀛樼偣{startPoint}!");
+                if (Repository.QueryFirst(x => x.SourceAddress == startPoint &&
+                x.TaskStatus < AGVTaskStatusEnum.DoneFetch.ObjToInt() ||
+                x.TargetAddress == startPoint) != null)
+                    throw new Exception($"缂撳瓨鐐广�恵startPoint}銆戝瓨鍦ㄤ换鍔★紒");
+                return cachePoint1;
+            }
 
             Dt_AreaRouter areaRouter = _basicService.AreaRouterService.Repository.QueryFirst(x => x.NextArea == StartcachePoint.AreaId.ToString());
             if (areaRouter == null) throw new Exception("鏈壘鍒拌矾鐢变俊鎭�!");
@@ -277,7 +323,7 @@
             }
             catch (Exception ex)
             {
-                return WebResponseContent.Instance.Error(ex.Message);
+                return WebResponseContent.Instance.Error("AGV浠诲姟涓嬪彂澶辫触:" + ex.Message);
             }
         }
 
@@ -318,6 +364,10 @@
                                 if (qty > 0) startCachePoint.PointStatus = LocationStatusEnum.InStock.ObjToInt();
                                 startCachePoint.Remark = qty.ToString();
                             }
+                            //else if (startCachePoint.AreaId == 1)
+                            //{
+                            //    startCachePoint.PointStatus = LocationStatusEnum.PalletLock.ObjToInt();
+                            //}
                             _basicService.CachePointService.Repository.UpdateData(startCachePoint);
                         }
                     }

--
Gitblit v1.9.3