| | |
| | | using CMS.Plugin.HIAWms.Application.Contracts.Dtos.WmsInOutStockRecord; |
| | | using CMS.Plugin.HIAWms.Application.Contracts.Services; |
| | | using CMS.Plugin.HIAWms.Domain.Shared; |
| | | using CMS.Plugin.HIAWms.Domain.WmsInOutStockRecord; |
| | | using CmsQueryExtensions; |
| | | 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.HIAWms.Application.Implements; |
| | | |
| | | using CMS.Plugin.HIAWms.Application.Contracts.Dtos.WmsInOutStockRecord; |
| | | using CMS.Plugin.HIAWms.Application.Contracts.Services; |
| | | using CMS.Plugin.HIAWms.Domain.Shared; |
| | | using CmsQueryExtensions; |
| | | using CMS.Plugin.HIAWms.Domain.WmsInOutStockRecord; |
| | | 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.HIAWms.Application.Implements; |
| | | |
| | | /// <summary> |
| | | /// 出入库记录表应用服务 |
| | | /// 出入库记录应用服务 |
| | | /// </summary> |
| | | public class WmsInOutStockRecordAppService : CMSPluginAppService, IWmsInOutStockRecordAppService |
| | | { |
| | | private readonly IWmsInOutStockRecordRepository _wmsInOutStockRecordRepository; |
| | | |
| | | public class WmsInOutStockRecordAppService : CMSPluginAppService, IWmsInOutStockRecordAppService |
| | | { |
| | | private readonly IWmsInOutStockRecordRepository wmsInOutStockRecordRepository; |
| | | |
| | | /// <summary> |
| | | /// Initializes a new instance of the <see cref="WmsInOutStockRecordAppService"/> class. |
| | | /// </summary> |
| | | /// <param name="WmsInOutStockRecordRepository">The task job repository.</param> |
| | | public WmsInOutStockRecordAppService(IWmsInOutStockRecordRepository wmsInOutStockRecordRepository) |
| | | { |
| | | _wmsInOutStockRecordRepository = wmsInOutStockRecordRepository; |
| | | } |
| | | |
| | | public WmsInOutStockRecordAppService(IWmsInOutStockRecordRepository _WmsInOutStockRecordRepository) |
| | | { |
| | | wmsInOutStockRecordRepository = _WmsInOutStockRecordRepository; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取指定出入库记录表 |
| | | /// 获取指定出入库记录 |
| | | /// </summary> |
| | | /// <param name="id"></param> |
| | | /// <returns></returns> |
| | | public virtual async Task<WmsInOutStockRecordDto> GetAsync(Guid id) |
| | | { |
| | | return ObjectMapper.Map<WmsInOutStockRecord, WmsInOutStockRecordDto>(await _wmsInOutStockRecordRepository.GetAsync(id)); |
| | | } |
| | | |
| | | public virtual async Task<WmsInOutStockRecordDto> GetAsync(Guid id) |
| | | { |
| | | return ObjectMapper.Map<WmsInOutStockRecord, WmsInOutStockRecordDto>(await wmsInOutStockRecordRepository.GetAsync(id)); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 分页获取出入库记录表 |
| | | /// 分页获取出入库记录 |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | public virtual async Task<PagedResultDto<WmsInOutStockRecordDto>> GetListAsync(GetWmsInOutStockRecordInput input) |
| | | { |
| | | Check.NotNull(input, nameof(input)); |
| | | |
| | | if (input.Sorting.IsNullOrWhiteSpace()) |
| | | { |
| | | input.Sorting = nameof(WmsInOutStockRecord.Sort); |
| | | } |
| | | |
| | | public virtual async Task<PagedResultDto<WmsInOutStockRecordDto>> GetListAsync(GetWmsInOutStockRecordInput input) |
| | | { |
| | | Check.NotNull(input, nameof(input)); |
| | | |
| | | if (input.Sorting.IsNullOrWhiteSpace()) |
| | | { |
| | | input.Sorting = nameof(WmsInOutStockRecord.Sort); |
| | | } |
| | | |
| | | #region 动态构造查询条件 |
| | | |
| | | |
| | | //动态构造查询条件 |
| | | var whereConditions = DynamicGetQueryParams(input); |
| | | |
| | | #endregion |
| | | |
| | | var count = await _wmsInOutStockRecordRepository.GetCountAsync(whereConditions); |
| | | var list = await _wmsInOutStockRecordRepository.GetListAsync(whereConditions, input.Sorting, input.MaxResultCount, input.SkipCount); |
| | | |
| | | return new PagedResultDto<WmsInOutStockRecordDto>(count, ObjectMapper.Map<List<WmsInOutStockRecord>, List<WmsInOutStockRecordDto>>(list)); |
| | | } |
| | | |
| | | var whereConditions = DynamicGetQueryParams(input); |
| | | |
| | | #endregion |
| | | |
| | | var count = await wmsInOutStockRecordRepository.GetCountAsync(whereConditions); |
| | | var list = await wmsInOutStockRecordRepository.GetListAsync(whereConditions, input.Sorting, input.MaxResultCount, input.SkipCount); |
| | | |
| | | return new PagedResultDto<WmsInOutStockRecordDto>(count, ObjectMapper.Map<List<WmsInOutStockRecord>, List<WmsInOutStockRecordDto>>(list)); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 动态构造查询条件 |
| | | /// </summary> |
| | | /// <param name="input">输入参数</param> |
| | | /// <returns></returns> |
| | | private FunReturnResultModel<Expression<Func<WmsInOutStockRecord, bool>>> DynamicGetQueryParams(GetWmsInOutStockRecordInput input) |
| | | { |
| | | private FunReturnResultModel<Expression<Func<WmsInOutStockRecord, bool>>> DynamicGetQueryParams(GetWmsInOutStockRecordInput input) |
| | | { |
| | | //动态构造查询条件 |
| | | var whereConditions = WhereConditionsExtensions.GetWhereConditions<WmsInOutStockRecord, GetWmsInOutStockRecordInput>(input); |
| | | if (!whereConditions.IsSuccess) |
| | | { |
| | | throw new Exception("动态构造查询条件失败:" + whereConditions.ErrMsg); |
| | | } |
| | | |
| | | var whereConditions = WhereConditionsExtensions.GetWhereConditions<WmsInOutStockRecord, GetWmsInOutStockRecordInput>(input); |
| | | if (!whereConditions.IsSuccess) |
| | | { |
| | | throw new Exception("动态构造查询条件失败:" + whereConditions.ErrMsg); |
| | | } |
| | | |
| | | //也可再次自定义构建查询条件 |
| | | Expression<Func<WmsInOutStockRecord, bool>> extendExpression = a => a.IsDeleted == false; |
| | | Expression<Func<WmsInOutStockRecord, bool>> extendExpression = a => a.IsDeleted == false; |
| | | // 使用 System.Linq.PredicateBuilder 的 And |
| | | var pres = (System.Linq.Expressions.Expression<Func<WmsInOutStockRecord, bool>>)(whereConditions.data); |
| | | whereConditions.data = System.Linq.PredicateBuilder.And(pres, extendExpression); |
| | | |
| | | return whereConditions; |
| | | } |
| | | |
| | | var pres = (System.Linq.Expressions.Expression<Func<WmsInOutStockRecord, 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<WmsInOutStockRecordDto> CreateAsync(WmsInOutStockRecordCreateDto input) |
| | | { |
| | | await CheckCreateOrUpdateDtoAsync(input); |
| | | |
| | | |
| | | |
| | | var maxSort = await _wmsInOutStockRecordRepository.GetMaxSortAsync(); |
| | | var sort = input.Sort ?? maxSort; |
| | | |
| | | var insertObj = ObjectMapper.Map<WmsInOutStockRecordCreateDto, WmsInOutStockRecord>(input); |
| | | insertObj.Sort = sort; |
| | | input.MapExtraPropertiesTo(insertObj, MappingPropertyDefinitionChecks.None); |
| | | |
| | | await _wmsInOutStockRecordRepository.InsertAsync(insertObj); |
| | | |
| | | if (input.Sort.HasValue && insertObj.Sort != maxSort) |
| | | { |
| | | await AdjustSortAsync(insertObj.Id, insertObj.Sort); |
| | | } |
| | | |
| | | return ObjectMapper.Map<WmsInOutStockRecord, WmsInOutStockRecordDto>(insertObj); |
| | | } |
| | | |
| | | public virtual async Task<WmsInOutStockRecordDto> CreateAsync(WmsInOutStockRecordCreateDto input) |
| | | { |
| | | await CheckCreateOrUpdateDtoAsync(input); |
| | | |
| | | var exist = await wmsInOutStockRecordRepository.NameExistAsync(input.Id); |
| | | if (exist) |
| | | { |
| | | throw new UserFriendlyException(L[CMSPluginDomainErrorCodes.NameAlreadyExists, input.Id]); |
| | | } |
| | | |
| | | var maxSort = await wmsInOutStockRecordRepository.GetMaxSortAsync(); |
| | | var sort = input.Sort ?? maxSort; |
| | | |
| | | var insertObj = ObjectMapper.Map<WmsInOutStockRecordCreateDto, WmsInOutStockRecord>(input); |
| | | insertObj.Sort = sort; |
| | | input.MapExtraPropertiesTo(insertObj, MappingPropertyDefinitionChecks.None); |
| | | |
| | | await wmsInOutStockRecordRepository.InsertAsync(insertObj); |
| | | |
| | | if (input.Sort.HasValue && insertObj.Sort != maxSort) |
| | | { |
| | | await AdjustSortAsync(insertObj.Id, insertObj.Sort); |
| | | } |
| | | |
| | | return ObjectMapper.Map<WmsInOutStockRecord, WmsInOutStockRecordDto>(insertObj); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新出入库记录表 |
| | | /// 更新出入库记录 |
| | | /// </summary> |
| | | /// <param name="id"></param> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="UserFriendlyException"></exception> |
| | | public virtual async Task<WmsInOutStockRecordDto> UpdateAsync(Guid id, WmsInOutStockRecordUpdateDto input) |
| | | { |
| | | await CheckCreateOrUpdateDtoAsync(input); |
| | | |
| | | var updateObj = await _wmsInOutStockRecordRepository.GetAsync(id); |
| | | |
| | | |
| | | updateObj.SetConcurrencyStampIfNotNull(input.ConcurrencyStamp); |
| | | input.MapExtraPropertiesTo(updateObj, MappingPropertyDefinitionChecks.None); |
| | | |
| | | updateObj.OrderNo = input.OrderNo; |
| | | public virtual async Task<WmsInOutStockRecordDto> UpdateAsync(Guid id, WmsInOutStockRecordUpdateDto input) |
| | | { |
| | | await CheckCreateOrUpdateDtoAsync(input); |
| | | |
| | | var updateObj = await wmsInOutStockRecordRepository.GetAsync(id); |
| | | var exist = await wmsInOutStockRecordRepository.NameExistAsync(input.Id, updateObj.Id); |
| | | if (exist) |
| | | { |
| | | throw new UserFriendlyException(L[CMSPluginDomainErrorCodes.NameAlreadyExists, input.Id]); |
| | | } |
| | | |
| | | updateObj.SetConcurrencyStampIfNotNull(input.ConcurrencyStamp); |
| | | input.MapExtraPropertiesTo(updateObj, MappingPropertyDefinitionChecks.None); |
| | | |
| | | updateObj.OrderNo = input.OrderNo; |
| | | updateObj.MaterialName = input.MaterialName; |
| | | updateObj.MaterialNo = input.MaterialNo; |
| | | updateObj.StockType = input.StockType; |
| | |
| | | updateObj.TaskNo = input.TaskNo; |
| | | updateObj.SourcePlace = input.SourcePlace; |
| | | updateObj.ToPlace = input.ToPlace; |
| | | |
| | | |
| | | await _wmsInOutStockRecordRepository.UpdateAsync(updateObj); |
| | | |
| | | return ObjectMapper.Map<WmsInOutStockRecord, WmsInOutStockRecordDto>(updateObj); |
| | | } |
| | | |
| | | updateObj.IsDisabled = input.IsDisabled; |
| | | |
| | | |
| | | await wmsInOutStockRecordRepository.UpdateAsync(updateObj); |
| | | |
| | | return ObjectMapper.Map<WmsInOutStockRecord, WmsInOutStockRecordDto>(updateObj); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 克隆出入库记录表 |
| | | /// 克隆出入库记录 |
| | | /// </summary> |
| | | /// <param name="ids"></param> |
| | | /// <returns></returns> |
| | | public async Task<List<WmsInOutStockRecordDto>> CloneAsync(IEnumerable<Guid> ids) |
| | | { |
| | | public async Task<List<WmsInOutStockRecordDto>> CloneAsync(IEnumerable<Guid> ids) |
| | | { |
| | | //var wmsInOutStockRecords = new List<WmsInOutStockRecord>(); |
| | | //if (ids != null) |
| | | //{ |
| | |
| | | // name += WmsInOutStockRecordConsts.CloneTag; |
| | | // continue; |
| | | // } |
| | | |
| | | |
| | | // notExist = true; |
| | | // } |
| | | |
| | | |
| | | // //WmsInOutStockRecord = await wmsInOutStockRecordRepository.InsertAsync(WmsInOutStockRecord.Clone(GuidGenerator.Create(), name, sort++)); |
| | | // wmsInOutStockRecords.Add(WmsInOutStockRecord); |
| | | // } |
| | | // } |
| | | //} |
| | | |
| | | |
| | | //return ObjectMapper.Map<List<WmsInOutStockRecord>, List<WmsInOutStockRecordDto>>(wmsInOutStockRecords); |
| | | return new List<WmsInOutStockRecordDto>(); |
| | | } |
| | | |
| | | return new List<WmsInOutStockRecordDto>(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 删除单个出入库记录表 |
| | | /// 删除单个出入库记录 |
| | | /// </summary> |
| | | /// <param name="id"></param> |
| | | /// <returns></returns> |
| | | public virtual Task DeleteAsync(Guid id) |
| | | { |
| | | return _wmsInOutStockRecordRepository.DeleteAsync(id); |
| | | } |
| | | |
| | | public virtual Task DeleteAsync(Guid id) |
| | | { |
| | | return wmsInOutStockRecordRepository.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 _wmsInOutStockRecordRepository.GetListAsync(null, nameof(WmsInOutStockRecord.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 _wmsInOutStockRecordRepository.UpdateManyAsync(list); |
| | | } |
| | | |
| | | public virtual async Task AdjustSortAsync(Guid id, int sort) |
| | | { |
| | | var list = await wmsInOutStockRecordRepository.GetListAsync(null, nameof(WmsInOutStockRecord.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 wmsInOutStockRecordRepository.UpdateManyAsync(list); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 导入出入库记录表 |
| | | /// 导入出入库记录 |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="UserFriendlyException"></exception> |
| | | public async Task ImportAsync(WmsInOutStockRecordsImportModel input) |
| | | { |
| | | |
| | | } |
| | | |
| | | public async Task ImportAsync(WmsInOutStockRecordsImportModel input) |
| | | { |
| | | Check.NotNull(input, nameof(input)); |
| | | |
| | | var wmsInOutStockRecordCreateDtos = new List<(int RowIndex, WmsInOutStockRecordCreateDto Item)>(); |
| | | var wmsInOutStockRecordUpdateDtos = new List<(int RowIndex, Guid Id, WmsInOutStockRecordUpdateDto Item)>(); |
| | | var importItems = input.WmsInOutStockRecords; |
| | | |
| | | if (importItems != null && importItems.Any()) |
| | | { |
| | | #region 导入校验 |
| | | |
| | | // 判断名称是否重复,并输出第几行重复 |
| | | var duplicateWmsInOutStockRecords = importItems.GroupBy(x => x.Id).Where(x => x.Count() > 1).ToList(); |
| | | if (duplicateWmsInOutStockRecords?.Any() == true) |
| | | { |
| | | var duplicateWmsInOutStockRecordMsgs = duplicateWmsInOutStockRecords.Select(x => $"第 {string.Join(",", x.Select(x => x.RowIndex))} 行:{x.Key} 名称重复"); |
| | | var errorMsg = $"导入失败!配置, {string.Join(",", duplicateWmsInOutStockRecordMsgs)},终止导入"; |
| | | throw new UserFriendlyException(errorMsg); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | foreach (var impItem in importItems) |
| | | { |
| | | if (impItem.Id.IsNullOrWhiteSpace()) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | if (impItem.Id.IsNullOrWhiteSpace()) |
| | | { |
| | | var errorMsg = $"导入失败!配置,第{impItem.RowIndex}行:WmsInOutStockRecord名称不能为空"; |
| | | throw new UserFriendlyException(errorMsg); |
| | | } |
| | | |
| | | var oldWmsInOutStockRecord = await wmsInOutStockRecordRepository.FindByNameAsync(impItem.Id); |
| | | if (oldWmsInOutStockRecord != null) |
| | | { |
| | | var wmsInOutStockRecordUpdateDto = new WmsInOutStockRecordUpdateDto |
| | | { |
| | | OrderNo = impItem.OrderNo, |
| | | MaterialName = impItem.MaterialName, |
| | | MaterialNo = impItem.MaterialNo, |
| | | StockType = impItem.StockType, |
| | | ContainerNo = impItem.ContainerNo, |
| | | MaterialModel = impItem.MaterialModel, |
| | | OperateTime = impItem.OperateTime, |
| | | Remark = impItem.Remark, |
| | | MaterialId = impItem.MaterialId, |
| | | TaskNo = impItem.TaskNo, |
| | | SourcePlace = impItem.SourcePlace, |
| | | ToPlace = impItem.ToPlace, |
| | | IsDisabled = impItem.IsDisabled, |
| | | |
| | | }; |
| | | |
| | | wmsInOutStockRecordUpdateDtos.Add((impItem.RowIndex, oldWmsInOutStockRecord.Id, wmsInOutStockRecordUpdateDto)); |
| | | } |
| | | else |
| | | { |
| | | var wmsInOutStockRecordCreateDto = new WmsInOutStockRecordCreateDto |
| | | { |
| | | OrderNo = impItem.OrderNo, |
| | | MaterialName = impItem.MaterialName, |
| | | MaterialNo = impItem.MaterialNo, |
| | | StockType = impItem.StockType, |
| | | ContainerNo = impItem.ContainerNo, |
| | | MaterialModel = impItem.MaterialModel, |
| | | OperateTime = impItem.OperateTime, |
| | | Remark = impItem.Remark, |
| | | MaterialId = impItem.MaterialId, |
| | | TaskNo = impItem.TaskNo, |
| | | SourcePlace = impItem.SourcePlace, |
| | | ToPlace = impItem.ToPlace, |
| | | IsDisabled = impItem.IsDisabled, |
| | | |
| | | }; |
| | | |
| | | wmsInOutStockRecordCreateDtos.Add((impItem.RowIndex, wmsInOutStockRecordCreateDto)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 新增 |
| | | foreach (var wmsInOutStockRecordDto in wmsInOutStockRecordCreateDtos) |
| | | { |
| | | try |
| | | { |
| | | await CreateAsync(wmsInOutStockRecordDto.Item); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | var errorMsg = $"导入失败!配置,第{wmsInOutStockRecordDto.RowIndex}行:{e.Message},终止导入"; |
| | | throw new UserFriendlyException(errorMsg); |
| | | } |
| | | } |
| | | |
| | | // 更新 |
| | | foreach (var wmsInOutStockRecordDto in wmsInOutStockRecordUpdateDtos) |
| | | { |
| | | try |
| | | { |
| | | await UpdateAsync(wmsInOutStockRecordDto.Id, wmsInOutStockRecordDto.Item); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | var errorMsg = $"导入失败!配置,第{wmsInOutStockRecordDto.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(GetWmsInOutStockRecordInput input) |
| | | { |
| | | Check.NotNull(input, nameof(input)); |
| | | |
| | | if (input.Sorting.IsNullOrWhiteSpace()) |
| | | { |
| | | input.Sorting = nameof(WmsInOutStockRecord.Sort); |
| | | } |
| | | |
| | | public async Task<(Dictionary<string, object> Sheets, string FileName)> ExportAsync(GetWmsInOutStockRecordInput input) |
| | | { |
| | | Check.NotNull(input, nameof(input)); |
| | | |
| | | if (input.Sorting.IsNullOrWhiteSpace()) |
| | | { |
| | | input.Sorting = nameof(WmsInOutStockRecord.Sort); |
| | | } |
| | | |
| | | #region 动态构造查询条件 |
| | | |
| | | |
| | | //动态构造查询条件 |
| | | var whereConditions = DynamicGetQueryParams(input); |
| | | |
| | | #endregion |
| | | |
| | | |
| | | var list = await _wmsInOutStockRecordRepository.GetListAsync(whereConditions, input.Sorting, input.MaxResultCount, input.SkipCount, includeDetails: true); |
| | | var result = ObjectMapper.Map<List<WmsInOutStockRecord>, List<WmsInOutStockRecordDto>>(list); |
| | | |
| | | var sheets = new Dictionary<string, object> |
| | | { |
| | | ["配置"] = ExportHelper.ConvertListToExportData(result), |
| | | }; |
| | | |
| | | var fileName = result.Count > 1 ? "WmsInOutStockRecord列表" : result.Count == 1 ? result[0]?.MaterialName : "WmsInOutStockRecord模版"; |
| | | return (sheets, fileName); |
| | | } |
| | | |
| | | var whereConditions = DynamicGetQueryParams(input); |
| | | |
| | | #endregion |
| | | |
| | | |
| | | var list = await wmsInOutStockRecordRepository.GetListAsync(whereConditions, input.Sorting, input.MaxResultCount, input.SkipCount, includeDetails: true); |
| | | var result = ObjectMapper.Map<List<WmsInOutStockRecord>, List<WmsInOutStockRecordDto>>(list); |
| | | |
| | | var sheets = new Dictionary<string, object> |
| | | { |
| | | ["配置"] = ExportHelper.ConvertListToExportData(result), |
| | | }; |
| | | |
| | | var fileName = result.Count > 1 ? "出入库记录列表" : result.Count == 1 ? result[0]?.Id : "WmsInOutStockRecord模版"; |
| | | return (sheets, fileName); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 校验出入库记录表,当新建或更新时 |
| | | /// 校验出入库记录,当新建或更新时 |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | protected Task CheckCreateOrUpdateDtoAsync(WmsInOutStockRecordCreateOrUpdateDtoBase input) |
| | | { |
| | | Check.NotNull(input, nameof(input)); |
| | | Check.NotNullOrWhiteSpace(input.OrderNo, "单据编号", 50); |
| | | protected Task CheckCreateOrUpdateDtoAsync(WmsInOutStockRecordCreateOrUpdateDtoBase input) |
| | | { |
| | | Check.NotNull(input, nameof(input)); |
| | | Check.NotNullOrWhiteSpace(input.OrderNo, "单据编号", 50); |
| | | Check.NotNullOrWhiteSpace(input.MaterialNo, "物料件号", 50); |
| | | Check.NotNull(input.StockType, "操作类型"); |
| | | Check.NotNullOrWhiteSpace(input.MaterialId, "物料ID", 50); |
| | | Check.NotNullOrWhiteSpace(input.TaskNo, "任务号", 50); |
| | | |
| | | return Task.CompletedTask; |
| | | } |
| | | } |
| | | |
| | | return Task.CompletedTask; |
| | | } |
| | | } |