1
647556386
3 天以前 3c506974e141024ed26a0c348d896c70ea42891b
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoDetailService.cs
@@ -1,10 +1,12 @@
using 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;
@@ -34,8 +36,8 @@
        public PageGridData<StockInfoDetailWithPalletDto> GetPageData2(PageDataOptions options)
        {
            // 1. èŽ·å–åŸºç¡€åˆ†é¡µæ•°æ®
            PageGridData<Dt_StockInfoDetail> pageData = base.GetPageData(options);
            List<Dt_StockInfoDetail> filteredDetails = pageData.Rows.ToList(); // å…ˆæ‹·è´åŽŸå§‹æ•°æ®
            ISugarQueryable<Dt_StockInfoDetail> sugarQueryable1 = BaseDal.Db.Queryable<Dt_StockInfoDetail>();
            ISugarQueryable<Dt_StockInfo> sugarQueryable = BaseDal.Db.Queryable<Dt_StockInfo>();
            if (!string.IsNullOrEmpty(options.Wheres))
            {
@@ -46,24 +48,17 @@
                    {
                        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)
                                {
                                    filteredDetails = filteredDetails.Where(x => x.StockId == targetStock.Id).ToList();
                                    sugarQueryable1 = sugarQueryable1.Where(x => x.StockId == targetStock.Id);
                                }
                                else
                                {
                                    filteredDetails = new List<Dt_StockInfoDetail>();
                                }
                                break; // å•个托盘码查询,匹配后退出循环
                                break;
                            }
                        }
                    }
@@ -72,47 +67,40 @@
                {
                }
            }
            List<int> stockIds = filteredDetails.Select(detail => detail.StockId).Distinct().ToList();
            var stockDict = _stockinfoRepository.QueryData(x => stockIds.Contains(x.Id))
                                                .ToDictionary(x => x.Id, x => x.PalletCode ?? "无托盘编号");
            List<StockInfoDetailWithPalletDto> dtoList = filteredDetails
                .Select(detail => new StockInfoDetailWithPalletDto
            EntityProperties.ValidatePageOptions(options, ref sugarQueryable1);
            ISugarQueryable<StockInfoDetailWithPalletDto> list = sugarQueryable1.InnerJoin(sugarQueryable, (b, a) => a.Id == b.StockId).Select((b, a) => new StockInfoDetailWithPalletDto
                {
                    Id = detail.Id,
                    StockId = detail.StockId,
                    MaterielCode = detail.MaterielCode,
                    MaterielName = detail.MaterielName,
                    OrderNo = detail.OrderNo,
                    BatchNo = detail.BatchNo,
                    ProductionDate = detail.ProductionDate,
                    EffectiveDate = detail.EffectiveDate,
                    SerialNumber = detail.SerialNumber,
                    StockQuantity = detail.StockQuantity,
                    OutboundQuantity = detail.OutboundQuantity,
                    Status = detail.Status,
                    Unit = detail.Unit,
                    InboundOrderRowNo = detail.InboundOrderRowNo,
                    SupplyCode = detail.SupplyCode,
                    WarehouseCode = detail.WarehouseCode,
                    Barcode = detail.Barcode,
                    BusinessType = detail.BusinessType,
                    Remark = detail.Remark,
                    Creater = detail.Creater,
                    CreateDate = detail.CreateDate,
                    Modifier = detail.Modifier,
                    ModifyDate = detail.ModifyDate,
                    PalletCode = stockDict.TryGetValue(detail.StockId, out var palletCode) ? palletCode : "无托盘编号"
                })
                .ToList();
                    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??"无托盘编号"
                });
            return new PageGridData<StockInfoDetailWithPalletDto>
            {
                Rows = dtoList.Where(x=>x.PalletCode != "无托盘编号").ToList(),
                Total = pageData.Total,
                Summary = pageData.Summary
            };
            int totalCount = 0;
            var stockViewDTOs = list.ToPageList(options.Page, options.Rows, ref totalCount);
            return new PageGridData<StockInfoDetailWithPalletDto>(totalCount, stockViewDTOs);
        }
    }