您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

6 个月前
6 个月前
6 个月前
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using Confluent.Kafka;
  2. using Microsoft.Extensions.Options;
  3. using Newtonsoft.Json;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Reflection.PortableExecutable;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using TelpoPush.Models.MqTemplates;
  11. using TelpoPush.Service.Biz;
  12. namespace TelpoPush.Worker.ThirdSsl.Handlers
  13. {
  14. public class ThirdSslProcess
  15. {
  16. private readonly static object _syncLocker = new object();
  17. private readonly IHostEnvironment _env;
  18. private readonly ILogger<ThirdSslProcess> _logger;
  19. private readonly IZkRealHRMonitorService _zkRealHRMonitorService;
  20. public ThirdSslProcess(
  21. IHostEnvironment env,
  22. ILogger<ThirdSslProcess> logger,
  23. IZkRealHRMonitorService zkRealHRMonitorService)
  24. {
  25. _env = env;
  26. _logger = logger;
  27. _zkRealHRMonitorService= zkRealHRMonitorService;
  28. }
  29. public async Task SendSslThird(string? message, string topic, Headers headers)
  30. {
  31. //lock (_syncLocker)
  32. //{
  33. _logger.LogInformation($"获取kafka数据Message:<{message}>");
  34. if (!string.IsNullOrEmpty(message))
  35. {
  36. BaseModel model = JsonConvert.DeserializeObject<BaseModel>(message);
  37. if (!string.IsNullOrEmpty(model.Content.ToString()))
  38. {
  39. switch (model.TopicName)
  40. {
  41. case "topic.push.telpo.zkheartrate":
  42. await DataServiceZkRealHRMonitor(model);
  43. break;
  44. default:
  45. break;
  46. }
  47. }
  48. }
  49. // }
  50. }
  51. public async Task DataServiceZkRealHRMonitor(BaseModel model)
  52. {
  53. string content = model.Content.ToString().ToLower();
  54. if (content.Contains("heartrates"))
  55. {
  56. var data = JsonConvert.DeserializeObject<ZkRealHeartRatesTemplate>(content);
  57. await _zkRealHRMonitorService.Save(data.heartRates, model.MessageId);
  58. }
  59. else if (content.Contains("anomalycancel"))
  60. {
  61. var data = JsonConvert.DeserializeObject<ZkRealHeartRateAnomalyCancelTemplate>(content);
  62. await _zkRealHRMonitorService.SaveAnomalyCancel(data.anomalyCancel, model.MessageId);
  63. }
  64. }
  65. }
  66. }