| | |
| | | using CMS.Plugin.HIAWms.Application.Contracts.Dtos.WmsMaterialStocks; |
| | | using CMS.Plugin.HIAWms.Application.Contracts.Dtos.WmsTask; |
| | | using CMS.Plugin.HIAWms.Application.Contracts.Services; |
| | | using CMS.Plugin.HIAWms.Domain.Shared.WmsMaterialStocks; |
| | | using CMS.Plugin.HIAWms.Domain.WmsAreas; |
| | |
| | | using CMS.Plugin.HIAWms.Domain.WmsMaterials; |
| | | using CMS.Plugin.HIAWms.Domain.WmsMaterialStocks; |
| | | using CMS.Plugin.HIAWms.Domain.WmsPlaces; |
| | | using CMS.Plugin.HIAWms.Domain.WmsTask; |
| | | using CmsQueryExtensions; |
| | | using CmsQueryExtensions.Extension; |
| | | using Microsoft.Extensions.DependencyInjection; |
| | | using System.Linq.Expressions; |
| | | using System.Text.Json; |
| | | using Volo.Abp; |
| | | using Volo.Abp.Application.Dtos; |
| | |
| | | return new PagedResultDto<WmsMaterialStockDto>(count, ObjectMapper.Map<List<WmsMaterialStock>, List<WmsMaterialStockDto>>(list)); |
| | | } |
| | | |
| | | public async Task<PagedResultDto<WmsMaterialStockDto>> GetStockDetailAsync(GetWmsMaterialStocksInput input) |
| | | { |
| | | Check.NotNull(input, nameof(input)); |
| | | |
| | | if (input.Sorting.IsNullOrWhiteSpace()) |
| | | { |
| | | input.Sorting = nameof(WmsMaterialStock.Sort); |
| | | } |
| | | |
| | | #region 动态构造查询条件 |
| | | |
| | | //动态构造查询条件 |
| | | var whereConditions = DynamicGetQueryParams(input); |
| | | |
| | | #endregion |
| | | |
| | | var count = await _wmsmaterialstockRepository.GetDetailCountAsync(whereConditions); |
| | | var list = await _wmsmaterialstockRepository.GetStockDetailListAsync(whereConditions, input.Sorting, input.MaxResultCount, input.SkipCount); |
| | | |
| | | return new PagedResultDto<WmsMaterialStockDto>(count, ObjectMapper.Map<List<WmsMaterialStock>, List<WmsMaterialStockDto>>(list)); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 动态构造查询条件 |
| | | /// </summary> |
| | | /// <param name="input">输入参数</param> |
| | | /// <returns></returns> |
| | | private FunReturnResultModel<Expression<Func<WmsMaterialStock, bool>>> DynamicGetQueryParams(GetWmsMaterialStocksInput input) |
| | | { |
| | | //动态构造查询条件 |
| | | var whereConditions = WhereConditionsExtensions.GetWhereConditions<WmsMaterialStock, GetWmsMaterialStocksInput>(input); |
| | | if (!whereConditions.IsSuccess) |
| | | { |
| | | throw new Exception("动态构造查询条件失败:" + whereConditions.ErrMsg); |
| | | } |
| | | |
| | | //也可再次自定义构建查询条件 |
| | | 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); |
| | | |
| | | return whereConditions; |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public virtual async Task<WmsMaterialStockDto> CreateAsync(WmsMaterialStockCreateDto input) |
| | | { |