wangxinhui
2025-07-30 88676143aeceaeec3bd108f9cd609c4f3470ba96
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/³ÉÆ·²Ö/ConveyorLineJob_CP.cs
@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using Microsoft.AspNetCore.Components.Routing;
using Newtonsoft.Json;
using Quartz;
using SqlSugar.Extensions;
using System;
@@ -94,8 +95,13 @@
                                WriteError(item.StationName, $"未找到路由配置信息,设备编号:{item.StationCode},任务号:{task.TaskNum}");
                                continue;
                            }
                            _taskService.UpdateTask(task, TaskStatusEnum.Line_Executing, nextAddress: router.NextPosi, targetAddress: router.NextPosi);
                            device.SetValue(W_ConveyorLineCPDB.StartPos, task.CurrentAddress, item.StationCode);
                            //string? locationCode = _taskService.RequestAssignLocation(task.TaskNum, "AGV_CP");
                            //if (string.IsNullOrEmpty(locationCode) && task.TaskType != TaskTypeEnum.EmptyProductBack.ObjToInt())
                            //{
                            //    WriteError(item.StationName, $"请求分配货位返回信息错误,设备编号:{item.StationCode},任务号:{task.TaskNum}");
                            //    continue;
                            //}
                            device.SetValue(W_ConveyorLineCPDB.StartPos, router.StartPosi, item.StationCode);
                            device.SetValue(W_ConveyorLineCPDB.EndPos, router.NextPosi, item.StationCode);
                            device.SetValue(W_ConveyorLineCPDB.Barcode, task.PalletCode, item.StationCode);
                            device.SetValue(W_ConveyorLineCPDB.TaskNum, task.TaskNum, item.StationCode);
@@ -104,6 +110,7 @@
                            device.SetValue(W_ConveyorLineCPDB.CheckPos, 1, item.StationCode);
                            //启动指令
                            device.SetValue(W_ConveyorLineCPDB.ConveyArrival, 1, item.StationCode);
                            _taskService.UpdateTask(task, TaskStatusEnum.Line_Executing, nextAddress: router.NextPosi, targetAddress: router.NextPosi);
                            if (task.TaskType==TaskTypeEnum.EmptyProductBack.ObjToInt())
                            {
                                _taskService.TaskCompleted(task.TaskNum);
@@ -113,15 +120,15 @@
                    else if (item.StationType == StationTypeEnum.StationType_InStartAndOutEnd.ObjToInt() && deviceProRead != null)
                    {
                        R_ConveyorLineCPInfo conveyorLineInfoRead = device.Communicator.ReadCustomer<R_ConveyorLineCPInfo>(deviceProRead.DeviceProAddress);
                        if (conveyorLineInfoRead != null && conveyorLineInfoRead.EndPos.ToString()==item.StationCode)
                        if (conveyorLineInfoRead != null && conveyorLineInfoRead.EndPos.ToString() == item.StationCode)
                        {
                            short isCanTake = device.GetValue<GroundStationDBName, short>(GroundStationDBName.R_IsCanTake, item.StationCode);
                            if (conveyorLineInfoRead.ConveyArrivaled==1 && isCanTake==1)
                            if (conveyorLineInfoRead.ConveyArrivaled == 1 && isCanTake == 1)
                            {
                                //获取任务
                                Dt_Task task = _taskRepository.QueryFirst(x => x.NextAddress == item.StationCode && _taskService.TaskInboundTypes.Contains(x.TaskType) && (x.TaskState == TaskStatusEnum.Line_Executing.ObjToInt()) && x.DeviceCode == device.DeviceCode && x.TaskNum == conveyorLineInfoRead.TaskNum.ObjToInt());
                                //获取站台
                                if (task!=null)
                                if (task != null)
                                {
                                    Dt_StationManger? stationManger = stationMangers.FirstOrDefault(x => x.StationCode == item.StationCode);
                                    if (stationManger == null)
@@ -142,12 +149,12 @@
                                        WriteError(item.StationName, $"请求分配货位返回信息错误,设备编号:{item.StationCode},任务号:{task.TaskNum}");
                                        continue;
                                    }
                                    _taskService.UpdateTask(task, TaskStatusEnum.AGV_Execute,deviceCode: router.ChildPosiDeviceCode, nextAddress: locationCode, targetAddress: locationCode, currentAddress: router.StartPosi);
                                    _taskService.UpdateTask(task, TaskStatusEnum.AGV_Execute, deviceCode: router.ChildPosiDeviceCode, currentAddress: router.StartPosi, nextAddress: locationCode, targetAddress: locationCode);
                                }
                            }
                        }
                    }
                }
            }