Jelajahi Sumber

hotfix: repblish

xf 8 bulan lalu
induk
melakukan
8c7f2ea377
1 mengubah file dengan 256 tambahan dan 2 penghapusan
  1. 256 2
      src/Hotline.Api/Controllers/TestController.cs

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

@@ -14,6 +14,7 @@ using Hotline.CallCenter.Calls;
 using Hotline.CallCenter.Configs;
 using Hotline.CallCenter.Ivrs;
 using Hotline.CallCenter.Tels;
+using Hotline.Configurations;
 using Hotline.ContingencyManagement;
 using Hotline.FlowEngine;
 using Hotline.FlowEngine.Definitions;
@@ -43,6 +44,7 @@ using Hotline.Users;
 using MapsterMapper;
 using MediatR;
 using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Builder.Extensions;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Options;
 using MiniExcelLibs;
@@ -116,6 +118,7 @@ public class TestController : BaseController
     private readonly IRepository<Tel> _telRepository;
     private readonly IOrderDomainService _orderDomainService;
     private readonly ICallApplication _callApplication;
+    private readonly IOptionsSnapshot<AppConfiguration> _appOptions;
 
     private readonly ISystemSettingCacheManager _systemSettingCacheManager;
     //private readonly ITypedCache<List<User>> _cache;
@@ -169,6 +172,7 @@ IRepository<ContingencyManagementHotspot> contingencyManagementHotspotRepository
 IRepository<Hotspot> hotspotRepository,
 IOrderDomainService orderDomainService,
 ICallApplication callApplication,
+        IOptionsSnapshot<AppConfiguration> appOptions,
         ISystemSettingCacheManager systemSettingCacheManager
         )
     {
@@ -216,6 +220,7 @@ ICallApplication callApplication,
         _telRepository = telRepository;
         _orderDomainService = orderDomainService;
         _callApplication = callApplication;
+        _appOptions = appOptions;
         _systemSettingCacheManager = systemSettingCacheManager;
     }
 
@@ -651,7 +656,7 @@ ICallApplication callApplication,
     [HttpGet("t2")]
     public async Task<string> GetCacheAllowAnonymous()
     {
-        var systemAdministrator = _systemSettingCacheManager.GetSetting(SettingConstants.SystemAdministrator)?.SettingValue[0]; 
+        var systemAdministrator = _systemSettingCacheManager.GetSetting(SettingConstants.SystemAdministrator)?.SettingValue[0];
         return systemAdministrator;
     }
 
@@ -694,5 +699,254 @@ ICallApplication callApplication,
         var publicKey = keyList[1];
         return $"{publicKey} \r\n {privateKey}";
     }
-    
+
+    [AllowAnonymous]
+    [HttpPost("republish")]
+    public async Task Republish()
+    {
+        var provinceNos = new List<string>
+        {
+            "RGDH9951150024082950312",
+"RGDH9951150024080750198",
+"RGDH9951150024083050009",
+"RGDH9951150024083150167",
+"RGDH9951150024083150102",
+"RGDH9951150024083050052",
+"RGDH9951150024080750184",
+"RGDH9951150024083050108",
+"RGDH9951150024083050314",
+"RGDH9951150024083050363",
+"RGDH9951150024083150243",
+"RGDH9951150024082850303",
+"QT9951150024082150023",
+"RGDH9951150024080750185",
+"RGDH9951150024083150065",
+"RGDH9951150024082850032",
+"RGDH9951150024082950295",
+"RGDH9951150024080750189",
+"RGDH9951150024082650189",
+"RGDH9951150024083050008",
+"RGDH9951150024082950036",
+"RGDH9951150024082850341",
+"RGDH9951150024080750215",
+"RGDH9951150024081450005",
+"RGDH9951150024080750212",
+"RGDH9951150024083050137",
+"RGDH9951150024082450124",
+"RGDH9951150024083150188",
+"RGDH9951150024083150083",
+"RGDH9951150024082850082",
+"RGDH9951150024080750174",
+"RGDH9951150024082950371",
+"RGDH9951150024082950114",
+"RGDH9951150024083050339",
+"RGDH9951150024080750217",
+"RGDH9951150024082950040",
+"RGDH9951150024083050031",
+"RGDH9951150024083150267",
+"RGDH9951150024083050064",
+"RGDH9951150024072650086",
+"RGDH9951150024082950360",
+"RGDH9951150024080750195",
+"RGDH9951150024080750210",
+"RGDH9951150024082950250",
+"RGDH9951150024083050145",
+"RGDH9951150024083050356",
+"RGDH9951150024080750194",
+"RGDH9951150024080750173",
+"RGDH9951150024080750213",
+"RGDH9951150024080750218",
+"RGDH9951150024083150271",
+"RGDH9951150024083150134",
+"RGDH9951150024080750179",
+"RGDH9951150024083050140",
+"RGDH9951150024083150262",
+"RGDH9951150024083050119",
+"RGDH9951150024083150177",
+"RGDH9951150024083050146",
+"RGDH9951150024080750223",
+"RGDH9951150024080750221",
+"RGDH9951150024083150130",
+"RGDH9951150024080750209",
+"RGDH9951150024083150237",
+"RGDH9951150024082850095",
+"RGDH9951150024082850223",
+"RGDH9951150024083050077",
+"RGDH9951150024082950118",
+"RGDH9951150024082850056",
+"RGDH9951150024082550177",
+"RGDH9951150024083050358",
+"RGDH9951150024080750193",
+"RGDH9951150024082150011",
+"RGDH9951150024082950167",
+"RGDH9951150024083050201",
+"RGDH9951150024082850048",
+"RGDH9951150024083150161",
+"RGDH9951150024083050300",
+"RGDH9951150024083150016",
+"RGDH9951150024083150101",
+"RGDH9951150024082850207",
+"RGDH9951150024083150144",
+"RGDH9951150024082750300",
+"RGDH9951150024083050230",
+"RGDH9951150024080750211",
+"RGDH9951150024082750379",
+"RGDH9951150024082850252",
+"RGDH9951150024083050204",
+"RGDH9951150024080750176",
+"RGDH9951150024080750190",
+"RGDH9951150024083150027",
+"RGDH9951150024082850308",
+"RGDH9951150024082850070",
+"RGDH9951150024082950068",
+"RGDH9951150024083050002",
+"RGDH9951150024083050130",
+"RGDH9951150024083050060",
+"RGDH9951150024082950282",
+"RGDH9951150024082950320",
+"RGDH9951150024082850312",
+"RGDH9951150024083150040",
+"RGDH9951150024080750202",
+"RGDH9951150024083150216",
+"RGDH9951150024082750156",
+"RGDH9951150024082850224",
+"RGDH9951150024083150238",
+"RGDH9951150024083050327",
+"RGDH9951150024082950090",
+"RGDH9951150024083150131",
+"RGDH9951150024080750187",
+"RGDH9951150024082350072",
+"RGDH9951150024080750177",
+"RGDH9951150024082950010",
+"RGDH9951150024082850263",
+"RGDH9951150024082850087",
+"RGDH9951150024083050234",
+"RGDH9951150024083150098",
+"RGDH9951150024083050166",
+"RGDH9951150024082850339",
+"RGDH9951150024083150157",
+"RGDH9951150024080150214",
+"RGDH9951150024083150149",
+"RGDH9951150024083150264",
+"RGDH9951150024080750200",
+"RGDH9951150024083150116",
+"RGDH9951150024082950188",
+"RGDH9951150024083050148",
+"RGDH9951150024082750338",
+"RGDH9951150024082950268",
+"RGDH9951150024083050337",
+"RGDH9951150024082250263",
+"RGDH9951150024080750196",
+"RGDH9951150024080750192",
+"RGDH9951150024082850272",
+"RGDH9951150024082650290",
+"RGDH9951150024083150117",
+"RGDH9951150024080750207",
+"RGDH9951150024080750201",
+"RGDH9951150024080750188",
+"RGDH9951150024083050011",
+"RGDH9951150024083050067",
+"RGDH9951150024083050193",
+"RGDH9951150024082850242",
+"RGDH9951150024082950121",
+"RGDH9951150024080750222",
+"RGDH9951150024082950280",
+"RGDH9951150024080750205",
+"RGDH9951150024083050334",
+"RGDH9951150024083150235",
+"RGDH9951150024082950156",
+"RGDH9951150024080750220",
+"RGDH9951150024082750209",
+"RGDH9951150024083150046",
+"RGDH9951150024080750214",
+"RGDH9951150024082850116",
+"RGDH9951150024083050082",
+"RGDH9951150024083150118",
+"RGDH9951150024082950338",
+"RGDH9951150024082950359",
+"RGDH9951150024083150156",
+"RGDH9951150024083150072",
+"RGDH9951150024082150001",
+"RGDH9951150024082850186",
+"RGDH9951150024082750377",
+"RGDH9951150024083150166",
+"RGDH9951150024083050255",
+"RGDH9951150024083050190",
+"RGDH9951150024080750175",
+"RGDH9951150024083050184",
+"RGDH9951150024083050021",
+"RGDH9951150024082850317",
+"RGDH9951150024082950146",
+"RGDH9951150024083150172",
+"RGDH9951150024083050354",
+"RGDH9951150024082850305",
+"RGDH9951150024082850351",
+"RGDH9951150024082950340",
+"RGDH9951150024083150273",
+"RGDH9951150024080750208",
+"RGDH9951150024083150053",
+"RGDH9951150024082850291",
+"RGDH9951150024082950104",
+"RGDH9951150024082850247",
+"RGDH9951150024082850320",
+"RGDH9951150024083050285",
+"RGDH9951150024082850011",
+"RGDH9951150024083050174",
+"RGDH9951150024083150212",
+"RGDH9951150024083050323",
+"RGDH9951150024080750224",
+"RGDH9951150024083150244",
+"RGDH9951150024080750199",
+"RGDH9951150024082850269",
+"RGDH9951150024082850053",
+"RGDH9951150024082950342",
+"RGDH9951150024082950046",
+"RGDH9951150024082950194"
+        };
+        _logger.LogWarning($"推送数据共:{provinceNos.Count}");
+
+        var unpublishOrders = await _orderRepository.Queryable()
+            .Includes(d => d.Workflow, w => w.Steps.Where(s => s.StepType == EStepType.End))
+            .Where(d => provinceNos.Contains(d.ProvinceNo) &&
+                        !string.IsNullOrEmpty(d.ProvinceNo) &&
+                        d.Status >= EOrderStatus.Filed)
+            .ToListAsync(HttpContext.RequestAborted);
+
+        _logger.LogWarning($"准备开始推送:{unpublishOrders.Count}");
+
+        foreach (var order in unpublishOrders)
+        {
+            var orderFlowDto = new OrderFlowDto
+            {
+                Order = _mapper.Map<OrderDto>(order),
+                WorkflowTrace = _mapper.Map<WorkflowTraceDto>(order.Workflow.Traces.First())
+            };
+
+            if (order.SourceChannelCode == AppDefaults.SourceChannel.DianHua &&
+                !string.IsNullOrEmpty(order.CallId))
+            {
+                if (_appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.TianRun)
+                {
+                    var callRecord = await _callApplication.GetTianrunCallAsync(order.CallId, HttpContext.RequestAborted);
+                    if (callRecord != null)
+                    {
+                        orderFlowDto.TrCallRecordDto = _mapper.Map<TrCallDto>(callRecord);
+                    }
+                }
+                else if (_appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.XingTang)
+                {
+                    var call = await _callApplication.GetCallAsync(order.CallId, HttpContext.RequestAborted);
+                    if (call is not null)
+                        orderFlowDto.TrCallRecordDto = _mapper.Map<TrCallDto>(call);
+                }
+            }
+
+            //这里需要判断是否是警情退回
+            orderFlowDto.IsNonPoliceReturn = false;
+            await _capPublisher.PublishAsync(Hotline.Share.Mq.EventNames.HotlineOrderFiled, orderFlowDto, cancellationToken: HttpContext.RequestAborted);
+            _logger.LogWarning($"推送完成: {order.Id}");
+        }
+
+        _logger.LogWarning($"推送完成");
+    }
 }