From add6f8b46c1baee2a95a70cb8861f56c61178268 Mon Sep 17 00:00:00 2001 From: shilixia <2309368887@qq.com> Date: Thu, 7 Nov 2019 10:42:03 +0800 Subject: [PATCH 1/5] shanxingxiugai --- safesite/templates/examfigure.html | 4 ++-- safesite/urls.py | 1 - safesite/views.py | 3 ++- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/safesite/templates/examfigure.html b/safesite/templates/examfigure.html index ab227e46..ca280e04 100644 --- a/safesite/templates/examfigure.html +++ b/safesite/templates/examfigure.html @@ -72,7 +72,7 @@ $.ajax({ type: "get", async: true, //异步请求(同步请求将会锁住浏览器,用户其他操作必须等待请求完成才可以执行) - url: "api/trainfg?a=trainfig&year=" + y, //请求发送 + url: "api/examtj?a=trainfig&year=" + y, //请求发送 dataType: "json", //返回数据形式为json success: function (data) { //请求成功时执行该函数内容,data即为服务器返回的json对象 @@ -177,7 +177,7 @@ $.ajax({ type: "get", async: true, //异步请求(同步请求将会锁住浏览器,用户其他操作必须等待请求完成才可以执行) - url: "api/trainfg?a=traintype&year=" + y + "&month=" + m, //请求发送 + url: "api/examtj?a=traintype&year=" + y + "&month=" + m, //请求发送 dataType: "json", //返回数据形式为json success: function (data) { //请求成功时执行该函数内容,data即为服务器返回的json对象 diff --git a/safesite/urls.py b/safesite/urls.py index 31735cea..37caa876 100644 --- a/safesite/urls.py +++ b/safesite/urls.py @@ -157,7 +157,6 @@ urlpatterns = [ path('api/obscount',views.observepic), path('api/riskas',views.apiriskas), path('api/trainfg',views.trainfg), - path('api/examtj',views.examtj), path('api/check_session',views.check_session), #path('api/rights/group/',views.rightsgroup), diff --git a/safesite/views.py b/safesite/views.py index 58208ee0..d3ad63b3 100644 --- a/safesite/views.py +++ b/safesite/views.py @@ -6137,10 +6137,11 @@ def trainfg(req): first_day,first_day_of_next_month = gettime(datetime(year,month,1)) a = Train.objects.filter(usecomp__partid=companyid,deletemark=1,starttime__range=(first_day, first_day_of_next_month)) - for i in Dickey.objects.filter(dicparent_id=8): + for i in Dickey.objects.filter(Q(usecomps__contains=',1,' )|Q(usecomps__contains=','+str(companyid)+','),dicparent_id=8): count=a.filter(traintype__dickeyid=i.dickeyid).count() 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 From 11b09e42886178147e34b17318df4f0aa0971ddc Mon Sep 17 00:00:00 2001 From: shilixia <2309368887@qq.com> Date: Thu, 7 Nov 2019 14:16:02 +0800 Subject: [PATCH 2/5] cdjhkf --- safesite/templates/equipmentfigure.html | 1 + safesite/templates/examfigure.html | 268 ------------------------ safesite/templates/trainfigure.html | 2 + safesite/urls.py | 2 +- safesite/views.py | 13 +- 5 files changed, 11 insertions(+), 275 deletions(-) create mode 100644 safesite/templates/equipmentfigure.html delete mode 100644 safesite/templates/examfigure.html diff --git a/safesite/templates/equipmentfigure.html b/safesite/templates/equipmentfigure.html new file mode 100644 index 00000000..98f380eb --- /dev/null +++ b/safesite/templates/equipmentfigure.html @@ -0,0 +1 @@ +
正在完成
\ No newline at end of file diff --git a/safesite/templates/examfigure.html b/safesite/templates/examfigure.html deleted file mode 100644 index ca280e04..00000000 --- a/safesite/templates/examfigure.html +++ /dev/null @@ -1,268 +0,0 @@ - - - - -
- -
-
- - - - -
- -
-
-
- - - - -
- -
-
-
-
- - diff --git a/safesite/templates/trainfigure.html b/safesite/templates/trainfigure.html index 4f601349..d5a4bd3f 100644 --- a/safesite/templates/trainfigure.html +++ b/safesite/templates/trainfigure.html @@ -310,6 +310,8 @@
+ + 查询 导出
diff --git a/safesite/urls.py b/safesite/urls.py index 37caa876..0730db2b 100644 --- a/safesite/urls.py +++ b/safesite/urls.py @@ -90,7 +90,7 @@ urlpatterns = [ path('html/examhistory//',views.examhistory), path('html/riskact/chose',views.riskactchose), path('html/trainfig',views.trainfigure), - path('html/examfig',views.examfigure), + path('html/equipmentfig',views.equipmentfigure), #html页面 diff --git a/safesite/views.py b/safesite/views.py index d3ad63b3..c3de2af4 100644 --- a/safesite/views.py +++ b/safesite/views.py @@ -250,8 +250,8 @@ def bhrhtml(req): return render(req,'behavior.html') def trainfigure(req): return render(req,'trainfigure.html') -def examfigure(req): - return render(req,'examfigure.html') +def equipmentfigure(req): + return render(req,'equipmentfigure.html') def check_login(func): @@ -6122,7 +6122,10 @@ def trainfg(req): return JsonResponse({'code':1,'companylevel':companylevel,'workshoplevel':workshoplevel,'teamlevel':teamlevel,'departmentlevel':departmentlevel}) elif a=='trainuser': a = Trainuser.objects.filter(participant__usecomp__partid=companyid) - + if req.GET.get('qssj'): + a = a.filter(train__submittime__gte=req.GET.get('qssj')) + if req.GET.get('jssj'): + a = a.filter(train__submittime__lte=req.GET.get('jssj')) if req.GET.get('fxbm'): fxbm = req.GET.get('fxbm') parts = Partment.objects.filter(partlink__contains=',' + fxbm + ',')|Partment.objects.filter(partid=fxbm) @@ -6142,6 +6145,4 @@ 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 + \ No newline at end of file From 306a5d84976f3b905372afaef5951dd49cd46a01 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Wed, 20 Nov 2019 14:19:51 +0800 Subject: [PATCH 3/5] password encrapt daoru --- safesite/daoru.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/safesite/daoru.py b/safesite/daoru.py index 2dace7f4..8af79c88 100644 --- a/safesite/daoru.py +++ b/safesite/daoru.py @@ -8,6 +8,7 @@ import base64 from django.conf import settings import qrcode import os +from django.contrib.auth.hashers import make_password def makeqr(data): upload_folder = 'media/qr_equipment' @@ -311,6 +312,7 @@ def drusers(companyid,path): a.empid = empid a.username = username a.password = '0000' + a.epassword = make_password('0000') a.ubelongpart = Partment.objects.get(partid=partdict[partname]) a.usecomp = Partment.objects.get(partid=companyid) a.save() From e8b6e827ebc4fb6110652aff2c0a37f3476b17b1 Mon Sep 17 00:00:00 2001 From: shilixia <2309368887@qq.com> Date: Wed, 20 Nov 2019 14:33:29 +0800 Subject: [PATCH 4/5] kaoshi --- mysite/settings.py | 4 +- safesite/templates/equipmentfigure.html | 280 +++++++++++++++++++++++- safesite/templates/examhistory.html | 21 +- safesite/urls.py | 2 +- safesite/views.py | 20 +- 5 files changed, 318 insertions(+), 9 deletions(-) diff --git a/mysite/settings.py b/mysite/settings.py index 01ffba4e..8f76d9a8 100644 --- a/mysite/settings.py +++ b/mysite/settings.py @@ -85,8 +85,8 @@ DATABASES = { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'safedb', 'USER':'postgres', - 'PASSWORD':'0000', - 'HOST':'114.115.210.98', + 'PASSWORD':'cTc1111Qa', + 'HOST':'121.36.23.77', 'PORT':'5432', 'CONN_MAX_AGE': 600, }, 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/templates/examhistory.html b/safesite/templates/examhistory.html index b3ea40ea..fdcabb1a 100644 --- a/safesite/templates/examhistory.html +++ b/safesite/templates/examhistory.html @@ -1,4 +1,4 @@ - + @@ -30,6 +30,7 @@ type: "get", url: "/api/examtestdetail?a=detail", data: { 'id': id }, + async: true, dateType: "json", success: function (data) { document.getElementById("examname").innerHTML = data.examtest__name; @@ -49,7 +50,9 @@ divHtml += '' + "【判断题】"+"第"+i+"题:" + data.testdetail[i].question__title +''; divHtml += '此题得分:' + data.testdetail[i].iscore + ' 分'; divHtml += '
'; - divHtml += '
A.' + data.testdetail[i].question__answer.A + '

B.' + data.testdetail[i].question__answer.B +'
'; + for (var item in data.testdetail[i].question__answer) { + divHtml += '
' + item + '、' + data.testdetail[i].question__answer[item] + '
'; + } divHtml += '
'; divHtml += '
'; divHtml += '
正确答案:' + data.testdetail[i].question__right + '
'; @@ -62,13 +65,16 @@ divHtml += '
' + (data.testdetail[i].question_resolution == undefined ? '本题无解析!' : data.testdetail[i].question_resolution) +'
'; } else if (data.testdetail[i].question__type == 2) { + console.log(data.testdetail[i]) var divHtml = ""; var answrText = ""; divHtml += '
'; divHtml += '' + "【多选题】" +"第" + i + "题:" + data.testdetail[i].question__title + ''; divHtml += '此题得分:' + data.testdetail[i].iscore + ' 分'; divHtml += '
'; - divHtml += '
A.' + data.testdetail[i].question__answer.A + '

B.' + data.testdetail[i].question__answer.B + '

C.' + data.testdetail[i].question__answer.C + '

D.' + data.testdetail[i].question__answer.D + '

E.' + (data.testdetail[i].question__answer.E == undefined ? '无该选项' : data.testdetail[i].question__answer.E) + '

F.' + (data.testdetail[i].question__answer.F == undefined ? '无该选项' : data.testdetail[i].question__answer.F) + '
'; + for (var item in data.testdetail[i].question__answer) { + divHtml += '
' + item + '、' + data.testdetail[i].question__answer[item] + '
'; + } divHtml += '
'; divHtml += '
'; divHtml += '
正确答案:' + data.testdetail[i].question__right + '
'; @@ -91,7 +97,14 @@ divHtml += '' + "【单选题】" + "第" + i + "题:" + data.testdetail[i].question__title + ''; divHtml += '此题得分:' + data.testdetail[i].iscore + ' 分'; divHtml += '
'; - divHtml += '
A.' + data.testdetail[i].question__answer.A + '

B.' + data.testdetail[i].question__answer.B + '

C.' + data.testdetail[i].question__answer.C + '

D.' + data.testdetail[i].question__answer.D + '
'; + for (var item in data.testdetail[i].question__answer) { + if (data.testdetail[i].question__answer[item] != "") + { + divHtml += '
' + item + '、' + data.testdetail[i].question__answer[item] + '
'; + } + + } + divHtml += '
'; divHtml += '
'; divHtml += '
正确答案:' + data.testdetail[i].question__right + '
'; 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 From c552919c622e3836b8cb7d04a82b1414311e8851 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 22 Nov 2019 17:49:08 +0800 Subject: [PATCH 5/5] login safety --- mysite/settings.py | 2 +- safesite/templates/abdrill.html | 2 +- safesite/templates/abtrain.html | 2 +- safesite/templates/noticeadd.html | 2 +- safesite/views.py | 606 ++++++++++++++++-------------- 5 files changed, 336 insertions(+), 278 deletions(-) diff --git a/mysite/settings.py b/mysite/settings.py index f6d1e1e9..5c9618d6 100644 --- a/mysite/settings.py +++ b/mysite/settings.py @@ -145,7 +145,7 @@ CELERY_TIMEZONE='Asia/Shanghai' CELERY_ENABLE_UTC=True ##配置session -SESSION_EXPIRE_AT_BROWSER_CLOSE = True +#SESSION_EXPIRE_AT_BROWSER_CLOSE = True SESSION_COOKIE_AGE = 1800 SESSION_SAVE_EVERY_REQUEST = True diff --git a/safesite/templates/abdrill.html b/safesite/templates/abdrill.html index 3a059c9f..ede12494 100644 --- a/safesite/templates/abdrill.html +++ b/safesite/templates/abdrill.html @@ -90,7 +90,7 @@ required=true>
- +
- +