| | |
| | | using Volo.Abp.Data; |
| | | using Volo.Abp.ObjectExtending; |
| | | using Volo.Abp.ObjectMapping; |
| | | using CMS.Plugin.HIAWms.Domain.WmsMaterials; |
| | | |
| | | namespace CMS.Plugin.HIAWms.Application.Implements; |
| | | |
| | |
| | | public class WmsInOutStockOrderAppService : CMSPluginAppService, IWmsInOutStockOrderAppService |
| | | { |
| | | private readonly IWmsInOutStockOrderRepository wmsInOutStockOrderRepository; |
| | | private readonly IWmsMaterialRepository _wmsMaterialRepository; |
| | | |
| | | /// <summary> |
| | | /// Initializes a new instance of the <see cref="WmsInOutStockOrderAppService"/> class. |
| | | /// </summary> |
| | | /// <param name="WmsInOutStockOrderRepository">The task job repository.</param> |
| | | public WmsInOutStockOrderAppService(IWmsInOutStockOrderRepository _WmsInOutStockOrderRepository) |
| | | public WmsInOutStockOrderAppService(IWmsInOutStockOrderRepository _WmsInOutStockOrderRepository, IWmsMaterialRepository wmsMaterialRepository) |
| | | { |
| | | wmsInOutStockOrderRepository = _WmsInOutStockOrderRepository; |
| | | _wmsMaterialRepository = wmsMaterialRepository; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | await CheckCreateOrUpdateDtoAsync(input); |
| | | |
| | | var material = await _wmsMaterialRepository.FindByNameAsync(input.MaterialNo); |
| | | if (material == null) |
| | | { |
| | | throw new UserFriendlyException("物料信息不存在"); |
| | | } |
| | | |
| | | var exist = await wmsInOutStockOrderRepository.NameExistAsync(input.OrderNo); |
| | | if (exist) |
| | | { |
| | |
| | | var maxSort = await wmsInOutStockOrderRepository.GetMaxSortAsync(); |
| | | var sort = input.Sort ?? maxSort; |
| | | |
| | | var maxPriority = await wmsInOutStockOrderRepository.GetMaxPriorityAsync(); |
| | | var priority = input.Priority > 0 ? input.Priority : maxPriority; |
| | | |
| | | var insertObj = ObjectMapper.Map<WmsInOutStockOrderCreateDto, WmsInOutStockOrder>(input); |
| | | insertObj.MaterialName = material.MaterialName; |
| | | insertObj.MaterialModel = material.MaterialModel; |
| | | insertObj.OrderStatus = Domain.Shared.Enums.OrderStatusEnum.NoStart; |
| | | |
| | | var type = "RK-"; |
| | | insertObj.StockType = Domain.Shared.Enums.StockTypeEnum.InBound; |
| | | if (input.OrderType == Domain.Shared.Enums.OrderTypeEnum.PRODUCTCALL || input.OrderType == Domain.Shared.Enums.OrderTypeEnum.PERSONOT) |
| | | { |
| | | type = "CK-"; |
| | | insertObj.StockType = Domain.Shared.Enums.StockTypeEnum.OutBound; |
| | | } |
| | | insertObj.OrderNo = type + DateTime.Now.ToString("yyyyMMddHHmmssfff"); |
| | | insertObj.Sort = sort; |
| | | insertObj.Priority = priority; |
| | | input.MapExtraPropertiesTo(insertObj, MappingPropertyDefinitionChecks.None); |
| | | |
| | | await wmsInOutStockOrderRepository.InsertAsync(insertObj); |
| | |
| | | /// </summary> |
| | | /// <param name="id"></param> |
| | | /// <returns></returns> |
| | | public virtual Task DeleteAsync(Guid id) |
| | | public virtual async Task DeleteAsync(Guid id) |
| | | { |
| | | return wmsInOutStockOrderRepository.DeleteAsync(id); |
| | | var order = await wmsInOutStockOrderRepository.GetAsync(id); |
| | | if(order != null && order.OrderStatus != Domain.Shared.Enums.OrderStatusEnum.NoStart) |
| | | { |
| | | throw new UserFriendlyException("只能删除未开始的单据"); |
| | | } |
| | | await wmsInOutStockOrderRepository.DeleteAsync(id); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | protected Task CheckCreateOrUpdateDtoAsync(WmsInOutStockOrderCreateOrUpdateDtoBase input) |
| | | { |
| | | Check.NotNull(input, nameof(input)); |
| | | Check.NotNullOrWhiteSpace(input.OrderNo, "单据编号", 50); |
| | | Check.NotNull(input.OrderStatus, "单据状态"); |
| | | Check.NotNullOrWhiteSpace(input.MaterialNo, "物料件号", 50); |
| | | Check.NotNullOrWhiteSpace(input.MaterialNo, "物料编号", 50); |
| | | Check.NotNullOrWhiteSpace(input.MaterialBatch, "批次号", 50); |
| | | Check.NotNull(input.OrderType, "单据类型"); |
| | | Check.NotNull(input.StockType, "操作类型(枚举值)"); |
| | | Check.NotNull(input.StockType, "操作类型"); |
| | | Check.NotNull(input.MaterialNumber, "单据数量"); |
| | | Check.NotNull(input.DistributeNumber, "下发数量"); |
| | | Check.NotNull(input.CompleteNumber, "完成数量"); |
| | | Check.NotNull(input.Priority, "优先级"); |
| | | |
| | | return Task.CompletedTask; |
| | | } |