647556386
2026-02-06 3fb6a51a60230f42be4db54cc4371a7106b322a4
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_StockService/StockDetailByMaterielService.cs
@@ -18,11 +18,13 @@
    {
        private readonly IUnitOfWorkManage _unitOfWorkManage;
        private readonly SqlSugarClient _dbBase;
        private readonly IRepository<Dt_StockInfoDetail> _stockInfoDetailRepository;
        public StockDetailByMaterielService(IUnitOfWorkManage unitOfWorkManage)
        public StockDetailByMaterielService(IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_StockInfoDetail> stockInfoDetailRepository)
        {
            _unitOfWorkManage = unitOfWorkManage;
            _dbBase = unitOfWorkManage.GetDbClient();
            _stockInfoDetailRepository = stockInfoDetailRepository;
        }
@@ -146,7 +148,12 @@
                    }
                }
                decimal totalStockQuantity = 0;
                if (groupedData.Count > 0)
                {
                    totalStockQuantity = groupedData.Values.Sum(x => x.StockQuantity);
                }
                materielnfoStatistics = groupedData.Values.ToList();
                int startIndex = (options.Page - 1) * options.Rows;
                int endIndex = Math.Min(startIndex + options.Rows, materielnfoStatistics.Count);
@@ -160,12 +167,25 @@
                }
                int count = groupedData.Count;
                return new PageGridData<StockDetailByMateriel>(count, materielnfoStatistics);
                return new PageGridData<StockDetailByMateriel>(count, materielnfoStatistics)
                {
                    TotalStockQuantity = totalStockQuantity
                };
            }
            catch (Exception ex)
            {
                return new PageGridData<StockDetailByMateriel>();
            }
        }
        public WebResponseContent CalculateStock(string warehouseCode,string materielCode)
        {
           var calculateStock =_stockInfoDetailRepository.QueryData(x => x.WarehouseCode == warehouseCode && x.MaterielCode == materielCode).Sum(x => x.StockQuantity);
           if(calculateStock == 0)
            {
                return WebResponseContent.Instance.Error("未找到库存");
            }
            return WebResponseContent.Instance.OK(data: calculateStock);
        }
    }
}