22
schangxiang@126.com
2025-05-15 9a83dbb67b223e94a946e1bf7db59336e7fb2f28
PipeLineLems/server/src/CMS.Plugin.PipeLineLems.Application/Implements/CallMaterialOrderAppService.cs
@@ -1,127 +1,140 @@
using CMS.Plugin.PipeLineLems.Application.Contracts.Dtos.CallMaterialOrder;
using CMS.Plugin.PipeLineLems.Application.Contracts.Services;
using CMS.Plugin.PipeLineLems.Domain.Shared;
using CmsQueryExtensions;
using CMS.Plugin.PipeLineLems.Domain.CallMaterialOrder;
using CmsQueryExtensions.Extension;
using System.Linq.Expressions;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Data;
using Volo.Abp.ObjectExtending;
using Volo.Abp.ObjectMapping;
namespace CMS.Plugin.PipeLineLems.Application.Implements;
using CMS.Plugin.PipeLineLems.Application.Contracts.Dtos.CallMaterialOrder;
using CMS.Plugin.PipeLineLems.Application.Contracts.Services;
using CMS.Plugin.PipeLineLems.Domain.Shared;
using CmsQueryExtensions;
using CMS.Plugin.PipeLineLems.Domain.CallMaterialOrder;
using CmsQueryExtensions.Extension;
using System.Linq.Expressions;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Data;
using Volo.Abp.ObjectExtending;
using Volo.Abp.ObjectMapping;
namespace CMS.Plugin.PipeLineLems.Application.Implements;
/// <summary> 
/// 叫料单表应用服务 
/// </summary> 
public class CallMaterialOrderAppService : CMSPluginAppService, ICallMaterialOrderAppService
{
    private readonly ICallMaterialOrderRepository callMaterialOrderRepository;
public class CallMaterialOrderAppService : CMSPluginAppService, ICallMaterialOrderAppService
{
    private readonly ICallMaterialOrderRepository callMaterialOrderRepository;
    private readonly SharedService _sharedService;
    private readonly IServiceProvider _serviceProvider;
    /// <summary> 
    /// Initializes a new instance of the <see cref="CallMaterialOrderAppService"/> class. 
    /// </summary> 
    /// <param name="CallMaterialOrderRepository">The task job repository.</param> 
    public CallMaterialOrderAppService(ICallMaterialOrderRepository _CallMaterialOrderRepository)
    {
        callMaterialOrderRepository = _CallMaterialOrderRepository;
    }
    public CallMaterialOrderAppService(ICallMaterialOrderRepository _CallMaterialOrderRepository, SharedService sharedService, IServiceProvider serviceProvider)
    {
        callMaterialOrderRepository = _CallMaterialOrderRepository;
        _sharedService = sharedService;
        _serviceProvider = serviceProvider;
    }
    /// <summary> 
    /// 获取指定叫料单表 
    /// </summary> 
    /// <param name="id"></param> 
    /// <returns></returns> 
    public virtual async Task<CallMaterialOrderDto> GetAsync(Guid id)
    {
        return ObjectMapper.Map<CallMaterialOrder, CallMaterialOrderDto>(await callMaterialOrderRepository.GetAsync(id));
    }
    public virtual async Task<CallMaterialOrderDto> GetAsync(Guid id)
    {
        return ObjectMapper.Map<CallMaterialOrder, CallMaterialOrderDto>(await callMaterialOrderRepository.GetAsync(id));
    }
    public virtual async Task CallMaterialByDataIdentifier(Guid id)
    {
        await _sharedService.CallMaterialByDataIdentifier(id, _serviceProvider);
    }
    public virtual async Task<CallMaterialOrder> FindByWmsTaskNoAsync(string wmsTaskNo)
    {
        return await callMaterialOrderRepository.FindByWmsTaskNoAsync(wmsTaskNo);
    }
    /// <summary> 
    /// 分页获取叫料单表 
    /// </summary> 
    /// <param name="input"></param> 
    /// <returns></returns> 
    public virtual async Task<PagedResultDto<CallMaterialOrderDto>> GetListAsync(GetCallMaterialOrderInput input)
    {
        Check.NotNull(input, nameof(input));
        if (input.Sorting.IsNullOrWhiteSpace())
        {
            input.Sorting = nameof(CallMaterialOrder.Sort);
        }
    public virtual async Task<PagedResultDto<CallMaterialOrderDto>> GetListAsync(GetCallMaterialOrderInput input)
    {
        Check.NotNull(input, nameof(input));
        if (input.Sorting.IsNullOrWhiteSpace())
        {
            input.Sorting = nameof(CallMaterialOrder.Sort);
        }
        #region 动态构造查询条件  
        //动态构造查询条件  
        var whereConditions = DynamicGetQueryParams(input);
        #endregion
        var count = await callMaterialOrderRepository.GetCountAsync(whereConditions);
        var list = await callMaterialOrderRepository.GetListAsync(whereConditions, input.Sorting, input.MaxResultCount, input.SkipCount);
        return new PagedResultDto<CallMaterialOrderDto>(count, ObjectMapper.Map<List<CallMaterialOrder>, List<CallMaterialOrderDto>>(list));
    }
        var whereConditions = DynamicGetQueryParams(input);
        #endregion
        var count = await callMaterialOrderRepository.GetCountAsync(whereConditions);
        var list = await callMaterialOrderRepository.GetListAsync(whereConditions, input.Sorting, input.MaxResultCount, input.SkipCount);
        return new PagedResultDto<CallMaterialOrderDto>(count, ObjectMapper.Map<List<CallMaterialOrder>, List<CallMaterialOrderDto>>(list));
    }
    /// <summary>  
    /// 动态构造查询条件  
    /// </summary>  
    /// <param name="input">输入参数</param>  
    /// <returns></returns>  
    private FunReturnResultModel<Expression<Func<CallMaterialOrder, bool>>> DynamicGetQueryParams(GetCallMaterialOrderInput input)
    {
    private FunReturnResultModel<Expression<Func<CallMaterialOrder, bool>>> DynamicGetQueryParams(GetCallMaterialOrderInput input)
    {
        //动态构造查询条件  
        var whereConditions = WhereConditionsExtensions.GetWhereConditions<CallMaterialOrder, GetCallMaterialOrderInput>(input);
        if (!whereConditions.IsSuccess)
        {
            throw new Exception("动态构造查询条件失败:" + whereConditions.ErrMsg);
        }
        var whereConditions = WhereConditionsExtensions.GetWhereConditions<CallMaterialOrder, GetCallMaterialOrderInput>(input);
        if (!whereConditions.IsSuccess)
        {
            throw new Exception("动态构造查询条件失败:" + whereConditions.ErrMsg);
        }
        //也可再次自定义构建查询条件  
        Expression<Func<CallMaterialOrder, bool>> extendExpression = a => a.IsDeleted == false;
        Expression<Func<CallMaterialOrder, bool>> extendExpression = a => a.IsDeleted == false;
        // 使用 System.Linq.PredicateBuilder 的 And 
        var pres = (System.Linq.Expressions.Expression<Func<CallMaterialOrder, bool>>)(whereConditions.data);
        whereConditions.data = System.Linq.PredicateBuilder.And(pres, extendExpression);
        return whereConditions;
    }
        var pres = (System.Linq.Expressions.Expression<Func<CallMaterialOrder, bool>>)(whereConditions.data);
        whereConditions.data = System.Linq.PredicateBuilder.And(pres, extendExpression);
        return whereConditions;
    }
    /// <summary> 
    /// 新建叫料单表 
    /// </summary> 
    /// <param name="input"></param> 
    /// <returns></returns> 
    /// <exception cref="UserFriendlyException"></exception> 
    public virtual async Task<CallMaterialOrderDto> CreateAsync(CallMaterialOrderCreateDto input)
    {
        await CheckCreateOrUpdateDtoAsync(input);
        var exist = await callMaterialOrderRepository.NameExistAsync(input.DataIdentifier);
        if (exist)
        {
            throw new UserFriendlyException(L[CMSPluginDomainErrorCodes.NameAlreadyExists, input.DataIdentifier]);
        }
        var maxSort = await callMaterialOrderRepository.GetMaxSortAsync();
        var sort = input.Sort ?? maxSort;
        var insertObj = ObjectMapper.Map<CallMaterialOrderCreateDto, CallMaterialOrder>(input);
        insertObj.Sort = sort;
        input.MapExtraPropertiesTo(insertObj, MappingPropertyDefinitionChecks.None);
        await callMaterialOrderRepository.InsertAsync(insertObj);
    public virtual async Task<CallMaterialOrderDto> CreateAsync(CallMaterialOrderCreateDto input)
    {
        await CheckCreateOrUpdateDtoAsync(input);
        var exist = await callMaterialOrderRepository.NameExistAsync(input.DataIdentifier);
        if (exist)
        {
            throw new UserFriendlyException(L[CMSPluginDomainErrorCodes.NameAlreadyExists, input.DataIdentifier]);
        }
        var maxSort = await callMaterialOrderRepository.GetMaxSortAsync();
        var sort = input.Sort ?? maxSort;
        var insertObj = ObjectMapper.Map<CallMaterialOrderCreateDto, CallMaterialOrder>(input);
        insertObj.Sort = sort;
        input.MapExtraPropertiesTo(insertObj, MappingPropertyDefinitionChecks.None);
        await callMaterialOrderRepository.InsertAsync(insertObj);
        //if (input.Sort.HasValue && insertObj.Sort != maxSort) 
        //{ 
        //    await AdjustSortAsync(insertObj.Id, insertObj.Sort); 
        //} 
        return ObjectMapper.Map<CallMaterialOrder, CallMaterialOrderDto>(insertObj);
    }
        return ObjectMapper.Map<CallMaterialOrder, CallMaterialOrderDto>(insertObj);
    }
    /// <summary> 
    /// 更新叫料单表 
    /// </summary> 
@@ -129,41 +142,41 @@
    /// <param name="input"></param> 
    /// <returns></returns> 
    /// <exception cref="UserFriendlyException"></exception> 
    public virtual async Task<CallMaterialOrderDto> UpdateAsync(Guid id, CallMaterialOrderUpdateDto input)
    {
        await CheckCreateOrUpdateDtoAsync(input);
        var updateObj = await callMaterialOrderRepository.GetAsync(id);
        var exist = await callMaterialOrderRepository.NameExistAsync(input.DataIdentifier, updateObj.Id);
        if (exist)
        {
            throw new UserFriendlyException(L[CMSPluginDomainErrorCodes.NameAlreadyExists, input.DataIdentifier]);
        }
        updateObj.SetConcurrencyStampIfNotNull(input.ConcurrencyStamp);
        input.MapExtraPropertiesTo(updateObj, MappingPropertyDefinitionChecks.None);
                updateObj.DataIdentifier = input.DataIdentifier;
    public virtual async Task<CallMaterialOrderDto> UpdateAsync(Guid id, CallMaterialOrderUpdateDto input)
    {
        await CheckCreateOrUpdateDtoAsync(input);
        var updateObj = await callMaterialOrderRepository.GetAsync(id);
        var exist = await callMaterialOrderRepository.NameExistAsync(input.DataIdentifier, updateObj.Id);
        if (exist)
        {
            throw new UserFriendlyException(L[CMSPluginDomainErrorCodes.NameAlreadyExists, input.DataIdentifier]);
        }
        updateObj.SetConcurrencyStampIfNotNull(input.ConcurrencyStamp);
        input.MapExtraPropertiesTo(updateObj, MappingPropertyDefinitionChecks.None);
        updateObj.DataIdentifier = input.DataIdentifier;
        updateObj.MaterialMode = input.MaterialMode;
        updateObj.CallMaterialStatus = input.CallMaterialStatus;
        updateObj.Quantity = input.Quantity;
        updateObj.WmsRetResult = input.WmsRetResult;
        updateObj.WmsTaskNo = input.WmsTaskNo;
        updateObj.Remark = input.Remark;
        await callMaterialOrderRepository.UpdateAsync(updateObj);
        return ObjectMapper.Map<CallMaterialOrder, CallMaterialOrderDto>(updateObj);
    }
        await callMaterialOrderRepository.UpdateAsync(updateObj);
        return ObjectMapper.Map<CallMaterialOrder, CallMaterialOrderDto>(updateObj);
    }
    /// <summary> 
    /// 克隆叫料单表 
    /// </summary> 
    /// <param name="ids"></param> 
    /// <returns></returns> 
    public async Task<List<CallMaterialOrderDto>> CloneAsync(IEnumerable<Guid> ids)
    {
    public async Task<List<CallMaterialOrderDto>> CloneAsync(IEnumerable<Guid> ids)
    {
        //var callMaterialOrders = new List<CallMaterialOrder>(); 
        //if (ids != null) 
        //{ 
@@ -183,234 +196,234 @@
        //                    name += CallMaterialOrderConsts.CloneTag; 
        //                    continue; 
        //                } 
        //                notExist = true; 
        //            } 
        //            //CallMaterialOrder = await callMaterialOrderRepository.InsertAsync(CallMaterialOrder.Clone(GuidGenerator.Create(), name, sort++)); 
        //            callMaterialOrders.Add(CallMaterialOrder); 
        //        } 
        //    } 
        //} 
        //return ObjectMapper.Map<List<CallMaterialOrder>, List<CallMaterialOrderDto>>(callMaterialOrders); 
        return new List<CallMaterialOrderDto>();
    }
        return new List<CallMaterialOrderDto>();
    }
    /// <summary> 
    /// 删除单个叫料单表 
    /// </summary> 
    /// <param name="id"></param> 
    /// <returns></returns> 
    public virtual Task DeleteAsync(Guid id)
    {
        return callMaterialOrderRepository.DeleteAsync(id);
    }
    public virtual Task DeleteAsync(Guid id)
    {
        return callMaterialOrderRepository.DeleteAsync(id);
    }
    /// <summary> 
    /// 删除多个叫料单表 
    /// </summary> 
    /// <param name="ids"></param> 
    /// <returns></returns> 
    public async Task DeleteManyAsync(IEnumerable<Guid> ids)
    {
        foreach (var id in ids)
        {
            await DeleteAsync(id);
        }
    }
    public async Task DeleteManyAsync(IEnumerable<Guid> ids)
    {
        foreach (var id in ids)
        {
            await DeleteAsync(id);
        }
    }
    /// <summary> 
    /// 调整排序叫料单表 
    /// </summary> 
    /// <param name="id"></param> 
    /// <param name="sort"></param> 
    /// <returns></returns> 
    public virtual async Task AdjustSortAsync(Guid id, int sort)
    {
        var list = await callMaterialOrderRepository.GetListAsync(null, nameof(CallMaterialOrder.Sort));
        if (list != null && list.Any())
        {
            var initSort = 1;
            list.ForEach(x => x.AdjustSort(initSort++));
            var entity = list.FirstOrDefault(x => x.Id == id);
            if (entity != null)
            {
                if (sort == 1)
                {
                    list.Where(x => x.Id != id).ToList()?.ForEach(x => x.AdjustSort(x.Sort + 1));
                }
                else if (entity.Sort > sort)
                {
                    list.Where(x => x.Id != id && x.Sort >= sort).ToList()?.ForEach(x => x.AdjustSort(x.Sort + 1));
                    list.Where(x => x.Id != id && x.Sort < sort).ToList()?.ForEach(x => x.AdjustSort(x.Sort - 1));
                }
                else if (entity.Sort < sort)
                {
                    list.Where(x => x.Id != id && x.Sort > sort).ToList()?.ForEach(x => x.AdjustSort(x.Sort + 1));
                    list.Where(x => x.Id != id && x.Sort <= sort).ToList()?.ForEach(x => x.AdjustSort(x.Sort - 1));
                }
                entity.AdjustSort(sort);
            }
        }
        await callMaterialOrderRepository.UpdateManyAsync(list);
    }
    public virtual async Task AdjustSortAsync(Guid id, int sort)
    {
        var list = await callMaterialOrderRepository.GetListAsync(null, nameof(CallMaterialOrder.Sort));
        if (list != null && list.Any())
        {
            var initSort = 1;
            list.ForEach(x => x.AdjustSort(initSort++));
            var entity = list.FirstOrDefault(x => x.Id == id);
            if (entity != null)
            {
                if (sort == 1)
                {
                    list.Where(x => x.Id != id).ToList()?.ForEach(x => x.AdjustSort(x.Sort + 1));
                }
                else if (entity.Sort > sort)
                {
                    list.Where(x => x.Id != id && x.Sort >= sort).ToList()?.ForEach(x => x.AdjustSort(x.Sort + 1));
                    list.Where(x => x.Id != id && x.Sort < sort).ToList()?.ForEach(x => x.AdjustSort(x.Sort - 1));
                }
                else if (entity.Sort < sort)
                {
                    list.Where(x => x.Id != id && x.Sort > sort).ToList()?.ForEach(x => x.AdjustSort(x.Sort + 1));
                    list.Where(x => x.Id != id && x.Sort <= sort).ToList()?.ForEach(x => x.AdjustSort(x.Sort - 1));
                }
                entity.AdjustSort(sort);
            }
        }
        await callMaterialOrderRepository.UpdateManyAsync(list);
    }
    /// <summary> 
    /// 导入叫料单表 
    /// </summary> 
    /// <param name="input"></param> 
    /// <returns></returns> 
    /// <exception cref="UserFriendlyException"></exception> 
    public async Task ImportAsync(CallMaterialOrdersImportModel input)
    {
        Check.NotNull(input, nameof(input));
        var callMaterialOrderCreateDtos = new List<(int RowIndex, CallMaterialOrderCreateDto Item)>();
        var callMaterialOrderUpdateDtos = new List<(int RowIndex, Guid Id, CallMaterialOrderUpdateDto Item)>();
        var importItems = input.CallMaterialOrders;
        if (importItems != null && importItems.Any())
        {
    public async Task ImportAsync(CallMaterialOrdersImportModel input)
    {
        Check.NotNull(input, nameof(input));
        var callMaterialOrderCreateDtos = new List<(int RowIndex, CallMaterialOrderCreateDto Item)>();
        var callMaterialOrderUpdateDtos = new List<(int RowIndex, Guid Id, CallMaterialOrderUpdateDto Item)>();
        var importItems = input.CallMaterialOrders;
        if (importItems != null && importItems.Any())
        {
            #region 导入校验 
            // 判断名称是否重复,并输出第几行重复 
            var duplicateCallMaterialOrders = importItems.GroupBy(x => x.DataIdentifier).Where(x => x.Count() > 1).ToList();
            if (duplicateCallMaterialOrders?.Any() == true)
            {
                var duplicateCallMaterialOrderMsgs = duplicateCallMaterialOrders.Select(x => $"第 {string.Join(",", x.Select(x => x.RowIndex))} 行:{x.Key}  名称重复");
                var errorMsg = $"导入失败!配置, {string.Join(",", duplicateCallMaterialOrderMsgs)},终止导入";
                throw new UserFriendlyException(errorMsg);
            }
            #endregion
            foreach (var impItem in importItems)
            {
                if (impItem.DataIdentifier.IsNullOrWhiteSpace())
                {
                    continue;
                }
                if (impItem.DataIdentifier.IsNullOrWhiteSpace())
                {
                    var errorMsg = $"导入失败!配置,第{impItem.RowIndex}行:CallMaterialOrder名称不能为空";
                    throw new UserFriendlyException(errorMsg);
                }
                var oldCallMaterialOrder = await callMaterialOrderRepository.FindByNameAsync(impItem.DataIdentifier);
                if (oldCallMaterialOrder != null)
                {
                    var callMaterialOrderUpdateDto = new CallMaterialOrderUpdateDto
                    {
            var duplicateCallMaterialOrders = importItems.GroupBy(x => x.DataIdentifier).Where(x => x.Count() > 1).ToList();
            if (duplicateCallMaterialOrders?.Any() == true)
            {
                var duplicateCallMaterialOrderMsgs = duplicateCallMaterialOrders.Select(x => $"第 {string.Join(",", x.Select(x => x.RowIndex))} 行:{x.Key}  名称重复");
                var errorMsg = $"导入失败!配置, {string.Join(",", duplicateCallMaterialOrderMsgs)},终止导入";
                throw new UserFriendlyException(errorMsg);
            }
            #endregion
            foreach (var impItem in importItems)
            {
                if (impItem.DataIdentifier.IsNullOrWhiteSpace())
                {
                    continue;
                }
                if (impItem.DataIdentifier.IsNullOrWhiteSpace())
                {
                    var errorMsg = $"导入失败!配置,第{impItem.RowIndex}行:CallMaterialOrder名称不能为空";
                    throw new UserFriendlyException(errorMsg);
                }
                var oldCallMaterialOrder = await callMaterialOrderRepository.FindByNameAsync(impItem.DataIdentifier);
                if (oldCallMaterialOrder != null)
                {
                    var callMaterialOrderUpdateDto = new CallMaterialOrderUpdateDto
                    {
                        DataIdentifier = impItem.DataIdentifier,
MaterialMode = impItem.MaterialMode,
CallMaterialStatus = impItem.CallMaterialStatus,
Quantity = impItem.Quantity,
WmsRetResult = impItem.WmsRetResult,
WmsTaskNo = impItem.WmsTaskNo,
Remark = impItem.Remark,
                    };
                    callMaterialOrderUpdateDtos.Add((impItem.RowIndex, oldCallMaterialOrder.Id, callMaterialOrderUpdateDto));
                }
                else
                {
                    var callMaterialOrderCreateDto = new CallMaterialOrderCreateDto
                    {
                        MaterialMode = impItem.MaterialMode,
                        CallMaterialStatus = impItem.CallMaterialStatus,
                        Quantity = impItem.Quantity,
                        WmsRetResult = impItem.WmsRetResult,
                        WmsTaskNo = impItem.WmsTaskNo,
                        Remark = impItem.Remark,
                    };
                    callMaterialOrderUpdateDtos.Add((impItem.RowIndex, oldCallMaterialOrder.Id, callMaterialOrderUpdateDto));
                }
                else
                {
                    var callMaterialOrderCreateDto = new CallMaterialOrderCreateDto
                    {
                        DataIdentifier = impItem.DataIdentifier,
MaterialMode = impItem.MaterialMode,
CallMaterialStatus = impItem.CallMaterialStatus,
Quantity = impItem.Quantity,
WmsRetResult = impItem.WmsRetResult,
WmsTaskNo = impItem.WmsTaskNo,
Remark = impItem.Remark,
                    };
                    callMaterialOrderCreateDtos.Add((impItem.RowIndex, callMaterialOrderCreateDto));
                }
            }
        }
                        MaterialMode = impItem.MaterialMode,
                        CallMaterialStatus = impItem.CallMaterialStatus,
                        Quantity = impItem.Quantity,
                        WmsRetResult = impItem.WmsRetResult,
                        WmsTaskNo = impItem.WmsTaskNo,
                        Remark = impItem.Remark,
                    };
                    callMaterialOrderCreateDtos.Add((impItem.RowIndex, callMaterialOrderCreateDto));
                }
            }
        }
        // 新增 
        foreach (var callMaterialOrderDto in callMaterialOrderCreateDtos)
        {
            try
            {
                await CreateAsync(callMaterialOrderDto.Item);
            }
            catch (Exception e)
            {
                var errorMsg = $"导入失败!配置,第{callMaterialOrderDto.RowIndex}行:{e.Message},终止导入";
                throw new UserFriendlyException(errorMsg);
            }
        }
        foreach (var callMaterialOrderDto in callMaterialOrderCreateDtos)
        {
            try
            {
                await CreateAsync(callMaterialOrderDto.Item);
            }
            catch (Exception e)
            {
                var errorMsg = $"导入失败!配置,第{callMaterialOrderDto.RowIndex}行:{e.Message},终止导入";
                throw new UserFriendlyException(errorMsg);
            }
        }
        // 更新 
        foreach (var callMaterialOrderDto in callMaterialOrderUpdateDtos)
        {
            try
            {
                await UpdateAsync(callMaterialOrderDto.Id, callMaterialOrderDto.Item);
            }
            catch (Exception e)
            {
                var errorMsg = $"导入失败!配置,第{callMaterialOrderDto.RowIndex}行:{e.Message},终止导入";
                throw new UserFriendlyException(errorMsg);
            }
        }
    }
        foreach (var callMaterialOrderDto in callMaterialOrderUpdateDtos)
        {
            try
            {
                await UpdateAsync(callMaterialOrderDto.Id, callMaterialOrderDto.Item);
            }
            catch (Exception e)
            {
                var errorMsg = $"导入失败!配置,第{callMaterialOrderDto.RowIndex}行:{e.Message},终止导入";
                throw new UserFriendlyException(errorMsg);
            }
        }
    }
    /// <summary> 
    /// 导出叫料单表 
    /// </summary> 
    /// <param name="input"></param> 
    /// <returns></returns> 
    public async Task<(Dictionary<string, object> Sheets, string FileName)> ExportAsync(GetCallMaterialOrderInput input)
    {
        Check.NotNull(input, nameof(input));
        if (input.Sorting.IsNullOrWhiteSpace())
        {
            input.Sorting = nameof(CallMaterialOrder.Sort);
        }
    public async Task<(Dictionary<string, object> Sheets, string FileName)> ExportAsync(GetCallMaterialOrderInput input)
    {
        Check.NotNull(input, nameof(input));
        if (input.Sorting.IsNullOrWhiteSpace())
        {
            input.Sorting = nameof(CallMaterialOrder.Sort);
        }
        #region 动态构造查询条件  
        //动态构造查询条件  
        var whereConditions = DynamicGetQueryParams(input);
        #endregion
        var list = await callMaterialOrderRepository.GetListAsync(whereConditions, input.Sorting, input.MaxResultCount, input.SkipCount, includeDetails: true);
        var result = ObjectMapper.Map<List<CallMaterialOrder>, List<CallMaterialOrderDto>>(list);
        var sheets = new Dictionary<string, object>
        {
            ["配置"] = ExportHelper.ConvertListToExportData(result),
        };
        var fileName = "叫料单";
        return (sheets, fileName);
    }
        var whereConditions = DynamicGetQueryParams(input);
        #endregion
        var list = await callMaterialOrderRepository.GetListAsync(whereConditions, input.Sorting, input.MaxResultCount, input.SkipCount, includeDetails: true);
        var result = ObjectMapper.Map<List<CallMaterialOrder>, List<CallMaterialOrderDto>>(list);
        var sheets = new Dictionary<string, object>
        {
            ["配置"] = ExportHelper.ConvertListToExportData(result),
        };
        var fileName = "叫料单";
        return (sheets, fileName);
    }
    /// <summary> 
    /// 校验叫料单表,当新建或更新时 
    /// </summary> 
    /// <param name="input"></param> 
    /// <returns></returns> 
    protected Task CheckCreateOrUpdateDtoAsync(CallMaterialOrderCreateOrUpdateDtoBase input)
    {
        Check.NotNull(input, nameof(input));
                Check.NotNullOrWhiteSpace(input.DataIdentifier, "原料标识", 256);
    protected Task CheckCreateOrUpdateDtoAsync(CallMaterialOrderCreateOrUpdateDtoBase input)
    {
        Check.NotNull(input, nameof(input));
        Check.NotNullOrWhiteSpace(input.DataIdentifier, "原料标识", 256);
        Check.NotNull(input.CallMaterialStatus, "叫料状态");
        Check.NotNull(input.Quantity, "叫料数量");
        return Task.CompletedTask;
    }
}
        return Task.CompletedTask;
    }
}