浏览代码

Merge remote-tracking branch 'remotes/origin/dev' into test

tanghongbin 5 年之前
父节点
当前提交
6dfe777d75
共有 2 个文件被更改,包括 54 次插入2 次删除
  1. 53 1
      Controller/AdminManage.py
  2. 1 1
      Controller/UserController.py

+ 53 - 1
Controller/AdminManage.py

@@ -80,6 +80,8 @@ class AdminManage(TemplateView):
             return self.getAllAppFrequency(userID, response)
         if operation == 'getPushStatistics':
             return self.query_push_by_level(userID, request_dict, response)
+        if operation == 'getPushFailures':
+            return self.query_failures_push(userID, request_dict, response)
 
     def resetUserPwd(self, request_dict, userID, response):
         own_permission = ModelService.check_perm(userID=userID, permID=50)
@@ -518,7 +520,7 @@ class AdminManage(TemplateView):
                 failures += 1
             tmp['total'] += 1
 
-        tmp_dict[start_time] = tmp
+        tmp_dict[current_time] = tmp
 
         for item in data:
             if tmp_dict.__contains__(item['date_time']):
@@ -537,6 +539,56 @@ class AdminManage(TemplateView):
 
         return response.json(0, res)
 
+    # def query_push_month_statistics(self, level, response):
+    #     start_time = 0
+    #     end_time = 0
+    #     localtime = time.localtime()
+    #     current_month = localtime.tm_mon
+    #
+    #     time_struct = [localtime.tm_year, current_month, 1, 0, 0, 0, 0, 0, 0]
+    #     current_time = int(time.mktime(tuple(time_struct)))
+    #     current_time = current_time - time.timezone - 8 * 60 * 60
+    #     count = 0
+    #     start_month = 0
+    #     if level == 3:  # 6个月
+    #         start_month = current_month - 5
+    #         count = 5
+    #     elif level == 4:
+    #         start_month = current_month - 11
+    #         count = 10
+    #
+    #
+    #     return
+
+    def query_failures_push(self, userID, request_dict, response):
+        own_permission = ModelService.check_perm(userID=userID, permID=30)
+        if own_permission is not True:
+            return response.json(404)
+
+        start_time = request_dict.get('start_time', None)
+        end_time = request_dict.get('end_time', None)
+        page = request_dict.get('page', None)
+        line = request_dict.get('line', None)
+
+        if not start_time or not end_time or not page or not line:
+            return response.json(444)
+
+        start_time = int(start_time)
+        end_time = int(end_time)
+        page = int(page)
+        line = int(line)
+        if page <= 0 or line < 0:
+            return response.json(444, 'page, line')
+
+        eq_qs = Equipment_Info.objects.filter(addTime__gte=start_time, addTime__lte=end_time)\
+            .filter(~Q(push_server_status=200)).values('id', 'devUid', 'devNickName', 'Channel', 'alarm', 'eventType', 'eventTime', 'receiveTime', 'userID__username')
+        if eq_qs.exists():
+            count = eq_qs.count()
+            eq_qs = eq_qs[(page-1)*line: page * line]
+            return response.json(0, {'count': count, 'data': list(eq_qs)})
+        else:
+            return response.json(0, {'count': 0, 'data': []})
+
 
 @require_http_methods(["GET"])
 def getUserIds(request):

+ 1 - 1
Controller/UserController.py

@@ -2904,7 +2904,7 @@ class Image_Code_RegisterView(TemplateView):
         # redis里面的验证码
         redis_image_code = redisObj.get_data(key=image_code_key)
         # 验证用户输入的验证码和redis中的验证码
-        if valid_code.lower() != redis_image_code.lower():
+        if redis_image_code is False or valid_code.lower() != redis_image_code.lower():
             return response.json(121)
         # 删除redis中的图片验证码,防止用户使用同一个图片验证码验证多次
         redisObj.del_data(key=image_code_key)