gridtaskset
This commit is contained in:
parent
32887443f8
commit
81783317e7
|
@ -1 +1 @@
|
|||
25112
|
||||
12524
|
||||
|
|
|
@ -24,37 +24,37 @@ def debug_task(self):
|
|||
print('Request: {0!r}'.format(self.request))
|
||||
|
||||
app.conf.update(
|
||||
CELERYBEAT_SCHEDULE = {
|
||||
'yc-task': {
|
||||
'task': 'safesite.tasks.ycjs',
|
||||
# CELERYBEAT_SCHEDULE = {
|
||||
# 'yc-task': {
|
||||
# 'task': 'safesite.tasks.ycjs',
|
||||
# #'schedule': crontab(hour=4, minute=30, day_of_week=1),
|
||||
# #'schedule': timedelta(seconds=20),
|
||||
# #'schedule': crontab(minute=00,hour=1,day_of_month=1),
|
||||
# 'schedule': crontab(minute=2),
|
||||
# #'args': (5, 6)
|
||||
# },
|
||||
# # 'grid-task': {
|
||||
# # 'task': 'safesite.tasks.gridtasksend',
|
||||
# # 'schedule': timedelta(minutes=1),
|
||||
# # #'args': (5, 6)
|
||||
# # },
|
||||
# # 'riskact-task': {
|
||||
# # 'task': 'safesite.tasks.riskacttask',
|
||||
# # 'schedule': timedelta(minutes=1),
|
||||
# # #'args': (5, 6)
|
||||
# # },
|
||||
# 'check-task': {
|
||||
# 'task': 'safesite.tasks.checktask',
|
||||
# 'schedule': timedelta(minutes=1),
|
||||
# #'args': (5, 6)
|
||||
# },
|
||||
# 'updatetzzs-task':{
|
||||
# 'task': 'safesite.tasks.updateTzzs',
|
||||
# 'schedule': crontab(hour=4, minute=30, day_of_week=1),
|
||||
#'schedule': timedelta(seconds=20),
|
||||
#'schedule': crontab(minute=00,hour=1,day_of_month=1),
|
||||
'schedule': crontab(minute=2),
|
||||
#'args': (5, 6)
|
||||
},
|
||||
# 'grid-task': {
|
||||
# 'task': 'safesite.tasks.gridtasksend',
|
||||
# 'schedule': timedelta(minutes=1),
|
||||
# #'args': (5, 6)
|
||||
# },
|
||||
# 'riskact-task': {
|
||||
# 'task': 'safesite.tasks.riskacttask',
|
||||
# 'schedule': timedelta(minutes=1),
|
||||
# #'args': (5, 6)
|
||||
# 'updateaqzs-task':{
|
||||
# 'task': 'safesite.tasks.updateAqzs',
|
||||
# 'schedule': crontab(hour=4, minute=30, day_of_week=1),
|
||||
# },
|
||||
'check-task': {
|
||||
'task': 'safesite.tasks.checktask',
|
||||
'schedule': timedelta(minutes=1),
|
||||
#'args': (5, 6)
|
||||
},
|
||||
'updatetzzs-task':{
|
||||
'task': 'safesite.tasks.updateTzzs',
|
||||
'schedule': crontab(hour=4, minute=30, day_of_week=1),
|
||||
},
|
||||
'updateaqzs-task':{
|
||||
'task': 'safesite.tasks.updateAqzs',
|
||||
'schedule': crontab(hour=4, minute=30, day_of_week=1),
|
||||
},
|
||||
}
|
||||
# }
|
||||
)
|
|
@ -147,7 +147,7 @@ CELERY_BROKER_URL = 'redis://127.0.0.1:6379/0'
|
|||
CELERY_BROKER_TRANSPORT = 'redis'
|
||||
CELERYD_MAX_TASKS_PER_CHILD = 10
|
||||
CELERY_TIMEZONE='Asia/Shanghai'
|
||||
# CELERY_ENABLE_UTC=True
|
||||
CELERY_ENABLE_UTC = False
|
||||
DJANGO_CELERY_BEAT_TZ_AWARE = False
|
||||
CELERY_BEAT_SCHEDULER = 'django_celery_beat.schedulers:DatabaseScheduler'
|
||||
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
# Generated by Django 2.2.8 on 2020-09-09 10:48
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('safesite', '0356_auto_20200908_1646'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
# migrations.RemoveField(
|
||||
# model_name='companyinfo',
|
||||
# name='liaison_fax',
|
||||
# ),
|
||||
migrations.RemoveField(
|
||||
model_name='myschedule',
|
||||
name='deletemark',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='gridtaskset',
|
||||
name='count',
|
||||
field=models.IntegerField(default=0, verbose_name='派发次数'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='gridtaskset',
|
||||
name='last_run_at',
|
||||
field=models.DateTimeField(blank=True, null=True, verbose_name='最近派发时间'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='gridtaskset',
|
||||
name='expire',
|
||||
field=models.IntegerField(blank=True, null=True, verbose_name='执行有效期'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='gridtaskset',
|
||||
name='myschedule',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='safesite.MySchedule'),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,21 @@
|
|||
# Generated by Django 2.2.8 on 2020-09-09 13:15
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('safesite', '0357_auto_20200909_1048'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
# migrations.RemoveField(
|
||||
# model_name='companyinfo',
|
||||
# name='liaison_fax',
|
||||
# ),
|
||||
migrations.RemoveField(
|
||||
model_name='gridtaskset',
|
||||
name='start_time',
|
||||
),
|
||||
]
|
|
@ -1046,7 +1046,6 @@ from django_celery_beat.models import PeriodicTask, IntervalSchedule, CrontabSch
|
|||
class MySchedule(models.Model):
|
||||
name = models.CharField('名称', max_length=1000)
|
||||
typeset = models.CharField('类型', default=1,max_length=10)
|
||||
deletemark = models.IntegerField(default=1)
|
||||
interval = models.ForeignKey(IntervalSchedule, null=True, blank=True, on_delete=models.SET_NULL)
|
||||
crontab = models.ForeignKey(CrontabSchedule, null=True, blank=True, on_delete=models.SET_NULL)
|
||||
usecomp = models.ForeignKey(
|
||||
|
@ -1060,9 +1059,10 @@ class GridTaskSet(models.Model):
|
|||
gridlevel = models.ForeignKey(Dickey, on_delete=models.CASCADE, verbose_name='网格化层级')
|
||||
user = models.ForeignKey(User,on_delete=models.CASCADE,verbose_name='执行人')
|
||||
note = models.TextField('检查备注', null=True)
|
||||
myschedule = models.ForeignKey(MySchedule,on_delete=models.CASCADE)
|
||||
start_time = models.DateTimeField('开始派发时间', null=True, blank=True)
|
||||
expire = models.IntegerField('派发有效期', null=True, blank=True)
|
||||
myschedule = models.ForeignKey(MySchedule,on_delete=models.SET_NULL, null=True, blank=True)
|
||||
expire = models.IntegerField('执行有效期', null=True, blank=True)
|
||||
count = models.IntegerField('派发次数', default=0)
|
||||
last_run_at = models.DateTimeField('最近派发时间', null=True, blank=True)
|
||||
periodictask = models.ForeignKey(PeriodicTask, on_delete=models.CASCADE, related_name='gridtaskset_periodictask')
|
||||
|
||||
class RiskActTask(models.Model): # 风险点排查执行记录
|
||||
|
|
|
@ -318,6 +318,13 @@ def sendGridtask2(**kwargs):
|
|||
RiskActTask.objects.create(riskact=obj.riskact,taskexpire = newm,taskadd=nowtime,istask=1,taskset=obj,tasknote=obj.note,user=obj.user)
|
||||
else:
|
||||
RiskActTask.objects.create(riskact=obj.riskact,taskadd=nowtime,istask=1,taskset=obj,tasknote=obj.note,user=obj.user)
|
||||
obj.last_run_at = nowtime
|
||||
obj.count = obj.count+1
|
||||
obj.save()
|
||||
|
||||
@shared_task
|
||||
def expireRiskacttask():
|
||||
RiskActTask.objects.filter(taskexpire__lte = datetime.datetime.now(), usable=1).update(usable=0)
|
||||
|
||||
@shared_task
|
||||
def checktask():
|
||||
|
|
|
@ -105,15 +105,14 @@
|
|||
{ field: 'id', title: 'ID', hidden: true },
|
||||
{ field: 'gridlevel__dickeyname', title: '网格层级', width: 100 },
|
||||
{ field: 'user__name', title: '执行人', width: 100 },
|
||||
{ field: 'myschedule__name', title: '任务策略', width: 100 ,
|
||||
{ field: 'myschedule__name', title: '任务策略', width: 200 ,
|
||||
// formatter: function (value, row, index) {
|
||||
// if(value.hasOwnProperty('interval')){
|
||||
// return value.interval.replace(',hours', '小时').replace(',days', '天').replace(',weeks', '星期').replace(',months', '月').replace(',years', '年').replace(',seconds', '秒')
|
||||
// }
|
||||
// }
|
||||
},
|
||||
{ field: 'periodictask__start_time', title: '开始派发时间', width: 150 },
|
||||
{ field: 'periodictask__last_run_at', title: '最近派发时间', width: 150 },
|
||||
{ field: 'last_run_at', title: '最近派发时间', width: 150 },
|
||||
{ field: 'periodictask__enabled', title: '派发状态', width: 100,
|
||||
formatter: function (value, row, index) {
|
||||
switch (value) {
|
||||
|
@ -128,7 +127,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
{ field: 'periodictask__total_run_count', title: '已派发次数', width: 100 },
|
||||
{ field: 'count', title: '已派发次数', width: 100 },
|
||||
{ field: 'note', title: '执行备注', width: 100 },
|
||||
]],
|
||||
});
|
||||
|
|
|
@ -24,12 +24,6 @@
|
|||
<div style="margin-bottom:5px">
|
||||
<input id="note" name="note" class="easyui-textbox" style="width:480px;height:80px" data-options="label:'检查备注',multiline:true,">
|
||||
</div>
|
||||
<div style="margin-bottom:5px;">
|
||||
<label style='display:inline-block;'>开始派发时间</label>
|
||||
<input id="start_time" name="start_time" class="easyui-datetimebox" style="width:auto"
|
||||
data-options="currentText:'今天',closeText:'关闭',showSeconds:false" required=true />
|
||||
|
||||
</div>
|
||||
<div style="margin-bottom:10px">
|
||||
<input id="myschedule" class="easyui-combobox" name="myschedule" style="width:480px" data-options="
|
||||
label:'策略',
|
||||
|
@ -39,7 +33,7 @@
|
|||
required=true>
|
||||
</div>
|
||||
<div style="margin-bottom:10px">
|
||||
<input id="expire" name="expire" type="text" class="easyui-numberbox" value="8" data-options="label:'有效期(小时)'"/>
|
||||
<input id="expire" name="expire" type="text" class="easyui-numberbox" data-options="label:'有效期(小时)'"/>
|
||||
</div>
|
||||
<!-- <div style="margin-bottom:5px">
|
||||
<label style='display:inline-block;'>定时配置</label>
|
||||
|
|
|
@ -24,12 +24,6 @@
|
|||
<div style="margin-bottom:5px">
|
||||
<input id="note" name="note" class="easyui-textbox" style="width:480px;height:80px" data-options="label:'检查备注',multiline:true,">
|
||||
</div>
|
||||
<div style="margin-bottom:5px;">
|
||||
<label style='display:inline-block;'>开始派发时间</label>
|
||||
<input id="start_time" editable="false" name="start_time" class="easyui-datetimebox" style="width:auto"
|
||||
data-options="currentText:'今天',closeText:'关闭',showSeconds:false" required=true />
|
||||
|
||||
</div>
|
||||
<div style="margin-bottom:10px">
|
||||
<input id="myschedule" class="easyui-combobox" name="myschedule" style="width:480px" data-options="
|
||||
label:'策略',
|
||||
|
@ -39,7 +33,7 @@
|
|||
required=true>
|
||||
</div>
|
||||
<div style="margin-bottom:10px">
|
||||
<input id="expire" name="expire" type="text" class="easyui-numberbox" value="8" data-options="label:'有效期(小时)'"/>
|
||||
<input id="expire" name="expire" type="text" class="easyui-numberbox" data-options="label:'有效期(小时)'" />
|
||||
</div>
|
||||
<!-- <div style="margin-bottom:5px">
|
||||
<label style='display:inline-block;'>定时配置</label>
|
||||
|
@ -64,6 +58,7 @@
|
|||
$('#username').textbox('setValue',data.user__name)
|
||||
$('#user').val(data.user__userid)
|
||||
$('#note').textbox('setValue',data.note)
|
||||
$('#expire').numberbox('setValue',data.expire)
|
||||
$('#myschedule').combobox('setValue',data.myschedule__id)
|
||||
$('#start_time').datetimebox('setValue', data.periodictask__start_time)
|
||||
// if(data.schedule.hasOwnProperty('interval')){
|
||||
|
|
|
@ -51,10 +51,12 @@
|
|||
border:false,
|
||||
columns: [[
|
||||
{ field: 'id', title: 'ID', hidden: true },
|
||||
{ field: 'user__ubelongpart__partname', title: '排查部门', width: 150 },
|
||||
{ field: 'riskact__name', title: '风险点', width: 100 },
|
||||
{ field: 'riskact__area__name', title: '所属区域', width: 80 },
|
||||
{ field: 'user__ubelongpart__partname', title: '排查部门', width: 100 },
|
||||
{ field: 'user__name', title: '排查人', width: 80 },
|
||||
{ field: 'taskdo', title: '排查时间', width: 80 },
|
||||
{ field: 'state', title: '状态', width: 80,formatter: function (value, row, index) {
|
||||
{ field: 'state', title: '风险点状态', width: 80,formatter: function (value, row, index) {
|
||||
if(value==1){
|
||||
return '正常';
|
||||
}else{
|
||||
|
@ -66,8 +68,13 @@
|
|||
}else{
|
||||
return 'color:red;font-weight:bold';
|
||||
}}},
|
||||
{ field: 'riskact__name', title: '风险点', width: 100 },
|
||||
{ field: 'riskact__area__name', title: '所属区域', width: 80 },
|
||||
{ field: 'istask', title: '是否任务派发', width: 50,formatter: function (value, row, index) {
|
||||
if(value==1){
|
||||
return '是';
|
||||
}else{
|
||||
return '否';
|
||||
}
|
||||
}},
|
||||
]]
|
||||
});
|
||||
function delriskactcheck(){
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<!-- <a onclick="editscheduleset()" class="easyui-linkbutton"
|
||||
data-options="iconCls:'fa-pencil',plain:true">编辑</a> -->
|
||||
|
||||
<a onclick="delgirdtaskset()" class="easyui-linkbutton"
|
||||
<a onclick="delscheduleset()" class="easyui-linkbutton"
|
||||
data-options="iconCls:'fa-trash',plain:true">删除</a>
|
||||
|
||||
</div>
|
||||
|
@ -43,14 +43,14 @@
|
|||
$.messager.alert('提示', '请先选择一个策略!');
|
||||
}
|
||||
}
|
||||
function delgirdtaskset() {
|
||||
function delscheduleset() {
|
||||
var row = $('#schedulesettable').datagrid('getSelected');
|
||||
if (row) {
|
||||
$.messager.confirm('提示', '确定删除吗?', function (r) {
|
||||
if (r) {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: 'api/scheduleset?a=del&id=' + row.id,
|
||||
url: 'api/myschedule?a=del&id=' + row.id,
|
||||
datatype: "json",
|
||||
beforeSend: function () { },
|
||||
success: function (data) {
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
pageSize: 20,
|
||||
columns: [[
|
||||
{ field: 'riskact__name', title: '风险点名称', width: 80 },
|
||||
{ field: 'riskact__group__groupname', title: '所属岗位', width: 100 },
|
||||
{ field: 'user__name', title: '任务执行人', width: 80 },
|
||||
{ field: 'riskact__area__name', title: '区域', width: 100 },
|
||||
//{ field: 'num', title: '风险数量', width: 80 },
|
||||
{ field: 'taskadd', title: '任务开始时间', width: 80 },
|
||||
|
@ -35,11 +35,11 @@
|
|||
switch (value) {
|
||||
case 1: return 'color:white;background-color:green'; break;
|
||||
}}},
|
||||
{ field: '', title: '执行状态', width: 80, formatter: function (value, row, index) {
|
||||
{ field: 'taskdo', title: '执行时间', width: 80, formatter: function (value, row, index) {
|
||||
if(row.taskdo==null){
|
||||
return '未执行';
|
||||
}else{
|
||||
return '已完成';
|
||||
return '已完成' + '-' + row.taskdo;
|
||||
}
|
||||
}, styler: function (value, row, index) {
|
||||
if(value==null){
|
||||
|
@ -48,8 +48,7 @@
|
|||
return 'color:green;font-weight:bold';
|
||||
}}
|
||||
},
|
||||
{ field: 'taskdo', title: '执行时间', width: 80 },
|
||||
{ field: 'user__name', title: '执行人', width: 80 },
|
||||
|
||||
]],
|
||||
// onSelect: function (index, row) {
|
||||
// $('#tasktable').datagrid({url:'api/risktask?a=listtask&riskact='+row.risk__riskact__id+'&group='+row.risk__group__groupid})
|
||||
|
|
|
@ -7073,36 +7073,40 @@ def apimyschedule(req):
|
|||
userid = req.session['userid']
|
||||
companyid = getcompany(userid)
|
||||
if a == 'listcombobox':
|
||||
objs = MySchedule.objects.filter(usecomp__partid=companyid,deletemark=1)
|
||||
objs = MySchedule.objects.filter(usecomp__partid=companyid)
|
||||
objsdata = objs.values('id','name')
|
||||
keystr = transstr(objsdata, 'id', 'name')
|
||||
return HttpResponse(keystr, content_type="application/json")
|
||||
elif a == 'listall':
|
||||
objs = MySchedule.objects.filter(usecomp__partid=companyid, deletemark=1)
|
||||
objs = MySchedule.objects.filter(usecomp__partid=companyid)
|
||||
total = objs.count()
|
||||
startnum, endnum = fenye(req)
|
||||
objdata = objs.order_by('-pk')[startnum:endnum].values('id', 'name')
|
||||
return HttpResponse(transjson(total, objdata), content_type="application/json")
|
||||
elif a == 'add':
|
||||
data = json.loads(req.body.decode('utf-8'))
|
||||
print(data)
|
||||
if data['set'] == 'interval':
|
||||
iobj = IntervalSchedule()
|
||||
iobj.every = data['every']
|
||||
iobj.period = data['period']
|
||||
iobj.save()
|
||||
iobj, b = IntervalSchedule.objects.get_or_create(every=data['every'], period=data['period'], defaults={'every':data['every'], 'period':data['period']})
|
||||
MySchedule.objects.create(name=data['name'], typeset=data['set'], interval=iobj, usecomp=Partment.objects.get(partid=companyid))
|
||||
elif data['set'] == 'crontab':
|
||||
iobj = CrontabSchedule()
|
||||
iobj.minute = data['minute']
|
||||
iobj.hour = data['hour']
|
||||
iobj.day_of_week = data['day_of_week']
|
||||
iobj.day_of_month = data['day_of_month']
|
||||
iobj.month_of_year = data['month_of_year']
|
||||
iobj.timezone = 'Asia/Shanghai'
|
||||
iobj.save()
|
||||
cron = {
|
||||
'minute' : data['minute'],
|
||||
'hour': data['hour'],
|
||||
'day_of_week': data['day_of_week'],
|
||||
'day_of_month': data['day_of_month'],
|
||||
'month_of_year': data['month_of_year'],
|
||||
'timezone': 'Asia/Shanghai'
|
||||
}
|
||||
iobj, b = CrontabSchedule.objects.get_or_create(**cron, defaults=cron)
|
||||
MySchedule.objects.create(name=data['name'], typeset=data['set'], crontab=iobj, usecomp=Partment.objects.get(partid=companyid))
|
||||
return JsonResponse({'code': 1})
|
||||
elif a == 'del':
|
||||
user = User.objects.get(userid=userid)
|
||||
if user.issuper == 1:
|
||||
MySchedule.objects.get(id=req.GET.get('id')).delete()
|
||||
return JsonResponse({'code': 1})
|
||||
else:
|
||||
return JsonResponse({'code': 0})
|
||||
def apigridtaskset(req):
|
||||
a = req.GET.get('a')
|
||||
userid = req.session['userid']
|
||||
|
@ -7114,7 +7118,7 @@ def apigridtaskset(req):
|
|||
total = objs.count()
|
||||
startnum, endnum = fenye(req)
|
||||
objs = objs.order_by('-pk')[startnum:endnum].values('id', 'gridlevel__dickeyname', 'user__name',
|
||||
'myschedule__name', 'note', 'periodictask__enabled','periodictask__start_time','periodictask__last_run_at','periodictask__total_run_count')
|
||||
'myschedule__name', 'note', 'periodictask__enabled','last_run_at','count')
|
||||
return HttpResponse(transjson(total, objs), content_type="application/json")
|
||||
elif a == 'add':
|
||||
data = json.loads(req.body.decode('utf-8'))
|
||||
|
@ -7125,7 +7129,6 @@ def apigridtaskset(req):
|
|||
pobj.task = 'safesite.tasks.sendGridtask2'
|
||||
pobj.interval = schobj.interval if schobj.interval else None
|
||||
pobj.crontab = schobj.crontab if schobj.crontab else None
|
||||
pobj.start_time = data['start_time'] if ('start_time' in data and data['start_time']) else None
|
||||
pobj.save()
|
||||
obj = GridTaskSet()
|
||||
obj.riskact = RiskAct.objects.get(id=data['riskact'])
|
||||
|
@ -7142,7 +7145,7 @@ def apigridtaskset(req):
|
|||
elif a == 'detail':
|
||||
objs = GridTaskSet.objects.filter(id=req.GET.get('id'))
|
||||
objdata = objs.values('id', 'gridlevel__dickeyname', 'user__name','user__userid','gridlevel__dickeyid','myschedule__id',
|
||||
'myschedule__name', 'note', 'periodictask__start_time')[0]
|
||||
'myschedule__name', 'note')[0]
|
||||
xx = {'code':1, 'data':objdata}
|
||||
return HttpResponse(json.dumps(xx, cls=MyEncoder), content_type="application/json")
|
||||
elif a == 'del':
|
||||
|
@ -7163,7 +7166,6 @@ def apigridtaskset(req):
|
|||
schobj = MySchedule.objects.get(id=data['myschedule'])
|
||||
pobj.interval = schobj.interval if schobj.interval else None
|
||||
pobj.crontab = schobj.crontab if schobj.crontab else None
|
||||
pobj.start_time = data['start_time'] if ('start_time' in data and data['start_time']) else None
|
||||
pobj.save()
|
||||
obj.myschedule = schobj
|
||||
obj.save()
|
||||
|
@ -7470,8 +7472,7 @@ def apiriskacttask(req):
|
|||
objs = objs[startnum:endnum]
|
||||
return HttpResponse(transjson(total, objs), content_type="application/json")
|
||||
elif a == 'listall': # 全厂排查记录
|
||||
objs = RiskActTask.objects.filter(
|
||||
riskact__usecomp__partid=companyid).exclude(user=None)
|
||||
objs = RiskActTask.objects.filter(riskact__usecomp__partid=companyid).exclude(taskdo=None)
|
||||
if req.GET.get('pcbm'):
|
||||
parts = getparts(req.GET.get('pcbm'))
|
||||
objs = objs.filter(user__ubelongpart__in=parts)
|
||||
|
@ -7481,23 +7482,22 @@ def apiriskacttask(req):
|
|||
objs = objs.filter(taskdo__lte=req.GET.get('jssj'))
|
||||
total = objs.count()
|
||||
startnum, endnum = fenye(req)
|
||||
objs = objs[startnum:endnum].values('id', 'riskact__name', 'riskact__area__name', 'riskact__place',
|
||||
'taskdo', 'state', 'user__ubelongpart__partname', 'user__name', 'taskdo')
|
||||
objs = objs.order_by('-taskdo')[startnum:endnum].values('id', 'riskact__name', 'riskact__area__name', 'riskact__place',
|
||||
'taskdo', 'state', 'user__ubelongpart__partname', 'user__name', 'taskdo', 'istask')
|
||||
return HttpResponse(transjson(total, objs), content_type="application/json")
|
||||
elif a == 'listalltodo': # 全厂待办任务
|
||||
objs = RiskActTask.objects.filter(
|
||||
riskact__usecomp__partid=companyid, istask=1, user=None)
|
||||
objs = RiskActTask.objects.filter(istask=1, taskdo=None, usable=1)
|
||||
total = objs.count()
|
||||
startnum, endnum = fenye(req)
|
||||
objs = objs[startnum:endnum].values('id', 'riskact__group__groupname', 'riskact__area__name', 'riskact__type__dickeyname', 'riskact__id',
|
||||
'riskact__group__groupid', 'riskact__name', 'riskact__level', 'riskact__tasktype', 'taskadd', 'taskexpire', 'user__userid', 'usable')
|
||||
'riskact__group__groupid', 'riskact__name', 'riskact__level', 'riskact__tasktype', 'taskadd', 'taskexpire', 'user__userid', 'usable', 'user__name')
|
||||
return HttpResponse(transjson(total, objs), content_type="application/json")
|
||||
elif a == 'listself': # 排查记录
|
||||
a = RiskActTask.objects.filter(user__userid=userid)
|
||||
total = a.count()
|
||||
startnum, endnum = fenye(req)
|
||||
a = a.order_by('-id')[startnum:endnum].values('id', 'riskact__level', 'riskact__name', 'riskact__area__name', 'riskact__place',
|
||||
'taskdo', 'state', 'usable', 'riskact__group__groupname', 'taskadd', 'taskexpire', 'user__userid', 'riskact__id')
|
||||
'taskdo', 'state', 'usable', 'riskact__group__groupname', 'taskadd', 'taskexpire', 'user__userid', 'riskact__id', 'user__name')
|
||||
return HttpResponse(transjson(total, a), content_type="application/json")
|
||||
elif a == 'listmytodo': # 待办
|
||||
groups = Group.objects.filter(users__userid=userid)
|
||||
|
@ -7506,14 +7506,14 @@ def apiriskacttask(req):
|
|||
total = objs.count()
|
||||
startnum, endnum = fenye(req)
|
||||
objs = objs[startnum:endnum].values('id', 'riskact__group__groupname', 'riskact__area__name', 'riskact__type__dickeyname', 'riskact__id',
|
||||
'riskact__group__groupid', 'riskact__name', 'riskact__level', 'riskact__tasktype', 'taskadd', 'taskexpire', 'user__userid')
|
||||
'riskact__group__groupid', 'riskact__name', 'riskact__level', 'riskact__tasktype', 'taskadd', 'taskexpire', 'user__userid', 'user__name')
|
||||
return HttpResponse(transjson(total, objs), content_type="application/json")
|
||||
elif a == 'listmytodo2': # 我的待办
|
||||
objs = RiskActTask.objects.filter(usable=1, istask=1, user__userid=userid)
|
||||
total = objs.count()
|
||||
startnum, endnum = fenye(req)
|
||||
objs = objs[startnum:endnum].values('id', 'riskact__group__groupname', 'riskact__area__name', 'riskact__type__dickeyname', 'riskact__id',
|
||||
'riskact__group__groupid', 'riskact__name', 'riskact__level', 'riskact__tasktype', 'taskadd', 'taskexpire', 'user__userid')
|
||||
'riskact__group__groupid', 'riskact__name', 'riskact__level', 'riskact__tasktype', 'taskadd', 'taskexpire', 'user__userid', 'user__name')
|
||||
return HttpResponse(transjson(total, objs), content_type="application/json")
|
||||
elif a == 'todonum':
|
||||
groups = Group.objects.filter(users__userid=userid)
|
||||
|
@ -7546,9 +7546,9 @@ def apiriskcheck2(req):
|
|||
# objs = RiskActTask.objects.filter(
|
||||
# riskact__id=data['riskact'], usable=1, user=None, istask=1) # 匹配未处理的任务
|
||||
objs = RiskActTask.objects.filter(
|
||||
riskact__id=data['riskact'], usable=1, user=user, istask=1) # 匹配本人未处理的任务
|
||||
riskact__id=data['riskact'], usable=1, user=user, istask=1) # 匹配最近本人未处理的任务
|
||||
if objs.exists():
|
||||
obj = objs[0]
|
||||
obj = objs.last()
|
||||
obj.user = user
|
||||
obj.taskdo = nowtime
|
||||
obj.usable = 0
|
||||
|
@ -7577,8 +7577,8 @@ def apiriskcheck2(req):
|
|||
objs = objs.filter(riskacttask__id=req.GET.get('riskacttask'))
|
||||
total = objs.count()
|
||||
startnum, endnum = fenye(req)
|
||||
objs = objs.order_by('-id')[startnum:endnum].values('id', 'risk__step', 'risk__level', 'trouble__yhnum', 'risk__hazard',
|
||||
'risk__result', 'risk__measure1', 'risk__measure2', 'risk__measure3', 'risk__measure4', 'risk__measure5')
|
||||
objs = objs.order_by('trouble')[startnum:endnum].values('id','risk', 'risk__step', 'risk__level','trouble', 'trouble__yhnum', 'risk__hazard',
|
||||
'risk__result', 'risk__measure1', 'risk__measure2', 'risk__measure3', 'risk__measure4', 'risk__measure5', 'riskacttask', 'riskacttask__taskdo')
|
||||
return HttpResponse(transjson(total, objs), content_type="application/json")
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue