区域绑定功能
This commit is contained in:
parent
16c46902c1
commit
18344bd121
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 3.2.12 on 2022-06-25 01:47
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('am', '0002_auto_20220625_0819'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='area',
|
||||||
|
name='count_people',
|
||||||
|
field=models.PositiveIntegerField(default=0, verbose_name='当前人数'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -34,6 +34,7 @@ class Area(CommonBModel):
|
||||||
posts_access = models.ManyToManyField(Post, through='am.access')
|
posts_access = models.ManyToManyField(Post, through='am.access')
|
||||||
count_people_min = models.PositiveIntegerField('最小人员数', default=0)
|
count_people_min = models.PositiveIntegerField('最小人员数', default=0)
|
||||||
count_people_max = models.PositiveIntegerField('最大人员数', default=1000)
|
count_people_max = models.PositiveIntegerField('最大人员数', default=1000)
|
||||||
|
count_people = models.PositiveIntegerField('当前人数', default=0)
|
||||||
third_info = models.JSONField('三方信息', default=dict,
|
third_info = models.JSONField('三方信息', default=dict,
|
||||||
null=False, blank=True)
|
null=False, blank=True)
|
||||||
|
|
||||||
|
|
|
@ -28,14 +28,14 @@ class AreaViewSet(CustomModelViewSet):
|
||||||
obj = self.get_object()
|
obj = self.get_object()
|
||||||
third_info = obj.third_info
|
third_info = obj.third_info
|
||||||
if 'xx_rail' in third_info:
|
if 'xx_rail' in third_info:
|
||||||
data['uuid'] = third_info['xx_rail']['uuid']
|
data['id'] = third_info['xx_rail']['id']
|
||||||
_, res = xxClient.request(**xxapis['rail_update'], json=data)
|
_, res = xxClient.request(**xxapis['rail_update'], json=data)
|
||||||
third_info['xx_rail']['detail'] = data
|
third_info['xx_rail']['detail'] = data
|
||||||
obj.third_info = third_info
|
obj.third_info = third_info
|
||||||
obj.save()
|
obj.save()
|
||||||
else:
|
else:
|
||||||
_, res = xxClient.request(**xxapis['rail_create'], json=data)
|
_, res = xxClient.request(**xxapis['rail_create'], json=data)
|
||||||
rail_info = {'uuid': res, 'detail': data}
|
rail_info = {'id': res, 'detail': data}
|
||||||
third_info['xx_rail'] = rail_info
|
third_info['xx_rail'] = rail_info
|
||||||
obj.third_info = third_info
|
obj.third_info = third_info
|
||||||
obj.save()
|
obj.save()
|
||||||
|
|
|
@ -4,10 +4,17 @@ from apps.am.models import Area
|
||||||
from apps.third.clients import xxClient
|
from apps.third.clients import xxClient
|
||||||
from apps.third.tapis import xxapis
|
from apps.third.tapis import xxapis
|
||||||
|
|
||||||
|
|
||||||
class EcmService:
|
class EcmService:
|
||||||
"""事件处理服务
|
"""事件处理服务
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def create_remind(cls):
|
||||||
|
"""
|
||||||
|
创建事件提醒并发送通知
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def dispatch_dahua_event(cls, data: dict):
|
def dispatch_dahua_event(cls, data: dict):
|
||||||
"""分发大华事件进行处理
|
"""分发大华事件进行处理
|
||||||
|
@ -51,10 +58,12 @@ class EcmService:
|
||||||
"""围栏进入事件
|
"""围栏进入事件
|
||||||
"""
|
"""
|
||||||
# 判断区域是否超员
|
# 判断区域是否超员
|
||||||
area = Area.objects.filter(third_info__xx_railId=data['railId']).first()
|
area = Area.objects.filter(third_info__xx_rail__id=data['railId']).first()
|
||||||
if area:
|
if area:
|
||||||
json = {"railId": data['railId'], "type": ""}
|
json = {"railId": data['railId'], "type": ""}
|
||||||
_, res = xxClient.request(**xxapis['rail_ibeacon_list'], json=json)
|
_, res = xxClient.request(**xxapis['rail_ibeacon_list'], json=json)
|
||||||
if res['totalCount'] >= area.count_people_max:
|
if res['totalCount'] >= area.count_people_max:
|
||||||
# 触发超员事件
|
# 触发超员事件
|
||||||
|
area.count_people = res['totalCount']
|
||||||
|
area.save()
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in New Issue