equipment import;observe noread;correct bmzg
This commit is contained in:
parent
18190d1100
commit
103b0ae82b
|
|
@ -9,6 +9,7 @@ from django.conf import settings
|
||||||
import qrcode
|
import qrcode
|
||||||
import os
|
import os
|
||||||
from django.contrib.auth.hashers import make_password
|
from django.contrib.auth.hashers import make_password
|
||||||
|
from django.db.models import Q
|
||||||
|
|
||||||
def makeqr(data):
|
def makeqr(data):
|
||||||
upload_folder = 'media/qr_equipment'
|
upload_folder = 'media/qr_equipment'
|
||||||
|
|
@ -165,13 +166,48 @@ def drquestions(companyid,path,userid):
|
||||||
def drequipments(companyid,path):
|
def drequipments(companyid,path):
|
||||||
wb = load_workbook(path)
|
wb = load_workbook(path)
|
||||||
sheet = wb.worksheets[0]
|
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 = {}
|
numdict = {}
|
||||||
numsdict = {}
|
numsdict = {}
|
||||||
nums = Equipment.objects.filter(usecomp__partid=companyid)
|
nums = Equipment.objects.filter(usecomp__partid=companyid)
|
||||||
for i in nums:
|
for i in nums:
|
||||||
numdict[i.num]=i
|
numdict[i.num]=i
|
||||||
i=4
|
i=4
|
||||||
catedict = {'锅炉':352,'塔类':353,'反应器类':354,'储罐及容器类':355,'冷换设备类':356,'通用机械类':357,'动力类':358,'化工机械类':359,'起重运输类':360,'其他设备类':361,'其它设备类':361}
|
|
||||||
while sheet['c'+str(i)].value!=None:
|
while sheet['c'+str(i)].value!=None:
|
||||||
area = sheet['a'+str(i)].value
|
area = sheet['a'+str(i)].value
|
||||||
cate = sheet['b'+str(i)].value
|
cate = sheet['b'+str(i)].value
|
||||||
|
|
@ -268,6 +304,13 @@ def drequipments(companyid,path):
|
||||||
def drusers(companyid,path):
|
def drusers(companyid,path):
|
||||||
wb = load_workbook(path)
|
wb = load_workbook(path)
|
||||||
sheet = wb.worksheets[0]
|
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 = {}
|
partdict = {}
|
||||||
# groupdict = {}
|
# groupdict = {}
|
||||||
userdict = {}
|
userdict = {}
|
||||||
|
|
@ -322,7 +365,10 @@ def drusers(companyid,path):
|
||||||
else:
|
else:
|
||||||
userdict[username]=i
|
userdict[username]=i
|
||||||
i = i + 1
|
i = i + 1
|
||||||
return userdict
|
if userdict:
|
||||||
|
return {'code':2,'msg':'导入部分成功!','info':userdict}
|
||||||
|
else:
|
||||||
|
return {'code':1,'msg':'导入全部成功!'}
|
||||||
|
|
||||||
def drrisks(companyid,path):
|
def drrisks(companyid,path):
|
||||||
wb = load_workbook(path)
|
wb = load_workbook(path)
|
||||||
|
|
|
||||||
|
|
@ -97,23 +97,17 @@
|
||||||
var data = JSON.parse(evt.target.responseText);
|
var data = JSON.parse(evt.target.responseText);
|
||||||
removeLoading();
|
removeLoading();
|
||||||
if (data.code == 1) {
|
if (data.code == 1) {
|
||||||
$.messager.alert('提示', '上传成功!', 'info', function () {
|
$.messager.alert('提示', data.msg, 'info', function () {
|
||||||
$("#main").panel({ href: 'userhtml', title: '用户' });
|
$("#main").panel({ href: 'userhtml', title: '用户' });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if(data.code == 2){
|
else if(data.code == 2){
|
||||||
msg = ''
|
$.messager.alert('提示', data.msg + data.info, 'info', function () {
|
||||||
userdict = data.userdict
|
|
||||||
for(var key in userdict){
|
|
||||||
msg+=key+'(' + userdict[key].toString + '),'
|
|
||||||
}
|
|
||||||
msg+= '因账号重复未成功,其余成功!'
|
|
||||||
$.messager.alert('提示', msg, 'info', function () {
|
|
||||||
$("#main").panel({ href: 'userhtml', title: '用户' });
|
$("#main").panel({ href: 'userhtml', title: '用户' });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$.messager.alert('提示', '失败!文件内容有误');
|
$.messager.alert('提示', data.msg);
|
||||||
}
|
}
|
||||||
document.getElementById('drfile').value = '';
|
document.getElementById('drfile').value = '';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1130,30 +1130,30 @@ def accessyh(req):
|
||||||
postdict['touser']=a.fxr.openid
|
postdict['touser']=a.fxr.openid
|
||||||
send_wechatmsg.delay(postdict)
|
send_wechatmsg.delay(postdict)
|
||||||
return JsonResponse({"code":1})
|
return JsonResponse({"code":1})
|
||||||
else:
|
else:
|
||||||
a.shresult = 5
|
a.shresult = 5
|
||||||
a.yhzt = 0
|
a.yhzt = 0
|
||||||
a.sybzt = 1
|
a.sybzt = 1
|
||||||
a.todouser = a.fxr
|
a.todouser = a.fxr
|
||||||
a.pgyj = yhdata['pgyj']
|
a.pgyj = yhdata['pgyj']
|
||||||
a.save()
|
a.save()
|
||||||
m=TroubleAccess(troubleid=a,clr=a.pgr,yhzt=0,action='请'+a.fxr.name+'重新填报',result=0)
|
m=TroubleAccess(troubleid=a,clr=a.pgr,yhzt=0,action='请'+a.fxr.name+'重新填报',result=0)
|
||||||
m.save()
|
m.save()
|
||||||
postdict={
|
postdict={
|
||||||
'touser':'oPGqkweX75QtLmgehUN-ipR4hcyc',
|
'touser':'oPGqkweX75QtLmgehUN-ipR4hcyc',
|
||||||
'template_id':'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
|
'template_id':'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
|
||||||
"miniprogram":{"appid":"wx5c39b569f01c27db","path":"pages/trouble/accesstrouble?troubleid="+str(a.troubleid)},
|
"miniprogram":{"appid":"wx5c39b569f01c27db","path":"pages/trouble/accesstrouble?troubleid="+str(a.troubleid)},
|
||||||
'data':{
|
'data':{
|
||||||
'first':{'value':a.yhdj.dickeyname + '被退出需重新上报:'},
|
'first':{'value':a.yhdj.dickeyname + '被退回需重新上报:'},
|
||||||
'keyword1':{'value':a.yhms},
|
'keyword1':{'value':a.yhms},
|
||||||
'keyword2':{'value':a.fxsj},
|
'keyword2':{'value':a.fxsj},
|
||||||
'keyword3':{'value':a.yhdd},
|
'keyword3':{'value':a.yhdd},
|
||||||
'remark':{'value':'请查看评估意见并修改后上传。'}
|
'remark':{'value':'请查看评估意见并修改后上传。'}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
postdict['touser']=a.todouser.openid
|
||||||
postdict['touser']=a.todouser.openid
|
send_wechatmsg.delay(postdict)
|
||||||
send_wechatmsg.delay(postdict)
|
return JsonResponse({"code":1})
|
||||||
return JsonResponse({"code":1})
|
|
||||||
elif 'zppg' in yhdata and yhdata['zppg']=='yes':
|
elif 'zppg' in yhdata and yhdata['zppg']=='yes':
|
||||||
a.yhzt=1
|
a.yhzt=1
|
||||||
a.sybzt=1
|
a.sybzt=1
|
||||||
|
|
@ -2848,9 +2848,10 @@ def gchandle(req):
|
||||||
total = a.count()
|
total = a.count()
|
||||||
a = a[startnum:endnum].values('lookid','looknum','lookplace','actname','looktime','looker__name','lookeder','otherunsafe')
|
a = a[startnum:endnum].values('lookid','looknum','lookplace','actname','looktime','looker__name','lookeder','otherunsafe')
|
||||||
for i in a:
|
for i in a:
|
||||||
if Observeto.objects.filter(observe__lookid=i['lookid'],user__userid = userid).exists():
|
objs = Observeto.objects.filter(observe__lookid=i['lookid'],user__userid = userid)
|
||||||
|
if objs.exists():
|
||||||
i['read']=1
|
i['read']=1
|
||||||
i['readtime'] = Observeto.objects.filter(observe__lookid=i['lookid'],user__userid = userid)[0].submittime
|
i['readtime'] = objs[0].submittime
|
||||||
else:
|
else:
|
||||||
i['read']=0
|
i['read']=0
|
||||||
return HttpResponse(transjson(total,a),content_type="application/json")
|
return HttpResponse(transjson(total,a),content_type="application/json")
|
||||||
|
|
@ -2935,7 +2936,7 @@ def gchandle(req):
|
||||||
return JsonResponse(gcdict)
|
return JsonResponse(gcdict)
|
||||||
elif a == 'noreadnum':
|
elif a == 'noreadnum':
|
||||||
a = Observe.objects.filter(usecomp=Partment.objects.get(partid=companyid),deletemark=1).count()
|
a = Observe.objects.filter(usecomp=Partment.objects.get(partid=companyid),deletemark=1).count()
|
||||||
b = Observeto.objects.filter(user__userid=userid).count()
|
b = Observeto.objects.filter(user__userid=userid,observe__deletemark=1).count()
|
||||||
noread = a-b
|
noread = a-b
|
||||||
return JsonResponse({'noread':noread})
|
return JsonResponse({'noread':noread})
|
||||||
elif a == 'exportword':
|
elif a == 'exportword':
|
||||||
|
|
@ -3258,14 +3259,7 @@ def drapi(req):
|
||||||
filepath = filepath.replace('\\','/')
|
filepath = filepath.replace('\\','/')
|
||||||
with open( filepath, 'wb') as f:
|
with open( filepath, 'wb') as f:
|
||||||
f.write(req.FILES['upfile'].read())
|
f.write(req.FILES['upfile'].read())
|
||||||
# try:
|
return JsonResponse(drusers(companyid,filepath))
|
||||||
userdict = drusers(companyid,filepath)
|
|
||||||
if userdict:
|
|
||||||
return JsonResponse({"code":2,"userdict":userdict})
|
|
||||||
else:
|
|
||||||
return JsonResponse({"code":1})
|
|
||||||
# except:
|
|
||||||
# return JsonResponse({"code":0})
|
|
||||||
elif a == 'equipment':
|
elif a == 'equipment':
|
||||||
userid = req.session['userid']
|
userid = req.session['userid']
|
||||||
companyid = getcompany(userid)
|
companyid = getcompany(userid)
|
||||||
|
|
@ -4179,7 +4173,7 @@ def apitool(req):
|
||||||
i.save()
|
i.save()
|
||||||
return JsonResponse({"code":1})
|
return JsonResponse({"code":1})
|
||||||
elif a == 'correct_examtest':
|
elif a == 'correct_examtest':
|
||||||
for i in ExamTest.objects.all():
|
for i in ExamTest.objects.filter(Q(starttime=None)|Q(endtime=None)):
|
||||||
if i.starttime:
|
if i.starttime:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
|
@ -4193,6 +4187,16 @@ def apitool(req):
|
||||||
i.endtime = i.createtime + timedelta(days=1)
|
i.endtime = i.createtime + timedelta(days=1)
|
||||||
i.save()
|
i.save()
|
||||||
return JsonResponse({"code":1})
|
return JsonResponse({"code":1})
|
||||||
|
elif a == 'correct_bmzg':
|
||||||
|
for i in Partment.objects.filter(Q(bmzg__contains=',,')|Q(aqy__contains=',,')):
|
||||||
|
print(i)
|
||||||
|
if ',,' in i.bmzg:
|
||||||
|
i.bmzg = i.bmzg.replace(',,',',')
|
||||||
|
i.save()
|
||||||
|
if ',,' in i.aqy:
|
||||||
|
i.aqy = i.aqy.replace(',,',',')
|
||||||
|
i.save()
|
||||||
|
return JsonResponse({"code":1})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue