|
@@ -3,17 +3,21 @@ using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
+using Hotline.CallCenter.Calls;
|
|
|
+using Hotline.Orders;
|
|
|
using Hotline.Realtimes;
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
+using SqlSugar;
|
|
|
+using XF.Domain.Repository;
|
|
|
|
|
|
namespace Hotline.Application.Bigscreen
|
|
|
{
|
|
|
public class BigscreenDataShowRefreshService : BackgroundService
|
|
|
{
|
|
|
private readonly IServiceScopeFactory _serviceScopeFactory;
|
|
|
- private readonly DateTime _lastModifyTime;
|
|
|
+ private DateTime _lastModifyTime;
|
|
|
|
|
|
public BigscreenDataShowRefreshService(IServiceScopeFactory serviceScopeFactory)
|
|
|
{
|
|
@@ -32,18 +36,37 @@ namespace Hotline.Application.Bigscreen
|
|
|
{
|
|
|
using var scope = _serviceScopeFactory.CreateScope();
|
|
|
var realtimeService = scope.ServiceProvider.GetRequiredService<IRealtimeService>();
|
|
|
+ var orderRepository = scope.ServiceProvider.GetRequiredService<IOrderRepository>();
|
|
|
+ var callRepository = scope.ServiceProvider.GetRequiredService<IRepository<TrCallRecord>>();
|
|
|
|
|
|
while (!stoppingToken.IsCancellationRequested)
|
|
|
{
|
|
|
- //todo
|
|
|
- var data = new {
|
|
|
- Name = "John",
|
|
|
- Age = 20,
|
|
|
- };
|
|
|
+ var now = DateTime.Now;
|
|
|
+ var today = now.Date;
|
|
|
+ var secRange = (now - _lastModifyTime).TotalSeconds;
|
|
|
|
|
|
- //await realtimeService.BsDataShowChangedAsync(data, stoppingToken);
|
|
|
+ if (secRange >= 10)
|
|
|
+ {
|
|
|
+ //area1
|
|
|
+ var todayTotal = await orderRepository.CountAsync(d => d.CreationTime.Date == today, stoppingToken);
|
|
|
+ var todayCompleted =
|
|
|
+ await orderRepository.CountAsync(d => d.FiledTime.HasValue && d.FiledTime.Value.Date == today,
|
|
|
+ stoppingToken);
|
|
|
+ await realtimeService.BsDataShowChanged1Async(new { todayTotal, todayCompleted }, stoppingToken);
|
|
|
|
|
|
- await Task.Delay(30000, stoppingToken);
|
|
|
+ //area3
|
|
|
+ // var calls = callRepository.Queryable()
|
|
|
+ // .OrderByDescending(d=>d.CreationTime)
|
|
|
+ // .Take(20)
|
|
|
+ // .Select(d=>new {d.})
|
|
|
+
|
|
|
+ //area8
|
|
|
+
|
|
|
+
|
|
|
+ _lastModifyTime = DateTime.Now;
|
|
|
+ }
|
|
|
+
|
|
|
+ await Task.Delay(10000, stoppingToken);
|
|
|
}
|
|
|
}
|
|
|
}
|