From 08489774383cb16c28e313277f2920fe30ce8f2c Mon Sep 17 00:00:00 2001 From: caoqianming Date: Mon, 2 Dec 2019 21:08:02 +0800 Subject: [PATCH 1/8] operation check complete --- safesite/templates/examtestadd.html | 2 +- safesite/templates/examtestadd2.html | 2 +- safesite/views.py | 114 ++++++++++++++++++--------- 3 files changed, 78 insertions(+), 40 deletions(-) diff --git a/safesite/templates/examtestadd.html b/safesite/templates/examtestadd.html index 8f9ed5b8..1adfe4a0 100644 --- a/safesite/templates/examtestadd.html +++ b/safesite/templates/examtestadd.html @@ -29,7 +29,7 @@
+ data-options="label:'最早参加',currentText:'今天',closeText:'关闭',showSeconds: false,required:true" />
+ data-options="label:'考试开启',currentText:'今天',closeText:'关闭',showSeconds: false,required:true" />
datetime.now(): - i['isActive'] = True + if i['examtest__endtime']: + if i['examtest__endtime']>datetime.now(): + i['isActive'] = True + else: + i['isActive'] = False else: - i['isActive'] = False + i['isActive'] = True return HttpResponse(transjson(total,a),content_type="application/json") elif a=='listyk': a = ExamTestDetail.objects From 18190d1100bccd7e48d4eba7f5fcd70d5fc6caab Mon Sep 17 00:00:00 2001 From: caoqianming Date: Mon, 2 Dec 2019 21:43:10 +0800 Subject: [PATCH 2/8] operation check complete2 --- safesite/views.py | 81 +++++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 41 deletions(-) diff --git a/safesite/views.py b/safesite/views.py index d7552513..1c503921 100644 --- a/safesite/views.py +++ b/safesite/views.py @@ -4430,50 +4430,49 @@ def apioperation(req): x=User.objects.get(userid=i) if int(userid)==int(i):#申请人包含作业人直接确认 Operzyry.objects.create(oper=obj,operzyry=x,checked=1) - if Operzyry.objects.filter(oper=obj,checked=0).exists(): - pass - else:#工作人员全部确认 - obj.zyzt['zyzt'] = '审批中' - obj.zyzt['index'] = 0 - index = obj.zyzt['index'] - sprs = [] #初始化审批人列表 - if 'sprs' in obj.zyzt['splc'][index]: - sprs = obj.zyzt['splc'][index]['sprs'] - else: - sprs = [obj.zyzt['splc'][index]['spr']] - jdmc = obj.zyzt['splc'][index]['jdmc'] - obj.zyzt['jdmc'] = jdmc - obj.todousers = sprs - obj.save() - postdict={ - 'touser':'', - 'template_id':'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0', - 'miniprogram':{'appid':'wx5c39b569f01c27db'}, - 'data':{ - 'first':{ - 'value':obj.zylx.dickeyname + '作业审批,审批节点:' + obj.zyzt['jdmc'] - }, - 'keyword1':{ - 'value':obj.zynr - }, - 'keyword2':{ - 'value':obj.kssj - }, - 'keyword3':{ - 'value':obj.zydd - }, - 'remark':{ - 'value':'请您及时完成审批!' - } - } - } - tolist = list(User.objects.filter(userid__in=sprs).values_list('openid',flat=True)) - send_wechatmsgs.delay(postdict,tolist) - return JsonResponse({"code":1}) else: Operzyry.objects.create(oper=obj,operzyry=x) b.append(x.openid) - + if b: + pass + else:#工作人员全部确认 + obj.zyzt['zyzt'] = '审批中' + obj.zyzt['index'] = 0 + index = obj.zyzt['index'] + sprs = [] #初始化审批人列表 + if 'sprs' in obj.zyzt['splc'][index]: + sprs = obj.zyzt['splc'][index]['sprs'] + else: + sprs = [obj.zyzt['splc'][index]['spr']] + jdmc = obj.zyzt['splc'][index]['jdmc'] + obj.zyzt['jdmc'] = jdmc + obj.todousers = sprs + obj.save() + postdict={ + 'touser':'', + 'template_id':'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0', + 'miniprogram':{'appid':'wx5c39b569f01c27db'}, + 'data':{ + 'first':{ + 'value':obj.zylx.dickeyname + '作业审批,审批节点:' + obj.zyzt['jdmc'] + }, + 'keyword1':{ + 'value':obj.zynr + }, + 'keyword2':{ + 'value':obj.kssj + }, + 'keyword3':{ + 'value':obj.zydd + }, + 'remark':{ + 'value':'请您及时完成审批!' + } + } + } + tolist = list(User.objects.filter(userid__in=sprs).values_list('openid',flat=True)) + send_wechatmsgs.delay(postdict,tolist) + return JsonResponse({"code":1}) postdict={ 'touser':'', 'template_id':'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0', From d06de9eb392fa6d0f76898bb96b9a434226d2e41 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Mon, 2 Dec 2019 23:58:01 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E5=90=88=E5=B9=B6=E8=B7=B3=E8=BF=87?= =?UTF-8?q?=E5=AE=A1=E6=89=B9=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- safesite/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/safesite/views.py b/safesite/views.py index 1c503921..86157cf7 100644 --- a/safesite/views.py +++ b/safesite/views.py @@ -4631,7 +4631,7 @@ def apioperation(req): obj.zyzt['splc'][1]['sprs'] = [spr1] #作业部门审批人 if spr2: obj.zyzt['splc'][2]['sprs'] = [spr2] #属地部门审批人 - while nextindex Date: Tue, 3 Dec 2019 00:15:58 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E5=90=88=E5=B9=B6=E5=AE=A1=E6=89=B9?= =?UTF-8?q?=E4=BA=BA2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- safesite/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/safesite/views.py b/safesite/views.py index 1c503921..36b4b63f 100644 --- a/safesite/views.py +++ b/safesite/views.py @@ -4734,7 +4734,7 @@ def apioperation(req): } } } - Operspxq.objects.create(oper=obj,jdmc=obj.zyzt['splc'][nextindex-1]['jdmc'],spr=spruser,checked=1,spbm=spruser.ubelongpart) + # Operspxq.objects.create(oper=obj,jdmc=obj.zyzt['splc'][nextindex-1]['jdmc'],spr=spruser,checked=1,spbm=spruser.ubelongpart) send_wechatmsg.delay(postdict) return JsonResponse({"code":1}) elif a == 'gbzy':#关闭作业 From a8d06aeaf49e2d23d8c8a5e49f729e27a64e57d6 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Tue, 3 Dec 2019 00:19:31 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E5=90=88=E5=B9=B6=E5=AE=A1=E6=89=B9?= =?UTF-8?q?=E4=BA=BA3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- safesite/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/safesite/views.py b/safesite/views.py index e7f87a58..36b4b63f 100644 --- a/safesite/views.py +++ b/safesite/views.py @@ -4631,7 +4631,7 @@ def apioperation(req): obj.zyzt['splc'][1]['sprs'] = [spr1] #作业部门审批人 if spr2: obj.zyzt['splc'][2]['sprs'] = [spr2] #属地部门审批人 - while nextindex Date: Wed, 4 Dec 2019 18:01:07 +0800 Subject: [PATCH 6/8] equipment import;observe noread;correct bmzg --- safesite/daoru.py | 50 ++++++++++++++++++++- safesite/templates/userhtml.html | 12 ++---- safesite/views.py | 74 +++++++++++++++++--------------- 3 files changed, 90 insertions(+), 46 deletions(-) diff --git a/safesite/daoru.py b/safesite/daoru.py index 8af79c88..695a1138 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 @@ -268,6 +304,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 +365,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/userhtml.html b/safesite/templates/userhtml.html index 8e50b55e..fe5ec32d 100644 --- a/safesite/templates/userhtml.html +++ b/safesite/templates/userhtml.html @@ -97,23 +97,17 @@ var data = JSON.parse(evt.target.responseText); removeLoading(); if (data.code == 1) { - $.messager.alert('提示', '上传成功!', 'info', function () { + $.messager.alert('提示', data.msg, 'info', function () { $("#main").panel({ href: 'userhtml', title: '用户' }); }); } else if(data.code == 2){ - msg = '' - userdict = data.userdict - for(var key in userdict){ - msg+=key+'(' + userdict[key].toString + '),' - } - msg+= '因账号重复未成功,其余成功!' - $.messager.alert('提示', msg, 'info', function () { + $.messager.alert('提示', data.msg + data.info, 'info', function () { $("#main").panel({ href: 'userhtml', title: '用户' }); }); } else { - $.messager.alert('提示', '失败!文件内容有误'); + $.messager.alert('提示', data.msg); } document.getElementById('drfile').value = ''; diff --git a/safesite/views.py b/safesite/views.py index 1c503921..db318501 100644 --- a/safesite/views.py +++ b/safesite/views.py @@ -1130,30 +1130,30 @@ def accessyh(req): postdict['touser']=a.fxr.openid send_wechatmsg.delay(postdict) return JsonResponse({"code":1}) - else: - a.shresult = 5 - a.yhzt = 0 - a.sybzt = 1 - a.todouser = a.fxr - a.pgyj = yhdata['pgyj'] - a.save() - m=TroubleAccess(troubleid=a,clr=a.pgr,yhzt=0,action='请'+a.fxr.name+'重新填报',result=0) - m.save() - postdict={ - 'touser':'oPGqkweX75QtLmgehUN-ipR4hcyc', - 'template_id':'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0', - "miniprogram":{"appid":"wx5c39b569f01c27db","path":"pages/trouble/accesstrouble?troubleid="+str(a.troubleid)}, - 'data':{ - 'first':{'value':a.yhdj.dickeyname + '被退出需重新上报:'}, - 'keyword1':{'value':a.yhms}, - 'keyword2':{'value':a.fxsj}, - 'keyword3':{'value':a.yhdd}, - 'remark':{'value':'请查看评估意见并修改后上传。'} + else: + a.shresult = 5 + a.yhzt = 0 + a.sybzt = 1 + a.todouser = a.fxr + a.pgyj = yhdata['pgyj'] + a.save() + m=TroubleAccess(troubleid=a,clr=a.pgr,yhzt=0,action='请'+a.fxr.name+'重新填报',result=0) + m.save() + postdict={ + 'touser':'oPGqkweX75QtLmgehUN-ipR4hcyc', + 'template_id':'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0', + "miniprogram":{"appid":"wx5c39b569f01c27db","path":"pages/trouble/accesstrouble?troubleid="+str(a.troubleid)}, + 'data':{ + 'first':{'value':a.yhdj.dickeyname + '被退回需重新上报:'}, + 'keyword1':{'value':a.yhms}, + 'keyword2':{'value':a.fxsj}, + 'keyword3':{'value':a.yhdd}, + 'remark':{'value':'请查看评估意见并修改后上传。'} + } } - } - postdict['touser']=a.todouser.openid - send_wechatmsg.delay(postdict) - return JsonResponse({"code":1}) + postdict['touser']=a.todouser.openid + send_wechatmsg.delay(postdict) + return JsonResponse({"code":1}) elif 'zppg' in yhdata and yhdata['zppg']=='yes': a.yhzt=1 a.sybzt=1 @@ -2848,9 +2848,10 @@ def gchandle(req): total = a.count() a = a[startnum:endnum].values('lookid','looknum','lookplace','actname','looktime','looker__name','lookeder','otherunsafe') 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['readtime'] = Observeto.objects.filter(observe__lookid=i['lookid'],user__userid = userid)[0].submittime + i['readtime'] = objs[0].submittime else: i['read']=0 return HttpResponse(transjson(total,a),content_type="application/json") @@ -2935,7 +2936,7 @@ def gchandle(req): return JsonResponse(gcdict) elif a == 'noreadnum': 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 return JsonResponse({'noread':noread}) elif a == 'exportword': @@ -3258,14 +3259,7 @@ def drapi(req): filepath = filepath.replace('\\','/') with open( filepath, 'wb') as f: f.write(req.FILES['upfile'].read()) - # try: - userdict = drusers(companyid,filepath) - if userdict: - return JsonResponse({"code":2,"userdict":userdict}) - else: - return JsonResponse({"code":1}) - # except: - # return JsonResponse({"code":0}) + return JsonResponse(drusers(companyid,filepath)) elif a == 'equipment': userid = req.session['userid'] companyid = getcompany(userid) @@ -4179,7 +4173,7 @@ def apitool(req): i.save() return JsonResponse({"code":1}) 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: pass else: @@ -4193,6 +4187,16 @@ def apitool(req): i.endtime = i.createtime + timedelta(days=1) i.save() 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}) From 15ff36c244464debad7aff33a69116cc0d7b29e1 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Wed, 4 Dec 2019 20:52:25 +0800 Subject: [PATCH 7/8] equipment daoru --- safesite/daoru.py | 5 ++++- safesite/templates/equipment.html | 12 +++--------- safesite/views.py | 7 +------ 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/safesite/daoru.py b/safesite/daoru.py index 695a1138..f8c8f0ab 100644 --- a/safesite/daoru.py +++ b/safesite/daoru.py @@ -292,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} diff --git a/safesite/templates/equipment.html b/safesite/templates/equipment.html index 95ef4534..ca770a8f 100644 --- a/safesite/templates/equipment.html +++ b/safesite/templates/equipment.html @@ -311,23 +311,17 @@ var data = JSON.parse(evt.target.responseText); removeLoading(); if (data.code == 1) { - $.messager.alert('提示', '上传成功!', 'info', function () { + $.messager.alert('提示', data.msg, 'info', function () { $("#main").panel({ href: 'html/equipment', title: '设备设施' }); }); } else if (data.code == 2) { - msg = '' - equipmentdict = data.equipmentdict - // for (var key in equipmentdict) { - // msg += key + ',' - // } - msg += '部分因编号重复未成功上传!' - $.messager.alert('提示', msg, 'info', function () { + $.messager.alert('提示', data.msg+data.info, 'info', function () { $("#main").panel({ href: 'html/equipment', title: '用户' }); }); } else { - $.messager.alert('提示', '失败!文件内容有误'); + $.messager.alert('提示', data.msg); } document.getElementById('drfile').value = ''; diff --git a/safesite/views.py b/safesite/views.py index f1d8ff77..0a2667bc 100644 --- a/safesite/views.py +++ b/safesite/views.py @@ -3271,12 +3271,7 @@ def drapi(req): filepath = filepath.replace('\\','/') with open( filepath, 'wb') as f: f.write(req.FILES['upfile'].read()) - # try: - equipmentdict = drequipments(companyid,filepath) - if equipmentdict: - return JsonResponse({"code":2,"equipmentdict":equipmentdict}) - else: - return JsonResponse({"code":1}) + return JsonResponse(drequipments(companyid,filepath)) elif a == 'risk': userid = req.session['userid'] companyid = getcompany(userid) From cde61132f299f08ae8a1232dd2ab6865265dd16d Mon Sep 17 00:00:00 2001 From: caoqianming Date: Wed, 4 Dec 2019 20:55:17 +0800 Subject: [PATCH 8/8] file type xianzhi --- safesite/templates/abdrill.html | 2 +- safesite/templates/abtrain.html | 2 +- safesite/templates/noticeadd.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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>
- +
- +