operation notice

This commit is contained in:
caoqianming 2019-11-27 00:27:04 +08:00
parent 08522c858b
commit a164dbce6a
2 changed files with 8 additions and 15 deletions

View File

@ -35,16 +35,6 @@ 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):

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,send_wechatmsgsu from .tasks import send_wechatmsgs,send_wechatmsg,yjjs,gettime,yjjs_px,yjjs_yl,updateTzzs,updateAqzs,yjjs_gc,yjjs_ws
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
@ -4509,7 +4509,7 @@ def apioperation(req):
postdict={ postdict={
'touser':'', 'touser':'',
'template_id':'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0', 'template_id':'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
"miniprogram":{"appid":"wx5c39b569f01c27db"}, 'miniprogram':{'appid":"wx5c39b569f01c27db'},
'data':{ 'data':{
'first':{ 'first':{
'value':obj.zylx.dickeyname + '作业审批:' 'value':obj.zylx.dickeyname + '作业审批:'
@ -4528,7 +4528,8 @@ def apioperation(req):
} }
} }
} }
send_wechatmsgsu.delay(postdict,sprs) tolist = list(User.objects.filter(userid__in=sprs).values_list('openid',flat=True))
send_wechatmsgs.delay(postdict,tolist)
return JsonResponse({"code":1}) return JsonResponse({"code":1})
elif a == 'spzy': elif a == 'spzy':
userid = req.session['userid'] userid = req.session['userid']
@ -4596,7 +4597,8 @@ def apioperation(req):
} }
} }
} }
send_wechatmsgsu.delay(postdict,newsprs) tolist = list(User.objects.filter(userid__in=newsprs).values_list('openid',flat=True))
send_wechatmsgs.delay(postdict,tolist)
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:
@ -4628,7 +4630,8 @@ def apioperation(req):
} }
} }
} }
send_wechatmsgsu.delay(postdict,nextsplc['sprs']) tolist = list(User.objects.filter(userid__in=nextsplc['sprs']).values_list('openid',flat=True))
send_wechatmsgs.delay(postdict,tolist)
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 :