From dcecb039035f4b2e82e31c39b74db9402444c536 Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期二, 08 四月 2025 21:35:39 +0800
Subject: [PATCH] 代码更新,优化等内容

---
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_StockRepository/ProStockInfoRepository.cs |   46 ++++++++++++++++++++++++++++++++++++----------
 1 files changed, 36 insertions(+), 10 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_StockRepository/ProStockInfoRepository.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_StockRepository/ProStockInfoRepository.cs"
index 7dea7fd..81470c6 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_StockRepository/ProStockInfoRepository.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_StockRepository/ProStockInfoRepository.cs"
@@ -4,9 +4,11 @@
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using WIDESEA_Common.CommonEnum;
 using WIDESEA_Common.StockEnum;
 using WIDESEA_Core.BaseRepository;
 using WIDESEA_Core.Helper;
+using WIDESEA_IBasicRepository;
 using WIDESEA_IStockRepository;
 using WIDESEA_Model.Models;
 
@@ -14,8 +16,10 @@
 {
     public class ProStockInfoRepository : RepositoryBase<Dt_ProStockInfo>, IProStockInfoRepository
     {
-        public ProStockInfoRepository(IUnitOfWorkManage unitOfWorkManage) : base(unitOfWorkManage)
+        private readonly IBasicRepository _basicRepository;
+        public ProStockInfoRepository(IUnitOfWorkManage unitOfWorkManage,IBasicRepository basicRepository) : base(unitOfWorkManage)
         {
+            _basicRepository = basicRepository;
         }
         //鏍规嵁鏄庣粏鏁版嵁鏌ユ壘鍙敤搴撳瓨搴撳瓨
         public List<Dt_ProStockInfo> GetProStocks(Dt_ProOutOrderDetail proOutOrderDetail,List<string> locationInfos)
@@ -24,18 +28,40 @@
             bool isCanLot= string.IsNullOrEmpty(proOutOrderDetail.PLot);
             bool isCanDate = string.IsNullOrEmpty(proOutOrderDetail.DateCode);
             bool isCanVer = string.IsNullOrEmpty(proOutOrderDetail.OutSpecifyVer);
-            proStockInfos = Db.Queryable<Dt_ProStockInfo>().Where(x => locationInfos.Contains(x.LocationCode) && x.ProStockAttribute == ProStockAttributeEnum.鎴愬搧.ObjToInt())
+            ////鍒ゆ柇瀹㈡埛鍑哄叆瑙勫垯
+            //Dt_CustomerInfo customerInfo = _basicRepository.CustomerInfoRepository.QueryFirst(x=>x.Code== proOutOrderDetail.Customer);
+            //if (customerInfo==null)
+            //{
+            //    throw new Exception("鏈壘鍒板鎴蜂俊鎭�");
+            //}
+            //if (customerInfo.OutRule==CustomerOutRuleEnum.SaleOrderRule.ObjToInt())
+            //{
+            //    proStockInfos = Db.Queryable<Dt_ProStockInfo>().Where(x => locationInfos.Contains(x.LocationCode) && x.ProStockAttribute == ProStockAttributeEnum.鎴愬搧.ObjToInt())
+            //    .Includes(x => x.proStockInfoDetails)
+            //    .Where(x => x.proStockInfoDetails
+            //    .Any(v =>
+            //        v.SaleOrder==proOutOrderDetail.SaleOrder
+            //        && v.ProductCode == proOutOrderDetail.PCode
+            //        && v.ProductVersion == proOutOrderDetail.PVer
+            //        && (isCanLot ? isCanLot : v.BagNo == proOutOrderDetail.PLot)
+            //        && (isCanDate ? isCanDate : v.DateCode == proOutOrderDetail.DateCode)
+            //    ))
+            //    .ToList();
+            //}
+            //else
+            //{
+                proStockInfos = Db.Queryable<Dt_ProStockInfo>().Where(x => locationInfos.Contains(x.LocationCode) && x.ProStockAttribute == ProStockAttributeEnum.鎴愬搧.ObjToInt())
                 .Includes(x => x.proStockInfoDetails)
                 .Where(x => x.proStockInfoDetails
-                .Any(v => v.SaleOrder == proOutOrderDetail.SaleOrder
-                && v.ProductCode == proOutOrderDetail.PCode
-                && v.ProductVersion == proOutOrderDetail.PVer
-                && (isCanLot ? isCanLot : v.LotNumber == proOutOrderDetail.PLot)
-                && (isCanDate ? isCanDate : v.DateCode == proOutOrderDetail.DateCode)
+                .Any(v =>
+                    v.ProductCode == proOutOrderDetail.PCode
+                    && v.ProductVersion == proOutOrderDetail.PVer
+                    && (isCanLot ? isCanLot : v.BagNo == proOutOrderDetail.PLot)
+                    && (isCanDate ? isCanDate : v.DateCode == proOutOrderDetail.DateCode)
                 ))
-            .ToList();
-            
-            proStockInfos = proStockInfos.OrderBy(x => x.proStockInfoDetails.FirstOrDefault()?.DateCode).ThenBy(x=>x.proStockInfoDetails.Sum(x=>x.StockPcsQty)).ToList();
+                .ToList();
+            //}
+            proStockInfos = proStockInfos?.OrderBy(x => x.proStockInfoDetails.FirstOrDefault()?.DateCode).ThenBy(x=>x.CreateDate).ThenBy(x=>x.proStockInfoDetails.Sum(x=>x.StockPcsQty)).ToList();
             return proStockInfos;
         }
         /// <summary>

--
Gitblit v1.9.3