From fcea0213798ee8a22b1599f5ad11ba1dca55b16a Mon Sep 17 00:00:00 2001 From: caoqianming Date: Wed, 25 Sep 2019 20:18:41 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9A=90=E6=82=A3=E3=80=81=E5=BB=BA=E8=AE=AE?= =?UTF-8?q?=E5=B8=83=E8=8C=A8=E7=BA=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migrations/0271_auto_20190925_1113.py | 18 ++++ .../migrations/0272_auto_20190925_1657.py | 18 ++++ safesite/models.py | 2 + safesite/templates/trouble.html | 4 +- safesite/views.py | 93 +++++++++++++------ 5 files changed, 107 insertions(+), 28 deletions(-) create mode 100644 safesite/migrations/0271_auto_20190925_1113.py create mode 100644 safesite/migrations/0272_auto_20190925_1657.py diff --git a/safesite/migrations/0271_auto_20190925_1113.py b/safesite/migrations/0271_auto_20190925_1113.py new file mode 100644 index 00000000..22b22b28 --- /dev/null +++ b/safesite/migrations/0271_auto_20190925_1113.py @@ -0,0 +1,18 @@ +# Generated by Django 2.1.5 on 2019-09-25 11:13 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('safesite', '0270_auto_20190920_1200'), + ] + + operations = [ + migrations.AlterField( + model_name='trouble', + name='shresult', + field=models.IntegerField(blank=True, choices=[(1, '通过'), (2, '审核未通过'), (3, '复查未通过'), (4, '已修改'), (5, '评估未通过'), (6, '未采纳')], null=True), + ), + ] diff --git a/safesite/migrations/0272_auto_20190925_1657.py b/safesite/migrations/0272_auto_20190925_1657.py new file mode 100644 index 00000000..070d32ac --- /dev/null +++ b/safesite/migrations/0272_auto_20190925_1657.py @@ -0,0 +1,18 @@ +# Generated by Django 2.1.5 on 2019-09-25 16:57 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('safesite', '0271_auto_20190925_1113'), + ] + + operations = [ + migrations.AddField( + model_name='suggest', + name='accept', + field=models.IntegerField(default=1), + ), + ] diff --git a/safesite/models.py b/safesite/models.py index d7b1815f..524f261f 100644 --- a/safesite/models.py +++ b/safesite/models.py @@ -120,6 +120,7 @@ class Trouble(models.Model):#隐患排查 (3, '复查未通过'), (4, '已修改'), (5,'评估未通过'), + (6,'未采纳'), ) deletemark=models.IntegerField(default='1') troubleid = models.AutoField(primary_key=True) @@ -409,6 +410,7 @@ class Suggest(models.Model):#合理化建议 yjwcsj = models.DateTimeField(null=True,blank=True) #预计完成时间 sjwcsj = models.DateTimeField(null=True,blank=True) #实际完成时间 shyj = models.CharField(max_length=1000,null=True,blank=True) #审核意见 + accept = models.IntegerField(default=1) class Suggestflow(models.Model):#建议流程 id = models.AutoField(primary_key=True) diff --git a/safesite/templates/trouble.html b/safesite/templates/trouble.html index 04eedee4..c7cc757c 100644 --- a/safesite/templates/trouble.html +++ b/safesite/templates/trouble.html @@ -116,12 +116,13 @@ { field: 'todouser__userid', hidden: true }, { field: 'sybzt', hidden: true }, { - field: 'shresult', title: '整改结果状态', width: 100, styler: function (value, row, index) { + field: 'shresult', title: '隐患状态', width: 100, styler: function (value, row, index) { switch (value) { case 1: return ''; break; case 2: return 'background-color:red;'; break; case 3: return 'background-color:red;'; break; case 4: return 'background-color:yellow;'; break; + case 6: return 'background-color:yellow;'; break; } }, formatter: function (value, row, index) { switch (value) { @@ -130,6 +131,7 @@ case 3: return '复查未通过'; break; case 4: return '已修改'; break; case 5: return '评估未通过'; break; + case 6: return '未采纳'; break; } } }, diff --git a/safesite/views.py b/safesite/views.py index fd426a0a..60cc281a 100644 --- a/safesite/views.py +++ b/safesite/views.py @@ -945,29 +945,55 @@ def accessyh(req): return JsonResponse({"code":1}) elif a.yhzt==1: if yhdata['shresult'] == 'reject': - 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':'请查看评估意见并修改后上传。'} + if 'accept' in yhdata: + if yhdata['accept'] == 'no': + a.shresult = 6 + a.yhzt = 6 + a.sybzt = 1 + a.todouser = None + a.pgyj = yhdata['pgyj'] + a.save() + m=TroubleAccess(troubleid=a,clr=a.pgr,yhzt=6,action='未采纳',opinion=yhdata['pgyj']) + 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.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':'请查看评估意见并修改后上传。'} + } } - } - 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 @@ -2551,9 +2577,10 @@ def gchandle(req): if 'unsafe' in gcdata: olist = gcdata['unsafe'] for i in olist: - dickey = Dickey.objects.get(dickeyid=i) - m = Unsafes(observe = obj,unsafedickey=dickey,unsafedicclass=dickey.dicparent) - m.save() + if i != 0: + dickey = Dickey.objects.get(dickeyid=i) + m = Unsafes(observe = obj,unsafedickey=dickey,unsafedicclass=dickey.dicparent) + m.save() yjjs_gc.delay(companyid) return JsonResponse({"code":1}) elif a == 'listall': @@ -3692,11 +3719,23 @@ def apitool(req): newpart = req.GET.get('part') username = req.GET.get('username') user = User.objects.get(username=username) + oldpart = user.ubelongpart + oldpart.aqy = oldpart.aqy.replace(','+str(user.userid)+',','') + oldpart.bmzg = oldpart.bmzg.replace(','+str(user.userid)+',','') + oldpart.bsq = oldpart.bsq.replace(','+str(user.userid)+',','') + oldpart.save() part = Partment.objects.get(partid=newpart) - companyid = part.partlink.split(',')[1] + if part.iscompany==1: + usecomp = part + else: + usecomp = Partment.objects.get(partid=part.partlink.split(',')[1]) user.ubelongpart = part - user.usecomp = Partment.objects.get(partid=companyid) + user.usecomp = usecomp user.save() + for i in Group.objects.filter(usecomp=usecomp): + i.users.remove(user) + groupobj = Group.objects.filter(usecomp=usecomp,grouptype=3).first() + groupobj.users.add(user) return JsonResponse({"code":1}) elif a == 'correctionzs': objs = Socertificate.objects.all()