|  |  |  | 
|---|
|  |  |  | using WIDESEAWCS_Common.APIEnum; | 
|---|
|  |  |  | using WIDESEAWCS_Common.TaskEnum; | 
|---|
|  |  |  | using WIDESEAWCS_Core; | 
|---|
|  |  |  | using WIDESEAWCS_Core.Enums; | 
|---|
|  |  |  | using WIDESEAWCS_Core.Helper; | 
|---|
|  |  |  | using WIDESEAWCS_Model.Models; | 
|---|
|  |  |  | using WIDESEAWCS_QuartzJob; | 
|---|
|  |  |  | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | new CodePath() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | type="00", | 
|---|
|  |  |  | type="04", | 
|---|
|  |  |  | positionCode=agvTask.NextAddress | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | 
|---|
|  |  |  | var WaitToTasks = _taskService.Db.Queryable<Dt_Task>().Where(x => x.TaskState == TaskStatusEnum.AGV_WaitToExecute.ObjToInt() && nameof(AGV_ZHJob).Contains(x.DeviceCode)).ToList().OrderBy(x => x.Grade).ThenBy(x => x.CreateDate).ToList(); | 
|---|
|  |  |  | foreach (var WaitToTask in WaitToTasks) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | AgvSecureReplyDTO replyDTO = new AgvSecureReplyDTO(); | 
|---|
|  |  |  | if (WaitToTask.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (WaitToTasks.FirstOrDefault(x => x.TaskState == TaskStatusEnum.AGV_Puting.ObjToInt() || x.TaskState == TaskStatusEnum.Finish.ObjToInt()) != null) | 
|---|
|  |  |  | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | otherDevice.SetValue(GroundStationDBName.W_PutPalletType, WaitToTask.PalletType, stationManger.StationCode); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | replyDTO.ReqCode = Guid.NewGuid().ToString().Replace("-", "");//WaitToTask.TaskNum.ToString(), | 
|---|
|  |  |  | replyDTO.taskCode = WaitToTask.AgvTaskNum; | 
|---|
|  |  |  | replyDTO.nextPositionCode = new CodePath() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | type="00", | 
|---|
|  |  |  | positionCode= stationManger.AGVStationCode | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | replyDTO.ReqCode = Guid.NewGuid().ToString().Replace("-", "");//WaitToTask.TaskNum.ToString(), | 
|---|
|  |  |  | replyDTO.taskCode = WaitToTask.AgvTaskNum; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | AgvSecureReplyDTO replyDTO = new AgvSecureReplyDTO() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | ReqCode = Guid.NewGuid().ToString().Replace("-", ""), //WaitToTask.TaskNum.ToString(), | 
|---|
|  |  |  | taskCode = WaitToTask.AgvTaskNum, | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | WebResponseContent content = _taskService.AgvSecureReply(replyDTO); | 
|---|
|  |  |  | if (content.Status && WaitToTask.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | _taskService.UpdateData(WaitToTasks); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //åæ¾è´§å®æåå
¥å¼å¸¸å¤ç | 
|---|
|  |  |  | Dt_Task? TakeErroeTask = _taskService.Db.Queryable<Dt_Task>().Where(x => x.TaskState == TaskStatusEnum.AGV_TakeError.ObjToInt() && nameof(AGV_ZHJob).Contains(x.DeviceCode)).First(); | 
|---|
|  |  |  | if (TakeErroeTask != null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.AGVStationCode == TakeErroeTask.CurrentAddress); | 
|---|
|  |  |  | if (stationManger == null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | throw new Exception($"æªæ¾å°ç«å°é
ç½®"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode); | 
|---|
|  |  |  | if (device == null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | throw new Exception($"æªæ¾å°å¯¹åºè®¾å¤"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | OtherDevice otherDevice = (OtherDevice)device; | 
|---|
|  |  |  | otherDevice.SetValue(GroundStationDBName.W_TakeFinish, true, stationManger.StationCode); | 
|---|
|  |  |  | Thread.Sleep(1000); | 
|---|
|  |  |  | otherDevice.SetValue(GroundStationDBName.W_TakeFinish, false, stationManger.StationCode); | 
|---|
|  |  |  | TakeErroeTask.TaskState = TaskStatusEnum.AGV_Finish.ObjToInt(); | 
|---|
|  |  |  | var up = _taskRepository.DeleteAndMoveIntoHty(TakeErroeTask, OperateTypeEnum.èªå¨å®æ); | 
|---|
|  |  |  | _taskService.TaskCompleted(TakeErroeTask.TaskNum); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Dt_Task? PutErroeTask = _taskService.Db.Queryable<Dt_Task>().Where(x => x.TaskState == TaskStatusEnum.AGV_PutError.ObjToInt() && nameof(AGV_ZHJob).Contains(x.DeviceCode)).First(); | 
|---|
|  |  |  | if (PutErroeTask != null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.AGVStationCode == PutErroeTask.NextAddress); | 
|---|
|  |  |  | if (stationManger == null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | throw new Exception($"æªæ¾å°ç«å°é
ç½®"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode); | 
|---|
|  |  |  | if (device == null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | throw new Exception($"æªæ¾å°ç«å°é
ç½®"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | OtherDevice otherDevice = (OtherDevice)device; | 
|---|
|  |  |  | otherDevice.SetValue(GroundStationDBName.W_PutFinish, true, stationManger.StationCode); | 
|---|
|  |  |  | PutErroeTask.CurrentAddress = stationManger.StationCode; | 
|---|
|  |  |  | PutErroeTask.NextAddress = ""; | 
|---|
|  |  |  | PutErroeTask.TaskState = TaskStatusEnum.AGV_Finish.ObjToInt(); | 
|---|
|  |  |  | PutErroeTask.DeviceCode = "SC01_ZH"; | 
|---|
|  |  |  | var up = _taskRepository.UpdateData(PutErroeTask); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception ex) | 
|---|
|  |  |  | { | 
|---|