1
wangxinhui
2025-07-19 334ecd210dbadba93c8ac7cf1c6255db999f226d
ÏîÄ¿´úÂë/WCS/WCSServices/WIDESEAWCS_Tasks/³ÉÆ·²Ö/ConveyorLineJob_CPA.cs
@@ -10,6 +10,7 @@
using WIDESEAWCS_Common;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Communicator;
using WIDESEAWCS_Core;
using WIDESEAWCS_IBasicInfoRepository;
using WIDESEAWCS_ITaskInfoRepository;
using WIDESEAWCS_ITaskInfoService;
@@ -66,7 +67,9 @@
            {
                OtherDevice device = (OtherDevice)value;
                List<string> deviceStations = device.DeviceProDTOs.Select(x => x.DeviceChildCode).ToList();
                //获取有协议的输送线-z
                List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData(x => x.StationDeviceCode == device.DeviceCode);
                //让每个输送线启动-z
                foreach (var item in stationMangers.Where(x => deviceStations.Contains(x.StationCode)))
                {
                    DeviceProDTO? deviceProRead = device.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StationCode && x.DeviceProParamType == nameof(R_ConveyorLineCPDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
@@ -74,13 +77,22 @@
                    if (deviceProRead != null)
                    {
                        R_ConveyorLineCPInfo conveyorLineInfoRead = device.Communicator.ReadCustomer<R_ConveyorLineCPInfo>(deviceProRead.DeviceProAddress);
                        if (conveyorLineInfoRead.Command == 2 && conveyorLineInfoRead.TaskNo > 0)
                        if (conveyorLineInfoRead != null && conveyorLineInfoRead.Command == 2 && conveyorLineInfoRead.TaskNo > 0 && item.StationType== StationTypeEnum.StationType_OnlyInbound.ObjToInt()) //二楼线体入库站台->堆垛机
                        {
                            //获取入库站台是否存在入库任务
                            Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == conveyorLineInfoRead.TaskNo && x.NextAddress == item.StationCode && _taskService.TaskInboundTypes.Contains(x.TaskType) && x.TaskState == TaskStatusEnum.Line_Executing.ObjToInt() && x.DeviceCode == device.DeviceCode);
                            if (task != null)
                            {
                                string local = "";
                                //分配货位
                                string local = "SC01_CP-001-064-001-01";
                                if (task.HeightType==1)
                                {
                                    local = "SC02_CP-001-064-001-01";
                                }
                                else if (task.HeightType == 2)
                                {
                                    local = "SC02_CP-001-063-001-01";
                                }
                                task.CurrentAddress = item.StackerCraneStationCode;
                                task.TargetAddress= local;
                                task.NextAddress = local;
@@ -96,6 +108,31 @@
                            }
                        }
                        else if (conveyorLineInfoRead != null && conveyorLineInfoRead.Command == 4 && conveyorLineInfoRead.TaskNo <= 0 && item.StationType == StationTypeEnum.StationType_OnlyOutbound.ObjToInt()) //二楼线体出库站台
                        {
                            //获取出库站台是否存在出库待执行任务
                            Dt_Task task = _taskRepository.QueryFirst(x => x.CurrentAddress == item.StationCode && _taskService.TaskOutboundTypes.Contains(x.TaskType)
                            && x.TaskState ==TaskStatusEnum.Line_Execute.ObjToInt() && x.DeviceCode == device.DeviceCode);
                            if (task != null)
                            {
                                //获取路由配置
                                List<Dt_Router> routers = _routerRepository.QueryData(x => x.InOutType == task.TaskType && task.CurrentAddress == x.StartPosi);
                                Dt_Router router = routers.FirstOrDefault();
                                if (router == null)
                                {
                                    WriteError(item.StationName, $"任务号:{task.TaskNum}未找到路由配置信息");
                                    return Task.CompletedTask;
                                }
                                //写入出库线体地址
                                device.SetValue(W_ConveyorLineCPDB.W_TargetAddress, router.NextPosi, item.StationCode);
                                device.SetValue(W_ConveyorLineCPDB.W_TaskNo, task.TaskNum, item.StationCode);
                                device.SetValue(W_ConveyorLineCPDB.W_Command, 1, item.StationCode);
                                //更新设备
                                task.DeviceCode = router.ChildPosiDeviceCode;
                                _taskService.UpdateTask(task, TaskStatusEnum.Line_Executing);
                                WriteError(item.StationName, $"任务号:{task.TaskNum}进行线体出库");
                            }
                        }
                    }
                    else
                    {