dengjunjie
2025-06-06 c1b448e302ae76d129eb136b698308754bf783c5
´úÂë¹ÜÀí/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();