helongyang
19 小时以前 06eb604f71605c47f015b88b1620b72b6f69df8c
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/²âÊԼܲÖ/StackerCraneJob_CSJ.cs
@@ -1,4 +1,5 @@
using AutoMapper;
using HslCommunication.WebSocket;
using Microsoft.AspNetCore.Components.Routing;
using Newtonsoft.Json;
using Quartz;
@@ -27,6 +28,7 @@
using WIDESEAWCS_QuartzJob.StackerCrane.Enum;
using WIDESEAWCS_Tasks.HoisterJob;
using WIDESEAWCS_Tasks.StackerCraneJob;
using WIDESEAWCS_Tasks.测试架仓;
namespace WIDESEAWCS_Tasks
{
@@ -36,13 +38,15 @@
        private readonly IMapper _mapper;
        private readonly ICacheService _cacheService;
        private readonly ITaskService _taskService;
        public static CSJReadData cSJReadData = new CSJReadData();
        private readonly ITaskExecuteDetailService _taskExecuteDetailService;
        private readonly ITaskRepository _taskRepository;
        private readonly IRouterService _routerService;
        private readonly IStationMangerRepository _stationMangerRepository;
        private WebSocketServer _webSocketServer;
        private List<Dt_ApiInfo> apiInfos;
        public StackerCraneJob_CSJ(ITaskService taskService, ICacheService cacheService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IRouterService routerService, IStationMangerRepository stationMangerRepository, IMapper mapper)
        public StackerCraneJob_CSJ(ITaskService taskService, ICacheService cacheService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IRouterService routerService, IStationMangerRepository stationMangerRepository, IMapper mapper, WebSocketServer webSocketServer)
        {
            _taskService = taskService;
            _taskExecuteDetailService = taskExecuteDetailService;
@@ -51,6 +55,7 @@
            _stationMangerRepository = stationMangerRepository;
            _cacheService = cacheService;
            _mapper = mapper;
            _webSocketServer = webSocketServer;
            string? apiInfoStr = _cacheService.Get("apiInfos");
            if (!string.IsNullOrEmpty(apiInfoStr))
@@ -81,6 +86,7 @@
                    commonStackerCrane.CheckStackerCraneTaskCompleted();//防止任务完成事件监测超时,再手动触发一次
                    if (commonStackerCrane.StackerCraneAutoStatusValue == StackerCraneAutoStatus.Automatic && commonStackerCrane.StackerCraneStatusValue == StackerCraneStatus.Normal && commonStackerCrane.StackerCraneWorkStatusValue == StackerCraneWorkStatus.Standby)
                    {
                        Thread.Sleep(1000);
                        Dt_Task? task = GetTask(commonStackerCrane);
                        if (task != null)
                        {
@@ -100,6 +106,14 @@
                            }
                        }
                    }
                    cSJReadData.R_CSJ_Status = ((short)commonStackerCrane.StackerCraneStatusValue);
                    cSJReadData.R_CSJ_AutoStatus = ((short)commonStackerCrane.StackerCraneAutoStatusValue);
                    cSJReadData.R_CSJ_WorkStatus = ((short)commonStackerCrane.StackerCraneWorkStatusValue);
                    cSJReadData.R_CSJ_TaskNum = commonStackerCrane.CurrentTaskNum.ObjToInt();
                    cSJReadData.R_CSJ_WorkType = commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType);
                    cSJReadData.R_CSJ_TrayType = commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.TrayType);
                    string cSJData = JsonConvert.SerializeObject(cSJReadData);
                    _webSocketServer.PublishAllClientPayload(cSJData);
                }
            }
            catch (Exception ex)
@@ -204,7 +218,7 @@
                    }
                }
            }
            //判断移库
            if (task != null && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
            {
                if (OutTaskStationIsOccupied(task) == null)
@@ -277,6 +291,8 @@
                    }
                    else if (existTask != null && existTask.TaskState != (int)TaskStatusEnum.SC_Execute)
                    {
                        WriteError(commonStackerCrane.DeviceCode, $"任务{task.TaskNum}浅货位任务{existTask.TaskNum}任务状态不为堆垛待执行");
                        _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"任务{task.TaskNum}浅货位任务{existTask.TaskNum}任务状态不为堆垛待执行");
                        return null;
                    }
                    else