题目导入

This commit is contained in:
caoqianming 2019-10-12 09:34:13 +08:00
parent 023709fd9b
commit 26c4d25cbc
13 changed files with 124 additions and 33 deletions

View File

@ -0,0 +1,15 @@
# Generated by Django 2.1.5 on 2019-10-11 14:15
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('safesite', '0272_auto_20190923_1026'),
('safesite', '0266_auto_20190917_2314'),
('safesite', '0273_auto_20191008_1604'),
]
operations = [
]

View File

@ -0,0 +1,33 @@
# Generated by Django 2.1.5 on 2019-10-11 14:15
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('safesite', '0274_merge_20191011_1415'),
]
operations = [
migrations.AlterField(
model_name='user',
name='headimgurl',
field=models.CharField(blank=True, max_length=200, null=True),
),
migrations.AlterField(
model_name='user',
name='mpopenid',
field=models.CharField(blank=True, max_length=200, null=True),
),
migrations.AlterField(
model_name='user',
name='nickname',
field=models.CharField(blank=True, max_length=200, null=True),
),
migrations.AlterField(
model_name='user',
name='openid',
field=models.CharField(blank=True, max_length=200, null=True),
),
]

View File

@ -51,12 +51,12 @@ class User(models.Model):
name = models.CharField(max_length=20)
password = models.CharField(max_length=30)
ubelongpart = models.ForeignKey(Partment,related_name='upart', on_delete=models.CASCADE)
openid=models.CharField(max_length=200,default='0')#公众号openid
nickname=models.CharField(max_length=200,default='wechartname')#昵称
headimgurl=models.CharField(max_length=200,default='0')#头像
openid=models.CharField(max_length=200,null=True,blank=True)#公众号openid
nickname=models.CharField(max_length=200,null=True,blank=True)#昵称
headimgurl=models.CharField(max_length=200,null=True,blank=True)#头像
issuper=models.IntegerField(default='0')#超管
deletemark=models.IntegerField(default='1')
mpopenid=models.CharField(max_length=200,default='0') #小程序openid
mpopenid=models.CharField(max_length=200,null=True,blank=True) #小程序openid
usecomp = models.ForeignKey(Partment,on_delete=models.CASCADE,null=True,blank=True)#所属公司
def __str__(self):
return self.username
@ -577,8 +577,8 @@ class ExamTest(models.Model):#考试表
state = models.IntegerField(default=1) #1进行中
exampaper = models.ForeignKey(ExamPaper,on_delete=models.CASCADE)
user = models.ManyToManyField(User,through='ExamTestDetail') #考试人员
starttime = models.DateTimeField(null=True,blank=True)
endtime = models.DateTimeField(null=True,blank=True)
starttime = models.DateTimeField(null=True,blank=True)#最早参加
endtime = models.DateTimeField(null=True,blank=True)#最迟参加
createtime = models.DateTimeField(default = timezone.now)
modifytime = models.DateTimeField(auto_now = True)
totalscore=models.IntegerField(default=100)

Binary file not shown.

View File

@ -15,6 +15,7 @@ from .safespider import getTzzs
dirname = settings.BASE_DIR +'/safesite/'
def getcs(companyid):#获取公司相关参数设置
print(companyid)
return Yjsetup.objects.filter(usecomp__partid=companyid).values()[0]
def gettime(x=datetime.datetime.now()):
@ -55,7 +56,10 @@ def yjjs(companyid):
else:
sbjs = 0
#隐患整改率
zgjs = a.filter(yhzt__in=[4,5,6]).count()/a.count()
if a.count() != 0:
zgjs = a.filter(yhzt__in=[4,5,6]).count()/a.count()
else:
zgjs = 4
if zgjs == 1:
zgjs = 0
elif zgjs>=0.8 and zgjs <1:
@ -92,7 +96,10 @@ def yjjs_px(companyid):
#计算培训效果
participantnum = Trainuser.objects.filter(train__in=a).count()
knownum = a.aggregate(knownum = Sum('knownum'))['knownum']
x = knownum/participantnum
if participantnum != 0:
x = knownum/participantnum
else:
x = 0
if x == 1:
pxxg = 1
elif 1>x>= 0.9:
@ -149,7 +156,10 @@ def yjjs_yl(companyid):
#计算演练效果
participantnum = Drill.objects.filter(drillid__in=a).count()
knownum = a.aggregate(knownum = Sum('knownum'))['knownum']
x = knownum/participantnum
if participantnum != 0:
x = knownum/participantnum
else:
x = 0
if x == 1:
ylxg = 1
elif 1>x>= 0.9:

View File

@ -69,7 +69,7 @@
<div id="examtestdiv" style="margin-bottom:5px;display:none">
<input id="examtest" name="examtest" class="easyui-combobox" style="width:480px;" editable=false data-options="label:'关联考试',url:'api/examtest?a=listtrain'">
</div>
<div id='filediv' style="margin-bottom:5px;display:none">
<div id='filediv' style="margin-bottom:5px;">
<label>相关资料 </label><input type="file" id="file" name="" accept="*" style="margin-left: 20px" />
<span id='ps' style="display:none">
<input type="button" onclick="cancleUploadFile()" value="取消" />
@ -99,7 +99,7 @@
var data = JSON.parse(evt.target.responseText);
if (data.code = 1) {
$('#ps').css('display', 'none');
$("#fileol").append('<li><button onclick="removep(this)" >删除</button><a class = "filea" target="_blank" filepath="' + data.filepath + '" href="http://' + window.location.host + '/' + data.filepath + '" >' + data.filename + '</a></li>');
$("#fileol").append('<li><button onclick="removep(this)" >删除</button><a class = "filea" target="_blank" filepath="' + data.filepath + '" href="' + data.filepath + '" >' + data.filename + '</a></li>');
} else { alert("上传失败!"); } document.getElementById('file').value = '';
}; //请求完成
xhr.onerror = function (evt) { alert("上传失败!"); $('#ps').css('display', 'none'); }; //请求失败
@ -182,6 +182,11 @@
if (a == 'addtrain') {
$.messager.confirm('提示', '请仔细核对信息,确定后将向用户发送微信通知!', function (r) {
var filearray = new Array();
$(".filea").each(function () {
filearray.push($(this).attr("filepath"));
});
fd.append("upfile", filearray.join('?'));
if (r) {
$.ajax({
type: "POST",
@ -268,6 +273,10 @@
$("#participantname").textbox('setValue', data.participantname).textbox('disable');
$("#trainid").attr('value', data.trainid);
$("#knownumdiv,#filediv,#pxxgdiv,#examtestdiv").show();
for(var i=0;i<data.material.length;i++){
let x = data.material[i]
$("#fileol").append('<li><button onclick="removep(this)" >删除</button><a class = "filea" target="_blank" filepath="' + x + '" href="/' + x + '" >' + x.split('_').pop() + '</a></li>');
}
},

View File

@ -168,7 +168,7 @@
var issuper = {{ issuper }};
if (issuper == 1) { $('#setupb').show() }
if (openid == 0 && issuper != 1) { $('#wxdg').dialog(); } else { $('#bindwx').text('解绑微信'); };
if (headimgurl != 0) { $('#headimg').attr('src', headimgurl); }
if (headimgurl != 0 && headimgurl != 'None') { $('#headimg').attr('src', headimgurl); }
function logout() {
$.messager.confirm('系统提示', '您确定要退出本次登录吗?', function (r) {
if (r) {

View File

@ -326,11 +326,11 @@ float: left;">
</div>
<div style="width:100%;height:800px">
<div id="panelx" class="easyui-panel" data-options="iconCls:'fa-bar-chart'" >
<div id="panelx" class="easyui-panel" data-options="iconCls:'fa-bar-chart'" style="width:100%;height:800px">
</div>
</div>
<script type="text/javascript">
//首页总数统计

View File

@ -23,8 +23,8 @@
data-options="iconCls:'fa-pencil',plain:true">编辑</a>
<a id="deltm" onclick="deltm()" class="easyui-linkbutton"
data-options="iconCls:'fa-trash',plain:true">删除</a>
<!-- <a id="drtms" onclick="javascript:$('#drtmdg').dialog('open').window('center');" class="easyui-linkbutton"
data-options="iconCls:'fa-upload',plain:true">导入试题</a> -->
<a id="drtms" onclick="javascript:$('#drtmdg').dialog('open').window('center');" class="easyui-linkbutton"
data-options="iconCls:'fa-upload',plain:true">导入试题</a>
</div>
<table id="tmtable" style="height:100%;"></table>

View File

@ -58,7 +58,7 @@
if(value==1){
return '正常';
}else{
return value;
return '异常';
}
}, styler: function (value, row, index) {
if(value==1){

View File

@ -29,7 +29,7 @@
<th data-options="field:'username',align:'right'" width="20%">账户</th>
<th data-options="field:'ubelongpart__partname',align:'right'" width="30%">所属部门</th>
<th data-options="field:'openid',align:'center',formatter: function (value, row, index) {
if(value!=0){return '<img src='+'/static/safesite/easyui/themes/icons/ok.png'+'/>';}
if(value!=0 && value != null){return '<img src='+'/static/safesite/easyui/themes/icons/ok.png'+'/>';}
}"
width="15%">是否可接受通知</th>

View File

@ -82,7 +82,7 @@ urlpatterns = [
path('html/risk/add/<int:id>/',views.riskadd),
path('html/task',views.task),
path('html/taskdo',views.taskdo),
path('html/riskcheck',views.riskcheck),
path('html/riskcheck',views.riskcheck),#风险点排查记录
path('html/risk/edit/<int:id>/',views.riskedit),
path('html/report/edit',views.reportedit),
#html页面

View File

@ -1266,6 +1266,7 @@ def addtrain(req):
a.submituser=User.objects.get(userid=userid)
a.duration=req.POST.get('duration')
a.trainnum='PX'+time.strftime('%Y%m%d%H%M%S')
a.material= req.POST.get('upfile')
a.save()
a.checkqr = makeqr_train('https://safeyun.ctcshe.com/miniprogram/checktrain?trainid='+str(a.trainid))
a.save()
@ -2788,18 +2789,21 @@ def bwlogin(req):
headimgurl = req.POST.get('headimgurl')
user = User.objects.filter(username__exact = username, password__exact = password)
if user:
mpuser = User.objects.filter(openid=openid).exclude(username = username)
if mpuser.exists():
return render(req,'bindwechat.html',{'msg':'您的微信已绑定平台下'+mpuser[0].username+'账号,不可重复绑定请先至pc端解绑','code':0}) #已绑定其他账号
else:
if user[0].openid == '0' or user[0].openid == None or user[0].openid == '':
user.update(openid=openid,headimgurl=headimgurl,nickname=nickname)
return render(req,'bindwechat.html',{'msg':'绑定成功,请刷新电脑端浏览器!','code':1})
else:
if user[0].openid == openid:
return render(req,'bindwechat.html',{'msg':'绑定成功,请刷新电脑端浏览器!','code':1})
else:
return render(req,'bindwechat.html',{'msg':'该平台账号已绑定昵称为'+user[0].nickname+'的微信,不可重复绑定请先至pc端解绑','code':0}) #已绑定其他账号
# mpuser = User.objects.filter(openid=openid).exclude(username = username)
# if mpuser.exists():
# return render(req,'bindwechat.html',{'msg':'您的微信已绑定平台下'+mpuser[0].username+'账号,不可重复绑定请先至pc端解绑','code':0}) #已绑定其他账号
# else:
# if user[0].openid == '0' or user[0].openid == None or user[0].openid == '':
# user.update(openid=openid,headimgurl=headimgurl,nickname=nickname)
# return render(req,'bindwechat.html',{'msg':'绑定成功,请刷新电脑端浏览器!','code':1})
# else:
User.objects.filter(openid=openid).update(openid=None,headimgurl=None,nickname=None)
user.update(openid=openid,headimgurl=headimgurl,nickname=nickname)
return render(req,'bindwechat.html',{'msg':'绑定成功,请刷新电脑端浏览器!','code':1})
# if user[0].openid == openid:
# return render(req,'bindwechat.html',{'msg':'绑定成功,请刷新电脑端浏览器!','code':1})
# else:
# return render(req,'bindwechat.html',{'msg':'该平台账号已绑定昵称为'+user[0].nickname+'的微信,不可重复绑定请先至pc端解绑','code':0}) #已绑定其他账号
else:
return render(req,'bwlogin.html',{'msg':'用户名或密码错误!'})
@ -3802,6 +3806,26 @@ def apitool(req):
i.zghtp = i.zghtp.replace('#','')
i.save()
return JsonResponse({"code":1})
elif a == 'correct_yjyc':
for i in Partment.objects.filter(iscompany=1,deletemark=1):
yjjs(i.partid)
yjjs_gc(i.partid)
yjjs_px(i.partid)
yjjs_ws(i.partid)
yjjs_yl(i.partid)
return JsonResponse({"code":1})
elif a == 'correct_company':
m = []
for i in Partment.objects.filter(iscompany=1,deletemark=1):
if User.objects.filter(usecomp=i).exists() :
pass
else:
x = {}
x['name']=i.partname
x['id']=i.partid
m.append(x)
return JsonResponse({'wxgs':m})
def apinotice(req):
@ -4821,7 +4845,7 @@ def apiexamtestdetail(req):
companyid = getcompany(userid)
if a=='dknum':
a = ExamTestDetail.objects
a = a.filter(user__userid=userid,examtest__state=1,ison=0)
a = a.filter(user__userid=userid,examtest__state=1,ison=0,examtest__endtime__gte=datetime.now())
dknum = a.count()
return JsonResponse({"code":1,"dknum":dknum})
elif a=='listdk':