测试一键报警/围栏进入事件
This commit is contained in:
parent
ce39ff84ac
commit
3e38c6b23c
|
@ -9,7 +9,7 @@ from apps.develop.serializers import CleanDataSerializer, GenerateVoiceSerialize
|
|||
TestTaskSerializer, TestAlgoSerializer
|
||||
from apps.develop.tasks import backup_database, backup_media, reload_web_git, reload_server_git, reload_server_only
|
||||
from rest_framework.exceptions import APIException
|
||||
from apps.ecm.service import check_not_in_place, create_remind, notify_event, snap_and_analyse
|
||||
from apps.ecm.service import check_not_in_place, create_remind, handle_xx_event, loc_change, notify_event, rail_in, snap_and_analyse
|
||||
from apps.ecm.tasks import opl_task
|
||||
from apps.opm.models import Opl
|
||||
from apps.system.tasks import show
|
||||
|
@ -245,6 +245,40 @@ class TestViewSet(CustomGenericViewSet):
|
|||
cache.set('test_snap_task', [])
|
||||
return Response()
|
||||
|
||||
@action(methods=['post'], detail=False, serializer_class=Serializer)
|
||||
def test_loc_change(self, request, pk=None):
|
||||
"""位置信息改变
|
||||
|
||||
位置信息改变
|
||||
"""
|
||||
data = {'buildId': '204878', 'floorNo': 'Floor1', 'userId': '1918B20019F5', 'timestampMillisecond': 1663064881805, 'xMillimeter': 316654, 'yMillimeter': 361852,
|
||||
'zMillimeter': 0, 'pointProperties': 0, 'locationType': 1, 'status': 2, 'src': 0, 'longitude': 114.7395738002794, 'latitude': 38.621726856149856}
|
||||
res = loc_change(data=data)
|
||||
return Response(res)
|
||||
|
||||
@action(methods=['post'], detail=False, serializer_class=Serializer)
|
||||
def test_one_key_alarm(self, request, pk=None):
|
||||
"""一键报警事件
|
||||
|
||||
一键报警事件
|
||||
"""
|
||||
data = {'buildId': '204878', 'mac': '1918B20019F5',
|
||||
'time': 1663067822887, 'event': 'alarm', 'alarmTypeName': '一键报警'}
|
||||
res = handle_xx_event(name='one_key_alarm', data=data)
|
||||
return Response(res)
|
||||
|
||||
|
||||
@action(methods=['post'], detail=False, serializer_class=Serializer)
|
||||
def test_rail_in(self, request, pk=None):
|
||||
"""测试围栏进入
|
||||
|
||||
测试围栏进入
|
||||
"""
|
||||
data = {'railId': '80fe94bff7b240aa893976965197487c', 'userId': '1918B20019F5',"railName":"二道门",
|
||||
'time': 1663067822887, "type":1, "buildId": "204878", "floorNo":"Floor1"}
|
||||
res = rail_in(data=data)
|
||||
return Response(res)
|
||||
|
||||
@action(methods=['post'], detail=False, serializer_class=Serializer)
|
||||
def test_not_in_place(self, request, pk=None):
|
||||
check_not_in_place(Opl.objects.get(id='1568880208688320512'))
|
||||
|
|
|
@ -152,7 +152,7 @@ def create_remind(event: Event, params: dict):
|
|||
# t_sms.start()
|
||||
# 查找所有提醒配置
|
||||
n_s = NotifySetting.objects.filter(event_cate__in=event.cates.all()).order_by('sort')
|
||||
area_level = event.area.level
|
||||
area_level = event.area.level if event.area else Area.AREA_4
|
||||
for i in n_s:
|
||||
if i.user and area_level >= i.filter_area_level:
|
||||
Remind.objects.get_or_create(event=event, recipient=i.user,
|
||||
|
@ -408,29 +408,24 @@ def rail_in(data):
|
|||
return
|
||||
elif ep_blt.belong_dept in depts and i.type == Access.ACCESS_IN_NO:
|
||||
# 触发违规进入事件
|
||||
handle_xx_event_2('i_enter', ep=ep_blt, area=area)
|
||||
return handle_xx_event_2('i_enter', ep=ep_blt, area=area)
|
||||
elif i.dept.type == 'rparty': # 如果是相关方
|
||||
if ep_blt.belong_dept == i.dept and i.type == Access.ACCESS_IN_YES:
|
||||
return
|
||||
elif ep_blt.belong_dept == i.dept and i.type == Access.ACCESS_IN_NO:
|
||||
# 触发违规进入事件
|
||||
handle_xx_event_2('i_enter', ep=ep_blt, area=area)
|
||||
return handle_xx_event_2('i_enter', ep=ep_blt, area=area)
|
||||
elif i.employee: # 如果是按人设定的
|
||||
if ep_blt == i.employee and i.type == Access.ACCESS_IN_YES:
|
||||
return
|
||||
elif ep_blt == i.employee and i.type == Access.ACCESS_IN_NO:
|
||||
# 触发违规进入事件
|
||||
handle_xx_event_2('i_enter', ep=ep_blt, area=area)
|
||||
return handle_xx_event_2('i_enter', ep=ep_blt, area=area)
|
||||
# 通用权限设置过滤
|
||||
if ep_blt.type == 'employee' and area.employee_yes:
|
||||
return
|
||||
elif ep_blt.type == 'remployee' and area.remployee_yes:
|
||||
return
|
||||
elif ep_blt.type == 'visitor' and area.visitor_yes:
|
||||
return
|
||||
else:
|
||||
access_list = area.access_list
|
||||
if ep_blt.type not in access_list:
|
||||
# 触发违规进入事件
|
||||
handle_xx_event_2('i_enter', ep=ep_blt, area=area)
|
||||
return handle_xx_event_2('i_enter', ep=ep_blt, area=area)
|
||||
# elif area and (not blts):
|
||||
# # 触发未知标签进入事件
|
||||
# e_i_enter(ep=ep_blt, area=area)
|
||||
|
@ -473,11 +468,13 @@ def loc_change(data):
|
|||
ep_loc_dict['time1'] = time2
|
||||
ep_loc_dict['area_fix_id'] = area_fix['id'] if area_fix else None
|
||||
cache.set(key_str, ep_loc_dict)
|
||||
return ep_loc_dict
|
||||
|
||||
|
||||
def handle_xx_event(name: str, data: dict):
|
||||
# 有绑定对象再提示事件
|
||||
blts = TDevice.objects.filter(code=data['mac']).first()
|
||||
ep_loc_dict = {}
|
||||
if blts.employee:
|
||||
# 触发事件
|
||||
cate = EventCate.objects.filter(code=name).first()
|
||||
|
@ -499,6 +496,7 @@ def handle_xx_event(name: str, data: dict):
|
|||
'event': event
|
||||
})
|
||||
notify_event(event)
|
||||
return ep_loc_dict
|
||||
|
||||
|
||||
def handle_xx_event_2(name: str, ep: Employee, area: Area):
|
||||
|
@ -512,10 +510,10 @@ def handle_xx_event_2(name: str, ep: Employee, area: Area):
|
|||
elif ops.filter(coordinator__employee=ep).exists():
|
||||
# 如果是协调员
|
||||
return
|
||||
elif Opl.objects.filter(operation=ops, charger__employee=ep).exists():
|
||||
elif Opl.objects.filter(operation__in=ops, charger__employee=ep).exists():
|
||||
# 如果是作业负责人
|
||||
return
|
||||
elif Opl.objects.filter(operation=ops, monitor__employee=ep).exists():
|
||||
elif Opl.objects.filter(operation__in=ops, monitor__employee=ep).exists():
|
||||
# 如果是作业监护人
|
||||
return
|
||||
cate = EventCate.objects.filter(code=name).first()
|
||||
|
|
Loading…
Reference in New Issue