| | |
| | | using CMS.Plugin.HIAWms.Application.Contracts.Dtos.WmsMaterials; |
| | | using CMS.Plugin.HIAWms.Application.Contracts.Dtos.WmsMaterial; |
| | | using CMS.Plugin.HIAWms.Application.Contracts.Services; |
| | | using CMS.Plugin.HIAWms.Domain.Shared; |
| | | 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; |
| | |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public virtual async Task<PagedResultDto<WmsMaterialDto>> GetListAsync(GetWmsMaterialsInput input) |
| | | public virtual async Task<PagedResultDto<WmsMaterialDto>> GetListAsync(GetWmsMaterialInput input) |
| | | { |
| | | Check.NotNull(input, nameof(input)); |
| | | |
| | |
| | | input.Sorting = nameof(WmsMaterial.Sort); |
| | | } |
| | | |
| | | var specification = new WmsMaterialSpecification(input.Name); |
| | | var material = ObjectMapper.Map<GetWmsMaterialsInput, 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 /> |
| | |
| | | |
| | | wmsmaterial.MaterialName = input.MaterialName; |
| | | wmsmaterial.PurchaseType = input.PurchaseType; |
| | | wmsmaterial.MaterialType = input.MaterialType; |
| | | wmsmaterial.MaterialTypeCode = input.MaterialTypeCode; |
| | | wmsmaterial.PrimaryUnit = input.PrimaryUnit; |
| | | wmsmaterial.Standard = input.Standard; |
| | | wmsmaterial.OuterDiameter = input.OuterDiameter; |
| | |
| | | wmsmaterial.Factory = input.Factory; |
| | | wmsmaterial.MaterialModel = input.MaterialModel; |
| | | wmsmaterial.Certification = input.Certification; |
| | | |
| | | wmsmaterial.MaterialTypeDesc = input.MaterialTypeDesc; |
| | | await _wmsmaterialRepository.UpdateAsync(wmsmaterial); |
| | | |
| | | return ObjectMapper.Map<WmsMaterial, WmsMaterialDto>(wmsmaterial); |
| | |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public async Task ImportAsync(WmsMaterialsImportModel input) |
| | | public async Task ImportAsync(WmsMaterialImportModels input) |
| | | { |
| | | Check.NotNull(input, nameof(input)); |
| | | |
| | |
| | | MaterialNo = wmsmaterial.MaterialNo, |
| | | MaterialName = wmsmaterial.MaterialName, |
| | | PurchaseType = wmsmaterial.PurchaseType, |
| | | MaterialType = wmsmaterial.MaterialType, |
| | | MaterialTypeCode = wmsmaterial.MaterialTypeCode, |
| | | MaterialTypeDesc = wmsmaterial.MaterialTypeDesc, |
| | | PrimaryUnit = wmsmaterial.PrimaryUnit, |
| | | Standard = wmsmaterial.Standard, |
| | | OuterDiameter = wmsmaterial.OuterDiameter, |
| | |
| | | IsMainBranch = wmsmaterial.IsMainBranch, |
| | | Factory = wmsmaterial.Factory, |
| | | Certification = wmsmaterial.Certification, |
| | | MaterialModel = wmsmaterial.MaterialModel, |
| | | Remark = wmsmaterial.Remark, |
| | | }; |
| | | |
| | |
| | | MaterialNo = wmsmaterial.MaterialNo, |
| | | MaterialName = wmsmaterial.MaterialName, |
| | | PurchaseType = wmsmaterial.PurchaseType, |
| | | MaterialType = wmsmaterial.MaterialType, |
| | | MaterialTypeCode = wmsmaterial.MaterialTypeCode, |
| | | MaterialTypeDesc = wmsmaterial.MaterialTypeDesc, |
| | | PrimaryUnit = wmsmaterial.PrimaryUnit, |
| | | Standard = wmsmaterial.Standard, |
| | | OuterDiameter = wmsmaterial.OuterDiameter, |
| | |
| | | MaterialQuality = wmsmaterial.MaterialQuality, |
| | | Length = wmsmaterial.Length, |
| | | IsMainBranch = wmsmaterial.IsMainBranch, |
| | | MaterialModel = wmsmaterial.MaterialModel, |
| | | Factory = wmsmaterial.Factory, |
| | | Certification = wmsmaterial.Certification, |
| | | Remark = wmsmaterial.Remark, |
| | |
| | | } |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public async Task<(Dictionary<string, object> Sheets, string FileName)> ExportAsync(GetWmsMaterialsInput input) |
| | | /// <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<GetWmsMaterialsInput, 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); |
| | | } |
| | | |