wangxinhui
2026-03-26 5c272c606bdf2da3577dbaa5f48d0ee163f1e7d2
ÏîÄ¿´úÂë/WCS/WCSServices/WIDESEAWCS_Tasks/Ô­ÁÏ¿â/ConveyorLineJob_YL1ndFloor.cs
@@ -12,6 +12,7 @@
using WIDESEAWCS_Communicator;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_DTO.TaskInfo;
using WIDESEAWCS_IBasicInfoRepository;
using WIDESEAWCS_ITaskInfoRepository;
using WIDESEAWCS_ITaskInfoService;
@@ -73,6 +74,7 @@
                foreach (var item in stationMangers.Where(x => deviceStations.Contains(x.StationCode)))
                {
                    DeviceProDTO? deviceProRead = device.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StationCode && x.DeviceProParamType == nameof(WR_CLineYLDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
                    DeviceProDTO? deviceErrRead = device.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StationCode && x.DeviceProParamType == nameof(R_ErrorYLDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
                    if (deviceProRead != null)
                    {
                        R_ConveyorLineYLInfo conveyorLineInfoRead = device.Communicator.ReadCustomer<R_ConveyorLineYLInfo>(deviceProRead.DeviceProAddress);
@@ -119,23 +121,27 @@
                            {
                                if (string.IsNullOrEmpty(task.Roadway) && string.IsNullOrEmpty(task.NextAddress))
                                {
                                    WebResponseContent content = _taskService.AssignYLRoadwayNo(task.PalletCode);
                                    if (!content.Status)
                                    WebResponseContent content = _taskService.AssignYLRoadwayNo(task.PalletCode,weight: conveyorLineInfoRead.WR_Weight, thickness: conveyorLineInfoRead.WR_Height, wide: conveyorLineInfoRead.WR_Width);
                                    if (content.Status)
                                    {
                                        string roadWay = content.Data.ToString();
                                        //获取路由配置
                                        List<Dt_Router> routers = _routerRepository.QueryData(x => x.InOutType == task.TaskType && task.CurrentAddress == x.StartPosi && x.ChildPosiDeviceCode == roadWay);
                                        Dt_Router router = routers.FirstOrDefault();
                                        if (router == null)
                                        {
                                            WriteError(item.StationName, $"任务号:{task.TaskNum}未找到路由配置信息");
                                            return Task.CompletedTask;
                                        }
                                        task.Roadway = roadWay;
                                        task.NextAddress = router.NextPosi;
                                        _taskService.UpdateTask(task, TaskStatusEnum.AGV_Finish);
                                    }
                                    else
                                    {
                                        WriteError(item.StationCode, $"请求入库失败:{content.Message}");
                                    }
                                    string roadWay = content.Data.ToString();
                                    //获取路由配置
                                    List<Dt_Router> routers = _routerRepository.QueryData(x => x.InOutType == task.TaskType && task.CurrentAddress == x.StartPosi && x.ChildPosiDeviceCode== roadWay);
                                    Dt_Router router = routers.FirstOrDefault();
                                    if (router == null)
                                    {
                                        WriteError(item.StationName, $"任务号:{task.TaskNum}未找到路由配置信息");
                                        return Task.CompletedTask;
                                    }
                                    task.Roadway = roadWay;
                                    task.NextAddress = router.NextPosi;
                                    _taskService.UpdateTask(task,TaskStatusEnum.AGV_Finish);
                                }
                                else
                                {
@@ -173,9 +179,9 @@
                                
                            }
                        }
                        else if (conveyorLineInfoRead != null && item.StationType == StationTypeEnum.StationType_OnlyOutbound.ObjToInt() && conveyorLineInfoRead.WR_ToHode <= 0 && conveyorLineInfoRead.WR_Request == 99 && conveyorLineInfoRead.WR_Task <= 0) //出站台分配目标点
                        else if (conveyorLineInfoRead != null && item.StationType == StationTypeEnum.StationType_OnlyOutbound.ObjToInt() && conveyorLineInfoRead.WR_ToHode <= 0 && conveyorLineInfoRead.WR_Request == 99 && conveyorLineInfoRead.WR_Task > 0) //出站台分配目标点
                        {
                            Dt_Task task = _taskRepository.QueryFirst(x => x.CurrentAddress == item.StationCode && _taskService.TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == TaskStatusEnum.Line_Execute.ObjToInt() && x.DeviceCode == device.DeviceCode);
                            Dt_Task task = _taskRepository.QueryFirst(x => x.CurrentAddress == item.StationCode && x.TaskNum == conveyorLineInfoRead.WR_Task && _taskService.TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == TaskStatusEnum.Line_Execute.ObjToInt() && x.DeviceCode == device.DeviceCode);
                            if (task != null)
                            {
                                //发送目标点
@@ -201,8 +207,39 @@
                            {
                                //任务回复
                                device.SetValue(WR_CLineYLDB.WR_Reresult, 98, item.StationCode);
                                _taskService.TaskCompleted(task.TaskNum);
                                WriteInfo(item.StationCode, $"任务号:{task.TaskNum}一楼出库至老厂房完成");
                                _taskService.UpdateTask(task, TaskStatusEnum.Line_Executing, deviceCode: "CL3_YL");
                                WriteInfo(item.StationCode, $"任务号:{task.TaskNum},RIFD{task.RfidCode}一楼出库至老厂房完成");
                            }
                        }
                        else if (conveyorLineInfoRead != null && item.StationType == StationTypeEnum.StationType_InboundAndOutbound.ObjToInt() && conveyorLineInfoRead.WR_Task <= 0 && !string.IsNullOrEmpty(conveyorLineInfoRead.WR_TMID) && conveyorLineInfoRead.WR_Request == 98) //一楼老厂出库口完成
                        {
                            Dt_Task task = _taskRepository.QueryFirst(x => (x.RfidCode == conveyorLineInfoRead.WR_TMID || x.PalletCode== conveyorLineInfoRead.WR_TMID) && _taskService.TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == TaskStatusEnum.Line_Executing.ObjToInt() && x.DeviceCode == device.DeviceCode);
                            if (task != null)
                            {
                                //任务回复
                                device.SetValue(WR_CLineYLDB.WR_Reresult, 98, item.StationCode);
                                _taskService.UpdateTask(task, TaskStatusEnum.Line_Executing, deviceCode: "CL3_YL");
                                WriteInfo(item.StationCode, $"任务号:{task.TaskNum},RIFD{task.RfidCode}一楼出库至老厂房完成");
                            }
                        }
                    }
                    else if (deviceErrRead!=null)
                    {
                        R_ErrorYLDB errorYLDB = device.Communicator.ReadCustomer<R_ErrorYLDB>(deviceErrRead.DeviceProAddress);
                        if (errorYLDB != null && errorYLDB.R_Error==2)
                        {
                            ErrorDeviceInfo? errorDeviceInfo = RoadwayError.Roadways.FirstOrDefault(x=>x.Code==item.StationCode);
                            if (errorDeviceInfo==null)
                            {
                                RoadwayError.Roadways.Add(new ErrorDeviceInfo() { Code = item.StationCode, Roadway = item.StackerCraneCode });
                            }
                        }
                        else if(errorYLDB != null && errorYLDB.R_Error == 1)
                        {
                            ErrorDeviceInfo? deviceInfo = RoadwayError.Roadways.FirstOrDefault(x => x.Code == item.StationCode);
                            if (deviceInfo != null)
                            {
                                RoadwayError.Roadways.Remove(deviceInfo);
                            }
                        }
                    }