| | |
| | | { |
| | | 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; |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | 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); |
| | |
| | | } |
| | | |
| | | 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); |
| | | } |
| | | } |
| | | } |