喇叭接口异常
This commit is contained in:
parent
60a8d6fc9c
commit
3326f9c730
|
@ -3,7 +3,7 @@ from apps.utils.task import CustomTask
|
||||||
from apps.am.models import Area
|
from apps.am.models import Area
|
||||||
from celery import shared_task
|
from celery import shared_task
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
import shapely.geometry
|
from shapely.geometry import Polygon
|
||||||
|
|
||||||
|
|
||||||
@shared_task(base=CustomTask)
|
@shared_task(base=CustomTask)
|
||||||
|
@ -13,15 +13,14 @@ def cache_areas_info():
|
||||||
"""
|
"""
|
||||||
area_fix_list = []
|
area_fix_list = []
|
||||||
for i in Area.objects.filter(type=Area.AREA_TYPE_FIX).exclude(third_info__xx_rail=None):
|
for i in Area.objects.filter(type=Area.AREA_TYPE_FIX).exclude(third_info__xx_rail=None):
|
||||||
polygon = []
|
points = []
|
||||||
for item in i.third_info['xx_rail']['detail']['polygon']['points']:
|
for item in i.third_info['xx_rail']['detail']['polygon']['points']:
|
||||||
polygon.append([item.x, item.y])
|
points.append((item['x'], item['y']))
|
||||||
poly_context = {'type': 'MULTIPOLYGON',
|
|
||||||
'coordinates': [[area_fix_list]]}
|
|
||||||
area_dict = {
|
area_dict = {
|
||||||
'id': i.id,
|
'id': i.id,
|
||||||
'floor_no': i.third_info['xx_rail']['detail']['floorNo'],
|
'floor_no': i.third_info['xx_rail']['detail']['floorNo'],
|
||||||
'poly_shape': shapely.geometry.asShape(poly_context),
|
'polygon': Polygon(points),
|
||||||
'stay_minute_min': i.stay_minute_min,
|
'stay_minute_min': i.stay_minute_min,
|
||||||
'stay_minute_max': i.stay_minute_max
|
'stay_minute_max': i.stay_minute_max
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
|
from apps.am.tasks import cache_areas_info
|
||||||
from apps.am.views import AreaViewSet, AccessViewSet
|
from apps.am.views import AreaViewSet, AccessViewSet
|
||||||
from django.urls import path, include
|
from django.urls import path, include
|
||||||
from rest_framework.routers import DefaultRouter
|
from rest_framework.routers import DefaultRouter
|
||||||
|
|
||||||
API_BASE_URL = 'api/am/'
|
API_BASE_URL = 'api/am/'
|
||||||
HTML_BASE_URL = 'am/'
|
HTML_BASE_URL = 'am/'
|
||||||
|
cache_areas_info()
|
||||||
router = DefaultRouter()
|
router = DefaultRouter()
|
||||||
router.register('area', AreaViewSet, basename='area')
|
router.register('area', AreaViewSet, basename='area')
|
||||||
router.register('access', AccessViewSet, basename='access')
|
router.register('access', AccessViewSet, basename='access')
|
||||||
|
|
|
@ -12,7 +12,7 @@ from apps.third.tapis import xxapis
|
||||||
from apps.utils.queryset import get_child_queryset2, get_parent_queryset
|
from apps.utils.queryset import get_child_queryset2, get_parent_queryset
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
import time
|
import time
|
||||||
import shapely.geometry
|
from shapely.geometry import Point
|
||||||
from apps.third.clients import dhClient, spClient
|
from apps.third.clients import dhClient, spClient
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
@ -403,8 +403,8 @@ def loc_change(data):
|
||||||
else:
|
else:
|
||||||
for i in area_fix_list:
|
for i in area_fix_list:
|
||||||
if data['floorNo'] == i['floor_no']:
|
if data['floorNo'] == i['floor_no']:
|
||||||
point = shapely.geometry.Point(data['xMillimeter'], data['yMillimeter'])
|
point = Point(data['xMillimeter'], data['yMillimeter'])
|
||||||
if i['poly_shape'].intersects(point): # 如果点在多边形中
|
if i['polygon'].intersects(point): # 如果点在多边形中
|
||||||
ep_loc_dict['time1'] = time2
|
ep_loc_dict['time1'] = time2
|
||||||
ep_loc_dict['are_id'] = i['area_fix_id']
|
ep_loc_dict['are_id'] = i['area_fix_id']
|
||||||
ep_loc_dict['time2'] = time2
|
ep_loc_dict['time2'] = time2
|
||||||
|
|
|
@ -97,7 +97,7 @@ class LogView(APIView):
|
||||||
logs.append({
|
logs.append({
|
||||||
"name": file,
|
"name": file,
|
||||||
"filepath": filepath,
|
"filepath": filepath,
|
||||||
"size": round(fsize/1000, 1)
|
"size": round(fsize/1024, 1)
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
fsize = os.path.getsize(filepath)
|
fsize = os.path.getsize(filepath)
|
||||||
|
@ -105,7 +105,7 @@ class LogView(APIView):
|
||||||
logs.append({
|
logs.append({
|
||||||
"name": file,
|
"name": file,
|
||||||
"filepath": filepath,
|
"filepath": filepath,
|
||||||
"size": round(fsize/1000, 1)
|
"size": round(fsize/1024, 1)
|
||||||
})
|
})
|
||||||
return Response(logs)
|
return Response(logs)
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ def get_op_monitor(state, ticket, new_ticket_data, handler):
|
||||||
if opl:
|
if opl:
|
||||||
return [opl.monitor.id]
|
return [opl.monitor.id]
|
||||||
|
|
||||||
|
|
||||||
def bind_opl(ticket: Ticket, transition: Transition, new_ticket_data: dict):
|
def bind_opl(ticket: Ticket, transition: Transition, new_ticket_data: dict):
|
||||||
opl = Opl.objects.get(id=new_ticket_data['opl'])
|
opl = Opl.objects.get(id=new_ticket_data['opl'])
|
||||||
ticket_data = ticket.ticket_data
|
ticket_data = ticket.ticket_data
|
||||||
|
|
|
@ -326,6 +326,7 @@ class TDeviceViewSet(ListModelMixin, UpdateModelMixin, DestroyModelMixin, Custom
|
||||||
|
|
||||||
喇叭列表
|
喇叭列表
|
||||||
"""
|
"""
|
||||||
|
# print(request.data)
|
||||||
_, res = spClient.request(**spapis['device_list'], params=request.data)
|
_, res = spClient.request(**spapis['device_list'], params=request.data)
|
||||||
codes = []
|
codes = []
|
||||||
for i in res['rows']:
|
for i in res['rows']:
|
||||||
|
|
Loading…
Reference in New Issue