liulijun
2025-11-24 9086b238cd9fbb9fbeae7cab11d59576cd9d2853
ÏîÄ¿´úÂë/WCS/WCSServices/WIDESEAWCS_Tasks/³ÉÆ·²Ö/ConveyorLineJob_CPH.cs
@@ -42,7 +42,6 @@
        private readonly IRouterExtension _routerExtension;
        private readonly List<Dt_WarehouseDevice> warehouseDevices;
        private static object lockObj = 0;//
        private static List<string> strings = new List<string>();
        public ConveyorLineJob_CPH(ICacheService cacheService, ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IStationMangerRepository stationMangerRepository, IRouterRepository routerRepository, IRouterService routerService, IRouterExtension routerExtension)
        {
@@ -54,14 +53,6 @@
            _routerRepository = routerRepository;
            _routerService = routerService;
            _routerExtension = routerExtension;
            //string boxCodes = AppSettings.Get("BoxCodes");
            //if (!string.IsNullOrEmpty(boxCodes) && strings.Count<=0)
            //{
            //    foreach (string s in boxCodes.Split(","))
            //    {
            //        strings.Add(s);
            //    }
            //}
            string? warehouseDevicesStr = _cacheService.Get<string>(nameof(Dt_WarehouseDevice));
            if (!string.IsNullOrEmpty(warehouseDevicesStr))
            {
@@ -80,19 +71,19 @@
                if (lockObj.ToString()=="0")
                {
                    lockObj = 1;
                    Task task = Task.Run(() =>
                    Task task = Task.Run(async () =>
                    {
                        try
                        {
                            while (true)
                            bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object? value);
                            if (flag && value != null)
                            {
                                bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object? value);
                                if (flag && value != null)
                                //获取当前设备
                                OtherDevice device = (OtherDevice)value;
                                List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData(x => x.StationDeviceCode == device.DeviceCode);
                                Dt_StationManger? RequestIn = stationMangers.FirstOrDefault(x => x.StationType == StationTypeEnum.StationType_OnlyInbound.ObjToInt());
                                while (true)
                                {
                                    //获取当前设备
                                    OtherDevice device = (OtherDevice)value;
                                    List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData(x => x.StationDeviceCode == device.DeviceCode);
                                    Dt_StationManger? RequestIn = stationMangers.FirstOrDefault(x => x.StationType == StationTypeEnum.StationType_OnlyInbound.ObjToInt());
                                    if (RequestIn != null)
                                    {
                                        DeviceProDTO? deviceProRead = device.DeviceProDTOs.Where(x => x.DeviceChildCode == RequestIn.StationCode && x.DeviceProParamType == nameof(R_CLineCPHDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
@@ -103,47 +94,26 @@
                                            //码垛环线请求任务 
                                            if (conveyorLineInfoRead != null && (conveyorLineInfoRead.R_State == 2 || conveyorLineInfoRead.R_State == 3) && conveyorLineInfoRead.R_TaskNo <= 0 && !string.IsNullOrEmpty(conveyorLineInfoRead.R_BoxCode) && conveyorLineInfoRead.R_Request == 1)
                                            {
                                                //WebResponseContent content = _taskService.MESBoxCodeNotice(conveyorLineInfoRead.R_BoxCode);
                                                ////向WMS请求任务
                                                //if (true)
                                                //{
                                                //}
                                                //string[] strings = conveyorLineInfoRead.R_BoxCode.Split("-");
                                                //if (strings.Length==2)
                                                //{
                                                #region todo:临时逻辑
                                                ////写入执行数据
                                                //if (strings.FirstOrDefault(x=>x == conveyorLineInfoRead.R_BoxCode)!=null)
                                                //{
                                                    device.SetValue(W_CLineCPHDB.W_TaskNo, 100 + 5, RequestIn.StationCode);
                                                    device.SetValue(W_CLineCPHDB.W_Channel, 14, RequestIn.StationCode);
                                                    device.SetValue(W_CLineCPHDB.W_Long, 465, RequestIn.StationCode);
                                                    device.SetValue(W_CLineCPHDB.W_Wide, 375, RequestIn.StationCode);
                                                    device.SetValue(W_CLineCPHDB.W_High, 690, RequestIn.StationCode);
                                                    device.SetValue(W_CLineCPHDB.W_TMID, conveyorLineInfoRead.R_BoxCode, RequestIn.StationCode);
                                                    device.SetValue(W_CLineCPHDB.W_Request, 1, RequestIn.StationCode);
                                                //    WebResponseContent content = _taskService.MESBoxCodeNotice(conveyorLineInfoRead.R_BoxCode);
                                                //    if (content.Message.Contains("true"))
                                                //    {
                                                //        strings.Remove(conveyorLineInfoRead.R_BoxCode);
                                                //        WriteInfo(RequestIn.StationName, content.Message);
                                                //    }
                                                //    else
                                                //    {
                                                //        WriteError(RequestIn.StationName, content.Message);
                                                //    }
                                                //}
                                                //else
                                                //{
                                                //    WriteError(RequestIn.StationName, $"未找到条码{conveyorLineInfoRead.R_BoxCode}数据");
                                                //}
                                                //写入执行数据
                                                device.SetValue(W_CLineCPHDB.W_TaskNo, 100 + 5, RequestIn.StationCode);
                                                device.SetValue(W_CLineCPHDB.W_Channel, 14, RequestIn.StationCode);
                                                device.SetValue(W_CLineCPHDB.W_Long, 485, RequestIn.StationCode);
                                                device.SetValue(W_CLineCPHDB.W_Wide, 460, RequestIn.StationCode);
                                                device.SetValue(W_CLineCPHDB.W_High, 420, RequestIn.StationCode);
                                                device.SetValue(W_CLineCPHDB.W_TMID, conveyorLineInfoRead.R_BoxCode, RequestIn.StationCode);
                                                device.SetValue(W_CLineCPHDB.W_Request, 1, RequestIn.StationCode);
                                                WebResponseContent content = _taskService.MESBoxCodeNotice(conveyorLineInfoRead.R_BoxCode);
                                                if (content.Status)
                                                {
                                                    WriteInfo(RequestIn.StationName, content.Message);
                                                }
                                                else
                                                {
                                                    WriteError(RequestIn.StationName, content.Message);
                                                }
                                                #endregion
                                                //}
                                                //else
                                                //{
                                                //    WriteError(RequestIn.StationName, $"数据截取错误:{strings}");
                                                //}
                                            }
                                        }
                                        else
@@ -151,7 +121,7 @@
                                            WriteError(RequestIn.StationName, $"未找到设备子编号{RequestIn.StationCode}的协议信息");
                                        }
                                    }
                                    foreach (var item in stationMangers.Where(x=>x.StationType==StationTypeEnum.StationType_OnlyOutbound.ObjToInt()))
                                    foreach (var item in stationMangers.Where(x => x.StationType == StationTypeEnum.StationType_OnlyOutbound.ObjToInt()))
                                    {
                                        DeviceProDTO? deviceProRead = device.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StationCode && x.DeviceProParamType == nameof(R_CLineCPHDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
                                        if (deviceProRead != null)
@@ -171,21 +141,20 @@
                                            }
                                        }
                                    }
                                    Thread.Sleep(100);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            lockObj = 0;
                            WriteError(nameof(ConveyorLineJob_CPH), $"错误信息:{ex.Message}");
                        }
                    });
                }
                
            }
            return Task.CompletedTask;
        }
    }