yanjinhui
2026-03-05 2a849d2f6220733dea112d09eb1f0bfb8fa2e28f
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
@@ -16,12 +16,10 @@
#endregion << ç‰ˆ æœ¬ æ³¨ é‡Š >>
using AutoMapper;
using Dm;
using SqlSugar;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
using WIDESEAWCS_BasicInfoService;
using WIDESEAWCS_Common;
using WIDESEAWCS_Common.LocationEnum;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseRepository;
@@ -29,6 +27,8 @@
using WIDESEAWCS_Core.Enums;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_DTO;
using WIDESEAWCS_DTO.AGV.HIKROBOT;
using WIDESEAWCS_DTO.RGV.FOURBOT;
using WIDESEAWCS_DTO.TaskInfo;
using WIDESEAWCS_DTO.WMS;
using WIDESEAWCS_IBasicInfoService;
@@ -41,6 +41,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;
@@ -68,7 +69,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;
@@ -77,7 +78,8 @@
            _kLSLocationInfoService = kLSLocationInfoService;
            _rGVLocationInfoService = rGVLocationInfoService;
            _hKLocationInfoService = hKLocationInfoService;
            _apiInfoService = apiInfoService;
            _apiInfoService = apiInfoService;
            _trackloginfoService = trackloginfoService;
        }
        public WebResponseContent ReceiveWMSTask([NotNull] List<WMSTasksDTO> taskDTOs)
        {
@@ -156,6 +158,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
@@ -179,6 +182,57 @@
                    }
                }
                #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
                #region æµ·åº·
                if (isHK)
                {
                    CancelHIKROBOTTask cancelHIKROBOTTask = new CancelHIKROBOTTask
                    {
                        robotTaskCode = dt_Task.WMSTaskNum,
                        cancelType = "CANCEL"//原软取消,DROP人工介入(原硬取消)
                    };
                    Dt_ApiInfo? apiInfo = _apiInfoService.Repository.QueryFirst(x => x.ApiCode == nameof(CancelHIKROBOTTask));
                    if (apiInfo == null) throw new Exception("未找到四向车AGV任务下发接口配置信息!请检查接口配置");
                    string response = HttpHelper.Post(apiInfo.ApiAddress, cancelHIKROBOTTask.Serialize());
                    HIKROBOTReturn hIKROBOTReturn = response.DeserializeObject<HIKROBOTReturn>();
                    if (hIKROBOTReturn.code == "SUCCESS" && hIKROBOTReturn.message == "成功")
                    {
                        //直接移入历史
                        BaseDal.DeleteAndMoveIntoHty(dt_Task, OperateTypeEnum.自动完成);
                        return content.OK("取消任务成功", dt_Task);
                    }
                    else
                    {
                        return content.Error($"任务失败{hIKROBOTReturn.data}");
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
@@ -217,7 +271,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,
@@ -229,6 +283,7 @@
                    if (agvContent.success == true && agvContent.code == 0)
                    {
                        BaseDal.UpdateData(dt_Task);
                        return content.OK("修改任务优先级成功", dt_Task);
                    }
                    else {
@@ -236,7 +291,54 @@
                    }
                }
                #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== "成功")
                    {
                        BaseDal.UpdateData(dt_Task);
                        return content.OK("修改任务优先级成功", dt_Task);
                    }
                    else
                    {
                        return content.Error($"任务失败{fOURBOTReturn.data}");
                    }
                }
                #endregion
                #region æµ·åº·
                if (isHK)
                {
                    var request = new HIKROBOTTaskGrade
                    {
                        robotTaskCode = dt_Task.WMSTaskNum,//任务号
                        initPriority = updateTaskPriority.taskPriority//优先级
                    };
                    Dt_ApiInfo? apiInfo = _apiInfoService.Repository.QueryFirst(x => x.ApiCode == nameof(HIKROBOTTaskGrade));
                    if (apiInfo == null) throw new Exception("未找到四向车AGV任务下发接口配置信息!请检查接口配置");
                    string response = HttpHelper.Post(apiInfo.ApiAddress, request.Serialize());
                    HIKROBOTReturn hIKROBOTReturn=response.DeserializeObject<HIKROBOTReturn>();
                    if (hIKROBOTReturn.code == "SUCCESS0"&&hIKROBOTReturn.message=="成功")
                    {
                        BaseDal.UpdateData(dt_Task);
                        return content.OK("修改任务优先级成功", dt_Task);
                    }
                    else
                    {
                        return content.Error($"任务失败{hIKROBOTReturn.data}");
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
@@ -912,5 +1014,40 @@
        {
            throw new NotImplementedException();
        }
        public WebResponseContent ContainerRequest(WMSContainerFlow wMSContainerFlow)
        {
            throw new NotImplementedException();
        }
        public WebResponseContent IQCResult(IQCResultDTO iQC)
        {
            throw new NotImplementedException();
        }
        /// <summary>
        /// æ‰¹é‡æ›´æ–°å‚¨ä½çŠ¶æ€
        /// </summary>
        /// <param name="fOURBOTStorageStatusNotify"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public WebResponseContent multiSetNodeStatus(FOURBOTStorageStatusNotify fOURBOTStorageStatusNotify)
        {
            try
            {
                var  Agvlocation = _rGVLocationInfoService.Repository.QueryData(x=> fOURBOTStorageStatusNotify.storageCode.Contains(x.LocationCode));
                foreach (var item in Agvlocation)
                {
                    item.LocationStatus = (int)(fOURBOTStorageStatusNotify.disable==0?EnableStatusEnum.Normal:EnableStatusEnum.Disable);
                }
                _rGVLocationInfoService.UpdateData(Agvlocation);
                return WebResponseContent.Instance.OK();
            }
            catch (Exception ex)
            {
                return WebResponseContent.Instance.Error(ex.Message);
            }
        }
    }
}