将定时任务改为,发布、订阅模式的消息队列执行任务
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Channels;
|
||||
using System.Threading.Tasks;
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Core.Manager;
|
||||
@@ -24,6 +25,7 @@ using Tnb.WarehouseMgr.Entities.Attributes;
|
||||
using Tnb.WarehouseMgr.Entities.Consts;
|
||||
using Tnb.WarehouseMgr.Entities.Dto;
|
||||
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
|
||||
using Tnb.WarehouseMgr.Filters;
|
||||
using Tnb.WarehouseMgr.Interfaces;
|
||||
|
||||
namespace Tnb.WarehouseMgr
|
||||
@@ -44,13 +46,16 @@ namespace Tnb.WarehouseMgr
|
||||
private readonly IWareHouseService _wareHouseService;
|
||||
private readonly IBillRullService _billRullService;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly ChannelWriter<NotifyMessage> _channelWriter;
|
||||
public WmsEmptyInstockService(
|
||||
ISqlSugarRepository<WmsCarryH> repository,
|
||||
IRunService runService,
|
||||
IVisualDevService visualDevService,
|
||||
IWareHouseService wareHouseService,
|
||||
IUserManager userManager,
|
||||
IBillRullService billRullService)
|
||||
IBillRullService billRullService,
|
||||
ITaskMessageNotify taskMesageNotify
|
||||
)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_runService = runService;
|
||||
@@ -58,9 +63,9 @@ namespace Tnb.WarehouseMgr
|
||||
_wareHouseService = wareHouseService;
|
||||
_userManager = userManager;
|
||||
_billRullService = billRullService;
|
||||
_channelWriter = taskMesageNotify.Writer;
|
||||
OverideFuncs.CreateAsync = WmsEmptyIn;
|
||||
}
|
||||
|
||||
private async Task<dynamic> WmsEmptyIn(VisualDevModelDataCrInput input)
|
||||
{
|
||||
|
||||
@@ -159,6 +164,7 @@ namespace Tnb.WarehouseMgr
|
||||
await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput,
|
||||
it => new WmsCarryH { is_lock = 1, location_id = preTaskUpInput.CarryStartLocationId, location_code = preTaskUpInput.CarryStartLocationCode },
|
||||
it => new BasLocation { is_lock = 1 });
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -179,6 +185,12 @@ namespace Tnb.WarehouseMgr
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
//向队列写入消息
|
||||
NotifyMessage message = new() { TaskName = nameof(IWareHouseService.GenTaskExecute) };
|
||||
await _channelWriter.WriteAsync(message);
|
||||
}
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user