|
@@ -22,6 +22,7 @@ from Object.TokenObject import TokenObject
|
|
from Object.UrlTokenObject import UrlTokenObject
|
|
from Object.UrlTokenObject import UrlTokenObject
|
|
from Service.CommonService import CommonService
|
|
from Service.CommonService import CommonService
|
|
from Service.ModelService import ModelService
|
|
from Service.ModelService import ModelService
|
|
|
|
+from Ansjer.config import CONFIG_INFO, CONFIG_CN
|
|
|
|
|
|
|
|
|
|
def downloadUrl(fileType, fileCode, fileVersion, fileName):
|
|
def downloadUrl(fileType, fileCode, fileVersion, fileName):
|
|
@@ -535,6 +536,11 @@ def getNewVerInterface(request):
|
|
|
|
|
|
now_stamp = int(time.time())
|
|
now_stamp = int(time.time())
|
|
if now_ver <= max_ver:
|
|
if now_ver <= max_ver:
|
|
|
|
+
|
|
|
|
+ ver_result = check_version(uid, tko.userID, equipment.data_json)
|
|
|
|
+ if not ver_result: # 当前设备对应版本号不显示最新版本
|
|
|
|
+ return response.json(902)
|
|
|
|
+
|
|
# 创建url的token
|
|
# 创建url的token
|
|
param_url = "ansjer/" + CommonService.RandomStr(6) + "/" + file_path
|
|
param_url = "ansjer/" + CommonService.RandomStr(6) + "/" + file_path
|
|
data = {'Url': param_url, 'user_id': tko.userID,
|
|
data = {'Url': param_url, 'user_id': tko.userID,
|
|
@@ -580,6 +586,32 @@ def getNewVerInterface(request):
|
|
return response.json(902)
|
|
return response.json(902)
|
|
|
|
|
|
|
|
|
|
|
|
+def check_version(uid, user_id, ver_data):
|
|
|
|
+ """
|
|
|
|
+ :param uid: 设备UID
|
|
|
|
+ :param user_id: 用户id
|
|
|
|
+ :param ver_data: 版本指定升级数据
|
|
|
|
+ :return: True | False
|
|
|
|
+ """
|
|
|
|
+ try:
|
|
|
|
+ if not ver_data: # 默认当前版本所有设备
|
|
|
|
+ return True
|
|
|
|
+
|
|
|
|
+ if uid and ver_data['uid_list']: # 当前版本指定UID
|
|
|
|
+ return uid in ver_data['uid_list']
|
|
|
|
+ if user_id and ver_data['country_list'] and CONFIG_INFO != CONFIG_CN: # 当前版本指定用户国家
|
|
|
|
+ user_qs = Device_User.objects.filter(userID=user_id).values('region_country')
|
|
|
|
+ if not user_qs.exists(): # 用户不存在不升级
|
|
|
|
+ return False
|
|
|
|
+ if user_qs[0]['region_country'] == 0: # 用户未选择国家 不进行升级提示
|
|
|
|
+ return False
|
|
|
|
+ return user_qs[0]['region_country'] in ver_data['country_list']
|
|
|
|
+ return True
|
|
|
|
+ except Exception as e:
|
|
|
|
+ print(repr(e))
|
|
|
|
+ return True
|
|
|
|
+
|
|
|
|
+
|
|
# ota包上传
|
|
# ota包上传
|
|
class uploadOTAInterfaceView(TemplateView):
|
|
class uploadOTAInterfaceView(TemplateView):
|
|
@method_decorator(csrf_exempt)
|
|
@method_decorator(csrf_exempt)
|