1
dengjunjie
3 天以前 29cd467ba62b2bdf49c6546e78ae3ec809c4a723
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_AGV.cs
@@ -25,7 +25,7 @@
            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);
            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搬运
            //{
@@ -73,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}】存在AGV任务!");
                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}】存在AGV任务!");
                    }
                }
                //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();
@@ -100,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}】存在AGV任务!");
                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();
            }
@@ -120,7 +132,7 @@
        /// </summary>
        /// <param name="endPoint"></param>
        /// <returns></returns>
        public WebResponseContent CallMateriel(string endPoint)
        public WebResponseContent CallMateriel(string endPoint, string startPoint)
        {
            try
            {
@@ -129,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()
                {
@@ -173,7 +185,7 @@
        /// </summary>
        /// <param name="startPoint"></param>
        /// <returns></returns>
        public WebResponseContent MaterielCarry(string startPoint)
        public WebResponseContent MaterielCarry(string startPoint, string endPoint)
        {
            try
            {
@@ -182,7 +194,7 @@
                x.TargetAddress == startPoint) != null)
                    throw new Exception($"站点【{startPoint}】存在任务!");
                Dt_CachePoint startcachePoint = new Dt_CachePoint();
                Dt_CachePoint cachePoint = GetCachePointByStartPoint(startPoint, ref startcachePoint);
                Dt_CachePoint cachePoint = GetCachePointByStartPoint(startPoint, endPoint, ref startcachePoint);
                Dt_Task task = new()
                {
@@ -225,12 +237,23 @@
        /// <param name="startPoint"></param>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        private Dt_CachePoint GetCachePointByStartPoint(string startPoint, ref Dt_CachePoint startcachePoint)
        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("未找到路由信息!");
@@ -249,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("未找到路由信息!");
@@ -289,7 +323,7 @@
            }
            catch (Exception ex)
            {
                return WebResponseContent.Instance.Error(ex.Message);
                return WebResponseContent.Instance.Error("AGV任务下发失败:" + ex.Message);
            }
        }