1
huangxiaoqiang
2025-06-05 c87ea81736b138f3969ab58850830ede2f060212
CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs
@@ -259,65 +259,27 @@
                    Platform platform = _platFormRepository.QueryFirst(x => x.DeviceCode == conveyorLine.DeviceCode && x.PlatCode == childDeviceCode && x.Status == "Active");
                    if (platform != null && !string.IsNullOrEmpty(platform.Location))
                    {
                        if (platform.PlatCode == "1299" || platform.PlatCode == "1295" || platform.PlatCode == "1291" || platform.PlatCode == "1287" || platform.PlatCode == "1283")
                        var strings = platform.Location.Split(',').ToList();
                        foreach (var ite in strings)
                        {
                            Platform platformJZ = _platFormRepository.QueryFirst(x => x.PlatCode == "10086" && x.Status == "Active");
                            if (platformJZ != null)
                            // 读取任务命令
                            ConveyorLineTaskCommand command1 = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(ite);
                            if (command1.InteractiveSignal != 2)
                            {
                                var strings = platform.Location.Split(',').ToList();
                                foreach (var ite in strings)
                                command.InteractiveSignal = writeInteractiveSignal;
                                int count = strings.Count;
                                // 获取处理方法
                                MethodInfo? method = GetType().GetMethod(platform.ExecutionMethod);
                                if (method != null)
                                {
                                    // 读取任务命令
                                    ConveyorLineTaskCommand command1 = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(ite);
                                    if (command1.InteractiveSignal != 2)
                                    {
                                        command.InteractiveSignal = writeInteractiveSignal;
                                        int count = strings.Count;
                                        // 获取处理方法
                                        MethodInfo? method = GetType().GetMethod(platform.ExecutionMethod);
                                        if (method != null)
                                        {
                                            command.InteractiveSignal = commandWrite.WriteInteractiveSignal;
                                            // 调用处理方法
                                            method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode, count, platform });
                                        }
                                    }
                                    command.InteractiveSignal = commandWrite.WriteInteractiveSignal;
                                    // 调用处理方法
                                    method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode, count, platform });
                                }
                            }
                            //else
                            //{
                            //    //ConsoleHelper.WriteErrorLine("静置空托不允许出料");
                            //}
                        }
                        else
                        {
                            var strings = platform.Location.Split(',').ToList();
                            foreach (var ite in strings)
                            {
                                // 读取任务命令
                                ConveyorLineTaskCommand command1 = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(ite);
                                if (command1.InteractiveSignal != 2)
                                {
                                    command.InteractiveSignal = writeInteractiveSignal;
                                    int count = strings.Count;
                                    // 获取处理方法
                                    MethodInfo? method = GetType().GetMethod(platform.ExecutionMethod);
                                    if (method != null)
                                    {
                                        command.InteractiveSignal = commandWrite.WriteInteractiveSignal;
                                        // 调用处理方法
                                        method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode, count, platform });
                                    }
                                }
                            }
                        }
                    }
                    //if (conveyorLine.DeviceCode == "1001")
                    //{
                    //    ConsoleHelper.WriteSuccessLine("ProcessDeviceAsync方法结束时间:" + DateTime.Now.ToString("G") + $"点位:{childDeviceCode}");
                    //}
                }
            }
            catch (Exception ex)
@@ -369,30 +331,31 @@
                        {
                            // 获取任务的下一目标地址
                            var next = task.NextAddress;
                        // 将任务映射为命令
                        var taskCommand = MapTaskCommand(task, command);
                        // 恢复任务的下一目标地址
                        task.NextAddress = next;
                        // 发送命令到子设备
                        conveyorLine.SendCommand(taskCommand, childDeviceCode);
                            // 将任务映射为命令
                            var taskCommand = MapTaskCommand(task, command);
                            // 恢复任务的下一目标地址
                            task.NextAddress = next;
                            // 发送命令到子设备
                            conveyorLine.SendCommand(taskCommand, childDeviceCode);
                        // 输出警告信息,表示任务已到达子设备并请求扫码入库,下一目标地址
                        var logs = $"【{conveyorLine._deviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{childDeviceCode}】请求扫码入库,下一目标地址【{taskCommand.TargetAddress}】";
                        ConsoleHelper.WriteWarningLine(logs);
                            // 输出警告信息,表示任务已到达子设备并请求扫码入库,下一目标地址
                            var logs = $"【{conveyorLine._deviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{childDeviceCode}】请求扫码入库,下一目标地址【{taskCommand.TargetAddress}】";
                            ConsoleHelper.WriteWarningLine(logs);
                        await _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = logs, time = DateTime.Now.ToString("G"), color = "red" });
                        WriteInfo(conveyorLine.DeviceName, logs);
                            await _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = logs, time = DateTime.Now.ToString("G"), color = "red" });
                            WriteInfo(conveyorLine.DeviceName, logs);
                        // 发送任务完成通知
                        ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
                        // 更新任务状态为下一状态
                        _taskService.UpdateTaskStatusToNext(task);
                            // 发送任务完成通知
                            ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
                            // 更新任务状态为下一状态
                            _taskService.UpdateTaskStatusToNext(task);
                        }
                    }
                }
                else
                {
                    var taskInTray = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
                    //var taskInTray = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
                    var taskInTray = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode,command.Barcode);
                    if (taskInTray != null && taskInTray.TaskType == (int)TaskInboundTypeEnum.InTray)
                    {
                        RequestInNextAddress(conveyorLine, command, childDeviceCode, ProtocalDetailValue);
@@ -493,7 +456,8 @@
            _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" });
            WriteInfo(conveyorLine.DeviceName, log);
            Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
            //Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
            Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode, command.Barcode);
            if (task != null)
            {
                if (command.Barcode == task.PalletCode)
@@ -501,6 +465,7 @@
                    Dt_Task? newTask = _taskService.UpdatePosition(task.TaskNum, task.CurrentAddress);
                    if (newTask != null)
                    {
                        //ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(newTask);
                        //taskCommand.InteractiveSignal = command.InteractiveSignal;
                        var next = newTask.NextAddress;
@@ -516,6 +481,7 @@
                        conveyorLine.SendCommand(taskCommand, childDeviceCode);
                        ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
                        _taskService.UpdateData(newTask);
                    }
                }
@@ -541,7 +507,8 @@
                _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" });
                WriteInfo(conveyorLine.DeviceName, log);
                var task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
                //var task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
                var task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode, command.Barcode);
                if (task != null && task.TaskState != (int)TaskInStatusEnum.Line_InFinish)
                {
                    if (command.Barcode == task.PalletCode && childDeviceCode == task.NextAddress)
@@ -599,6 +566,7 @@
            {
                // 查询输送线任务,根据输送线设备和子设备代码获取任务信息
                var task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
                //var task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode, command.Barcode);
                // 输出成功信息,包括输送线名称、任务号、托盘条码和子设备代码,以及任务信息
                var logs = $"【{conveyorLine._deviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{childDeviceCode}】输送线请求出库,task{task.ToJsonString()}";
@@ -663,7 +631,8 @@
            WriteInfo(conveyorLine.DeviceName, log);
            // 查询正在执行的输送线任务,根据任务号和子设备代码获取任务信息
            Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
            //Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
            Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode, command.Barcode);
            // 如果任务存在
            if (task != null)
@@ -677,6 +646,7 @@
                    // 如果更新后的任务对象不为空
                    if (newTask != null)
                    {
                        //_taskService.UpdateData(newTask);
                        // 获取下一目标地址
                        var next = newTask.NextAddress;
@@ -698,6 +668,7 @@
                        // 标记输送线发送任务完成
                        ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
                        _taskService.UpdateData(newTask);
                    }
                }
@@ -722,7 +693,8 @@
                WriteInfo(conveyorLine.DeviceName, logs);
                // 查询正在执行的输送线任务
                var task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
                //var task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
                var task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode, command.Barcode);
                // 如果任务存在
                if (task != null)