| | |
| | | using Volo.Abp.Data; |
| | | using Volo.Abp.ObjectExtending; |
| | | using Volo.Abp.ObjectMapping; |
| | | using CmsQueryExtensions.Entitys; |
| | | |
| | | namespace CMS.Plugin.PipeLineLems.Application.Implements; |
| | | |
| | |
| | | /// </summary> |
| | | public class CallMaterialOrderRecordAppService : CMSPluginAppService, ICallMaterialOrderRecordAppService |
| | | { |
| | | private readonly ICallMaterialOrderRecordRepository callMaterialOrderRecordRepository; |
| | | private readonly ICallMaterialOrderRecordRepository _callMaterialOrderRecordRepository; |
| | | |
| | | /// <summary> |
| | | /// Initializes a new instance of the <see cref="CallMaterialOrderRecordAppService"/> class. |
| | | /// </summary> |
| | | /// <param name="CallMaterialOrderRecordRepository">The task job repository.</param> |
| | | public CallMaterialOrderRecordAppService(ICallMaterialOrderRecordRepository _CallMaterialOrderRecordRepository) |
| | | public CallMaterialOrderRecordAppService(ICallMaterialOrderRecordRepository callMaterialOrderRecordRepository) |
| | | { |
| | | callMaterialOrderRecordRepository = _CallMaterialOrderRecordRepository; |
| | | _callMaterialOrderRecordRepository = callMaterialOrderRecordRepository; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public virtual async Task<CallMaterialOrderRecordDto> GetAsync(Guid id) |
| | | { |
| | | return ObjectMapper.Map<CallMaterialOrderRecord, CallMaterialOrderRecordDto>(await callMaterialOrderRecordRepository.GetAsync(id)); |
| | | return ObjectMapper.Map<CallMaterialOrderRecord, CallMaterialOrderRecordDto>(await _callMaterialOrderRecordRepository.GetAsync(id)); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | |
| | | #endregion |
| | | |
| | | var count = await callMaterialOrderRecordRepository.GetCountAsync(whereConditions); |
| | | var list = await callMaterialOrderRecordRepository.GetListAsync(whereConditions, input.Sorting, input.MaxResultCount, input.SkipCount); |
| | | var count = await _callMaterialOrderRecordRepository.GetCountAsync(whereConditions); |
| | | var list = await _callMaterialOrderRecordRepository.GetListAsync(whereConditions, input.Sorting, input.MaxResultCount, input.SkipCount); |
| | | |
| | | return new PagedResultDto<CallMaterialOrderRecordDto>(count, ObjectMapper.Map<List<CallMaterialOrderRecord>, List<CallMaterialOrderRecordDto>>(list)); |
| | | } |
| | |
| | | { |
| | | await CheckCreateOrUpdateDtoAsync(input); |
| | | |
| | | var exist = await callMaterialOrderRecordRepository.NameExistAsync(input.DataIdentifier); |
| | | var exist = await _callMaterialOrderRecordRepository.NameExistAsync(input.DataIdentifier); |
| | | if (exist) |
| | | { |
| | | throw new UserFriendlyException(L[CMSPluginDomainErrorCodes.NameAlreadyExists, input.DataIdentifier]); |
| | | } |
| | | |
| | | var maxSort = await callMaterialOrderRecordRepository.GetMaxSortAsync(); |
| | | var maxSort = await _callMaterialOrderRecordRepository.GetMaxSortAsync(); |
| | | var sort = input.Sort ?? maxSort; |
| | | |
| | | var insertObj = ObjectMapper.Map<CallMaterialOrderRecordCreateDto, CallMaterialOrderRecord>(input); |
| | | insertObj.Sort = sort; |
| | | input.MapExtraPropertiesTo(insertObj, MappingPropertyDefinitionChecks.None); |
| | | |
| | | await callMaterialOrderRecordRepository.InsertAsync(insertObj); |
| | | insertObj.CreatorName = input.CreatorName;//创建人 |
| | | await _callMaterialOrderRecordRepository.InsertAsync(insertObj); |
| | | |
| | | //if (input.Sort.HasValue && insertObj.Sort != maxSort) |
| | | //{ |
| | |
| | | { |
| | | await CheckCreateOrUpdateDtoAsync(input); |
| | | |
| | | var updateObj = await callMaterialOrderRecordRepository.GetAsync(id); |
| | | var exist = await callMaterialOrderRecordRepository.NameExistAsync(input.DataIdentifier, updateObj.Id); |
| | | var updateObj = await _callMaterialOrderRecordRepository.GetAsync(id); |
| | | var exist = await _callMaterialOrderRecordRepository.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 callMaterialOrderRecordRepository.UpdateAsync(updateObj); |
| | | |
| | | |
| | | await _callMaterialOrderRecordRepository.UpdateAsync(updateObj); |
| | | |
| | | return ObjectMapper.Map<CallMaterialOrderRecord, CallMaterialOrderRecordDto>(updateObj); |
| | | } |
| | |
| | | /// </summary> |
| | | /// <param name="ids"></param> |
| | | /// <returns></returns> |
| | | public async Task<List<CallMaterialOrderRecordDto>> CloneAsync(IEnumerable<Guid> ids) |
| | | public async Task<List<CallMaterialOrderRecordDto>> CloneAsync(IEnumerable<Guid> ids, MyCurrentUser myCurrentUser) |
| | | { |
| | | //var callMaterialOrderRecords = new List<CallMaterialOrderRecord>(); |
| | | //if (ids != null) |
| | | //{ |
| | | // var sort = await callMaterialOrderRecordRepository.GetMaxSortAsync(); |
| | | // var sort = await _callMaterialOrderRecordRepository.GetMaxSortAsync(); |
| | | // foreach (var id in ids) |
| | | // { |
| | | // var CallMaterialOrderRecord = await callMaterialOrderRecordRepository.FindAsync(id); |
| | | // var CallMaterialOrderRecord = await _callMaterialOrderRecordRepository.FindAsync(id); |
| | | // if (CallMaterialOrderRecord != null) |
| | | // { |
| | | // var name = CallMaterialOrderRecord.Name + CallMaterialOrderRecordConsts.CloneTag; |
| | | // var notExist = false; |
| | | // while (!notExist) |
| | | // { |
| | | // var exist = await callMaterialOrderRecordRepository.NameExistAsync(name); |
| | | // var exist = await _callMaterialOrderRecordRepository.NameExistAsync(name); |
| | | // if (exist || callMaterialOrderRecords.Any(x => x.Name == name)) |
| | | // { |
| | | // name += CallMaterialOrderRecordConsts.CloneTag; |
| | |
| | | // notExist = true; |
| | | // } |
| | | |
| | | // //CallMaterialOrderRecord = await callMaterialOrderRecordRepository.InsertAsync(CallMaterialOrderRecord.Clone(GuidGenerator.Create(), name, sort++)); |
| | | // //CallMaterialOrderRecord = await _callMaterialOrderRecordRepository.InsertAsync(CallMaterialOrderRecord.Clone(GuidGenerator.Create(), name, sort++)); |
| | | // callMaterialOrderRecords.Add(CallMaterialOrderRecord); |
| | | // } |
| | | // } |
| | |
| | | /// <returns></returns> |
| | | public virtual Task DeleteAsync(Guid id) |
| | | { |
| | | return callMaterialOrderRecordRepository.DeleteAsync(id); |
| | | return _callMaterialOrderRecordRepository.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) |
| | | { |
| | | _callMaterialOrderRecordRepository.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) |
| | | { |
| | | _callMaterialOrderRecordRepository.BatchDeletePermanentlyAsync(ids); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public virtual async Task AdjustSortAsync(Guid id, int sort) |
| | | { |
| | | var list = await callMaterialOrderRecordRepository.GetListAsync(null, nameof(CallMaterialOrderRecord.Sort)); |
| | | var list = await _callMaterialOrderRecordRepository.GetListAsync(null, nameof(CallMaterialOrderRecord.Sort)); |
| | | if (list != null && list.Any()) |
| | | { |
| | | var initSort = 1; |
| | |
| | | } |
| | | } |
| | | |
| | | await callMaterialOrderRecordRepository.UpdateManyAsync(list); |
| | | await _callMaterialOrderRecordRepository.UpdateManyAsync(list); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="UserFriendlyException"></exception> |
| | | public async Task ImportAsync(CallMaterialOrderRecordsImportModel input) |
| | | public async Task ImportAsync(CallMaterialOrderRecordsImportModel input, MyCurrentUser myCurrentUser) |
| | | { |
| | | Check.NotNull(input, nameof(input)); |
| | | |
| | |
| | | throw new UserFriendlyException(errorMsg); |
| | | } |
| | | |
| | | var oldCallMaterialOrderRecord = await callMaterialOrderRecordRepository.FindByNameAsync(impItem.DataIdentifier); |
| | | var oldCallMaterialOrderRecord = await _callMaterialOrderRecordRepository.FindByNameAsync(impItem.DataIdentifier); |
| | | if (oldCallMaterialOrderRecord != null) |
| | | { |
| | | var callMaterialOrderRecordUpdateDto = new CallMaterialOrderRecordUpdateDto |
| | | { |
| | | 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 |
| | | { |
| | | callMaterialOrderRecordDto.Item.CreatorName = myCurrentUser.UserAccount;//创建人 |
| | | await CreateAsync(callMaterialOrderRecordDto.Item); |
| | | } |
| | | catch (Exception e) |
| | |
| | | { |
| | | try |
| | | { |
| | | callMaterialOrderRecordDto.Item.LastModifierName = myCurrentUser.UserAccount;//修改人 |
| | | await UpdateAsync(callMaterialOrderRecordDto.Id, callMaterialOrderRecordDto.Item); |
| | | } |
| | | catch (Exception e) |
| | |
| | | #endregion |
| | | |
| | | |
| | | var list = await callMaterialOrderRecordRepository.GetListAsync(whereConditions, input.Sorting, input.MaxResultCount, input.SkipCount, includeDetails: true); |
| | | var list = await _callMaterialOrderRecordRepository.GetListAsync(whereConditions, input.Sorting, input.MaxResultCount, input.SkipCount, includeDetails: true); |
| | | var result = ObjectMapper.Map<List<CallMaterialOrderRecord>, List<CallMaterialOrderRecordDto>>(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<CallMaterialOrderRecord>> GetListByFilterAsync(Expression<Func<CallMaterialOrderRecord, bool>> whereConditions, CancellationToken cancellationToken = default) |
| | | { |
| | | return await _callMaterialOrderRecordRepository.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<CallMaterialOrderRecord> GetSingleByFilterAsync(Expression<Func<CallMaterialOrderRecord, bool>> whereConditions, bool isMultipleThrowException = false, CancellationToken cancellationToken = default) |
| | | { |
| | | return await _callMaterialOrderRecordRepository.GetSingleByFilterAsync(whereConditions, isMultipleThrowException); |
| | | } |
| | | } |