From edca9fd026f88d4edad94b528694d95d62246c67 Mon Sep 17 00:00:00 2001 From: zs <zhousong@weben-smart.com> Date: 周五, 16 5月 2025 16:19:33 +0800 Subject: [PATCH] 添加记录 --- HIAWms/server/src/CMS.Plugin.HIAWms.Application/Implements/LMesOperateAppService.cs | 51 +++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 45 insertions(+), 6 deletions(-) diff --git a/HIAWms/server/src/CMS.Plugin.HIAWms.Application/Implements/LMesOperateAppService.cs b/HIAWms/server/src/CMS.Plugin.HIAWms.Application/Implements/LMesOperateAppService.cs index f2586a5..4549ca4 100644 --- a/HIAWms/server/src/CMS.Plugin.HIAWms.Application/Implements/LMesOperateAppService.cs +++ b/HIAWms/server/src/CMS.Plugin.HIAWms.Application/Implements/LMesOperateAppService.cs @@ -2,6 +2,7 @@ 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; @@ -22,6 +23,7 @@ { private readonly IWmsTaskRepository _wmsTaskRepository; private readonly IWmsMaterialRepository _wmsMaterialRepository; + private readonly IWmsCommonAppService _wmsCommonAppService; private readonly IWmsInOutStockOrderAppService _wmsInOutStockOrderAppService; private readonly IWmsOutStockAppService _wmsOutStockOrderAppService; private readonly IServiceProvider _serviceProvider; @@ -31,13 +33,15 @@ IWmsInOutStockOrderAppService wmsInOutStockOrderAppService, IWmsOutStockAppService wmsOutStockOrderAppService , - IServiceProvider serviceProvider) + IServiceProvider serviceProvider, + IWmsCommonAppService wmsCommonAppService) { _wmsTaskRepository = wmsTaskRepository; _wmsMaterialRepository = wmsMaterialRepository; _wmsInOutStockOrderAppService = wmsInOutStockOrderAppService; _wmsOutStockOrderAppService = wmsOutStockOrderAppService; _serviceProvider = serviceProvider; + _wmsCommonAppService = wmsCommonAppService; } /// <summary> @@ -53,9 +57,9 @@ 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) @@ -85,7 +89,10 @@ MaterialName = materiaL.MaterialName, MaterialModel = item.MaterialMode, MaterialNumber = 1, - MaterialBatch = item.MaterialMode + MaterialBatch = item.MaterialMode, + OrderStatus = Domain.Shared.Enums.OrderStatusEnum.Executing, + OperateTime = DateTime.Now, + DistributeNumber = 1, }; var createResult = await _wmsInOutStockOrderAppService.CreateAsync(createOrderInput); @@ -100,15 +107,47 @@ 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(); + } } } -- Gitblit v1.9.3