wanshenmean
昨天 0b2869539598059704e1d208e2bcb18603b0fe0f
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotTaskProcessor.cs
@@ -124,6 +124,20 @@
        }
        /// <summary>
        /// 按任务编号获取机器人任务
        /// </summary>
        /// <remarks>
        /// 用于 RobotJob 快速查找执行中的任务,避免全表扫描。
        /// 优先通过状态中缓存的 CurrentTaskNum 定位任务。
        /// </remarks>
        /// <param name="taskNum">机器人任务编号</param>
        /// <returns>匹配的任务对象,如果没有则返回 null</returns>
        public Dt_RobotTask? GetTaskByNum(int taskNum)
        {
            return _robotTaskService.Repository.QueryFirst(x => x.RobotTaskNum == taskNum);
        }
        /// <summary>
        /// 按设备编码获取当前机器人的执行中任务
        /// </summary>
        /// <remarks>
@@ -186,6 +200,7 @@
            // 将任务关联到状态对象
            state.CurrentTask = task;
            state.CurrentTaskNum = task.RobotTaskNum;
            if (isScanNG)
            {
@@ -276,6 +291,7 @@
            // 将任务关联到状态对象
            state.CurrentTask = task;
            state.CurrentTaskNum = task.RobotTaskNum;
            if (_stateManager.TryUpdateStateSafely(state.IPAddress, state))
            {
@@ -346,6 +362,7 @@
            task.RobotTaskState = TaskRobotStatusEnum.RobotExecuting.GetHashCode();
            state.CurrentTask = task;
            state.CurrentTaskNum = task.RobotTaskNum;
            if (_stateManager.TryUpdateStateSafely(state.IPAddress, state))
            {
@@ -389,6 +406,7 @@
        {
            task.RobotTaskState = TaskRobotStatusEnum.RobotExecuting.GetHashCode();
            state.CurrentTask = task;
            state.CurrentTaskNum = task.RobotTaskNum;
            if (_stateManager.TryUpdateStateSafely(state.IPAddress, state))
            {
@@ -434,6 +452,7 @@
        {
            task.RobotTaskState = TaskRobotStatusEnum.RobotExecuting.GetHashCode();
            state.CurrentTask = task;
            state.CurrentTaskNum = task.RobotTaskNum;
            if (_stateManager.TryUpdateStateSafely(state.IPAddress, state))
            {
@@ -688,9 +707,9 @@
                        // 通道/位置编号
                        Channel = x,
                        // 电池条码:如果状态中有条码列表,取对应位置的条码;否则为空
                        // 电池条码:使用当前批次条码列表,取对应位置的条码;否则为空
                        //CellBarcode = state.CellBarcode?.Count > 0 ? state.CellBarcode[x - 1] : ""
                        CellBarcode = !state.CellBarcode.IsNullOrEmpty() ? state.CellBarcode[idx].ToString() ?? string.Empty : string.Empty
                        CellBarcode = !state.CurrentBatchBarcodes.IsNullOrEmpty() ? state.CurrentBatchBarcodes[idx].ToString() ?? string.Empty : string.Empty
                    })
                    .ToList()
            };