|
@@ -105,7 +105,7 @@ class SmartSocketView(View):
|
|
|
'accumulated_time': accumulated_time,
|
|
|
'updated_time': now_time
|
|
|
}
|
|
|
- if not power_qs.exists():
|
|
|
+ if not power_qs.exists(): # 添加插座上报电量统计
|
|
|
socket_info_qs = SocketInfo.objects.filter(serial_number=serial_number).values('device_id')
|
|
|
if not socket_info_qs.exists():
|
|
|
return response.json(173)
|
|
@@ -114,6 +114,7 @@ class SmartSocketView(View):
|
|
|
data['serial_number'] = serial_number
|
|
|
SocketPowerStatistics.objects.create(**data)
|
|
|
return response.json(0)
|
|
|
+ # 更新当天电量统计
|
|
|
power_qs.update(**data)
|
|
|
return response.json(0)
|
|
|
except Exception as e:
|
|
@@ -266,8 +267,15 @@ class SmartSocketView(View):
|
|
|
task_id = request_dict.get('taskId', None)
|
|
|
device_switch = request_dict.get('deviceSwitch', None)
|
|
|
task_switch = request_dict.get('taskSwitch', None)
|
|
|
- if not all([task_type, start_time, repeat, device_switch, task_switch]):
|
|
|
+ if not all([task_type, start_time, end_time, repeat, device_switch, task_switch]):
|
|
|
return response.json(444)
|
|
|
+ # 排查是否已设置过当前排程
|
|
|
+ socket_s_qs = SocketSchedule.objects.filter(device_id=device_id,
|
|
|
+ start_time=int(start_time),
|
|
|
+ end_time=int(end_time),
|
|
|
+ time_type=int(task_type))
|
|
|
+ if socket_s_qs.exists():
|
|
|
+ return response.json(174)
|
|
|
device_switch = int(device_switch)
|
|
|
task_switch = int(task_switch)
|
|
|
now_time = int(time.time())
|