Browse Source

电池电量增加通道筛选

zhangdongming 2 weeks ago
parent
commit
005adb2082
1 changed files with 4 additions and 0 deletions
  1. 4 0
      Controller/UserDevice/DeviceReportController.py

+ 4 - 0
Controller/UserDevice/DeviceReportController.py

@@ -57,6 +57,7 @@ class DeviceReportView(View):
             return self.get_battery_capacity_list(userID, request, request_dict, response)
         elif operation == 'getWakeSleepData':
             return self.get_wake_sleep_data(userID, request_dict, response)
+        return response.json(414)
 
     @classmethod
     def get_wake_sleep_data(cls, userID, request_dict, response):
@@ -72,6 +73,7 @@ class DeviceReportView(View):
             uid = request_dict.get('device_id', None)
             if not uid:
                 return response.json(444)
+            channel = int(request_dict.get('channel', 1))
             current_time = int(time.time())
             SECONDS_PER_DAY = 24 * 60 * 60  # 单日秒数常量
 
@@ -84,6 +86,7 @@ class DeviceReportView(View):
 
             seven_days_stats = DeviceDailyReport.objects.filter(
                 device_id=uid,
+                channel=channel,
                 report_time__range=(seven_days_ago, current_time)  # 时间范围查询
             ).aggregate(
                 total_human_detection=Coalesce(Sum('human_detection'), Value(0)),
@@ -95,6 +98,7 @@ class DeviceReportView(View):
             # region 30天明细数据(按时间倒序)
             thirty_days_details = DeviceDailyReport.objects.filter(
                 device_id=uid,
+                channel=channel,
                 report_time__gte=thirty_days_ago,
                 report_time__lte=current_time
             ).order_by('-report_time').values_list(