From 898378cad844ef4283c9946a388ca9a4ec3bf964 Mon Sep 17 00:00:00 2001
From: 647556386 <647556386@qq.com>
Date: 星期五, 05 十二月 2025 18:17:43 +0800
Subject: [PATCH] 1

---
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_InboundService/InboundOrderService.cs |   94 +++++++++++++++++++++++++++++++++++-----------
 1 files changed, 71 insertions(+), 23 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_InboundService/InboundOrderService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_InboundService/InboundOrderService.cs"
index a18a2fb..2dd5af5 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_InboundService/InboundOrderService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_InboundService/InboundOrderService.cs"
@@ -1,5 +1,6 @@
 锘縰sing AutoMapper;
 using SqlSugar;
+using System.Dynamic;
 using System.Threading.Tasks;
 using WIDESEA_Common.CommonEnum;
 using WIDESEA_Common.OrderEnum;
@@ -96,8 +97,11 @@
                         item.Unit = purchaseToStockResult.Unit;
                         item.OrderQuantity = purchaseToStockResult.Quantity;
                     }
+                    if (model.OrderType != InOrderTypeEnum.AllocatInbound.ObjToInt())
+                    {
+                        model.InboundOrderNo = CreateCodeByRule(nameof(RuleCodeEnum.InboundOrderRule));
+                    }
 
-                    model.InboundOrderNo = CreateCodeByRule(nameof(RuleCodeEnum.InboundOrderRule));
                     Db.InsertNav(model).Include(x => x.Details).ExecuteCommand();
                 }
                 return WebResponseContent.Instance.OK();
@@ -338,12 +342,12 @@
                 if (!result2.Item1) return content = WebResponseContent.Instance.Error(result2.Item2);
 
                 //  materielGroupDTO.WarehouseCode
-                var code = _warehouseAreaRepository.Db.Queryable<Dt_WarehouseArea>().Where(x => x.Code == materielGroupDTO.WarehouseType).Select(x=>x.Code).First();
-                if(string.IsNullOrEmpty(code))
+                var code = _warehouseAreaRepository.Db.Queryable<Dt_WarehouseArea>().Where(x => x.Code == materielGroupDTO.WarehouseType).Select(x => x.Code).First();
+                if (string.IsNullOrEmpty(code))
                 {
                     return content = WebResponseContent.Instance.Error($"浠撳簱涓病鏈夎{materielGroupDTO.WarehouseType}缂栧彿銆�");
                 }
-                
+
 
                 Dt_InboundOrder inboundOrder = GetInboundOrder(materielGroupDTO.OrderNo);
 
@@ -365,10 +369,10 @@
 
                 if (stockInfo == null)
                 {
-                    stockInfo = new Dt_StockInfo() { PalletType = (int)PalletTypeEnum.None,LocationType=materielGroupDTO.locationType.ObjToInt() };
+                    stockInfo = new Dt_StockInfo() { PalletType = (int)PalletTypeEnum.None, LocationType = materielGroupDTO.locationType.ObjToInt() };
                     stockInfo.Details = new List<Dt_StockInfoDetail>();
                 }
-               
+
                 foreach (var item in dbinboundOrderDetails)
                 {
                     stockInfo.Details.Add(new Dt_StockInfoDetail
@@ -382,15 +386,15 @@
                         SupplyCode = item.SupplyCode,
                         WarehouseCode = materielGroupDTO.WarehouseType,
                         StockQuantity = item.OrderQuantity,
-                        BarcodeQty=item.BarcodeQty,
-                        BarcodeUnit=item.BarcodeUnit,
-                        FactoryArea= inboundOrder.FactoryArea,
-                        Status = 0,                         
+                        BarcodeQty = item.BarcodeQty,
+                        BarcodeUnit = item.BarcodeUnit,
+                        FactoryArea = inboundOrder.FactoryArea,
+                        Status = 0,
                         OrderNo = inboundOrder.InboundOrderNo,
                         BusinessType = inboundOrder.BusinessType,
-                   
+
                     });
-                   
+
                     item.ReceiptQuantity = item.BarcodeQty;
                     item.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt();
                     item.WarehouseCode = materielGroupDTO.WarehouseType;
@@ -437,7 +441,7 @@
 
             WebResponseContent content = new WebResponseContent();
             try
-            {                                           
+            {
                 (bool, string, object?) result2 = ModelValidate.ValidateModelData(materielGroupDTO);
                 if (!result2.Item1) return content = WebResponseContent.Instance.Error(result2.Item2);
 
@@ -447,7 +451,8 @@
                     return content = WebResponseContent.Instance.Error($"鍖哄煙涓病鏈夎{materielGroupDTO.WarehouseCode}缂栧彿銆�");
                 }
 
-                if(_stockRepository.QueryFirst(x=>x.PalletCode == materielGroupDTO.PalletCode)!=null){
+                if (_stockRepository.QueryFirst(x => x.PalletCode == materielGroupDTO.PalletCode) != null)
+                {
                     return WebResponseContent.Instance.Error("璇ユ墭鐩樺凡缁忕粍杩囩洏");
                 }
 
@@ -466,7 +471,7 @@
                 {
                     if (stockInfo == null)
                     {
-                        stockInfo = new Dt_StockInfo() { PalletType = PalletTypeEnum.Empty.ObjToInt(), StockStatus = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt(), PalletCode = materielGroupDTO.PalletCode,LocationType= materielGroupDTO.WarehouseCode.ObjToInt() };
+                        stockInfo = new Dt_StockInfo() { PalletType = PalletTypeEnum.Empty.ObjToInt(), StockStatus = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt(), PalletCode = materielGroupDTO.PalletCode, LocationType = materielGroupDTO.WarehouseCode.ObjToInt() };
                         stockInfo.Details = new List<Dt_StockInfoDetail>();
                     }
                     else
@@ -647,25 +652,31 @@
             {
                 return WebResponseContent.Instance.Error("鎵樼洏鍙蜂笉鑳戒负绌�");
             }
-           var stock= _stockRepository.Db.Queryable<Dt_StockInfo>().Includes(o=>o.Details).First(x => x.PalletCode == palletCode );
+            var stock = _stockRepository.Db.Queryable<Dt_StockInfo>().Includes(o => o.Details).First(x => x.PalletCode == palletCode && x.StockStatus == (int)StockStatusEmun.缁勭洏鏆傚瓨);
             if (stock == null)
             {
                 return WebResponseContent.Instance.Error($"鏈壘鍒版墭鐩樺彿{palletCode}瀵瑰簲鐨勫簱瀛樿褰�");
+            }
+
+            if (stock.Details == null || !stock.Details.Any())
+            {
+                _stockRepository.DeleteData(stock);
+                return WebResponseContent.Instance.OK();
             }
             //  鑾峰彇搴撳瓨璇︽儏鍏宠仈鐨勬墍鏈夊叆搴撳崟鍙�
             var relatedOrderNos = stock.Details.Select(d => d.OrderNo).First();
             //  鏌ヨ鎵�鏈夊叧鑱旂殑鍏ュ簱鍗曪紙鍚鎯咃級
             var inboundOrders = _inboundOrderRepository.Db.Queryable<Dt_InboundOrder>()
-                .Includes(x => x.Details) 
-                .Where(x => relatedOrderNos==x.InboundOrderNo)
+                .Includes(x => x.Details)
+                .Where(x => relatedOrderNos == x.InboundOrderNo)
                 .First();
 
             var barcodes = stock.Details.Select(d => d.Barcode).ToList();
 
-                // 鍖归厤搴撳瓨鏉$爜瀵瑰簲鐨勫叆搴撳崟鏄庣粏
-                var matchedInboundDetails = inboundOrders.Details
-                    ?.Where(d => barcodes.Contains(d.Barcode))
-                    .ToList();
+            // 鍖归厤搴撳瓨鏉$爜瀵瑰簲鐨勫叆搴撳崟鏄庣粏
+            var matchedInboundDetails = inboundOrders.Details
+                ?.Where(d => barcodes.Contains(d.Barcode))
+                .ToList();
             foreach (var detail in matchedInboundDetails)
             {
                 detail.ReceiptQuantity = 0;
@@ -675,7 +686,44 @@
             _stockDetailRepository.DeleteData(stock.Details);
             _stockRepository.DeleteData(stock);
 
-            return WebResponseContent.Instance.OK();
+
+            return WebResponseContent.Instance.OK("鎵樼洏鎾ら攢鎴愬姛");
+        }
+
+        public override PageGridData<Dt_InboundOrder> GetPageData(PageDataOptions options)
+        {
+            string wheres = ValidatePageOptions(options);
+            //鑾峰彇鎺掑簭瀛楁
+            Dictionary<string, SqlSugar.OrderByType> orderbyDic = GetPageDataSort(options, TProperties);
+            List<OrderByModel> orderByModels = new List<OrderByModel>();
+            foreach (var item in orderbyDic)
+            {
+                OrderByModel orderByModel = new()
+                {
+                    FieldName = item.Key,
+                    OrderByType = item.Value
+                };
+                orderByModels.Add(orderByModel);
+            }
+
+
+            int totalCount = 0;
+            List<SearchParameters> searchParametersList = new List<SearchParameters>();
+            if (!string.IsNullOrEmpty(options.Wheres))
+            {
+                try
+                {
+                    searchParametersList = options.Wheres.DeserializeObject<List<SearchParameters>>();
+                    options.Filter = searchParametersList;
+                }
+                catch { }
+            }
+            var data = BaseDal.Db.Queryable<Dt_InboundOrder>()
+                .WhereIF(!wheres.IsNullOrEmpty(), wheres)
+                .OrderBy(orderByModels).Includes(x=>x.Details)
+                .ToPageList(options.Page, options.Rows, ref totalCount);
+
+            return new PageGridData<Dt_InboundOrder>(totalCount, data);
         }
     }
 }

--
Gitblit v1.9.3