Pārlūkot izejas kodu

数据保存调整

master
杨雷 pirms 3 mēnešiem
vecāks
revīzija
cfda23a099
1 mainītis faili ar 46 papildinājumiem un 15 dzēšanām
  1. +46
    -15
      TelpoPush.WanJiaAn.Worker/Handlers/WanJiaAnProcess.cs

+ 46
- 15
TelpoPush.WanJiaAn.Worker/Handlers/WanJiaAnProcess.cs Parādīt failu

@@ -1,4 +1,5 @@
using Confluent.Kafka;
using Google.Protobuf.WellKnownTypes;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using System.ComponentModel.DataAnnotations;
@@ -263,17 +264,19 @@ namespace TelpoPush.WanJiaAn.Worker.Handlers
var data = alarmEvent?.alarm_event;
if (data?.event_type == 2 || data?.event_type == 52)//2:哭声检测;52:遮脸提醒
{
string tag = "";
string tagRemark = "";
if (data.report_type == 1)
tag = "事件开始";
tagRemark = "事件开始";
else if (data.report_type == 2)
tag = "事件结束";
tagRemark = "事件结束";
else if (data.report_type == 3)
tag = "资源上报";
tagRemark = "资源上报";

string tag = data?.event_type == 2 ? "哭声检测" : "遮脸提醒";
string eventId = $"{data?.event_id}_{data?.report_type}";
var wanjiaanAlarm = new WanjiaanAlarmEvent()
{
EventId = data.event_id,
EventId = eventId,
DeviceId = model.device_id,
UserId = model.user_id,
EventTime = TimeHelper.ConvertToLocalDateTime(model.event_time),
@@ -282,7 +285,7 @@ namespace TelpoPush.WanJiaAn.Worker.Handlers
EventStart = TimeHelper.ConvertToLocalDateTime(data.event_start),
ImageUrl = data.image,
VideoUrl = data.url,
Remark = $"{tag}:{JsonConvert.SerializeObject(model)};",
Remark = $"{tagRemark}:{JsonConvert.SerializeObject(model)};",
CreateTime = DateTime.Now,
};
if (!string.IsNullOrEmpty(data.event_end))
@@ -291,16 +294,42 @@ namespace TelpoPush.WanJiaAn.Worker.Handlers
wanjiaanAlarm.VideoStart = TimeHelper.ConvertToLocalDateTime(data.video_start);
if (!string.IsNullOrEmpty(data.video_end))
wanjiaanAlarm.VideoEnd = TimeHelper.ConvertToLocalDateTime(data.video_end);
await _messageWanJiaAnClient.AddAsync(wanjiaanAlarm);//数据保存

var alarmEventDb = await _redis.GetWanjiaanAlarmEvent(wanjiaanAlarm.EventId);
if (alarmEventDb != null)
wanjiaanAlarm.Remark = alarmEventDb.Remark + wanjiaanAlarm.Remark;
await _redis.SetWanjiaanAlarmEvent(wanjiaanAlarm.EventId, wanjiaanAlarm);
if (data.report_type == 3)
{
await _messageWanJiaAnClient.AddAsync(wanjiaanAlarm);
await _redis.DelWanjiaanAlarmEvent(wanjiaanAlarm.EventId);
}
//推送 业务
//var messageObj = new
//{
// messageId = eventId,
// topic = "topic.push.third",
// time = TimeHelper.ToDateTimeStr(wanjiaanAlarm.EventTime),
// data = new
// {
// imei = wanjiaanAlarm.DeviceId,
// wanjiaanAlarm.UserId,
// wanjiaanAlarm.EventType,
// wanjiaanAlarm.ReportType,
// wanjiaanAlarm.EventStart,
// wanjiaanAlarm.EventEnd,
// wanjiaanAlarm.ImageUrl,
// wanjiaanAlarm.VideoUrl,
// wanjiaanAlarm.VideoStart,
// wanjiaanAlarm.VideoEnd
// }
//};
//var header = new Dictionary<string, int> { { "DataType", 32 } };
//await _serviceMqProcess.ProcessThirdhServer(wanjiaanAlarm.DeviceId, messageObj, header, $"{tag}({tagRemark})");

#region 注释

//var alarmEventDb = await _redis.GetWanjiaanAlarmEvent(eventId);
//if (alarmEventDb != null)
// wanjiaanAlarm.Remark = alarmEventDb.Remark + wanjiaanAlarm.Remark;
//await _redis.SetWanjiaanAlarmEvent(wanjiaanAlarm.EventId, wanjiaanAlarm);
//if (data.report_type == 3)
//{
// await _messageWanJiaAnClient.AddAsync(wanjiaanAlarm);
// await _redis.DelWanjiaanAlarmEvent(wanjiaanAlarm.EventId);
//}

//var param = new GeneralParam
//{
@@ -340,6 +369,8 @@ namespace TelpoPush.WanJiaAn.Worker.Handlers
// _messageWanJiaAnClient.Add(wanjiaanAlarm);
// await _redis.SetWanjiaanAlarmEvent(event_id, wanjiaanAlarm);
//}

#endregion
}
}
}


Notiek ielāde…
Atcelt
Saglabāt