| | |
| | | using CMS.Plugin.HIAWms.Application.Contracts.Dtos.OutStockDto; |
| | | using CMS.Plugin.HIAWms.Application.Contracts.Dtos.WmsInOutStockOrder; |
| | | using CMS.Plugin.HIAWms.Application.Contracts.Services; |
| | | using CMS.Plugin.HIAWms.Domain.Shared.Enums; |
| | | using CMS.Plugin.HIAWms.Domain.WmsMaterials; |
| | | using CMS.Plugin.HIAWms.Domain.WmsTask; |
| | | using Microsoft.Extensions.DependencyInjection; |
| | |
| | | { |
| | | private readonly IWmsTaskRepository _wmsTaskRepository; |
| | | private readonly IWmsMaterialRepository _wmsMaterialRepository; |
| | | private readonly IWmsCommonAppService _wmsCommonAppService; |
| | | private readonly IWmsInOutStockOrderAppService _wmsInOutStockOrderAppService; |
| | | private readonly IWmsOutStockAppService _wmsOutStockOrderAppService; |
| | | private readonly IServiceProvider _serviceProvider; |
| | |
| | | IWmsInOutStockOrderAppService wmsInOutStockOrderAppService, |
| | | IWmsOutStockAppService wmsOutStockOrderAppService |
| | | , |
| | | IServiceProvider serviceProvider) |
| | | IServiceProvider serviceProvider, |
| | | IWmsCommonAppService wmsCommonAppService) |
| | | { |
| | | _wmsTaskRepository = wmsTaskRepository; |
| | | _wmsMaterialRepository = wmsMaterialRepository; |
| | | _wmsInOutStockOrderAppService = wmsInOutStockOrderAppService; |
| | | _wmsOutStockOrderAppService = wmsOutStockOrderAppService; |
| | | _serviceProvider = serviceProvider; |
| | | _wmsCommonAppService = wmsCommonAppService; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | throw new UserFriendlyException("叫料参数错误"); |
| | | } |
| | | |
| | | //using var scope = _serviceProvider.CreateScope(); |
| | | //var unitOfWorkManager = scope.ServiceProvider.GetRequiredService<IUnitOfWorkManager>(); |
| | | //using var uow = unitOfWorkManager.Begin(requiresNew: true); |
| | | using var scope = _serviceProvider.CreateScope(); |
| | | var unitOfWorkManager = scope.ServiceProvider.GetRequiredService<IUnitOfWorkManager>(); |
| | | using var uow = unitOfWorkManager.Begin(requiresNew: true); |
| | | |
| | | var result = new List<CallMaterialOutput>(); |
| | | foreach (var item in input) |
| | |
| | | OrderStatus = Domain.Shared.Enums.OrderStatusEnum.Executing, |
| | | OperateTime = DateTime.Now, |
| | | DistributeNumber = 1, |
| | | |
| | | }; |
| | | var createResult = await _wmsInOutStockOrderAppService.CreateAsync(createOrderInput); |
| | | |
| | |
| | | MaterialNo = materiaL.MaterialNo, |
| | | MaterialName = materiaL.MaterialName, |
| | | DataIdentifier = item.DataIdentifier, |
| | | IgnoreOrder = true, |
| | | OrderType = createResult.OrderType, |
| | | Priority = createResult.Priority |
| | | }, |
| | | }; |
| | | var callresult = await _wmsOutStockOrderAppService.CallMaterialAsync(callInput); |
| | | result.AddRange(callresult); |
| | | } |
| | | |
| | | //await uow.SaveChangesAsync(); |
| | | await uow.SaveChangesAsync(); |
| | | |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// LMes出库 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public async Task LMesOutStockAsync(ReduceInput input) |
| | | { |
| | | if (input == null) |
| | | { |
| | | throw new UserFriendlyException("出库参数错误"); |
| | | } |
| | | |
| | | using var scope = _serviceProvider.CreateScope(); |
| | | var unitOfWorkManager = scope.ServiceProvider.GetRequiredService<IUnitOfWorkManager>(); |
| | | using var uow = unitOfWorkManager.Begin(requiresNew: true); |
| | | if (string.IsNullOrEmpty(input.MaterialMode)) |
| | | { |
| | | throw new UserFriendlyException("出库型号不能为空"); |
| | | } |
| | | var reduceInput = new ReduceStockInput |
| | | { |
| | | MaterialModel = input.MaterialMode, |
| | | StockNumber = input.Quantity, |
| | | PlaceNo = input.PlaceNo, |
| | | }; |
| | | await _wmsCommonAppService.ReduceMaterialStockAsync(reduceInput); |
| | | |
| | | await uow.SaveChangesAsync(); |
| | | } |
| | | } |
| | | } |