From 2f14ad3cc01d575bfde0850bae05fded8acb7af6 Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期日, 12 一月 2025 00:20:26 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/MeiRuiAn/HuaiAn

---
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderService.cs |  103 +++++++++++++++++++++++++++++++++------------------
 1 files changed, 67 insertions(+), 36 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderService.cs"
index 7bfa3f1..efc8049 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderService.cs"
@@ -45,7 +45,7 @@
         private readonly IOutStockLockInfoService _outStockLockInfoService;
         private readonly IOutboundOrderRepository _outboundOrderRepository;
 
-        public OutboundOrderService(IOutboundOrderRepository BaseDal, IMapper mapper,IUnitOfWorkManage unitOfWorkManage, IBasicService basicService, IOutboundOrderDetailRepository outboundOrderDetailRepository, IStockInfoService stockInfoService,
+        public OutboundOrderService(IOutboundOrderRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IBasicService basicService, IOutboundOrderDetailRepository outboundOrderDetailRepository, IStockInfoService stockInfoService,
           IStockInfoRepository stockInfoRepository, IInvokeERPService invokeERPService, IOutStockLockInfoService outStockLockInfoService,
           IOutboundOrderRepository outboundOrderRepository) : base(BaseDal)
         {
@@ -71,6 +71,32 @@
             }
             saveModel.DetailData[0].Add("orderDetailStatus", OrderDetailStatusEnum.New.ObjToInt());
             return base.AddData(saveModel);
+        }
+        public WebResponseContent GetOutboundOrders(SaveModel saveModel)
+        {
+            WebResponseContent content = new WebResponseContent();
+            try
+            {
+                int pageNo = saveModel.MainData["pageNo"].ObjToInt();
+                string? orderNo = saveModel.MainData["orderNo"].ToString();
+                int warehouseId = saveModel.MainData["warehouseId"].ObjToInt();
+                List<Dt_OutboundOrder> dt_ReceiveOrders = new List<Dt_OutboundOrder>();
+                if (string.IsNullOrEmpty(orderNo))
+                {
+                    dt_ReceiveOrders = Db.Queryable<Dt_OutboundOrder>().Where(x => x.OrderStatus < OutLockStockStatusEnum.鍑哄簱瀹屾垚.ObjToInt() && x.WarehouseId == warehouseId).ToPageList(pageNo, 5);
+                }
+                else
+                {
+                    dt_ReceiveOrders = Db.Queryable<Dt_OutboundOrder>().Where(x => (x.OrderNo.Contains(orderNo)) && x.OrderStatus < OutLockStockStatusEnum.鍑哄簱瀹屾垚.ObjToInt() && x.WarehouseId == warehouseId).ToPageList(pageNo, 5);
+                }
+
+                content.OK(data: dt_ReceiveOrders);
+            }
+            catch (Exception ex)
+            {
+                content.Error(ex.Message);
+            }
+            return content;
         }
         public WebResponseContent ReceiveOutOrder(ErpOutOrderDTO model)
         {
@@ -127,11 +153,10 @@
                             MaterielName = materielInfo.MaterielName,
                             OrderDetailStatus = OrderDetailStatusEnum.New.ObjToInt(),
                             OrderQuantity = model.Qty,
-                            Unit=materielInfo.MaterielUnit
+                            Unit = materielInfo.MaterielUnit
                         };
                         Dt_OutboundOrder outboundOrder = new Dt_OutboundOrder()
                         {
-                            OrderNo=model.OrderNo,
                             UpperOrderNo = model.OrderNo,
                             OrderStatus = OutOrderStatusEnum.鏈紑濮�.ObjToInt(),
                             OrderType = OutOrderTypeEnum.Issue.ObjToInt(),
@@ -188,22 +213,22 @@
             }
         }
         //涓婃姤鍑哄簱瀹屾垚
-        public WebResponseContent TestOutUpload(int id,List<Dt_OutStockLockInfo>? outStockLockInfos)
+        public WebResponseContent TestOutUpload(int id, List<Dt_OutStockLockInfo>? outStockLockInfos)
         {
             try
             {
-                Dt_OutboundOrder outboundOrder = Db.Queryable<Dt_OutboundOrder>().Where(x=>x.Id==id).Includes(x=>x.Details).First();
+                Dt_OutboundOrder outboundOrder = Db.Queryable<Dt_OutboundOrder>().Where(x => x.Id == id).Includes(x => x.Details).First();
                 Dt_Warehouse warehouse = _basicService.WarehouseService.Repository.QueryFirst(x => x.WarehouseId == outboundOrder.WarehouseId);
                 ERPIssueModel issueModel = new ERPIssueModel();
                 List<Dt_StockInfo> stockInfos = new List<Dt_StockInfo>();
-                List<Dt_OutStockLockInfo> _OutStockLockInfos=new List<Dt_OutStockLockInfo>();
+                List<Dt_OutStockLockInfo> _OutStockLockInfos = new List<Dt_OutStockLockInfo>();
                 int overCount = outboundOrder.Details.Where(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()).Count();
                 if (outboundOrder.Details.Count == overCount)
                 {
                     outboundOrder.OrderStatus = OutOrderStatusEnum.鍑哄簱瀹屾垚.ObjToInt();
                     _outboundOrderRepository.UpdateData(outboundOrder);
                 }
-                if (outboundOrder==null)
+                if (outboundOrder == null)
                 {
                     return WebResponseContent.Instance.Error("鍑哄簱鍗曚笉瀛樺湪");
                 }
@@ -212,33 +237,39 @@
                     return WebResponseContent.Instance.OK();
                 }
                 //娴嬭瘯鏋跺簱缁橢RP涓婃姤鍑哄簱瀹屾垚
-                if (warehouse.WarehouseCode==WarehouseEnum.HA64.ToString())
+                if (warehouse.WarehouseCode == WarehouseEnum.HA64.ToString())
                 {
-                    stockInfos = TestOutStocksUpdate(warehouse).Data as List<Dt_StockInfo> ?? new List<Dt_StockInfo>();
-                    List<ERPPickItemModel> eRPOutPick =new List<ERPPickItemModel>();
-                    for (int i = 0; i < stockInfos.Count; i++)
+                    List<ERPPickModel> eRPPicks = new List<ERPPickModel>();
+                    foreach (var item in outboundOrder.Details)
                     {
-                        ERPPickItemModel pickItemModel = new ERPPickItemModel()
+                        if (item.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()) continue;
+                        stockInfos = TestOutStocksUpdate(warehouse, item).Data as List<Dt_StockInfo> ?? null;
+                        if (stockInfos == null) continue;
+                        List<ERPPickItemModel> eRPOutPick = new List<ERPPickItemModel>();
+                        for (int i = 0; i < stockInfos.Count; i++)
                         {
-                            Lotno= stockInfos[i].Details[0].BatchNo,
-                            Qty= stockInfos[i].Details[0].StockQuantity.ObjToInt().ToString(),
-                            Location= warehouse.WarehouseCode
-                        };
-                        eRPOutPick.Add(pickItemModel);
-                    }
-                    
-                    ERPPickModel pickModel = new ERPPickModel()
-                    {
-                        Rowindex = outboundOrder.Details[0].RowNo,
-                        Material = outboundOrder.Details[0].MaterielCode,
-                        Qty = (outboundOrder.Details[0].OrderQuantity.ObjToInt()).ToString(),
-                        Dataitem = eRPOutPick
-                    };
+                            ERPPickItemModel pickItemModel = new ERPPickItemModel()
+                            {
+                                Lotno = stockInfos[i].Details[0].BatchNo,
+                                Qty = stockInfos[i].Details[0].StockQuantity.ObjToInt().ToString(),
+                                Location = warehouse.WarehouseCode
+                            };
+                            eRPOutPick.Add(pickItemModel);
+                        }
 
+                        ERPPickModel pickModel = new ERPPickModel()
+                        {
+                            Rowindex = item.RowNo,
+                            Material = item.MaterielCode,
+                            Qty = (item.OrderQuantity.ObjToInt()).ToString(),
+                            Dataitem = eRPOutPick
+                        };
+                        eRPPicks.Add(pickModel);
+                    }
                     ERPIssueItemModel issueItemModel = new ERPIssueItemModel()
                     {
                         Pickcode = outboundOrder.UpperOrderNo,
-                        PickList = new List<ERPPickModel>() { pickModel }
+                        PickList = eRPPicks
                     };
                     issueModel = new ERPIssueModel()
                     {
@@ -255,8 +286,8 @@
                 }
                 else
                 {
-                    List<ERPPickModel> eRPPickModels= new List<ERPPickModel>();
-                    
+                    List<ERPPickModel> eRPPickModels = new List<ERPPickModel>();
+
                     //鑾峰彇鍑哄簱璇︽儏鍗�
                     foreach (var item in outStockLockInfos)
                     {
@@ -275,7 +306,7 @@
                             Qty = pickItemModel.Qty,
                             Dataitem = new List<ERPPickItemModel> { pickItemModel }
                         };
-                        if (item.OrderQuantity==item.AssignQuantity)
+                        if (item.OrderQuantity == item.AssignQuantity)
                         {
                             item.Status = OutLockStockStatusEnum.鍑哄簱瀹屾垚.ObjToInt();
                         }
@@ -290,7 +321,7 @@
                     issueModel = new ERPIssueModel()
                     {
                         UniqueTag = id.ToString(),
-                        Code = outboundOrder.OrderNo,//娴嬭瘯
+                        Code = outboundOrder.OrderNo,
                         WarehouseCode = warehouse.WarehouseCode,
                         Docremark = "",
                         Deptno = outboundOrder.DepartmentCode,
@@ -300,7 +331,7 @@
                         Issitem = new List<ERPIssueItemModel>() { issueItemModel },
                     };
                 }
-                
+
                 if (stockInfos.Count > 0)
                 {
                     _stockInfoRepository.UpdateData(stockInfos);
@@ -324,15 +355,15 @@
         /// <param name="warehouse"></param>
         /// <param name="model"></param>
         /// <returns></returns>
-        public WebResponseContent TestOutStocksUpdate(Dt_Warehouse warehouse)
+        public WebResponseContent TestOutStocksUpdate(Dt_Warehouse warehouse,Dt_OutboundOrderDetail outboundOrderDetails)
         {
             try
             {
                 //鑾峰彇鍑哄簱鍗曞簱瀛�
-                List<Dt_StockInfo> stockInfos = _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId).Includes(x => x.Details).ToList();
-                if (stockInfos.Count<=0)
+                List<Dt_StockInfo> stockInfos = _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId).Includes(x => x.Details).Where(x=>x.Details.Any(j=>j.MaterielCode== outboundOrderDetails.MaterielCode)).Take((int)outboundOrderDetails.OrderQuantity).ToList();
+                if (stockInfos.Count <= 0)
                 {
-                    return WebResponseContent.Instance.Error($"搴撳瓨涓嶈冻");
+                    return WebResponseContent.Instance.OK();
                 }
                 //鏇存敼鐘舵��
                 stockInfos.ForEach(x =>

--
Gitblit v1.9.3