1
huangxiaoqiang
2025-11-10 8f7e6826d51a25c7b368c210dbb321d423d24a85
ÏîÄ¿´úÂë/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
@@ -3,6 +3,7 @@
using LogLibrary.Log;
using Mapster;
using Newtonsoft.Json;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
using SqlSugar;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
@@ -123,28 +124,23 @@
                            task.NextAddress = station.stationChildCode;
                            task.Floor = "1F";
                            task.Floor = item.Floor;
                            task.AGVSign = "";
                        }
                        else if (task.TaskState.GetTaskStateGroup() == TaskStateGroup.AcrossFloorGroup)
                        {
                            var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == item.SourceAddress);
                            var next = _stationManagerRepository.QueryFirst(x => x.stationType == 5 && x.stationFloor == item.Floor);
                            if (station != null)
                            {
                                var next = _stationManagerRepository.QueryFirst(x => x.stationType == 5 && x.stationFloor == station.stationFloor);
                            task.TaskState = (int)TaskAcrossFloorStatusEnum.CarryNew;
                                task.TaskState = (int)TaskAcrossFloorStatusEnum.CarryNew;
                            task.CurrentAddress = item.SourceAddress;
                                task.CurrentAddress = item.SourceAddress;
                            task.NextAddress = next.stationChildCode;
                                task.NextAddress = next.stationChildCode;
                            task.Floor = item.Floor;
                                task.Floor = station.stationFloor;
                                task.AGVSign = "";
                            }
                            task.AGVSign = "";
                        }
                        else if (task.TaskState.GetTaskStateGroup() == TaskStateGroup.CarryGroup)
                        {
@@ -180,22 +176,17 @@
                        }
                        else if (task.TaskState.GetTaskStateGroup() == TaskStateGroup.AcrossFloorGroup)
                        {
                            var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == item.SourceAddress);
                            var next = _stationManagerRepository.QueryFirst(x => x.stationType == 5 && x.stationFloor == item.Floor);
                            if (station != null)
                            {
                                var next = _stationManagerRepository.QueryFirst(x => x.stationType == 5 && x.stationFloor == station.stationFloor);
                            task.TaskState = (int)TaskAcrossFloorStatusEnum.CarryNew;
                                task.TaskState = (int)TaskAcrossFloorStatusEnum.CarryNew;
                            task.CurrentAddress = item.SourceAddress;
                                task.CurrentAddress = item.SourceAddress;
                            task.NextAddress = next.stationChildCode;
                                task.NextAddress = next.stationChildCode;
                            task.Floor = item.Floor;
                                task.Floor = station.stationFloor;
                                task.AGVSign = "";
                            }
                            task.AGVSign = "";
                        }
                        else if (task.TaskState.GetTaskStateGroup() == TaskStateGroup.CarryGroup)
                        {
@@ -230,26 +221,20 @@
                        }
                        else if (task.TaskState.GetTaskStateGroup() == TaskStateGroup.AcrossFloorGroup)
                        {
                            var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == item.SourceAddress);
                            var next = _stationManagerRepository.QueryFirst(x => x.stationType == 5 && x.stationFloor == item.Floor);
                            if (station != null)
                            {
                                var next = _stationManagerRepository.QueryFirst(x => x.stationType == 5 && x.stationFloor == station.stationFloor);
                            task.TaskState = (int)TaskAcrossFloorStatusEnum.CarryNew;
                                task.TaskState = (int)TaskAcrossFloorStatusEnum.CarryNew;
                            task.CurrentAddress = item.SourceAddress;
                                task.CurrentAddress = item.SourceAddress;
                            task.NextAddress = next.stationChildCode;
                                task.NextAddress = next.stationChildCode;
                            task.Floor = item.Floor;
                                task.Floor = station.stationFloor;
                                task.AGVSign = "";
                            }
                            task.AGVSign = "";
                        }
                        else if (task.TaskState.GetTaskStateGroup() == TaskStateGroup.CarryGroup)
                        {
                            var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == item.SourceAddress);
                            task.TaskState = (int)TaskAGVCarryStatusEnum.CarryNew;
@@ -257,7 +242,7 @@
                            task.NextAddress = task.TargetAddress;
                            task.Floor = station.stationFloor;
                            task.Floor = item.Floor;
                            task.AGVSign = "";
                        }
@@ -267,23 +252,19 @@
                    {
                        if (task.TaskState.GetTaskStateGroup() == TaskStateGroup.AcrossFloorGroup)
                        {
                            var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == item.SourceAddress);
                            var next = _stationManagerRepository.QueryFirst(x => x.stationType == 5 && x.stationFloor == item.Floor);
                            if (station != null)
                            {
                                var next = _stationManagerRepository.QueryFirst(x => x.stationType == 5 && x.stationFloor == station.stationFloor);
                            task.TaskState = (int)TaskAcrossFloorStatusEnum.CarryNew;
                                task.TaskState = (int)TaskAcrossFloorStatusEnum.CarryNew;
                            task.CurrentAddress = item.SourceAddress;
                                task.CurrentAddress = item.SourceAddress;
                            task.NextAddress = next.stationChildCode;
                                task.NextAddress = next.stationChildCode;
                            task.Floor = item.Floor;
                                task.Floor = station.stationFloor;
                                task.AGVSign = "";
                            }
                            task.AGVSign = "";
                        }
                    }
                    // å°†è½¬æ¢åŽçš„任务添加到任务列表中
@@ -387,7 +368,7 @@
        /// <returns></returns>
        public Dt_Task QueryRequestTSJSignalTask()
        {
            return BaseDal.QueryFirst(x => TaskAcrossFloorboundTypes.Contains(x.TaskType) && x.TaskState > (int)TaskAcrossFloorStatusEnum.CarryNew && (x.AGVSign == "RequestPickUp" || x.AGVSign == "RequestPut"));
            return BaseDal.QueryFirst(x =>  x.TaskState > (int)TaskAcrossFloorStatusEnum.CarryNew && (x.AGVSign == "RequestPickUp" || x.AGVSign == "RequestPut"));
        }
        #endregion
@@ -460,7 +441,7 @@
            try
            {
                int oldState = task.TaskState;
                if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
                if (task.TaskState.GetTaskStateGroup() == TaskStateGroup.OutbondGroup)
                {
                    int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskOutStatusEnum>();
@@ -485,8 +466,14 @@
                        content = StackCraneTaskCompleted(task.TaskNum);
                        return content;
                    }
                    if (task.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting)
                    {
                        var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.TargetAddress);
                        SendAgvTask(station.stationRemark, task.TaskNum);
                    }
                }
                else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)
                else if (task.TaskState.GetTaskStateGroup() == TaskStateGroup.InboundGroup)
                {
                    int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskInStatusEnum>();
                    task.TaskState = nextStatus;
@@ -518,7 +505,7 @@
                        //// ååºåˆ—化响应内容
                        //content = JsonConvert.DeserializeObject<WebResponseContent>(abc);
                        //LogFactory.WriteError($"Info_获取货位", $"获取货位,任务号:【{task.TaskNum}】,托盘号:【{task.PalletCode}】返回参数【{JsonConvert.SerializeObject(content)}】{Environment.NewLine}{Environment.NewLine}");
                        //LogFactory.WriteError($"获取货位", $"获取货位,任务号:【{task.TaskNum}】,托盘号:【{task.PalletCode}】返回参数【{JsonConvert.SerializeObject(content)}】");
                        //// æ£€æŸ¥çŠ¶æ€å¹¶è¿”å›ž
                        //if (!content.Status)
@@ -540,7 +527,6 @@
                        if (App.User.UserId > 0)
                        {
                            content = StackCraneTaskCompleted(task.TaskNum);
                            return content;
                        }
                        task.ModifyDate = DateTime.Now;
@@ -553,7 +539,7 @@
                        _taskHtyRepository.AddData(task_Hty);
                    }
                }
                else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.CarryGroup)
                else if (task.TaskState.GetTaskStateGroup() == TaskStateGroup.CarryGroup)
                {
                    int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskAGVCarryStatusEnum>();
@@ -561,6 +547,8 @@
                    if (task.TaskState == (int)TaskAGVCarryStatusEnum.AGV_CarryFinish)
                    {
                        CompletedTask(task.TaskNum);
                        task.ModifyDate = DateTime.Now;
                        task.Modifier = "System";
@@ -571,7 +559,7 @@
                        _taskHtyRepository.AddData(task_Hty);
                    }
                }
                else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.AcrossFloorGroup)
                else if (task.TaskState.GetTaskStateGroup() == TaskStateGroup.AcrossFloorGroup)
                {
                    int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskAcrossFloorStatusEnum>();
@@ -606,7 +594,7 @@
                            stationManager = _stationManagerRepository.QueryFirst(x => x.stationType == 5 && x.stationFloor == "1F");
                            TaskTemplate = "CCC";
                        }
                        var taskDto = new RequestAcrossFloorTaskDto()
                        {
                            NextAddress = task.NextAddress,
@@ -661,22 +649,6 @@
                        BaseDal.AddData(taskNew);
                        SendAgvTask(TaskTemplate, taskNew.TaskNum);
                        return content.OK();
                    }
                    if (task.TaskState == (int)TaskAGVCarryStatusEnum.AGV_CarryFinish)
                    {
                        CompletedTask(task.TaskNum);
                        task.ModifyDate = DateTime.Now;
                        task.Modifier = "System";
                        Dt_Task_Hty task_Hty = _mapper.Map<Dt_Task_Hty>(task);
                        task_Hty.TaskId = 0;
                        BaseDal.DeleteData(task);
                        _taskHtyRepository.AddData(task_Hty);
                    }
                }
                else
@@ -769,6 +741,8 @@
                    task.Modifier = "System";
                    BaseDal.UpdateData(task);
                    content.OK(data: task);
                    _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"堆垛机出库完成");
                }
                else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup && task.TaskState == (int)TaskInStatusEnum.SC_InExecuting)