1
yanjinhui
2026-03-03 9df00ed513b03b093c62bbcc2d1b887e14924553
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
@@ -29,6 +29,7 @@
using WIDESEAWCS_Core.Enums;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_DTO;
using WIDESEAWCS_DTO.RGV.FOURBOT;
using WIDESEAWCS_DTO.TaskInfo;
using WIDESEAWCS_DTO.WMS;
using WIDESEAWCS_IBasicInfoService;
@@ -41,6 +42,7 @@
{
    public partial class TaskService : ServiceBase<Dt_Task, IRepository<Dt_Task>>, ITaskService
    {
        private readonly ITrackloginfoService _trackloginfoService;
        private readonly IRouterService _routerService;
        private readonly ITaskExecuteDetailService _taskExecuteDetailService;
        private readonly IHKLocationInfoService _hKLocationInfoService;
@@ -48,6 +50,7 @@
        private readonly IRGVLocationInfoService _rGVLocationInfoService;
        private readonly IRepository<Dt_TaskExecuteDetail> _taskExecuteDetailRepository;
        private readonly IApiInfoService _apiInfoService;
        private readonly IStationMangerService _stationMangerService;
        private readonly IMapper _mapper;
        private Dictionary<string, OrderByType> _taskOrderBy = new()
@@ -67,7 +70,7 @@
        /// </summary>
        public IRepository<Dt_Task> Repository => BaseDal;
        public TaskService(IRepository<Dt_Task> BaseDal, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, IRepository<Dt_TaskExecuteDetail> taskExecuteDetailRepository, IMapper mapper, IKLSLocationInfoService kLSLocationInfoService, IRGVLocationInfoService rGVLocationInfoService, IHKLocationInfoService hKLocationInfoService, IApiInfoService apiInfoService) : base(BaseDal)
        public TaskService(IRepository<Dt_Task> BaseDal, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, IRepository<Dt_TaskExecuteDetail> taskExecuteDetailRepository, IMapper mapper, IKLSLocationInfoService kLSLocationInfoService, IRGVLocationInfoService rGVLocationInfoService, IHKLocationInfoService hKLocationInfoService, IApiInfoService apiInfoService,ITrackloginfoService trackloginfoService) : base(BaseDal)
        {
            _routerService = routerService;
            _taskExecuteDetailService = taskExecuteDetailService;
@@ -76,7 +79,8 @@
            _kLSLocationInfoService = kLSLocationInfoService;
            _rGVLocationInfoService = rGVLocationInfoService;
            _hKLocationInfoService = hKLocationInfoService;
            _apiInfoService = apiInfoService;
            _apiInfoService = apiInfoService;
            _trackloginfoService = trackloginfoService;
        }
        public WebResponseContent ReceiveWMSTask([NotNull] List<WMSTasksDTO> taskDTOs)
        {
@@ -155,6 +159,7 @@
                bool isHK = dt_Task.TaskType == (int)TaskTypeEnum.Carry || dt_Task.TaskType == (int)TaskTypeEnum.CJInbound || dt_Task.TaskType == (int)TaskTypeEnum.CJInbound || dt_Task.TaskType == (int)TaskTypeEnum.CJOutbound;
                //这里将状态改变了198取消任务
                dt_Task.TaskType = TaskStatusEnum.WMSCancel.ObjToInt();
                #region
                if (isGALAXISTask)
                {
                    var KLS = new CancelGALAXISTask
@@ -178,6 +183,31 @@
                    }
                }
                #endregion
                #region å››å‘车
                if (isAGV)
                {
                    CancelSXCTake cancelSXCTake = new CancelSXCTake
                    {
                        taskID = dt_Task.RGVTaskId
                    };
                    Dt_ApiInfo? apiInfo = _apiInfoService.Repository.QueryFirst(x => x.ApiCode == nameof(CancelSXCTake));
                    if (apiInfo == null) throw new Exception("未找到四向车AGV任务下发接口配置信息!请检查接口配置");
                    string response = HttpHelper.Post(apiInfo.ApiAddress, cancelSXCTake.Serialize());
                    FOURBOTReturn fOURBOTReturn = response.DeserializeObject<FOURBOTReturn>();
                    if (fOURBOTReturn.returnCode == 0 && fOURBOTReturn.returnUserMsg == "成功")
                    {
                        //直接移入历史
                        BaseDal.DeleteAndMoveIntoHty(dt_Task, OperateTypeEnum.自动完成);
                        return content.OK("取消任务成功", dt_Task);
                    }
                    else
                    {
                        return content.Error($"任务失败{fOURBOTReturn.data}");
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
@@ -216,7 +246,7 @@
                {
                    var updateGALAXISTaskGrade = new UpdateGALAXISTaskGrade
                    {
                        taskId = dt_Task.TaskNum.ToString(),
                        taskId = dt_Task.WMSTaskNum,
                        reportTime = DateTime.Now.ToString(),
                        district = dt_Task.Roadway,//任务库区
                        priorityCode = updateTaskPriority.taskPriority,
@@ -228,6 +258,7 @@
                    if (agvContent.success == true && agvContent.code == 0)
                    {
                        BaseDal.UpdateData(dt_Task);
                        return content.OK("修改任务优先级成功", dt_Task);
                    }
                    else {
@@ -235,7 +266,31 @@
                    }
                }
                #endregion
                #region å››å‘车
                if (isAGV)
                {
                    var request = new UpdateAgvSXCTake
                    {
                        taskID = dt_Task.RGVTaskId,
                        priority = updateTaskPriority.taskPriority
                    };
                    Dt_ApiInfo? apiInfo = _apiInfoService.Repository.QueryFirst(x => x.ApiCode == nameof(UpdateAgvSXCTake));
                    if (apiInfo == null) throw new Exception("未找到四向车AGV任务下发接口配置信息!请检查接口配置");
                    string response = HttpHelper.Post(apiInfo.ApiAddress, request.Serialize());
                    FOURBOTReturn fOURBOTReturn = response.DeserializeObject<FOURBOTReturn>();
                    if (fOURBOTReturn.returnCode == 0 && fOURBOTReturn .returnUserMsg== "成功")
                    {
                        return content.OK("修改任务优先级成功", dt_Task);
                    }
                    else
                    {
                        return content.Error($"任务失败{fOURBOTReturn.data}");
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {