From 9e579eda4601ed7b492b9d19a24e8146f6ebdf8d Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期六, 19 四月 2025 19:50:43 +0800
Subject: [PATCH] 优化空托出入库逻辑

---
 项目代码/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Interface/LargeScreenController.cs |   89 +++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 86 insertions(+), 3 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Interface/LargeScreenController.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Interface/LargeScreenController.cs"
index 848802a..17e7b01 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Interface/LargeScreenController.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Interface/LargeScreenController.cs"
@@ -6,8 +6,10 @@
 using WIDESEA_Common.TaskEnum;
 using WIDESEA_Core;
 using WIDESEA_Core.Enums;
+using WIDESEA_DTO.LargeScreen;
 using WIDESEA_IBasicService;
 using WIDESEA_IInboundRepository;
+using WIDESEA_IOutboundRepository;
 using WIDESEA_ITaskInfoRepository;
 using WIDESEA_Model.Models;
 using WIDESEAWCS_DTO.WCSInfo;
@@ -22,12 +24,18 @@
         private readonly ITaskRepository _taskRepository;
         private readonly ITask_HtyRepository _taskHtyRepository;
         private readonly IInboundOrderDetailRepository _inboundOrderDetailRepository;
-        public LargeScreenController(ILocationInfoService locationInfoService, ITaskRepository taskRepository, ITask_HtyRepository taskHtyRepository, IInboundOrderDetailRepository inboundOrderDetailRepository)
+        private readonly IInboundOrderRepository _inboundOrderRepository;
+        private readonly IOutboundOrderDetailRepository _outboundOrderDetailRepository;
+        private readonly IOutboundOrderRepository _outboundOrderRepository;
+        public LargeScreenController(ILocationInfoService locationInfoService, ITaskRepository taskRepository, ITask_HtyRepository taskHtyRepository, IInboundOrderDetailRepository inboundOrderDetailRepository, IInboundOrderRepository inboundOrderRepository, IOutboundOrderDetailRepository outboundOrderDetailRepository, IOutboundOrderRepository outboundOrderRepository)
         {
             _locationInfoService = locationInfoService;
             _taskRepository = taskRepository;
             _taskHtyRepository = taskHtyRepository;
             _inboundOrderDetailRepository = inboundOrderDetailRepository;
+            _inboundOrderRepository = inboundOrderRepository;
+            _outboundOrderDetailRepository = outboundOrderDetailRepository;
+            _outboundOrderRepository = outboundOrderRepository;
         }
 
         [HttpPost, Route("GetLocationInfo")]
@@ -35,14 +43,89 @@
         {
             return _locationInfoService.GetLocationInfo(model);
         }
+        /// <summary>
+        /// 鑾峰彇宸ュ崟淇℃伅
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        [HttpPost, Route("GetBoundOrder")]
+        public WebResponseContent GetBoundOrder([FromBody] SaveModel model)
+        {
+            WebResponseContent webResponseContent = new WebResponseContent();
+            try
+            {
+                var name = model.MainData["Name"].ToString();
+                List<BoundOrderDTO> boundOrderDTOs = new List<BoundOrderDTO>();
+                if (name == "鍏ュ簱")
+                {
+                    List<Dt_InboundOrder> inboundOrders = _inboundOrderRepository.QueryData(x => true);
+                    List<Dt_InboundOrderDetail> inboundOrderDetails = _inboundOrderDetailRepository.QueryData(y => inboundOrders.Select(x => x.Id).ToList().Contains(y.OrderId));
+                    foreach (var item in inboundOrderDetails)
+                    {
+                        Dt_InboundOrder _InboundOrder = inboundOrders.Where(x => x.Id == item.OrderId).First();
+                        BoundOrderDTO boundOrderDTO = new BoundOrderDTO()
+                        {
+                            OrderNo = _InboundOrder.OrderNo,
+                            BatchNo = item.BatchNo,
+                            MaterielCode = item.MaterielCode,
+                            MaterielName = item.MaterielName,
+                            OrderDetailStatus = item.OrderDetailStatus,
+                            OrderQuantity = item.OrderQuantity,
+                            OrderType = _InboundOrder.OrderType,
+                            OverInQuantity = item.OverInQuantity,
+                        };
+                        boundOrderDTOs.Add(boundOrderDTO);
+                    }
+                }
+                else
+                {
+                    List<Dt_OutboundOrder> outboundOrders = _outboundOrderRepository.QueryData(x => true);
+                    List<Dt_OutboundOrderDetail> outboundOrderDetails = _outboundOrderDetailRepository.QueryData(y => outboundOrders.Select(x => x.Id).ToList().Contains(y.OrderId));
+                    foreach (var item in outboundOrderDetails)
+                    {
+                        Dt_OutboundOrder _OutboundOrder = outboundOrders.Where(x => x.Id == item.OrderId).First();
+                        BoundOrderDTO boundOrderDTO = new BoundOrderDTO()
+                        {
+                            OrderNo = _OutboundOrder.OrderNo,
+                            BatchNo = item.BatchNo,
+                            MaterielCode = item.MaterielCode,
+                            MaterielName = item.MaterielName,
+                            OrderDetailStatus = item.OrderDetailStatus,
+                            OrderQuantity = item.OrderQuantity,
+                            OrderType = _OutboundOrder.OrderType,
+                            OverInQuantity = item.OverOutQuantity,
+                        };
+                        boundOrderDTOs.Add(boundOrderDTO);
+                    }
+                }
+                webResponseContent.OK(data: boundOrderDTOs);
+            }
+            catch (Exception ex)
+            {
+                webResponseContent.Error(ex.Message);
+            }
+            return webResponseContent;
+        }
 
         [HttpPost, Route("GetTask")]
         public WebResponseContent GetTask([FromBody] SaveModel model)
         {
-            List<Dt_Task_Hty> task_Hties = _taskHtyRepository.QueryData(x => x.TaskType == TaskInboundTypeEnum.Inbound.ObjToInt()).ToList();
+            var name = model.MainData["Name"].ToString();
+            List<Dt_Task_Hty> task_Hties = _taskHtyRepository.QueryData(x => x.TaskType == (name == "鍏ュ簱" ? TaskInboundTypeEnum.Inbound.ObjToInt() : TaskOutboundTypeEnum.Outbound.ObjToInt())).ToList();
             var task_htys = task_Hties.Where(x => x.InsertTime.Date == DateTime.Now.Date).ToList();
-            var tasks = _taskRepository.QueryData(x => x.TaskType == TaskInboundTypeEnum.Inbound.ObjToInt()).ToList();
+            var tasks = _taskRepository.QueryData(x => x.TaskType == (name == "鍏ュ簱" ? TaskInboundTypeEnum.Inbound.ObjToInt() : TaskOutboundTypeEnum.Outbound.ObjToInt())).ToList();
             List<Dt_InboundOrderDetail> inboundOrderDetails = _inboundOrderDetailRepository.QueryData(x => x.OrderDetailStatus <= OrderDetailStatusEnum.GroupAndInbound.ObjToInt()).ToList();
+            if (name != "鍏ュ簱")
+            {
+                List<Dt_OutboundOrderDetail> outboundOrderDetails = _outboundOrderDetailRepository.QueryData(x => x.OrderDetailStatus < OrderDetailStatusEnum.Outbound.ObjToInt()).ToList();
+                return WebResponseContent.Instance.OK(data: new
+                {
+                    task_Htiesqty = task_Hties.Count,
+                    task_htysqty = task_htys.Count,
+                    tasksqty = tasks.Count,
+                    inboundOrderDetailsqty = outboundOrderDetails.Sum(x => x.OrderQuantity - x.OverOutQuantity)
+                });
+            }
             return WebResponseContent.Instance.OK(data: new
             {
                 task_Htiesqty = task_Hties.Count,

--
Gitblit v1.9.3