Explorar o código

更新推送时间

lang %!s(int64=3) %!d(string=hai) anos
pai
achega
9601c9bd3b
Modificáronse 1 ficheiros con 5 adicións e 5 borrados
  1. 5 5
      Controller/AiController.py

+ 5 - 5
Controller/AiController.py

@@ -410,7 +410,8 @@ class AiView(View):
 
     def do_ai_identification(self, request_dict,response):
         etk = request_dict.get('etk', None)
-        now_time = int(time.time())
+        n_time = request_dict.get('n_time', None)
+        receiveTime = int(time.time())
         logger = logging.getLogger('info')
         logger.info('-----------into----ai--api')
         logger.info("etk={etk}".format(etk=etk))
@@ -426,7 +427,7 @@ class AiView(View):
                 return response.json(444)
 
             ##通过uid查出endTime是否过期,并且ai开关是否打开
-            AiServiceQuery = AiService.objects.filter(uid=uid, detect_status=1, use_status=1, endTime__gt=now_time).\
+            AiServiceQuery = AiService.objects.filter(uid=uid, detect_status=1, use_status=1, endTime__gt=receiveTime).\
                 values('detect_group')
             if not AiServiceQuery.exists():
                 logger.info('none-----aiService')
@@ -449,7 +450,7 @@ class AiView(View):
             file_list = [file_post_one, file_post_two, file_post_three]
             del file_post_one, file_post_two, file_post_three
 
-            dir_path = os.path.join(BASE_DIR, 'static/ai/' + uid + '/' + str(now_time))
+            dir_path = os.path.join(BASE_DIR, 'static/ai/' + uid + '/' + str(receiveTime))
             if not os.path.exists(dir_path):
                 os.makedirs(dir_path)
             file_path_list = []
@@ -507,7 +508,6 @@ class AiView(View):
             logger.info(label_list)
             #存储消息以及推送
             channel = request_dict.get('channel', '1')
-            n_time = now_time
             is_st = 1  #单图
 
             # 查询推送数据
@@ -577,7 +577,7 @@ class AiView(View):
                         Channel=channel,
                         alarm='检查到{labels} \tChannel:{channel}'.format(labels=','.join(labels['label_list']), channel=channel),
                         is_st=is_st,
-                        receiveTime=n_time,
+                        receiveTime=receiveTime,
                         addTime=now_time,
                         storage_location=2
                     ))