helongyang
2025-06-22 dc06f58d8ed537555fd529551180f43a0586ec3f
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/¸¨ÁϲÖ/ConveyorLineJob_FL.cs
@@ -60,31 +60,38 @@
        public Task Execute(IJobExecutionContext context)
        {
            bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object? value);
            if (flag && value != null)
            try
            {
                OtherDevice device = (OtherDevice)value;
                List<string> deviceStations = device.DeviceProDTOs.Select(x => x.DeviceChildCode).ToList();
                List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData(x => x.StationDeviceCode == device.DeviceCode);
                foreach (var item in stationMangers.Where(x => deviceStations.Contains(x.StationCode)))
                bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object? value);
                if (flag && value != null)
                {
                    DeviceProDTO? deviceProRead = device.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StationCode && x.DeviceProParamType == nameof(R_ConveyorLineFLDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
                    if (item.StationType == StationTypeEnum.StationType_OnlyInbound.ObjToInt() && deviceProRead != null)
                    OtherDevice device = (OtherDevice)value;
                    List<string> deviceStations = device.DeviceProDTOs.Select(x => x.DeviceChildCode).ToList();
                    List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData(x => x.StationDeviceCode == device.DeviceCode);
                    foreach (var item in stationMangers.Where(x => deviceStations.Contains(x.StationCode)))
                    {
                        R_ConveyorLineFLInfo conveyorLineInfoRead = device.Communicator.ReadCustomer<R_ConveyorLineFLInfo>(deviceProRead.DeviceProAddress);
                        bool conveyArrivaled = device.GetValue<R_ConveyorLineFLDB, bool>(R_ConveyorLineFLDB.ConveyArrivaled, item.StationCode);
                        if (conveyArrivaled)
                        DeviceProDTO? deviceProRead = device.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StationCode && x.DeviceProParamType == nameof(R_ConveyorLineFLDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
                        if (item.StationType == StationTypeEnum.StationType_OnlyInbound.ObjToInt() && deviceProRead != null)
                        {
                            Dt_Task newTask = _taskRepository.QueryFirst(x => x.TaskNum== conveyorLineInfoRead.TaskNum.ObjToInt() && x.PalletCode == conveyorLineInfoRead.Barcode && x.TaskState == TaskStatusEnum.New.ObjToInt() && x.DeviceCode== item.StackerCraneCode && !string.IsNullOrEmpty(x.DeviceCode));
                            if (newTask != null)
                            R_ConveyorLineFLInfo conveyorLineInfoRead = device.Communicator.ReadCustomer<R_ConveyorLineFLInfo>(deviceProRead.DeviceProAddress);
                            bool conveyArrivaled = device.GetValue<R_ConveyorLineFLDB, bool>(R_ConveyorLineFLDB.ConveyArrivaled, item.StationCode);
                            if (conveyArrivaled)
                            {
                                _taskService.UpdateTask(newTask, TaskStatusEnum.AGV_Execute);
                                Dt_Task newTask = _taskRepository.QueryFirst(x => x.TaskNum == conveyorLineInfoRead.TaskNum.ObjToInt() && x.PalletCode == conveyorLineInfoRead.Barcode && x.TaskState == TaskStatusEnum.New.ObjToInt() && x.DeviceCode == item.StackerCraneCode && !string.IsNullOrEmpty(x.DeviceCode));
                                if (newTask != null)
                                {
                                    _taskService.UpdateTask(newTask, TaskStatusEnum.AGV_Execute);
                                }
                                WriteError(item.StationName, $"入库到位信号,托盘号{conveyorLineInfoRead.Barcode},任务号:{conveyorLineInfoRead.TaskNum}");
                            }
                            WriteError(item.StationName, $"入库到位信号,托盘号{conveyorLineInfoRead.Barcode},任务号:{conveyorLineInfoRead.TaskNum}");
                        }
                    }
                }
                }
            }
            catch (Exception ex)
            {
                WriteError(nameof(ConveyorLineJob_FL), ex.Message, ex);
            }
            return Task.CompletedTask;
        }