wangxinhui
2 天以前 2c889b38311883ceb703c4e0034c798fdaa2e21c
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/×躸²Ö/AGV_ZHExtend.cs
@@ -7,6 +7,7 @@
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;
@@ -176,6 +177,50 @@
                    }
                }
                _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)
            {