|
|
@ -4,11 +4,15 @@ using System.Linq; |
|
|
|
using System.Linq.Dynamic.Core; |
|
|
|
using System.Text.Json; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using EFCore.BulkExtensions; |
|
|
|
using Magicodes.ExporterAndImporter.Core.Extension; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using Microsoft.AspNetCore.SignalR; |
|
|
|
using Microsoft.EntityFrameworkCore; |
|
|
|
using Microsoft.Extensions.Configuration; |
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
using Omu.ValueInjecter; |
|
|
|
using SettleAccount.Job.SignalR; |
|
|
|
using Volo.Abp.Application.Services; |
|
|
|
using Volo.Abp.DependencyInjection; |
|
|
|
using Win.Sfs.SettleAccount.Entities.BQ.Vmi; |
|
|
@ -130,3 +134,40 @@ public class VmiAsyncBalanceService : ApplicationService, IJobService, ITransien |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 消息表定时清理
|
|
|
|
/// </summary>
|
|
|
|
public class VmiAsyncMessageService : Controller, IApplicationService, IJobService, ITransientDependency |
|
|
|
{ |
|
|
|
private readonly IServiceProvider _serviceProvider; |
|
|
|
|
|
|
|
public VmiAsyncMessageService(IServiceProvider serviceProvider) |
|
|
|
{ |
|
|
|
this._serviceProvider = serviceProvider; |
|
|
|
} |
|
|
|
|
|
|
|
[NonAction] |
|
|
|
public Task Invoke(IServiceProvider serviceProvider) |
|
|
|
{ |
|
|
|
using var scope = serviceProvider.CreateScope(); |
|
|
|
var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>(); |
|
|
|
db.Set<VmiMessage>().Where(o => o.isConsumed).BatchDelete(); |
|
|
|
var count = db.Set<VmiMessage>().Where(o => !o.isConsumed).Count(); |
|
|
|
scope.ServiceProvider.GetService<IHubContext<PageHub>>().Clients.All.ServerToClient("VmiBalance", count.ToString(), ""); |
|
|
|
return Task.CompletedTask; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 未处理消息数量
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost] |
|
|
|
public int GetMessageCount() |
|
|
|
{ |
|
|
|
using var scope = this._serviceProvider.CreateScope(); |
|
|
|
var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>(); |
|
|
|
var count = db.Set<VmiMessage>().Where(o => !o.isConsumed).Count(); |
|
|
|
return count; |
|
|
|
} |
|
|
|
} |
|
|
|