| | |
| | | using CMS.Plugin.HIAWms.Application.Contracts.Dtos.WmsContainers; |
| | | using CMS.Plugin.HIAWms.Application.Contracts.Dtos.WmsContainer; |
| | | using CMS.Plugin.HIAWms.Application.Contracts.Services; |
| | | using CMS.Plugin.HIAWms.Domain.Shared; |
| | | using CMS.Plugin.HIAWms.Domain.Shared.WmsContainers; |
| | | using CMS.Plugin.HIAWms.Domain.WmsContainers; |
| | | using CmsQueryExtensions; |
| | | using CmsQueryExtensions.Extension; |
| | | using System.Linq.Expressions; |
| | | using Volo.Abp; |
| | | using Volo.Abp.Application.Dtos; |
| | | using Volo.Abp.Data; |
| | |
| | | input.Sorting = nameof(WmsContainer.Sort); |
| | | } |
| | | |
| | | var specification = new WmsContainerSpecification(input.Name); |
| | | var container = ObjectMapper.Map < GetWmsContainerInput, WmsContainer>(input); |
| | | var count = await _wmscontainerRepository.GetCountAsync(container,input.Filter, specification); |
| | | var list = await _wmscontainerRepository.GetListAsync(container,input.Sorting, input.MaxResultCount, input.SkipCount, input.Filter, specification); |
| | | #region 动态构造查询条件 |
| | | |
| | | //动态构造查询条件 |
| | | var whereConditions = DynamicGetQueryParams(input); |
| | | |
| | | #endregion |
| | | |
| | | var count = await _wmscontainerRepository.GetCountAsync(whereConditions); |
| | | var list = await _wmscontainerRepository.GetListAsync(whereConditions, input.Sorting, input.MaxResultCount, input.SkipCount); |
| | | |
| | | return new PagedResultDto<WmsContainerDto>(count, ObjectMapper.Map<List<WmsContainer>, List<WmsContainerDto>>(list)); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 动态构造查询条件 |
| | | /// </summary> |
| | | /// <param name="input">输入参数</param> |
| | | /// <returns></returns> |
| | | private FunReturnResultModel<Expression<Func<WmsContainer, bool>>> DynamicGetQueryParams(GetWmsContainerInput input) |
| | | { |
| | | //动态构造查询条件 |
| | | var whereConditions = WhereConditionsExtensions.GetWhereConditions<WmsContainer, GetWmsContainerInput>(input); |
| | | if (!whereConditions.IsSuccess) |
| | | { |
| | | throw new Exception("动态构造查询条件失败:" + whereConditions.ErrMsg); |
| | | } |
| | | |
| | | //也可再次自定义构建查询条件 |
| | | Expression<Func<WmsContainer, bool>> extendExpression = a => a.IsDeleted == false; |
| | | // 使用 System.Linq.PredicateBuilder 的 And |
| | | var pres = (System.Linq.Expressions.Expression<Func<WmsContainer, 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(GetWmsContainerInput input) |
| | | { |
| | | Check.NotNull(input, nameof(input)); |
| | |
| | | input.Sorting = nameof(WmsContainer.Sort); |
| | | } |
| | | |
| | | var specification = new WmsContainerSpecification(input.Name); |
| | | var container = ObjectMapper.Map<GetWmsContainerInput, WmsContainer>(input); |
| | | var list = await _wmscontainerRepository.GetListAsync(container,input.Sorting, input.MaxResultCount, input.SkipCount, input.Filter, specification, includeDetails: true); |
| | | #region 动态构造查询条件 |
| | | |
| | | //动态构造查询条件 |
| | | var whereConditions = DynamicGetQueryParams(input); |
| | | |
| | | #endregion |
| | | |
| | | var list = await _wmscontainerRepository.GetListAsync(whereConditions, input.Sorting, input.MaxResultCount, input.SkipCount, includeDetails: true); |
| | | var result = ObjectMapper.Map<List<WmsContainer>, List<WmsContainerDto>>(list); |
| | | |
| | | var sheets = new Dictionary<string, object> |
| | |
| | | ["配置"] = ExportHelper.ConvertListToExportData(result), |
| | | }; |
| | | |
| | | var fileName = result.Count > 1 ? "WmsContainer列表" : result.Count == 1 ? result.First()?.ContainerNo : "WmsContainer模版"; |
| | | var fileName = "托盘管理"; |
| | | return (sheets, fileName); |
| | | } |
| | | |