|
@@ -31,6 +31,7 @@ from Object.ResponseObject import ResponseObject
|
|
from Object.TokenObject import TokenObject
|
|
from Object.TokenObject import TokenObject
|
|
from Object.UidTokenObject import UidTokenObject
|
|
from Object.UidTokenObject import UidTokenObject
|
|
from django.http import JsonResponse
|
|
from django.http import JsonResponse
|
|
|
|
+from Service.CommonService import CommonService
|
|
|
|
|
|
|
|
|
|
# http://192.168.136.40:8077/detect/changeStatus?uid=JW3684H8BSHG9TTM111A&token_val=18071adc03536302f34&appBundleId=com.ansjer.zccloud_ab&push_type=2&token=local&status=1
|
|
# http://192.168.136.40:8077/detect/changeStatus?uid=JW3684H8BSHG9TTM111A&token_val=18071adc03536302f34&appBundleId=com.ansjer.zccloud_ab&push_type=2&token=local&status=1
|
|
@@ -59,11 +60,40 @@ class DetectControllerView(View):
|
|
userID = tko.userID
|
|
userID = tko.userID
|
|
if operation == 'changeStatus':
|
|
if operation == 'changeStatus':
|
|
return self.do_change_status(userID, request_dict, response)
|
|
return self.do_change_status(userID, request_dict, response)
|
|
|
|
+ if operation == 'queryInfo':
|
|
|
|
+ return self.do_query(request_dict, response, userID)
|
|
else:
|
|
else:
|
|
return response.json(414)
|
|
return response.json(414)
|
|
else:
|
|
else:
|
|
return response.json(tko.code)
|
|
return response.json(tko.code)
|
|
|
|
|
|
|
|
+ def do_query(self, request_dict, response, userID):
|
|
|
|
+ page = int(request_dict.get('page', None))
|
|
|
|
+ line = int(request_dict.get('line', None))
|
|
|
|
+ if not page or not line:
|
|
|
|
+ return response.json(444, 'page,line')
|
|
|
|
+ qs = Equipment_Info.objects.filter(userID_id=userID)
|
|
|
|
+ uid = request_dict.get('uid', None)
|
|
|
|
+ if uid:
|
|
|
|
+ qs.filter(devUid=uid)
|
|
|
|
+ if not qs.exists():
|
|
|
|
+ return response.json(0, {'datas': [], 'count': 0})
|
|
|
|
+ qs = qs.values('id', 'devUid', 'devNickName', 'Channel', 'eventType', 'status', 'alarm', 'eventTime',
|
|
|
|
+ 'receiveTime')
|
|
|
|
+ count = qs.count()
|
|
|
|
+ qr = qs[(page - 1) * line:page * line]
|
|
|
|
+ # send_json = CommonService.qs_to_dict(res)
|
|
|
|
+ res = []
|
|
|
|
+ import oss2
|
|
|
|
+ auth = oss2.Auth('LTAIyMkGfEdogyL9', '71uIjpsqVOmF7DAITRyRuc259jHOjO')
|
|
|
|
+ bucket = oss2.Bucket(auth, 'oss-cn-shenzhen.aliyuncs.com', 'apg')
|
|
|
|
+ for p in qr:
|
|
|
|
+ p['img'] = bucket.sign_url('GET',
|
|
|
|
+ '{uid}/{channel}/{time}.jpeg'.format(uid=p['devUid'], channel=p['Channel'],
|
|
|
|
+ time=p['time']), 300)
|
|
|
|
+ res.append(p)
|
|
|
|
+ return response.json(0, {'datas': res, 'count': count})
|
|
|
|
+
|
|
def do_change_status(self, userID, request_dict, response):
|
|
def do_change_status(self, userID, request_dict, response):
|
|
uid = request_dict.get('uid', None)
|
|
uid = request_dict.get('uid', None)
|
|
token_val = request_dict.get('token_val', None)
|
|
token_val = request_dict.get('token_val', None)
|