去除通知

This commit is contained in:
caoqianming 2021-10-15 11:31:35 +08:00
parent e2f436da1e
commit aea2392170
4 changed files with 272 additions and 103 deletions

View File

@ -26,25 +26,27 @@ def gettime(x=datetime.datetime.now()):
@shared_task
def send_wechatmsgs(postdict,tolist):
with open(dirname + 'token.txt','r',encoding= 'utf-8') as f:
token=f.read()
try:
for i in tolist:
postdict['touser']=i
requests.post('https://api.weixin.qq.com/cgi-bin/message/template/send?access_token='+token,data=json.dumps(postdict))
except:
pass
pass
# with open(dirname + 'token.txt','r',encoding= 'utf-8') as f:
# token=f.read()
# try:
# for i in tolist:
# postdict['touser']=i
# requests.post('https://api.weixin.qq.com/cgi-bin/message/template/send?access_token='+token,data=json.dumps(postdict))
# except:
# pass
@shared_task
def send_wechatmsg(postdict):
with open(dirname + 'token.txt','r',encoding= 'utf-8') as f:
token=f.read()
try:
v = requests.post('https://api.weixin.qq.com/cgi-bin/message/template/send?access_token='+token,data=json.dumps(postdict))
print(v.text())
except:
pass
pass
# with open(dirname + 'token.txt','r',encoding= 'utf-8') as f:
# token=f.read()
# try:
# v = requests.post('https://api.weixin.qq.com/cgi-bin/message/template/send?access_token='+token,data=json.dumps(postdict))
# print(v.text())
# except:
# pass
@shared_task
def yjjs(companyid):

View File

@ -96,8 +96,8 @@
<div style="text-align: center;position: fixed;width: auto;height: 70px;top: 40px;right: 60px;">
<a style="color: #eee5e7;cursor: pointer;" class="easyui-linkbutton" iconCls="fa-sign-out" plain=true
onclick="logout()">安全退出</a>
<a style="color: #eee5e7;cursor: pointer;" id="bindwx" class="easyui-linkbutton" iconCls="fa-weixin"
plain=true onclick="bindwx()">绑定微信</a>
<!-- <a style="color: #eee5e7;cursor: pointer;" id="bindwx" class="easyui-linkbutton" iconCls="fa-weixin"
plain=true onclick="bindwx()">绑定微信</a> -->
<a style="color: #eee5e7;cursor: pointer;" class="easyui-linkbutton" iconCls="fa-key" plain=true
onclick="javascript:$('#pwdg').dialog({border:false})">修改密码</a>
<a id='setupb' class="easyui-linkbutton" iconCls="fa-cogs" plain=true
@ -240,7 +240,9 @@
var headimgurl = $('#userindex').attr('headimgurl');
var issuper = {{ issuper }};
if (issuper == 1) { $('#setupb').show(); $('#bindwx').hide() }
if ((openid == 0 || openid == 'None') && issuper != 1) { $('#wxdg').dialog(); } else { $('#bindwx').text('解绑微信'); };
if ((openid == 0 || openid == 'None') && issuper != 1) {
// $('#wxdg').dialog();
} else { $('#bindwx').text('解绑微信'); };
if (headimgurl != 0 && headimgurl != 'None' && issuper != 1) { $('#headimg').attr('src', headimgurl); }
function logout() {
$.messager.confirm('系统提示', '您确定要退出本次登录吗?', function (r) {

View File

@ -166,12 +166,10 @@
<div class="login_qrcode" id="J_login_qrcode">
<div class="login_qrcode_container">
<span class="txt_scan">扫码关注微信公众号、小程序</span> <span onclick="hideWechatQRcode();" class="wchatClose"></span>
<img class='gzcode' src="/static/safesite/mystatic/images/weixin.jpg">
<span class="txt_scan">扫码打开小程序</span> <span onclick="hideWechatQRcode();" class="wchatClose"></span>
<!-- <img class='gzcode' src="/static/safesite/mystatic/images/weixin.jpg"> -->
<img class="gzcode2" src="/static/safesite/mystatic/images/weixinmp.jpg">
<p>
请点开微信,扫码,关注公众号、小程序
</p>
</div>
</div>
<div class="login_mask" id="J_login_mask"></div>

View File

@ -21,7 +21,7 @@ from django.contrib.auth.hashers import check_password, make_password
from django.contrib.sessions.models import Session
from django.core import serializers
from django.core.serializers.json import DjangoJSONEncoder
from django.db.models import Avg, Count, F, Q, Sum, Max
from django.db.models import Avg, Count, F, Q, Sum
from django.forms.models import model_to_dict
from django.http import (HttpResponse, HttpResponseRedirect, JsonResponse,
request)
@ -31,7 +31,7 @@ from django.views.decorators.csrf import csrf_exempt
from django.views.generic import TemplateView
from duibiao import calsim
from groups import models as g_models
from mysite.settings_dev import APPID_MP, APPSECRET_MP
from . import forms
from .daoru import (cal_area_risk_level, cal_riskact_level, drequipments,
drquestions, drrisks, drtodotroubles, drusers, makeqr, drsafelist,
@ -564,6 +564,11 @@ def equipmentfigure(req):
def resbility(req):
return render(req, 'resbility.html')
def contingencyplan(req):
return render(req, 'contingencyplan.html')
def contingencyplanadd(req):
return render(req, 'contingencyplanadd.html')
def addresbility(req):#责任制
return render(req,'resbilityadd.html')
@ -934,7 +939,8 @@ def menutree(req):
bgroups = user.userg.all()
x = []
for i in bgroups:
x.extend(i.menulist)
if i.menulist:
x.extend(i.menulist)
menus = Menu.objects.exclude(menuid__in=[11, 9]).filter(menuid__in=list(set(x)), deletemark=1,type=1).order_by(
'sortnum').values('menuid', 'menucode', 'parentid', 'url', 'menuname', 'icon').distinct()
return HttpResponse(json.dumps(list(menus)), content_type="application/json")
@ -1058,7 +1064,7 @@ def addyh(req):
postdict = {
'touser': 'oPGqkweX75QtLmgehUN-ipR4hcyc',
'template_id': 'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
"miniprogram": {"appid": APPID_MP, "path": "pages/trouble/accesstrouble?troubleid="+str(a.troubleid)},
"miniprogram": {"appid": "wx5c39b569f01c27db", "path": "pages/trouble/accesstrouble?troubleid="+str(a.troubleid)},
'data': {
'first': {
'value': a.yhdj.dickeyname + '待复查:'
@ -1104,7 +1110,7 @@ def addyh(req):
postdict = {
'touser': 'oPGqkweX75QtLmgehUN-ipR4hcyc',
'template_id': 'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
"miniprogram": {"appid": APPID_MP, "path": "pages/trouble/accesstrouble?troubleid="+str(a.troubleid)},
"miniprogram": {"appid": "wx5c39b569f01c27db", "path": "pages/trouble/accesstrouble?troubleid="+str(a.troubleid)},
'data': {
'first': {
@ -1155,7 +1161,7 @@ def addyh(req):
postdict = {
'touser': 'oPGqkweX75QtLmgehUN-ipR4hcyc',
'template_id': 'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
"miniprogram": {"appid": APPID_MP, "path": "pages/trouble/accesstrouble?troubleid="+str(a.troubleid)},
"miniprogram": {"appid": "wx5c39b569f01c27db", "path": "pages/trouble/accesstrouble?troubleid="+str(a.troubleid)},
'data': {
'first': {
@ -1199,7 +1205,7 @@ def addyh(req):
postdict = {
'touser': 'oPGqkweX75QtLmgehUN-ipR4hcyc',
'template_id': 'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
"miniprogram": {"appid": APPID_MP, "path": "pages/trouble/accesstrouble?troubleid="+str(a.troubleid)},
"miniprogram": {"appid": "wx5c39b569f01c27db", "path": "pages/trouble/accesstrouble?troubleid="+str(a.troubleid)},
'data': {
'first': {
@ -1236,7 +1242,7 @@ def addyh(req):
postdict = {
'touser': 'oPGqkweX75QtLmgehUN-ipR4hcyc',
'template_id': 'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
"miniprogram": {"appid": APPID_MP, "path": "pages/trouble/accesstrouble?troubleid="+str(a.troubleid)},
"miniprogram": {"appid": "wx5c39b569f01c27db", "path": "pages/trouble/accesstrouble?troubleid="+str(a.troubleid)},
'data': {
'first': {
@ -1308,7 +1314,7 @@ def accessyh(req):
postdict = {
'touser': 'oPGqkweX75QtLmgehUN-ipR4hcyc',
'template_id': 'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
"miniprogram": {"appid": APPID_MP, "path": "pages/trouble/accesstrouble?troubleid="+str(a.troubleid)},
"miniprogram": {"appid": "wx5c39b569f01c27db", "path": "pages/trouble/accesstrouble?troubleid="+str(a.troubleid)},
'data': {
'first': {'value': a.yhdj.dickeyname + '待整改:'},
'keyword1': {'value': a.yhms},
@ -1393,7 +1399,7 @@ def accessyh(req):
postdict = {
'touser': 'oPGqkweX75QtLmgehUN-ipR4hcyc',
'template_id': 'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
"miniprogram": {"appid": APPID_MP, "path": "pages/trouble/accesstrouble?troubleid="+str(a.troubleid)},
"miniprogram": {"appid": "wx5c39b569f01c27db", "path": "pages/trouble/accesstrouble?troubleid="+str(a.troubleid)},
'data': {
'first': {'value': a.yhdj.dickeyname + '待整改:'},
'keyword1': {'value': a.yhms},
@ -1431,7 +1437,7 @@ def accessyh(req):
postdict = {
'touser': 'oPGqkweX75QtLmgehUN-ipR4hcyc',
'template_id': 'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
"miniprogram": {"appid": APPID_MP, "path": "pages/trouble/accesstrouble?troubleid="+str(a.troubleid)},
"miniprogram": {"appid": "wx5c39b569f01c27db", "path": "pages/trouble/accesstrouble?troubleid="+str(a.troubleid)},
'data': {
'first': {'value': a.yhdj.dickeyname + '未被采纳:'},
'keyword1': {'value': a.yhms},
@ -1456,7 +1462,7 @@ def accessyh(req):
postdict = {
'touser': 'oPGqkweX75QtLmgehUN-ipR4hcyc',
'template_id': 'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
"miniprogram": {"appid": APPID_MP, "path": "pages/trouble/accesstrouble?troubleid="+str(a.troubleid)},
"miniprogram": {"appid": "wx5c39b569f01c27db", "path": "pages/trouble/accesstrouble?troubleid="+str(a.troubleid)},
'data': {
'first': {'value': a.yhdj.dickeyname + '被退回需重新上报:'},
'keyword1': {'value': a.yhms},
@ -1482,7 +1488,7 @@ def accessyh(req):
postdict = {
'touser': 'oPGqkweX75QtLmgehUN-ipR4hcyc',
'template_id': 'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
"miniprogram": {"appid": APPID_MP, "path": "pages/trouble/accesstrouble?troubleid="+str(a.troubleid)},
"miniprogram": {"appid": "wx5c39b569f01c27db", "path": "pages/trouble/accesstrouble?troubleid="+str(a.troubleid)},
'data': {
'first': {'value': a.yhdj.dickeyname + '待评估:'},
'keyword1': {'value': a.yhms},
@ -1526,7 +1532,7 @@ def accessyh(req):
postdict = {
'touser': 'oPGqkweX75QtLmgehUN-ipR4hcyc',
'template_id': 'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
"miniprogram": {"appid": APPID_MP, "path": "pages/trouble/accesstrouble?troubleid="+str(a.troubleid)},
"miniprogram": {"appid": "wx5c39b569f01c27db", "path": "pages/trouble/accesstrouble?troubleid="+str(a.troubleid)},
'data': {
'first': {'value': a.yhdj.dickeyname + '待整改:'},
'keyword1': {'value': a.yhms},
@ -1568,7 +1574,7 @@ def accessyh(req):
postdict = {
'touser': 'oPGqkweX75QtLmgehUN-ipR4hcyc',
'template_id': 'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
"miniprogram": {"appid": APPID_MP, "path": "pages/trouble/accesstrouble?troubleid="+str(a.troubleid)},
"miniprogram": {"appid": "wx5c39b569f01c27db", "path": "pages/trouble/accesstrouble?troubleid="+str(a.troubleid)},
'data': {
'first': {'value': a.yhdj.dickeyname + '待整改:'},
'keyword1': {'value': a.yhms},
@ -1593,7 +1599,7 @@ def accessyh(req):
postdict = {
'touser': 'oPGqkweX75QtLmgehUN-ipR4hcyc',
'template_id': 'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
"miniprogram": {"appid": APPID_MP, "path": "pages/trouble/accesstrouble?troubleid="+str(a.troubleid)},
"miniprogram": {"appid": "wx5c39b569f01c27db", "path": "pages/trouble/accesstrouble?troubleid="+str(a.troubleid)},
'data': {
'first': {'value': a.yhdj.dickeyname + '待整改:'},
'keyword1': {'value': a.yhms},
@ -1616,7 +1622,7 @@ def accessyh(req):
postdict = {
'touser': 'oPGqkweX75QtLmgehUN-ipR4hcyc',
'template_id': 'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
"miniprogram": {"appid": APPID_MP, "path": "pages/trouble/accesstrouble?troubleid="+str(a.troubleid)},
"miniprogram": {"appid": "wx5c39b569f01c27db", "path": "pages/trouble/accesstrouble?troubleid="+str(a.troubleid)},
'data': {
'first': {
@ -1652,7 +1658,7 @@ def accessyh(req):
postdict = {
'touser': 'oPGqkweX75QtLmgehUN-ipR4hcyc',
'template_id': 'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
"miniprogram": {"appid": APPID_MP, "path": "pages/trouble/accesstrouble?troubleid="+str(a.troubleid)},
"miniprogram": {"appid": "wx5c39b569f01c27db", "path": "pages/trouble/accesstrouble?troubleid="+str(a.troubleid)},
'data': {
'first': {'value': a.yhdj.dickeyname + '待整改:'},
'keyword1': {'value': a.yhms},
@ -1765,7 +1771,7 @@ def addtrain(req):
a.material = req.POST.get('upfile')
a.save()
a.checkqr = makeqr_train(
'https://cbma.ctc-gz.com/miniprogram/checktrain?trainid='+str(a.trainid))
'https://safeyun.ctcshe.com/miniprogram/checktrain?trainid='+str(a.trainid))
a.save()
plist = req.POST.getlist('trainpart')
ustr = req.POST.get('participant')
@ -2051,7 +2057,10 @@ def troublehandle(req):
a = a.filter(Q(zgbm__in=parts) | Q(fxbm__in=parts, zgbm=None))
if fxrname:
a = a.filter(fxr__name=fxrname)
res = exportxlsx('yh', a)
if req.GET.get('nopic', None):
res = exportxlsx('yh', a, 0)
else:
res = exportxlsx('yh', a)
return res
elif a == 'del':
userid = req.session['userid']
@ -2099,6 +2108,7 @@ def troublehandle(req):
yhpg = req.GET.get('yhpg')
fxbm = req.GET.get('fxbm')
fxr = req.GET.get('fxr')
zgr = req.GET.get('zgr')
qssj = req.GET.get('qssj')
jssj = req.GET.get('jssj')
yhqy = req.GET.get('yhqy')
@ -2117,6 +2127,8 @@ def troublehandle(req):
a = a.filter(jclx__dickeyid=jclx)
if yhpg:
a = a.filter(yhpg__dickeyid=yhpg)
if zgr:
a = a.filter(zgr__userid=zgr)
if fxbm or fxr:
if fxr:
a = a.filter(fxr__userid=fxr)
@ -2796,7 +2808,8 @@ def userhandle(req):
a.username = req.POST.get('username')
a.password = req.POST.get('password')
a.epassword = make_password(req.POST.get('password'))
a.ubelongpart = Partment.objects.get(partid=req.POST.get('ubelongpart'))
a.ubelongpart = Partment.objects.get(
partid=req.POST.get('ubelongpart'))
a.save()
companyid = getcompany(a.userid)
a.usecomp = Partment.objects.get(partid=companyid)
@ -3197,6 +3210,24 @@ def pxhandle(req):
companyid = getcompany(userid)
a = Train.objects.filter(usecomp=Partment.objects.get(
partid=companyid), deletemark=1)
qssj = req.GET.get('qssj', None)
jssj = req.GET.get('jssj', None)
pxbm = req.GET.get('trainpart', None)
pxjb = req.GET.get('trainlevel', None)
pxnr = req.GET.get('traincontent', None)
participant = req.GET.get('participant', None)
if pxjb:
a = a.filter(trainlevel__dicid=pxjb)
if pxnr:
a = a.filter(traincontent__dickeyid=pxnr)
if pxbm:
a = a.filter(trainpart__partid=pxbm)
if qssj:
a = a.filter(starttime__gte=qssj)
if jssj:
a = a.filter(starttime__lte=jssj)
if participant:
a = a.filter(participant__userid=participant)
total = a.count()
startnum, endnum = fenye(req)
a = a.order_by('-starttime')[startnum:endnum].values('trainnum', 'trainid', 'state', 'trainplace', 'starttime', 'trainname',
@ -3314,6 +3345,24 @@ def ylhandle(req):
startnum, endnum = fenye(req)
a = Drill.objects.filter(usecomp=Partment.objects.get(
partid=companyid), deletemark=1).order_by('-starttime')
qssj = req.GET.get('qssj', None)
jssj = req.GET.get('jssj', None)
ylbm = req.GET.get('drillpart', None)
yljb = req.GET.get('drilllevel', None)
ylnr = req.GET.get('drillcontent', None)
participant = req.GET.get('participant', None)
if yljb:
a = a.filter(drilllevel__dicid=yljb)
if ylnr:
a = a.filter(drillcontent__dickeyid=ylnr)
if ylbm:
a = a.filter(drillpart__partid=ylbm)
if qssj:
a = a.filter(starttime__gte=qssj)
if jssj:
a = a.filter(starttime__lte=jssj)
if participant:
a = a.filter(participant__userid=participant)
total = a.count()
startnum, endnum = fenye(req)
a = a[startnum:endnum].values('drillnum', 'drillid', 'state', 'drillplace', 'starttime',
@ -3816,7 +3865,7 @@ def mplogin(req):
code = req.POST.get('code')
except:
code = json.loads(res)['code']
info = requests.get('https://api.weixin.qq.com/sns/jscode2session?appid='+APPID_MP+'&secret='+APPSECRET_MP+'&js_code=' +
info = requests.get('https://api.weixin.qq.com/sns/jscode2session?appid=wx5c39b569f01c27db&secret=68762892f8df2b4a0b1940c5250a8dc0&js_code=' +
code+'&grant_type=authorization_code').content.decode('utf-8')
info = json.loads(info)
mpopenid = info['openid']
@ -4065,8 +4114,18 @@ def apimiss(req):
startnum, endnum = fenye(req)
a = Miss.objects.filter(usecomp=Partment.objects.get(
partid=companyid), deletemark=1)
if req.GET.get('misser', None):
a = a.filter(misser__userid=req.GET.get('misser'))
if req.GET.get('missqy', None):
a = a.filter(missqy__id=req.GET.get('missqy'))
if req.GET.get('fsbm'):
parts = Partment.objects.filter(partlink__contains=','+req.GET.get(
'fsbm')+',') | Partment.objects.filter(partid=req.GET.get('fsbm'))
a = a.filter(misspart__in=parts)
if req.GET.get('qssj'):
a = a.filter(misstime__gte=req.GET.get('qssj'))
if req.GET.get('jssj'):
a = a.filter(misstime__lte=req.GET.get('jssj'))
a = a.order_by('-misstime')
total = a.count()
startnum, endnum = fenye(req)
@ -4163,6 +4222,8 @@ def apisocert(req):
companyid = getcompany(userid)
startnum, endnum = fenye(req)
a = Socertificate.objects.filter(user__usecomp__partid=companyid).order_by('id') # 无deletemark
if req.GET.get('user', None):
a = a.filter(user=req.GET.get('user'), zszt=1)
total = a.count()
startnum, endnum = fenye(req)
if req.GET.get('sort'):
@ -4371,6 +4432,8 @@ def apisafecert(req):
companyid = getcompany(userid)
startnum, endnum = fenye(req)
a = Safecert.objects.filter(user__usecomp__partid=companyid).order_by('id') # 无deletemark
if req.GET.get('user', None):
a = a.filter(user=req.GET.get('user'), zszt=1)
total = a.count()
startnum, endnum = fenye(req)
if req.GET.get('sort'):
@ -4701,6 +4764,20 @@ def apisuggest(req):
startnum, endnum = fenye(req)
a = Suggest.objects.filter(usecomp=Partment.objects.get(
partid=companyid)).order_by('-submittime')
if req.GET.get('jyr', None):
a = a.filter(jyr__userid=req.GET.get('jyr'))
if req.GET.get('clr', None):
a = a.filter(clr__userid=req.GET.get('clr'))
if req.GET.get('qssj'):
a = a.filter(submittime__gte=req.GET.get('qssj'))
if req.GET.get('jssj'):
a = a.filter(submittime__lte=req.GET.get('jssj'))
if req.GET.get('jyrname', None):
a = a.filter(jyr__name__contains=req.GET.get('jyrname'))
if req.GET.get('jybm'):
parts = Partment.objects.filter(partlink__contains=','+req.GET.get(
'jybm')+',') | Partment.objects.filter(partid=req.GET.get('jybm'))
a = a.filter(jybm__in=parts)
total = a.count()
startnum, endnum = fenye(req)
a = a[startnum:endnum].values('jyid', 'jylb__dickeyname', 'jyr__name', 'jybm__partname', 'dqxz', 'jynr',
@ -4764,6 +4841,12 @@ def apisuggest(req):
a = a.filter(submittime__gte=req.GET.get('qssj'))
if req.GET.get('jssj'):
a = a.filter(submittime__lte=req.GET.get('jssj'))
if req.GET.get('jyrname', None):
a = a.filter(jyr__name__contains=req.GET.get('jyrname'))
if req.GET.get('jybm'):
parts = Partment.objects.filter(partlink__contains=','+req.GET.get(
'jybm')+',') | Partment.objects.filter(partid=req.GET.get('jybm'))
a = a.filter(jybm__in=parts)
total = a.count()
a = a.order_by('-submittime')[startnum:endnum].values('jyid', 'jylb__dickeyname', 'jyr__name', 'jybm__partname',
'dqxz', 'jynr', 'jynum', 'jyzt', 'todouser__userid', 'todouser__name', 'jyqy__name', 'jydd', 'submittime', 'accept')
@ -4773,10 +4856,20 @@ def apisuggest(req):
companyid = getcompany(userid)
a = Suggest.objects.filter(
usecomp=Partment.objects.get(partid=companyid))
if req.GET.get('jyr', None):
a = a.filter(jyr__userid=req.GET.get('jyr'))
if req.GET.get('clr', None):
a = a.filter(clr__userid=req.GET.get('clr'))
if req.GET.get('qssj'):
a = a.filter(jyrq__gte=req.GET.get('qssj'))
a = a.filter(submittime__gte=req.GET.get('qssj'))
if req.GET.get('jssj'):
a = a.filter(jyrq__lte=req.GET.get('jssj'))
a = a.filter(submittime__lte=req.GET.get('jssj'))
if req.GET.get('jyrname', None):
a = a.filter(jyr__name__contains=req.GET.get('jyrname'))
if req.GET.get('jybm'):
parts = Partment.objects.filter(partlink__contains=','+req.GET.get(
'jybm')+',') | Partment.objects.filter(partid=req.GET.get('jybm'))
a = a.filter(jybm__in=parts)
res = exportxlsx('jy', a)
return res
elif a == 'exportword':
@ -4865,6 +4958,11 @@ def apisuggest(req):
# 特别操作
def apitool(req):
a = req.GET.get('a')
# if a == 'correctjobjctime':
# for i in Checkjob.objects.all():
# if i.jctime2 is None:
# i.jctime2 = i.endtime
# i.save()
if a == 'correctgrouptype':
for company in Partment.objects.filter(iscompany=1):
users = User.objects.filter(usecomp = company)
@ -4890,7 +4988,7 @@ def apitool(req):
elif a == 'correct_train_qr':
for i in Train.objects.all():
i.checkqr = makeqr_train(
'https://cbma.ctc-gz.com/miniprogram/checktrain?trainid='+str(i.trainid))
'https://safeyun.ctcshe.com/miniprogram/checktrain?trainid='+str(i.trainid))
i.save()
return JsonResponse({'code': 1})
elif a == 'correct_teacher':
@ -4902,19 +5000,19 @@ def apitool(req):
elif a == 'correct_riskact_qr':
for i in RiskAct.objects.all():
i.qrcode = makeqr_riskact(
'https://cbma.ctc-gz.com/miniprogram/riskact?id='+str(i.id))
'https://safeyun.ctcshe.com/miniprogram/riskact?id='+str(i.id))
i.save()
return JsonResponse({'code': 1})
elif a == 'correct_examtest_qr':
for i in ExamTest.objects.all():
i.qrcode = makeqr_examtest(
'https://cbma.ctc-gz.com/miniprogram/examtest?id='+str(i.id))
'https://safeyun.ctcshe.com/miniprogram/examtest?id='+str(i.id))
i.save()
return JsonResponse({'code': 1})
elif a == 'correct_area_qr':
for i in Area.objects.all():
i.qrcode = makeqr_area(
'https://cbma.ctc-gz.com/miniprogram/area?id='+str(i.id))
'https://safeyun.ctcshe.com/miniprogram/area?id='+str(i.id))
i.save()
return JsonResponse({'code': 1})
elif a == 'correct_risk':
@ -5183,7 +5281,7 @@ def apinotice(req):
postdict = {
'touser': '',
'template_id': 'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
"miniprogram": {"appid": APPID_MP},
"miniprogram": {"appid": "wx5c39b569f01c27db"},
'data': {
'first': {
'value': '公司通知:'
@ -5478,7 +5576,7 @@ def apioperation(req):
postdict = {
'touser': '',
'template_id': 'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
"miniprogram": {"appid": APPID_MP},
"miniprogram": {"appid": "wx5c39b569f01c27db"},
'data': {
'first': {
'value': obj.zylx.dickeyname + '作业通知:'
@ -5506,6 +5604,10 @@ def apioperation(req):
usecomp=usecomp, deletemark=1).order_by('-submittime')
if req.GET.get('zyqy', False):
a = a.filter(zyqy__id=req.GET.get('zyqy'))
if req.GET.get('zyfzr', None):
a = a.filter(zyfzr__userid=req.GET.get('zyfzr'))
if req.GET.get('zyry', None):
a = a.filter(zyry__userid=req.GET.get('zyry'))|a.filter(zyfzr__userid=req.GET.get('zyry'))
if req.GET.get('qssj', None):
a = a.filter(kssj__gte=req.GET.get('qssj'))
if req.GET.get('jssj', None):
@ -6282,6 +6384,8 @@ def apiexamtest(req):
search = req.GET.get('search', None)
starttime1 = req.GET.get('starttime1', None)
starttime2 = req.GET.get('starttime2', None)
user = req.GET.get('user', None)
user_tg = req.GET.get('user_tg', None)
if search:
a = a.filter(Q(name__contains=search)|Q(exampaper__name=search))
if starttime1:
@ -6292,6 +6396,10 @@ def apiexamtest(req):
a = a.filter(state=1)
if state == 'close':
a = a.filter(state=0)
if user:
a = a.filter(user__userid=user)
if user_tg:
a = a.filter(user__userid=user_tg, detail_examtest__passcode=1)
if owner == 'yes':
ownerlist = ExamTestDetail.objects.filter(user__userid=userid, examtest__state=1,testnum=0).values_list('examtest__id',flat=True)
a = a.filter(Q(id__in=ownerlist)|Q(ispublic=1))
@ -6343,7 +6451,7 @@ def apiexamtest(req):
obj.testnum = data['testnum']
obj.save()
obj.qrcode = makeqr_examtest(
'https://cbma.ctc-gz.com/miniprogram/examtest?id='+str(obj.id))
'https://safeyun.ctcshe.com/miniprogram/examtest?id='+str(obj.id))
obj.save()
if 'participant' in data and data['participant']:
ksry = data['participant'].split(',')
@ -6356,7 +6464,7 @@ def apiexamtest(req):
postdict = {
'touser': '',
'template_id': 'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
"miniprogram": {"appid": APPID_MP, "path": "pages/examtest/index"},
"miniprogram": {"appid": "wx5c39b569f01c27db", "path": "pages/examtest/index"},
'data': {
'first': {
'value': '小程序考试通知:'
@ -6441,7 +6549,7 @@ def apiexamtest(req):
obj.testnum = data['testnum']
obj.save()
obj.qrcode = makeqr_examtest(
'https://cbma.ctc-gz.com/miniprogram/examtest?id='+str(obj.id))
'https://safeyun.ctcshe.com/miniprogram/examtest?id='+str(obj.id))
obj.save()
if 'participant' in data and data['participant']:
ksry = data['participant'].split(',')
@ -6454,7 +6562,7 @@ def apiexamtest(req):
postdict = {
'touser': '',
'template_id': 'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
"miniprogram": {"appid": APPID_MP, "path": "pages/examtest/index"},
"miniprogram": {"appid": "wx5c39b569f01c27db", "path": "pages/examtest/index"},
'data': {
'first': {
'value': '小程序考试通知:'
@ -6710,11 +6818,7 @@ def apiexamtestrate(req):
companyid = req.GET.get('companyid')
alltest = ExamTest.objects.filter(usecomps__contains=','+str(companyid)+',').exclude(nousecomps__contains=','+str(companyid)+',')
allexamtestdetail = ExamTestDetail.objects.filter(examtest__in=alltest,testnum__gte=1)
objs = allexamtestdetail.values('user__userid','user__name','user__headimgurl','user__ubelongpart__partname').annotate(totalscore=Sum('score'),totaltook=Sum('took'),testnum=Count('user__userid'), maxscore = Max('score'))
# if req.GET.get('type', None) == 'max':
objs = objs.order_by('-maxscore','testnum', '-totalscore')
# else:
# objs = objs.order_by('-totalscore','totaltook')
objs = allexamtestdetail.values('user__userid','user__name','user__headimgurl','user__ubelongpart__partname').annotate(totalscore=Sum('score'),totaltook=Sum('took'),testnum=Count('user__userid')).order_by('-totalscore','totaltook')
total = objs.count()
objslist = list(objs)
for i in objslist:
@ -6730,35 +6834,35 @@ def apiexamtestrate(req):
i['avgscore'] = round(i['avgscore'],1)
with open('ratedata.dat','wb') as f:
pickle.dump({'total':total,'rows':objslist,'rows2':orgsCallist,'updatetime':datetime.now().strftime('%Y-%m-%d %H:%M')},f)
# from openpyxl import Workbook, load_workbook
# wb = load_workbook('e:/个人总排名.xlsx')
# sheet = wb.active
# for i in objslist:
# num = str(objslist.index(i)+3)
# sheet['a'+num] = i['user__name']
# sheet['b'+num] = i['user__ubelongpart__partname']
# sheet['c'+num] = i['testnum']
# sheet['d'+num] = i['totalscore']
# sheet['e'+num] = convertseconds(i['totaltook'])
# nowtime = datetime.now().strftime('%Y%m%d')
# sheet['b1'] = nowtime
# filename = '个人总排名' + nowtime
# filepath = 'e:/' + filename +'.xlsx'
# wb.save(filepath)
from openpyxl import Workbook, load_workbook
wb = load_workbook('e:/个人总排名.xlsx')
sheet = wb.active
for i in objslist:
num = str(objslist.index(i)+3)
sheet['a'+num] = i['user__name']
sheet['b'+num] = i['user__ubelongpart__partname']
sheet['c'+num] = i['testnum']
sheet['d'+num] = i['totalscore']
sheet['e'+num] = convertseconds(i['totaltook'])
nowtime = datetime.now().strftime('%Y%m%d')
sheet['b1'] = nowtime
filename = '个人总排名' + nowtime
filepath = 'e:/' + filename +'.xlsx'
wb.save(filepath)
# wb2 = load_workbook('e:/机构总排名.xlsx')
# sheet = wb2.active
# for i in orgsCallist:
# num = str(orgsCallist.index(i)+3)
# sheet['a'+num] = i['user__ubelongpart__partname']
# sheet['b'+num] = i['totaluser']
# sheet['c'+num] = i['totaltest']
# sheet['d'+num] = i['avgscore']
# nowtime = datetime.now().strftime('%Y%m%d')
# sheet['b1'] = nowtime
# filename = '机构总排名' + nowtime
# filepath = 'e:/' + filename +'.xlsx'
# wb2.save(filepath)
wb2 = load_workbook('e:/机构总排名.xlsx')
sheet = wb2.active
for i in orgsCallist:
num = str(orgsCallist.index(i)+3)
sheet['a'+num] = i['user__ubelongpart__partname']
sheet['b'+num] = i['totaluser']
sheet['c'+num] = i['totaltest']
sheet['d'+num] = i['avgscore']
nowtime = datetime.now().strftime('%Y%m%d')
sheet['b1'] = nowtime
filename = '机构总排名' + nowtime
filepath = 'e:/' + filename +'.xlsx'
wb2.save(filepath)
return JsonResponse({"code": 1})
@ -6942,7 +7046,7 @@ def apiarea(req):
obj = Area.objects.create(name=name, order=order, belongmap=Map.objects.get(
id=map), usecomp=Partment.objects.get(partid=companyid))
makeqr_area(
'https://cbma.ctc-gz.com/miniprogram/area?id='+str(obj.id))
'https://safeyun.ctcshe.com/miniprogram/area?id='+str(obj.id))
return JsonResponse({"code": 1})
elif a == 'del':
if User.objects.get(userid=userid).issuper == 1:
@ -7055,7 +7159,7 @@ def apiequipment(req):
obj.usecomp = Partment.objects.get(partid=companyid)
obj.save()
obj.qrcode = makeqr(
'https://cbma.ctc-gz.com/miniprogram/equipment?id='+str(obj.id))
'https://safeyun.ctcshe.com/miniprogram/equipment?id='+str(obj.id))
obj.save()
return JsonResponse({"code": 1})
elif a == 'del':
@ -7085,6 +7189,28 @@ def apiinspect(req):
companyid = getcompany(userid)
if a == 'listall':
a = Inspect.objects.filter(usecomp__partid=companyid)
qssj = req.GET.get('qssj')
jssj = req.GET.get('jssj')
xjbm = req.GET.get('xjbm')
xjr = req.GET.get('xjr')
state = req.GET.get('state')
if xjbm or xjr:
if xjr:
a = a.filter(user__userid=xjr)
else:
parts = Partment.objects.filter(partid=xjbm) | Partment.objects.filter(
partlink__contains=','+xjbm+',')
a = a.filter(user__ubelongpart__in=parts)
if req.GET.get('xjr_0'):
a = a.filter(user__userid=req.GET.get('xjr_0'), state=0)
if qssj:
a = a.filter(creattime__gte=qssj)
if jssj:
a = a.filter(creattime__lte=jssj)
if state:
a = a.filter(state=state)
if req.GET.get('num', None):
a = a.filter(equipment__num__contains = req.GET.get('num'))
total = a.count()
startnum, endnum = fenye(req)
a = a.order_by('-id')[startnum:endnum].values('id', 'state', 'content', 'creattime', 'equipment__num', 'equipment__name',
@ -7287,10 +7413,16 @@ def apiinspectitem(req):
objs = objs.filter(inspect__creattime__gte=req.GET.get("qssj"))
if req.GET.get("jssj", None):
objs = objs.filter(inspect__creattime__lte=req.GET.get("jssj"))
if req.GET.get("qssjx", None):
objs = objs.filter(handletime__gte=req.GET.get("qssjx"))
if req.GET.get("jssjx", None):
objs = objs.filter(handletime__lte=req.GET.get("jssjx"))
# xjbm = req.GET.get('xjbm',None)
xjr = req.GET.get('xjr',None)
if xjr:
objs = objs.filter(inspect__user__name__contains=xjr)
if req.GET.get('todouser_0', None):
objs = objs.filter(todouser__userid=req.GET.get('todouser_0'), state='异常已处理')
# if xjbm or xjr:
# if xjr:
# objs = objs.filter(inspect__user__userid=xjr)
@ -7393,7 +7525,7 @@ def apiriskact(req):
obj.kind = data['kind']
obj.save()
obj.qrcode = makeqr_riskact(
'https://cbma.ctc-gz.com/miniprogram/riskact?id='+str(obj.id))
'https://safeyun.ctcshe.com/miniprogram/riskact?id='+str(obj.id))
obj.save()
return JsonResponse({'code': 1})
elif a == 'edit':
@ -8556,7 +8688,7 @@ def checkprojects(req):
total = a.count()
startnum, endnum = fenye(req)
a = a.order_by('-starttime')[startnum:endnum].values('id','checkname__name','checktask__checktaskname','jobstate','starttime','endtime','yanshou','checkquestion','zguser__username','zgtime','checktask__checktype__checktitle','checkname__username', 'taskstate','checktask__checktime','createuser__username','createdate')
a = a.order_by('-starttime')[startnum:endnum].values('id','checkname__name','checktask__checktaskname','jobstate','starttime','endtime','yanshou', 'yanshouren__name', 'checkquestion','zguser__username','zgtime','checktask__checktype__checktitle','checkname__username', 'taskstate','checktask__checktime','createuser__username','createdate')
return HttpResponse(transjson(total, a), content_type="application/json")
elif a == 'wxlistall':
@ -8586,7 +8718,7 @@ def checkprojects(req):
elif a == 'jobdetail':
obj = Checkjob.objects.filter(id=req.GET.get('id'))
obj = obj.values('checktask__checktaskname','zguser','yhtp','content','jctime','zgtime','checkname__name','zgjg','jobstate','taskstate','checkquestion','checktask__checkplace','checktask__checktype__checkcontent','checkname__username','checktask__checktime')[0]
obj = obj.values('checktask__checktaskname','zguser','yhtp','content','jctime','zgtime','checkname__name','zgjg','jobstate','taskstate','checkquestion','checktask__checkplace','checktask__checktype__checkcontent','checkname__username','checktask__checktime', 'jctime2')[0]
if obj['yhtp']:
obj['yhtp'] = obj['yhtp'].split('?')
@ -8604,8 +8736,9 @@ def checkprojects(req):
obj.taskstate =int(data['taskstate'])
obj.createuser = User.objects.get(userid=userid)
obj.content=data['content']
obj.jctime=datetime.now()
obj.zgtime=datetime.now()
obj.jctime = data['jctime'] if data.get('jctime', None) else obj.starttime
obj.jctime2 = data['jctime2'] if data.get('jctime2', None) else obj.endtime
obj.zgtime = data['zgtime'] if data.get('zgtime', None) else None
if yhtp:
obj.yhtp=yhtp
obj.zghtp=zghtp
@ -8619,7 +8752,7 @@ def checkprojects(req):
postdict = {
'touser': '',
'template_id': 'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
"miniprogram": {"appid": APPID_MP},
"miniprogram": {"appid": "wx5c39b569f01c27db"},
'data': {
'first': {
'value': '处罚通知:'
@ -8649,6 +8782,10 @@ def checkprojects(req):
elif a == 'yanshou':
obj = Checkjob.objects.get(id=req.GET.get('id'))
if obj.yanshou:
return JsonResponse({'code': 0, 'msg':'任务已验收'})
if obj.taskstate !=2:
return JsonResponse({'code': 0, 'msg':'任务状态有误'})
obj.yanshou = datetime.now()
obj.yanshouren = User.objects.get(userid=userid)
obj.save()
@ -8706,7 +8843,7 @@ def checkprojects(req):
postdict = {
'touser': '',
'template_id': 'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
"miniprogram": {"appid": APPID_MP},
"miniprogram": {"appid": "wx5c39b569f01c27db"},
'data': {
'first': {
'value': '检查任务通知:'
@ -8767,7 +8904,7 @@ def checkprojects(req):
postdict = {
'touser': '',
'template_id': 'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
"miniprogram": {"appid": APPID_MP},
"miniprogram": {"appid": "wx5c39b569f01c27db"},
'data': {
'first': {
'value': '检查任务通知:'
@ -8848,7 +8985,7 @@ def checkprojects(req):
uselist.append(item.name)
x = a.values('checktask__checktaskname','starttime','zgjg','checktask__tasktype','endtime','jobstate','zguser__username','checktask__checktype__checkcontent','checktask__checkplace','checktask__checktime' ,'checkname__username','checkname__name', 'checkquestion', 'zgtime', 'zguser__username', 'createuser__username',
'createdate', 'taskstate','zghtp','jctime','content','yhtp','pmpeople', 'zgyq','zgjg', 'yanshou', 'yanshouren__name')[0]
'createdate', 'taskstate','zghtp','content','yhtp','pmpeople', 'zgyq','zgjg', 'yanshou', 'yanshouren__name', 'jctime', 'jctime2')[0]
x['bcfr'] = uselist
if x['yhtp']:
x['yhtp'] = x['yhtp'].split('?')
@ -8983,7 +9120,7 @@ def apisafelist(req):
obj.name = data['name']
obj.save()
obj.qrcode = makeqr_safelist(
'https://cbma.ctc-gz.com/miniprogram/safelist?id='+str(obj.id))
'https://safeyun.ctcshe.com/miniprogram/safelist?id='+str(obj.id))
obj.save()
return JsonResponse({"code":1})
elif a == 'edit':
@ -9102,4 +9239,34 @@ def apisafefeedback(req):
data = json.loads(req.body.decode('utf-8'))
obj = SafeFeedBack.objects.get(id=data['id'])
obj.delete()
return JsonResponse({"code":1})
return JsonResponse({"code":1})
@apicheck_login
def apicontingencyplan(req):
a = req.GET.get('a')
userid = req.session['userid']
user= User.objects.get(userid=userid)
if a == 'listall':
objs = ContingencyPlan.objects.filter(usecomp=user.usecomp, deletemark=1)
if req.GET.get('type', None):
objs = objs.filter(type=req.GET.get('type'))
total = objs.count()
startnum, endnum = fenye(req)
objs = objs[startnum:endnum].values('id', 'name', 'path', 'createtime', 'type', 'createby__name', 'path')
return HttpResponse(transjson(total, objs), content_type="application/json")
elif a == 'add':
data = json.loads(req.body.decode('utf-8'))
obj= ContingencyPlan()
obj.name = data['name']
obj.type = data['type']
obj.path = data['path']
obj.createby = user
obj.save()
return JsonResponse({"code":1})
elif a == 'del':
data = json.loads(req.body.decode('utf-8'))
obj = ContingencyPlan.objects.get(id=data['id'])
obj.delete()
return JsonResponse({"code":1})