|
@@ -199,7 +199,7 @@ class GatewaySubDeviceView(View):
|
|
|
@param request_dict: 请求参数
|
|
|
@request_dict gatewaySubId: 子设备id
|
|
|
@request_dict cycle: 时间周期
|
|
|
- @request_dict eventType: 事件类型, 18:温度,19:湿度
|
|
|
+ @request_dict eventType: 事件类型, 2200:温度,2201:湿度
|
|
|
@param response: 响应对象
|
|
|
@return: response
|
|
|
"""
|
|
@@ -208,7 +208,13 @@ class GatewaySubDeviceView(View):
|
|
|
event_type = request_dict.get('eventType', None)
|
|
|
if not all([sub_device_id, cycle, event_type]):
|
|
|
return response.json(444, {'error param': 'gatewaySubId or cycle or eventType'})
|
|
|
+
|
|
|
now_time = int(time.time())
|
|
|
+ # 判断event_type
|
|
|
+ event_type = int(event_type)
|
|
|
+ if event_type != 2200 or event_type != 2201:
|
|
|
+ return response.json(444, {'invalid eventType': event_type})
|
|
|
+
|
|
|
try:
|
|
|
record_dict = cls.get_record_dict(cycle, now_time, sub_device_id, event_type)
|
|
|
record_list = []
|
|
@@ -232,7 +238,7 @@ class GatewaySubDeviceView(View):
|
|
|
@param cycle: 时间周期
|
|
|
@param now_time: 当前时间
|
|
|
@param sub_device_id: 子设备id
|
|
|
- @param event_type: 事件类型, 18:温度,19:湿度
|
|
|
+ @param event_type: 事件类型, 2200:温度,2201:湿度
|
|
|
@return: record_dict: 记录数据
|
|
|
"""
|
|
|
record_dict = OrderedDict()
|
|
@@ -400,9 +406,11 @@ class GatewaySubDeviceView(View):
|
|
|
res['is_tampered'] = sub_device_qs[0]['is_tampered']
|
|
|
elif device_type == 220: # 温湿度传感器返回温湿度数据
|
|
|
tem_record_qs = SensorRecord.objects.filter(gateway_sub_device_id=sub_device_id,
|
|
|
- event_type=18).order_by('-created_time').values('alarm')[:1]
|
|
|
+ event_type=2200).order_by('-created_time').values('alarm')[
|
|
|
+ :1]
|
|
|
hum_record_qs = SensorRecord.objects.filter(gateway_sub_device_id=sub_device_id,
|
|
|
- event_type=19).order_by('-created_time').values('alarm')[:1]
|
|
|
+ event_type=2201).order_by('-created_time').values('alarm')[
|
|
|
+ :1]
|
|
|
temperature = tem_record_qs[0]['alarm'] if tem_record_qs.exists() else ''
|
|
|
humidity = hum_record_qs[0]['alarm'] if tem_record_qs.exists() else ''
|
|
|
res['temperature'] = temperature
|