1
dengjunjie
2025-02-18 d5c610cbf2451bbf9a103c295ae51e541ad98951
ÏîÄ¿´úÂë/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/ConveyorLineExtend/ConveyorLineExtend.cs
@@ -11,6 +11,7 @@
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob;
using WIDESEAWCS_QuartzJob.DTO;
using WIDESEAWCS_QuartzJob.Models;
using WIDESEAWCS_Tasks.ConveyorLineJob;
namespace WIDESEAWCS_Tasks
@@ -33,52 +34,45 @@
                    ConveyorLineTaskCommandR command = conveyorLine.ReadCustomer<ConveyorLineTaskCommandR>(childDeviceCode);
                    if (command != null)
                    {
                        if (childDeviceCode == "101" && command.Status == (ushort)ConveyorStatus.Wait)
                        if (childDeviceCode == "1002" && command.Status == (ushort)ConveyorStatus.Wait)
                        {
                            ConveyorLineTaskCommandW taskCommand = new ConveyorLineTaskCommandW()
                            {
                                TaskNum = 131205,
                                NextAddress = 1004,
                                //PalletCode = "A0216",
                                WriterTrue=1
                            };
                            conveyorLine.SendCommand(taskCommand, childDeviceCode);
                            RequestInbound(conveyorLine, command, childDeviceCode);
                        }
                        else if (childDeviceCode == "104" && command.Status == (ushort)ConveyorStatus.Stored)
                        else if (childDeviceCode == "1004" && command.Status == (ushort)ConveyorStatus.Stored)
                        {
                            ConveyorLineInFinish(conveyorLine, command, childDeviceCode);
                        }
                        else if (childDeviceCode == "108" && command.Status == (ushort)ConveyorStatus.Stored)
                        else if (childDeviceCode == "1008" && command.Status == (ushort)ConveyorStatus.Stored)
                        {
                            ConveyorLineOutFinish(conveyorLine, command, childDeviceCode);
                        }
                    }
                    #region MyRegion
                    if (command != null && command.Status == (ushort)ConveyorStatus.Stored)//添加输送线状态ConveyorLineStatus enum
                    {
                        switch (childDeviceCode)
                        {
                            case "101":
                                {
                                    RequestInbound(conveyorLine, command, childDeviceCode);
                                }
                                break;
                            case "104":
                                ConveyorLineInFinish(conveyorLine, command, childDeviceCode);
                                break;
                            //case "105":
                            //    RequestOutbound(conveyorLine, command, childDeviceCode);
                            //    break;
                            case "108":
                                ConveyorLineOutFinish(conveyorLine, command, childDeviceCode);
                                break;
                                //default:
                                //    RequestInNextAddress(conveyorLine, command, childDeviceCode);
                                //    RequestOutNextAddress(conveyorLine, command, childDeviceCode);
                                //    break;
                        }
                    }
                    //if (command != null && command.Status == (ushort)ConveyorStatus.Stored)//添加输送线状态ConveyorLineStatus enum
                    //{
                    //    switch (childDeviceCode)
                    //    {
                    //        case "1002":
                    //            {
                    //                RequestInbound(conveyorLine, command, childDeviceCode);
                    //            }
                    //            break;
                    //        case "1004":
                    //            ConveyorLineInFinish(conveyorLine, command, childDeviceCode);
                    //            break;
                    //        //case "105":
                    //        //    RequestOutbound(conveyorLine, command, childDeviceCode);
                    //        //    break;
                    //        case "1008":
                    //            ConveyorLineOutFinish(conveyorLine, command, childDeviceCode);
                    //            break;
                    //            //default:
                    //            //    RequestInNextAddress(conveyorLine, command, childDeviceCode);
                    //            //    RequestOutNextAddress(conveyorLine, command, childDeviceCode);
                    //            //    break;
                    //    }
                    //}
                    #endregion
                }
                catch (Exception ex)
@@ -98,15 +92,19 @@
        /// <param name="childDeviceCode">子设备编号</param>
        public void RequestInbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandR command, string childDeviceCode)
        {
            //Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode, command.Barcode);
            Dt_Task task = _taskService.QueryConveyorLineTaskNum(conveyorLine.DeviceCode, childDeviceCode, command.TaskNum);
            Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode, command.Barcode);
            //Dt_Task task = _taskService.QueryConveyorLineTaskNum(conveyorLine.DeviceCode, childDeviceCode, command.TaskNum);
            if (task != null)
            {
                if (command.Spec > 0)
                {
                    DeviceProtocolDetailDTO? deviceProtocolDetail = conveyorLine.DeviceProtocolDetailDTOs.FirstOrDefault(x => x.ProtocalDetailValue == command.Spec.ToString() && x.DeviceProParamName == nameof(ConveyorLineTaskCommandR.Spec));
                    task.ExceptionMessage = deviceProtocolDetail?.ProtocolDetailDes;
                    _taskService.UpdateData(task);
                    string? Des = deviceProtocolDetail?.ProtocolDetailDes;
                    if (Des != task.ExceptionMessage)
                    {
                        task.ExceptionMessage = deviceProtocolDetail?.ProtocolDetailDes;
                        _taskService.UpdateData(task);
                    }
                    return;
                }
                ConveyorLineDTO lineDTO = new ConveyorLineDTO()
@@ -118,31 +116,40 @@
                    Weight = command.Weight,
                };
                var content = _taskService.RequestWMSTask(lineDTO);
                if (content.Status)
                if (!content.Status)
                {
                    task.CurrentAddress = childDeviceCode;
                    task.NextAddress = AppSettings.Configuration["OKAddress"];
                    task.ExceptionMessage = null;
                    ConveyorLineTaskCommandW taskCommand = _mapper.Map<ConveyorLineTaskCommandW>(task);
                    taskCommand.WriterTrue = 1;
                    if (conveyorLine.SendCommand(taskCommand, childDeviceCode))
                        _taskService.UpdateTaskStatusToNext(task);
                    task.ExceptionMessage = content?.Message;
                    _taskService.UpdateData(task);
                }
                else
                //if (content.Status)
                //{
                task.CurrentAddress = childDeviceCode;
                List<Dt_Router> routers = _routerService.QueryNextRoutes(task.CurrentAddress, task.TargetAddress);
                if (routers.Count > 0)
                {
                    //if (content.Code == 404)//修改终点地址
                    //{
                    task.CurrentAddress = childDeviceCode;
                    task.NextAddress = AppSettings.Configuration["NGAddress"];
                    task.ExceptionMessage = content.Message;
                    task.TaskState = (int)TaskInStatusEnum.InException;
                    ConveyorLineTaskCommandW taskCommand = _mapper.Map<ConveyorLineTaskCommandW>(task);
                    taskCommand.WriterTrue = 1;
                    if (conveyorLine.SendCommand(taskCommand, childDeviceCode)) _taskService.UpdateData(task);
                    //}
                    task.NextAddress = routers.FirstOrDefault().ChildPosi;
                }
                //task.NextAddress = AppSettings.Configuration["OKAddress"];
                task.ExceptionMessage = null;
                ConveyorLineTaskCommandW taskCommand = _mapper.Map<ConveyorLineTaskCommandW>(task);
                taskCommand.WriterTrue = (short)command.inRead;
                if (conveyorLine.SendCommand(taskCommand, childDeviceCode))
                    _taskService.UpdateTaskStatusToNext(task);
                //}
                //else
                //{
                //    //if (content.Code == 404)//修改终点地址
                //    //{
                //    task.CurrentAddress = childDeviceCode;
                //    task.NextAddress = AppSettings.Configuration["NGAddress"];
                //    task.ExceptionMessage = content.Message;
                //    task.TaskState = (int)TaskInStatusEnum.InException;
                //    ConveyorLineTaskCommandW taskCommand = _mapper.Map<ConveyorLineTaskCommandW>(task);
                //    taskCommand.WriterTrue = 1;
                //    if (conveyorLine.SendCommand(taskCommand, childDeviceCode)) _taskService.UpdateData(task);
                //    //}
                //}
            }
        }