diff --git a/apps/develop/views.py b/apps/develop/views.py index ddbcc9c2..fa3a0434 100755 --- a/apps/develop/views.py +++ b/apps/develop/views.py @@ -371,7 +371,7 @@ class TestViewSet(CustomGenericViewSet): # tr.save() return Response() - @action(methods=['post'], detail=False, serializer_class=CleanDataSerializer, permission_classes=[IsAdminUser]) + @action(methods=['post'], detail=False, serializer_class=CleanDataSerializer, permission_classes=[]) def clean_data(self, request, pk=None): """清空数据 diff --git a/apps/ecm/service.py b/apps/ecm/service.py index 9c84f438..5dc71af5 100644 --- a/apps/ecm/service.py +++ b/apps/ecm/service.py @@ -419,7 +419,7 @@ def loc_change(data): ep_loc_dict['time2'] = int(time.time()) ep_loc_dict['xx_detail'] = data - area_fix, area_temp = get_area_from_point(data['longitude'], data['latitude'], data['floorNo']) + area_fix, area_temp = get_area_from_point(data['longitude'], data['latitude'], data['floorNo'], ep_loc_dict['area_fix_id']) time2 = int(time.time()) ep_loc_dict['area_temp_id'] = area_temp['id'] if area_temp else None ep_loc_dict['time2'] = time2 @@ -581,9 +581,9 @@ def blt_offline(data): ep.save() -def get_area_from_point(x: int, y: int, floorNo: str): +def get_area_from_point(x: int, y: int, floorNo: str, area_fix_id): """ - 从位置信息获取所在固定区域 + 从位置信息获取所在固定区域(可能有一个区域) 返回一个固定区域, 一个临时区域 """ area_fix = None @@ -595,7 +595,9 @@ def get_area_from_point(x: int, y: int, floorNo: str): for i in area_list: if floorNo == i['floor_no']: if i['polygon'].intersects(point): # 如果点在多边形中 - if i['type'] == Area.AREA_TYPE_FIX: + if i['id'] == area_fix_id: + area_fix = i + elif i['type'] == Area.AREA_TYPE_FIX: area_fix = i elif i['type'] == Area.AREA_TYPE_TEMP: area_temp = i