刘磊
2025-06-25 2de09bec5cc05bf875543fa8956167ca7db73021
ÏîÄ¿´úÂë/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs
@@ -85,9 +85,12 @@
                if (conveyorLine != null)
                {
                    List<Dt_StationManager> stationManagers = _stationManagerService.GetAllStationByDeviceCode(conveyorLine.DeviceCode);
                    ConveyorLineTaskCommand command2 = new ConveyorLineTaskCommand();
                    foreach (var station in stationManagers)
                    {
                        ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(station.stationChildCode);
                        DeviceProtocolDetailDTO? deviceProtocolDetails = conveyorLine.DeviceProtocolDetailDTOs.FirstOrDefault(x => x.DeviceProParamName == station.stationChildCode && x.ProtocalDetailValue == command.ConveyorLineSingal.ToString());
@@ -140,11 +143,12 @@
            }
            catch (Exception ex)
            {
                //WriteError("CommonConveyorLineJob", ex);
                Console.Out.WriteLine(nameof(CommonConveyorLineJob) + ":" + ex.ToString());
            }
            finally
            {
                //WriteDebug("CommonConveyorLineJob", "test");
                WriteDebug("CommonConveyorLineJob", "test");
                //Console.Out.WriteLine(DateTime.Now);
            }
            return;
@@ -174,7 +178,17 @@
                    if (task != null)
                    {
                        conveyorLine.SetValue(ConveyorLineDBName.Number, task.PalletCode, stationInfo.stationChildCode);
                        if ((task.TargetAddress == "2042" || task.TargetAddress == "2032") && task.TaskState == (int)TaskOutStatusEnum.SC_OutFinish)
                        {
                            conveyorLine.SetValue(ConveyorLineDBName.TargetAddress, task.TargetAddress, stationInfo.stationChildCode);
                        }
                        else
                        {
                        conveyorLine.SetValue(ConveyorLineDBName.TargetAddress, task.NextAddress, stationInfo.stationChildCode);
                        }
                        //conveyorLine.SetValue(ConveyorLineDBName.TargetAddress, task.NextAddress, stationInfo.stationChildCode);
                        conveyorLine.SetValue(ConveyorLineDBName.ResponState, 1, stationInfo.stationChildCode);
                        _taskService.UpdateTaskStatusToNext(task);
@@ -189,7 +203,16 @@
            else
            {
                conveyorLine.SetValue(ConveyorLineDBName.Number, taskNew.PalletCode, stationInfo.stationChildCode);
                if ((taskNew.TargetAddress == "2042" || taskNew.TargetAddress == "2032") && taskNew.TaskState == (int)TaskOutStatusEnum.SC_OutFinish)
                {
                    conveyorLine.SetValue(ConveyorLineDBName.TargetAddress, taskNew.TargetAddress, stationInfo.stationChildCode);
                }
                else
                {
                conveyorLine.SetValue(ConveyorLineDBName.TargetAddress, taskNew.NextAddress, stationInfo.stationChildCode);
                }
                //conveyorLine.SetValue(ConveyorLineDBName.TargetAddress, taskNew.NextAddress, stationInfo.stationChildCode);
                conveyorLine.SetValue(ConveyorLineDBName.ResponState, 1, stationInfo.stationChildCode);
                _taskService.UpdateTaskStatusToNext(taskNew);
@@ -321,30 +344,41 @@
                //根据车轴缓存位置 å†™å…¥å¯¹åº”目标地址
                if (task.TargetAddress == stationInfo.stationChildCode)
                {
                    WebResponseContent content = _taskService.RequestWheelsFlow(task.task_CZInfo).Result;
                    //WebResponseContent content = _taskService.RequestWheelsFlow(task.task_CZInfo).Result;
                    WebResponseContent content = _taskService.RequestWheelsFlow(task.PalletCode).Result;
                    if (content.Status)
                    {
                        string taraddress = content.Data.ToString(); // "2032";
                        string taraddress = content.Data.ToString(); // "2032";SourceAddress
                        conveyorLine.SetValue(ConveyorLineDBName.TargetAddress, taraddress, stationInfo.stationChildCode);
                        conveyorLine.SetValue(ConveyorLineDBName.ResponState, 1, stationInfo.stationChildCode);
                        _taskService.UpdateTaskStatusToNext(task);
                        bool k1 = conveyorLine.SetValue(ConveyorLineDBName.SourceAddress, "2021", stationInfo.stationChildCode);
                        bool k2= conveyorLine.SetValue(ConveyorLineDBName.TargetAddress, taraddress, stationInfo.stationChildCode);
                        bool k3= conveyorLine.SetValue(ConveyorLineDBName.ResponState, 1, stationInfo.stationChildCode);
                        WebResponseContent k4 = _taskService.UpdateTaskStatusToNext(task);
                        Console.Out.WriteLine($"读取到输送线申请,申请条码:{command.Number},反馈至输送线信息====起始地址:{k1},目标地址“{k2},反馈信号:{k3},任务修改状态:{k4.Status}))");
                    }
                    else
                    {
                        conveyorLine.SetValue(ConveyorLineDBName.ResponState, 2, stationInfo.stationChildCode);
                        Console.Out.WriteLine($"读取到输送线申请,申请条码:{command.Number},向WMS申请去向失败,原因:{content.Message},写入申诉信故障:2");
                    }
                }
                else
                {
                    conveyorLine.SetValue(ConveyorLineDBName.TargetAddress, task.TargetAddress, stationInfo.stationChildCode);
                    conveyorLine.SetValue(ConveyorLineDBName.ResponState, 1, stationInfo.stationChildCode);
                    _taskService.UpdateTaskStatusToNext(task);
                    bool k1= conveyorLine.SetValue(ConveyorLineDBName.SourceAddress, "2021", stationInfo.stationChildCode);
                    bool k2 = conveyorLine.SetValue(ConveyorLineDBName.TargetAddress, task.TargetAddress, stationInfo.stationChildCode);
                    bool k3 = conveyorLine.SetValue(ConveyorLineDBName.ResponState, 1, stationInfo.stationChildCode);
                    WebResponseContent k4 = _taskService.UpdateTaskStatusToNext(task);
                    Console.Out.WriteLine($"读取到输送线申请,申请条码:{command.Number},反馈至输送线信息====起始地址:{k1},目标地址“{k2},反馈信号:{k3},任务修改状态:{k4.Status}))");
                }
            }
            else
            {
                conveyorLine.SetValue(ConveyorLineDBName.ResponState, 2, stationInfo.stationChildCode);
                Console.Out.WriteLine($"读取到输送线申请,申请条码:{command.Number},未找到,写入申诉信故障:2");
            }
            //_taskService.UpdatePosition(task.TaskNum, stationInfo.stationChildCode);
        }
@@ -359,15 +393,16 @@
        /// <param name="ProtocalDetailValue">线体当前bool读取偏移地址</param>
        public void RequestCZInfo(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, Dt_StationManager stationInfo)
        {
            var task = _taskService.QueryExecutingTaskByBarcode(command.Number, stationInfo.stationChildCode);
            if (task == null)
            WebResponseContent content = _taskService.GetFeedbackAxleloading();
            if (content.Status)
            {
                //todo  æŸ¥è¯¢WMS车轴数据返回
                Random random = new Random(20);
                string cztm = "CZ00" + random.Next();
                //conveyorLine
                //conveyorLine.SetValue(ConveyorLineDBName.Number, cztm, stationInfo.stationChildCode);
                conveyorLine.SetValue(ConveyorLineDBName.Number, content.Data.ToString(), stationInfo.stationChildCode);
                conveyorLine.SetValue(ConveyorLineDBName.CarType,"001", stationInfo.stationChildCode);
                conveyorLine.SetValue(ConveyorLineDBName.ResponState, 1, stationInfo.stationChildCode);
            }
            else
            {
                conveyorLine.SetValue(ConveyorLineDBName.ResponState, 2, stationInfo.stationChildCode);
            }
        }
@@ -380,11 +415,38 @@
        /// <param name="ProtocalDetailValue">线体当前bool读取偏移地址</param>
        public void RequestTakeCZ(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, Dt_StationManager stationInfo)
        {
            var task = _taskService.QueryExecutingTaskByBarcode(command.Number, stationInfo.stationChildCode);
            if (task == null)
            WebResponseContent content = _taskService.UpdateAxleCurrentStatue(command.Number);
            if (content.Status)
            {
                //conveyorLine
                conveyorLine.SetValue(ConveyorLineDBName.ResponState, 1, stationInfo.stationChildCode);
                Console.Out.WriteLine("成功!写出车轴线末端生成agv取货任务,反馈输送线信号:1");
            }
            /*else
            {
                var log = $"【{conveyorLine.DeviceName}】,车轴条码:{command.Number},更新失败原因:{content.Message}";
                WriteInfo(conveyorLine.DeviceName, log);
                conveyorLine.SetValue(ConveyorLineDBName.ResponState, 3, stationInfo.stationChildCode);
            }*/
        }
        /// <summary>
        /// agv站台申请取料
        /// </summary>
        /// <param name="conveyorLine">输送线实例对象</param>
        /// <param name="command">读取的请求信息</param>
        /// <param name="childDeviceCode">子设备编号</param>
        /// <param name="ProtocalDetailValue">线体当前bool读取偏移地址</param>
        public void RequestagvStation(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, Dt_StationManager stationInfo)
        {
            DeviceProDTO? deviceProDTOt = conveyorLine.DeviceProDTOs.Find(x => x.DeviceChildCode == "3022" && x.DeviceProParamName == "Number");
            string Number = conveyorLine.Communicator.Read<string>(deviceProDTOt.DeviceProAddress);
            if (Number != "" && Number!=null)
            {
                //调取wms接口申请agv任务
                WebResponseContent content = _taskService.GetAGVTaskdistribution(stationInfo.stationLocation);
            }
        }
        #endregion