|
@@ -21,6 +21,7 @@ from Ansjer.config import BASE_DIR
|
|
from Object.ResponseObject import ResponseObject
|
|
from Object.ResponseObject import ResponseObject
|
|
from Object.TokenObject import TokenObject
|
|
from Object.TokenObject import TokenObject
|
|
from Service.ModelService import ModelService
|
|
from Service.ModelService import ModelService
|
|
|
|
+from Model.models import SysMsgModel, Equipment_Info
|
|
|
|
|
|
|
|
|
|
@csrf_exempt
|
|
@csrf_exempt
|
|
@@ -69,12 +70,12 @@ class getStatView(View):
|
|
filePath.encode(encoding='gb2312', errors='strict')
|
|
filePath.encode(encoding='gb2312', errors='strict')
|
|
return self.getFile(filePath, response)
|
|
return self.getFile(filePath, response)
|
|
|
|
|
|
- def getFile(self, filePath,response):
|
|
|
|
|
|
+ def getFile(self, filePath, response):
|
|
if filePath:
|
|
if filePath:
|
|
pass
|
|
pass
|
|
else:
|
|
else:
|
|
return response.json(800)
|
|
return response.json(800)
|
|
- fullPath = os.path.join(BASE_DIR,filePath).replace('\\', '/')
|
|
|
|
|
|
+ fullPath = os.path.join(BASE_DIR, filePath).replace('\\', '/')
|
|
from var_dump import var_dump
|
|
from var_dump import var_dump
|
|
var_dump(fullPath)
|
|
var_dump(fullPath)
|
|
if os.path.isfile(fullPath):
|
|
if os.path.isfile(fullPath):
|
|
@@ -83,4 +84,34 @@ class getStatView(View):
|
|
except Exception as e:
|
|
except Exception as e:
|
|
return response.json(906, repr(e))
|
|
return response.json(906, repr(e))
|
|
else:
|
|
else:
|
|
- return HttpResponse(Imagedata, content_type="image/jpeg")
|
|
|
|
|
|
+ return HttpResponse(Imagedata, content_type="image/jpeg")
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+def initMsgFunc(request):
|
|
|
|
+ response = ResponseObject()
|
|
|
|
+ request.encoding = 'utf-8'
|
|
|
|
+ if request.method == 'GET':
|
|
|
|
+ request_dict = request.GET
|
|
|
|
+ if request.method == 'POST':
|
|
|
|
+ request_dict = request.POST
|
|
|
|
+ else:
|
|
|
|
+ response.json(404)
|
|
|
|
+ token = request_dict.get('token', None)
|
|
|
|
+ content = request_dict.get('content', None)
|
|
|
|
+ if not content:
|
|
|
|
+ return response.json(444, 'content')
|
|
|
|
+ tko = TokenObject(token)
|
|
|
|
+ response.lang = tko.lang
|
|
|
|
+ if tko.code == 0:
|
|
|
|
+ userID = tko.userID
|
|
|
|
+ sm_count = SysMsgModel.objects.filter(userID_id=userID, status=0).count()
|
|
|
|
+ eq_count = Equipment_Info.objects.filter(status=False).count()
|
|
|
|
+ rq_count = Equipment_Info.objects.filter(status=False, eventType=57).count()
|
|
|
|
+ res = {
|
|
|
|
+ 'sm_count': sm_count, # 系统消息未读数量
|
|
|
|
+ 'eq_count': eq_count, # 未读消息总数
|
|
|
|
+ 'rq_count': rq_count, # 人形检测总数
|
|
|
|
+ }
|
|
|
|
+ return response.json(0, res)
|
|
|
|
+ else:
|
|
|
|
+ return response.json(tko.code)
|