Pārlūkot izejas kodu

Merge branch 'test' of http://192.168.136.99:3000/servers/ASJServer into peng

peng 2 gadi atpakaļ
vecāks
revīzija
222ca07c40

+ 6 - 1
Controller/RegionController.py

@@ -340,8 +340,13 @@ class RegionView(View):
             if is_app:
                 for country in country_qs:
                     if country['country_id'] == 1:
-                        country['api'] = 'https://www.dvema.com/'
                         country['push_api'] = 'https://push.dvema.com/'
+                        if 'Zosi' in app_name:
+                            country['api'] = 'https://api.zositech2.com/'
+                        elif 'Loocam' in app_name:
+                            country['api'] = 'https://api.loocam2.com/'
+                        else:
+                            country['api'] = 'https://www.dvema.com/'
                         break
             # AVSS
             else:

+ 2 - 1
Controller/UserDevice/UserDeviceShareController.py

@@ -15,6 +15,7 @@ from django.views import View
 from Model.models import DeviceSharePermission, DeviceChannelUserSet, DeviceChannelUserPermission, UidChannelSetModel
 from Object.ResponseObject import ResponseObject
 from Object.TokenObject import TokenObject
+from Service.UserDeviceService import UserDeviceService
 
 LOGGER = logging.getLogger('info')
 
@@ -145,7 +146,7 @@ class UserDeviceShareView(View):
         try:
             if not all([user_id, uid]):
                 return False
-
+            UserDeviceService.update_device_channel(uid)
             channel_qs = UidChannelSetModel.objects.filter(uid__uid=uid).values('channel')
             if not channel_qs.exists():
                 return False

+ 4 - 0
Controller/UserManger.py

@@ -100,8 +100,12 @@ class showUserMoreView(TemplateView):
                             app_name = app_inf_qs[0]['appName']
                             if 'Zosi' in app_name:
                                 sqlDict['datas'][k]['fields']['api'] = country_qs[0]['country__region__zosi_api']
+                                if region_country == 1:
+                                    sqlDict['datas'][k]['fields']['api'] = 'https://api.zositech2.com/'
                             elif 'Loocam' in app_name:
                                 sqlDict['datas'][k]['fields']['api'] = country_qs[0]['country__region__loocam_api']
+                                if region_country == 1:
+                                    sqlDict['datas'][k]['fields']['api'] = 'https://api.loocam2.com/'
 
                     # region数据
                     region_country = sqlDict['datas'][k]['fields']['region_country']

+ 31 - 0
Service/UserDeviceService.py

@@ -286,3 +286,34 @@ class UserDeviceService:
         except Exception as e:
             LOGGER.info('异常详情,errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
             return channels
+
+    @staticmethod
+    def update_device_channel(uid):
+        """
+        UID通道同步更新
+        @param uid: 设备UID
+        @return: True | False
+        """
+        try:
+            uid_set_qs = UidSetModel.objects.filter(uid=uid).values('id', 'channel')
+            if not uid_set_qs.exists():
+                return False
+            uid_set_id = uid_set_qs[0]['id']
+            channel_index = uid_set_qs[0]['channel']
+            uid_channel_qs = UidChannelSetModel.objects.filter(uid_id=uid_set_id).values('channel')
+            if uid_channel_qs.exists() and uid_channel_qs.count() != channel_index:
+                uid_channel_list = []
+                channels = [val['channel'] for val in uid_channel_qs]
+                for i in range(1, channel_index + 1):
+                    if i in channels:
+                        continue
+                    channel_name = 'channel' + str(i)  # channel1,channel2...
+                    UidChannelSet = UidChannelSetModel(uid_id=uid_set_id, channel=i, channel_name=channel_name)
+                    uid_channel_list.append(UidChannelSet)
+                if not uid_channel_list:
+                    return True
+                UidChannelSetModel.objects.bulk_create(uid_channel_list)
+            return True
+        except Exception as e:
+            LOGGER.info('异常详情,errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
+            return False