| | |
| | | using Microsoft.AspNetCore.Http; |
| | | using Microsoft.AspNetCore.Mvc; |
| | | using System.Text; |
| | | using System.Text.RegularExpressions; |
| | | using WIDESEA_DTO.Agv; |
| | | using WIDESEA_External.Model; |
| | | using WIDESEAWCS_Common.APIEnum; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.Enums; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_Core.LogHelper; |
| | | using WIDESEAWCS_DTO; |
| | | using WIDESEAWCS_DTO.Agv; |
| | | using WIDESEAWCS_IBasicInfoRepository; |
| | | using WIDESEAWCS_ITaskInfoRepository; |
| | |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_QuartzJob; |
| | | using WIDESEAWCS_QuartzJob.DTO; |
| | | using WIDESEAWCS_QuartzJob.Models; |
| | | using WIDESEAWCS_QuartzJob.Repository; |
| | | using WIDESEAWCS_Tasks; |
| | | using WIDESEAWCS_Tasks.ConveyorLineJob; |
| | | using WIDESEAWCS_Tasks.DBNames; |
| | | using WIDESEAWCS_Tasks.StackPlateJob; |
| | | using static Dm.net.buffer.ByteArrayBuffer; |
| | | |
| | | namespace WIDESEAWCS_Server.Controllers |
| | | { |
| | |
| | | private readonly IStationMangerRepository _stationMangerRepository; |
| | | private readonly ITaskService _taskService; |
| | | private readonly ITaskRepository _taskRepository; |
| | | private readonly IRouterRepository _routerRepository; |
| | | |
| | | public AGVController(IStationMangerRepository stationMangerRepository, ITaskService taskService, ITaskRepository taskRepository) |
| | | public AGVController(IStationMangerRepository stationMangerRepository, ITaskService taskService, ITaskRepository taskRepository,IRouterRepository routerRepository) |
| | | { |
| | | _stationMangerRepository = stationMangerRepository; |
| | | _taskService = taskService; |
| | | _taskRepository = taskRepository; |
| | | _routerRepository = routerRepository; |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | var task = _taskRepository.QueryFirst(x => secureApplyModel.ReceiveTaskID.ObjToInt() == x.TaskNum); |
| | | if (task == null) throw new Exception("æªæ¾å°ä»»å¡"); |
| | | if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt()) |
| | | if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) |
| | | { |
| | | var content = TakeRequest(task.CurrentAddress); |
| | | if (!content.Status) |
| | | if (task.TaskState==TaskStatusEnum.AGV_Executing.ObjToInt())//åºåºåè´§è¯·æ± |
| | | { |
| | | throw new Exception(content.Message); |
| | | var content = TakeRequest(secureApplyModel.WbCode); |
| | | if (!content.Status) |
| | | { |
| | | throw new Exception(content.Message); |
| | | } |
| | | } |
| | | else//åºåºæ¾è´§è¯·æ± |
| | | { |
| | | var content = PutRequest(task.NextAddress, task); |
| | | if (!content.Status) |
| | | { |
| | | throw new Exception(content.Message); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | var content = PutRequest(task.NextAddress, task.PalletType); |
| | | if (!content.Status) |
| | | if (task.TaskState == TaskStatusEnum.AGV_Executing.ObjToInt())//å
¥åºåè´§è¯·æ± |
| | | { |
| | | throw new Exception(content.Message); |
| | | var content = TakeRequest(secureApplyModel.WbCode); |
| | | if (!content.Status) |
| | | { |
| | | throw new Exception(content.Message); |
| | | } |
| | | } |
| | | else//å
¥åºæ¾è´§è¯·æ± |
| | | { |
| | | var content = PutRequest(task.NextAddress, task); |
| | | if (!content.Status) |
| | | { |
| | | throw new Exception(content.Message); |
| | | } |
| | | } |
| | | } |
| | | task.TaskState = TaskStatusEnum.AGV_Puting.ObjToInt(); |
| | | var up = _taskRepository.UpdateData(task); |
| | | agvResponse.OK("æå","0"); |
| | | } |
| | | catch (Exception ex) |
| | |
| | | if (task == null) throw new Exception($"æªæ¾å°ä»»å¡,ä»»å¡å·ã{agvUpdateModel.ReceiveTaskID}ã"); |
| | | switch (agvUpdateModel.GoodsState) |
| | | { |
| | | //case 1://åºåºæ ¹æ®è¿ä¸ªä¿¡å·å¤æåè´§å®æ |
| | | // if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt()) |
| | | // { |
| | | // var content = TakeFinish(task.CurrentAddress); |
| | | // if (!content.Status) throw new Exception(content.Message); |
| | | // task.TaskState = TaskStatusEnum.AGV_Finish.ObjToInt(); |
| | | // var up = _taskRepository.DeleteAndMoveIntoHty(task, OperateTypeEnum.èªå¨å®æ); |
| | | // _taskService.TaskCompleted(task.TaskNum); |
| | | // } |
| | | // break; |
| | | case 2://å
¥åºæ ¹æ®è¿ä¸ªä¿¡å·å¤ææ¾è´§å®æ |
| | | case "1"://åºåºæ ¹æ®è¿ä¸ªä¿¡å·å¤æåè´§å®æ |
| | | |
| | | //æ´æ°ä»»å¡ç¶æ |
| | | _taskService.UpdateTask(task, TaskStatusEnum.AGV_TakeFinish); |
| | | if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) |
| | | { |
| | | var content = TakeFinish(task.CurrentAddress); |
| | | if (!content.Status) |
| | | { |
| | | throw new Exception(content.Message); |
| | | }; |
| | | } |
| | | else |
| | | { |
| | | if (task.TaskType == TaskTypeEnum.PrintYLInbound.ObjToInt() || task.TaskType == TaskTypeEnum.PrintYLBackInbound.ObjToInt()) |
| | | { |
| | | var content = TakeFinish(task.CurrentAddress); |
| | | if (!content.Status) |
| | | { |
| | | throw new Exception(content.Message); |
| | | }; |
| | | } |
| | | } |
| | | return agvResponse.OK("æå", "0"); |
| | | case "2"://å
¥åºæ ¹æ®è¿ä¸ªä¿¡å·å¤ææ¾è´§å®æ |
| | | if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup) |
| | | { |
| | | Dt_StationManger dt_Station = _stationMangerRepository.QueryFirst(x => x.StationCode == task.NextAddress); |
| | |
| | | { |
| | | throw new Exception($"{task.NextAddress}AGVç«å°æªå®ä¹"); |
| | | } |
| | | task.CurrentAddress = dt_Station.StationCode; |
| | | task.NextAddress = ""; |
| | | task.TaskState = TaskStatusEnum.AGV_Finish.ObjToInt(); |
| | | task.DeviceCode = dt_Station.StationDeviceCode; |
| | | var up = _taskRepository.UpdateData(task); |
| | | if (task.TaskType == TaskTypeEnum.PrintYLInbound.ObjToInt() || task.TaskType == TaskTypeEnum.PrintYLBackInbound.ObjToInt()) |
| | | { |
| | | List<Dt_Router> routers = _routerRepository.QueryData(x => x.InOutType == task.TaskType && task.NextAddress == x.StartPosi); |
| | | Dt_Router router = routers.FirstOrDefault(); |
| | | if (router == null) |
| | | { |
| | | throw new Exception($"ä»»å¡å·:{task.TaskNum}æªæ¾å°è·¯ç±é
置信æ¯"); |
| | | } |
| | | string oldAddress = task.NextAddress; |
| | | //æ´æ°ä»»å¡ç¶æ |
| | | task.CurrentAddress = router.NextPosi; |
| | | task.NextAddress = ""; |
| | | task.DeviceCode = router.ChildPosiDeviceCode; |
| | | _taskService.UpdateTask(task, TaskStatusEnum.AGV_Finish); |
| | | PutFinish(oldAddress, task.TaskNum); |
| | | } |
| | | else |
| | | { |
| | | task.CurrentAddress = dt_Station.StationCode; |
| | | task.NextAddress = ""; |
| | | task.TaskState = TaskStatusEnum.AGV_Finish.ObjToInt(); |
| | | task.DeviceCode = dt_Station.StationDeviceCode; |
| | | _taskRepository.UpdateData(task); |
| | | } |
| | | return agvResponse.OK("æå","0"); |
| | | } |
| | | break; |
| | | else |
| | | { |
| | | _taskService.TaskCompleted(task.TaskNum); |
| | | if (task.TaskType==TaskTypeEnum.PrintYLOutbound.ObjToInt() || task.TaskType == TaskTypeEnum.OutCarton.ObjToInt()) |
| | | { |
| | | PutFinish(task.NextAddress); |
| | | } |
| | | return agvResponse.OK("æå", "0"); |
| | | } |
| | | default: |
| | | throw new Exception($"æªå®ä¹æ¹æ³åã{agvUpdateModel.TaskState}ã"); |
| | | } |
| | |
| | | agvResponse.Error(ex.Message); |
| | | } |
| | | return agvResponse; |
| | | //return _taskService.AgvUpdateTask(agvUpdateModel); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="palletType"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("PutRequest"), AllowAnonymous] |
| | | public WebResponseContent PutRequest(string code, int palletType) |
| | | public WebResponseContent PutRequest(string code, Dt_Task task) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | |
| | | { |
| | | return content.Error($"æªæ¾å°ç«å°é
ç½®"); |
| | | } |
| | | #region todo:临æ¶é»è¾ |
| | | if (stationManger.StationDeviceCode=="MES") |
| | | { |
| | | |
| | | RequestAGVArriveDTO requestAGVArriveDTO =new RequestAGVArriveDTO() |
| | | { |
| | | SD_WorkCentreAgvArriveNoticeInfo=new List<AgvArriveNotice> { new AgvArriveNotice() |
| | | { |
| | | DispatchPlanMaterialId=task.DispatchPlanId, |
| | | WorkCentreCode=task.WorkCentreCode, |
| | | LocationCode=code, |
| | | CallId=Guid.NewGuid().ToString().Replace("-","") |
| | | } } |
| | | }; |
| | | MESResponse response = _taskService.MESAvgArriveNotice(requestAGVArriveDTO).DeserializeObject<MESResponse>() ?? throw new Exception("æªè·åå°è¿åä¿¡æ¯"); |
| | | if (!response.Result) |
| | | { |
| | | throw new Exception($"è°ç¨MESå°è½¦å
许æ¾è´§æ¥é,MESè¿åä¿¡æ¯"+ Regex.Replace(response.Msg, @"\\u([0-9a-fA-F]{4})", match => { |
| | | return ((char)Convert.ToInt32(match.Groups[1].Value, 16)).ToString(); |
| | | })); |
| | | } |
| | | if (response.Obj) |
| | | { |
| | | return content.Error($"å
许åæ"); |
| | | } |
| | | else |
| | | { |
| | | return content.Error($"ç¦æ¢æ¾æ"); |
| | | } |
| | | |
| | | } |
| | | #endregion |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode); |
| | | if (device == null) |
| | | { |
| | | return content.Error($"æªæ¾å°å¯¹åºè®¾å¤"); |
| | | } |
| | | |
| | | OtherDevice otherDevice = (OtherDevice)device; |
| | | |
| | | short Command = otherDevice.GetValue<R_ConveyorLineCPDB, short>(R_ConveyorLineCPDB.Command, stationManger.StationCode); |
| | | if (Command == 3) |
| | | if (device.DeviceCode.Contains("Plate")) |
| | | { |
| | | content.OK("å
è®¸æ¾æ"); |
| | | CommonConveyorLine commonConveyorLine = (CommonConveyorLine)device; |
| | | StackPlateTaskCommandCommand command = commonConveyorLine.ReadCustomer<StackPlateTaskCommandCommand>(device.DeviceCode); |
| | | |
| | | if (command != null && command.State == 2 && command.InteractiveSignal == 1) |
| | | { |
| | | return content.OK("å
è®¸æ¾æ"); |
| | | } |
| | | else |
| | | { |
| | | return content.Error("ç¦æ¢æ¾æ"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return content.Error("ç¦æ¢æ¾æ"); |
| | | |
| | | OtherDevice otherDevice = (OtherDevice)device; |
| | | |
| | | if (device.DeviceCode.Contains("CP"))//æåè¾é线 |
| | | { |
| | | short Command = otherDevice.GetValue<R_ConveyorLineCPDB, short>(R_ConveyorLineCPDB.Command, stationManger.StationCode); |
| | | if (Command == 3) |
| | | { |
| | | content.OK("å
è®¸æ¾æ"); |
| | | } |
| | | else |
| | | { |
| | | return content.Error("ç¦æ¢æ¾æ"); |
| | | } |
| | | } |
| | | else if (device.DeviceCode.Contains("Coveryor"))//æ¥é©³å° |
| | | { |
| | | bool RequestPut = otherDevice.GetValue<CoveryorDB, bool>(CoveryorDB.C_RequestPut, stationManger.StationDeviceCode); |
| | | if (!RequestPut) |
| | | { |
| | | otherDevice.SetValue(CoveryorDB.C_InTaskNum, task.TaskNum, stationManger.StationDeviceCode); |
| | | otherDevice.SetValue(CoveryorDB.C_RequestPut, true, stationManger.StationDeviceCode); |
| | | Thread.Sleep(1000); |
| | | } |
| | | bool AllowFinish = otherDevice.GetValue<CoveryorDB, bool>(CoveryorDB.C_AllowFinish, stationManger.StationDeviceCode); |
| | | if (AllowFinish) |
| | | { |
| | | content.OK("å
è®¸æ¾æ"); |
| | | } |
| | | else |
| | | { |
| | | return content.Error("ç¦æ¢æ¾æ"); |
| | | } |
| | | } |
| | | else if (device.DeviceCode.Contains("Retract"))//伸缩货å |
| | | { |
| | | bool RequestPut = otherDevice.GetValue<RetractDB, bool>(RetractDB.Ret_RequestPut, stationManger.StationDeviceCode); |
| | | if (!RequestPut) |
| | | { |
| | | otherDevice.SetValue(RetractDB.Ret_TargetAddress, Convert.ToInt16(stationManger.StationCode), stationManger.StationDeviceCode); |
| | | otherDevice.SetValue(RetractDB.Ret_RequestPut, true, stationManger.StationDeviceCode); |
| | | Thread.Sleep(1000); |
| | | } |
| | | bool AllowFinish = otherDevice.GetValue<RetractDB, bool>(RetractDB.Ret_AllowFinish, stationManger.StationDeviceCode); |
| | | if (AllowFinish) |
| | | { |
| | | content.OK("å
è®¸æ¾æ"); |
| | | } |
| | | else |
| | | { |
| | | return content.Error("ç¦æ¢æ¾æ"); |
| | | } |
| | | } |
| | | else if (device.DeviceCode.Contains("TrussCarton"))//æ¡æ¶ |
| | | { |
| | | bool RequestPut = otherDevice.GetValue<W_TrussCartonDB, bool>(GetCartonRequest(stationManger.StackerCraneStationCode), stationManger.StationDeviceCode); |
| | | if (!RequestPut) |
| | | { |
| | | otherDevice.SetValue(GetCartonRequest(stationManger.StackerCraneStationCode), true, stationManger.StationDeviceCode); |
| | | Thread.Sleep(1000); |
| | | } |
| | | bool AllowFinish = otherDevice.GetValue<R_TrussCartonDB, bool>(GetCarton(stationManger.StackerCraneStationCode), stationManger.StationDeviceCode); |
| | | if (AllowFinish) |
| | | { |
| | | content.OK("å
è®¸æ¾æ"); |
| | | } |
| | | else |
| | | { |
| | | return content.Error("ç¦æ¢æ¾æ"); |
| | | } |
| | | } |
| | | } |
| | | return content; |
| | | } |
| | |
| | | /// <param name="code"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("PutFinish"), AllowAnonymous] |
| | | public WebResponseContent PutFinish(string code) |
| | | public WebResponseContent PutFinish(string code,int taskNum=0) |
| | | { |
| | | try |
| | | { |
| | | Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.AGVStationCode == code); |
| | | Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == code); |
| | | if (stationManger == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°ç«å°é
ç½®"); |
| | |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°å¯¹åºè®¾å¤"); |
| | | } |
| | | |
| | | OtherDevice otherDevice = (OtherDevice)device; |
| | | otherDevice.SetValue(GroundStationDBName.W_PutFinish, true, stationManger.StationCode); |
| | | if (device.DeviceCode.Contains("Plate")) |
| | | { |
| | | CommonConveyorLine commonConveyorLine = (CommonConveyorLine)device; |
| | | commonConveyorLine.SetValue(StackPlateDBName.WriteInteractiveSignal, Convert.ToInt16(1), device.DeviceCode); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | else |
| | | { |
| | | OtherDevice otherDevice = (OtherDevice)device; |
| | | if (device.DeviceCode.Contains("Coveryor"))//æ¥é©³å° |
| | | { |
| | | otherDevice.SetValue(CoveryorDB.C_PutFinish, true, stationManger.StationDeviceCode); |
| | | } |
| | | else if (device.DeviceCode.Contains("Retract"))//伸缩货å |
| | | { |
| | | otherDevice.SetValue(RetractDB.Ret_PutFinish, true, stationManger.StationDeviceCode); |
| | | } |
| | | else if (device.DeviceCode.Contains("TrussCarton"))//çº¸ç®±æ¡æ¶ |
| | | { |
| | | otherDevice.SetValue(GetCartonPut(stationManger.StackerCraneStationCode), true, stationManger.StationDeviceCode); |
| | | } |
| | | } |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// è·åæ¡æ¶æ¾æä¿¡å· |
| | | /// </summary> |
| | | public W_TrussCartonDB GetCartonPut(string StationCode) |
| | | { |
| | | switch (StationCode) |
| | | { |
| | | case "1": |
| | | return W_TrussCartonDB.W_CartonPut1; |
| | | case "2": |
| | | return W_TrussCartonDB.W_CartonPut2; |
| | | case "3": |
| | | return W_TrussCartonDB.W_CartonPut3; |
| | | case "4": |
| | | return W_TrussCartonDB.W_CartonPut4; |
| | | case "5": |
| | | return W_TrussCartonDB.W_CartonPut5; |
| | | case "6": |
| | | return W_TrussCartonDB.W_CartonPut6; |
| | | default: |
| | | throw new Exception("æªå®ä¹å·¥ä½"); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// è·åæ¡æ¶è¯·æ±ä¿¡å· |
| | | /// </summary> |
| | | public W_TrussCartonDB GetCartonRequest(string StationCode) |
| | | { |
| | | switch (StationCode) |
| | | { |
| | | case "1": |
| | | return W_TrussCartonDB.W_CartonRequest1; |
| | | case "2": |
| | | return W_TrussCartonDB.W_CartonRequest2; |
| | | case "3": |
| | | return W_TrussCartonDB.W_CartonRequest3; |
| | | case "4": |
| | | return W_TrussCartonDB.W_CartonRequest4; |
| | | case "5": |
| | | return W_TrussCartonDB.W_CartonRequest5; |
| | | case "6": |
| | | return W_TrussCartonDB.W_CartonRequest6; |
| | | default: |
| | | throw new Exception("æªå®ä¹å·¥ä½"); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·åæ¡æ¶è¿å
¥ä¿¡å· |
| | | /// </summary> |
| | | public R_TrussCartonDB GetCarton(string StationCode) |
| | | { |
| | | switch (StationCode) |
| | | { |
| | | case "1": |
| | | return R_TrussCartonDB.R_CartonAllow1; |
| | | case "2": |
| | | return R_TrussCartonDB.R_CartonAllow2; |
| | | case "3": |
| | | return R_TrussCartonDB.R_CartonAllow3; |
| | | case "4": |
| | | return R_TrussCartonDB.R_CartonAllow4; |
| | | case "5": |
| | | return R_TrussCartonDB.R_CartonAllow5; |
| | | case "6": |
| | | return R_TrussCartonDB.R_CartonAllow6; |
| | | default: |
| | | throw new Exception("æªå®ä¹å·¥ä½"); |
| | | } |
| | | } |
| | | |
| | |
| | | [HttpPost, HttpGet, Route("TakeRequest"), AllowAnonymous] |
| | | public WebResponseContent TakeRequest(string code) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.AGVStationCode == code); |
| | | if (stationManger == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°ç«å°é
ç½®"); |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°ç«å°é
ç½®{code}"); |
| | | } |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode); |
| | | if (device == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°å¯¹åºè®¾å¤"); |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°å¯¹åºè®¾å¤{stationManger.StationDeviceCode}"); |
| | | } |
| | | |
| | | OtherDevice otherDevice = (OtherDevice)device; |
| | | |
| | | bool canPut = otherDevice.GetValue<GroundStationDBName, bool>(GroundStationDBName.R_IsCanTake, stationManger.StationCode); |
| | | if (canPut) |
| | | if (device.DeviceCode.Contains("Plate")) |
| | | { |
| | | otherDevice.SetValue(GroundStationDBName.W_TakeRequest, true, stationManger.StationCode); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | else |
| | | { |
| | | otherDevice.SetValue(GroundStationDBName.W_TakeRequest, true, stationManger.StationCode); |
| | | Thread.Sleep(1000); |
| | | canPut = otherDevice.GetValue<GroundStationDBName, bool>(GroundStationDBName.R_IsCanTake, stationManger.StationCode); |
| | | if (canPut) |
| | | CommonConveyorLine commonConveyorLine = (CommonConveyorLine)device; |
| | | StackPlateTaskCommandCommand command = commonConveyorLine.ReadCustomer<StackPlateTaskCommandCommand>(device.DeviceCode); |
| | | |
| | | if (command != null&&command.State == 2 && command.InteractiveSignal == 2) |
| | | { |
| | | return WebResponseContent.Instance.OK(); |
| | | return content.OK("å
许åæ"); |
| | | } |
| | | else |
| | | { |
| | | return WebResponseContent.Instance.Error($"åè´§ç³è¯·ä¸"); |
| | | return content.Error("ç¦æ¢åæ"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | OtherDevice otherDevice = (OtherDevice)device; |
| | | |
| | | if (otherDevice.DeviceCode.Contains("CP"))//æåè¾é线 |
| | | { |
| | | short Command = otherDevice.GetValue<R_ConveyorLineCPDB, short>(R_ConveyorLineCPDB.Command, stationManger.StationCode); |
| | | if (Command == 2) |
| | | { |
| | | content.OK("å
许åæ"); |
| | | } |
| | | else |
| | | { |
| | | return content.Error("ç¦æ¢åæ"); |
| | | } |
| | | } |
| | | else if (device.DeviceCode.Contains("Coveryor"))//æ¥é©³å° |
| | | { |
| | | bool AllowTake = otherDevice.GetValue<CoveryorDB, bool>(CoveryorDB.C_AllowTake, stationManger.StationDeviceCode); |
| | | if (AllowTake) |
| | | { |
| | | content.OK("å
许åæ"); |
| | | } |
| | | else |
| | | { |
| | | return content.Error("ç¦æ¢åæ"); |
| | | } |
| | | } |
| | | else if (device.DeviceCode.Contains("Retract"))//伸缩货å |
| | | { |
| | | bool AllowTake = otherDevice.GetValue<RetractDB, bool>(RetractDB.Ret_AllowTake, stationManger.StationDeviceCode); |
| | | if (AllowTake) |
| | | { |
| | | content.OK("å
许åæ"); |
| | | } |
| | | else |
| | | { |
| | | return content.Error("ç¦æ¢åæ"); |
| | | } |
| | | } |
| | | } |
| | | return content; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | //[HttpPost, HttpGet, Route("TakeFinish"), AllowAnonymous] |
| | | /// <summary> |
| | | /// åè´§å®æ |
| | | /// </summary> |
| | |
| | | { |
| | | try |
| | | { |
| | | Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.AGVStationCode == code); |
| | | Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == code); |
| | | if (stationManger == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°ç«å°é
ç½®"); |
| | |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°å¯¹åºè®¾å¤"); |
| | | } |
| | | if (device.DeviceCode.Contains("Plate")) |
| | | { |
| | | CommonConveyorLine commonConveyorLine = (CommonConveyorLine)device; |
| | | commonConveyorLine.SetValue(StackPlateDBName.WriteInteractiveSignal, Convert.ToInt16(2), device.DeviceCode); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | else |
| | | { |
| | | OtherDevice otherDevice = (OtherDevice)device; |
| | | if (device.DeviceCode.Contains("CP")) |
| | | { |
| | | otherDevice.SetValue(W_ConveyorLineCPDB.W_Command, 2, stationManger.StationCode); |
| | | } |
| | | else if (device.DeviceCode.Contains("Coveryor")) |
| | | { |
| | | otherDevice.SetValue(CoveryorDB.C_TakeFinish, true, stationManger.StationDeviceCode); |
| | | } |
| | | else if (device.DeviceCode.Contains("Retract"))//伸缩货å |
| | | { |
| | | otherDevice.SetValue(RetractDB.Ret_TakeFinish, true, stationManger.StationDeviceCode); |
| | | } |
| | | } |
| | | |
| | | OtherDevice otherDevice = (OtherDevice)device; |
| | | otherDevice.SetValue(GroundStationDBName.W_TakeFinish, true, stationManger.StationCode); |
| | | Thread.Sleep(1000); |
| | | otherDevice.SetValue(GroundStationDBName.W_TakeFinish, false, stationManger.StationCode); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// AGVç¡®è®¤å®ææ¥å£(åæ¾) |
| | | /// </summary> |
| | | /// <param name="code"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("AGVFinish"), AllowAnonymous] |
| | | public WebResponseContent AGVFinish(string address,int taskNum) |
| | | { |
| | | try |
| | | { |
| | | Dt_Task task = _taskRepository.QueryFirst(x=>x.TaskNum==taskNum && x.DeviceCode=="AGV"); |
| | | if (task==null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"{taskNum}AGVä»»å¡ä¸åå¨"); |
| | | } |
| | | //è·å对åºçåæ ç¹ |
| | | Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x=>x.AGVStationCode== address); |
| | | if (stationManger==null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"{address}AGVå°åç¼å·ä¸åå¨"); |
| | | } |
| | | if (task.TaskState == TaskStatusEnum.AGV_Executing.ObjToInt())//åè´§ |
| | | { |
| | | if (task.CurrentAddress != stationManger.StationCode) |
| | | { |
| | | return WebResponseContent.Instance.Error($"{taskNum}AGVä»»å¡åè´§å°åç¼å·ä¸æ¯{address}"); |
| | | } |
| | | AgvFinishDTO agvFinishDTO = new AgvFinishDTO() |
| | | { |
| | | ReceiveTaskID = task.TaskNum.ToString(), |
| | | Variables = new List<PointDetail>() |
| | | { |
| | | new PointDetail() |
| | | { |
| | | Code="isPick", |
| | | Value="true" |
| | | } |
| | | } |
| | | }; |
| | | //åéAGV宿éç¥ |
| | | WebResponseContent content = _taskService.AGVFinish(agvFinishDTO); |
| | | if (!content.Status) |
| | | throw new Exception(content.Message); |
| | | } |
| | | else//æ¾è´§ |
| | | { |
| | | if (task.NextAddress != stationManger.StationCode) |
| | | { |
| | | return WebResponseContent.Instance.Error($"{taskNum}AGV任塿¾è´§å°åç¼å·ä¸æ¯{address}"); |
| | | } |
| | | AgvFinishDTO agvFinishDTO = new AgvFinishDTO() |
| | | { |
| | | ReceiveTaskID = task.TaskNum.ToString(), |
| | | Variables = new List<PointDetail>() |
| | | { |
| | | new PointDetail() |
| | | { |
| | | Code="isDown", |
| | | Value="true" |
| | | } |
| | | } |
| | | }; |
| | | //åéAGV宿éç¥ |
| | | WebResponseContent content = _taskService.AGVFinish(agvFinishDTO); |
| | | if (!content.Status) |
| | | throw new Exception(content.Message); |
| | | } |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |