| | |
| | | } |
| | | |
| | | /// <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> |
| | |
| | | { |
| | | 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(), |
| | |
| | | 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}"); |
| | |
| | | { |
| | | 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() |
| | |
| | | }; |
| | | 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); |
| | | } |
| | | } |
| | |
| | | /// <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; |
| | | } |
| | |
| | | /// <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> |
| | |
| | | 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(); |