|
@@ -13,6 +13,7 @@ from django.views import View
|
|
|
|
|
|
from Model.models import SwitchDimmingSettings, SwitchChronopher, Device_Info, SceneLog, FamilyRoomDevice, \
|
|
from Model.models import SwitchDimmingSettings, SwitchChronopher, Device_Info, SceneLog, FamilyRoomDevice, \
|
|
SwitchOperateLog
|
|
SwitchOperateLog
|
|
|
|
+from Object.RedisObject import RedisObject
|
|
from Service.CommonService import CommonService
|
|
from Service.CommonService import CommonService
|
|
from Object.ApschedulerObject import ApschedulerObject
|
|
from Object.ApschedulerObject import ApschedulerObject
|
|
from django.db import transaction
|
|
from django.db import transaction
|
|
@@ -61,7 +62,6 @@ class SmartSwitchView(View):
|
|
else:
|
|
else:
|
|
return response.json(414)
|
|
return response.json(414)
|
|
|
|
|
|
-
|
|
|
|
@staticmethod
|
|
@staticmethod
|
|
def get_dimming_setting(request_dict, response):
|
|
def get_dimming_setting(request_dict, response):
|
|
"""
|
|
"""
|
|
@@ -363,10 +363,18 @@ class SmartSwitchView(View):
|
|
"""
|
|
"""
|
|
now_time = int(time.time())
|
|
now_time = int(time.time())
|
|
msg['implementTime'] = now_time
|
|
msg['implementTime'] = now_time
|
|
|
|
+ redis_obj = RedisObject()
|
|
|
|
+ is_lock = redis_obj.CONN.setnx(task_id + 'do_notify', 1)
|
|
|
|
+ redis_obj.CONN.expire(task_id + 'do_notify', 60)
|
|
|
|
+ if not is_lock:
|
|
|
|
+ LOGGER.info('定时发送mqtt结果:{},参数:{},{},{},{},{},线程:{},进程:{}'.format(False, serial_number, topic_name, msg,
|
|
|
|
+ now_time, task_id,
|
|
|
|
+ threading.get_ident(), os.getpid()))
|
|
result = CommonService.req_publish_mqtt_msg(serial_number, topic_name, msg)
|
|
result = CommonService.req_publish_mqtt_msg(serial_number, topic_name, msg)
|
|
LOGGER.info('定时发送mqtt结果:{},参数:{},{},{},{},{},线程:{},进程:{}'.format(result, serial_number, topic_name, msg,
|
|
LOGGER.info('定时发送mqtt结果:{},参数:{},{},{},{},{},线程:{},进程:{}'.format(result, serial_number, topic_name, msg,
|
|
now_time, task_id,
|
|
now_time, task_id,
|
|
threading.get_ident(), os.getpid()))
|
|
threading.get_ident(), os.getpid()))
|
|
|
|
+ redis_obj.del_data(key=task_id + 'do_notify')
|
|
|
|
|
|
@staticmethod
|
|
@staticmethod
|
|
def create_chronopher_log(request_dict, response):
|
|
def create_chronopher_log(request_dict, response):
|