TestController.cs 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955
  1. using DotNetCore.CAP;
  2. using Hotline.Ai.Visit;
  3. using Hotline.Application.CallCenter;
  4. using Hotline.Application.ExportExcel;
  5. using Hotline.Application.FlowEngine;
  6. using Hotline.Application.JudicialManagement;
  7. using Hotline.Application.Orders;
  8. using Hotline.Application.Quality;
  9. using Hotline.Application.StatisticalReport;
  10. using Hotline.Authentications;
  11. using Hotline.Caching.Interfaces;
  12. using Hotline.CallCenter.BlackLists;
  13. using Hotline.CallCenter.Calls;
  14. using Hotline.CallCenter.Configs;
  15. using Hotline.CallCenter.Ivrs;
  16. using Hotline.CallCenter.Tels;
  17. using Hotline.Configurations;
  18. using Hotline.ContingencyManagement;
  19. using Hotline.FlowEngine;
  20. using Hotline.FlowEngine.Definitions;
  21. using Hotline.FlowEngine.Notifications;
  22. using Hotline.FlowEngine.WorkflowModules;
  23. using Hotline.FlowEngine.Workflows;
  24. using Hotline.Import;
  25. using Hotline.JudicialManagement;
  26. using Hotline.Orders;
  27. using Hotline.Realtimes;
  28. using Hotline.Repository.SqlSugar;
  29. using Hotline.Repository.SqlSugar.Ts;
  30. using Hotline.Settings;
  31. using Hotline.Settings.Hotspots;
  32. using Hotline.Settings.TimeLimits;
  33. using Hotline.Share.Dtos;
  34. using Hotline.Share.Dtos.FlowEngine;
  35. using Hotline.Share.Dtos.FlowEngine.Workflow;
  36. using Hotline.Share.Dtos.Order;
  37. using Hotline.Share.Dtos.Realtime;
  38. using Hotline.Share.Dtos.TrCallCenter;
  39. using Hotline.Share.Enums.FlowEngine;
  40. using Hotline.Share.Enums.JudicialManagement;
  41. using Hotline.Share.Enums.Order;
  42. using Hotline.Share.Enums.Quality;
  43. using Hotline.Users;
  44. using MapsterMapper;
  45. using MediatR;
  46. using Microsoft.AspNetCore.Authorization;
  47. using Microsoft.AspNetCore.Builder.Extensions;
  48. using Microsoft.AspNetCore.Mvc;
  49. using Microsoft.Extensions.Options;
  50. using MiniExcelLibs;
  51. using SqlSugar;
  52. using XC.RSAUtil;
  53. using XF.Domain.Authentications;
  54. using XF.Domain.Cache;
  55. using XF.Domain.Exceptions;
  56. using XF.Domain.Filters;
  57. using XF.Domain.Locks;
  58. using XF.Domain.Queues;
  59. using XF.Domain.Repository;
  60. using Order = Hotline.Orders.Order;
  61. namespace Hotline.Api.Controllers;
  62. /// <summary>
  63. ///
  64. /// </summary>
  65. //[AllowAnonymous]
  66. public class TestController : BaseController
  67. {
  68. private readonly ILogger<TestController> _logger;
  69. //private readonly IAuthorizeGenerator _authorizeGenerator;
  70. private readonly IOptionsSnapshot<CallCenterConfiguration> _options;
  71. private readonly ISessionContext _sessionContext;
  72. private readonly IRepository<User> _userRepository;
  73. private readonly ITypedCache<User> _cache;
  74. private readonly IRealtimeService _realtimeService;
  75. private readonly IBlacklistDomainService _blacklistDomainService;
  76. private readonly IIvrDomainService _ivrDomainService;
  77. private readonly ISugarUnitOfWork<HotlineDbContext> _uow;
  78. private readonly IRepository<Identity.Roles.Role> _roleRepository;
  79. private readonly IMediator _mediator;
  80. private readonly IDistributedLock _distributedLock;
  81. private readonly IRepository<OrderUrge> _orderUrgeRepository;
  82. private readonly IRepositoryTextSearch<OrderTs> _repositoryts;
  83. private readonly ITimeLimitDomainService _timeLimitDomainService;
  84. private readonly IWfModuleDomainService _wfModuleDomainService;
  85. private readonly IDaySettingRepository _daySettingRepository;
  86. //private readonly ITrClient _trClient;
  87. private readonly ICapPublisher _capPublisher;
  88. private readonly IQueue _queue;
  89. private readonly IExportApplication _exportApplication;
  90. private readonly IRepository<WorkflowTrace> _workflowTraceRepository;
  91. private readonly IRepository<WorkflowStep> _workflowStepRepository;
  92. private readonly IWorkflowRepository _workflowRepository;
  93. //private readonly IRepository<WorkflowStepHandler> _workflowStepHandleRepository;
  94. private readonly IRepository<SystemOrganize> _systemOrganizeRepository;
  95. private readonly IOrderRepository _orderRepository;
  96. private readonly IRepository<TrCallRecord> _trCallRecordRepository;
  97. private readonly IQualityApplication _qualityApplication;
  98. private readonly IEnforcementApplication _enforcementApplication;
  99. private readonly IWorkflowDomainService _workflowDomainService;
  100. private readonly IMapper _mapper;
  101. private readonly IOrderReportApplication _orderReportApplication;
  102. private readonly IRepository<EnforcementOrders> _enforcementOrdersRepository;
  103. private readonly IRepository<JudicialManagementOrders> _judicialManagementOrdersRepository;
  104. private readonly IRepository<EnforcementOrdersHandler> _enforcementOrdersHandlerRepository;
  105. private readonly IWorkflowApplication _workflowApplication;
  106. private readonly IRepository<ContingencyManagementHotspot> _contingencyManagementHotspotRepository;
  107. private readonly IRepository<Hotspot> _hotspotRepository;
  108. private readonly IOrderApplication _orderApplication;
  109. private readonly IRepository<Tel> _telRepository;
  110. private readonly IOrderDomainService _orderDomainService;
  111. private readonly ICallApplication _callApplication;
  112. private readonly IOptionsSnapshot<AppConfiguration> _appOptions;
  113. private readonly ISystemSettingCacheManager _systemSettingCacheManager;
  114. //private readonly ITypedCache<List<User>> _cache;
  115. //private readonly ICacheManager<User> _cache;
  116. public TestController(
  117. //INewRockClient client,
  118. ILogger<TestController> logger,
  119. //IAuthorizeGenerator authorizeGenerator,
  120. IOptionsSnapshot<CallCenterConfiguration> options,
  121. ISessionContext sessionContext,
  122. IRepository<User> userRepository,
  123. //ICacheManager<User> cache
  124. //ITypedCache<List<User>> cache
  125. ITypedCache<User> cache,
  126. IRealtimeService realtimeService,
  127. IBlacklistDomainService blacklistDomainService,
  128. IIvrDomainService ivrDomainService,
  129. ISugarUnitOfWork<HotlineDbContext> uow,
  130. IRepository<Identity.Roles.Role> roleRepository,
  131. IMediator mediator,
  132. IDistributedLock distributedLock,
  133. IRepository<OrderUrge> orderUrgeRepository,
  134. IRepositoryTextSearch<OrderTs> repositoryts,
  135. ITimeLimitDomainService timeLimitDomainService,
  136. IWfModuleDomainService wfModuleDomainService,
  137. IDaySettingRepository daySettingRepository,
  138. //ITrClient trClient,
  139. ICapPublisher capPublisher,
  140. IQueue queue,
  141. IExportApplication exportApplication,
  142. IRepository<WorkflowTrace> workflowTraceRepository,
  143. IRepository<WorkflowStep> workflowStepRepository,
  144. IWorkflowRepository workflowRepository,
  145. //IRepository<WorkflowStepHandler> workflowStepHandleRepository,
  146. IRepository<SystemOrganize> systemOrganizeRepository,
  147. IOrderRepository orderRepository,
  148. IRepository<TrCallRecord> trCallRecordRepository,
  149. IQualityApplication qualityApplication,
  150. IEnforcementApplication enforcementApplication,
  151. IWorkflowDomainService workflowDomainService,
  152. IMapper mapper,
  153. IOrderApplication orderApplication,
  154. IRepository<Tel> telRepository,
  155. IOrderReportApplication orderReportApplication,
  156. IRepository<EnforcementOrders> enforcementOrdersRepository,
  157. IRepository<JudicialManagementOrders> judicialManagementOrdersRepository,
  158. IRepository<EnforcementOrdersHandler> enforcementOrdersHandlerRepository,
  159. IRepository<ContingencyManagementHotspot> contingencyManagementHotspotRepository,
  160. IRepository<Hotspot> hotspotRepository,
  161. IOrderDomainService orderDomainService,
  162. ICallApplication callApplication,
  163. IOptionsSnapshot<AppConfiguration> appOptions,
  164. ISystemSettingCacheManager systemSettingCacheManager
  165. )
  166. {
  167. _logger = logger;
  168. //_authorizeGenerator = authorizeGenerator;
  169. _options = options;
  170. _sessionContext = sessionContext;
  171. _userRepository = userRepository;
  172. _cache = cache;
  173. _realtimeService = realtimeService;
  174. _blacklistDomainService = blacklistDomainService;
  175. _ivrDomainService = ivrDomainService;
  176. _uow = uow;
  177. _roleRepository = roleRepository;
  178. _mediator = mediator;
  179. _distributedLock = distributedLock;
  180. _orderUrgeRepository = orderUrgeRepository;
  181. _repositoryts = repositoryts;
  182. _timeLimitDomainService = timeLimitDomainService;
  183. _wfModuleDomainService = wfModuleDomainService;
  184. _daySettingRepository = daySettingRepository;
  185. //_trClient = trClient;
  186. _capPublisher = capPublisher;
  187. _queue = queue;
  188. _exportApplication = exportApplication;
  189. _workflowTraceRepository = workflowTraceRepository;
  190. _workflowStepRepository = workflowStepRepository;
  191. _workflowRepository = workflowRepository;
  192. //_workflowStepHandleRepository = workflowStepHandleRepository;
  193. _systemOrganizeRepository = systemOrganizeRepository;
  194. _orderRepository = orderRepository;
  195. _trCallRecordRepository = trCallRecordRepository;
  196. _qualityApplication = qualityApplication;
  197. _enforcementApplication = enforcementApplication;
  198. _workflowDomainService = workflowDomainService;
  199. _orderRepository = orderRepository;
  200. _mapper = mapper;
  201. _orderReportApplication = orderReportApplication;
  202. _enforcementOrdersRepository = enforcementOrdersRepository;
  203. _judicialManagementOrdersRepository = judicialManagementOrdersRepository;
  204. _enforcementOrdersHandlerRepository = enforcementOrdersHandlerRepository;
  205. _contingencyManagementHotspotRepository = contingencyManagementHotspotRepository;
  206. _hotspotRepository = hotspotRepository;
  207. _orderApplication = orderApplication;
  208. _telRepository = telRepository;
  209. _orderDomainService = orderDomainService;
  210. _callApplication = callApplication;
  211. _appOptions = appOptions;
  212. _systemSettingCacheManager = systemSettingCacheManager;
  213. }
  214. /// <summary>
  215. /// 推送回访到省上
  216. /// </summary>
  217. /// <returns></returns>
  218. [HttpPost("publishVisitToProvince")]
  219. [AllowAnonymous]
  220. public async Task PublsihVisitToProvince([FromBody] DateTime date)
  221. {
  222. //查询需要推送的数据
  223. var list = await _orderRepository.Queryable()
  224. .Includes(x => x.OrderVisits.Where(q => q.VisitState == EVisitState.Visited).ToList())
  225. .Where(x => x.CreationTime.Date == date.Date && x.Status == EOrderStatus.Visited && x.ProcessType == EProcessType.Zhiban && x.CounterSignType == null).ToListAsync();
  226. foreach (var item in list)
  227. {
  228. var visit = item.OrderVisits.FirstOrDefault();
  229. if (visit != null)
  230. {
  231. //推省上
  232. await _capPublisher.PublishAsync(Hotline.Share.Mq.EventNames.HotlineOrderVisited,
  233. new PublishVisitDto()
  234. {
  235. Order = _mapper.Map<OrderDto>(item),
  236. No = visit.No,
  237. VisitType = visit.VisitType,
  238. VisitName = visit.CreatorName,
  239. VisitTime = visit.VisitTime,
  240. VisitRemark = "满意",
  241. AreaCode = item.AreaCode!,
  242. SubjectResultSatifyCode = "4",
  243. FirstSatisfactionCode = "4",
  244. ClientGuid = ""
  245. }, cancellationToken: HttpContext.RequestAborted);
  246. }
  247. }
  248. }
  249. [HttpGet("addcontingencymanagementhotspot")]
  250. [AllowAnonymous]
  251. public async Task AddContingencyManagementHotspot([FromQuery] string? Id, string? ParentId)
  252. {
  253. if (!string.IsNullOrWhiteSpace(Id))
  254. {
  255. var data = await _hotspotRepository.GetAsync(Id, HttpContext.RequestAborted);
  256. if (data != null)
  257. {
  258. var newdata = _mapper.Map<ContingencyManagementHotspot>(data);
  259. newdata.Id = data.Id;
  260. await _contingencyManagementHotspotRepository.AddAsync(newdata, HttpContext.RequestAborted);
  261. }
  262. }
  263. if (!string.IsNullOrEmpty(ParentId))
  264. {
  265. var data = await _hotspotRepository.Queryable().Where(p => p.ParentId == ParentId).ToListAsync();
  266. if (data != null && data.Count > 0)
  267. {
  268. foreach (var item in data)
  269. {
  270. var newdata = _mapper.Map<ContingencyManagementHotspot>(item);
  271. newdata.Id = item.Id;
  272. await _contingencyManagementHotspotRepository.AddAsync(newdata, HttpContext.RequestAborted);
  273. }
  274. }
  275. }
  276. }
  277. /// <summary>
  278. /// 处理司法工单数据
  279. /// </summary>
  280. /// <param name="StartTime"></param>
  281. /// <param name="EndTime"></param>
  282. /// <returns></returns>
  283. [HttpGet("addjudicial_management_orders")]
  284. [AllowAnonymous]
  285. public async Task AddJudicialManagementOrders(DateTime StartTime, DateTime? EndTime)
  286. {
  287. var list = await _enforcementOrdersRepository.Queryable()
  288. .Includes(x => x.Order)
  289. .Where(x => x.CreationTime >= StartTime && x.CreationTime <= EndTime && x.Order.AcceptTypeCode == "35")
  290. .ToListAsync();
  291. foreach (var item in list)
  292. {
  293. var order = item.Order;
  294. if (order != null)
  295. {
  296. var orderData = await _judicialManagementOrdersRepository.GetAsync(p => p.Id == order.Id, HttpContext.RequestAborted);
  297. if (orderData == null)
  298. {
  299. orderData = new JudicialManagementOrders();
  300. //处理工单
  301. _mapper.Map(order, orderData);
  302. orderData.Id = order.Id;
  303. orderData.IsEnforcementOrder = order.IsEnforcementOrder.HasValue ? order.IsEnforcementOrder.Value : false;
  304. orderData.IsTheClueTrue = item.IsTheClueTrue;
  305. orderData.IsPassTheBuckOrder = item.IsPassTheBuckOrder;
  306. orderData.OrderSoure = EOrderSoure.Hotline;
  307. orderData.CreationTime = item.CreationTime;
  308. if (item.EventTypeId == "04" || item.EventTypeId == "05" || item.EventTypeId == "06" || item.EventTypeId == "07" || item.EventTypeId == "08" ||
  309. item.EventTypeId == "0401" || item.EventTypeId == "0501" || item.EventTypeId == "0601" || item.EventTypeId == "0701" || item.EventTypeId == "0801")
  310. {
  311. orderData.EventTypeId = "0901";
  312. orderData.EventTypeName = "其他情形";
  313. orderData.EventTypeSpliceName = "其他类-其他情形";
  314. orderData.EventTypeOneLevelId = "09";
  315. }
  316. else
  317. {
  318. orderData.EventTypeId = item.EventTypeId;
  319. orderData.EventTypeName = item.EventTypeName;
  320. orderData.EventTypeSpliceName = item.EventTypeSpliceName;
  321. orderData.EventTypeOneLevelId = item.EventTypeOneLevelId;
  322. }
  323. List<Kv> kvs = new List<Kv>
  324. {
  325. new Kv { Key = order.OrgLevelOneName, Value = order.OrgLevelOneCode }
  326. };
  327. orderData.EnforcementOrdersHandler = kvs;
  328. await _judicialManagementOrdersRepository.AddAsync(orderData, HttpContext.RequestAborted);
  329. //处理部门
  330. EnforcementOrdersHandler enforcementOrdersHandler = new EnforcementOrdersHandler()
  331. {
  332. OrderId = order.Id,
  333. OrderNo = order.No,
  334. OrderSoure = EOrderSoure.Hotline,
  335. OrgCode = order.OrgLevelOneCode,
  336. OrgName = order.OrgLevelOneName,
  337. CreationTime = order.CreationTime
  338. };
  339. await _enforcementOrdersHandlerRepository.AddAsync(enforcementOrdersHandler, HttpContext.RequestAborted);
  340. }
  341. }
  342. }
  343. }
  344. /// <summary>
  345. /// 计算工单的办理时长
  346. /// </summary>
  347. /// <param name="StartTime"></param>
  348. /// <param name="EndTime"></param>
  349. /// <returns></returns>
  350. [HttpGet("update_order_handle_time")]
  351. [AllowAnonymous]
  352. public async Task UpdateOrderHandleTime(DateTime StartTime, DateTime? EndTime)
  353. {
  354. var list = await _orderRepository.Queryable()
  355. .Where(p => p.CreationTime >= StartTime && p.CreationTime <= EndTime && p.Status >= EOrderStatus.Filed)
  356. .Where(p => p.CreationTimeHandleDuration == null || p.CenterToOrgHandleDuration == null)
  357. .ToListAsync();
  358. if (list.Any())
  359. {
  360. foreach (var item in list)
  361. {
  362. var creationTimeHandleDurationWorkday = item.FiledTime.HasValue
  363. ? _timeLimitDomainService.CalcWorkTimeEx(item.CreationTime, item.FiledTime.Value,
  364. item.ProcessType is EProcessType.Zhiban)
  365. : 0;
  366. var centerToOrgHandleDurationWorkday = item.FiledTime.HasValue && item.CenterToOrgTime.HasValue
  367. ? _timeLimitDomainService.CalcWorkTimeEx(item.CenterToOrgTime.Value, item.FiledTime.Value,
  368. item.ProcessType is EProcessType.Zhiban)
  369. : 0;
  370. item.CreationTimeHandleDurationWorkday = creationTimeHandleDurationWorkday;
  371. item.CenterToOrgHandleDurationWorkday = centerToOrgHandleDurationWorkday;
  372. if (item.FiledTime.HasValue)
  373. {
  374. var count = Math.Round((item.FiledTime - item.CreationTime).Value.TotalSeconds);
  375. item.CreationTimeHandleDuration = count <= 0 ? 1 : count;
  376. }
  377. else
  378. item.CreationTimeHandleDuration = 0;
  379. if (item.FiledTime.HasValue && item.CenterToOrgTime.HasValue)
  380. {
  381. var count = Math.Round((item.FiledTime - item.CenterToOrgTime).Value.TotalSeconds);
  382. item.CenterToOrgHandleDuration = count <= 0 ? 1 : count;
  383. }
  384. else
  385. item.CenterToOrgHandleDuration = 0;
  386. await _orderRepository.UpdateAsync(item, HttpContext.RequestAborted);
  387. }
  388. }
  389. }
  390. [HttpGet("testo")]
  391. [AllowAnonymous]
  392. public async Task<OpenResponse> TestOrigin()
  393. {
  394. var now = DateTime.Now.ToString();
  395. return OpenResponse.Ok(now);
  396. }
  397. [HttpGet("init-orgname")]
  398. [AllowAnonymous]
  399. public async Task InitUserOrgFullName()
  400. {
  401. var list = await _userRepository.Queryable().Where(x => 1 == 1 && string.IsNullOrEmpty(x.FullOrgName)).ToListAsync();
  402. foreach (var item in list)
  403. {
  404. var orgFullName = "";
  405. var orgFullCode = "";
  406. var orgId = item.OrgId;
  407. int strLength = orgId.Length;
  408. int segmentsCount = strLength / 3;
  409. List<string> strings = new List<string>();
  410. for (int i = 0; i < segmentsCount; i++)
  411. {
  412. int startIndex = i * 3;
  413. int length = Math.Min(3, strLength - startIndex);
  414. strings.Add(orgId.Substring(startIndex, length));
  415. }
  416. if (strLength > 3)
  417. {
  418. orgFullCode = strings[0];
  419. strings.Remove(orgFullCode);
  420. }
  421. foreach (var str in strings)
  422. {
  423. orgFullCode = orgFullCode + str;
  424. var org = await _systemOrganizeRepository.GetAsync(orgFullCode);
  425. if (org != null)
  426. {
  427. orgFullName = orgFullName + org.Name + "/";
  428. }
  429. }
  430. if (orgFullName.Length > 0)
  431. {
  432. orgFullName = orgFullName.Remove(orgFullName.Length - 1);
  433. }
  434. item.FullOrgName = orgFullName;
  435. await _userRepository.UpdateAsync(item);
  436. }
  437. }
  438. [HttpPost("import")]
  439. [AllowAnonymous]
  440. public async Task<List<ExcelContent>> Import(IFormFile file)
  441. {
  442. //var FileName = file.FileName;
  443. //var fileExtension = Path.GetExtension(FileName);
  444. ////新文件名
  445. //var newFileName = DateTime.Now.ToString("yyyyMMddhhmmss");
  446. ////文件保存路径
  447. //var filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "Upload", newFileName);
  448. ////判断路径是否存在
  449. //if (!Directory.Exists(filePath))
  450. //{
  451. // //创建路径
  452. // Directory.CreateDirectory(filePath);
  453. //}
  454. //filePath = Path.Combine(filePath, newFileName+ fileExtension);
  455. using (var stream = new MemoryStream())
  456. {
  457. file.CopyTo(stream);
  458. var list = MiniExcel.Query<ExcelContent>(stream).ToList();
  459. //Directory.Delete(filePath, true);
  460. return list;
  461. }
  462. }
  463. [AllowAnonymous]
  464. [HttpGet("export")]
  465. public async Task<object> Export()
  466. {
  467. List<ExcelContent> list = new List<ExcelContent>();
  468. ExcelContent excelContent = new ExcelContent() { ExternalId = "123123" };
  469. list.Add(excelContent);
  470. return _exportApplication.ExportData<ExcelContent>(list, "demo.xlsx");
  471. }
  472. [HttpGet("time")]
  473. [AllowAnonymous]
  474. public async Task<OpenResponse> GetTime(string batchId, string taskId)
  475. {
  476. //await _repositoryts.AddVectorAsync("f595e730-909a-45e4-9138-a84bf15f4662", DateTime.Now,
  477. // new List<string> { "xx", "bb" }, HttpContext.RequestAborted);
  478. //await _repositoryts.AddVectorAsync("f595e730-909a-45e4-9138-a84bf15f4663", DateTime.Now,
  479. // new List<string> { "aa", "bb", "cc" }, HttpContext.RequestAborted);
  480. var result0 = await _repositoryts.SearchAsync(new List<string> { "xx", "aa" }, HttpContext.RequestAborted);
  481. var result = await _repositoryts.SearchAsync(new List<string> { "bb" }, HttpContext.RequestAborted);
  482. var result1 = await _repositoryts.SearchAsync(new List<string> { "cc", "bb" }, HttpContext.RequestAborted);
  483. var result2 = await _repositoryts.SearchAsync(new List<string> { "cc", "xx" }, HttpContext.RequestAborted);
  484. var result3 = await _repositoryts.SearchAsync(new List<string> { "aa", "bb", "ss" }, HttpContext.RequestAborted);
  485. //await _repositoryts.UpdateVectorAsync("f595e730-909a-45e4-9138-a84bf15f4662",
  486. // new List<string> { "ss", "bb" }, HttpContext.RequestAborted);
  487. //_uow.Db.Ado.SqlQueryAsync<OrderUrge>("SELECT to_tsvector('fat cats ate fat rats') @@ to_tsquery('fat & rat')")
  488. //var tests = _uowWex.Db.Ado.SqlQuery<Test>("select * from view_telinfo_full where IsSynch=@IsSynch", new { IsSynch = 0 });
  489. //var a = _uowWex.Db.Ado.ExecuteCommand("update telinfo set IsSynch=1 where GUID=@CallId", new { CallId = "b1f97f3c-88b6-4f42-b8de-83ed448854b0" });
  490. //var rsp = await _wexClient.QueryTelsAsync(new QueryTelRequest { }, HttpContext.RequestAborted);
  491. //int a = _timeLimitDomainService.CalcWorkTime(DateTime.Now, DateTime.Parse("2023-09-11 16:21:00"));
  492. //int m = _timeLimitDomainService.CalcWorkTime(DateTime.Parse("2023-09-19 12:00:00"), DateTime.Parse("2023-09-20 18:00:00"), false);
  493. //var r = _timeLimitDomainService.CalcEndTime(DateTime.Parse("2024-6-06 14:32:47"),"40");
  494. //var r = _timeLimitDomainService.CalcExpiredTime(DateTime.Parse("2024-02-29 10:12:33"), Share.Enums.FlowEngine.EFlowDirection.OrgToCenter, "10");
  495. //await _wfModuleDomainService.PersistenceModulesAsync(HttpContext.RequestAborted);
  496. //var rsp = await _daprClient.InvokeMethodAsync<ApiResponse<string>>(HttpMethod.Get, "identity", "api/v1/Test/time", HttpContext.RequestAborted);
  497. //var rsp1 = await _daprClient.InvokeMethodAsync<int, ApiResponse<string>>(HttpMethod.Post, "identity", "api/v1/Test/time1", 222, HttpContext.RequestAborted);
  498. //var a = await _trClient.QueryTelsAsync(new Tr.Sdk.Tels.QueryTelRequest() { }, HttpContext.RequestAborted);
  499. //await _daySettingRepository.IsWorkDay(DateTime.Now);
  500. //var r = _timeLimitDomainService.CalcWorkTime(DateTime.Parse("2024-6-06 14:32:47"), DateTime.Parse("2024-3-22 06:00:00"), false);
  501. //var r = _timeLimitDomainService.CalcWorkTime(DateTime.Parse("2024-3-24 17:20:00"), DateTime.Parse("2024-3-24 17:21:00"), false);
  502. //await _aiVisitService.QueryAiVisitTask(batchId, taskId, HttpContext.RequestAborted);
  503. //var r = _timeLimitDomainService.CalcWorkTimeReduce(DateTime.Now, 5);
  504. //var r = _timeLimitDomainService.CalcWorkTimeToDecimal(DateTime.Parse("2024-07-09 14:57:51"), DateTime.Parse("2024-07-10 14:20:42"), false);
  505. //var endTime = _timeLimitDomainService
  506. //.CalcEndTime(DateTime.Parse("2024-07-09 14:57:51"), ETimeType.WorkDay, -3, 0, 0);///.EndTime;
  507. //var timeResult = _timeLimitDomainService.CalcEndTime(DateTime.Now, ETimeType.WorkDay, 3, 80, 50);
  508. //var t = _timeLimitDomainService.CalcWorkTimeEx(DateTime.Parse("2024-07-22 11:30:00"), DateTime.Parse("2024-07-23 14:00:00"), false);
  509. //var r = await _aiVisitService.QueryAiVisitTaskEx("MTAwMDAx173ASS0kSUAqK2rl2sFGME", "", HttpContext.RequestAborted);
  510. //var r = await _aiVisitService.QueryAiVisitTaskResult(batchId, DateTime.Parse("2024-07-28"), DateTime.Parse("2024-08-01"), HttpContext.RequestAborted);
  511. //var r = _timeLimitDomainService.CalcExpiredTime(DateTime.Now, EFlowDirection.CenterToCenter, batchId);
  512. //_capPublisher.PublishDelay(DateTime.Now.AddSeconds(10) - DateTime.Now, EventNames.HotlineBatchSmsTask, new PublishBatchSmsTaskDto() { TaskId = "123123" });
  513. return OpenResponse.Ok(DateTime.Now.ToString("F"));
  514. }
  515. [HttpGet("pgsql")]
  516. public async Task<string> Pgsql()
  517. {
  518. var role = new Identity.Roles.Role
  519. {
  520. Name = $"test_role_{TimeOnly.FromDateTime(DateTime.Now)}",
  521. DisplayName = "test_role_display",
  522. ClientId = "test"
  523. };
  524. var roleId = await _roleRepository.AddAsync(role, HttpContext.RequestAborted);
  525. role.Description = "Description";
  526. await _roleRepository.UpdateAsync(role, HttpContext.RequestAborted);
  527. return roleId;
  528. }
  529. [AllowAnonymous]
  530. [HttpGet("roles")]
  531. public async Task<List<Identity.Roles.Role>> GetRoles()
  532. {
  533. using var lockManager = new LockManager(_distributedLock, $"{nameof(TestController)}.{nameof(GetRoles)}");
  534. lockManager.InvokeInLock(() => { Console.WriteLine("do something"); }, TimeSpan.FromSeconds(10));
  535. await lockManager.InvokeInLockAsync(
  536. d => _roleRepository.Queryable(includeDeleted: true).ToListAsync(),
  537. TimeSpan.FromSeconds(10),
  538. HttpContext.RequestAborted);
  539. var a = await _roleRepository.Queryable()
  540. //.Where(d => !d.IsDeleted)
  541. .ToListAsync();
  542. //var a = await db.Queryable<Role>().ToListAsync();
  543. var b = await _roleRepository.Queryable(includeDeleted: true).ToListAsync();
  544. return a;
  545. }
  546. //[AllowAnonymous]
  547. [HttpGet("hash")]
  548. public async Task Hash()
  549. {
  550. var s = _sessionContext;
  551. }
  552. /// <summary>
  553. /// signalR测试(method: Ring)
  554. /// </summary>
  555. /// <returns></returns>
  556. [HttpGet("ring")]
  557. public async Task RingTest()
  558. {
  559. await _realtimeService.RingAsync(_sessionContext.RequiredUserId,
  560. new RingDto { Id = new Guid().ToString(), From = _sessionContext.Phone ?? "未知号码", To = "12345" },
  561. HttpContext.RequestAborted);
  562. }
  563. /// <summary>
  564. /// signalR测试(method: Answered)
  565. /// </summary>
  566. /// <returns></returns>
  567. [HttpGet("answered")]
  568. public async Task AnsweredTest()
  569. {
  570. await _realtimeService.AnsweredAsync(_sessionContext.RequiredUserId,
  571. new AnsweredDto() { Id = new Guid().ToString(), From = _sessionContext.Phone ?? "未知号码", To = "12345" },
  572. HttpContext.RequestAborted);
  573. }
  574. /// <summary>
  575. /// signalR测试(method: Bye)
  576. /// </summary>
  577. /// <returns></returns>
  578. [HttpGet("bye")]
  579. public async Task ByeTest()
  580. {
  581. await _realtimeService.ByeAsync(_sessionContext.RequiredUserId, new ByeDto() { Id = new Guid().ToString() },
  582. HttpContext.RequestAborted);
  583. }
  584. [AllowAnonymous]
  585. [HttpGet("t2")]
  586. public async Task<string> GetCacheAllowAnonymous()
  587. {
  588. var systemAdministrator = _systemSettingCacheManager.GetSetting(SettingConstants.SystemAdministrator)?.SettingValue[0];
  589. return systemAdministrator;
  590. }
  591. [HttpGet("t3")]
  592. public async Task<string> GetCacheWithAuth()
  593. {
  594. var systemAdministrator = _systemSettingCacheManager.GetSetting(SettingConstants.SystemAdministrator)?.SettingValue[0];
  595. return systemAdministrator;
  596. }
  597. [AllowAnonymous]
  598. [HttpGet("t4")]
  599. public async Task<string> GetAllowAnonymous()
  600. {
  601. return DateTime.Now.ToString("O");
  602. }
  603. [AllowAnonymous]
  604. [HttpGet("t5")]
  605. public async Task<string> GetUserAllowAnonymous()
  606. {
  607. var users = await _userRepository.Queryable()
  608. .FirstAsync(d => d.Name == "xf", HttpContext.RequestAborted);
  609. return users.Id;
  610. }
  611. [HttpGet("t6")]
  612. public async Task<string> GetUserWithAuth()
  613. {
  614. var users = await _userRepository.Queryable()
  615. .FirstAsync(d => d.Name == "xf", HttpContext.RequestAborted);
  616. return users.Id;
  617. }
  618. [HttpGet("rsa")]
  619. public async Task<string> Rsa()
  620. {
  621. var keyList = RsaKeyGenerator.Pkcs1Key(2048, true);
  622. var privateKey = keyList[0];
  623. var publicKey = keyList[1];
  624. return $"{publicKey} \r\n {privateKey}";
  625. }
  626. [AllowAnonymous]
  627. [HttpGet("republish")]
  628. public async Task Republish()
  629. {
  630. var provinceNos = new List<string>
  631. {
  632. "RGDH9951150024082950312",
  633. "RGDH9951150024080750198",
  634. "RGDH9951150024083050009",
  635. "RGDH9951150024083150167",
  636. "RGDH9951150024083150102",
  637. "RGDH9951150024083050052",
  638. "RGDH9951150024080750184",
  639. "RGDH9951150024083050108",
  640. "RGDH9951150024083050314",
  641. "RGDH9951150024083050363",
  642. "RGDH9951150024083150243",
  643. "RGDH9951150024082850303",
  644. "QT9951150024082150023",
  645. "RGDH9951150024080750185",
  646. "RGDH9951150024083150065",
  647. "RGDH9951150024082850032",
  648. "RGDH9951150024082950295",
  649. "RGDH9951150024080750189",
  650. "RGDH9951150024082650189",
  651. "RGDH9951150024083050008",
  652. "RGDH9951150024082950036",
  653. "RGDH9951150024082850341",
  654. "RGDH9951150024080750215",
  655. "RGDH9951150024081450005",
  656. "RGDH9951150024080750212",
  657. "RGDH9951150024083050137",
  658. "RGDH9951150024082450124",
  659. "RGDH9951150024083150188",
  660. "RGDH9951150024083150083",
  661. "RGDH9951150024082850082",
  662. "RGDH9951150024080750174",
  663. "RGDH9951150024082950371",
  664. "RGDH9951150024082950114",
  665. "RGDH9951150024083050339",
  666. "RGDH9951150024080750217",
  667. "RGDH9951150024082950040",
  668. "RGDH9951150024083050031",
  669. "RGDH9951150024083150267",
  670. "RGDH9951150024083050064",
  671. "RGDH9951150024072650086",
  672. "RGDH9951150024082950360",
  673. "RGDH9951150024080750195",
  674. "RGDH9951150024080750210",
  675. "RGDH9951150024082950250",
  676. "RGDH9951150024083050145",
  677. "RGDH9951150024083050356",
  678. "RGDH9951150024080750194",
  679. "RGDH9951150024080750173",
  680. "RGDH9951150024080750213",
  681. "RGDH9951150024080750218",
  682. "RGDH9951150024083150271",
  683. "RGDH9951150024083150134",
  684. "RGDH9951150024080750179",
  685. "RGDH9951150024083050140",
  686. "RGDH9951150024083150262",
  687. "RGDH9951150024083050119",
  688. "RGDH9951150024083150177",
  689. "RGDH9951150024083050146",
  690. "RGDH9951150024080750223",
  691. "RGDH9951150024080750221",
  692. "RGDH9951150024083150130",
  693. "RGDH9951150024080750209",
  694. "RGDH9951150024083150237",
  695. "RGDH9951150024082850095",
  696. "RGDH9951150024082850223",
  697. "RGDH9951150024083050077",
  698. "RGDH9951150024082950118",
  699. "RGDH9951150024082850056",
  700. "RGDH9951150024082550177",
  701. "RGDH9951150024083050358",
  702. "RGDH9951150024080750193",
  703. "RGDH9951150024082150011",
  704. "RGDH9951150024082950167",
  705. "RGDH9951150024083050201",
  706. "RGDH9951150024082850048",
  707. "RGDH9951150024083150161",
  708. "RGDH9951150024083050300",
  709. "RGDH9951150024083150016",
  710. "RGDH9951150024083150101",
  711. "RGDH9951150024082850207",
  712. "RGDH9951150024083150144",
  713. "RGDH9951150024082750300",
  714. "RGDH9951150024083050230",
  715. "RGDH9951150024080750211",
  716. "RGDH9951150024082750379",
  717. "RGDH9951150024082850252",
  718. "RGDH9951150024083050204",
  719. "RGDH9951150024080750176",
  720. "RGDH9951150024080750190",
  721. "RGDH9951150024083150027",
  722. "RGDH9951150024082850308",
  723. "RGDH9951150024082850070",
  724. "RGDH9951150024082950068",
  725. "RGDH9951150024083050002",
  726. "RGDH9951150024083050130",
  727. "RGDH9951150024083050060",
  728. "RGDH9951150024082950282",
  729. "RGDH9951150024082950320",
  730. "RGDH9951150024082850312",
  731. "RGDH9951150024083150040",
  732. "RGDH9951150024080750202",
  733. "RGDH9951150024083150216",
  734. "RGDH9951150024082750156",
  735. "RGDH9951150024082850224",
  736. "RGDH9951150024083150238",
  737. "RGDH9951150024083050327",
  738. "RGDH9951150024082950090",
  739. "RGDH9951150024083150131",
  740. "RGDH9951150024080750187",
  741. "RGDH9951150024082350072",
  742. "RGDH9951150024080750177",
  743. "RGDH9951150024082950010",
  744. "RGDH9951150024082850263",
  745. "RGDH9951150024082850087",
  746. "RGDH9951150024083050234",
  747. "RGDH9951150024083150098",
  748. "RGDH9951150024083050166",
  749. "RGDH9951150024082850339",
  750. "RGDH9951150024083150157",
  751. "RGDH9951150024080150214",
  752. "RGDH9951150024083150149",
  753. "RGDH9951150024083150264",
  754. "RGDH9951150024080750200",
  755. "RGDH9951150024083150116",
  756. "RGDH9951150024082950188",
  757. "RGDH9951150024083050148",
  758. "RGDH9951150024082750338",
  759. "RGDH9951150024082950268",
  760. "RGDH9951150024083050337",
  761. "RGDH9951150024082250263",
  762. "RGDH9951150024080750196",
  763. "RGDH9951150024080750192",
  764. "RGDH9951150024082850272",
  765. "RGDH9951150024082650290",
  766. "RGDH9951150024083150117",
  767. "RGDH9951150024080750207",
  768. "RGDH9951150024080750201",
  769. "RGDH9951150024080750188",
  770. "RGDH9951150024083050011",
  771. "RGDH9951150024083050067",
  772. "RGDH9951150024083050193",
  773. "RGDH9951150024082850242",
  774. "RGDH9951150024082950121",
  775. "RGDH9951150024080750222",
  776. "RGDH9951150024082950280",
  777. "RGDH9951150024080750205",
  778. "RGDH9951150024083050334",
  779. "RGDH9951150024083150235",
  780. "RGDH9951150024082950156",
  781. "RGDH9951150024080750220",
  782. "RGDH9951150024082750209",
  783. "RGDH9951150024083150046",
  784. "RGDH9951150024080750214",
  785. "RGDH9951150024082850116",
  786. "RGDH9951150024083050082",
  787. "RGDH9951150024083150118",
  788. "RGDH9951150024082950338",
  789. "RGDH9951150024082950359",
  790. "RGDH9951150024083150156",
  791. "RGDH9951150024083150072",
  792. "RGDH9951150024082150001",
  793. "RGDH9951150024082850186",
  794. "RGDH9951150024082750377",
  795. "RGDH9951150024083150166",
  796. "RGDH9951150024083050255",
  797. "RGDH9951150024083050190",
  798. "RGDH9951150024080750175",
  799. "RGDH9951150024083050184",
  800. "RGDH9951150024083050021",
  801. "RGDH9951150024082850317",
  802. "RGDH9951150024082950146",
  803. "RGDH9951150024083150172",
  804. "RGDH9951150024083050354",
  805. "RGDH9951150024082850305",
  806. "RGDH9951150024082850351",
  807. "RGDH9951150024082950340",
  808. "RGDH9951150024083150273",
  809. "RGDH9951150024080750208",
  810. "RGDH9951150024083150053",
  811. "RGDH9951150024082850291",
  812. "RGDH9951150024082950104",
  813. "RGDH9951150024082850247",
  814. "RGDH9951150024082850320",
  815. "RGDH9951150024083050285",
  816. "RGDH9951150024082850011",
  817. "RGDH9951150024083050174",
  818. "RGDH9951150024083150212",
  819. "RGDH9951150024083050323",
  820. "RGDH9951150024080750224",
  821. "RGDH9951150024083150244",
  822. "RGDH9951150024080750199",
  823. "RGDH9951150024082850269",
  824. "RGDH9951150024082850053",
  825. "RGDH9951150024082950342",
  826. "RGDH9951150024082950046",
  827. "RGDH9951150024082950194"
  828. };
  829. _logger.LogWarning($"推送数据共:{provinceNos.Count}");
  830. var unpublishOrders = await _orderRepository.Queryable()
  831. //.Includes(d => d.Workflow, w => w.Traces)
  832. .Where(d => provinceNos.Contains(d.ProvinceNo) &&
  833. !string.IsNullOrEmpty(d.ProvinceNo) &&
  834. d.Status >= EOrderStatus.Filed)
  835. .ToListAsync(HttpContext.RequestAborted);
  836. _logger.LogWarning($"准备开始推送:{unpublishOrders.Count}");
  837. foreach (var order in unpublishOrders)
  838. {
  839. var trace = await _workflowTraceRepository.Queryable()
  840. .FirstAsync(d => d.WorkflowId == order.WorkflowId && d.StepType == EStepType.End,
  841. HttpContext.RequestAborted);
  842. var orderFlowDto = new OrderFlowDto
  843. {
  844. Order = _mapper.Map<OrderDto>(order),
  845. WorkflowTrace = _mapper.Map<WorkflowTraceDto>(trace)
  846. };
  847. if (order.SourceChannelCode == AppDefaults.SourceChannel.DianHua &&
  848. !string.IsNullOrEmpty(order.CallId))
  849. {
  850. if (_appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.TianRun)
  851. {
  852. var callRecord = await _callApplication.GetTianrunCallAsync(order.CallId, HttpContext.RequestAborted);
  853. if (callRecord != null)
  854. {
  855. orderFlowDto.TrCallRecordDto = _mapper.Map<TrCallDto>(callRecord);
  856. }
  857. }
  858. else if (_appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType == AppDefaults.CallCenterType.XingTang)
  859. {
  860. var call = await _callApplication.GetCallAsync(order.CallId, HttpContext.RequestAborted);
  861. if (call is not null)
  862. orderFlowDto.TrCallRecordDto = _mapper.Map<TrCallDto>(call);
  863. }
  864. }
  865. //这里需要判断是否是警情退回
  866. orderFlowDto.IsNonPoliceReturn = false;
  867. await _capPublisher.PublishAsync(Hotline.Share.Mq.EventNames.HotlineOrderFiled, orderFlowDto, cancellationToken: HttpContext.RequestAborted);
  868. _logger.LogWarning($"推送完成: {order.Id}");
  869. }
  870. _logger.LogWarning($"推送完成");
  871. }
  872. }