| | |
| | | using Volo.Abp.Data; |
| | | using Volo.Abp.ObjectExtending; |
| | | using Volo.Abp.ObjectMapping; |
| | | using CmsQueryExtensions.Entitys; |
| | | |
| | | namespace CMS.Plugin.PipeLineLems.Application.Implements; |
| | | |
| | |
| | | /// </summary> |
| | | public class CallMaterialOrderAppService : CMSPluginAppService, ICallMaterialOrderAppService |
| | | { |
| | | private readonly ICallMaterialOrderRepository callMaterialOrderRepository; |
| | | private readonly ICallMaterialOrderRepository _callMaterialOrderRepository; |
| | | |
| | | /// <summary> |
| | | /// Initializes a new instance of the <see cref="CallMaterialOrderAppService"/> class. |
| | | /// </summary> |
| | | /// <param name="CallMaterialOrderRepository">The task job repository.</param> |
| | | public CallMaterialOrderAppService(ICallMaterialOrderRepository _CallMaterialOrderRepository) |
| | | public CallMaterialOrderAppService(ICallMaterialOrderRepository callMaterialOrderRepository) |
| | | { |
| | | callMaterialOrderRepository = _CallMaterialOrderRepository; |
| | | _callMaterialOrderRepository = callMaterialOrderRepository; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public virtual async Task<CallMaterialOrderDto> GetAsync(Guid id) |
| | | { |
| | | return ObjectMapper.Map<CallMaterialOrder, CallMaterialOrderDto>(await callMaterialOrderRepository.GetAsync(id)); |
| | | return ObjectMapper.Map<CallMaterialOrder, CallMaterialOrderDto>(await _callMaterialOrderRepository.GetAsync(id)); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | |
| | | #endregion |
| | | |
| | | var count = await callMaterialOrderRepository.GetCountAsync(whereConditions); |
| | | var list = await callMaterialOrderRepository.GetListAsync(whereConditions, input.Sorting, input.MaxResultCount, input.SkipCount); |
| | | 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)); |
| | | } |
| | |
| | | { |
| | | await CheckCreateOrUpdateDtoAsync(input); |
| | | |
| | | var exist = await callMaterialOrderRepository.NameExistAsync(input.DataIdentifier); |
| | | var exist = await _callMaterialOrderRepository.NameExistAsync(input.DataIdentifier); |
| | | if (exist) |
| | | { |
| | | throw new UserFriendlyException(L[CMSPluginDomainErrorCodes.NameAlreadyExists, input.DataIdentifier]); |
| | | } |
| | | |
| | | var maxSort = await callMaterialOrderRepository.GetMaxSortAsync(); |
| | | 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); |
| | | insertObj.CreatorName = input.CreatorName;//创建人 |
| | | await _callMaterialOrderRepository.InsertAsync(insertObj); |
| | | |
| | | //if (input.Sort.HasValue && insertObj.Sort != maxSort) |
| | | //{ |
| | |
| | | { |
| | | await CheckCreateOrUpdateDtoAsync(input); |
| | | |
| | | var updateObj = await callMaterialOrderRepository.GetAsync(id); |
| | | var exist = await callMaterialOrderRepository.NameExistAsync(input.DataIdentifier, updateObj.Id); |
| | | 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.DataIdentifier = input.DataIdentifier; |
| | | updateObj.MaterialMode = input.MaterialMode; |
| | | updateObj.MaterialBatch = input.MaterialBatch; |
| | | updateObj.CallMaterialStatus = input.CallMaterialStatus; |
| | | updateObj.Quantity = input.Quantity; |
| | | updateObj.WmsRetResult = input.WmsRetResult; |
| | |
| | | updateObj.Remark = input.Remark; |
| | | |
| | | |
| | | await callMaterialOrderRepository.UpdateAsync(updateObj); |
| | | updateObj.LastModifierName = input.LastModifierName;//修改人 |
| | | |
| | | await _callMaterialOrderRepository.UpdateAsync(updateObj); |
| | | |
| | | return ObjectMapper.Map<CallMaterialOrder, CallMaterialOrderDto>(updateObj); |
| | | } |
| | |
| | | /// </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, MyCurrentUser myCurrentUser) |
| | | { |
| | | //var callMaterialOrders = new List<CallMaterialOrder>(); |
| | | //if (ids != null) |
| | | //{ |
| | | // var sort = await callMaterialOrderRepository.GetMaxSortAsync(); |
| | | // var sort = await _callMaterialOrderRepository.GetMaxSortAsync(); |
| | | // foreach (var id in ids) |
| | | // { |
| | | // var CallMaterialOrder = await callMaterialOrderRepository.FindAsync(id); |
| | | // var CallMaterialOrder = await _callMaterialOrderRepository.FindAsync(id); |
| | | // if (CallMaterialOrder != null) |
| | | // { |
| | | // var name = CallMaterialOrder.Name + CallMaterialOrderConsts.CloneTag; |
| | | // var notExist = false; |
| | | // while (!notExist) |
| | | // { |
| | | // var exist = await callMaterialOrderRepository.NameExistAsync(name); |
| | | // var exist = await _callMaterialOrderRepository.NameExistAsync(name); |
| | | // if (exist || callMaterialOrders.Any(x => x.Name == name)) |
| | | // { |
| | | // name += CallMaterialOrderConsts.CloneTag; |
| | |
| | | // notExist = true; |
| | | // } |
| | | |
| | | // //CallMaterialOrder = await callMaterialOrderRepository.InsertAsync(CallMaterialOrder.Clone(GuidGenerator.Create(), name, sort++)); |
| | | // //CallMaterialOrder = await _callMaterialOrderRepository.InsertAsync(CallMaterialOrder.Clone(GuidGenerator.Create(), name, sort++)); |
| | | // callMaterialOrders.Add(CallMaterialOrder); |
| | | // } |
| | | // } |
| | |
| | | /// <returns></returns> |
| | | public virtual Task DeleteAsync(Guid id) |
| | | { |
| | | return callMaterialOrderRepository.DeleteAsync(id); |
| | | return _callMaterialOrderRepository.DeleteAsync(id); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | /// <param name="ids"></param> |
| | | /// <returns></returns> |
| | | public async Task DeleteManyAsync(IEnumerable<Guid> ids) |
| | | public async Task DeleteManyAsync(IEnumerable<Guid> ids, MyCurrentUser myCurrentUser) |
| | | { |
| | | foreach (var id in ids) |
| | | { |
| | | await DeleteAsync(id); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 物理删除叫料单表 |
| | | /// </summary> |
| | | /// <param name="id">主键ID</param> |
| | | /// <param name="cancellationToken"></param> |
| | | /// <returns></returns> |
| | | public virtual async Task DeletePermanentlyAsync(Guid id, MyCurrentUser myCurrentUser, CancellationToken cancellationToken = default) |
| | | { |
| | | _callMaterialOrderRepository.DeletePermanentlyAsync(id); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 批量物理删除叫料单表(直接删除,不软删除) |
| | | /// </summary> |
| | | /// <param name="ids">要删除的主键ID列表</param> |
| | | /// <param name="cancellationToken"></param> |
| | | /// <returns></returns> |
| | | public virtual async Task BatchDeletePermanentlyAsync(IEnumerable<Guid> ids, MyCurrentUser myCurrentUser, CancellationToken cancellationToken = default) |
| | | { |
| | | _callMaterialOrderRepository.BatchDeletePermanentlyAsync(ids); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public virtual async Task AdjustSortAsync(Guid id, int sort) |
| | | { |
| | | var list = await callMaterialOrderRepository.GetListAsync(null, nameof(CallMaterialOrder.Sort)); |
| | | var list = await _callMaterialOrderRepository.GetListAsync(null, nameof(CallMaterialOrder.Sort)); |
| | | if (list != null && list.Any()) |
| | | { |
| | | var initSort = 1; |
| | |
| | | } |
| | | } |
| | | |
| | | await callMaterialOrderRepository.UpdateManyAsync(list); |
| | | await _callMaterialOrderRepository.UpdateManyAsync(list); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="UserFriendlyException"></exception> |
| | | public async Task ImportAsync(CallMaterialOrdersImportModel input) |
| | | public async Task ImportAsync(CallMaterialOrdersImportModel input, MyCurrentUser myCurrentUser) |
| | | { |
| | | Check.NotNull(input, nameof(input)); |
| | | |
| | |
| | | throw new UserFriendlyException(errorMsg); |
| | | } |
| | | |
| | | var oldCallMaterialOrder = await callMaterialOrderRepository.FindByNameAsync(impItem.DataIdentifier); |
| | | var oldCallMaterialOrder = await _callMaterialOrderRepository.FindByNameAsync(impItem.DataIdentifier); |
| | | if (oldCallMaterialOrder != null) |
| | | { |
| | | var callMaterialOrderUpdateDto = new CallMaterialOrderUpdateDto |
| | | { |
| | | DataIdentifier = impItem.DataIdentifier, |
| | | MaterialMode = impItem.MaterialMode, |
| | | MaterialBatch = impItem.MaterialBatch, |
| | | CallMaterialStatus = impItem.CallMaterialStatus, |
| | | Quantity = impItem.Quantity, |
| | | WmsRetResult = impItem.WmsRetResult, |
| | |
| | | { |
| | | DataIdentifier = impItem.DataIdentifier, |
| | | MaterialMode = impItem.MaterialMode, |
| | | MaterialBatch = impItem.MaterialBatch, |
| | | CallMaterialStatus = impItem.CallMaterialStatus, |
| | | Quantity = impItem.Quantity, |
| | | WmsRetResult = impItem.WmsRetResult, |
| | |
| | | { |
| | | try |
| | | { |
| | | callMaterialOrderDto.Item.CreatorName = myCurrentUser.UserAccount;//创建人 |
| | | await CreateAsync(callMaterialOrderDto.Item); |
| | | } |
| | | catch (Exception e) |
| | |
| | | { |
| | | try |
| | | { |
| | | callMaterialOrderDto.Item.LastModifierName = myCurrentUser.UserAccount;//修改人 |
| | | await UpdateAsync(callMaterialOrderDto.Id, callMaterialOrderDto.Item); |
| | | } |
| | | catch (Exception e) |
| | |
| | | #endregion |
| | | |
| | | |
| | | var list = await callMaterialOrderRepository.GetListAsync(whereConditions, input.Sorting, input.MaxResultCount, input.SkipCount, includeDetails: true); |
| | | 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> |
| | |
| | | |
| | | return Task.CompletedTask; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据条件获取叫料单表列表 |
| | | /// </summary> |
| | | /// <param name="whereConditions"></param> |
| | | /// <param name="cancellationToken"></param> |
| | | /// <returns></returns> |
| | | public async Task<List<CallMaterialOrder>> GetListByFilterAsync(Expression<Func<CallMaterialOrder, bool>> whereConditions, CancellationToken cancellationToken = default) |
| | | { |
| | | return await _callMaterialOrderRepository.GetListByFilterAsync(whereConditions); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据条件获取单个叫料单表 |
| | | /// </summary> |
| | | /// <param name="whereConditions"></param> |
| | | /// <param name="isMultipleThrowException">是否查询出多条就报错</param> |
| | | /// <param name="cancellationToken"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="UserFriendlyException"></exception> |
| | | public async Task<CallMaterialOrder> GetSingleByFilterAsync(Expression<Func<CallMaterialOrder, bool>> whereConditions, bool isMultipleThrowException = false, CancellationToken cancellationToken = default) |
| | | { |
| | | return await _callMaterialOrderRepository.GetSingleByFilterAsync(whereConditions, isMultipleThrowException); |
| | | } |
| | | } |