| | |
| | | public WebResponseContent ShelfOutboundCarry(Dt_Task outTask) |
| | | { |
| | | //夿æ¯å¦ä¸ºçµè¯åºï¼è¾
æåºäººå·¥å¤ç(ç«åºç®æ å°åè½¬æ¢æAGVç«ç¹å°å) |
| | | 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)), |
| | |
| | | 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(); |
| | | } |
| | | |
| | | /// <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}ãåå¨AGVä»»å¡ï¼"); |
| | | Dt_CachePoint? cachePoint = _basicService.CachePointService.Repository.QueryFirst(x => x.PointCode == point); |
| | | if (cachePoint == null) 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(); |
| | | if (cachePoint.AreaId == 4) 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}ãåå¨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("å½åç¼åç¹åºåæ éæ¾æé!"); |
| | | cachePoint.PointStatus = LocationStatusEnum.Free.ObjToInt(); |
| | | 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="endPoint"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent CallMateriel(string endPoint) |
| | | public WebResponseContent CallMateriel(string endPoint, string startPoint) |
| | | { |
| | | try |
| | | { |
| | | Dt_CachePoint cachePoint = GetCachePointByEndPoint(endPoint); |
| | | 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, startPoint); |
| | | |
| | | 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}"); |
| | |
| | | /// </summary> |
| | | /// <param name="startPoint"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent MaterielCarry(string startPoint) |
| | | public WebResponseContent MaterielCarry(string startPoint, string endPoint) |
| | | { |
| | | try |
| | | { |
| | | Dt_CachePoint cachePoint = GetCachePointByStartPoint(startPoint); |
| | | if (Repository.QueryFirst(x => x.SourceAddress == startPoint && |
| | | x.TaskStatus < AGVTaskStatusEnum.DoneFetch.ObjToInt() || |
| | | x.TargetAddress == startPoint) != null) |
| | | throw new Exception($"ç«ç¹ã{startPoint}ãåå¨ä»»å¡ï¼"); |
| | | Dt_CachePoint startcachePoint = new Dt_CachePoint(); |
| | | Dt_CachePoint cachePoint = GetCachePointByStartPoint(startPoint, endPoint, ref startcachePoint); |
| | | |
| | | 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); |
| | | } |
| | | } |
| | |
| | | /// <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) |
| | | { |
| | | Dt_AreaRouter areaRouter = _basicService.AreaRouterService.Repository.QueryFirst(x => x.StartArea == startPoint); |
| | | if (areaRouter == null) |
| | | #region MyRegion |
| | | Dt_CachePoint? StartcachePoint = _basicService.CachePointService.Repository.QueryFirst(x => x.PointCode == startPoint); |
| | | if (StartcachePoint == null) throw new Exception($"æªæ¾å°ç¼åç¹{startPoint}!"); |
| | | startcachePoint = StartcachePoint; |
| | | endPoint = ""; |
| | | if (!string.IsNullOrEmpty(endPoint)) |
| | | { |
| | | throw new Exception("æªæ¾å°è·¯ç±ä¿¡æ¯!"); |
| | | 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_AreaInfo areaInfo = _basicService.AreaInfoService.Repository.QueryFirst(x => x.AreaCode == areaRouter.NextArea); |
| | | if (areaInfo == null) |
| | | { |
| | | throw new Exception("æªæ¾å°ä¸ä¸åºåä¿¡æ¯!"); |
| | | } |
| | | 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(areaInfo.Id); |
| | | Dt_CachePoint? cachePoint = _basicService.CachePointService.AssignCachePoint(areaRouter.NextArea.ObjToInt()); |
| | | if (cachePoint == null) |
| | | { |
| | | throw new Exception("æªæ¾å°ç©ºé²ç¼åç¹!"); |
| | | } |
| | | #endregion |
| | | |
| | | return cachePoint; |
| | | } |
| | |
| | | /// <param name="endPoint"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | private Dt_CachePoint GetCachePointByEndPoint(string endPoint) |
| | | private Dt_CachePoint GetCachePointByEndPoint(string endPoint, string startPoint) |
| | | { |
| | | Dt_AreaRouter areaRouter = _basicService.AreaRouterService.Repository.QueryFirst(x => x.NextArea == endPoint); |
| | | if (areaRouter == null) |
| | | #region MyRegion |
| | | Dt_CachePoint? StartcachePoint = _basicService.CachePointService.Repository.QueryFirst(x => x.PointCode == endPoint); |
| | | if (StartcachePoint == null) throw new Exception($"æªæ¾å°ç¼åç¹{endPoint}!"); |
| | | |
| | | if (!string.IsNullOrEmpty(endPoint)) |
| | | { |
| | | throw new Exception("æªæ¾å°è·¯ç±ä¿¡æ¯!"); |
| | | } |
| | | Dt_AreaInfo areaInfo = _basicService.AreaInfoService.Repository.QueryFirst(x => x.AreaCode == areaRouter.StartArea); |
| | | if (areaInfo == null) |
| | | { |
| | | throw new Exception("æªæ¾å°èµ·ç¹ç¼ååºåä¿¡æ¯!"); |
| | | 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_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("AGVä»»å¡ä¸å失败:" + ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// ä»»å¡ç¶æä¸æ¥ |
| | | /// </summary> |
| | |
| | | { |
| | | return new { code = 404, message = "æªæ¾å°è¯¥ä»»å¡!" }; |
| | | } |
| | | if (task.TaskStatus == ((AGVTaskStatusEnum)Enum.Parse(typeof(AGVTaskStatusEnum), model.Task_status)).ObjToInt()) |
| | | return new { code = 200, message = "æå" }; |
| | | switch ((AGVTaskStatusEnum)Enum.Parse(typeof(AGVTaskStatusEnum), model.Task_status)) |
| | | { |
| | | case AGVTaskStatusEnum.Create: |
| | |
| | | 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(); |
| | | startCachePoint.Remark = qty.ToString(); |
| | | } |
| | | //else if (startCachePoint.AreaId == 1) |
| | | //{ |
| | | // startCachePoint.PointStatus = LocationStatusEnum.PalletLock.ObjToInt(); |
| | | //} |
| | | _basicService.CachePointService.Repository.UpdateData(startCachePoint); |
| | | } |
| | | } |
| | |
| | | return new { code = 200, message = "æå" }; |
| | | } |
| | | case AGVTaskStatusEnum.Cancel: |
| | | case AGVTaskStatusEnum.Terminate: |
| | | case AGVTaskStatusEnum.Error: |
| | | { |
| | | if (task.TaskStatus < AGVTaskStatusEnum.DoneFetch.ObjToInt()) |
| | | { |
| | | Dt_CachePoint startCachePoint = _basicService.CachePointService.Repository.QueryFirst(x => x.PointCode == task.SourceAddress); |
| | | startCachePoint.PointStatus = LocationStatusEnum.InStock.ObjToInt(); |
| | | _basicService.CachePointService.Repository.UpdateData(startCachePoint); |
| | | } |
| | | task.TaskStatus = AGVTaskStatusEnum.Cancel.ObjToInt(); |
| | | BaseDal.DeleteAndMoveIntoHty(task, OperateType.èªå¨å é¤); |
| | | return new { code = 200, message = "æå" }; |
| | | } |
| | | case AGVTaskStatusEnum.Terminate: |
| | | task.TaskStatus = AGVTaskStatusEnum.Terminate.ObjToInt(); |
| | | break; |
| | | case AGVTaskStatusEnum.Error: |
| | | task.TaskStatus = AGVTaskStatusEnum.Error.ObjToInt(); |
| | | break; |
| | | //case AGVTaskStatusEnum.Terminate: |
| | | // task.TaskStatus = AGVTaskStatusEnum.Terminate.ObjToInt(); |
| | | // break; |
| | | //case AGVTaskStatusEnum.Error: |
| | | // task.TaskStatus = AGVTaskStatusEnum.Error.ObjToInt(); |
| | | // break; |
| | | default: |
| | | return new { code = 404, message = "æªå®ä¹ä»»å¡ç±»å!" }; |
| | | } |