diff --git a/safesite/daoru.py b/safesite/daoru.py index 8af79c88..f8c8f0ab 100644 --- a/safesite/daoru.py +++ b/safesite/daoru.py @@ -9,6 +9,7 @@ from django.conf import settings import qrcode import os from django.contrib.auth.hashers import make_password +from django.db.models import Q def makeqr(data): upload_folder = 'media/qr_equipment' @@ -165,13 +166,48 @@ def drquestions(companyid,path,userid): def drequipments(companyid,path): wb = load_workbook(path) sheet = wb.worksheets[0] + # 验证文件内容 + if sheet['a3'].value != '区域': + return {'code':0,'msg':'区域列错误!'} + if sheet['b3'].value != '设备类别': + return {'code':0,'msg':'设备类别列错误!'} + if sheet['c3'].value != '编号': + return {'code':0,'msg':'编号列错误!'} + if sheet['d3'].value != '设备名称': + return {'code':0,'msg':'设备名称列错误!'} + if sheet['e3'].value != '规格型号': + return {'code':0,'msg':'规格型号列错误!'} + if sheet['f3'].value != '生产厂家': + return {'code':0,'msg':'生产厂家列错误!'} + if sheet['g3'].value != '出厂编号': + return {'code':0,'msg':'出厂编号列错误!'} + if sheet['h3'].value != '出厂日期': + return {'code':0,'msg':'出厂日期列错误!'} + if sheet['i3'].value != '投用日期': + return {'code':0,'msg':'投用日期列错误!'} + if sheet['j3'].value != '安装位置': + return {'code':0,'msg':'安装位置列错误!'} + if sheet['k3'].value != '主要技术参数': + return {'code':0,'msg':'主要技术参数列错误!'} + if sheet['l3'].value != '是否特种设备': + return {'code':0,'msg':'是否特种设备列错误!'} + if sheet['m3'].value != '是否主设备': + return {'code':0,'msg':'是否主设备列错误!'} + if sheet['n3'].value != '责任部门': + return {'code':0,'msg':'责任部门列错误!'} + if sheet['o3'].value != '责任人': + return {'code':0,'msg':'责任人列错误!'} + catedict = {} + for i in Dickey.objects.filter(Q(dicparent__dicid=47),Q(usecomps__contains=','+str(companyid)+',')|Q(usecomps__contains=',1,')).exclude(usecomps__contains=','+str(companyid)+','): + catedict[i.dicname] = i.dicid + if '其他设备类' not in catedict: + catedict['其它设备类'] = 361 numdict = {} numsdict = {} nums = Equipment.objects.filter(usecomp__partid=companyid) for i in nums: numdict[i.num]=i i=4 - catedict = {'锅炉':352,'塔类':353,'反应器类':354,'储罐及容器类':355,'冷换设备类':356,'通用机械类':357,'动力类':358,'化工机械类':359,'起重运输类':360,'其他设备类':361,'其它设备类':361} while sheet['c'+str(i)].value!=None: area = sheet['a'+str(i)].value cate = sheet['b'+str(i)].value @@ -256,7 +292,10 @@ def drequipments(companyid,path): else: numsdict[num]=name i = i+1 - return numsdict + if numsdict: + return {'code':1,'msg':'全部导入成功!'} + else: + return {'code':2,'msg':'部分未导入成功!','info':numsdict} @@ -268,6 +307,13 @@ def drequipments(companyid,path): def drusers(companyid,path): wb = load_workbook(path) sheet = wb.worksheets[0] + # 验证文件内容 + if sheet['b3'].value != '姓名': + return {'code':0,'msg':'姓名列错误!'} + if sheet['c3'].value != '账户(手机号)': + return {'code':0,'msg':'账户列错误!'} + if sheet['d3'].value != '部门': + return {'code':0,'msg':'部门列错误!'} partdict = {} # groupdict = {} userdict = {} @@ -322,7 +368,10 @@ def drusers(companyid,path): else: userdict[username]=i i = i + 1 - return userdict + if userdict: + return {'code':2,'msg':'导入部分成功!','info':userdict} + else: + return {'code':1,'msg':'导入全部成功!'} def drrisks(companyid,path): wb = load_workbook(path) diff --git a/safesite/templates/abdrill.html b/safesite/templates/abdrill.html index ede12494..3b5de8ac 100644 --- a/safesite/templates/abdrill.html +++ b/safesite/templates/abdrill.html @@ -90,7 +90,7 @@ required=true>
- +
+ data-options="label:'最早参加',currentText:'今天',closeText:'关闭',showSeconds: false,required:true" />
+ data-options="label:'考试开启',currentText:'今天',closeText:'关闭',showSeconds: false,required:true" />
- +