From 3c7658b4fff5cfba50105357eb3723dcbcea5c6a Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期五, 27 十二月 2024 18:38:24 +0800
Subject: [PATCH] AGV接口逻辑

---
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/TaskEnum/TaskStatusEnum.cs   |    8 +
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/AGV/AGVJob.cs                 |   62 +-------
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/InvokeAGVService.cs |   15 +-
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/AGV/AGVExtend.cs              |  121 +++++++++++++++++
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/AGVController.cs |  139 +++++++++++++++++++
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_SystemRepository/Sys_MenuRepository.cs |   34 ++--
 6 files changed, 296 insertions(+), 83 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/TaskEnum/TaskStatusEnum.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/TaskEnum/TaskStatusEnum.cs"
index 8424dd8..80b262c 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/TaskEnum/TaskStatusEnum.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/TaskEnum/TaskStatusEnum.cs"
@@ -52,7 +52,13 @@
         /// AGV瀹屾垚
         /// </summary>
         [Description("AGV瀹屾垚")]
-        AGV_Finish = 320,
+        AGV_Finish = 330,
+
+        /// <summary>
+        /// AGV寰呯户缁墽琛�
+        /// </summary>
+        [Description("AGV寰呯户缁墽琛�")]
+        AGV_WaitToExecute = 320,
 
         /// <summary>
         /// 浠诲姟瀹屾垚
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/AGVController.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/AGVController.cs"
index bf814b7..0cf13a6 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/AGVController.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/AGVController.cs"
@@ -1,8 +1,14 @@
 锘縰sing Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
+using WIDESEA_DTO.Agv;
+using WIDESEAWCS_Common.TaskEnum;
 using WIDESEAWCS_Core;
+using WIDESEAWCS_Core.Enums;
+using WIDESEAWCS_Core.Helper;
 using WIDESEAWCS_IBasicInfoRepository;
+using WIDESEAWCS_ITaskInfoRepository;
+using WIDESEAWCS_ITaskInfoService;
 using WIDESEAWCS_Model.Models;
 using WIDESEAWCS_QuartzJob;
 using WIDESEAWCS_Tasks;
@@ -14,13 +20,121 @@
     public class AGVController : ControllerBase
     {
         private readonly IStationMangerRepository _stationMangerRepository;
+        private readonly ITaskService _taskService;
+        private readonly ITaskRepository _taskRepository;
 
-        public AGVController(IStationMangerRepository stationMangerRepository)
+        public AGVController(IStationMangerRepository stationMangerRepository, ITaskService taskService, ITaskRepository taskRepository)
         {
             _stationMangerRepository = stationMangerRepository;
+            _taskService = taskService;
+            _taskRepository = taskRepository;
+        }
+        /// <summary>
+        /// 瀹夊叏淇″彿鐢宠 AGV-WCS
+        /// </summary>
+        /// <param name="secureApplyModel"></param>
+        /// <returns></returns>
+        [HttpPost, HttpGet, Route("AgvSecureApply"), AllowAnonymous]
+        public AgvResponseContent AgvSecureApply([FromBody] AgvSecureApplyDTO secureApplyModel)
+        {
+            AgvResponseContent agvResponseContent = new AgvResponseContent();
+            agvResponseContent.ReqCode = secureApplyModel.ReqCode;
+            try
+            {
+                var task = _taskRepository.QueryFirst(x => secureApplyModel.TaskCode.ObjToInt() == x.TaskNum);
+                if (task == null) throw new Exception("鏈壘鍒颁换鍔�");
+                if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt())
+                {
+                    var content = TakeRequest(task.CurrentAddress);
+                    if (!content.Status) throw new Exception(content.Message);
+                }
+                else
+                {
+                    var content = PutRequest(task.NextAddress, task.PalletType);
+                    if (!content.Status) throw new Exception(content.Message);
+                }
+                task.TaskState = TaskStatusEnum.AGV_WaitToExecute.ObjToInt();
+                var up = _taskRepository.UpdateData(task);
+                agvResponseContent.Code = up ? "0" : "1";
+                agvResponseContent.Message = up ? "鎴愬姛" : "澶辫触";
+            }
+            catch (Exception ex)
+            {
+                agvResponseContent.Code = "1";
+                agvResponseContent.Message = ex.Message;
+            }
+            return agvResponseContent;
+            //return _taskService.AgvSecureApply(secureApplyModel);
+        }
+        /// <summary>
+        /// AGV浠诲姟鏇存柊/瀹屾垚
+        /// </summary>
+        /// <param name="agvUpdateModel"></param>
+        /// <returns></returns>
+        [HttpPost, HttpGet, Route("AgvCallback"), AllowAnonymous]
+        public AgvResponseContent AgvUpdateTask([FromBody] AgvUpdateDTO agvUpdateModel)
+        {
+            AgvResponseContent agvResponseContent = new AgvResponseContent();
+            try
+            {
+                if (agvUpdateModel == null) throw new Exception("鏈幏鍙栧埌璇锋眰鍙傛暟");
+                agvResponseContent.ReqCode = agvUpdateModel.ReqCode;
+                var task = _taskRepository.QueryFirst(x => agvUpdateModel.TaskCode.ObjToInt() == x.TaskNum);
+                if (task == null) throw new Exception("鏈壘鍒颁换鍔�");
+                switch (agvUpdateModel.Method)
+                {
+                    case "start":
+                        break;
+                    case "outbin"://鍑哄簱鏍规嵁杩欎釜淇″彿鍒ゆ柇鍙栬揣瀹屾垚
+                        if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt())
+                        {
+                            var content = TakeFinish(task.CurrentAddress);
+                            if (!content.Status) throw new Exception(content.Message);
+                            task.TaskState = TaskStatusEnum.AGV_Finish.ObjToInt();
+                            var up = _taskRepository.DeleteAndMoveIntoHty(task, OperateTypeEnum.鑷姩瀹屾垚);
+                            agvResponseContent.Code = up ? "0" : "1";
+                            agvResponseContent.Message = up ? "鎴愬姛" : "澶辫触";
+                            return agvResponseContent;
+                        }
+                        break;
+                    case "end"://鍏ュ簱鏍规嵁杩欎釜淇″彿鍒ゆ柇鏀捐揣瀹屾垚
+                        if (task.TaskType != TaskTypeEnum.Outbound.ObjToInt())
+                        {
+                            var content = PutFinish(task.CurrentAddress);
+                            if (!content.Status) throw new Exception(content.Message);
+                            task.TaskState = TaskStatusEnum.SC_Execute.ObjToInt();
+                            var up = _taskRepository.UpdateData(task);
+                            agvResponseContent.Code = up ? "0" : "1";
+                            agvResponseContent.Message = up ? "鎴愬姛" : "澶辫触";
+                            return agvResponseContent;
+                        }
+                        break;
+                    case "cancel":
+                        task.TaskState = TaskStatusEnum.Cancel.ObjToInt();
+                        _taskRepository.UpdateData(task);
+                        break;
+                    default:
+                        throw new Exception($"鏈畾涔夋柟娉曞悕銆恵agvUpdateModel.Method}銆�");
+                }
+                agvResponseContent.Code = "0";
+                agvResponseContent.Message = "鎴愬姛";
+            }
+            catch (Exception ex)
+            {
+                agvResponseContent.Code = "1";
+                agvResponseContent.Message = ex.Message;
+            }
+            return agvResponseContent;
+            //return _taskService.AgvUpdateTask(agvUpdateModel);
         }
 
-        [HttpPost, HttpGet, Route("PutRequest"), AllowAnonymous]
+        /// <summary>
+        /// 鏀捐揣璇锋眰
+        /// </summary>
+        /// <param name="code"></param>
+        /// <param name="palletType"></param>
+        /// <returns></returns>
+        //[HttpPost, HttpGet, Route("PutRequest"), AllowAnonymous]
         public WebResponseContent PutRequest(string code, int palletType)
         {
             try
@@ -65,7 +179,12 @@
             }
         }
 
-        [HttpPost, HttpGet, Route("PutFinish"), AllowAnonymous]
+        //[HttpPost, HttpGet, Route("PutFinish"), AllowAnonymous]
+        /// <summary>
+        /// 鏀捐揣瀹屾垚
+        /// </summary>
+        /// <param name="code"></param>
+        /// <returns></returns>
         public WebResponseContent PutFinish(string code)
         {
             try
@@ -92,7 +211,12 @@
             }
         }
 
-        [HttpPost, HttpGet, Route("TakeRequest"), AllowAnonymous]
+        //[HttpPost, HttpGet, Route("TakeRequest"), AllowAnonymous]
+        /// <summary>
+        /// 鍙栬揣璇锋眰
+        /// </summary>
+        /// <param name="code"></param>
+        /// <returns></returns>
         public WebResponseContent TakeRequest(string code)
         {
             try
@@ -136,7 +260,12 @@
             }
         }
 
-        [HttpPost, HttpGet, Route("TakeFinish"), AllowAnonymous]
+        //[HttpPost, HttpGet, Route("TakeFinish"), AllowAnonymous]
+        /// <summary>
+        /// 鍙栬揣瀹屾垚
+        /// </summary>
+        /// <param name="code"></param>
+        /// <returns></returns>
         public WebResponseContent TakeFinish(string code)
         {
             try
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/InvokeAGVService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/InvokeAGVService.cs"
index 5f367e3..129ec17 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/InvokeAGVService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/InvokeAGVService.cs"
@@ -6,6 +6,7 @@
 using System.Threading.Tasks;
 using WIDESEA_DTO.Agv;
 using WIDESEAWCS_Common.APIEnum;
+using WIDESEAWCS_Common.TaskEnum;
 using WIDESEAWCS_Core;
 using WIDESEAWCS_Core.Helper;
 
@@ -23,12 +24,12 @@
             WebResponseContent content = new WebResponseContent();
             try
             {
-                string apiAddress = AppSettings.Get(APIEnum.AgvSendTask.ToString());
+                string apiAddress = "http://10.30.4.19:8182/rcms/services/rest/hikRpcService/genAgvSchedulingTask";// AppSettings.Get(APIEnum.AgvSendTask.ToString());
                 string response = HttpHelper.Post(apiAddress, taskModel.Serialize());
                 AgvResponseContent agvContent = response.DeserializeObject<AgvResponseContent>();
-                if (agvContent.Code == "200")
+                if (agvContent.Code == "0")
                 {
-                    content.OK(agvContent.Message);
+                    content.OK(data: agvContent.Data);
                 }
                 else
                 {
@@ -46,11 +47,10 @@
         /// </summary>
         public AgvResponseContent AgvSecureApply(AgvSecureApplyDTO secureApplyModel)
         {
-
             return new AgvResponseContent();
         }
         /// <summary>
-        /// 瀹夊叏淇″彿鍥炲 WCS-AGV
+        /// 瀹夊叏淇″彿鍥炲 WCS-AGV  //AGV浠诲姟缁х画鎵ц
         /// </summary>
         /// <param name="secureModel"></param>
         /// <returns></returns>
@@ -59,10 +59,10 @@
             WebResponseContent content = new WebResponseContent();
             try
             {
-                string apiAddress = AppSettings.Get(APIEnum.AgvSecureReply.ToString());
+                string apiAddress = "http://10.30.4.19:8182/rcms/services/rest/hikRpcService/continueTask";// AppSettings.Get(APIEnum.AgvSecureReply.ToString());
                 string response = HttpHelper.Post(apiAddress, secureReplyModel.Serialize());
                 AgvResponseContent agvContent = response.DeserializeObject<AgvResponseContent>();
-                if (agvContent.Code == "200")
+                if (agvContent.Code == "0")
                 {
                     content.OK(agvContent.Message);
                 }
@@ -84,7 +84,6 @@
         /// <returns></returns>
         public AgvResponseContent AgvUpdateTask(AgvUpdateDTO agvUpdateModel)
         {
-
             return new AgvResponseContent();
         }
     }
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/AGV/AGVExtend.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/AGV/AGVExtend.cs"
new file mode 100644
index 0000000..3f480c9
--- /dev/null
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/AGV/AGVExtend.cs"
@@ -0,0 +1,121 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using WIDESEA_DTO.Agv;
+using WIDESEAWCS_Common.TaskEnum;
+using WIDESEAWCS_Core;
+using WIDESEAWCS_Core.Helper;
+using WIDESEAWCS_Model.Models;
+
+namespace WIDESEAWCS_Tasks
+{
+    public partial class AGVJob
+    {
+        /// <summary>
+        /// 涓嬪彂AGV浠诲姟
+        /// </summary>
+        public void SendAGVTask()
+        {
+            try
+            {
+                var newTasks = _taskService.Db.Queryable<Dt_Task>().Where(x => x.TaskState == TaskStatusEnum.AGV_Execute.ObjToInt() || x.TaskState == TaskStatusEnum.New.ObjToInt()).ToList().OrderBy(x => x.Grade).ThenBy(x => x.CreateDate).ToList();
+                foreach (var agvTask in newTasks)
+                {
+                    AgvTaskDTO taskDTO = new AgvTaskDTO()
+                    {
+                        ReqCode = Guid.NewGuid().ToString().Replace("-", ""),
+                        TaskTyp = AgvTaskType(agvTask.TaskType, agvTask.DeviceCode),
+                        PositionCodePath = new List<CodePath>()
+                        {
+                            new CodePath()
+                            {
+                                type="00",
+                                positionCode=agvTask.CurrentAddress
+                            },
+                            new CodePath()
+                            {
+                                type="00",
+                                positionCode=agvTask.NextAddress
+                            }
+                        },
+                        TaskCode = agvTask.TaskNum.ToString(),
+                        PodTyp = agvTask.PalletType == 1 ? "XX" : "DD",
+                    };
+                    WebResponseContent content = _taskService.AgvSendTask(taskDTO);
+                    if (content.Status)
+                    {
+                        agvTask.TaskState = TaskStatusEnum.AGV_Executing.ObjToInt();
+                        agvTask.Remark = content.Data.ObjToString();
+                    }
+                    else
+                    {
+                        agvTask.TaskState = TaskStatusEnum.Exception.ObjToInt();
+                        //agvTask.Remark = content.Data.ObjToString();
+                        agvTask.ExceptionMessage = content.Message;
+                    }
+                }
+                _taskService.UpdateData(newTasks);
+            }
+            catch (Exception ex)
+            {
+                Console.Out.WriteLine(nameof(AGVJob) + ":" + ex.Message);
+            }
+        }
+        /// <summary>
+        /// 涓嬪彂AGV缁х画鎵ц浠诲姟
+        /// </summary>
+        public void SendAGVWaitToTask()
+        {
+            try
+            {
+                var WaitToTasks = _taskService.Db.Queryable<Dt_Task>().Where(x => x.TaskState == TaskStatusEnum.AGV_WaitToExecute.ObjToInt()).ToList().OrderBy(x => x.Grade).ThenBy(x => x.CreateDate).ToList();
+                foreach (var WaitToTask in WaitToTasks)
+                {
+                    AgvSecureReplyDTO replyDTO = new AgvSecureReplyDTO()
+                    {
+                        ReqCode = Guid.NewGuid().ToString().Replace("-", ""), //WaitToTask.TaskNum.ToString(),
+                        taskCode = WaitToTask.Remark,
+                    };
+                    WebResponseContent content = _taskService.AgvSecureReply(replyDTO);
+                    if (content.Status)
+                    {
+                        WaitToTask.TaskState = TaskStatusEnum.AGV_Executing.ObjToInt();
+                    }
+                    else
+                    {
+                        WaitToTask.TaskState = TaskStatusEnum.Exception.ObjToInt();
+                        WaitToTask.ExceptionMessage = content.Message;
+                    }
+                }
+                _taskService.UpdateData(WaitToTasks);
+            }
+            catch (Exception ex)
+            {
+                Console.Out.WriteLine(nameof(AGVJob) + ":" + ex.Message);
+            }
+        }
+
+        public string AgvTaskType(int TaskType, string DeviceCode)
+        {
+            switch (DeviceCode)
+            {
+                case "SC01_CSJ":
+                    {
+                        return TaskType == TaskTypeEnum.ProductionReturn.ObjToInt() ? "23" : "24";
+                    }
+                case "SC01_ZH":
+                    {
+                        if (TaskType == TaskTypeEnum.InboundXB.ObjToInt())
+                            return "20";
+                        else if (TaskType == TaskTypeEnum.InboundJT.ObjToInt())
+                            return "21";
+                        else return "22";
+                    }
+                default:
+                    throw new NotImplementedException();
+            }
+        }
+    }
+}
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/AGV/AGVJob.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/AGV/AGVJob.cs"
index 09bcf17..3371042 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/AGV/AGVJob.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/AGV/AGVJob.cs"
@@ -12,6 +12,7 @@
 using WIDESEAWCS_Core;
 using WIDESEAWCS_Core.Helper;
 using WIDESEAWCS_DTO.TaskInfo;
+using WIDESEAWCS_IBasicInfoRepository;
 using WIDESEAWCS_ITaskInfoService;
 using WIDESEAWCS_Model.Models;
 using WIDESEAWCS_QuartzJob;
@@ -20,82 +21,35 @@
 namespace WIDESEAWCS_Tasks
 {
     [DisallowConcurrentExecution]
-    public class AGVJob : JobBase, IJob
+    public partial class AGVJob : JobBase, IJob
     {
         public readonly ITaskService _taskService;
         private readonly ITaskExecuteDetailService _taskExecuteDetailService;
         private readonly IRouterService _routerService;
+        private readonly IStationMangerRepository _stationMangerRepository;
         private readonly IMapper _mapper;
 
-        public AGVJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IMapper mapper)
+        public AGVJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IStationMangerRepository stationMangerRepository, IMapper mapper)
         {
             _taskService = taskService;
             _taskExecuteDetailService = taskExecuteDetailService;
             _routerService = routerService;
+            _stationMangerRepository = stationMangerRepository;
             _mapper = mapper;
         }
         public Task Execute(IJobExecutionContext context)
         {
             try
             {
-                List<Dt_Task> UpTasks = new List<Dt_Task>();
-                var newTasks = _taskService.Db.Queryable<Dt_Task>().Where(x => x.TaskState == TaskStatusEnum.AGV_Execute.ObjToInt() || x.TaskState == TaskStatusEnum.New.ObjToInt()).ToList().OrderBy(x => x.Grade).ThenBy(x => x.CreateDate).ToList();
-                foreach (var agvTask in newTasks)
-                {
-                    AgvTaskDTO taskDTO = new AgvTaskDTO()
-                    {
-                        ReqCode = agvTask.TaskNum.ToString(),
-                        TaskTyp = AgvTaskType(agvTask.TaskType, agvTask.DeviceCode),
-                        PositionCodePath = new List<CodePath>()
-                        {
-                            new CodePath()
-                            {
-                                type="",
-                                positionCode=""
-                            },
-                            new CodePath()
-                            {
-                                type="",
-                                positionCode=""
-                            }
-                        },
-                        PodTyp = agvTask.PalletType == 1 ? "XX" : "DD",
-                    };
-                    WebResponseContent content = _taskService.AgvSendTask(taskDTO);
-                    if (content.Status)
-                    {
-                        agvTask.TaskState = TaskStatusEnum.AGV_Execute.ObjToInt();
-                        UpTasks.Add(agvTask);
-                    }
-                }
-                _taskService.UpdateData(UpTasks);
+                SendAGVTask();
+
+                SendAGVWaitToTask();
             }
             catch (Exception ex)
             {
                 Console.Out.WriteLine(nameof(AGVJob) + ":" + ex.Message);
             }
             return Task.CompletedTask;
-        }
-
-        public string AgvTaskType(int TaskType, string DeviceCode)
-        {
-            switch (DeviceCode)
-            {
-                case "SC01-CSJ":
-                    {
-                        return TaskType == TaskTypeEnum.ProductionReturn.ObjToInt() ? "23" : "24";
-                    }
-                case "SC01-ZH":
-                    {
-                        if (TaskType == TaskTypeEnum.InboundXB.ObjToInt())
-                            return "20";
-                        else if (TaskType == TaskTypeEnum.InboundJT.ObjToInt())
-                            return "21";
-                        else return "22";
-                    }
-                default:
-                    throw new NotImplementedException();
-            }
         }
     }
 }
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_SystemRepository/Sys_MenuRepository.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_SystemRepository/Sys_MenuRepository.cs"
index da9c152..139ac7f 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_SystemRepository/Sys_MenuRepository.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_SystemRepository/Sys_MenuRepository.cs"
@@ -47,22 +47,26 @@
 
         public List<MenuDTO> GetAllMenuPDA()
         {
-            List<Sys_Menu> menus = base.QueryData(x => (x.Enable == 1 || x.Enable == 2) && x.MenuType == 1).OrderByDescending(a => a.OrderNo).ThenByDescending(q => q.ParentId).ToList();
-            List<MenuDTO> _menus = _mapper.Map<List<MenuDTO>>(menus);
-            _menus.ForEach(x =>
+            //List<Sys_Menu> menus = base.QueryData(x => (x.Enable == 1 || x.Enable == 2) && x.MenuType == App.User.MenuType).OrderByDescending(a => a.OrderNo).ThenByDescending(q => q.ParentId).ToList();
+            //List<MenuDTO> _menus = _mapper.Map<List<MenuDTO>>(menus);
+            //_menus.ForEach(x =>
+            //{
+            //    if (!string.IsNullOrEmpty(x.Auth) && x.Auth.Length > 10)
+            //    {
+            //        try
+            //        {
+            //            x.Actions = x.Auth.DeserializeObject<List<ActionDTO>>();
+            //        }
+            //        catch { }
+            //    }
+            //    x.Actions ??= new List<ActionDTO>();
+            //});
+            if (App.User.IsRoleIdSuperAdmin(App.User.RoleId))
             {
-                if (!string.IsNullOrEmpty(x.Auth) && x.Auth.Length > 10)
-                {
-                    try
-                    {
-                        x.Actions = x.Auth.DeserializeObject<List<ActionDTO>>();
-                    }
-                    catch { }
-                }
-                x.Actions ??= new List<ActionDTO>();
-            });
-            string test = _menus.Serialize();
-            return _menus;
+                return GetAllMenu();
+            }
+            List<int> menuIds = GetPermissions(App.User.RoleId).Select(x => x.MenuId).ToList();
+            return GetAllMenu().Where(x => menuIds.Contains(x.MenuId)).ToList();
         }
 
         public object GetSuperAdminMenu()

--
Gitblit v1.9.3