dispath event 优化

This commit is contained in:
曹前明 2022-09-23 09:56:19 +08:00
parent 48f4b22c6a
commit 600a1785f8
1 changed files with 3 additions and 1 deletions

View File

@ -337,6 +337,8 @@ def dispatch_dahua_event(data: dict):
'event': event
})
elif 300 < alarm_type < 1000 and vchannel: # 其他智能通道报警
global_img_o = dhClient.get_full_pic(data['info']['alarmPicture'])
happen_time = timestamp_to_time(int(data['info']['alarmDate']))
algo_channels = AlgoChannel.objects.filter(vchannel=vchannel, algo__self_algo=True).exclude(
algo__code=None).order_by('algo__priority', 'algo__create_time').values('id', 'algo', 'algo__code')
cates = [] # 触发的事件种类
@ -357,7 +359,7 @@ def dispatch_dahua_event(data: dict):
event.area = vchannel.area
event.obj_cate = 'other'
event.vchannel = vchannel
event.happen_time = timestamp_to_time(int(data['info']['alarmDate']))
event.happen_time = happen_time
event.save()
for i in cates:
Eventdo.objects.get_or_create(cate=i, event=event, defaults={