|
@@ -9,9 +9,10 @@ from django.views import View
|
|
|
from django.views.decorators.csrf import csrf_exempt
|
|
|
|
|
|
from Ansjer.config import BASE_DIR
|
|
|
-from Model.models import RegionModel, CompanyModel, VPGModel, UIDModel
|
|
|
+from Model.models import RegionModel, CompanyModel, VPGModel, UIDModel, MacModel, UIDCompanySerialModel
|
|
|
from Object.uidManageResponseObject import uidManageResponseObject
|
|
|
from Object.TokenObject import TokenObject
|
|
|
+from Service.CommonService import CommonService
|
|
|
from Service.ModelService import ModelService
|
|
|
|
|
|
|
|
@@ -172,13 +173,20 @@ class VPGView(View):
|
|
|
|
|
|
def do_uid_list(self, userID, request_dict, response):
|
|
|
vpg_id = request_dict.get('vpg_id', None)
|
|
|
- page = request_dict.get('page', None)
|
|
|
- line = request_dict.get('limit', None)
|
|
|
+ page = int(request_dict.get('page', None))
|
|
|
+ line = int(request_dict.get('limit', None))
|
|
|
|
|
|
if not vpg_id:
|
|
|
return response.json(444)
|
|
|
+
|
|
|
+ start = (page - 1) * line
|
|
|
+ end = start + line
|
|
|
uid_qs = UIDModel.objects.filter(vpg_id=vpg_id).values('uid')
|
|
|
+
|
|
|
+ count = VPGModel.objects.get(id=vpg_id).uid_count # 从vpg表获取uid总数
|
|
|
+ uid_qs = uid_qs[start:end] # 显示条数
|
|
|
res = {
|
|
|
+ 'count': count,
|
|
|
'data': list(uid_qs),
|
|
|
}
|
|
|
return response.json(0, res)
|
|
@@ -204,6 +212,11 @@ def do_upload_uid(request):
|
|
|
|
|
|
bulk = []
|
|
|
add_time = update_time = int(time.time())
|
|
|
+ MAC = MacModel.objects.filter().values('id', 'value', 'is_active')[0] # 获取最新可用的mac
|
|
|
+ current_mac = MAC['value']
|
|
|
+ if (not MAC['is_active']) or (current_mac[-8:] == 'FF.FF.FF'):
|
|
|
+ return response.json(175)
|
|
|
+
|
|
|
# path = '/'.join((BASE_DIR, 'static/uid')).replace('\\', '/') + '/'
|
|
|
# if not os.path.exists(path):
|
|
|
# os.makedirs(path)
|
|
@@ -220,7 +233,7 @@ def do_upload_uid(request):
|
|
|
for uid in uid_list:
|
|
|
bulk.append(UIDModel(
|
|
|
uid=uid,
|
|
|
- mac='74:19:F8:DC:CA:C9', # mac['value']
|
|
|
+ mac=current_mac,
|
|
|
uid_extra='',
|
|
|
status=0,
|
|
|
add_time=add_time,
|
|
@@ -228,10 +241,17 @@ def do_upload_uid(request):
|
|
|
area=0, # 关联vgp表已有区域信息,可以考虑去掉
|
|
|
vpg_id=vpg_id
|
|
|
))
|
|
|
+ temp_mac = CommonService.updateMac(current_mac) # mac地址值+1;后3个字节为FF时返回None
|
|
|
+ if temp_mac:
|
|
|
+ current_mac = temp_mac # 更新赋值写入uid表
|
|
|
+ else:
|
|
|
+ temp_mac = current_mac # 赋值为FF写入mac表
|
|
|
+ break
|
|
|
with transaction.atomic():
|
|
|
UIDModel.objects.bulk_create(bulk) # 批量写入uid数据
|
|
|
uid_count = UIDModel.objects.filter(vpg_id=vpg_id).count() # 获取族群下uid的数量
|
|
|
VPGModel.objects.filter(id=vpg_id).update(uid_count=uid_count) # 更新vgp表的uid_count
|
|
|
+ MacModel.objects.filter().update(value=temp_mac) # 更新mac表的mac地址值
|
|
|
return response.json(0)
|
|
|
except Exception as e:
|
|
|
print(e)
|