lang 3 лет назад
Родитель
Сommit
28b100439f
1 измененных файлов с 10 добавлено и 9 удалено
  1. 10 9
      Controller/AiController.py

+ 10 - 9
Controller/AiController.py

@@ -125,11 +125,12 @@ class AiView(View):
             file_post_three = request_dict.get('fileThree', None)
             file_post_four = request_dict.get('fileFour', None)
 
-            if not all([file_post_one,file_post_two,file_post_three,file_post_four]):
-                return response.json(444)
-
             file_list = [file_post_one, file_post_two, file_post_three, file_post_four]
             del file_post_one, file_post_two, file_post_three, file_post_four
+            if not all(file_list):
+                for k, val in enumerate(file_list):
+                    if not val:
+                        return response.json(444,'缺少第{k}张图'.format(k=k+1))
 
             dir_path = os.path.join(BASE_DIR, 'static/ai/' + uid + '/' + str(n_time))
             if not os.path.exists(dir_path):
@@ -178,9 +179,10 @@ class AiView(View):
                 logger.info('没有识别到任何标签-----------------')
                 return response.json(10055)
             event_type_list = labels['user_detect_group']
-            label_list = ','.join(labels['label_list'])
+            label_str = ','.join(labels['label_list'])
+            new_bounding_box_dict = labels['new_bounding_box_dict']
             logger.info(event_type_list)
-            logger.info(label_list)
+            logger.info(label_str)
 
             # 上传缩略图到s3
             for i, val in enumerate(file_path_list):
@@ -236,20 +238,19 @@ class AiView(View):
                             devUid=uid,
                             devNickName=nickname,
                             Channel=channel,
-                            alarm='检查到{labels} \tChannel:{channel}'.format(labels=','.join(labels['label_list']),
-                                                                           channel=channel),
+                            alarm='检查到{labels} \tChannel:{channel}'.format(labels=label_str,channel=channel),
                             is_st=is_st,
                             receiveTime=receiveTime,
                             addTime=now_time,
                             storage_location=2,
-                            borderCoords=json.dumps(labels['new_bounding_box_dict'])
+                            borderCoords=json.dumps(new_bounding_box_dict)
                         ))
                     userID_ids.append(userID_id)
 
                 # 推送标题
                 msg_title = self.get_msg_title(appBundleId=appBundleId, nickname=nickname)
                 # 推送内容
-                msg_text = self.get_msg_text(channel=channel, n_time=n_time, lang=lang, tz=tz, label_list=label_list)
+                msg_text = self.get_msg_text(channel=channel, n_time=n_time, lang=lang, tz=tz, label_list=label_str)
                 kwargs = {
                     'uid': uid,
                     'channel': channel,