|
@@ -8,7 +8,7 @@
|
|
import json
|
|
import json
|
|
|
|
|
|
from Ansjer.config import SERVER_TYPE
|
|
from Ansjer.config import SERVER_TYPE
|
|
-from Model.models import Order_Model, UID_Bucket, UserExModel, EquipmentLogModel
|
|
|
|
|
|
+from Model.models import Order_Model, UID_Bucket, UserExModel
|
|
from Object.RedisObject import RedisObject
|
|
from Object.RedisObject import RedisObject
|
|
from Object.ResponseObject import ResponseObject
|
|
from Object.ResponseObject import ResponseObject
|
|
from Object.TokenObject import TokenObject
|
|
from Object.TokenObject import TokenObject
|
|
@@ -52,8 +52,6 @@ class Cloudsum(View):
|
|
return self.usercount(userID, request_dict, response)
|
|
return self.usercount(userID, request_dict, response)
|
|
if operation == 'usercloud':
|
|
if operation == 'usercloud':
|
|
return self.usercloud(userID, response)
|
|
return self.usercloud(userID, response)
|
|
- if operation == 'equipment_logs':
|
|
|
|
- return self.equipment_logs(userID, request_dict, response)
|
|
|
|
|
|
|
|
# 类型:用户手机
|
|
# 类型:用户手机
|
|
# 统计用户手机型号 已有
|
|
# 统计用户手机型号 已有
|
|
@@ -128,53 +126,3 @@ class Cloudsum(View):
|
|
a = Order_Model.objects.extra(select={'dates': "FROM_UNIXTIME(addTime,'%%Y-%%m')"}).values(
|
|
a = Order_Model.objects.extra(select={'dates': "FROM_UNIXTIME(addTime,'%%Y-%%m')"}).values(
|
|
'dates').filter(status=1).annotate(开通云存合计=Count('addTime')).order_by('dates')
|
|
'dates').filter(status=1).annotate(开通云存合计=Count('addTime')).order_by('dates')
|
|
return response.json(0, list(a))
|
|
return response.json(0, list(a))
|
|
-
|
|
|
|
- def equipment_logs(self, userID, request_dict, response):
|
|
|
|
- page = int(request_dict.get('page', None))
|
|
|
|
- line = int(request_dict.get('line', None))
|
|
|
|
- order = request_dict.get('order', '-id')
|
|
|
|
- if order == '':
|
|
|
|
- order = '-id'
|
|
|
|
- if not page or not line:
|
|
|
|
- return response.json(444, 'page,line')
|
|
|
|
-
|
|
|
|
- own_perm = ModelService.check_perm(userID=userID, permID=30)
|
|
|
|
- if own_perm is not True:
|
|
|
|
- return response.json(404)
|
|
|
|
-
|
|
|
|
- if SERVER_TYPE == 'Ansjer.formal_settings':
|
|
|
|
- logKey = 'logger'
|
|
|
|
- else:
|
|
|
|
- logKey = 'test_logger'
|
|
|
|
- # 判断redis列表长度
|
|
|
|
- redisObj = RedisObject()
|
|
|
|
- data_list = redisObj.lrange(logKey, 0, -1)
|
|
|
|
- redisObj.del_data(key=logKey)
|
|
|
|
- add_batch_log(data_list)
|
|
|
|
-
|
|
|
|
- qs = EquipmentLogModel.objects.all().order_by(order)
|
|
|
|
- if qs.exists():
|
|
|
|
- count = qs.count()
|
|
|
|
- res = qs[(page - 1) * line:page * line]
|
|
|
|
- send_json = CommonService.qs_to_dict(res)
|
|
|
|
- send_json['count'] = count
|
|
|
|
- return response.json(0, send_json)
|
|
|
|
- return response.json(0, {'datas': [], 'count': 0})
|
|
|
|
-
|
|
|
|
-# 访问日志批量添加
|
|
|
|
-def add_batch_log(data_list):
|
|
|
|
- try:
|
|
|
|
- if data_list:
|
|
|
|
- querysetlist = []
|
|
|
|
- for i in data_list:
|
|
|
|
- data = json.loads(i.decode('utf-8'))
|
|
|
|
- querysetlist.append(EquipmentLogModel(**data))
|
|
|
|
- EquipmentLogModel.objects.bulk_create(querysetlist)
|
|
|
|
- else:
|
|
|
|
- return
|
|
|
|
- except Exception as e:
|
|
|
|
- print('ggga')
|
|
|
|
- print(repr(e))
|
|
|
|
- return False
|
|
|
|
- else:
|
|
|
|
- return True
|
|
|