测试区域缺员超员
This commit is contained in:
parent
3e38c6b23c
commit
cf531a5463
|
@ -26,4 +26,8 @@ class TestAlgoSerializer(serializers.Serializer):
|
||||||
|
|
||||||
|
|
||||||
class SpeakerSerializer(serializers.Serializer):
|
class SpeakerSerializer(serializers.Serializer):
|
||||||
sns = serializers.ListField(child=serializers.CharField(), label="喇叭列表")
|
sns = serializers.ListField(child=serializers.CharField(), label="喇叭列表")
|
||||||
|
|
||||||
|
|
||||||
|
class AreaManSerializer(serializers.Serializer):
|
||||||
|
area = serializers.CharField()
|
|
@ -5,12 +5,13 @@ from rest_framework.permissions import IsAdminUser
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework.serializers import Serializer
|
from rest_framework.serializers import Serializer
|
||||||
from rest_framework.decorators import action
|
from rest_framework.decorators import action
|
||||||
from apps.develop.serializers import CleanDataSerializer, GenerateVoiceSerializer, SendSmsSerializer, SpeakerSerializer, \
|
from apps.am.models import Area
|
||||||
|
from apps.develop.serializers import AreaManSerializer, CleanDataSerializer, GenerateVoiceSerializer, SendSmsSerializer, SpeakerSerializer, \
|
||||||
TestTaskSerializer, TestAlgoSerializer
|
TestTaskSerializer, TestAlgoSerializer
|
||||||
from apps.develop.tasks import backup_database, backup_media, reload_web_git, reload_server_git, reload_server_only
|
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 rest_framework.exceptions import APIException
|
||||||
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.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.ecm.tasks import opl_task, update_count_people
|
||||||
from apps.opm.models import Opl
|
from apps.opm.models import Opl
|
||||||
from apps.system.tasks import show
|
from apps.system.tasks import show
|
||||||
from apps.third.clients import dhClient
|
from apps.third.clients import dhClient
|
||||||
|
@ -278,6 +279,15 @@ class TestViewSet(CustomGenericViewSet):
|
||||||
'time': 1663067822887, "type":1, "buildId": "204878", "floorNo":"Floor1"}
|
'time': 1663067822887, "type":1, "buildId": "204878", "floorNo":"Floor1"}
|
||||||
res = rail_in(data=data)
|
res = rail_in(data=data)
|
||||||
return Response(res)
|
return Response(res)
|
||||||
|
|
||||||
|
@action(methods=['post'], detail=False, serializer_class=AreaManSerializer)
|
||||||
|
def test_area_man(self, request, pk=None):
|
||||||
|
"""测试区域超员/缺员事件
|
||||||
|
|
||||||
|
测试区域超员/缺员事件
|
||||||
|
"""
|
||||||
|
res = update_count_people(i=Area.objects.get(id=request.data['area']))
|
||||||
|
return Response(res)
|
||||||
|
|
||||||
@action(methods=['post'], detail=False, serializer_class=Serializer)
|
@action(methods=['post'], detail=False, serializer_class=Serializer)
|
||||||
def test_not_in_place(self, request, pk=None):
|
def test_not_in_place(self, request, pk=None):
|
||||||
|
|
|
@ -18,7 +18,6 @@ import time
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@shared_task
|
@shared_task
|
||||||
def update_count_people(i: Area):
|
def update_count_people(i: Area):
|
||||||
if i.third_info.get('xx_rail', None):
|
if i.third_info.get('xx_rail', None):
|
||||||
|
@ -38,6 +37,7 @@ def update_count_people(i: Area):
|
||||||
elif i.count_people < i.count_people_min:
|
elif i.count_people < i.count_people_min:
|
||||||
# 触发缺员事件
|
# 触发缺员事件
|
||||||
handle_xx_event_3('lack_man', i)
|
handle_xx_event_3('lack_man', i)
|
||||||
|
return {'count': i.count_people}
|
||||||
|
|
||||||
|
|
||||||
def handle_xx_event_3(name: str, area: Area):
|
def handle_xx_event_3(name: str, area: Area):
|
||||||
|
@ -52,7 +52,7 @@ def handle_xx_event_3(name: str, area: Area):
|
||||||
'cate': cate,
|
'cate': cate,
|
||||||
'event': event
|
'event': event
|
||||||
})
|
})
|
||||||
voice_msg = area.name + '下有' + str(area.count) + '人,' + cate.name + ',请及时处理'
|
voice_msg = area.name + '下有' + str(area.count_people) + '人,' + cate.name + ',请及时处理'
|
||||||
notify_event(event, voice_msg=voice_msg)
|
notify_event(event, voice_msg=voice_msg)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue