From f506ae008db19791fd211c4c7ca8041a2bf00874 Mon Sep 17 00:00:00 2001
From: 647556386 <647556386@qq.com>
Date: 星期三, 28 一月 2026 11:44:39 +0800
Subject: [PATCH] 库存暂存增加,单据修改代码优化,erpjob开启

---
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_InboundService/InboundService.cs |   35 ++++++++++++++++++++++++++++++++---
 1 files changed, 32 insertions(+), 3 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/InboundService.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/InboundService.cs"
index d678648..7dcdc17 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/InboundService.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/InboundService.cs"
@@ -440,13 +440,24 @@
                     //}
                 }
                 _mesReturnRecord.UpdateData(returnRecords);
+                //閲嶆柊鍥炶皟瀹屾垚鐨勫崟鎹紝鏇存柊搴撳瓨鐘舵��
+                foreach (var returnRecord in returnRecords)
+                {
+                    if (returnRecord.ReturnStatus == 1)
+                    {
+                        _stockInfoRepository.Db.Updateable<Dt_StockInfoDetail>().SetColumns(it => new Dt_StockInfoDetail
+                        {
+                            Status = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt()
+                        }).Where(it => it.OrderNo == returnRecord.OrderNo && returnRecord.RequestData.Contains(it.Barcode)).ExecuteCommand();
+                    }
+                }
 
                 var inboundOrderDetail = _inboundOrderRepository.Db.Queryable<Dt_InboundOrderDetail>()
-                                        .Where(x => x.OrderId == inboundOrder.Id && x.OrderDetailStatus==(int)OrderDetailStatusEnum.Over && x.ReturnToMESStatus == 0)
+                                        .Where(x => x.OrderId == inboundOrder.Id && x.OrderDetailStatus == (int)OrderDetailStatusEnum.Over && x.ReturnToMESStatus == 0)
                                         .ToList();
 
                 var stocks = _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.StockStatus == (int)StockStatusEmun.鍏ュ簱瀹屾垚)
-                                            .Where(it => SqlFunc.Subqueryable<Dt_StockInfoDetail>().Where(s => s.StockId == it.Id && s.OrderNo == inboundOrder.InboundOrderNo).Any())
+                                            .Where(it => SqlFunc.Subqueryable<Dt_StockInfoDetail>().Where(s => s.StockId == it.Id && s.OrderNo == inboundOrder.InboundOrderNo && s.Status == StockStatusEmun.鍏ュ簱纭.ObjToInt()).Any())
                                             .ToList();
 
                 var stockIds = stocks.Select(s => s.Id).ToList();
@@ -467,6 +478,13 @@
                                     inbound => inbound.Barcode,
                                     stockdetail => stockdetail.Barcode,
                                     (inbound, stockdetail) => inbound.Id)
+                                .ToList();
+
+                var inbounddetailBarcode = inboundOrderDetail
+                                .Join(allDetailsData,
+                                    inbound => inbound.Barcode,
+                                    stockdetail => stockdetail.Barcode,
+                                    (inbound, stockdetail) => stockdetail.Barcode)
                                 .ToList();
 
                 var detail = allDetailsData.Where(x => matchedData.Contains(x.Barcode)).ToList();
@@ -512,6 +530,11 @@
                     {
                         _inboundOrderRepository.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 1 })
                         .Where(it => it.OrderId == inboundOrder.Id && inbounddetailID.Contains(it.Id)).ExecuteCommand();
+
+                        _stockInfoRepository.Db.Updateable<Dt_StockInfoDetail>().SetColumns(it => new Dt_StockInfoDetail
+                        {
+                            Status = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt()
+                        }).Where(it => it.OrderNo == inboundOrder.InboundOrderNo && inbounddetailBarcode.Contains(it.Barcode)).ExecuteCommand();
                     }
                     else
                     {
@@ -535,7 +558,7 @@
                         details = FeedbackInboundDetailsModelDto(detail)
                     };
 
-                    if (feedmodel.details.Count<=0)
+                    if (feedmodel.details.Count <= 0)
                     {
                         if (returnRecords.Count() == returnRecords.Count(x => x.ReturnStatus == 1))
                         {
@@ -558,6 +581,11 @@
                     {
                         _inboundOrderRepository.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 1 })
                         .Where(it => inbounddetailID.Contains(it.Id)).ExecuteCommand();
+
+                        _stockInfoRepository.Db.Updateable<Dt_StockInfoDetail>().SetColumns(it => new Dt_StockInfoDetail
+                        {
+                            Status = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt()
+                        }).Where(it => it.OrderNo == inboundOrder.InboundOrderNo && inbounddetailBarcode.Contains(it.Barcode)).ExecuteCommand();
                     }
                     else
                     {
@@ -575,6 +603,7 @@
             }
         }
 
+
         public List<AllocateDtoDetail> GetAllocateDtoDetails(List<Dt_StockInfoDetail> stockInfoDetails)
         {
             var groupedData = stockInfoDetails.GroupBy(item => new { item.MaterielCode, item.InboundOrderRowNo, item.BarcodeUnit, item.WarehouseCode })

--
Gitblit v1.9.3