yinghuan
This commit is contained in:
parent
1d31462c8d
commit
4562b7a3d7
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,175 @@
|
||||||
|
{% extends "./base.html" %}
|
||||||
|
|
||||||
|
{% block title %}隐患统计{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{% load static %}
|
||||||
|
<div class="callout callout-warning">
|
||||||
|
<h3>行为统计</h3>
|
||||||
|
</div>
|
||||||
|
<div style="height:600px;width:100%;background-color:aquamarine">
|
||||||
|
<div style="width:100%;height:100px;">
|
||||||
|
<select id="YearNum" style="margin-left:5px;height:30px;width:70px;font-size:large"> </select> <span style="font-size:large">年</span>
|
||||||
|
|
||||||
|
<select id="banqType" style="height:30px;width:70px;font-size:large">
|
||||||
|
<option value="1">1</option>
|
||||||
|
<option value="2">2</option>
|
||||||
|
<option value="3">3</option>
|
||||||
|
<option value="4">4</option>
|
||||||
|
<option value="5">5</option>
|
||||||
|
<option value="6">6</option>
|
||||||
|
<option value="7">7</option>
|
||||||
|
<option value="8">8</option>
|
||||||
|
<option value="9">9</option>
|
||||||
|
<option value="10">10</option>
|
||||||
|
<option value="11">11</option>
|
||||||
|
<option value="12">12</option>
|
||||||
|
</select>
|
||||||
|
<span style="font-size:large">月</span>
|
||||||
|
|
||||||
|
<button class="btn btn-info" onclick="funTypeChange()"> 查询</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="troubchart" style="width:60%;height:400px;margin:auto"></div>
|
||||||
|
</div>
|
||||||
|
<!-- jQuery 3 -->
|
||||||
|
<script src="{% static 'groups/bower_components/jquery/dist/jquery.min.js' %}"></script>
|
||||||
|
<!-- Bootstrap 3.3.7 -->
|
||||||
|
<script src="{% static 'groups/bower_components/bootstrap/dist/js/bootstrap.min.js' %}"></script>
|
||||||
|
<!-- iCheck -->
|
||||||
|
<script src="{% static 'groups/plugins/iCheck/icheck.min.js' %}"></script>
|
||||||
|
<script src="{% static 'groups/bower_components/echarts.min.js' %}"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
//隐患数量趋势图
|
||||||
|
|
||||||
|
|
||||||
|
$(function () {
|
||||||
|
|
||||||
|
var currentYear = new Date().getFullYear();
|
||||||
|
var select = document.getElementById("YearNum");
|
||||||
|
for (var i = 0; i <= 3; i++) {
|
||||||
|
var theOption = document.createElement("option");
|
||||||
|
theOption.innerHTML = currentYear - i;
|
||||||
|
theOption.value = currentYear - i;
|
||||||
|
select.appendChild(theOption);
|
||||||
|
}
|
||||||
|
var date = new Date();
|
||||||
|
var year = date.getFullYear();
|
||||||
|
var month = date.getMonth() + 1;
|
||||||
|
$("#YearNum").val(year);
|
||||||
|
$("#banqType").val(month);
|
||||||
|
gczxt()
|
||||||
|
|
||||||
|
});
|
||||||
|
function funTypeChange() {
|
||||||
|
gczxt()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function gczxt() {//行为观察折线图
|
||||||
|
var y = $("#YearNum").val();
|
||||||
|
var m = $("#banqType").val();
|
||||||
|
//行为观察折线图
|
||||||
|
$.ajax({
|
||||||
|
type: "get",
|
||||||
|
async: true, //异步请求(同步请求将会锁住浏览器,用户其他操作必须等待请求完成才可以执行)
|
||||||
|
url: "/groups/api/observeChart?code=tbpic&year=" + y + "&month=" + m, //请求发送
|
||||||
|
dataType: "json", //返回数据形式为json
|
||||||
|
success: function (data) {
|
||||||
|
//请求成功时执行该函数内容,data即为服务器返回的json对象
|
||||||
|
console.log(data);
|
||||||
|
var gcChart2 = echarts.init(document.getElementById("troubchart"));
|
||||||
|
var companyName = [];
|
||||||
|
if (data.list != null) {
|
||||||
|
$.each(data.list, function (i, item) {
|
||||||
|
|
||||||
|
companyName.push(item.usecomp__partname);
|
||||||
|
|
||||||
|
})
|
||||||
|
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: companyName
|
||||||
|
},
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
|
@ -0,0 +1,138 @@
|
||||||
|
{% extends "./base.html" %}
|
||||||
|
|
||||||
|
{% block title %}隐患统计{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{% load static %}
|
||||||
|
<div class="callout callout-warning">
|
||||||
|
<h3>隐患统计</h3>
|
||||||
|
</div>
|
||||||
|
<div style="height:600px;width:100%;background-color:aquamarine">
|
||||||
|
<div style="width:100%;height:100px;">
|
||||||
|
<select id="YearNum" style="margin-left:5px;height:30px;width:70px;font-size:large"> </select> <span style="font-size:large">年</span>
|
||||||
|
|
||||||
|
<select id="banqType" style="height:30px;width:70px;font-size:large">
|
||||||
|
<option value="1">1</option>
|
||||||
|
<option value="2">2</option>
|
||||||
|
<option value="3">3</option>
|
||||||
|
<option value="4">4</option>
|
||||||
|
<option value="5">5</option>
|
||||||
|
<option value="6">6</option>
|
||||||
|
<option value="7">7</option>
|
||||||
|
<option value="8">8</option>
|
||||||
|
<option value="9">9</option>
|
||||||
|
<option value="10">10</option>
|
||||||
|
<option value="11">11</option>
|
||||||
|
<option value="12">12</option>
|
||||||
|
</select>
|
||||||
|
<span style="font-size:large">月</span>
|
||||||
|
|
||||||
|
<button class="btn btn-info" onclick="funTypeChange()"> 查询</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="troubchart" style="width:60%;height:400px;margin:auto"></div>
|
||||||
|
</div>
|
||||||
|
<!-- jQuery 3 -->
|
||||||
|
<script src="{% static 'groups/bower_components/jquery/dist/jquery.min.js' %}"></script>
|
||||||
|
<!-- Bootstrap 3.3.7 -->
|
||||||
|
<script src="{% static 'groups/bower_components/bootstrap/dist/js/bootstrap.min.js' %}"></script>
|
||||||
|
<!-- iCheck -->
|
||||||
|
<script src="{% static 'groups/plugins/iCheck/icheck.min.js' %}"></script>
|
||||||
|
<script src="{% static 'groups/bower_components/echarts.min.js' %}"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
//隐患数量趋势图
|
||||||
|
|
||||||
|
|
||||||
|
$(function () {
|
||||||
|
|
||||||
|
var currentYear = new Date().getFullYear();
|
||||||
|
var select = document.getElementById("YearNum");
|
||||||
|
for (var i = 0; i <= 3; i++) {
|
||||||
|
var theOption = document.createElement("option");
|
||||||
|
theOption.innerHTML = currentYear - i;
|
||||||
|
theOption.value = currentYear - i;
|
||||||
|
select.appendChild(theOption);
|
||||||
|
}
|
||||||
|
var date = new Date();
|
||||||
|
var year = date.getFullYear();
|
||||||
|
var month = date.getMonth() + 1;
|
||||||
|
$("#YearNum").val(year);
|
||||||
|
$("#banqType").val(month);
|
||||||
|
troub();
|
||||||
|
|
||||||
|
});
|
||||||
|
function funTypeChange() {
|
||||||
|
troub();
|
||||||
|
}
|
||||||
|
function troub() {
|
||||||
|
|
||||||
|
var y = $("#YearNum").val();
|
||||||
|
var m = $("#banqType").val();
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: "get",
|
||||||
|
async: true, //异步请求(同步请求将会锁住浏览器,用户其他操作必须等待请求完成才可以执行)
|
||||||
|
url: "/groups/api/troubleChart?code=tbpic&year=" + y + "&month=" + m, //请求发送
|
||||||
|
dataType: "json", //返回数据形式为json
|
||||||
|
success: function (data) {
|
||||||
|
console.log(data.data.troublelist);
|
||||||
|
console.log(data.num);
|
||||||
|
//请求成功时执行该函数内容,data即为服务器返回的json对象
|
||||||
|
var yhChart = echarts.init(document.getElementById("troubchart"));
|
||||||
|
var yhnum = [];
|
||||||
|
var companyName = [];
|
||||||
|
if (data.data.troublelist != null) {
|
||||||
|
$.each(data.data.troublelist, function (i, item) {
|
||||||
|
|
||||||
|
|
||||||
|
yhnum.push(item.number);
|
||||||
|
|
||||||
|
companyName.push(item.usecomp__partname);
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
yhChart.setOption(
|
||||||
|
|
||||||
|
option = {
|
||||||
|
color: ['#3398DB'],
|
||||||
|
tooltip: {
|
||||||
|
trigger: 'axis',
|
||||||
|
axisPointer: { // 坐标轴指示器,坐标轴触发有效
|
||||||
|
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
title: {
|
||||||
|
text: '本集团'+y+'年'+m+'月各公司隐患统计图'
|
||||||
|
},
|
||||||
|
tooltip: {},
|
||||||
|
legend: {
|
||||||
|
data: ['公司隐患总数']
|
||||||
|
},
|
||||||
|
xAxis: {
|
||||||
|
type: 'category',
|
||||||
|
data: companyName
|
||||||
|
},
|
||||||
|
yAxis: {},
|
||||||
|
series: [{
|
||||||
|
name: '公司隐患总数',
|
||||||
|
data: yhnum,
|
||||||
|
type: 'bar'
|
||||||
|
}]
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (errorMsg) {
|
||||||
|
yhChart.hideLoading();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
|
@ -9,11 +9,13 @@ urlpatterns = [
|
||||||
path('logout/', views.logout, name='groups_logout'),
|
path('logout/', views.logout, name='groups_logout'),
|
||||||
path('captcha/', include('captcha.urls')),
|
path('captcha/', include('captcha.urls')),
|
||||||
path('company/', views.company, name='groups_company'),
|
path('company/', views.company, name='groups_company'),
|
||||||
path('trouble/', views.job, name='groups_trouble'),
|
path('trouble/', views.trouble, name='groups_trouble'),#隐患排查统计图
|
||||||
path('observe/', views.job, name='groups_observe'),
|
path('observe/', views.observe, name='groups_observe'),#行为观察统计图
|
||||||
path('miss/', views.job, name='groups_miss'),
|
path('miss/', views.job, name='groups_miss'),#未遂事件统计图
|
||||||
path('risk/', views.job, name='groups_risk'),
|
path('risk/', views.job, name='groups_risk'),#风险管控统计图
|
||||||
path('tain/', views.job, name='groups_train'),
|
path('tain/', views.job, name='groups_train'),#教育培训统计图
|
||||||
path('test/', views.job, name='groups_test'),
|
path('test/', views.job, name='groups_test'),#在线考试统计图
|
||||||
path('refresh_captcha/', views.refresh_captcha),
|
path('refresh_captcha/', views.refresh_captcha),
|
||||||
]
|
path('api/troubleChart',views.troubleChart),
|
||||||
|
path('api/observeChart',views.observeChart)
|
||||||
|
]
|
|
@ -4,9 +4,12 @@ from django.shortcuts import redirect
|
||||||
from .models import Group,GroupUser
|
from .models import Group,GroupUser
|
||||||
from .forms import GroupUserForm
|
from .forms import GroupUserForm
|
||||||
from safesite import models as s_models
|
from safesite import models as s_models
|
||||||
|
import time
|
||||||
|
from datetime import datetime,date,timedelta
|
||||||
|
from safesite.tasks import send_wechatmsgs,send_wechatmsg,yjjs,gettime,yjjs_px,yjjs_yl,updateTzzs,updateAqzs,yjjs_gc,yjjs_ws
|
||||||
|
from django.db.models import Q
|
||||||
|
from django.core.serializers.json import DjangoJSONEncoder
|
||||||
|
from django.db.models import F,Count,Sum
|
||||||
def index(request):
|
def index(request):
|
||||||
if not request.session.get('is_login', None):
|
if not request.session.get('is_login', None):
|
||||||
return redirect('/groups/login/')
|
return redirect('/groups/login/')
|
||||||
|
@ -63,3 +66,52 @@ def company(request):
|
||||||
|
|
||||||
def job(request):
|
def job(request):
|
||||||
return render(request, 'groups/job.html', locals())
|
return render(request, 'groups/job.html', locals())
|
||||||
|
def trouble(request):#隐患排查
|
||||||
|
return render(request, 'groups/troublepic.html', locals())
|
||||||
|
def observe(request):#行为观察
|
||||||
|
return render(request, 'groups/observe.html', locals())
|
||||||
|
def troubleChart(request):#隐患统计图
|
||||||
|
code = request.GET.get('code')
|
||||||
|
year = int(request.GET.get('year'))
|
||||||
|
month =int( request.GET.get('month'))
|
||||||
|
if code=='tbpic':
|
||||||
|
yhcompanys=[]
|
||||||
|
yhcompanyscount=[]
|
||||||
|
first_day,first_day_of_next_month = gettime(datetime(year,month,1))
|
||||||
|
companys = GroupUser.objects.get(id = request.session['user_id']).group.members.all()
|
||||||
|
troublelist = s_models.Trouble.objects.filter(deletemark=1,usecomp__in=companys,fxsj__range=(first_day, first_day_of_next_month)).values('usecomp__partid','usecomp__partname').annotate(number = Count('troubleid'))
|
||||||
|
return HttpResponse(json.dumps({'code':1,'data':{'troublelist':list(troublelist)}}), content_type='application/json')
|
||||||
|
def observeChart(request):#行为观察
|
||||||
|
code = request.GET.get('code')
|
||||||
|
year = int(request.GET.get('year'))
|
||||||
|
month =int( request.GET.get('month'))
|
||||||
|
if code=='tbpic':
|
||||||
|
userfy=[]#人员反映
|
||||||
|
userwz=[]#员工的位置
|
||||||
|
grfh=[]#个人防护装备
|
||||||
|
gjhsb=[]#工具和设备
|
||||||
|
cxhbz=[]#程序和标准
|
||||||
|
rtgcx=[]#人体工程学
|
||||||
|
hjzj=[]#环境整洁
|
||||||
|
first_day,first_day_of_next_month = gettime(datetime(year,month,1))
|
||||||
|
companys = GroupUser.objects.get(id = request.session['user_id']).group.members.all()
|
||||||
|
Observe = s_models.Observe.objects.filter(deletemark=1,usecomp__in=companys,looktime__range=(first_day, first_day_of_next_month)).values('usecomp__partid','usecomp__partname').annotate(number = Count('lookid'))
|
||||||
|
for j in Observe:
|
||||||
|
|
||||||
|
for i in s_models.Dicclass.objects.filter(parentid__dicid=23):
|
||||||
|
if i.dicid==24:
|
||||||
|
userfy.append(s_models.Unsafes.objects.filter(observe__in=j,unsafedicclass=i).count())
|
||||||
|
elif i.dicid==25:
|
||||||
|
userwz.append(s_models.Unsafes.objects.filter(observe__in=j,unsafedicclass=i).count())
|
||||||
|
elif i.dicid==26:
|
||||||
|
grfh.append(s_models.Unsafes.objects.filter(observe__in=j,unsafedicclass=i).count())
|
||||||
|
elif i.dicid==27:
|
||||||
|
gjhsb.append(s_models.Unsafes.objects.filter(observe__in=j,unsafedicclass=i).count())
|
||||||
|
elif i.dicid==28:
|
||||||
|
cxhbz.append(s_models.Unsafes.objects.filter(observe__in=j,unsafedicclass=i).count())
|
||||||
|
elif i.dicid==29:
|
||||||
|
rtgcx.append(s_models.Unsafes.objects.filter(observe__in=j,unsafedicclass=i).count())
|
||||||
|
elif i.dicid==30:
|
||||||
|
hjzj.append(s_models.Unsafes.objects.filter(observe__in=j,unsafedicclass=i).count())
|
||||||
|
|
||||||
|
return HttpResponse(json.dumps({'code':1,'data':{'list':list(Observe)},'userfy':userfy,'userwz':userwz,'grfh':grfh,'gjhsb':gjhsb,'cxhbz':cxhbz,'rtgcx':rtgcx,'hjzj':hjzj,}), content_type='application/json')
|
Loading…
Reference in New Issue