Browse Source

查询v2推送消息时,如果时ai消息类型时,接口返回时新增一个字段ai_event_type_list表示此条记录包含了哪些ai类型

lang 3 năm trước cách đây
mục cha
commit
dc0a34c115
2 tập tin đã thay đổi với 27 bổ sung2 xóa
  1. 7 1
      Controller/DetectControllerV2.py
  2. 20 1
      Service/EquipmentInfoService.py

+ 7 - 1
Controller/DetectControllerV2.py

@@ -358,7 +358,6 @@ class DetectControllerViewV2(View):
             eventTime = p['eventTime']
             channel = p['Channel']
             storage_location = p['storage_location']
-            p['borderCoords'] = '' if p['borderCoords'] == '' else json.loads(p['borderCoords'])
             if p['is_st'] == 1:
                 thumbspng = '{uid}/{channel}/{time}.jpeg'.format(uid=devUid, channel=p['Channel'], time=eventTime)
                 if storage_location == 1:  # oss
@@ -435,6 +434,13 @@ class DetectControllerViewV2(View):
                 p['devNickName'] = uid_type_dict[devUid]['NickName']
             else:
                 p['uid_type'] = ''
+
+            p['borderCoords'] = '' if p['borderCoords'] == '' else json.loads(p['borderCoords']) # ai消息坐标信息
+            #ai消息标识标签
+            ai_all_event_type = EquipmentInfoService.get_all_comb_event_type()
+            p['ai_event_type_list'] = []
+            if p['eventType'] in ai_all_event_type: #如果是ai消息类型,则分解eventType, 如:123 -> [1,2,3]
+                p['ai_event_type_list'] = list(map(int, str(p['eventType'])))
             res.append(p)
         return response.json(0, {'datas': res, 'count': count})
 

+ 20 - 1
Service/EquipmentInfoService.py

@@ -237,7 +237,7 @@ class EquipmentInfoService:
         if len(ai_event_type_list) < 1:
             return event_type_list
         ai_event_type_list.sort()
-        type = [1, 2, 3, 4]  # AI目前所有的标签,1人,2车,3宠物,4包裹,后续有新类型需要这里加
+        type = [1, 2, 3, 4]  # AI目前所有的标签,1人,2车,3宠物,4包裹,后续有新类型需要这里加, 后续会优化,存在表里,包裹存对应的aws标签
         comb_ai_event_type = []
         seen = set()
         for i in range(1, len(type) + 1):  # 计算所有组合,如[1, 2, 3, 4], 4取1,4取2,4取3,4取4
@@ -256,3 +256,22 @@ class EquipmentInfoService:
             regroup_list.append(int(val))
         event_type_list = regroup_list + event_type_list  # 加上普通移动消息类型
         return event_type_list
+
+    @classmethod
+    def get_all_comb_event_type(cls):
+        """
+        计算ai消息类型全组合
+        @return: event_type_list ai所有消息类型数组
+        """
+        type = [1, 2, 3, 4]  # AI目前所有的标签,1人,2车,3宠物,4包裹,后续有新类型需要这里加, 后续会优化,存在表里,包裹存对应的aws标签
+        comb_ai_event_type = []
+        for i in range(1, len(type) + 1):  # 计算所有组合,如[1, 2, 3, 4], 4取1,4取2,4取3,4取4
+            for s in itertools.combinations(type, i):
+                    s_list = list(s)
+                    s_list = [str(v) for v in s_list]
+                    comb_ai_event_type.append(s_list)
+        regroup_list = []
+        for val in comb_ai_event_type:  # 组合ai类型组合,如[[2,3],[1,3]] -> [23, 13]
+            val = ''.join(val)
+            regroup_list.append(int(val))
+        return comb_ai_event_type