| | |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public virtual async Task<PagedResultDto<WmsMaterialStockDto>> GetListAsync(GetWmsMaterialStocksInput input) |
| | | public virtual async Task<PagedResultDto<WmsMaterialStockDto>> GetListAsync(GetWmsMaterialStockInput input) |
| | | { |
| | | Check.NotNull(input, nameof(input)); |
| | | |
| | |
| | | input.Sorting = nameof(WmsMaterialStock.Sort); |
| | | } |
| | | |
| | | var specification = new WmsMaterialStockSpecification(input.Name); |
| | | var stock = ObjectMapper.Map<GetWmsMaterialStocksInput, WmsMaterialStock>(input); |
| | | var count = await _wmsmaterialstockRepository.GetCountAsync(stock, input.StartTime, input.EndTime, input.Filter, specification); |
| | | var list = await _wmsmaterialstockRepository.GetListAsync(stock, input.StartTime, input.EndTime, input.Sorting, input.MaxResultCount, input.SkipCount, input.Filter, specification); |
| | | //动态构造查询条件 |
| | | var whereConditions = DynamicGetQueryParams(input); |
| | | |
| | | var stock = ObjectMapper.Map<GetWmsMaterialStockInput, WmsMaterialStock>(input); |
| | | var count = await _wmsmaterialstockRepository.GetCountAsync(whereConditions); |
| | | var list = await _wmsmaterialstockRepository.GetListAsync(whereConditions, input.Sorting, input.MaxResultCount, input.SkipCount); |
| | | |
| | | return new PagedResultDto<WmsMaterialStockDto>(count, ObjectMapper.Map<List<WmsMaterialStock>, List<WmsMaterialStockDto>>(list)); |
| | | } |
| | | |
| | | public async Task<PagedResultDto<WmsMaterialStockDto>> GetStockDetailAsync(GetWmsMaterialStocksInput input) |
| | | public async Task<PagedResultDto<WmsMaterialStockDto>> GetStockDetailAsync(GetWmsMaterialStockInput input) |
| | | { |
| | | Check.NotNull(input, nameof(input)); |
| | | |
| | |
| | | |
| | | var count = await _wmsmaterialstockRepository.GetDetailCountAsync(whereConditions); |
| | | var list = await _wmsmaterialstockRepository.GetStockDetailListAsync(whereConditions, input.Sorting, input.MaxResultCount, input.SkipCount); |
| | | var result = list |
| | | .GroupBy(x => x.PlaceNo) // 按库位号分组 |
| | | .SelectMany(g => g |
| | | .OrderBy(x => x.InStockTime) // 按入库时间排序 |
| | | .Select((x, index) => new WmsMaterialStockDto |
| | | { |
| | | MaterialId = x.MaterialId, |
| | | MaterialBatch = x.MaterialBatch, |
| | | MaterialModel = x.MaterialModel, |
| | | MaterialName = x.MaterialName, |
| | | MaterialNo = x.MaterialNo, |
| | | CheckStatus = x.CheckStatus, |
| | | ContainerNo = x.ContainerNo, |
| | | ContainerType = x.ContainerType, |
| | | StockNumber = x.StockNumber, |
| | | SupplierCode = x.SupplierCode, |
| | | PlaceNo = x.PlaceNo, |
| | | PlaceStatus = x.PlaceStatus, |
| | | StorageTypeNo = x.StorageTypeNo, |
| | | AreaCode = x.AreaCode, |
| | | AreaName = x.AreaName, |
| | | IsLock = x.IsLock, |
| | | Id = x.Id, |
| | | EmptyContainer = x.EmptyContainer, |
| | | InStockTime = x.InStockTime, |
| | | RedundantField1 = x.RedundantField1, |
| | | RedundantField2 = x.RedundantField2, |
| | | RedundantField3 = x.RedundantField3, |
| | | Remark = x.Remark, |
| | | OrderInPlace = index+1 |
| | | |
| | | return new PagedResultDto<WmsMaterialStockDto>(count, ObjectMapper.Map<List<WmsMaterialStock>, List<WmsMaterialStockDto>>(list)); |
| | | })).ToList(); |
| | | |
| | | return new PagedResultDto<WmsMaterialStockDto>(count, result); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | /// <param name="input">输入参数</param> |
| | | /// <returns></returns> |
| | | private FunReturnResultModel<Expression<Func<WmsMaterialStock, bool>>> DynamicGetQueryParams(GetWmsMaterialStocksInput input) |
| | | private FunReturnResultModel<Expression<Func<WmsMaterialStock, bool>>> DynamicGetQueryParams(GetWmsMaterialStockInput input) |
| | | { |
| | | //动态构造查询条件 |
| | | var whereConditions = WhereConditionsExtensions.GetWhereConditions<WmsMaterialStock, GetWmsMaterialStocksInput>(input); |
| | | var whereConditions = WhereConditionsExtensions.GetWhereConditions<WmsMaterialStock, GetWmsMaterialStockInput>(input); |
| | | if (!whereConditions.IsSuccess) |
| | | { |
| | | throw new Exception("动态构造查询条件失败:" + whereConditions.ErrMsg); |
| | | } |
| | | |
| | | //也可再次自定义构建查询条件 |
| | | Expression<Func<WmsMaterialStock, bool>> extendExpression = a => a.IsDeleted == false ; |
| | | Expression<Func<WmsMaterialStock, bool>> extendExpression = a => a.IsDeleted == false; |
| | | // 使用 System.Linq.PredicateBuilder 的 And |
| | | var pres = (System.Linq.Expressions.Expression<Func<WmsMaterialStock, bool>>)(whereConditions.data); |
| | | whereConditions.data = System.Linq.PredicateBuilder.And(pres, extendExpression); |
| | |
| | | /// <inheritdoc /> |
| | | public virtual async Task AdjustSortAsync(Guid id, int sort) |
| | | { |
| | | var list = await _wmsmaterialstockRepository.GetListAsync(null, null, null, nameof(WmsMaterialStock.Sort)); |
| | | var list = await _wmsmaterialstockRepository.GetListAsync(null, "", 0, 999); |
| | | if (list != null && list.Any()) |
| | | { |
| | | var initSort = 1; |
| | |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public async Task<(Dictionary<string, object> Sheets, string FileName)> ExportAsync(GetWmsMaterialStocksInput input) |
| | | public async Task<(Dictionary<string, object> Sheets, string FileName)> ExportAsync(GetWmsMaterialStockInput input) |
| | | { |
| | | Check.NotNull(input, nameof(input)); |
| | | |
| | |
| | | input.Sorting = nameof(WmsMaterialStock.Sort); |
| | | } |
| | | |
| | | var specification = new WmsMaterialStockSpecification(input.Name); |
| | | var stock = ObjectMapper.Map<GetWmsMaterialStocksInput, WmsMaterialStock>(input); |
| | | var list = await _wmsmaterialstockRepository.GetListAsync(stock, input.StartTime, input.EndTime, input.Sorting, input.MaxResultCount, input.SkipCount, input.Filter, specification, includeDetails: true); |
| | | var whereConditions = DynamicGetQueryParams(input); |
| | | var stock = ObjectMapper.Map<GetWmsMaterialStockInput, WmsMaterialStock>(input); |
| | | var list = await _wmsmaterialstockRepository.GetListAsync(whereConditions, input.Sorting, input.MaxResultCount, input.SkipCount); |
| | | var result = ObjectMapper.Map<List<WmsMaterialStock>, List<WmsMaterialStockDto>>(list); |
| | | |
| | | var sheets = new Dictionary<string, object> |