|
@@ -11,6 +11,7 @@ from django.views.generic.base import View
|
|
|
from AnsjerPush.Config.gatewaySensorConfig import SENSOR_TYPE, EVENT_TYPE
|
|
|
from AnsjerPush.config import LOGGER, XM_PUSH_CHANNEL_ID
|
|
|
from Model.models import SensorRecord, GatewaySubDevice, GatewayPush, Device_Info, SceneLog, SmartScene, CountryModel
|
|
|
+from Object.RedisObject import RedisObject
|
|
|
from Object.ResponseObject import ResponseObject
|
|
|
from Service.EquipmentInfoService import EquipmentInfoService
|
|
|
from Service.HuaweiPushService.HuaweiPushService import HuaweiPushObject
|
|
@@ -291,6 +292,15 @@ class GatewayView(View):
|
|
|
"""
|
|
|
scene_id = request_dict.get('sceneId', None)
|
|
|
status = request_dict.get('status', None)
|
|
|
+
|
|
|
+ # 防止定时任务同时请求生成多条场景日志
|
|
|
+ redis_obj = RedisObject()
|
|
|
+ key = scene_id + 'scene_log_limit'
|
|
|
+ is_lock = redis_obj.CONN.setnx(key, 1)
|
|
|
+ redis_obj.CONN.expire(key, 60)
|
|
|
+ if not is_lock:
|
|
|
+ return response.json(0)
|
|
|
+
|
|
|
LOGGER.info('---场景日志推送接口--- request_dict:{}'.format(request_dict))
|
|
|
if not all([scene_id, status]):
|
|
|
return response.json(444)
|