Kaynağa Gözat

Merge branch 'dev' of http://192.168.136.99:3000/servers/ASJServer into cloud_storage_dev

lang 3 yıl önce
ebeveyn
işleme
d94ad5ccac

+ 171 - 0
AdminController/DeviceManagementController.py

@@ -0,0 +1,171 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+import json
+import time
+
+from django.db import transaction
+from Object.ResponseObject import ResponseObject
+from Object.TokenObject import TokenObject
+from django.views.generic.base import View
+from Service.ModelService import ModelService
+from Service.CommonService import CommonService
+from Model.models import Device_Info, UidSetModel, LogModel, UID_Bucket, Unused_Uid_Meal, Order_Model, StsCrdModel, \
+    VodHlsModel, ExperienceContextModel
+import datetime
+from django.utils import timezone
+
+class DeviceManagement(View):
+    def get(self, request, *args, **kwargs):
+        request.encoding = 'utf-8'
+        operation = kwargs.get('operation')
+        return self.validation(request.GET, request, operation)
+
+    def post(self, request, *args, **kwargs):
+        request.encoding = 'utf-8'
+        operation = kwargs.get('operation')
+        return self.validation(request.POST, request, operation)
+
+    def validation(self, request_dict, request, operation):
+        language = request_dict.get('language', 'en')
+        response = ResponseObject(language, 'pc')
+        tko = TokenObject(
+            request.META.get('HTTP_AUTHORIZATION'),
+            returntpye='pc')
+        if tko.code != 0:
+            return response.json(tko.code)
+        response.lang = tko.lang
+        userID = tko.userID
+        if userID is not None:
+            if operation == 'query':
+                return self.query(request_dict, userID, response)
+            elif operation == 'findByUser':
+                return self.findByUser(request_dict, userID, response)
+            elif operation == 'delete':
+                return self.delete(request_dict, userID, response)
+            elif operation == 'uidSetQuery':
+                return self.uidSetQuery(request_dict, userID, response)
+            elif operation == 'vod_reset':
+                return self.vod_reset(request, request_dict, response)
+            elif operation == 'primary_user_reset':
+                return self.primary_user_reset(request, request_dict, response)
+        return response.json(444, 'operation')
+
+
+    def query(self, request_dict, userID, response):
+        own_perm = ModelService.check_perm(userID=userID, permID=30)
+        if not own_perm :
+            return response.json(404)
+
+        pageNo = request_dict.get('pageNo', None)
+        pageSize = request_dict.get('pageSize', None)
+        UID = request_dict.get('UID', None)
+        if not all([pageNo, pageSize]):
+            return response.json(444)
+
+        page = int(pageNo)
+        line = int(pageSize)
+
+        queryset = Device_Info.objects.all()
+        if UID:
+            queryset = queryset.filter(UID__contains=UID)
+        if queryset.exists():
+            count = queryset.count()
+            res = queryset[(page - 1) * line:page * line]
+            send_dict = CommonService.qs_to_dict(res)
+            for k, v in enumerate(send_dict["datas"]):
+                for val in res:
+                    if v['pk'] == val.id:
+                        if send_dict["datas"][k]['fields']['Online'] is True:
+                            dl_time = val.update_time+datetime.timedelta(minutes=60)
+                            now_time = timezone.localtime(timezone.now())
+                            if now_time > dl_time:
+                                pass
+                                # send_dict["datas"][k]['fields']['Online'] = False
+                        username= ModelService.get_user_name(send_dict["datas"][k]['fields']['userID'])
+                        send_dict["datas"][k]['fields']['username']=username
+                        primary= ModelService.get_user_name(send_dict["datas"][k]['fields']['primaryUserID'])
+                        send_dict["datas"][k]['fields']['primaryusername']=primary
+            return response.json(
+                0, {'list': send_dict, 'total': count})
+        return response.json(
+            0, {'list': {}, 'total': 0})
+
+    # 管理员查询接口
+    def uidSetQuery(self, request_dict, userID, response):
+
+        pageNo = request_dict.get('pageNo', None)
+        pageSize = request_dict.get('pageSize', None)
+        UID = request_dict.get('UID', None)
+        if not all([pageNo, pageSize]):
+            return response.json(444)
+
+        page = int(pageNo)
+        line = int(pageSize)
+
+        omqs = UidSetModel.objects.all().order_by('-id')
+        if UID:
+            omqs = omqs.filter(uid__contains=UID)
+        count = omqs.count()
+        order_ql = omqs[(page - 1) * line:page * line]
+        uidset_json = CommonService.qs_to_dict(order_ql)
+        uidset_json['count'] = count
+        return response.json(
+            0, {'list': uidset_json, 'total': count})
+
+    # 重置设备云存
+    def vod_reset(self, request, request_dict, response):
+        uid = request_dict.get('uid', None)
+        if uid:
+            try:
+                # 记录操作日志
+                ip = CommonService.get_ip_address(request)
+                content = json.loads(json.dumps(request_dict))
+                log = {
+                    'ip': ip,
+                    'user_id': 1,
+                    'status': 200,
+                    'time': int(datetime.time.time()),
+                    'url': 'uidset/vod_reset',
+                    'content': json.dumps(content),
+                    'operation': '{}重置设备云存'.format(uid),
+                }
+                with transaction.atomic():
+                    LogModel.objects.create(**log)
+                    # 删除和更新设备云存相关数据
+                    UID_Bucket.objects.filter(uid=uid).delete()
+                    Unused_Uid_Meal.objects.filter(uid=uid).delete()
+                    Order_Model.objects.filter(UID=uid).delete()
+                    StsCrdModel.objects.filter(uid=uid).delete()
+                    VodHlsModel.objects.filter(uid=uid).delete()
+                    ExperienceContextModel.objects.filter(uid=uid).delete()
+                    # UIDMainUser.objects.filter(UID=uid).delete()
+                    Device_Info.objects.filter(UID=uid).update(vodPrimaryUserID='', vodPrimaryMaster='')
+            except Exception as e:
+                print(e)
+                return response.json(500, repr(e))
+            else:
+                return response.json(0)
+
+    # 重置设备主用户
+    def primary_user_reset(self, request, request_dict, response):
+        uid = request_dict.get('uid', None)
+        if not uid:
+            return response.json(404)
+        try:
+            # 记录操作日志
+            ip = CommonService.get_ip_address(request)
+            content = json.loads(json.dumps(request_dict))
+            log = {
+                'ip': ip,
+                'user_id': 1,
+                'status': 200,
+                'time': int(time.time()),
+                'url': 'uidset/primary_user_reset',
+                'content': json.dumps(content),
+                'operation': '{}重置设备主用户'.format(uid),
+            }
+            LogModel.objects.create(**log)
+            Device_Info.objects.filter(UID=uid).update(vodPrimaryUserID='', vodPrimaryMaster='')
+            return response.json(0)
+        except Exception as e:
+            return response.json(500, repr(e))

+ 143 - 7
AdminController/UserManageController.py

@@ -21,6 +21,7 @@ import simplejson
 import simplejson as json
 import requests
 from django.contrib.auth.hashers import make_password, check_password  # 对密码加密模块
+from django.db import transaction
 from django.db.models import Q
 from django.http import HttpResponseRedirect
 from django.utils.decorators import method_decorator
@@ -34,7 +35,8 @@ from Ansjer.config import AuthCode_Expire, SERVER_DOMAIN, APNS_CONFIG, JPUSH_CON
     OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET
 from Controller.CheckUserData import DataValid, date_handler, RandomStr
 from Model.models import Device_User, Role, UidPushModel, UserOauth2Model, UserExModel, Device_Info, UidSetModel, \
-    UserAppFrequencyModel, CountryIPModel, CountryModel, UidChannelSetModel, MenuModel, FeedBackModel, StatResModel
+    UserAppFrequencyModel, CountryIPModel, CountryModel, UidChannelSetModel, MenuModel, FeedBackModel, StatResModel, \
+    SysMassModel, App_Info, SysMsgModel
 from Object.AWS.SesClassObject import SesClassObject
 from Object.AliSmsObject import AliSmsObject
 from Object.RedisObject import RedisObject
@@ -303,8 +305,12 @@ class UserManagement(View):
     def validation(self, request_dict, request, operation):
         language = request_dict.get('language', 'en')
         response = ResponseObject(language, 'pc')
-        if operation == '??':
-            return 0
+        if operation == 'sendSysMessage':
+            return self.sendSysMessage(request_dict, response)
+        elif operation == 'getAppDataList':
+            return self.getAppDataList(request_dict, response)
+        elif operation == 'replyFeedBack':
+            return self.replyFeedBack(request_dict, response)
         else:
             tko = TokenObject(request.META.get('HTTP_AUTHORIZATION'), returntpye='pc')
             if tko.code != 0:
@@ -316,11 +322,15 @@ class UserManagement(View):
             elif operation == 'AddOrEditAccount':
                 return self.AddOrEditAccount(userID, request_dict, response)
             elif operation == 'doDelete':
-                return self.doDelete(userID, request_dict, response)
+                return self.doDelete(request_dict, response)
             elif operation == 'resetPassword':
                 return self.resetPassword(request_dict, response)
             elif operation == 'getFeedbackList':
                 return self.getFeedbackList(request_dict, response)
+            elif operation == 'deleteFeedBack':
+                return self.deleteFeedBack(request_dict, response)
+            elif operation == 'getSysMessageList':
+                return self.getSysMessageList(request_dict, response)
             else:
                 return response.json(404)
 
@@ -437,10 +447,16 @@ class UserManagement(View):
             print(e)
             return response.json(500, repr(e))
 
-    def doDelete(self, userID, request_dict, response):
+    def doDelete(self, request_dict, response):
         userID = request_dict.get('userID', '')
-        Device_User.objects.filter(userID=userID).delete()
-        return response.json(0)
+        if not userID:
+            return response.json(444)
+        try:
+            Device_User.objects.filter(userID=userID).delete()
+            return response.json(0)
+        except Exception as e:
+            print(e)
+            return response.json(500, repr(e))
 
     def resetPassword(self, request_dict, response):
         userID = request_dict.get('userID', None)
@@ -520,3 +536,123 @@ class UserManagement(View):
             print(e)
             return response.json(500, repr(e))
 
+    def replyFeedBack(self, request_dict, response):
+        feedBackID = request_dict.get('feedBackID', None)
+        msg = request_dict.get('msg', None)
+        uid = request_dict.get('uid', None)
+
+        if not all([feedBackID, msg]):
+            return response.json(444)
+
+        try:
+            nowTime = int(time.time())
+            feed_back_qs = FeedBackModel.objects.filter(id=feedBackID)
+            if not feed_back_qs.exists():
+                return response.json(173)
+            with transaction.atomic():
+                SysMsgModel.objects.create(userID_id=feed_back_qs.first().userID_id, msg=msg, uid=uid,
+                                           addTime=nowTime, updTime=nowTime)   # 创建系统消息
+                feed_back_qs.update(status=1)   # 更新状态为已回复
+            return response.json(0)
+        except Exception as e:
+            print(e)
+            return response.json(500, repr(e))
+
+    def deleteFeedBack(self, request_dict, response):
+        feedBackID = request_dict.get('feedBackID', None)
+        if not feedBackID:
+            return response.json(444)
+        try:
+            feed_back = FeedBackModel.objects.get(id=feedBackID)
+            sr_id_list = feed_back.FS.values_list('id', flat=True)
+            StatResModel.objects.filter(id__in=sr_id_list).delete()
+            feed_back.delete()
+            return response.json(0)
+        except Exception as e:
+            print(e)
+            return response.json(500, repr(e))
+
+    def getSysMessageList(self, request_dict, response):
+        print('request_dict: ', request_dict)
+        pageNo = request_dict.get('pageNo', None)
+        pageSize = request_dict.get('pageSize', None)
+
+        if not all([pageNo, pageSize]):
+            return response.json(444)
+
+        page = int(pageNo)
+        line = int(pageSize)
+
+        try:
+            sys_mass_qs = SysMassModel.objects.filter()
+            total = sys_mass_qs.count()
+            sys_mass_qs = sys_mass_qs.values('id', 'sender__username', 'addTime', 'updTime', 'lang', 'recever', 'msg',
+                                             'platform')
+            sys_mass_qs = sys_mass_qs[(page - 1) * line:page * line]
+            return response.json(0, {'list': list(sys_mass_qs), 'total': total})
+        except Exception as e:
+            print(e)
+            return response.json(500, repr(e))
+
+    def getAppDataList(self, request_dict, response):
+        print('request_dict: ', request_dict)
+        platform = request_dict.get('platform', None)
+
+        if platform == 'android':
+            app_type = [1]
+        elif platform == 'ios':
+            app_type = [2]
+        else:
+            app_type = [1, 2]
+
+        try:
+            app_info_qs = App_Info.objects.filter(app_type__in=app_type).values('appBundleId', 'appName').distinct()
+            appBundleId_list = []
+            for app_info in app_info_qs:
+                appBundleId_list.append(app_info['appBundleId'])
+            return response.json(0, {'appBundleId_list': appBundleId_list})
+        except Exception as e:
+            print(e)
+            return response.json(500, repr(e))
+
+    def sendSysMessage(self, request_dict, response):
+        print('request_dict: ', request_dict)
+        lang = request_dict.get('lang', None)
+        platform = request_dict.get('platform', None)
+        recever = request_dict.get('app_list', None)
+        msg = request_dict.get('msg', None)
+
+        if not all([lang, platform, recever, msg]):
+            return response.json(444)
+
+        try:
+            with transaction.atomic():
+                # SysMassModel表创建群发消息记录数据
+                nowTime = int(time.time())
+                sender_id = Device_User.objects.filter(username='13800138001').values('userID').first()['userID']
+                SysMassModel.objects.create(
+                    sender_id=sender_id,
+                    lang=lang,
+                    platform=platform,
+                    recever=recever,
+                    msg=msg,
+                    addTime=nowTime,
+                    updTime=nowTime,
+                )
+                # 根据UserExModel表的userID群发消息给用户
+                region_list = lang.split(',')
+                appBundleId_list = recever.split(',')
+                userID_list = UserExModel.objects.filter(appBundleId__in=appBundleId_list, region__in=region_list)\
+                    .values_list('userID_id', flat=True)
+                sys_msg_list = []
+                for userID in userID_list:
+                    sys_msg_list.append(SysMsgModel(userID_id=userID, msg=msg, addTime=nowTime, updTime=nowTime))
+                    if len(sys_msg_list) > 5000:
+                        SysMsgModel.objects.bulk_create(sys_msg_list)
+                        sys_msg_list = []
+                SysMsgModel.objects.bulk_create(sys_msg_list)
+            return response.json(0)
+        except Exception as e:
+            print(e)
+            return response.json(500, repr(e))
+

+ 180 - 0
AdminController/VersionManagementController.py

@@ -0,0 +1,180 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+import os
+import hashlib
+from django.views.generic.base import View
+
+from Ansjer.config import BASE_DIR
+from Model.models import Equipment_Version
+from Object.TokenObject import TokenObject
+from Object.ResponseObject import ResponseObject
+from Service.CommonService import CommonService
+
+
+class VersionManagement(View):
+    def get(self, request, *args, **kwargs):
+        request.encoding = 'utf-8'
+        operation = kwargs.get('operation')
+        return self.validation(request.GET, request, operation)
+
+    def post(self, request, *args, **kwargs):
+        request.encoding = 'utf-8'
+        operation = kwargs.get('operation')
+        return self.validation(request.POST, request, operation)
+
+    def validation(self, request_dict, request, operation):
+        language = request_dict.get('language', 'en')
+        response = ResponseObject(language, 'pc')
+        if operation == 'upLoadFile':
+            return self.upLoadFile(request, request_dict, response)
+        else:
+            tko = TokenObject(
+                request.META.get('HTTP_AUTHORIZATION'),
+                returntpye='pc')
+            if tko.code != 0:
+                return response.json(tko.code)
+            response.lang = tko.lang
+            userID = tko.userID
+            if operation == 'getEquipmentVersionList':
+                return self.getEquipmentVersionList(request_dict, response)
+            elif operation == 'editVersionInformation':
+                return self.editVersionInformation(request_dict, response)
+            elif operation == 'deleteEquipmentVersion':
+                return self.deleteEquipmentVersion(request_dict, response)
+            else:
+                return response.json(404)
+
+    def getEquipmentVersionList(self, request_dict, response):
+        mci = request_dict.get('mci', None)
+        lang = request_dict.get('lang', None)
+        version = request_dict.get('version', None)
+        pageNo = request_dict.get('pageNo', None)
+        pageSize = request_dict.get('pageSize', None)
+
+        if not all([pageNo, pageSize]):
+            return response.json(444)
+
+        page = int(pageNo)
+        line = int(pageSize)
+
+        try:
+            equipment_version_qs = Equipment_Version.objects.filter()
+            if mci:
+                equipment_version_qs = equipment_version_qs.filter(mci=mci)
+            if lang:
+                equipment_version_qs = equipment_version_qs.filter(lang=lang)
+            if version:
+                equipment_version_qs = equipment_version_qs.filter(version__contains=version)
+
+            total = equipment_version_qs.count()
+            equipment_version_qs = equipment_version_qs.values()[(page - 1) * line:page * line]
+            equipment_version_list = CommonService.qs_to_list(equipment_version_qs)
+            return response.json(0, {'list': equipment_version_list, 'total': total})
+        except Exception as e:
+            print(e)
+            return response.json(500, repr(e))
+
+    def upLoadFile(self, request, request_dict, response):
+        file = request.FILES.get('file', None)
+        mci = request_dict.get('mci', '')
+        lang = request_dict.get('lang', '')
+        ESN = request_dict.get('ESN', '')
+        max_ver = request_dict.get('max_ver', '')
+        channel = request_dict.get('channel', '')
+        resolutionRatio = request_dict.get('resolutionRatio', '')
+        Description = request_dict.get('Description', '')
+        status = request_dict.get('status', 0)
+        fileSize = request_dict.get('fileSize', '')
+
+        if not all([file, mci, lang, ESN, max_ver, channel, resolutionRatio]):
+            return response.json(444)
+
+        try:
+            channel = int(channel)
+            resolutionRatio = int(resolutionRatio)
+            status = int(status)
+            # 文件名为设备版本,最后一个'.'的前面为软件版本,后面为设备规格名称
+            # V2.2.4.16E201252CA,软件版本:2.2.4,设备规格名称:16E201252CA
+            file_name = str(file)                           # 文件名
+            version = file_name[:file_name.rindex('.')]     # 设备版本
+            rpoint = version.rindex('.')
+            softwareVersion = version[1:rpoint]             # 软件版本
+            code = version[rpoint+1:]                       # 设备规格名称
+            chipModelList2Code = code[:4]                   # 主芯片
+            type = code[-3:-1]                              # 设备机型
+            companyCode = code[-1:]                         # 公司代码
+            fileSize = fileSize
+            filePath = '/'.join(('static/otapack', mci, lang, file_name))
+            file_data = file.read()
+            fileMd5 = hashlib.md5(file_data).hexdigest()
+            data_dict = {'mci': mci, 'lang': lang, 'ESN': ESN, 'max_ver': max_ver,  'channel': channel,
+                         'resolutionRatio': resolutionRatio, 'Description': Description, 'status': status,
+                         'version': version, 'softwareVersion': softwareVersion, 'code': code,
+                         'chipModelList2Code': chipModelList2Code, 'type': type, 'companyCode': companyCode,
+                         'fileSize': fileSize, 'filePath': filePath, 'fileMd5': fileMd5}
+            # Equipment_Version表创建或更新数据
+            equipment_version_qs = Equipment_Version.objects.filter(code=code, lang=lang)
+            if not equipment_version_qs.exists():
+                Equipment_Version.objects.create(eid=CommonService.getUserID(getUser=False, setOTAID=True), **data_dict)
+            else:
+                equipment_version_qs.update(**data_dict)
+
+            # 上传文件到服务器
+            upload_path = '/'.join((BASE_DIR, 'static/otapack', mci, lang)).replace('\\', '/') + '/'
+            if not os.path.exists(upload_path):  # 上传目录不存在则创建
+                os.makedirs(upload_path)
+            # 文件上传
+            full_name = upload_path + file_name
+            if os.path.exists(full_name):   # 删除同名文件
+                os.remove(full_name)
+            with open(full_name, 'wb+') as write_file:
+                for chunk in file.chunks():
+                    write_file.write(chunk)
+            return response.json(0)
+        except Exception as e:
+            print(e)
+            return response.json(500, repr(e))
+
+    def editVersionInformation(self, request_dict, response):
+        eid = request_dict.get('eid', None)
+        ESN = request_dict.get('ESN', '')
+        max_ver = request_dict.get('max_ver', '')
+        status = request_dict.get('status', '')
+        channel = request_dict.get('channel', '')
+        resolutionRatio = request_dict.get('resolutionRatio', '')
+        Description = request_dict.get('Description', '')
+
+        if not eid:
+            return response.json(444)
+        status = 1 if status == 'true' else 0
+        try:
+            equipment_version_qs = Equipment_Version.objects.filter(eid=eid)
+            if not equipment_version_qs.exists():
+                return response.json(173)
+            data_dict = {'ESN': ESN, 'max_ver': max_ver, 'status': status, 'channel': channel,
+                         'resolutionRatio': resolutionRatio, 'Description': Description}
+            equipment_version_qs.update(**data_dict)
+            return response.json(0)
+        except Exception as e:
+            print(e)
+            return response.json(500, repr(e))
+
+    def deleteEquipmentVersion(self, request_dict, response):
+        eid = request_dict.get('eid', None)
+
+        if not eid:
+            return response.json(444)
+
+        try:
+            equipment_version_qs = Equipment_Version.objects.filter(eid=eid)
+            filePath = equipment_version_qs.values('filePath')[0]['filePath']
+            equipment_version_qs.delete()
+            # 删除文件
+            full_name = '/'.join((BASE_DIR, filePath)).replace('\\', '/')
+            if os.path.exists(full_name):
+                os.remove(full_name)
+            return response.json(0)
+        except Exception as e:
+            print(e)
+            return response.json(500, repr(e))
+

+ 5 - 1
Ansjer/urls.py

@@ -20,7 +20,7 @@ from Controller import FeedBack, EquipmentOTA, EquipmentInfo, AdminManage, AppIn
     RegionController, VPGController, LanguageController, TestController, DeviceConfirmRegion, S3GetStsController, \
     DetectControllerV2, ShadowController, TestDetectController, PcInfo, PctestController, DeviceDebug
 from AdminController import UserManageController, RoleController, MenuController, TestServeController, \
-    ServeManagementController, LogManagementController
+    ServeManagementController, LogManagementController, DeviceManagementController, VersionManagementController
 
 urlpatterns = [
     url(r'^testApi/(?P<operation>.*)$', TestApi.testView.as_view()),
@@ -355,6 +355,10 @@ urlpatterns = [
 
     # 菜单管理
     re_path('menuManagement/(?P<operation>.*)', MenuController.MenuView.as_view()),
+    # 设备管理
+    re_path('deviceManagement/(?P<operation>.*)', DeviceManagementController.DeviceManagement.as_view()),
+    # 版本管理
+    re_path('versionManagement/(?P<operation>.*)', VersionManagementController.VersionManagement.as_view()),
     # 服务管理
     re_path('serveManagement/(?P<operation>.*)', ServeManagementController.serveManagement.as_view()),
     # 测试服务

+ 2 - 2
Controller/AppLogController.py

@@ -83,8 +83,8 @@ class AppLogView(View):
         if uid is None or average_delay is None or status is None or filename is None:
             return response.json(444)
         else:
-            if len(uid) < 20:
-                return response.json(444, 'uid')
+            # if len(uid) < 20:
+            #     return response.json(444, 'uid')
 
             # ModelService.app_log_log(userID, uid)
             now_time = int(time.time())

+ 15 - 6
Controller/CloudStorage.py

@@ -189,6 +189,12 @@ class CloudStorageView(View):
         mold = request_dict.get('mold', None)
         uid = request_dict.get('uid', None)
         lang = request_dict.get('lang', 'en')
+
+        # DVR/NVR设备暂不返回云存套餐列表
+        device_info_qs = Device_Info.objects.filter(Q(UID=uid), Q(Type__lte=4) | Q(Type=10001))
+        if device_info_qs.exists():
+            return response.json(0)
+
         qs = Store_Meal.objects
         eq = ExperienceContextModel.objects.filter(uid=uid, experience_type=0).values('id')
 
@@ -1196,6 +1202,12 @@ class CloudStorageView(View):
         cdk = request_dict.get('cdk', None)
         lang = request_dict.get('lang', 'en')
 
+        redisObj = RedisObject()
+        isLock = redisObj.CONN.setnx(uid+'do_experience_order', 1)
+        redisObj.CONN.expire(uid+'do_experience_order', 60)
+        if not isLock:
+            return response.json(5)
+
         if cdk is not None and pay_type == 11:
             cdk_qs = CDKcontextModel.objects.filter(cdk=cdk).values('is_activate', 'rank__id', 'rank__commodity_code')
             if not cdk_qs.exists():
@@ -1206,13 +1218,9 @@ class CloudStorageView(View):
             commodity_code = cdk_qs[0]['rank__commodity_code']
 
         if uid is None or channel is None or commodity_code is None or pay_type is None or rank is None:
+            redisObj.del_data(key=uid + 'do_experience_order')
             return response.json(13, '参数有误.')
 
-        redisObj = RedisObject()
-        if redisObj.get_data(key=uid+'do_experience_order'):
-            return response.json(5)
-        redisObj.set_data(key=uid+'do_experience_order', val=uid, expire=300)
-
         dvq = Device_Info.objects.filter(UID=uid)
         dvq = dvq.filter(~Q(vodPrimaryUserID='')).values('vodPrimaryUserID')
         if dvq.exists():
@@ -1321,10 +1329,11 @@ class CloudStorageView(View):
                     sms = 'SMS_219748439'
 
                 self.do_vod_msg_Notice(uid, channel, userID, lang, sys_msg_text_list, sms)
-                redisObj.del_data(key=uid+'do_experience_order')
                 result = returnurl
+                redisObj.del_data(key=uid+'do_experience_order')
                 return response.json(0, result)
         except Exception:
+            del_data(key=uid + 'do_experience_order')
             return response.json(474)
         # red_url =
         # return JsonResponse(status=200, data={'red_url': red_url})

+ 4 - 0
Controller/DetectControllerV2.py

@@ -261,7 +261,11 @@ class DetectControllerViewV2(View):
         if not region:
             return response.json(444, 'region')
         region = int(region)
+        now_time = int(time.time())
+
         qs = Equipment_Info.objects.filter(userID_id=userID).order_by('-eventTime')
+        qs = qs.filter(eventTime__gt=now_time - 3600 * 168)
+
         if startTime and endTime:
             qs = qs.filter(eventTime__range=(startTime, endTime))
         if eventType:

+ 2 - 1
Controller/UserManger.py

@@ -144,6 +144,7 @@ class perfectUserInfoView(TemplateView):
             return response.json(104)
         userIconPath = kwargs.get('userIconPath', None)
         userContent = kwargs.get('userContent', None)
+        userIconUrl = ""
         if userIconPath:
             userIconUrl = SERVER_DOMAIN + 'account/getAvatar/' + userIconPath
         if userContent:
@@ -165,7 +166,7 @@ class perfectUserInfoView(TemplateView):
             for k, v in enumerate(res["datas"]):
                 res['datas'][k]['fields'].pop('password')
                 userIconPath = res['datas'][k]['fields']['userIconPath']
-                if userIconPath:
+                if userIconPath and userIconUrl != '':
                     res['datas'][k]['fields']['userIconUrl'] = userIconUrl
             return response.json(0, res)
 

+ 1 - 1
Model/models.py

@@ -533,7 +533,7 @@ class Equipment_Version(models.Model):
     type = models.CharField(blank=True, max_length=16, verbose_name=u'设备机型')
     companyCode = models.CharField(blank=True, max_length=128, verbose_name=u'用户公司名称')
     data_joined = models.DateTimeField(blank=True, verbose_name=u'加入时间', auto_now_add=True)
-    fileSize = models.IntegerField(blank=True, verbose_name=u'文件总大小')
+    fileSize = models.CharField(blank=True, max_length=16, verbose_name=u'文件总大小')
     filePath = models.CharField(blank=True, max_length=256, verbose_name=u'升级文件路径')
     Description = models.TextField(blank=True, default='', verbose_name=u'描述信息')
     fileMd5 = models.CharField(blank=True, max_length=32, default='', verbose_name=u'上传文件MD5加密')

+ 4 - 1
Service/CloudLogs.py

@@ -4,12 +4,13 @@ import datetime
 import time
 
 from bson import utc
+import jwt
 
 from Object.RedisObject import RedisObject
 from Service.CommonService import CommonService
 from Service.MiscellService import MiscellService
 from Service.TemplateService import TemplateService
-from Ansjer.config import SERVER_TYPE
+from Ansjer.config import SERVER_TYPE, OAUTH_ACCESS_TOKEN_SECRET
 from Model.models import CloudLogModel
 from Object.UidTokenObject import UidTokenObject
 
@@ -34,6 +35,8 @@ def batch_add_log_ctr(request, status_code):
         uid = utko.UID
         if not uid:
             uid = request_dict.get('uid', None)
+            if len(uid) > 50:
+                uid = jwt.decode(uid, OAUTH_ACCESS_TOKEN_SECRET, algorithms='HS256').get('uid', '')
         clientIP = CommonService.get_ip_address(request)
         # now_time = datetime.datetime.utcnow().replace(tzinfo=utc).astimezone(utc)
         # beijing = datetime.timezone(datetime.timedelta(hours=8))