From b698651baaa6c89ef1021aced28b380f2868612f Mon Sep 17 00:00:00 2001 From: shilixia <2309368887@qq.com> Date: Fri, 18 Oct 2019 16:37:19 +0800 Subject: [PATCH] xingweitongji --- .../static/safesite/easyui/themes/icon.css | 4 +- .../safesite/easyui/themes/icons/behv.png | Bin 0 -> 1066 bytes safesite/templates/behavior.html | 312 ++++++++++++++++++ safesite/urls.py | 4 +- safesite/views.py | 80 ++++- static/safesite/easyui/themes/icons/behv.png | Bin 0 -> 1066 bytes 6 files changed, 396 insertions(+), 4 deletions(-) create mode 100644 safesite/static/safesite/easyui/themes/icons/behv.png create mode 100644 safesite/templates/behavior.html create mode 100644 static/safesite/easyui/themes/icons/behv.png diff --git a/safesite/static/safesite/easyui/themes/icon.css b/safesite/static/safesite/easyui/themes/icon.css index ec677c31..b3d93cc6 100644 --- a/safesite/static/safesite/easyui/themes/icon.css +++ b/safesite/static/safesite/easyui/themes/icon.css @@ -166,7 +166,9 @@ .icon-taskdo{ background:url('icons/taskdo.png') no-repeat center center; } - +.icon-bhr { + background: url('icons/behv.png') no-repeat center center; +} diff --git a/safesite/static/safesite/easyui/themes/icons/behv.png b/safesite/static/safesite/easyui/themes/icons/behv.png new file mode 100644 index 0000000000000000000000000000000000000000..8ce205131966ff32cc66a1dbe1dffc9f88b01ba7 GIT binary patch literal 1066 zcmV+_1l9YAP)q*e8g6f_P34e1dpR5a$G8P7u68nJmI= zB)>O{!5gpzsPd|%7A;v4diI;q3R>!}Usb<;RTC;coz<_uacK1cJ^-UjL|xg+%u^7i z0FB8CM_&Ewr;10aI<7I#}uR?W9yIswqCc<>Cw!+HJod`8pRwmpRaI;&p>2x}iU zhWQGN%h19Ibxg0xoyy@q1wS9usMaE;0T=@!JdcgeV6Bh6`d^o2AaVh;gWh`r#A`74 zPbQpQH{8)SZ{+>n(&-c9j6koV{TTZ81m)g0_bTGhy*~K^N-4N;={)p*PtR0 z^)KqbwSJxDgaV-0zTEw;egdbyJsCbE?0U~0J6%mu#f!i>vOq%U*}SpXH>*Pd=-fGH zAbJPzm1nyL4>c}^ttE-KEzt+Iaj1c`181a&$^5&wrv z44nJ+MAd%L(+PSKUX`LeuA~9*RoKA5V)xr zJZ~%xcbB_IqI$xkg}pc^YeJo%m$D}j*a|>&VmD}hkrphuUo;jMPnJzlxECp~IYM)v zs2Kq5yWUhfSXm14bRrfnDc|I&nnttYwvy14(kxLsfisJAK6e&z<+qQtGZ;u>W#$8`>iUPTZRU?#-2TSsSi)L(|iE3st1xP&8vOqd{?8K!IfBw zqfnY5+_dJ{f5s<&XEMmEkSc2%o#2~!0SCDn`=Jo0V#P!5bp7BO8&!#4Nx#HEUH z`KBE>pH({Zno(>_CfldkDM*l432zyYO*+%w%bx#yAW2Dh(LiDlFCNJ-3yEJp*7LZ8 zr3K5NliTd_hSH>`Gr|+!{(4?D&&4IG-YD75%5>3Kt|Or~hQy~;qY;ng@3el1=LGJ@ zvV9N4mWzoc(NIbkUBT#*i7(B8M8+_z@Z19WkjqItFUVvKD?E}R)U2p%B(`78g60WG zE-4$yEl&yGfH9ogw?i}BMIcH6n1)0#IjqH(Q|js~m}mru + var now = new Date(); + $(function () { + year = now.getFullYear(); + month = now.getMonth() + 1; + for (var i = 0; i < 5; i++) { + $('#year').append(''); + } + $.get('api/tool?a=servertime', function (res) { + $('#year').combobox().combobox('setValue', res.year); + $('#month').combobox().combobox('setValue', res.month); + behaviorDate(); + }) + + }); + $("#sfxbm2").combotree({ + url: 'parthandle?a=tree', + editable: false, + loadFilter: function (rows) { + return convert(rows); + }, + formatter: function (node) { + var s = node.text; + if (node.children) { + s += ' (' + node.children.length + ')'; + } + return s; + }, + onSelect: function (node) { + $('#sfxr').combobox({ + url: 'getuser?partid=' + node.id + '&a=combobox', + editable: false, + }); + } + }); + function gcpmsearch() { + var querydata = $('#fxrpms').serializeJSON(); + $('#fxrpmtable').datagrid('load', querydata); + } + function gcpmexport() { + var data = $('#fxrpmtable').datagrid('getData'); + var datalist = data.rows; + + for (var j = 0, len = datalist.length; j < len; j++) { + var dic = datalist[j] + for (var key in dic) { + dic["观察人"] = dic["looker__name"] + dic["观察部门"] = dic["lookpart__partname"] + dic["行为观察数"] = dic["number"] + delete dic["looker__userid"]; + delete dic["looker__name"] + delete dic["lookpart__partname"] + delete dic["number"] + } + } + JSONToCSVConvertor(JSON.stringify(datalist), "观察行为排名", true); + } + function behaviorDate() + { + var y = $("#year").val(); + var m = $("#month").val(); + var gcChart = echarts.init(document.getElementById("piecontainer")); + + gcChart.setOption(option = { + title: { + text: '观察类型分布', + x: 'left' + }, + tooltip: { + trigger: 'item', + formatter: "{a}
{b} : {c} ({d}%)" + }, + legend: { + orient: 'vertical', + x: 'left', + y: 'bottom', + data: [] + }, + toolbox: { + show: true, + feature: { + mark: { show: true }, + dataView: { show: true, readOnly: false }, + restore: { show: true }, + saveAsImage: { show: true } + } + }, + calculable: true, + series: [ + { + name: '级别分布', + type: 'pie', + radius: '55%', + roseType: 'angle', + center: ['50%', '60%'], + itemStyle: { + normal: { + label: { + show: false + }, + labelLine: { + show: false + } + }, + emphasis: { + label: { + show: true, + position: 'center', + textStyle: { + fontSize: '22', + fontWeight: 'bold' + } + } + } + }, + data: [] + } + ] + }); + gcChart.showLoading(); + $.ajax({ + type: "get", + async: true, //异步请求(同步请求将会锁住浏览器,用户其他操作必须等待请求完成才可以执行) + url: "api/obscount?a=gclxt&year=" + y + "&month=" + m, //请求发送 + dataType: "json", //返回数据形式为json + success: function (data) { + //请求成功时执行该函数内容,data即为服务器返回的json对象 + + if (data) { + gcChart.hideLoading(); //隐藏加载动画 + gcChart.setOption({ + legend: { data: data.key }, + series: { + name: '级别分布', + data: data.value, + } + } + ); + + } + }, + error: function (errorMsg) { + gcChart.hideLoading(); + } + }); + + } + + + function funTypeChange() { + behaviorDate();//饼图 + } + + var y = now.getFullYear(); + //行为观察折线图 + $.ajax({ + type: "get", + async: true, //异步请求(同步请求将会锁住浏览器,用户其他操作必须等待请求完成才可以执行) + url: "api/obscount?a=gclzx&year=" + y, //请求发送 + dataType: "json", //返回数据形式为json + success: function (data) { + //请求成功时执行该函数内容,data即为服务器返回的json对象 + + var gcChart2 = echarts.init(document.getElementById("piecontainer2")); + gcChart2.hideLoading(); + gcChart2.setOption(option = { + title: { + text: '行为观察折线图' + }, + tooltip: { + trigger: 'axis' + }, + legend: { + data: ['人员的反映', '员工的位置', '个人防护装备', '工具和设备', '程序和标准','人体工程学','环境整洁'] + }, + grid: { + left: '3%', + right: '4%', + bottom: '3%', + containLabel: true + }, + toolbox: { + feature: { + saveAsImage: {} + } + }, + xAxis: { + type: 'category', + boundaryGap: false, + data: data.months + }, + yAxis: { + type: 'value' + }, + series: [ + { + name: '人员的反映', + type: 'line', + stack: '总量', + data: data.userfy + }, + { + name: '员工的位置', + type: 'line', + stack: '总量', + data: data.userwz + }, + { + name: '个人防护装备', + type: 'line', + stack: '总量', + data: data.grfh + }, + { + name: '工具和设备', + type: 'line', + stack: '总量', + data: data.gjhsb + }, + { + name: '程序和标准', + type: 'line', + stack: '总量', + data: data.cxhbz + } + , + { + name: '人体工程学', + type: 'line', + stack: '总量', + data: data.rtgcx + }, + { + name: '环境整洁', + type: 'line', + stack: '总量', + data: data.hjzj + } + ] + }); + }, + error: function (errorMsg) { + gcChart2.hideLoading(); + } + }); + + + + +
+ + +
+ +
+
+
+ + + + +
+ +
+
+
+ + + + + + + + + + +
用户ID观察人姓名观察部门行为观察数
+
+
+ 查询 + 导出 +
+ + + +
+ +
+
+ + + +
+
+
+ + + \ No newline at end of file diff --git a/safesite/urls.py b/safesite/urls.py index cb895384..358858c4 100644 --- a/safesite/urls.py +++ b/safesite/urls.py @@ -85,6 +85,8 @@ urlpatterns = [ path('html/riskcheck',views.riskcheck), path('html/risk/edit//',views.riskedit), path('html/report/edit',views.reportedit), + path('html/bhr',views.bhrhtml), + #html页面 @@ -149,7 +151,7 @@ urlpatterns = [ path('api/riskcheck2',views.apiriskcheck2), path('api/report',views.apireport), path('html/examhistory//',views.examhistory), - + path('api/obscount',views.observepic), #path('api/rights/group/',views.rightsgroup), path('api/main',views.mainapi), diff --git a/safesite/views.py b/safesite/views.py index 5cbc6980..623f1da6 100644 --- a/safesite/views.py +++ b/safesite/views.py @@ -234,7 +234,8 @@ def troubleashtml(req): return render(req,'troubleashtml.html') def userhtml(req): return render(req,'userhtml.html') - +def bhrhtml(req): + return render(req,'behavior.html') def check_login(func): def warpper(request,*args,**kwargs): is_login = request.session.get('userid', None) @@ -2714,10 +2715,85 @@ def gchandle(req): url = exportdoc2('gc',data) return JsonResponse({"code":1,"downloadurl":url}) +def observepic(req): + userid = req.session['userid'] + companyid = getcompany(userid) + if req.GET.get('a')=='gclxt':#观察类型饼图 + year = int(req.GET.get('year')) + month = int(req.GET.get('month')) + first_day,first_day_of_next_month = gettime(datetime(year,month,1)) + if req.GET.get('part'): + partid = req.GET.get('part') + else: + partid = companyid + parts = Partment.objects.filter(Q(partid=partid) | Q(partlink__contains=',' + str(partid) + ',')) + a = Observe.objects.filter(lookpart__in=parts,deletemark=1,looktime__range=(first_day, first_day_of_next_month)) + value=[] + key=[] + for i in Dicclass.objects.filter(parentid__dicid=23): + x = i.dicname + y = Unsafes.objects.filter(observe__in=a,unsafedicclass=i).count() + key.append(x) + value.append({'value':y,'name':x}) + return JsonResponse({'code':1,'key':key,'value':value}) + elif req.GET.get('a')=='gclzx':#观察类型折线图 + year = int(req.GET.get('year')) + months = [1,2,3,4,5,6,7,8,9,10,11,12] + userfy=[]#人员反映 + userwz=[]#员工的位置 + grfh=[]#个人防护装备 + gjhsb=[]#工具和设备 + cxhbz=[]#程序和标准 + rtgcx=[]#人体工程学 + hjzj=[]#环境整洁 + for month in months: + first_day,first_day_of_next_month = gettime(datetime(year,month,1)) + if req.GET.get('part'): + partid = req.GET.get('part') + else: + partid = companyid + parts = Partment.objects.filter(Q(partid=partid) | Q(partlink__contains=',' + str(partid) + ',')) + a = Observe.objects.filter(lookpart__in=parts,deletemark=1,looktime__range=(first_day, first_day_of_next_month)) + for i in Dicclass.objects.filter(parentid__dicid=23): + if i.dicid==24: + userfy.append(Unsafes.objects.filter(observe__in=a,unsafedicclass=i).count()) + elif i.dicid==25: + userwz.append(Unsafes.objects.filter(observe__in=a,unsafedicclass=i).count()) + elif i.dicid==26: + grfh.append(Unsafes.objects.filter(observe__in=a,unsafedicclass=i).count()) + elif i.dicid==27: + gjhsb.append(Unsafes.objects.filter(observe__in=a,unsafedicclass=i).count()) + elif i.dicid==28: + cxhbz.append(Unsafes.objects.filter(observe__in=a,unsafedicclass=i).count()) + elif i.dicid==29: + rtgcx.append(Unsafes.objects.filter(observe__in=a,unsafedicclass=i).count()) + elif i.dicid==30: + hjzj.append(Unsafes.objects.filter(observe__in=a,unsafedicclass=i).count()) + - + return JsonResponse({'code':1,'months':months,'userfy':userfy,'userwz':userwz,'grfh':grfh,'gjhsb':gjhsb,'cxhbz':cxhbz,'rtgcx':rtgcx,'hjzj':hjzj,}) + elif req.GET.get('a')=='gclxbg': + userid = req.session['userid'] + companyid = getcompany(userid) + a = Observe.objects.filter(usecomp=Partment.objects.get(partid=companyid),deletemark=1) + + if req.GET.get('qssj'):#开始时间 + a = a.filter(looktime__gte=req.GET.get('qssj')) + if req.GET.get('jssj'):#结束时间 + a = a.filter(looktime__lte=req.GET.get('jssj')) + if req.GET.get('fxbm'): + gcbm = req.GET.get('fxbm') + parts = Partment.objects.filter(partlink__contains=',' + gcbm + ',')|Partment.objects.filter(partid=gcbm) + a = a.filter(lookpart__in=parts) + + total = a.count() + objs = a.values('looker__userid','looker__name','lookpart__partname').annotate(number = Count('looker')).order_by('-number') + return HttpResponse(transjson(total,objs),content_type="application/json") + + + def dicchandle(req): a = req.GET.get('a') if a == 'tree': diff --git a/static/safesite/easyui/themes/icons/behv.png b/static/safesite/easyui/themes/icons/behv.png new file mode 100644 index 0000000000000000000000000000000000000000..8ce205131966ff32cc66a1dbe1dffc9f88b01ba7 GIT binary patch literal 1066 zcmV+_1l9YAP)q*e8g6f_P34e1dpR5a$G8P7u68nJmI= zB)>O{!5gpzsPd|%7A;v4diI;q3R>!}Usb<;RTC;coz<_uacK1cJ^-UjL|xg+%u^7i z0FB8CM_&Ewr;10aI<7I#}uR?W9yIswqCc<>Cw!+HJod`8pRwmpRaI;&p>2x}iU zhWQGN%h19Ibxg0xoyy@q1wS9usMaE;0T=@!JdcgeV6Bh6`d^o2AaVh;gWh`r#A`74 zPbQpQH{8)SZ{+>n(&-c9j6koV{TTZ81m)g0_bTGhy*~K^N-4N;={)p*PtR0 z^)KqbwSJxDgaV-0zTEw;egdbyJsCbE?0U~0J6%mu#f!i>vOq%U*}SpXH>*Pd=-fGH zAbJPzm1nyL4>c}^ttE-KEzt+Iaj1c`181a&$^5&wrv z44nJ+MAd%L(+PSKUX`LeuA~9*RoKA5V)xr zJZ~%xcbB_IqI$xkg}pc^YeJo%m$D}j*a|>&VmD}hkrphuUo;jMPnJzlxECp~IYM)v zs2Kq5yWUhfSXm14bRrfnDc|I&nnttYwvy14(kxLsfisJAK6e&z<+qQtGZ;u>W#$8`>iUPTZRU?#-2TSsSi)L(|iE3st1xP&8vOqd{?8K!IfBw zqfnY5+_dJ{f5s<&XEMmEkSc2%o#2~!0SCDn`=Jo0V#P!5bp7BO8&!#4Nx#HEUH z`KBE>pH({Zno(>_CfldkDM*l432zyYO*+%w%bx#yAW2Dh(LiDlFCNJ-3yEJp*7LZ8 zr3K5NliTd_hSH>`Gr|+!{(4?D&&4IG-YD75%5>3Kt|Or~hQy~;qY;ng@3el1=LGJ@ zvV9N4mWzoc(NIbkUBT#*i7(B8M8+_z@Z19WkjqItFUVvKD?E}R)U2p%B(`78g60WG zE-4$yEl&yGfH9ogw?i}BMIcH6n1)0#IjqH(Q|js~m}mru