dengjunjie
5 天以前 1daf7ed93fbdca2521edbd7fc1670ff3cd303806
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
@@ -16,9 +16,14 @@
#endregion << ç‰ˆ æœ¬ æ³¨ é‡Š >>
using AutoMapper;
using Newtonsoft.Json;
using SixLabors.ImageSharp.ColorSpaces;
using SqlSugar;
using System.Collections.Generic;
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;
@@ -34,6 +39,7 @@
using WIDESEAWCS_IBasicInfoService;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob;
using WIDESEAWCS_QuartzJob.Models;
using WIDESEAWCS_QuartzJob.Service;
@@ -50,6 +56,8 @@
        private readonly IRepository<Dt_TaskExecuteDetail> _taskExecuteDetailRepository;
        private readonly IApiInfoService _apiInfoService;
        private readonly IStationMangerService _stationMangerService;
        private readonly IStationInfoService _stationInfo;
        private readonly ITaskErrorMessageService _taskErrorMessageService;
        private readonly IMapper _mapper;
        private Dictionary<string, OrderByType> _taskOrderBy = new()
@@ -69,7 +77,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,ITrackloginfoService trackloginfoService) : 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, IStationMangerService stationMangerService, IStationInfoService stationInfo, ITaskErrorMessageService taskErrorMessageService) : base(BaseDal)
        {
            _routerService = routerService;
            _taskExecuteDetailService = taskExecuteDetailService;
@@ -80,57 +88,136 @@
            _hKLocationInfoService = hKLocationInfoService;
            _apiInfoService = apiInfoService;
            _trackloginfoService = trackloginfoService;
            _stationMangerService = stationMangerService;
            _stationInfo = stationInfo;
            _taskErrorMessageService = taskErrorMessageService;
        }
        public WebResponseContent ReceiveWMSTask([NotNull] List<WMSTasksDTO> taskDTOs)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                List<object> objects = new List<object>();
                foreach (var item in taskDTOs)
                {
                    foreach (var task in item.tasks)
                    {
                        content = TaskHelpMethods.isOkTaskInfo(task, true, true);
                        if (!content.Status) throw new Exception(content.Message);
                        if (BaseDal.QueryFirst(x => x.WMSTaskNum == task.taskCode || x.PalletCode == task.containerCode) != null)
                        #region åˆ¤æ–­
                        var contentStatus = TaskHelpMethods.isOkTaskInfo(task, true, true);
                        if (!contentStatus.Status)
                        {
                            objects.Add(new
                            {
                                taskCode = task.taskCode,
                                Message = $"任务号【{task.taskCode}】{content.Message}"
                            });
                            continue;
                        }
                        if (BaseDal.QueryFirst(x => x.WMSTaskNum == task.taskCode && x.TaskType == item.taskType) != null)
                        {
                            objects.Add(new
                            {
                                taskCode = task.taskCode,
                                Message = $"任务号【{task.taskCode}】已存在任务"
                            });
                            continue;
                            //throw new Exception($"任务号【{task.taskCode}】已存在任务");
                        }
                        if (BaseDal.QueryFirst(x => x.PalletCode == task.containerCode /*&& x.TaskType == item.taskType*/) != null)
                        {
                            objects.Add(new
                            {
                                taskCode = task.taskCode,
                                Message = $"托盘号【{task.containerCode}】已存在任务"
                            });
                            continue;
                            //throw new Exception($"托盘号【{task.containerCode}】已存在任务");
                        }
                        if (BaseDal.QueryFirst(x => x.SourceAddress == task.fromLocationCode && x.TaskType == item.taskType && x.TaskState < TaskStatusEnum.TakeFinish.ObjToInt()) != null)
                        {
                            objects.Add(new
                            {
                                taskCode = task.taskCode,
                                Message = $"起点位置【{task.fromLocationCode}】已存在任务"
                            });
                            continue;
                            //throw new Exception($"起点位置【{task.containerCode}】已存在任务");
                        }
                        #endregion
                        switch (item.taskType)
                        {
                            #region å‡¯ä¹å£«AGV面料库
                            case (int)TaskTypeEnum.MLInbound:
                                CreateKLSNewInTask(task, item.taskType);
                                content = CreateKLSNewInTask(task, item.taskType);
                                objects.Add(content.Data);
                                break;
                            case (int)TaskTypeEnum.MLOutbound:
                                CreateKLSNewOutTask(task, item.taskType);
                                content = CreateKLSNewOutTask(task, item.taskType);
                                objects.Add(content.Data);
                                break;
                            #endregion
                            #region æ—·è§†å››å‘车成品库
                            case (int)TaskTypeEnum.CPInbound:
                                CreateRGVNewInTask(task, item.taskType);
                                content = CreateRGVNewInTask(task, item.taskType);
                                objects.Add(content.Data);
                                break;
                            case (int)TaskTypeEnum.CPOutbound:
                                CreateRGVNewOutTask(task, item.taskType);
                                content = CreateRGVNewOutTask(task, item.taskType);
                                objects.Add(content.Data);
                                break;
                            case (int)TaskTypeEnum.CJInbound:
                                CreateHKNewInTask(task, item.taskType);
                            case (int)TaskTypeEnum.CPMoveInventory:
                                content = CreateRGVNewMoveTask(task, item.taskType);
                                objects.Add(content.Data);
                                break;
                            case (int)TaskTypeEnum.CJOutbound:
                                CreateHKNewOutTask(task, item.taskType);
                            #endregion
                            #region æµ·åº·AGV
                            case (int)TaskTypeEnum.STURR:
                            case (int)TaskTypeEnum.Q1TSJ4:
                                content = CreateHKNewInTask(task, item.taskType);
                                objects.Add(content.Data);
                                break;
                            case (int)TaskTypeEnum.Carry:
                                CarryTask(task, item.taskType);
                            case (int)TaskTypeEnum.STU0003:
                            case (int)TaskTypeEnum.CHUKU1:
                                content = CreateHKNewOutTask(task, item.taskType);
                                objects.Add(content.Data);
                                break;
                            case (int)TaskTypeEnum.CJCarry:
                                CJCarryTaske(task, item.taskType);
                            case (int)TaskTypeEnum.Q3RK:
                            case (int)TaskTypeEnum.Q3CK:
                                content = CarryTask(task, item.taskType);
                                objects.Add(content.Data);
                                break;
                            case (int)TaskTypeEnum.F01:
                                content = HKF01Transport(task, item.taskType);
                                break;
                            case (int)TaskTypeEnum.F04:
                            case (int)TaskTypeEnum.RK3F:
                            case (int)TaskTypeEnum.F02:
                            case (int)TaskTypeEnum.F03:
                            case (int)TaskTypeEnum.CK3F:
                                content = CJCarryTaske(task, item.taskType);
                                objects.Add(content.Data);
                                break;
                            #endregion
                            default:
                                objects.Add(new
                                {
                                    taskCode = task.taskCode,
                                    Message = $"未定义的任务类型"
                                });
                                break;
                        }
                    }
                }
                content.Data = objects;
            }
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            finally
            {
                _trackloginfoService.AddTrackLog(taskDTOs, content, $"WMS下发任务,", "", "");
            }
            return content;
        }
@@ -144,9 +231,13 @@
        public WebResponseContent CancelWMSTask(WMSCancelTask wMSCancelTask)
        {
            WebResponseContent content = new WebResponseContent();
            var KLS = new CancelGALAXISTask();
            CancelHIKROBOTTask cancelHIKROBOTTask = new CancelHIKROBOTTask();
            CancelSXCTake cancelSXCTake = new CancelSXCTake();
            var deviceName = "";
            try
            {
                Dt_Task dt_Task = BaseDal.QueryFirst(x => x.WMSTaskNum == wMSCancelTask.TaskCode);
                Dt_Task dt_Task = BaseDal.QueryFirst(x => x.WMSTaskNum == wMSCancelTask.TaskCode && x.TaskType != TaskTypeEnum.CPMoveInventory.ObjToInt());
                if (dt_Task == null) throw new Exception("未查询到任务号相关任务");
                // åˆ¤æ–­å½“前任务是否为凯乐士任务
@@ -155,13 +246,14 @@
                //四向车
                bool isAGV = dt_Task.TaskType == (int)TaskTypeEnum.CPInbound || dt_Task.TaskType == (int)TaskTypeEnum.CPOutbound;
                //海康
                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;
                bool isHK = dt_Task.TaskType == (int)TaskTypeEnum.F01 || dt_Task.TaskType == (int)TaskTypeEnum.RK3F || dt_Task.TaskType == (int)TaskTypeEnum.CK3F || dt_Task.TaskType == (int)TaskTypeEnum.Q1TSJ4 || dt_Task.TaskType == (int)TaskTypeEnum.STU0003 || dt_Task.TaskType == (int)TaskTypeEnum.F02 || dt_Task.TaskType == (int)TaskTypeEnum.CHUKU1 || dt_Task.TaskType == (int)TaskTypeEnum.Q3RK || dt_Task.TaskType == (int)TaskTypeEnum.Q3CK || dt_Task.TaskType == (int)TaskTypeEnum.STURR;
                //这里将状态改变了198取消任务
                dt_Task.TaskType = TaskStatusEnum.WMSCancel.ObjToInt();
                #region å‡¯ä¹å£«
                if (isGALAXISTask)
                {
                    var KLS = new CancelGALAXISTask
                    deviceName = "凯乐士AGV";
                    KLS = new CancelGALAXISTask
                    {
                        taskId = dt_Task.WMSTaskNum,
                        reportTime = DateTime.Now.ToString()
@@ -170,15 +262,16 @@
                    if (apiInfo == null) throw new Exception("未找到凯乐士AGV任务下发接口配置信息!请检查接口配置");
                    string response = HttpHelper.Post(apiInfo.ApiAddress, KLS.Serialize());
                    GALAXISReturn agvContent = response.DeserializeObject<GALAXISReturn>();
                    content.OK(data: agvContent);
                    if (agvContent.success == true && agvContent.code == 0)
                    {
                        //直接移入历史
                        BaseDal.DeleteAndMoveIntoHty(dt_Task, OperateTypeEnum.自动完成);
                        return content.OK("取消任务成功", dt_Task);
                        content.OK($"取消{dt_Task.WMSTaskNum}任务成功", dt_Task);
                    }
                    else
                    {
                        return content.Error($"任务失败{agvContent.data.returnInfo}");
                        content.Error($"任务{dt_Task.WMSTaskNum}失败{agvContent.data.returnInfo}");
                    }
                }
@@ -187,47 +280,72 @@
                #region å››å‘车
                if (isAGV)
                {
                    CancelSXCTake cancelSXCTake = new CancelSXCTake
                    deviceName = "四向车";
                    if (dt_Task.RGVTaskId == 0)
                    {
                        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);
                        if (dt_Task.TaskType == TaskTypeEnum.CPOutbound.ObjToInt() && dt_Task.TaskState == TaskStatusEnum.RGV_WaitSend.ObjToInt())
                        {
                            //修改库位状态
                            var rgvlocaiion = _rGVLocationInfoService.Repository.QueryFirst(x => x.LocationCode == dt_Task.SourceAddress);
                            rgvlocaiion.LocationStatus = LocationStatusEnum.InStock.ObjToInt(); //将库位状态改为有货
                        }
                        BaseDal.DeleteAndMoveIntoHty(dt_Task, OperateTypeEnum.自动删除);
                        content.OK($"取消{dt_Task.WMSTaskNum}任务成功", dt_Task);
                    }
                    else
                    {
                        return content.Error($"任务失败{fOURBOTReturn.data}");
                        cancelSXCTake = new CancelSXCTake
                        {
                            taskID = dt_Task.RGVTaskId,
                            withoutRunning = 1
                        };
                        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>();
                        content.OK(data: fOURBOTReturn);
                        if (fOURBOTReturn.returnCode == 0 && fOURBOTReturn.returnUserMsg == "成功")
                        {
                            //直接移入历史
                            BaseDal.DeleteAndMoveIntoHty(dt_Task, OperateTypeEnum.自动完成);
                            content.OK($"取消{dt_Task.WMSTaskNum}任务成功", dt_Task);
                        }
                        else
                        {
                            content.Error($"任务{dt_Task.WMSTaskNum}失败{fOURBOTReturn.data}");
                        }
                    }
                }
                #endregion
                #region æµ·åº·
                if (isHK)
                {
                    CancelHIKROBOTTask cancelHIKROBOTTask = new CancelHIKROBOTTask
                    deviceName = "海康机器人";
                    cancelHIKROBOTTask = new CancelHIKROBOTTask
                    {
                        robotTaskCode = dt_Task.WMSTaskNum,
                        cancelType = "CANCEL"//原软取消,DROP人工介入(原硬取消)
                        cancelType = "DROP"//原软取消,DROP人工介入(原硬取消)
                    };
                    var headers = new Dictionary<string, string>
                    {
                        { "X-lr-request-id", DateTimeOffset.Now.ToUnixTimeSeconds().ToString() + wMSCancelTask.TaskCode }
                    };
                    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());
                    string response = HttpHelper.Post(apiInfo.ApiAddress, cancelHIKROBOTTask.Serialize(), headers: headers);
                    HIKROBOTReturn hIKROBOTReturn = response.DeserializeObject<HIKROBOTReturn>();
                    content.OK(data: hIKROBOTReturn);
                    if (hIKROBOTReturn.code == "SUCCESS" && hIKROBOTReturn.message == "成功")
                    {
                        //直接移入历史
                        BaseDal.DeleteAndMoveIntoHty(dt_Task, OperateTypeEnum.自动完成);
                        return content.OK("取消任务成功", dt_Task);
                        content.OK("取消{dt_Task.WMSTaskNum}任务成功", dt_Task);
                    }
                    else
                    {
                        return content.Error($"任务失败{hIKROBOTReturn.data}");
                        content.Error($"任务{dt_Task.WMSTaskNum}失败,错误信息:{hIKROBOTReturn.data}");
                    }
                }
@@ -237,6 +355,10 @@
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            finally
            {
                _trackloginfoService.AddTrackLog(wMSCancelTask, content, $"取消{deviceName}任务,", "", "");
            }
            return content;
        }
@@ -250,11 +372,14 @@
        public WebResponseContent UpdateWMSTaskPriority(WMSUpdateTaskPriority updateTaskPriority)
        {
            WebResponseContent content = new WebResponseContent();
            var updateGALAXISTaskGrade = new UpdateGALAXISTaskGrade();
            var request = new UpdateAgvSXCTake();
            var Hkrequest = new HIKROBOTTaskGrade();
            try
            {
                Dt_Task dt_Task = BaseDal.QueryFirst(x => x.WMSTaskNum == updateTaskPriority.taskCode);
                if (dt_Task == null) throw new Exception("未查询到任务号相关任务");
                // åˆ¤æ–­å½“前任务是否为凯乐士任务
                bool isGALAXISTask = dt_Task.TaskType == (int)TaskTypeEnum.MLInbound ||
                                    dt_Task.TaskType == (int)TaskTypeEnum.MLOutbound;
@@ -263,31 +388,32 @@
                bool isAGV = dt_Task.TaskType == (int)TaskTypeEnum.CPInbound || dt_Task.TaskType == (int)TaskTypeEnum.CPOutbound;
                //海康
                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;
                bool isHK = dt_Task.TaskType == (int)TaskTypeEnum.F01 || dt_Task.TaskType == (int)TaskTypeEnum.RK3F || dt_Task.TaskType == (int)TaskTypeEnum.CK3F || dt_Task.TaskType == (int)TaskTypeEnum.Q1TSJ4 || dt_Task.TaskType == (int)TaskTypeEnum.STU0003 || dt_Task.TaskType == (int)TaskTypeEnum.F02 || dt_Task.TaskType == (int)TaskTypeEnum.CHUKU1 || dt_Task.TaskType == (int)TaskTypeEnum.Q3RK || dt_Task.TaskType == (int)TaskTypeEnum.Q3CK;
                //修改原本任务优先级
                dt_Task.Grade = updateTaskPriority.taskPriority;
                #region å‡¯ä¹å£«
                if (isGALAXISTask)
                {
                    var updateGALAXISTaskGrade = new UpdateGALAXISTaskGrade
                    updateGALAXISTaskGrade = new UpdateGALAXISTaskGrade
                    {
                        taskId = dt_Task.WMSTaskNum,
                        reportTime = DateTime.Now.ToString(),
                        district = dt_Task.Roadway,//任务库区
                        priorityCode = updateTaskPriority.taskPriority,
                    };
                    Dt_ApiInfo? apiInfo = _apiInfoService.Repository.QueryFirst(x => x.ApiCode == nameof(UpdateGALAXISTaskGrade));
                    if (apiInfo == null) throw new Exception("未找到凯乐士AGV任务下发接口配置信息!请检查接口配置");
                    string response = HttpHelper.Post(apiInfo.ApiAddress, updateGALAXISTaskGrade.Serialize());
                    GALAXISReturn agvContent = response.DeserializeObject<GALAXISReturn>();
                    content.OK(data: agvContent);
                    if (agvContent.success == true && agvContent.code == 0)
                    {
                        BaseDal.UpdateData(dt_Task);
                        return content.OK("修改任务优先级成功", dt_Task);
                        content.OK($"修改{dt_Task.WMSTaskNum}任务优先级成功", dt_Task);
                    }
                    else {
                        return content.Error($"任务失败{agvContent.data.returnInfo}");
                    else
                    {
                        content.Error($"{dt_Task.WMSTaskNum}任务失败,错误信息:{agvContent.data.returnInfo}");
                    }
                }
                #endregion
@@ -295,23 +421,24 @@
                #region å››å‘车
                if (isAGV)
                {
                    var request = new UpdateAgvSXCTake
                    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任务下发接口配置信息!请检查接口配置");
                    if (apiInfo == null) throw new Exception("未找到更新四向车任务优先级接口配置信息!请检查接口配置");
                    string response = HttpHelper.Post(apiInfo.ApiAddress, request.Serialize());
                    FOURBOTReturn fOURBOTReturn = response.DeserializeObject<FOURBOTReturn>();
                    if (fOURBOTReturn.returnCode == 0 && fOURBOTReturn .returnUserMsg== "成功")
                    content.OK(data: fOURBOTReturn);
                    if (fOURBOTReturn.returnCode == 0 && fOURBOTReturn.returnUserMsg == "成功")
                    {
                        BaseDal.UpdateData(dt_Task);
                        return content.OK("修改任务优先级成功", dt_Task);
                        content.OK("修改{dt_Task.WMSTaskNum}任务优先级成功", dt_Task);
                    }
                    else
                    {
                        return content.Error($"任务失败{fOURBOTReturn.data}");
                        content.Error($"任务{dt_Task.WMSTaskNum}失败,错误信息:{fOURBOTReturn.data}");
                    }
                }
@@ -319,23 +446,24 @@
                #region æµ·åº·
                if (isHK)
                {
                    var request = new HIKROBOTTaskGrade
                    Hkrequest = 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=="成功")
                    string response = HttpHelper.Post(apiInfo.ApiAddress, Hkrequest.Serialize());
                    HIKROBOTReturn hIKROBOTReturn = response.DeserializeObject<HIKROBOTReturn>();
                    content.OK(data: hIKROBOTReturn);
                    if (hIKROBOTReturn.code == "SUCCESS0" && hIKROBOTReturn.message == "成功")
                    {
                        BaseDal.UpdateData(dt_Task);
                        return content.OK("修改任务优先级成功", dt_Task);
                        content.OK("修改{dt_Task.WMSTaskNum}任务优先级成功", dt_Task);
                    }
                    else
                    {
                        return content.Error($"任务失败{hIKROBOTReturn.data}");
                        content.Error($"任务{dt_Task.WMSTaskNum}失败,错误信息{hIKROBOTReturn.data}");
                    }
                }
                #endregion
@@ -343,6 +471,33 @@
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            finally
            {
                // åœ¨ finally ä¸­åˆ¤æ–­å“ªä¸ªå¯¹è±¡è¢«èµ‹å€¼äº†
                object logObject = null;
                string deviceName = "";
                if (updateGALAXISTaskGrade != null)
                {
                    logObject = updateGALAXISTaskGrade;
                    deviceName = "凯乐士AGV";
                }
                else if (Hkrequest != null)
                {
                    logObject = Hkrequest;
                    deviceName = "海康机器人";
                }
                else if (request != null)
                {
                    logObject = request;
                    deviceName = "四向车";
                }
                if (logObject != null)
                {
                    _trackloginfoService.AddTrackLog(logObject, content, $"修改{deviceName}任务优先级", "", "");
                }
            }
            return content;
        }
@@ -357,11 +512,11 @@
            try
            {
                var rgv = new List<Dt_RGVLocationInfo>();
                var kls=new List<Dt_KLSLocationInfo>();
                var hk=new List<Dt_HKLocationInfo>();
                if(wMSUpdateLocationArea.WarehouseId == 1)
                var kls = new List<Dt_KLSLocationInfo>();
                var hk = new List<Dt_HKLocationInfo>();
                if (wMSUpdateLocationArea.WarehouseId == 1)
                {
                     var rgvList = _rGVLocationInfoService.Repository.QueryData(x =>wMSUpdateLocationArea.LocationCodes.Contains(x.LocationCode)).ToList();
                    var rgvList = _rGVLocationInfoService.Repository.QueryData(x => wMSUpdateLocationArea.LocationCodes.Contains(x.LocationCode)).ToList();
                    foreach (var item in rgvList)
                    {
                        item.WarehouseId = wMSUpdateLocationArea.UpdateAreaCode.ObjToInt();
@@ -403,7 +558,7 @@
        private void UpdateLocationCode(object LocationInfo, string updateAreaCode)
        {
        }
@@ -946,31 +1101,118 @@
        }
        /// <summary>
        /// å®¹å™¨æµåŠ¨è¯·æ±‚
        /// </summary>
        /// <param name="wMSContainerFlow"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public WebResponseContent ContainerFlow(WMSContainerFlow wMSContainerFlow)
        {
           return WebResponseContent.Instance.Error("该接口暂未实现");
        }
        /// <summary>
        /// åŒºåŸŸåº“位信息查询
        /// </summary>
        /// <param name="AreaCode"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException">区域号</exception>
        public WebResponseContent LocationInquiry(string AreaCode)
        public WebResponseContent LocationInquiry(WMSGetLocationInfo getLocationInfo)
        {
            if (AreaCode == null)
            WebResponseContent content = new WebResponseContent();
            List<object> list = new List<object>();
            try
            {
                //查询输送线空托缓存信息时返回空位数量
            }
            return WebResponseContent.Instance.OK();
                if (getLocationInfo == null) throw new Exception("请求参数不能为空!");
                //if (getLocationInfo.AreaCode == null) throw new Exception("库区编号不能为空!");
                if (getLocationInfo.WarehouseId == 0) throw new Exception("仓库ID不能为空!");
                if (getLocationInfo.WarehouseId == 1)
                {
                    List<Dt_RGVLocationInfo> rGVLocationInfos = new List<Dt_RGVLocationInfo>();
                    if (!string.IsNullOrEmpty(getLocationInfo.AreaCode))
                        rGVLocationInfos = _rGVLocationInfoService.Repository.QueryData(x => x.WarehouseId == getLocationInfo.AreaCode.ObjToInt());
                    else
                        rGVLocationInfos = _rGVLocationInfoService.Repository.QueryData();
                    foreach (var item in rGVLocationInfos)
                    {
                        list.Add(new
                        {
                            LoctionCode = item.LocationCode,
                            LocationStatus = item.LocationStatus,
                            EnableStatus = item.EnableStatus,
                            PalletCode = item.PalletCode
                        });
                    }
                    content.OK(data: list);
                }
                else if (getLocationInfo.WarehouseId == 2)
                {
                    List<Dt_KLSLocationInfo> rGVLocationInfos = new List<Dt_KLSLocationInfo>();
                    if (!string.IsNullOrEmpty(getLocationInfo.AreaCode))
                        rGVLocationInfos = _kLSLocationInfoService.Repository.QueryData(x => x.WarehouseId == getLocationInfo.AreaCode.ObjToInt());
                    else
                        rGVLocationInfos = _kLSLocationInfoService.Repository.QueryData();
                    foreach (var item in rGVLocationInfos)
                    {
                        list.Add(new
                        {
                            LoctionCode = item.LocationCode,
                            LocationStatus = item.LocationStatus,
                            EnableStatus = item.EnableStatus,
                            PalletCode = item.PalletCode
                        });
                    }
                    content.OK(data: list);
                }
                else if (getLocationInfo.WarehouseId == 3)
                {
                    //这里是提升机的
                    var device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "TSJ") as OtherDevice;
                    if (device == null) throw new Exception("未找到提升机设备信息");
                    if (!device.IsConnected) throw new Exception("PLC1提升机设备连接失败");
                    var value = device.GetValue<HoistEnum, short>(HoistEnum.Outboundmaterialbox, "TSJC3F");
                    list.Add(new
                    {
                        LoctionCode = value,
                        LocationStatus = value != 0 ? 100 : 0,
                        EnableStatus = 0,
                    });
                    content.OK(data: list);
                }
                else if (getLocationInfo.WarehouseId == 4)
                {
                    List<Dt_HKLocationInfo> rGVLocationInfos = new List<Dt_HKLocationInfo>();
                    if (!string.IsNullOrEmpty(getLocationInfo.AreaCode))
                        rGVLocationInfos = _hKLocationInfoService.Repository.QueryData(x => x.WarehouseId == getLocationInfo.AreaCode.ObjToInt());
                    else
                        rGVLocationInfos = _hKLocationInfoService.Repository.QueryData();
                    foreach (var item in rGVLocationInfos)
                    {
                        list.Add(new
                        {
                            LoctionCode = item.LocationCode,
                            LocationStatus = item.LocationStatus,
                            EnableStatus = item.EnableStatus,
                            PalletCode = item.PalletCode
                        });
                    }
                    content.OK(data: list);
                }
                else if (getLocationInfo.WarehouseId == 5)
                {
                    //读取光电信号
                    var device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "F1") as OtherDevice;
                    if (device == null) throw new Exception("未找到1楼质检门设备信息");
                    if (!device.IsConnected) throw new Exception("PLC1楼质检门设备连接失败");
                    var sta = _stationMangerService.Repository.QueryData(x => x.StationName.Contains("成品仓"));
                    foreach (var item in sta)
                    {
                        bool value = device.GetValue<QualityInspectionCommandEnum, bool>(QualityInspectionCommandEnum.R_StockAvailableSymbol, item.StationCode);
                        list.Add(new
                        {
                            LoctionCode = item.StationCode,
                            LocationStatus = value ? 100 : 0,
                            EnableStatus = 0,
                        });
                    }
                    content.OK(data: list);
                }
            }
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            return content;
        }
@@ -994,7 +1236,28 @@
        {
            throw new NotImplementedException();
        }
        public WebResponseContent InboundElevatorExit(string LocationCode, string containerCode)
        {
            WebResponseContent content = new WebResponseContent();
            inboundElevatorExitDTO inboundElevator=new inboundElevatorExitDTO();
            try
            {
                Dt_ApiInfo? apiInfo = _apiInfoService.Repository.QueryFirst(x => x.ApiCode == nameof(inboundElevatorExitDTO)) ?? throw new Exception("未找到4F提升机出口托盘号上报WMS接口配置信息!请检查接口配置");
                inboundElevator.containerCode= containerCode;
                inboundElevator.toLocationCode = LocationCode;
                string response = HttpHelper.Post(apiInfo.ApiAddress, inboundElevator.Serialize());
                content.OK(data: response);
                return WebResponseContent.Instance.OK();
            }
            catch (Exception ex)
            {
                return WebResponseContent.Instance.Error(ex.Message);
            }
            finally
            {
                _trackloginfoService.AddTrackLog(inboundElevator, content, "4F提升机出口托盘号上报WMS", "", "");
            }
        }
        /// <summary>
        /// æ–™ç®±éªŒè¯
        /// </summary>
@@ -1003,7 +1266,30 @@
        /// <returns></returns>
        public WebResponseContent MaterialBoxInspection(string taskCode, string containerCode)
        {
            throw new NotImplementedException();
            WebResponseContent content = new WebResponseContent();
            inboundTransportCheckDTO checkDTO = new inboundTransportCheckDTO();
            try
            {
                checkDTO.containerCode = containerCode;
                Dt_ApiInfo? apiInfo = _apiInfoService.Repository.QueryFirst(x => x.ApiCode == nameof(inboundTransportCheckDTO)) ?? throw new Exception("未找到裁片入库3F到4F运输箱号校验接口配置信息!请检查接口配置");
                string response = HttpHelper.Post(apiInfo.ApiAddress, checkDTO.Serialize());
                content.OK(data: response);
                WMSReturn wMSReturn = response.DeserializeObject<WMSReturn>();
                if (wMSReturn == null) throw new Exception("WMS返回结果转换失败!");
                if (!wMSReturn.success) throw new Exception(wMSReturn.message);
                string dataJson = wMSReturn.result.ToString();
                Exists? exists = JsonConvert.DeserializeObject<Exists>(dataJson);
                if (exists == null) throw new Exception($"WMS返回结果的result转换失败");
                return WebResponseContent.Instance.OK(exists.errorAreaCode);
            }
            catch (Exception ex)
            {
                return WebResponseContent.Instance.Error(ex.Message);
            }
            finally
            {
                _trackloginfoService.AddTrackLog(checkDTO, content, "裁片入库3F到4F运输箱号校验", "", "");
            }
        }
        /// <summary>
@@ -1014,15 +1300,93 @@
        {
            throw new NotImplementedException();
        }
        /// <summary>
        /// å®¹å™¨æµåŠ¨è¯·æ±‚
        /// </summary>
        /// <param name="wMSContainerFlow"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public WebResponseContent ContainerRequest(WMSContainerFlow wMSContainerFlow)
        {
            throw new NotImplementedException();
            try
            {
                Dt_StationManger stationManger = _stationMangerService.Repository.QueryFirst(x => x.StationCode == wMSContainerFlow.slotCode) ?? throw new Exception($"未找到站台【{wMSContainerFlow.slotCode}】信息");
                Dt_ApiInfo? apiInfo = _apiInfoService.Repository.QueryFirst(x => x.ApiCode == "releaseStation") ?? throw new Exception("未找到站点容器释放接口配置信息!请检查接口配置");
                if (wMSContainerFlow.direction == "200")
                {
                    stationManger.IsOccupied = LocationStatusEnum.Free.ObjToInt();
                    FOURBOToccupyStation fOURBOToccupyStation = new FOURBOToccupyStation()
                    {
                        stationCode = wMSContainerFlow.slotCode,
                    };
                    string response = HttpHelper.Post(apiInfo.ApiAddress, fOURBOToccupyStation.Serialize());
                    FOURBOTReturn fOURBOTReturn = response.DeserializeObject<FOURBOTReturn>();
                    if (fOURBOTReturn.returnCode != 0) throw new Exception(fOURBOTReturn.returnUserMsg);
                    _stationMangerService.UpdateData(stationManger);
                }
                return WebResponseContent.Instance.OK();
            }
            catch (Exception ex)
            {
                return WebResponseContent.Instance.Error(ex.Message);
            }
        }
        /// <summary>
        /// è´¨æ£€ç»“果反馈
        /// </summary>
        /// <param name="iQC"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public WebResponseContent IQCResult(IQCResultDTO iQC)
        {
            throw new NotImplementedException();
            WebResponseContent content = new WebResponseContent();
            try
            {
                #region å®¹å™¨ä¸Šæž¶
                Dt_StationManger stationManger = _stationMangerService.Repository.QueryFirst(x => x.StationCode == iQC.StationCode) ?? throw new Exception($"未找到站台【{iQC.StationCode}】信息");
                Dt_ApiInfo? apiInfo = _apiInfoService.Repository.QueryFirst(x => x.ApiCode == nameof(FOURBOToccupyStation)) ?? throw new Exception("未找到站点容器上架接口配置信息!请检查接口配置");
                FOURBOToccupyStation fOURBOToccupyStation = new FOURBOToccupyStation()
                {
                    stationCode = iQC.StationCode,
                    podID = iQC.ContainerCode,
                };
                string response = HttpHelper.Post(apiInfo.ApiAddress, fOURBOToccupyStation.Serialize());
                FOURBOTReturn fOURBOTReturn = response.DeserializeObject<FOURBOTReturn>();
                content.OK(data: fOURBOTReturn);
                if (fOURBOTReturn.returnCode != 0 /*&& fOURBOTReturn.returnUserMsg != $"站点已被占用,(podID={iQC.ContainerCode})"*/)
                    throw new Exception(fOURBOTReturn.returnUserMsg);
                #endregion
                #region åˆ›å»ºå››å‘车任务
                //var task = BaseDal.QueryFirst(x => x.PalletCode == iQC.ContainerCode && x.SourceAddress == iQC.StationCode && x.TaskState == (int)TaskStatusEnum.New);
                #endregion
                #region å‘¼å«å››å‘车
                //apiInfo = _apiInfoService.Repository.QueryFirst(x => x.ApiCode == nameof(FOURBOTnewMovePodTask)) ?? throw new Exception("未找到四向车任务下发接口配置信息!请检查接口配置");
                //FOURBOTnewMovePodTask fOURBOTnewMovePodTask = new()
                //{
                //    priority = task.Grade,
                //    podID = task.PalletCode,
                //    //desNodeID = task.SourceAddress,
                //    desExt = new
                //    {
                //        unload = 0//是否放下容器,0否1是
                //    },
                //    desStationCodes = task.SourceAddress,
                //    desType = 5
                //};
                //response = HttpHelper.Post(apiInfo.ApiAddress, fOURBOTnewMovePodTask.Serialize());
                //fOURBOTReturn = response.DeserializeObject<FOURBOTReturn>();
                //content.Data = fOURBOTReturn;
                //if (fOURBOTReturn.returnCode != 0) throw new Exception(fOURBOTReturn.returnUserMsg);
                //task.TaskState = (int)TaskStatusEnum.Execut;
                //BaseDal.UpdateData(task);
                #endregion
                return WebResponseContent.Instance.OK();
            }
            catch (Exception ex)
            {
                return WebResponseContent.Instance.Error(ex.Message);
            }
        }
        /// <summary>
@@ -1035,10 +1399,10 @@
        {
            try
            {
                var  Agvlocation = _rGVLocationInfoService.Repository.QueryData(x=> fOURBOTStorageStatusNotify.storageCode.Contains(x.LocationCode));
                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);
                    item.EnableStatus = (int)(fOURBOTStorageStatusNotify.disable == 0 ? EnableStatusEnum.Normal : EnableStatusEnum.Disable);
                }
                _rGVLocationInfoService.UpdateData(Agvlocation);
                return WebResponseContent.Instance.OK();
@@ -1049,5 +1413,34 @@
                return WebResponseContent.Instance.Error(ex.Message);
            }
        }
        public override WebResponseContent DeleteData(object[] keys)
        {
            try
            {
                // æŸ¥æ‰¾æ‰€æœ‰ä»»åŠ¡ä¸­åŒ…å«è¿™ä¸ªid的
                var take = BaseDal.QueryData(x => keys.Contains(x.TaskId));
                // æ‰§è¡Œç§»å…¥åŽ†å²æ“ä½œï¼Œå¹¶æ£€æŸ¥ç»“æžœ
                bool moveResult = BaseDal.DeleteAndMoveIntoHty(take, OperateTypeEnum.人工删除);
                if (!moveResult)
                {
                    // ç§»å…¥åŽ†å²å¤±è´¥ï¼Œè¿”å›žé”™è¯¯ä¿¡æ¯
                    return WebResponseContent.Instance.Error("移入历史记录失败");
                }
                return WebResponseContent.Instance.OK("删除成功,数据已移入历史");
            }
            catch (Exception ex)
            {
                // è®°å½•异常日志
                // Logger.Error(ex.Message);
                return WebResponseContent.Instance.Error("删除失败:" + ex.Message);
            }
        }
    }
}