|
@@ -251,7 +251,7 @@ class SmartSceneView(View):
|
|
|
return response.json(444, {'error param': 'invalid isAllDay'})
|
|
|
|
|
|
msg = {}
|
|
|
- if conditions_dict['type'] == 2: # 条件为选择子设备
|
|
|
+ if conditions_dict['type'] == 2: # 条件为选择子设备
|
|
|
sub_device_id = conditions_dict['sensor']['subDeviceId']
|
|
|
sub_device_qs = GatewaySubDevice.objects.filter(id=sub_device_id).values('src_addr').first()
|
|
|
msg['smart_scene_id'] = smart_scene_qs.id
|
|
@@ -350,7 +350,8 @@ class SmartSceneView(View):
|
|
|
return response.json(444, {'error param': 'smartSceneId'})
|
|
|
try:
|
|
|
smart_scene_qs = SmartScene.objects.filter(id=smart_scene_id).values('id', 'scene_name', 'conditions',
|
|
|
- 'tasks', 'effective_time_id')
|
|
|
+ 'tasks', 'effective_time_id',
|
|
|
+ 'is_all_day')
|
|
|
if not smart_scene_qs.exists():
|
|
|
return response.json(173)
|
|
|
res = {
|
|
@@ -360,21 +361,21 @@ class SmartSceneView(View):
|
|
|
}
|
|
|
|
|
|
# 如果存在关联的时间数据,组织时间数据
|
|
|
- try:
|
|
|
- effective_time_qs = EffectiveTime.objects.get(id=smart_scene_qs[0]['effective_time_id'])
|
|
|
- except ObjectDoesNotExist:
|
|
|
- return response.json(0, res)
|
|
|
-
|
|
|
- if effective_time_qs.is_all_day: # 全天
|
|
|
- time_dict = {'all_day': 1}
|
|
|
- else:
|
|
|
- time_dict = {
|
|
|
- 'start_time': effective_time_qs.start_time,
|
|
|
- 'end_time': effective_time_qs.end_time,
|
|
|
- 'repeat': effective_time_qs.repeat,
|
|
|
- }
|
|
|
- res['time'] = time_dict
|
|
|
+ is_all_day = smart_scene_qs[0]['is_all_day']
|
|
|
+ effectiveTime = {}
|
|
|
+ if is_all_day != 0:
|
|
|
+ effectiveTime['isAllDay'] = is_all_day
|
|
|
+ if is_all_day == 2:
|
|
|
+ try:
|
|
|
+ effective_time_qs = EffectiveTime.objects.get(id=smart_scene_qs[0]['effective_time_id'])
|
|
|
+ effectiveTime['startTime'] = effective_time_qs.start_time
|
|
|
+ effectiveTime['endTime'] = effective_time_qs.end_time
|
|
|
+ effectiveTime['repeat'] = effective_time_qs.repeat
|
|
|
+ except ObjectDoesNotExist:
|
|
|
+ return response.json(0, res)
|
|
|
+ res['effectiveTime'] = effectiveTime
|
|
|
return response.json(0, res)
|
|
|
+
|
|
|
except Exception as e:
|
|
|
return response.json(500, repr(e))
|
|
|
|
|
@@ -420,4 +421,3 @@ class SmartSceneView(View):
|
|
|
return response.json(500, repr(e))
|
|
|
else:
|
|
|
return response.json(0)
|
|
|
-
|