|
@@ -11,16 +11,16 @@
|
|
|
@file: EquipmentStat.py
|
|
|
@Contact: chanjunkai@163.com
|
|
|
"""
|
|
|
+import base64
|
|
|
+import urllib.parse
|
|
|
+from Ansjer.config import BASE_DIR
|
|
|
+from django.http import JsonResponse
|
|
|
from django.views.decorators.csrf import csrf_exempt
|
|
|
+
|
|
|
from Model.models import Device_Info
|
|
|
-from django.utils import timezone
|
|
|
-from Service.CommonService import CommonService
|
|
|
-from django.views.generic.base import View
|
|
|
from Object.ResponseObject import ResponseObject
|
|
|
-from Ansjer.config import UID_TOKEN_KEY
|
|
|
-import jwt
|
|
|
-from django.utils.decorators import method_decorator
|
|
|
-from Object.TokenObject import TokenObject
|
|
|
+from Service.CommonService import CommonService
|
|
|
+
|
|
|
'''
|
|
|
http://192.168.136.45:8077/device/online?UID=C2887N9EBS87ZAT1111A
|
|
|
http://192.168.136.45:8077/device/offline?UID=C2887N9EBS87ZAT1111A
|
|
@@ -42,7 +42,6 @@ def EquipmentOnline(request):
|
|
|
return response.json(173)
|
|
|
|
|
|
|
|
|
-
|
|
|
@csrf_exempt
|
|
|
def EquipmentOffline(request):
|
|
|
response = ResponseObject()
|
|
@@ -84,3 +83,33 @@ def updateIP(request):
|
|
|
print(repr(e))
|
|
|
return response.json(0, {'area': area})
|
|
|
|
|
|
+import ipdb
|
|
|
+def getTZ(request):
|
|
|
+ request.encoding = 'utf-8'
|
|
|
+ if request.method == 'GET':
|
|
|
+ request_dict = request.GET
|
|
|
+ elif request.method == 'POST':
|
|
|
+ request_dict = request.POST
|
|
|
+ else:
|
|
|
+ return JsonResponse(status=200, data={'code': 403, 'msg': '接口请求方法错误'})
|
|
|
+ c = request_dict.get('etk', None)
|
|
|
+ ip = request_dict.get('ip',None)
|
|
|
+ lang = request_dict.get('lang',None)
|
|
|
+ if c:
|
|
|
+ c = base64.b64decode(c)
|
|
|
+ c = c[2:-2]
|
|
|
+ c = urllib.parse.unquote(c.decode('utf-8'))
|
|
|
+ c = base64.b64decode(c)
|
|
|
+ uid = c.decode('utf-8')
|
|
|
+ if len(uid) == 20:
|
|
|
+ db = ipdb.City(BASE_DIR + "/DB/mydata4vipday2.ipdb")
|
|
|
+ info = db.find_map(ip, lang)
|
|
|
+ # tz = info.timezone
|
|
|
+ # of = info.utc_offset
|
|
|
+ from var_dump import var_dump
|
|
|
+ var_dump(info)
|
|
|
+ return JsonResponse(status=200, data={'code': 0, 'msg': 'success', 'data': info})
|
|
|
+ else:
|
|
|
+ return JsonResponse(status=200,data={'code':404,'msg':'令牌错误'})
|
|
|
+ else:
|
|
|
+ return JsonResponse(status=200, data={'code': 444, 'msg': '接口参数错误 etk'})
|