|
@@ -11,19 +11,16 @@
|
|
@file: EquipmentStat.py
|
|
@file: EquipmentStat.py
|
|
@Contact: chanjunkai@163.com
|
|
@Contact: chanjunkai@163.com
|
|
"""
|
|
"""
|
|
|
|
+from var_dump import var_dump
|
|
import base64
|
|
import base64
|
|
import urllib.parse
|
|
import urllib.parse
|
|
-from Ansjer.config import BASE_DIR
|
|
|
|
|
|
+
|
|
from django.http import JsonResponse
|
|
from django.http import JsonResponse
|
|
from django.views.decorators.csrf import csrf_exempt
|
|
from django.views.decorators.csrf import csrf_exempt
|
|
-import ipdb
|
|
|
|
-from Object.TokenObject import TokenObject
|
|
|
|
-from Model.models import Device_Info, UID_Preview
|
|
|
|
|
|
+
|
|
|
|
+from Model.models import Device_Info
|
|
from Object.ResponseObject import ResponseObject
|
|
from Object.ResponseObject import ResponseObject
|
|
from Service.CommonService import CommonService
|
|
from Service.CommonService import CommonService
|
|
-import time
|
|
|
|
-import oss2
|
|
|
|
-from Ansjer.config import OSS_STS_ACCESS_SECRET, OSS_STS_ACCESS_KEY
|
|
|
|
|
|
|
|
'''
|
|
'''
|
|
http://192.168.136.45:8077/device/online?UID=C2887N9EBS87ZAT1111A
|
|
http://192.168.136.45:8077/device/online?UID=C2887N9EBS87ZAT1111A
|
|
@@ -111,76 +108,19 @@ def getTZ(request):
|
|
print(uid)
|
|
print(uid)
|
|
info = CommonService.getIpIpInfo(ip=ip, lang=lang)
|
|
info = CommonService.getIpIpInfo(ip=ip, lang=lang)
|
|
tz = info['utc_offset']
|
|
tz = info['utc_offset']
|
|
- gmtz = tz.replace('UTC','GMT')
|
|
|
|
- if ':' not in gmtz:
|
|
|
|
- gmtz = gmtz+':00'
|
|
|
|
- info['gmt_offset'] = gmtz
|
|
|
|
-
|
|
|
|
- # tz = info.timezone
|
|
|
|
- # of = info.utc_offset
|
|
|
|
- # from var_dump import var_dump
|
|
|
|
- # var_dump(info)
|
|
|
|
|
|
+ # 增加GMT,且补:00
|
|
|
|
+ if len(tz) == 5:
|
|
|
|
+ gmtz = tz.replace('UTC-', 'GMT-0').replace('UTC+', 'GMT+0')
|
|
|
|
+ if ':' not in gmtz:
|
|
|
|
+ gmtz = gmtz + ':00'
|
|
|
|
+ info['gmt_offset'] = gmtz
|
|
|
|
+ elif len(tz) == 8:
|
|
|
|
+ gmtz = tz.replace('UTC-', 'GMT-0').replace('UTC+', 'GMT+0')
|
|
|
|
+ info['gmt_offset'] = gmtz
|
|
|
|
+ else:
|
|
|
|
+ return
|
|
return JsonResponse(status=200, data={'code': 0, 'msg': 'success', 'data': info})
|
|
return JsonResponse(status=200, data={'code': 0, 'msg': 'success', 'data': info})
|
|
else:
|
|
else:
|
|
return JsonResponse(status=200, data={'code': 404, 'msg': '令牌错误'})
|
|
return JsonResponse(status=200, data={'code': 404, 'msg': '令牌错误'})
|
|
else:
|
|
else:
|
|
return JsonResponse(status=200, data={'code': 444, 'msg': '接口参数错误 etk'})
|
|
return JsonResponse(status=200, data={'code': 444, 'msg': '接口参数错误 etk'})
|
|
-
|
|
|
|
-#
|
|
|
|
-# # 设备预览图
|
|
|
|
-# def addUIDPreview(request):
|
|
|
|
-# request.encoding = 'utf-8'
|
|
|
|
-# response = ResponseObject()
|
|
|
|
-# if request.method == 'GET':
|
|
|
|
-# request_dict = request.GET
|
|
|
|
-# elif request.method == 'POST':
|
|
|
|
-# request_dict = request.POST
|
|
|
|
-# else:
|
|
|
|
-# return response.json(414)
|
|
|
|
-# channel = request_dict.get('channel')
|
|
|
|
-# uid = request_dict.get('channel')
|
|
|
|
-# token = request_dict.get('token')
|
|
|
|
-# if all([token, uid, channel]):
|
|
|
|
-# tko = TokenObject(token)
|
|
|
|
-# if tko.code == 0:
|
|
|
|
-# nowTime = int(time.time())
|
|
|
|
-# upqs = UID_Preview.objects.filter(uid=uid, channel=channel)
|
|
|
|
-# if upqs.exists():
|
|
|
|
-# try:
|
|
|
|
-# is_update = upqs.update(updTime=nowTime)
|
|
|
|
-# except Exception as e:
|
|
|
|
-# print(repr(e))
|
|
|
|
-# return response.json(177)
|
|
|
|
-# else:
|
|
|
|
-# if is_update:
|
|
|
|
-# auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
|
|
|
|
-# bucket = oss2.Bucket(auth, 'oss-cn-shenzhen.aliyuncs.com', 'apg')
|
|
|
|
-# obj = 'uid_preview/{uid}/{channel}.jpeg'.format(uid=uid, channel=channel)
|
|
|
|
-# # 设置此签名URL在60秒内有效。
|
|
|
|
-# url = bucket.sign_url('PUT', obj, 7200)
|
|
|
|
-# return response.json(0, url)
|
|
|
|
-# else:
|
|
|
|
-# return response.json(177)
|
|
|
|
-# else:
|
|
|
|
-# create_data = {
|
|
|
|
-# 'addTime': nowTime,
|
|
|
|
-# 'updTime': nowTime,
|
|
|
|
-# 'uid': uid,
|
|
|
|
-# 'channel': channel
|
|
|
|
-# }
|
|
|
|
-# try:
|
|
|
|
-# UID_Preview.objects.create(**create_data)
|
|
|
|
-# except Exception as e:
|
|
|
|
-# print(repr(e))
|
|
|
|
-# return response.json(178)
|
|
|
|
-# else:
|
|
|
|
-# auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
|
|
|
|
-# bucket = oss2.Bucket(auth, 'oss-cn-shenzhen.aliyuncs.com', 'apg')
|
|
|
|
-# obj = 'uid_preview/{uid}/{channel}.jpeg'.format(uid=uid, channel=channel)
|
|
|
|
-# # 设置此签名URL在60秒内有效。
|
|
|
|
-# url = bucket.sign_url('PUT', obj, 7200)
|
|
|
|
-# return response.json(0, url)
|
|
|
|
-# else:
|
|
|
|
-# return response.json(tko.code)
|
|
|
|
-# else:
|
|
|
|
-# return response.json(444)
|
|
|