operation notification

This commit is contained in:
caoqianming 2019-11-25 17:43:07 +08:00
parent 55e2aeedf7
commit 9154ada5a3
4 changed files with 80 additions and 72 deletions

View File

@ -582,4 +582,4 @@ $.get('api/check_session',function(res){
}) })
} }
var t1 = window.setInterval(update, 1000 * 60) var t1 = window.setInterval(update, 1000 * 60)
var t2 = window.setInterval(checksession,1000*60*31) var t2 = window.setInterval(checksession,1000*60*41)

View File

@ -35,6 +35,17 @@ def send_wechatmsgs(postdict,tolist):
except: except:
pass pass
@shared_task
def send_wechatmsgsu(postdict,tousers):
with open(dirname + 'token.txt','r',encoding= 'utf-8') as f:
token=f.read()
try:
for i in tousers:
postdict['touser']= User.object.get(userid=i).openid
requests.post('https://api.weixin.qq.com/cgi-bin/message/template/send?access_token='+token,data=json.dumps(postdict))
except:
pass
@shared_task @shared_task
def send_wechatmsg(postdict): def send_wechatmsg(postdict):
with open(dirname + 'token.txt','r',encoding= 'utf-8') as f: with open(dirname + 'token.txt','r',encoding= 'utf-8') as f:

View File

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

View File

@ -13,7 +13,7 @@ import time
from datetime import datetime,date,timedelta from datetime import datetime,date,timedelta
from django.db.models import F,Count,Sum from django.db.models import F,Count,Sum
import requests import requests
from .tasks import send_wechatmsgs,send_wechatmsg,yjjs,gettime,yjjs_px,yjjs_yl,updateTzzs,updateAqzs,yjjs_gc,yjjs_ws from .tasks import send_wechatmsgs,send_wechatmsg,yjjs,gettime,yjjs_px,yjjs_yl,updateTzzs,updateAqzs,yjjs_gc,yjjs_ws,send_wechatmsgsu
from .export import exportdoc,exportxlsx,exportyjdoc,exportsimplexlsx,exportdoc2 from .export import exportdoc,exportxlsx,exportyjdoc,exportsimplexlsx,exportdoc2
from .daoru import drusers,drequipments,drrisks,drquestions,cal_riskact_level,cal_area_risk_level,makeqr,makeqr_train,makeqr_riskact,makeqr_examtest,makeqr_area from .daoru import drusers,drequipments,drrisks,drquestions,cal_riskact_level,cal_area_risk_level,makeqr,makeqr_train,makeqr_riskact,makeqr_examtest,makeqr_area
from django.forms.models import model_to_dict from django.forms.models import model_to_dict
@ -4499,30 +4499,29 @@ def apioperation(req):
sprs = [obj.zyzt['splc'][index]['spr']] sprs = [obj.zyzt['splc'][index]['spr']]
obj.todousers = sprs obj.todousers = sprs
obj.save() obj.save()
for i in sprs: postdict={
postdict={ 'touser':'',
'touser':'', 'template_id':'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
'template_id':User.objects.get(userid=i).openid, "miniprogram":{"appid":"wx5c39b569f01c27db"},
"miniprogram":{"appid":"wx5c39b569f01c27db"}, 'data':{
'data':{ 'first':{
'first':{ 'value':obj.zylx.dickeyname + '作业审批:'
'value':obj.zylx.dickeyname + '作业审批:' },
}, 'keyword1':{
'keyword1':{ 'value':obj.zynr
'value':obj.zynr },
}, 'keyword2':{
'keyword2':{ 'value':obj.kssj
'value':obj.kssj },
}, 'keyword3':{
'keyword3':{ 'value':obj.zydd
'value':obj.zydd },
}, 'remark':{
'remark':{ 'value':'请您及时完成审批!'
'value':'请您及时完成审批!'
}
} }
} }
send_wechatmsg.delay(postdict) }
send_wechatmsgsu.delay(postdict,sprs)
return JsonResponse({"code":1}) return JsonResponse({"code":1})
elif a == 'spzy': elif a == 'spzy':
userid = req.session['userid'] userid = req.session['userid']
@ -4541,7 +4540,7 @@ def apioperation(req):
Operspxq.objects.create(oper=Operation.objects.get(zyid=zyid),jdmc=oldjdmc,spr=spruser,checked=1,spbm=spruser.ubelongpart) Operspxq.objects.create(oper=Operation.objects.get(zyid=zyid),jdmc=oldjdmc,spr=spruser,checked=1,spbm=spruser.ubelongpart)
postdict={ postdict={
'touser':'', 'touser':'',
'template_id':obj.zyfzr.openid, 'template_id':'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
"miniprogram":{"appid":"wx5c39b569f01c27db"}, "miniprogram":{"appid":"wx5c39b569f01c27db"},
'data':{ 'data':{
'first':{ 'first':{
@ -4567,30 +4566,29 @@ def apioperation(req):
newsprs = data['newsprs']#新审批人 newsprs = data['newsprs']#新审批人
obj.todousers = newsprs obj.todousers = newsprs
obj.save() obj.save()
for i in newsprs: postdict={
postdict={ 'touser':'',
'touser':'', 'template_id':'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
'template_id':User.objects.get(userid=i).openid, "miniprogram":{"appid":"wx5c39b569f01c27db"},
"miniprogram":{"appid":"wx5c39b569f01c27db"}, 'data':{
'data':{ 'first':{
'first':{ 'value':obj.zylx.dickeyname + '作业审批:'
'value':obj.zylx.dickeyname + '作业审批:' },
}, 'keyword1':{
'keyword1':{ 'value':obj.zynr
'value':obj.zynr },
}, 'keyword2':{
'keyword2':{ 'value':obj.kssj
'value':obj.kssj },
}, 'keyword3':{
'keyword3':{ 'value':obj.zydd
'value':obj.zydd },
}, 'remark':{
'remark':{ 'value':'请您及时完成审批!'
'value':'请您及时完成审批!'
}
} }
} }
send_wechatmsg.delay(postdict) }
send_wechatmsgsu.delay(postdict,newsprs)
Operspxq.objects.create(oper=Operation.objects.get(zyid=zyid),jdmc=oldjdmc,spr=spruser,checked=2,spbm=spruser.ubelongpart) Operspxq.objects.create(oper=Operation.objects.get(zyid=zyid),jdmc=oldjdmc,spr=spruser,checked=2,spbm=spruser.ubelongpart)
return JsonResponse({"code":1}) return JsonResponse({"code":1})
try: try:
@ -4600,30 +4598,29 @@ def apioperation(req):
obj.zyzt['jdmc'] = nextsplc['jdmc'] obj.zyzt['jdmc'] = nextsplc['jdmc']
obj.todousers = nextsplc['sprs'] obj.todousers = nextsplc['sprs']
obj.save() obj.save()
for i in nextsplc['sprs']: postdict={
postdict={ 'touser':'',
'touser':'', 'template_id':'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
'template_id':User.objects.get(userid=i).openid, "miniprogram":{"appid":"wx5c39b569f01c27db"},
"miniprogram":{"appid":"wx5c39b569f01c27db"}, 'data':{
'data':{ 'first':{
'first':{ 'value':obj.zylx.dickeyname + '作业审批:'
'value':obj.zylx.dickeyname + '作业审批:' },
}, 'keyword1':{
'keyword1':{ 'value':obj.zynr
'value':obj.zynr },
}, 'keyword2':{
'keyword2':{ 'value':obj.kssj
'value':obj.kssj },
}, 'keyword3':{
'keyword3':{ 'value':obj.zydd
'value':obj.zydd },
}, 'remark':{
'remark':{ 'value':'请您及时完成审批!'
'value':'请您及时完成审批!'
}
} }
} }
send_wechatmsg.delay(postdict) }
send_wechatmsgsu.delay(postdict,nextsplc['sprs'])
Operspxq.objects.create(oper=Operation.objects.get(zyid=zyid),jdmc=oldjdmc,spr=spruser,checked=1,spbm=spruser.ubelongpart) Operspxq.objects.create(oper=Operation.objects.get(zyid=zyid),jdmc=oldjdmc,spr=spruser,checked=1,spbm=spruser.ubelongpart)
except : except :
@ -4634,7 +4631,7 @@ def apioperation(req):
Operspxq.objects.create(oper=Operation.objects.get(zyid=zyid),jdmc=oldjdmc,spr=spruser,checked=1,spbm=spruser.ubelongpart) Operspxq.objects.create(oper=Operation.objects.get(zyid=zyid),jdmc=oldjdmc,spr=spruser,checked=1,spbm=spruser.ubelongpart)
postdict={ postdict={
'touser':'', 'touser':'',
'template_id':obj.zyfzr.openid, 'template_id':'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
"miniprogram":{"appid":"wx5c39b569f01c27db"}, "miniprogram":{"appid":"wx5c39b569f01c27db"},
'data':{ 'data':{
'first':{ 'first':{