From 3f79b3dbdc9eebec0321de60546244960d34c755 Mon Sep 17 00:00:00 2001 From: shilixia <2309368887@qq.com> Date: Mon, 25 Nov 2019 11:54:43 +0800 Subject: [PATCH] xiugai --- safesite/templates/equipmentfigure.html | 280 +++++++++++++++++++++++- safesite/urls.py | 2 +- safesite/views.py | 20 +- 3 files changed, 299 insertions(+), 3 deletions(-) diff --git a/safesite/templates/equipmentfigure.html b/safesite/templates/equipmentfigure.html index 98f380eb..c038d430 100644 --- a/safesite/templates/equipmentfigure.html +++ b/safesite/templates/equipmentfigure.html @@ -1 +1,279 @@ -
正在完成
\ No newline at end of file + + + + +
+ +
+
+ + + + +
+ +
+
+
+ +
+ +
+
+
+ + + + + + + + +
姓名用户名培训次数
+
+
+ +
+ + + + 查询 + 导出 +
+ +
+
+
+
+ +
diff --git a/safesite/urls.py b/safesite/urls.py index 0730db2b..934b6455 100644 --- a/safesite/urls.py +++ b/safesite/urls.py @@ -158,7 +158,7 @@ urlpatterns = [ path('api/riskas',views.apiriskas), path('api/trainfg',views.trainfg), path('api/check_session',views.check_session), - + path('api/equipmentfig',views.equipmentfig),#设备统计图 #path('api/rights/group/',views.rightsgroup), path('api/main',views.mainapi), path('bindwechat', views.bwlogin,name='bwlogin'), #微信登陆绑定相关 diff --git a/safesite/views.py b/safesite/views.py index c3de2af4..e18c6cd1 100644 --- a/safesite/views.py +++ b/safesite/views.py @@ -6145,4 +6145,22 @@ def trainfg(req): dickeyname=i.dickeyname traintypelist.append({'value':count,'name':dickeyname}) return HttpResponse(json.dumps({'code':1,'data':{'traintypelist':list(traintypelist)}}), content_type='application/json') - \ No newline at end of file +#设备统计图 + +def equipmentfig(req): + a = req.GET.get('a') + userid = req.session['userid'] + companyid = getcompany(userid) + + if a=='state': + # year = int(req.GET.get('year')) + # month = int(req.GET.get('month')) + # first_day,first_day_of_next_month = gettime(datetime(year,month,1)) + a = Equipment.objects.filter(usecomp__partid=companyid,deletemark=1) + normal = a.filter(state=1).count()#正常 + abnormal = a.filter(state=0).count()#异常 + return JsonResponse({"code":1,"normal":normal,"abnormal":abnormal}) + elif a=='eqmcount': + eqmlist=Equipment.objects.filter(usecomp__partid=companyid,deletemark=1).values('area__name').annotate(num = Count('area')) + + return HttpResponse(json.dumps({'code':1,'data':{'eqmlist':list(eqmlist)}}), content_type='application/json') \ No newline at end of file