Selaa lähdekoodia

Merge branch 'fix/push_order' of Fengwo/hotline into release

xf 5 kuukautta sitten
vanhempi
commit
211cdcc81b

+ 37 - 2
src/Hotline.Api/Controllers/TestController.cs

@@ -1,4 +1,5 @@
-using DotNetCore.CAP;
+using DocumentFormat.OpenXml.Drawing.Charts;
+using DotNetCore.CAP;
 using Hotline.Ai.Visit;
 using Hotline.Application.CallCenter;
 using Hotline.Application.ExportExcel;
@@ -26,6 +27,7 @@ using Hotline.JudicialManagement;
 using Hotline.Orders;
 using Hotline.Realtimes;
 using Hotline.Repository.SqlSugar;
+using Hotline.Repository.SqlSugar.CallCenter;
 using Hotline.Repository.SqlSugar.Ts;
 using Hotline.Settings;
 using Hotline.Settings.Hotspots;
@@ -43,6 +45,7 @@ using Hotline.Share.Enums.Order;
 using Hotline.Share.Enums.Quality;
 using Hotline.Share.Mq;
 using Hotline.Users;
+using Mapster;
 using MapsterMapper;
 using MediatR;
 using Microsoft.AspNetCore.Authorization;
@@ -53,6 +56,7 @@ using MiniExcelLibs;
 using Newtonsoft.Json;
 using SqlSugar;
 using StackExchange.Redis;
+using System.Threading;
 using XC.RSAUtil;
 using XF.Domain.Authentications;
 using XF.Domain.Cache;
@@ -129,6 +133,7 @@ public class TestController : BaseController
     //private readonly ITypedCache<List<User>> _cache;
     //private readonly ICacheManager<User> _cache;
     private readonly ICalcExpireTime _expireTime;
+    private readonly ICallNativeRepository _callNativeRepository;
 
 
     public TestController(
@@ -181,7 +186,8 @@ ICallApplication callApplication,
         IOptionsSnapshot<AppConfiguration> appOptions,
         ISystemSettingCacheManager systemSettingCacheManager,
         ICalcExpireTime expireTime
-        )
+,
+        ICallNativeRepository callNativeRepository)
     {
         _logger = logger;
         //_authorizeGenerator = authorizeGenerator;
@@ -230,6 +236,7 @@ ICallApplication callApplication,
         _appOptions = appOptions;
         _systemSettingCacheManager = systemSettingCacheManager;
         _expireTime = expireTime;
+        _callNativeRepository = callNativeRepository;
     }
 
 
@@ -1039,4 +1046,32 @@ ICallApplication callApplication,
         _capPublisher.PublishDelay(ExpiredTime - DateTime.Now.AddHours(1), EventNames.HotlineOrderAutomaticDelay, new PublishAutomaticDelayDto() { OrderId = orderId });
     }
 
+
+    /// <summary>
+    /// 根据省编号修复工单和通话记录
+    /// </summary>
+    /// <param name="ProvinceNos">省编号</param>
+    /// <returns></returns>
+    [HttpPost("push_order_call")]
+    [AllowAnonymous]
+    public async Task PushOrderCallAsync([FromBody]List<string> ProvinceNos)
+    {
+        var orders = await _orderRepository.Queryable()
+            .Where(m => ProvinceNos.Contains(m.ProvinceNo))
+            .ToListAsync();
+        foreach (var order in orders)
+        {
+            var call = await _callNativeRepository.Queryable()
+                .Where(m => m.Id == order.CallId)
+                .FirstAsync();
+            if (call == null) continue;
+            var orderDto = order.Adapt<OrderDto>();
+            await _capPublisher.PublishAsync(EventNames.HotlineCallConnectWithOrder, new PublishCallRecrodDto()
+            {
+                Order = orderDto,
+                TrCallRecordDto = call.Adapt<TrCallDto>()
+            }, cancellationToken: HttpContext.RequestAborted);
+        }
+    }
+
 }

+ 2 - 2
src/Hotline.Application/CallCenter/DefaultCallApplication.cs

@@ -526,7 +526,7 @@ public abstract class DefaultCallApplication : ICallApplication
             // 推省上
             await _capPublisher.PublishAsync(EventNames.HotlineCallConnectWithOrder, new PublishCallRecrodDto()
             {
-                Order = _orderRepository.GetAsync(orderId, cancellationToken).Adapt<OrderDto>(),
+                Order = (await _orderRepository.GetAsync(orderId, cancellationToken)).Adapt<OrderDto>(),
                 TrCallRecordDto = call.Adapt<TrCallDto>()
             }, cancellationToken: cancellationToken);
             return;
@@ -545,7 +545,7 @@ public abstract class DefaultCallApplication : ICallApplication
         // 推省上
         await _capPublisher.PublishAsync(EventNames.HotlineCallConnectWithOrder, new PublishCallRecrodDto()
         {
-            Order = _orderRepository.GetAsync(orderId, cancellationToken).Adapt<OrderDto>(),
+            Order = (await _orderRepository.GetAsync(orderId, cancellationToken)).Adapt<OrderDto>(),
             TrCallRecordDto = call.Adapt<TrCallDto>()
         }, cancellationToken: cancellationToken);
         _systemLogRepository.Add("延迟更新工单通话", orderId, $"原CallId: {callId}, 更新CallId: {call.Id}", status: 1);