| | |
| | | using CMS.Plugin.HIAWms.Domain.Shared.WmsMaterials; |
| | | using CMS.Plugin.HIAWms.Domain.WmsMaterials; |
| | | using CmsQueryExtensions; |
| | | using CmsQueryExtensions.Extension; |
| | | using System.Linq.Expressions; |
| | | using Volo.Abp; |
| | | using Volo.Abp.Application.Dtos; |
| | | using Volo.Abp.Data; |
| | |
| | | input.Sorting = nameof(WmsMaterial.Sort); |
| | | } |
| | | |
| | | var specification = new WmsMaterialSpecification(input.Name); |
| | | var material = ObjectMapper.Map<GetWmsMaterialInput, WmsMaterial>(input); |
| | | var count = await _wmsmaterialRepository.GetCountAsync(material,input.Filter, specification); |
| | | #region 动态构造查询条件 |
| | | |
| | | var list = await _wmsmaterialRepository.GetListAsync(material,input.Sorting, input.MaxResultCount, input.SkipCount, input.Filter, specification); |
| | | //动态构造查询条件 |
| | | var whereConditions = DynamicGetQueryParams(input); |
| | | |
| | | #endregion |
| | | |
| | | var count = await _wmsmaterialRepository.GetCountAsync(whereConditions); |
| | | var list = await _wmsmaterialRepository.GetListAsync(whereConditions, input.Sorting, input.MaxResultCount, input.SkipCount); |
| | | |
| | | return new PagedResultDto<WmsMaterialDto>(count, ObjectMapper.Map<List<WmsMaterial>, List<WmsMaterialDto>>(list)); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 动态构造查询条件 |
| | | /// </summary> |
| | | /// <param name="input">输入参数</param> |
| | | /// <returns></returns> |
| | | private FunReturnResultModel<Expression<Func<WmsMaterial, bool>>> DynamicGetQueryParams(GetWmsMaterialInput input) |
| | | { |
| | | //动态构造查询条件 |
| | | var whereConditions = WhereConditionsExtensions.GetWhereConditions<WmsMaterial, GetWmsMaterialInput>(input); |
| | | if (!whereConditions.IsSuccess) |
| | | { |
| | | throw new Exception("动态构造查询条件失败:" + whereConditions.ErrMsg); |
| | | } |
| | | |
| | | //也可再次自定义构建查询条件 |
| | | Expression<Func<WmsMaterial, bool>> extendExpression = a => a.IsDeleted == false; |
| | | // 使用 System.Linq.PredicateBuilder 的 And |
| | | var pres = (System.Linq.Expressions.Expression<Func<WmsMaterial, bool>>)(whereConditions.data); |
| | | whereConditions.data = System.Linq.PredicateBuilder.And(pres, extendExpression); |
| | | |
| | | return whereConditions; |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | |
| | | } |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | /// <summary> |
| | | /// 导出物料基础信息 |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | public async Task<(Dictionary<string, object> Sheets, string FileName)> ExportAsync(GetWmsMaterialInput input) |
| | | { |
| | | Check.NotNull(input, nameof(input)); |
| | |
| | | input.Sorting = nameof(WmsMaterial.Sort); |
| | | } |
| | | |
| | | var specification = new WmsMaterialSpecification(input.Name); |
| | | #region 动态构造查询条件 |
| | | |
| | | var material = ObjectMapper.Map<GetWmsMaterialInput, WmsMaterial>(input); |
| | | var list = await _wmsmaterialRepository.GetListAsync(material,input.Sorting, input.MaxResultCount, input.SkipCount, input.Filter, specification, includeDetails: true); |
| | | //动态构造查询条件 |
| | | var whereConditions = DynamicGetQueryParams(input); |
| | | |
| | | #endregion |
| | | |
| | | |
| | | |
| | | var list = await _wmsmaterialRepository.GetListAsync(whereConditions, input.Sorting, input.MaxResultCount, input.SkipCount, includeDetails: true); |
| | | var result = ObjectMapper.Map<List<WmsMaterial>, List<WmsMaterialDto>>(list); |
| | | |
| | | var sheets = new Dictionary<string, object> |
| | |
| | | ["配置"] = ExportHelper.ConvertListToExportData(result), |
| | | }; |
| | | |
| | | var fileName = result.Count > 1 ? "WmsMaterial列表" : result.Count == 1 ? result[0]?.MaterialNo : "WmsMaterial模版"; |
| | | var fileName = "物料基础"; |
| | | return (sheets, fileName); |
| | | } |
| | | |