批量创建的id生成
This commit is contained in:
parent
c9a147f27c
commit
a08500ab8c
|
@ -0,0 +1,62 @@
|
|||
import json
|
||||
xx = {'id': 1656652947266,
|
||||
'category': 'alarm',
|
||||
'method': 'alarm.msg',
|
||||
'info':
|
||||
{'orgName': '根节点',
|
||||
'nodeCode': '1000038$1$0$0',
|
||||
'deviceCode': '1000038',
|
||||
'alarmCode': 'd05cbd72-9791-4865-8425-bd5015d8c76f',
|
||||
'alarmPicture': '6ad010cf-ce45-11ec-9715-e4246c7d1635/20220622/1/dsf_453810dc-f202-11ec-bd2d-e4246c7d1635_54513095_54528684.jpg',
|
||||
'nodeType': 2,
|
||||
'alarmDate': '1656652943',
|
||||
'alarmGrade': 2,
|
||||
'isSave': True,
|
||||
'extend':
|
||||
{
|
||||
'faceImageUrl': ['6ad010cf-ce45-11ec-9715-e4246c7d1635/20220622/1/dsf_453810dc-f202-11ec-bd2d-e4246c7d1635_54513095_54528684.jpg'],
|
||||
'glass': 0,
|
||||
'beard': 0,
|
||||
'candidateInfo': [
|
||||
{'birthday': '2022-6-24',
|
||||
'faceImageUrl': ['6ad010cf-ce45-11ec-9715-e4246c7d1635/20220622/1/dsf_453810dc-f202-11ec-bd2d-e4246c7d1635_54528684_54605683.jpg'],
|
||||
'groupName': '内部库1',
|
||||
'similarity': 98,
|
||||
'sex': 2,
|
||||
'cardType': 1,
|
||||
'name': '石静',
|
||||
'devPersonId': '4',
|
||||
'id': '371324199502156548',
|
||||
'type': 0}],
|
||||
'sex': 0,
|
||||
'occurrenceCount': 0,
|
||||
'deviceCode': '1000038',
|
||||
'globalScenePicUrl': '6ad010cf-ce45-11ec-9715-e4246c7d1635/20220622/1/dsf_453810dc-f202-11ec-bd2d-e4246c7d1635_54421218_54513095.jpg',
|
||||
'eye': 0,
|
||||
'alarmType': 1001003,
|
||||
'perFlag': -1,
|
||||
'mouth': 0,
|
||||
'feature': [],
|
||||
'isHit': True,
|
||||
'channelSeq': 0,
|
||||
'szSerialUUID': '',
|
||||
'channelName': '测试摄像头1',
|
||||
'beginTime': 1656652943,
|
||||
'endTime': 1656652943,
|
||||
'age': -1,
|
||||
'mask': 0},
|
||||
'unitType': 1,
|
||||
'alarmType': 1001003,
|
||||
'channelSeq': 0,
|
||||
'orgCode': '001',
|
||||
'channelName':
|
||||
'测试摄像头1',
|
||||
'alarmStat': 1,
|
||||
'isEvent': True},
|
||||
'subsystem': 'evo-face',
|
||||
'userIds': None,
|
||||
'sid': None,
|
||||
'domainId': None,
|
||||
'infoArray': None,
|
||||
'protocol': None}
|
||||
print(json.dumps(xx))
|
|
@ -77,7 +77,8 @@ class Event(CommonBModel):
|
|||
(20, '误报'),
|
||||
)
|
||||
cates = models.ManyToManyField(EventCate, verbose_name='关联事件种类', through='ecm.eventdo')
|
||||
imgs = models.ManyToManyField(File, verbose_name='事件图片', blank=True)
|
||||
face_img = models.CharField('人脸照', max_length=1000, null=True, blank=True)
|
||||
global_img = models.CharField('全景照', max_length=1000, null=True, blank=True)
|
||||
area = models.ForeignKey(Area, verbose_name='发生区域', on_delete=models.CASCADE)
|
||||
location = models.JSONField('事件点位坐标', default=dict, null=False, blank=True)
|
||||
obj_cate = models.CharField('发生对象', max_length=20, help_text='people(人员)/...')
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
|
||||
|
||||
import requests
|
||||
from apps.am.models import Access, Area
|
||||
from apps.am.tasks import cache_areas_info
|
||||
from apps.ecm.models import EventCate
|
||||
from apps.hrm.models import Employee
|
||||
from apps.system.models import User
|
||||
from apps.third.clients import xxClient
|
||||
|
@ -11,6 +13,7 @@ from apps.utils.queryset import get_child_queryset2
|
|||
from django.core.cache import cache
|
||||
import time
|
||||
import shapely.geometry
|
||||
from apps.third.clients import dhClient
|
||||
|
||||
|
||||
def get_area_info_from_cache(target: str, cache: list):
|
||||
|
@ -19,6 +22,14 @@ def get_area_info_from_cache(target: str, cache: list):
|
|||
return i
|
||||
return None
|
||||
|
||||
# def save_dahua_pic(pic:str):
|
||||
# """保存大华报警图片到本地
|
||||
# 返回本地路径
|
||||
# """
|
||||
# full_url = dhClient.get_full_pic(pic)
|
||||
# res = requests.get(url=full_url)
|
||||
# file_path = idwo
|
||||
|
||||
|
||||
class EcmService:
|
||||
"""事件处理服务
|
||||
|
@ -43,7 +54,18 @@ class EcmService:
|
|||
def dispatch_dahua_event(cls, data: dict):
|
||||
"""分发大华事件进行处理
|
||||
"""
|
||||
pass
|
||||
vchannel_code = data['info']['nodeCode']
|
||||
alarm_type = data['info']['alarmType']
|
||||
vchannel = TDevice.objects.filter(code=vchannel_code).first()
|
||||
if alarm_type == 1001003 and vchannel: # 内部人员报警
|
||||
# 加载算法逻辑
|
||||
# 安全帽检测
|
||||
ec = EventCate.objects.filter(code='helmet').first()
|
||||
# 视频区域
|
||||
area = vchannel.area
|
||||
if ec and area:
|
||||
# 保存照片
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def dispatch_xunxi_event(cls, data: dict):
|
||||
|
@ -75,10 +97,10 @@ class EcmService:
|
|||
elif data.type == 'bltOnOffLineV2':
|
||||
if data.data.online:
|
||||
# 标签通信在线
|
||||
pass
|
||||
cls.blt_online(data=data.data)
|
||||
else:
|
||||
# 标签通信离线
|
||||
pass
|
||||
cls.blt_offline(data=data.data)
|
||||
|
||||
@classmethod
|
||||
def rail_in(cls, data):
|
||||
|
@ -199,3 +221,11 @@ class EcmService:
|
|||
ep_loc_dict['are_id'] = i['area_fix_id']
|
||||
ep_loc_dict['time2'] = time2
|
||||
cache.set(key_str, ep_loc_dict)
|
||||
|
||||
@classmethod
|
||||
def blt_online(cls, data):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def blt_offline(cls, data):
|
||||
pass
|
||||
|
|
|
@ -9,6 +9,7 @@ from rest_framework.decorators import action
|
|||
from rest_framework import serializers
|
||||
from django.utils import timezone
|
||||
from rest_framework.response import Response
|
||||
from apps.utils.snowflake import idWorker
|
||||
|
||||
|
||||
# Create your views here.
|
||||
|
@ -27,6 +28,7 @@ class AlgoChannelViewSet(CreateModelMixin, DestroyModelMixin, ListModelMixin, Cu
|
|||
queryset = AlgoChannel.objects.all()
|
||||
create_serializer_class = AlgoChannelCreateSerializer
|
||||
serializer_class = AlgoChannelSerializer
|
||||
filterset_fields = ['algo']
|
||||
|
||||
@transaction.atomic
|
||||
@action(methods=['post'], detail=False, perms_map={'post': 'event_cate:update'},
|
||||
|
@ -41,7 +43,7 @@ class AlgoChannelViewSet(CreateModelMixin, DestroyModelMixin, ListModelMixin, Cu
|
|||
vdata = serializer.validated_data
|
||||
acs = []
|
||||
for i in vdata['vchannels']:
|
||||
acs.append(AlgoChannel(algo=vdata['algo'], vchannel=i))
|
||||
acs.append(AlgoChannel(id=idWorker.get_id(), algo=vdata['algo'], vchannel=i))
|
||||
AlgoChannel.objects.bulk_create(objs=acs, ignore_conflicts=False)
|
||||
return Response()
|
||||
|
||||
|
|
Loading…
Reference in New Issue