From 91ead18d0e92b6e1ed916c5159f3431bf2071a56 Mon Sep 17 00:00:00 2001
From: 647556386 <647556386@qq.com>
Date: 星期五, 12 十二月 2025 13:59:40 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/ZhongRui/ALDbanyunxiangmu

---
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoDetailService.cs |   90 +++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 86 insertions(+), 4 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_StockService/StockInfoDetailService.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_StockService/StockInfoDetailService.cs"
index cd50907..89d3890 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_StockService/StockInfoDetailService.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_StockService/StockInfoDetailService.cs"
@@ -1,5 +1,13 @@
-锘縰sing WIDESEA_Core.BaseRepository;
+锘縰sing SqlSugar;
+using System.Collections.Generic;
+using WIDESEA_Core;
+using WIDESEA_Core.BaseRepository;
 using WIDESEA_Core.BaseServices;
+using WIDESEA_Core.Enums;
+using WIDESEA_Core.Helper;
+using WIDESEA_Core.HttpContextUser;
+using WIDESEA_Core.Utilities;
+using WIDESEA_DTO.Stock;
 using WIDESEA_IStockService;
 using WIDESEA_Model.Models;
 
@@ -7,10 +15,12 @@
 {
     public partial class StockInfoDetailService : ServiceBase<Dt_StockInfoDetail, IRepository<Dt_StockInfoDetail>>, IStockInfoDetailService
     {
-        public StockInfoDetailService(IRepository<Dt_StockInfoDetail> BaseDal) : base(BaseDal)
+        public StockInfoDetailService(IRepository<Dt_StockInfoDetail> BaseDal, IRepository<Dt_StockInfo> stockinfoRepository) : base(BaseDal)
         {
+            _stockinfoRepository = stockinfoRepository;
         }
 
+        public IRepository<Dt_StockInfo> _stockinfoRepository;
         public IRepository<Dt_StockInfoDetail> Repository => BaseDal;
 
         public bool ExistBarcodes(string barcode)
@@ -20,7 +30,79 @@
 
         public bool ExistBarcodes(List<string> barcodes)
         {
-            return BaseDal.QueryFirst(x =>!string.IsNullOrEmpty( x.Barcode) &&  barcodes.Contains(x.Barcode)) != null;
+            return BaseDal.QueryFirst(x => !string.IsNullOrEmpty(x.Barcode) && barcodes.Contains(x.Barcode)) != null;
         }
+
+        public PageGridData<StockInfoDetailWithPalletDto> GetPageData2(PageDataOptions options)
+        {
+            // 1. 鑾峰彇鍩虹鍒嗛〉鏁版嵁
+            ISugarQueryable<Dt_StockInfoDetail> sugarQueryable1 = BaseDal.Db.Queryable<Dt_StockInfoDetail>();
+            ISugarQueryable<Dt_StockInfo> sugarQueryable = BaseDal.Db.Queryable<Dt_StockInfo>();
+
+            if (!string.IsNullOrEmpty(options.Wheres))
+            {
+                try
+                {
+                    List<SearchParameters> searchParametersList = options.Wheres.DeserializeObject<List<SearchParameters>>();
+                    if (searchParametersList?.Any() == true)
+                    {
+                        foreach (var param in searchParametersList)
+                        {
+                            if (param.Name.Equals(nameof(Dt_StockInfo.PalletCode).FirstLetterToLower(), StringComparison.OrdinalIgnoreCase)
+                                && !string.IsNullOrEmpty(param.Value?.ToString()))
+                            {
+                                string palletCode = param.Value.ToString().Trim();
+                                var targetStock = _stockinfoRepository.QueryFirst(x => x.PalletCode == palletCode);
+
+                                if (targetStock != null)
+                                {
+                                    sugarQueryable1 = sugarQueryable1.Where(x => x.StockId == targetStock.Id);
+                                }
+                                break;
+                            }
+                        }
+                    }
+                }
+                catch (Exception ex)
+                {
+                }
+            }
+            EntityProperties.ValidatePageOptions(options, ref sugarQueryable1);
+            ISugarQueryable<StockInfoDetailWithPalletDto> list = sugarQueryable1.InnerJoin(sugarQueryable, (b, a) => a.Id == b.StockId).Select((b, a) => new StockInfoDetailWithPalletDto
+            {
+                    Id = b.Id,
+                    StockId = b.StockId,
+                    MaterielCode = b.MaterielCode,
+                    MaterielName = b.MaterielName,
+                    OrderNo = b.OrderNo,
+                    BatchNo = b.BatchNo,
+                    ProductionDate = b.ProductionDate,
+                    EffectiveDate = b.EffectiveDate,
+                    SerialNumber = b.SerialNumber,
+                    StockQuantity = b.StockQuantity,
+                    OutboundQuantity = b.OutboundQuantity,
+                    Status = b.Status,
+                    Unit = b.Unit,
+                    InboundOrderRowNo = b.InboundOrderRowNo,
+                    SupplyCode = b.SupplyCode,
+                    WarehouseCode = b.WarehouseCode,
+                    Barcode = b.Barcode,
+                    BusinessType = b.BusinessType,
+                    Remark = b.Remark,
+                    Creater = b.Creater,
+                    CreateDate = b.CreateDate,
+                    Modifier = b.Modifier,
+                    ModifyDate = b.ModifyDate,
+                    PalletCode = a.PalletCode??"鏃犳墭鐩樼紪鍙�"
+                });
+
+
+            int totalCount = 0;
+            var stockViewDTOs = list.ToPageList(options.Page, options.Rows, ref totalCount);
+            return new PageGridData<StockInfoDetailWithPalletDto>(totalCount, stockViewDTOs);
+            
+        }
+
     }
-}
+    }
+

--
Gitblit v1.9.3