using System.Collections.Concurrent; using System.Data; using System.IO; using System.Threading; using DotNetCore.CAP; using Fw.Utility.Client; using Google.Protobuf.WellKnownTypes; using Hotline.Ai.Visit; using Hotline.Application.ExportExcel; using Hotline.Application.JudicialManagement; using Hotline.Application.Quality; using Hotline.CallCenter.BlackLists; using Hotline.CallCenter.Calls; using Hotline.CallCenter.Devices; using Hotline.CallCenter.Ivrs; using Hotline.FlowEngine.WorkflowModules; using Hotline.FlowEngine.Workflows; using Hotline.Identity.Roles; using Hotline.Import; using Hotline.Orders; using Hotline.Push.Notifies; using Hotline.Realtimes; using Hotline.Repository.SqlSugar; using Hotline.Repository.SqlSugar.CallCenter; using Hotline.Repository.SqlSugar.System; using Hotline.Repository.SqlSugar.Ts; using Hotline.Settings; using Hotline.Settings.TimeLimits; using Hotline.Share.Dtos; using Hotline.Share.Dtos.FlowEngine; using Hotline.Share.Dtos.FlowEngine.Workflow; using Hotline.Share.Dtos.Order; using Hotline.Share.Dtos.Realtime; using Hotline.Share.Dtos.SendSms; using Hotline.Share.Dtos.TrCallCenter; using Hotline.Share.Enums.FlowEngine; using Hotline.Share.Enums.Order; using Hotline.Share.Enums.Push; using Hotline.Share.Enums.Quality; using Hotline.Share.Enums.Settings; using Hotline.Share.Mq; using Hotline.Tools; using Hotline.Users; using MapsterMapper; using MediatR; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Components.Routing; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Routing.Template; using Microsoft.Extensions.Options; using MiniExcelLibs; using NewRock.Sdk; using NewRock.Sdk.Security; using SqlSugar; using SqlSugar.SplitTableExtensions; using StackExchange.Redis; using Tr.Sdk; using XC.RSAUtil; using XF.Domain.Authentications; using XF.Domain.Cache; using XF.Domain.Entities; using XF.Domain.Exceptions; using XF.Domain.Filters; using XF.Domain.Locks; using XF.Domain.Queues; using XF.Domain.Repository; using XF.EasyCaching; using Order = Hotline.Orders.Order; namespace Hotline.Api.Controllers; /// /// /// [AllowAnonymous] public class TestController : BaseController { private readonly ILogger _logger; private readonly IAuthorizeGenerator _authorizeGenerator; private readonly IOptionsSnapshot _options; private readonly ISessionContext _sessionContext; private readonly IRepository _userRepository; private readonly ITypedCache _cache; private readonly IRealtimeService _realtimeService; private readonly IBlacklistDomainService _blacklistDomainService; private readonly IIvrDomainService _ivrDomainService; private readonly ISugarUnitOfWork _uow; private readonly IRepository _roleRepository; private readonly IMediator _mediator; private readonly IDistributedLock _distributedLock; private readonly IRepository _orderUrgeRepository; private readonly IRepositoryTextSearch _repositoryts; private readonly ITimeLimitDomainService _timeLimitDomainService; private readonly IWfModuleDomainService _wfModuleDomainService; private readonly IDaySettingRepository _daySettingRepository; private readonly ITrClient _trClient; private readonly ICapPublisher _capPublisher; private readonly IQueue _queue; private readonly IExportApplication _exportApplication; private readonly IAiVisitService _aiVisitService; private readonly IRepository _workflowTraceRepository; private readonly IRepository _workflowStepRepository; private readonly IWorkflowRepository _workflowRepository; //private readonly IRepository _workflowStepHandleRepository; private readonly IRepository _systemOrganizeRepository; private readonly IOrderRepository _orderRepository; private readonly IRepository _trCallRecordRepository; private readonly IQualityApplication _qualityApplication; private readonly IEnforcementApplication _enforcementApplication; private readonly IMapper _mapper; private readonly IOptionsSnapshot _sendSmsConfiguration; //private readonly ITypedCache> _cache; //private readonly ICacheManager _cache; public TestController( INewRockClient client, ILogger logger, IAuthorizeGenerator authorizeGenerator, IOptionsSnapshot options, ISessionContext sessionContext, IRepository userRepository, //ICacheManager cache //ITypedCache> cache ITypedCache cache, IRealtimeService realtimeService, IBlacklistDomainService blacklistDomainService, IIvrDomainService ivrDomainService, ISugarUnitOfWork uow, IRepository roleRepository, IMediator mediator, IDistributedLock distributedLock, IRepository orderUrgeRepository, IRepositoryTextSearch repositoryts, ITimeLimitDomainService timeLimitDomainService, IWfModuleDomainService wfModuleDomainService, IDaySettingRepository daySettingRepository, ITrClient trClient, ICapPublisher capPublisher, IQueue queue, IExportApplication exportApplication, IAiVisitService aiVisitService, IRepository workflowTraceRepository, IRepository workflowStepRepository, IWorkflowRepository workflowRepository, //IRepository workflowStepHandleRepository, IRepository systemOrganizeRepository, IOrderRepository orderRepository, IRepository trCallRecordRepository, IQualityApplication qualityApplication, IEnforcementApplication enforcementApplication, IMapper mapper, IOptionsSnapshot sendSmsConfiguration ) { _logger = logger; _authorizeGenerator = authorizeGenerator; _options = options; _sessionContext = sessionContext; _userRepository = userRepository; _cache = cache; _realtimeService = realtimeService; _blacklistDomainService = blacklistDomainService; _ivrDomainService = ivrDomainService; _uow = uow; _roleRepository = roleRepository; _mediator = mediator; _distributedLock = distributedLock; _orderUrgeRepository = orderUrgeRepository; _repositoryts = repositoryts; _timeLimitDomainService = timeLimitDomainService; _wfModuleDomainService = wfModuleDomainService; _daySettingRepository = daySettingRepository; _trClient = trClient; _capPublisher = capPublisher; _queue = queue; _exportApplication = exportApplication; _aiVisitService = aiVisitService; _workflowTraceRepository = workflowTraceRepository; _workflowStepRepository = workflowStepRepository; _workflowRepository = workflowRepository; //_workflowStepHandleRepository = workflowStepHandleRepository; _systemOrganizeRepository = systemOrganizeRepository; _orderRepository = orderRepository; _trCallRecordRepository = trCallRecordRepository; _qualityApplication = qualityApplication; _enforcementApplication = enforcementApplication; _orderRepository = orderRepository; _mapper = mapper; _sendSmsConfiguration = sendSmsConfiguration; } [HttpGet("testo111")] [AllowAnonymous] public async Task Test111(DateTime StartTime, DateTime? EndTime) { var list = await _orderRepository.Queryable() .Where(p => p.CreationTime >= StartTime && p.CreationTime <= EndTime && p.Status >= EOrderStatus.Filed) .Where(p => p.CreationTimeHandleDuration == null || p.CenterToOrgHandleDuration == null) .ToListAsync(); if (list.Any()) { foreach (var item in list) { var creationTimeHandleDurationWorkday = item.ActualHandleTime.HasValue ? _timeLimitDomainService.CalcWorkTime(item.CreationTime, item.ActualHandleTime.Value, item.ProcessType is EProcessType.Zhiban) : 0; var centerToOrgHandleDurationWorkday = item.ActualHandleTime.HasValue && item.CenterToOrgTime.HasValue ? _timeLimitDomainService.CalcWorkTime(item.CenterToOrgTime.Value, item.ActualHandleTime.Value, item.ProcessType is EProcessType.Zhiban) : 0; item.CreationTimeHandleDurationWorkday = creationTimeHandleDurationWorkday; item.CenterToOrgHandleDurationWorkday = centerToOrgHandleDurationWorkday; if (item.ActualHandleTime.HasValue) { var count = Math.Round((item.ActualHandleTime - item.CreationTime).Value.TotalSeconds); item.CreationTimeHandleDuration = count <= 0 ? 1 : count; } else item.CreationTimeHandleDuration = 0; if (item.ActualHandleTime.HasValue && item.CenterToOrgTime.HasValue) { var count = Math.Round((item.ActualHandleTime - item.CenterToOrgTime).Value.TotalSeconds); item.CenterToOrgHandleDuration = count <= 0 ? 1 : count; } else item.CenterToOrgHandleDuration = 0; await _orderRepository.UpdateAsync(item, HttpContext.RequestAborted); } } } [HttpGet("testo")] [AllowAnonymous] public async Task TestOrigin() { var messageDto = new Share.Dtos.Push.MessageDto { PushBusiness = EPushBusiness.OrderAccept, ExternalId = "123456789", OrderId = "123456789", PushPlatform = EPushPlatform.Sms, Remark = " order.Title", Name = "张三", TemplateCode = "1005", Params = new List() { "20240610000022", "12345" }, TelNumber = "15881689499", }; await _mediator.Publish(new PushMessageNotify(messageDto), HttpContext.RequestAborted); var t = _sendSmsConfiguration.Value.Url; var now = DateTime.Now.ToString(); return OpenResponse.Ok(now); } [HttpGet("init-orgname")] [AllowAnonymous] public async Task InitUserOrgFullName() { var list = await _userRepository.Queryable().Where(x => 1 == 1 && string.IsNullOrEmpty(x.FullOrgName)).ToListAsync(); foreach (var item in list) { var orgFullName = ""; var orgFullCode = ""; var orgId = item.OrgId; int strLength = orgId.Length; int segmentsCount = strLength / 3; List strings = new List(); for (int i = 0; i < segmentsCount; i++) { int startIndex = i * 3; int length = Math.Min(3, strLength - startIndex); strings.Add(orgId.Substring(startIndex, length)); } if (strLength > 3) { orgFullCode = strings[0]; strings.Remove(orgFullCode); } foreach (var str in strings) { orgFullCode = orgFullCode + str; var org = await _systemOrganizeRepository.GetAsync(orgFullCode); if (org != null) { orgFullName = orgFullName + org.Name + "/"; } } if (orgFullName.Length > 0) { orgFullName = orgFullName.Remove(orgFullName.Length - 1); } item.FullOrgName = orgFullName; await _userRepository.UpdateAsync(item); } } [HttpPost("import")] [AllowAnonymous] public async Task> Import(IFormFile file) { //var FileName = file.FileName; //var fileExtension = Path.GetExtension(FileName); ////新文件名 //var newFileName = DateTime.Now.ToString("yyyyMMddhhmmss"); ////文件保存路径 //var filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "Upload", newFileName); ////判断路径是否存在 //if (!Directory.Exists(filePath)) //{ // //创建路径 // Directory.CreateDirectory(filePath); //} //filePath = Path.Combine(filePath, newFileName+ fileExtension); using (var stream = new MemoryStream()) { file.CopyTo(stream); var list = MiniExcel.Query(stream).ToList(); //Directory.Delete(filePath, true); return list; } } [AllowAnonymous] [HttpGet("export")] public async Task Export() { List list = new List(); ExcelContent excelContent = new ExcelContent() { ExternalId = "123123" }; list.Add(excelContent); return _exportApplication.ExportData(list, "demo.xlsx"); } [HttpGet("time")] [AllowAnonymous] public async Task GetTime(string batchId, string taskId) { //await _repositoryts.AddVectorAsync("f595e730-909a-45e4-9138-a84bf15f4662", DateTime.Now, // new List { "xx", "bb" }, HttpContext.RequestAborted); //await _repositoryts.AddVectorAsync("f595e730-909a-45e4-9138-a84bf15f4663", DateTime.Now, // new List { "aa", "bb", "cc" }, HttpContext.RequestAborted); var result0 = await _repositoryts.SearchAsync(new List { "xx", "aa" }, HttpContext.RequestAborted); var result = await _repositoryts.SearchAsync(new List { "bb" }, HttpContext.RequestAborted); var result1 = await _repositoryts.SearchAsync(new List { "cc", "bb" }, HttpContext.RequestAborted); var result2 = await _repositoryts.SearchAsync(new List { "cc", "xx" }, HttpContext.RequestAborted); var result3 = await _repositoryts.SearchAsync(new List { "aa", "bb", "ss" }, HttpContext.RequestAborted); //await _repositoryts.UpdateVectorAsync("f595e730-909a-45e4-9138-a84bf15f4662", // new List { "ss", "bb" }, HttpContext.RequestAborted); //_uow.Db.Ado.SqlQueryAsync("SELECT to_tsvector('fat cats ate fat rats') @@ to_tsquery('fat & rat')") //var tests = _uowWex.Db.Ado.SqlQuery("select * from view_telinfo_full where IsSynch=@IsSynch", new { IsSynch = 0 }); //var a = _uowWex.Db.Ado.ExecuteCommand("update telinfo set IsSynch=1 where GUID=@CallId", new { CallId = "b1f97f3c-88b6-4f42-b8de-83ed448854b0" }); //var rsp = await _wexClient.QueryTelsAsync(new QueryTelRequest { }, HttpContext.RequestAborted); //int a = _timeLimitDomainService.CalcWorkTime(DateTime.Now, DateTime.Parse("2023-09-11 16:21:00")); //int m = _timeLimitDomainService.CalcWorkTime(DateTime.Parse("2023-09-19 12:00:00"), DateTime.Parse("2023-09-20 18:00:00"), false); //var r = _timeLimitDomainService.CalcEndTime(DateTime.Parse("2024-6-06 14:32:47"),"40"); //var r = _timeLimitDomainService.CalcExpiredTime(DateTime.Parse("2024-02-29 10:12:33"), Share.Enums.FlowEngine.EFlowDirection.OrgToCenter, "10"); //await _wfModuleDomainService.PersistenceModulesAsync(HttpContext.RequestAborted); //var rsp = await _daprClient.InvokeMethodAsync>(HttpMethod.Get, "identity", "api/v1/Test/time", HttpContext.RequestAborted); //var rsp1 = await _daprClient.InvokeMethodAsync>(HttpMethod.Post, "identity", "api/v1/Test/time1", 222, HttpContext.RequestAborted); //var a = await _trClient.QueryTelsAsync(new Tr.Sdk.Tels.QueryTelRequest() { }, HttpContext.RequestAborted); //await _daySettingRepository.IsWorkDay(DateTime.Now); //var r = _timeLimitDomainService.CalcWorkTime(DateTime.Parse("2024-6-06 14:32:47"), DateTime.Parse("2024-3-22 06:00:00"), false); //var r = _timeLimitDomainService.CalcWorkTime(DateTime.Parse("2024-3-24 17:20:00"), DateTime.Parse("2024-3-24 17:21:00"), false); //await _aiVisitService.QueryAiVisitTask(batchId, taskId, HttpContext.RequestAborted); //var r = _timeLimitDomainService.CalcWorkTimeReduce(DateTime.Now, 5); //var r = _timeLimitDomainService.CalcWorkTimeToDecimal(DateTime.Parse("2024-05-14 14:41:42"), DateTime.Parse("2024-05-14 14:50:46"), false); return OpenResponse.Ok(DateTime.Now.ToString("F")); } [HttpGet("pgsql")] public async Task Pgsql() { var role = new Identity.Roles.Role { Name = $"test_role_{TimeOnly.FromDateTime(DateTime.Now)}", DisplayName = "test_role_display", ClientId = "test" }; var roleId = await _roleRepository.AddAsync(role, HttpContext.RequestAborted); role.Description = "Description"; await _roleRepository.UpdateAsync(role, HttpContext.RequestAborted); return roleId; } [AllowAnonymous] [HttpGet("roles")] public async Task> GetRoles() { using var lockManager = new LockManager(_distributedLock, $"{nameof(TestController)}.{nameof(GetRoles)}"); lockManager.InvokeInLock(() => { Console.WriteLine("do something"); }, TimeSpan.FromSeconds(10)); await lockManager.InvokeInLockAsync( d => _roleRepository.Queryable(includeDeleted: true).ToListAsync(), TimeSpan.FromSeconds(10), HttpContext.RequestAborted); var a = await _roleRepository.Queryable() //.Where(d => !d.IsDeleted) .ToListAsync(); //var a = await db.Queryable().ToListAsync(); var b = await _roleRepository.Queryable(includeDeleted: true).ToListAsync(); return a; } //[AllowAnonymous] [HttpGet("hash")] public async Task Hash() { var s = _sessionContext; } /// /// signalR测试(method: Ring) /// /// [HttpGet("ring")] public async Task RingTest() { await _realtimeService.RingAsync(_sessionContext.RequiredUserId, new RingDto { Id = new Guid().ToString(), From = _sessionContext.Phone ?? "未知号码", To = "12345" }, HttpContext.RequestAborted); } /// /// signalR测试(method: Answered) /// /// [HttpGet("answered")] public async Task AnsweredTest() { await _realtimeService.AnsweredAsync(_sessionContext.RequiredUserId, new AnsweredDto() { Id = new Guid().ToString(), From = _sessionContext.Phone ?? "未知号码", To = "12345" }, HttpContext.RequestAborted); } /// /// signalR测试(method: Bye) /// /// [HttpGet("bye")] public async Task ByeTest() { await _realtimeService.ByeAsync(_sessionContext.RequiredUserId, new ByeDto() { Id = new Guid().ToString() }, HttpContext.RequestAborted); } /// /// /// /// [AllowAnonymous] [HttpGet("t2")] public async Task GetVoiceEndAnswerAsyncTest() { //var answer = await _ivrDomainService.GetVoiceEndAnswerAsync("3", HttpContext.RequestAborted); //Console.WriteLine(answer.Content); throw new UserFriendlyException(2001, "test"); } [HttpGet("wfdefine")] public async Task GetWorkflowDefine([FromQuery] string id) { //var query = _workflowTraceRepository.Queryable() // .LeftJoin((t, w) => t.WorkflowId == w.Id) // .LeftJoin((t, w, o) => w.ExternalId == o.Id) // .Where((t, w, o) => o.No.Length == 14); //if (!string.IsNullOrEmpty(id)) // query = query.Where(d => d.WorkflowId == id); //var list = await query // .Select((t, w, o) => new { t, w, o }) // .ToListAsync(HttpContext.RequestAborted); //var toUsers = list.Where(d => d.t.FlowAssignType == EFlowAssignType.User).ToList(); //var userIds = toUsers.SelectMany(d => d.t.Handlers).Select(d => d.Key).Distinct().ToList(); //var users = await _userRepository.Queryable() // .Includes(d => d.Organization) // .Where(d => userIds.Contains(d.Id)) // .ToListAsync(HttpContext.RequestAborted); ////var orgTraces = list.Where(d => d.FlowAssignType == EFlowAssignType.Org).ToList(); //var stepHandlers = new List(); //foreach (var toUser in toUsers) //{ // foreach (var traceHandler in toUser.t.Handlers) // { // var user = users.FirstOrDefault(d => d.Id == traceHandler.Key); // if (user != null) // stepHandlers.Add(new WorkflowStepHandler // { // WorkflowId = toUser.w.Id, // ExternalId = toUser.w.ExternalId, // WorkflowStepId = toUser.t.StepId, // FlowAssignType = toUser.t.FlowAssignType.Value, // UserId = user.Id, // Username = user.Name, // OrgId = user.OrgId, // OrgName = user.Organization.Name, // IsActualHandler = user.Id == toUser.t.HandlerId // }); // } //} //var toOrgs = list.Where(d => d.t.FlowAssignType == EFlowAssignType.Org).ToList(); //foreach (var toOrg in toOrgs) //{ // foreach (var handler in toOrg.t.Handlers) // { // stepHandlers.Add(new WorkflowStepHandler // { // WorkflowId = toOrg.w.Id, // ExternalId = toOrg.w.ExternalId, // WorkflowStepId = toOrg.t.StepId, // FlowAssignType = toOrg.t.FlowAssignType.Value, // OrgId = handler.Key, // OrgName = handler.Value, // IsActualHandler = handler.Key == toOrg.t.HandlerOrgId // }); // } //} //_logger.LogInformation($"生成handlers: {stepHandlers.Count} 条"); //await _workflowStepHandleRepository.AddRangeAsync(stepHandlers, HttpContext.RequestAborted); } /// /// 处理FlowAssignType /// /// [AllowAnonymous] [HttpPost("t3")] public async Task TestExportExcel() { var orders = await _orderRepository.Queryable() //.Includes(d => d.Workflow, x => x.Steps.Where(d => d.BusinessType == EBusinessType.Send)) //.Where(d=>d.Workflow.Steps.Any(d=>d.BusinessType == EBusinessType.Send)) .Where(d => d.Status != EOrderStatus.WaitForAccept && d.CenterToOrgTime == null) .ToListAsync(HttpContext.RequestAborted); var orderIds = orders.Select(d => d.Id).ToList(); var steps = await _workflowStepRepository.Queryable() .Where(d => orderIds.Contains(d.ExternalId) && d.BusinessType == EBusinessType.Send && d.Status == EWorkflowStepStatus.Handled) .OrderBy(d => d.CreationTime) .ToListAsync(HttpContext.RequestAborted); _logger.LogWarning($"取到steps: {steps.Count} 条"); var updateOrders = new List(); foreach (var order in orders) { var step = steps.Where(d => d.ExternalId == order.Id) .OrderBy(d => d.CreationTime) .FirstOrDefault(); if (step is null) continue; order.CenterToOrgTime = step.HandleTime; order.CenterToOrgHandlerId = step.HandlerId; order.CenterToOrgHandlerName = step.HandlerName; order.CenterToOrgOpinion = step.Opinion; var handleDuration = order.CenterToOrgTime.HasValue && order.ActualHandleTime.HasValue ? _timeLimitDomainService.CalcWorkTime(order.CenterToOrgTime.Value, order.ActualHandleTime.Value, order.ProcessType is EProcessType.Zhiban) : 0; var fileDuration = order.CenterToOrgTime.HasValue && order.FiledTime.HasValue ? _timeLimitDomainService.CalcWorkTime(order.CenterToOrgTime.Value, order.FiledTime.Value, order.ProcessType is EProcessType.Zhiban) : 0; //var allDuration = order.StartTime.HasValue // ? _timeLimitDomainService.CalcWorkTime(order.StartTime.Value, order.FiledTime.Value, // order.ProcessType is EProcessType.Zhiban) // : 0; order.SetHandleDuration(); order.SetFileDuration(); order.HandleDurationWorkday = handleDuration; order.FileDurationWorkday = fileDuration; updateOrders.Add(order); } _logger.LogWarning($"更新工单:{updateOrders.Count} 条"); await _orderRepository.UpdateRangeAsync(updateOrders, HttpContext.RequestAborted); } [AllowAnonymous] [HttpPost("t4")] public async Task TestExportExcel1() { //var orders = await _orderRepository.Queryable() // .Includes(d => d.OrderExtension) // .InnerJoin((o, w) => o.WorkflowId == w.Id) // .Where((o, w) => o.Status < EOrderStatus.Filed && w.Status == EWorkflowStatus.Completed) // .ToListAsync(HttpContext.RequestAborted); //_logger.LogWarning($"order count: {orders.Count}"); //var workflowIds = orders.Select(d => d.WorkflowId).ToList(); //var workflows = await _workflowRepository.Queryable() // .Includes(d => d.Steps, x => x.WorkflowTrace) // //.Includes(d=>d.Traces) // .Where(d => workflowIds.Contains(d.Id)) // .ToListAsync(HttpContext.RequestAborted); //var updateOrders = new List(); //foreach (var order in orders) //{ // var workflow = workflows.First(d => d.Id == order.WorkflowId); // _mapper.Map(workflow, order); // var now = DateTime.Now; // var handleDuration = order.StartTime.HasValue // ? _timeLimitDomainService.CalcWorkTime(order.StartTime.Value, // now, order.ProcessType is EProcessType.Zhiban) // : 0; // var fileDuration = order.CenterToOrgTime.HasValue // ? _timeLimitDomainService.CalcWorkTime(order.CenterToOrgTime.Value, // now, order.ProcessType is EProcessType.Zhiban) // : 0; // var allDuration = order.StartTime.HasValue // ? _timeLimitDomainService.CalcWorkTime(order.StartTime.Value, now, // order.ProcessType is EProcessType.Zhiban) // : 0; // var creationTimeHandleDurationWorkday = order.ActualHandleTime.HasValue // ? _timeLimitDomainService.CalcWorkTime(order.CreationTime, order.ActualHandleTime.Value, // order.ProcessType is EProcessType.Zhiban) // : 0; // var centerToOrgHandleDurationWorkday = order.ActualHandleTime.HasValue && order.CenterToOrgTime.HasValue // ? _timeLimitDomainService.CalcWorkTime(order.CenterToOrgTime.Value, order.ActualHandleTime.Value, // order.ProcessType is EProcessType.Zhiban) // : 0; // order.File(now, handleDuration, fileDuration, allDuration, creationTimeHandleDurationWorkday, centerToOrgHandleDurationWorkday); // var endStep = workflow.Steps.FirstOrDefault(d => d.StepType == EStepType.End); // //var endTrace = workflow.Steps.FirstOrDefault(d => d.WorkflowTrace.StepType == EStepType.End)?.WorkflowTrace; // if (endStep is null) // { // _logger.LogWarning($"endStep 为空, orderNo:{order.No}"); // continue; // } // var step = workflow.Steps.FirstOrDefault(d => d.Id == endStep.PrevStepId); // //var trace = workflow.Steps.FirstOrDefault(d => d.WorkflowTrace.Id == endTrace.PrevStepId)?.WorkflowTrace; // if (step is null) // { // _logger.LogWarning($"step 为空, orderNo:{order.No}"); // continue; // } // var trace = step.WorkflowTrace; // order.FileUserId = trace.HandlerId; // order.FileUserName = trace.HandlerName; // order.FileUserOrgId = trace.HandlerOrgId; // order.FileUserOrgName = trace.HandlerOrgName; // order.FileOpinion = trace.Opinion; // //记录冗余归档数据 // if (workflow.Steps.Any(x => x.BusinessType == Share.Enums.FlowEngine.EBusinessType.Send)) // { // order.FileUserRole = EFileUserType.Dispatch; // } // else // { // order.FileUserRole = EFileUserType.Seat; // } // if (order.ProcessType == EProcessType.Jiaoban) // { // order.FileUserRole = EFileUserType.Org; // } // //是否已解决 // order.IsResolved = true;//notification.Dto.External == null ? false : notification.Dto.External.IsResolved; // //await _orderRepository.UpdateAsync(order, cancellationToken); // updateOrders.Add(order); // //var callRecord = await _trCallRecordRepository.GetAsync(p => p.CallAccept == order.CallId, cancellationToken); //由CallAccept改为OtherAccept // var orderFlowDto = new OrderFlowDto // { // Order = _mapper.Map(order), // WorkflowTrace = _mapper.Map(trace) // }; // var callRecord = await _trCallRecordRepository.GetAsync(p => p.OtherAccept == order.CallId, HttpContext.RequestAborted); // if (callRecord != null) // { // orderFlowDto.TrCallRecordDto = _mapper.Map(callRecord); // } // //这里需要判断是否是警情退回 // orderFlowDto.IsNonPoliceReturn = false;//notification.Dto.External == null ? false : notification.Dto.External.IsPoliceReturn; // await _capPublisher.PublishAsync(Hotline.Share.Mq.EventNames.HotlineOrderFiled, orderFlowDto, cancellationToken: HttpContext.RequestAborted); // //写入质检 针对受理之后直接结束的工单 // await _qualityApplication.AddQualityAsync(EQualitySource.Accepted, order.Id, HttpContext.RequestAborted); // //司法行政监督管理-工单处理 // await _enforcementApplication.AddEnforcementOrderAsync(order, HttpContext.RequestAborted); //} //_logger.LogWarning($"更新orders:{updateOrders.Count}"); //await _orderRepository.UpdateRangeAsync(updateOrders, HttpContext.RequestAborted); } [AllowAnonymous] [HttpGet("t5")] public async Task Test5() { var traces = await _workflowTraceRepository.Queryable() .Where(d => d.Status == EWorkflowStepStatus.Handled && d.HandlerOrgAreaCode == null) .ToListAsync(HttpContext.RequestAborted); var orgIds = traces.Select(d => d.HandlerOrgId).ToList(); var orgs = await _systemOrganizeRepository.Queryable() .Where(d => orgIds.Contains(d.Id)) .ToListAsync(HttpContext.RequestAborted); var updateSteps = new List(); foreach (var trace in traces) { var org = orgs.FirstOrDefault(d => d.Id == trace.HandlerOrgId); if (org == null) { _logger.LogWarning($"未找到部门,Id:{trace.HandlerOrgId}"); continue; } if (!trace.HandlerOrgIsCenter.HasValue) trace.HandlerOrgIsCenter = org.IsCenter; if (string.IsNullOrEmpty(trace.HandlerOrgAreaCode)) trace.HandlerOrgAreaCode = org.AreaCode; if (string.IsNullOrEmpty(trace.HandlerOrgAreaName)) trace.HandlerOrgAreaName = org.AreaName; updateSteps.Add(trace); } _logger.LogWarning($"更新数据:{updateSteps.Count} 条"); await _workflowTraceRepository.UpdateRangeAsync(updateSteps, HttpContext.RequestAborted); } [HttpGet("rsa")] public async Task Rsa() { var keyList = RsaKeyGenerator.Pkcs1Key(2048, true); var privateKey = keyList[0]; var publicKey = keyList[1]; return $"{publicKey} \r\n {privateKey}"; } }