using SqlSugar; using WIDESEA_Core; using WIDESEA_Core.BaseRepository; using WIDESEA_Core.BaseServices; using WIDESEA_Core.HttpContextUser; using WIDESEA_DTO.Stock; using WIDESEA_IStockService; using WIDESEA_Model.Models; namespace WIDESEA_StockService { public partial class StockInfoDetailService : ServiceBase>, IStockInfoDetailService { public StockInfoDetailService(IRepository BaseDal, IRepository stockinfoRepository) : base(BaseDal) { _stockinfoRepository = stockinfoRepository; } public IRepository _stockinfoRepository; public IRepository Repository => BaseDal; public bool ExistBarcodes(string barcode) { return BaseDal.QueryFirst(x => x.Barcode == barcode) != null; } public bool ExistBarcodes(List barcodes) { return BaseDal.QueryFirst(x => !string.IsNullOrEmpty(x.Barcode) && barcodes.Contains(x.Barcode)) != null; } public PageGridData GetPageData2(PageDataOptions options) { PageGridData lists = base.GetPageData (options); List stockIds = lists.Rows.Select(detail => detail.StockId).Distinct().ToList(); var stocks= _stockinfoRepository.QueryData(x => stockIds.Contains(x.Id)).ToList(); List dtoList = lists.Rows .Select(detail => 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= stocks .FirstOrDefault(stock => stock.Id == detail.StockId)? .PalletCode ?? "无托盘编号" }) .ToList(); return new PageGridData { Rows = dtoList, Total = lists.Total, Summary = lists.Summary }; } } }