gridtask
This commit is contained in:
parent
d28b8c8ce7
commit
fc3d2dba05
|
@ -1,4 +1,4 @@
|
|||
'__version__', (512, 15)
|
||||
'tz', (1536, 23)
|
||||
'utc_enabled', (1024, 4)
|
||||
'entries', (2048, 728)
|
||||
'entries', (3072, 791)
|
||||
|
|
Binary file not shown.
|
@ -1,4 +1,4 @@
|
|||
'__version__', (512, 15)
|
||||
'tz', (1536, 23)
|
||||
'utc_enabled', (1024, 4)
|
||||
'entries', (2048, 728)
|
||||
'entries', (3072, 791)
|
||||
|
|
|
@ -1 +1 @@
|
|||
15644
|
||||
9068
|
||||
|
|
|
@ -33,16 +33,21 @@ app.conf.update(
|
|||
'schedule': crontab(minute=2),
|
||||
#'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),
|
||||
'grid-task': {
|
||||
'task': 'safesite.tasks.gridtasksend',
|
||||
'schedule': timedelta(seconds=10),
|
||||
#'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),
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
# Generated by Django 2.2.8 on 2020-09-06 15:27
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('safesite', '0347_auto_20200905_1836'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='gridtaskset',
|
||||
old_name='task_schedule',
|
||||
new_name='schedule',
|
||||
),
|
||||
# migrations.RemoveField(
|
||||
# model_name='companyinfo',
|
||||
# name='liaison_fax',
|
||||
# ),
|
||||
]
|
|
@ -0,0 +1,27 @@
|
|||
# Generated by Django 2.2.8 on 2020-09-06 23:41
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('safesite', '0348_auto_20200906_1527'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
# migrations.RemoveField(
|
||||
# model_name='companyinfo',
|
||||
# name='liaison_fax',
|
||||
# ),
|
||||
migrations.AlterField(
|
||||
model_name='gridtaskset',
|
||||
name='last_send',
|
||||
field=models.DateTimeField(blank=True, null=True, verbose_name='最近派发时间'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='riskacttask',
|
||||
name='tasknote',
|
||||
field=models.TextField(blank=True, null=True, verbose_name='任务检查说明'),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,37 @@
|
|||
# Generated by Django 2.2.8 on 2020-09-06 23:44
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.utils.timezone
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('safesite', '0349_auto_20200906_2341'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
# migrations.RemoveField(
|
||||
# model_name='companyinfo',
|
||||
# name='liaison_fax',
|
||||
# ),
|
||||
migrations.RemoveField(
|
||||
model_name='gridtaskset',
|
||||
name='last_send',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='gridtaskset',
|
||||
name='start_send',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='gridtaskset',
|
||||
name='create_time',
|
||||
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='gridtaskset',
|
||||
name='start_task',
|
||||
field=models.DateTimeField(blank=True, null=True, verbose_name='最近/初始派发时间'),
|
||||
),
|
||||
]
|
|
@ -1049,12 +1049,12 @@ class GridTaskSet(models.Model):
|
|||
riskact = models.ForeignKey(RiskAct, on_delete=models.CASCADE, related_name='gridtaskset_riskact')
|
||||
gridlevel = models.ForeignKey(Dickey, on_delete=models.CASCADE, verbose_name='网格化层级')
|
||||
user = models.ForeignKey(User,on_delete=models.CASCADE,verbose_name='执行人')
|
||||
task_schedule = JSONField('定时配置',null=True, blank=True)
|
||||
schedule = JSONField('定时配置',null=True, blank=True)
|
||||
note = models.TextField('检查备注', null=True)
|
||||
start_send = models.DateTimeField('开始派发时间', null=True, blank=True)
|
||||
last_send = models.DateTimeField('最后派发时间', null=True, blank=True)
|
||||
start_task = models.DateTimeField('最近/初始派发时间', null=True, blank=True)
|
||||
is_paused = models.BooleanField(default=True, verbose_name='是否暂停派发')
|
||||
count = models.IntegerField('任务派发次数', default=0)
|
||||
create_time = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
class RiskActTask(models.Model): # 风险点排查执行记录
|
||||
id = models.AutoField(primary_key=True)
|
||||
|
@ -1070,7 +1070,7 @@ class RiskActTask(models.Model): # 风险点排查执行记录
|
|||
note = models.TextField(null=True, blank=True) # 检查备注
|
||||
state = models.IntegerField(default=1) # 1是正常
|
||||
istask = models.IntegerField(default=0) # 是否是任务
|
||||
tasknote = models.TextField('任务备注', null=True, blank=True)
|
||||
tasknote = models.TextField('任务检查说明', null=True, blank=True)
|
||||
taskset = models.ForeignKey(GridTaskSet, null=True, blank=True, verbose_name='由哪个设置派发', on_delete=models.SET_NULL)
|
||||
|
||||
class Risktask(models.Model): # 风险排查任务清单
|
||||
|
|
|
@ -4,7 +4,7 @@ from celery import shared_task
|
|||
import json
|
||||
import logging
|
||||
import requests
|
||||
from .models import User,Checkjob,Checktask,Trouble,Dickey,Partment,Dicclass,Train,Drill,TroubleAccess,Group,Yjyc,Yjsetup,Socertificate,Trainuser,Risk,Risktask,RiskActTask,Miss,Observe,RiskAct, Safecert
|
||||
from .models import *
|
||||
import datetime
|
||||
import calendar
|
||||
import pandas as pd
|
||||
|
@ -280,6 +280,47 @@ def riskacttask():
|
|||
RiskActTask.objects.create(riskact=i,taskexpire = taskexpire,taskadd=nowtime,istask=1)
|
||||
i.tasktime = nowtime
|
||||
i.save()
|
||||
|
||||
@shared_task
|
||||
def gridtasksend():
|
||||
nowtime = datetime.datetime.now()
|
||||
time2 = nowtime + datetime.timedelta(minutes=50)
|
||||
# for i in GridTaskSet.objects.filter(is_paused=False, last_send____gte=time2):
|
||||
for i in GridTaskSet.objects.filter(is_paused=False):
|
||||
sendGridtask(i)
|
||||
import arrow
|
||||
|
||||
def shifttime(number, type_, time1):
|
||||
if type_ == 'hours':
|
||||
return time1.shift(hours=number)
|
||||
elif type_=='days':
|
||||
return time1.shift(days=number)
|
||||
elif type_=='weeks':
|
||||
return time1.shift(weeks=number)
|
||||
elif type_=='months':
|
||||
return time1.shift(months=number)
|
||||
elif type_=='years':
|
||||
return time1.shift(years=number)
|
||||
elif type_=='seconds':
|
||||
return time1.shift(seconds=number)
|
||||
|
||||
def sendGridtask(obj):
|
||||
nowtime = arrow.now()
|
||||
schedule = obj.schedule
|
||||
if 'interval' in schedule and schedule['interval']:
|
||||
number, type_ = schedule['interval'].split(',')
|
||||
start_task = arrow.get(obj.start_task, 'Asia/Shanghai')
|
||||
print(nowtime, start_task)
|
||||
m = shifttime(number, type_, start_task)
|
||||
print(m)
|
||||
if nowtime >= m:
|
||||
newm = shifttime(number, type_, nowtime)
|
||||
RiskActTask.objects.filter(taskset=obj, usable=1).update(usable=0)
|
||||
RiskActTask.objects.create(riskact=obj.riskact,taskexpire = newm.datetime,taskadd=nowtime.datetime,istask=1,taskset=obj,tasknote=obj.note,user=obj.user)
|
||||
obj.start_task = nowtime
|
||||
obj.count = obj.count + 1
|
||||
obj.save()
|
||||
|
||||
@shared_task
|
||||
def checktask():
|
||||
nowtime = datetime.datetime.now()
|
||||
|
|
|
@ -34,6 +34,10 @@
|
|||
<a onclick="editgridtaskset()" class="easyui-linkbutton"
|
||||
data-options="iconCls:'fa-pencil',plain:true">编辑</a>
|
||||
{% endif %}
|
||||
{% if request|has_permission:'b_gridtaskset_toggle' %}
|
||||
<a onclick="togglegridtaskset()" class="easyui-linkbutton"
|
||||
data-options="iconCls:'fa-pencil',plain:true">暂停/启用派发</a>
|
||||
{% endif %}
|
||||
{% if request|has_permission:'b_gridtaskset_del' %}
|
||||
<a onclick="delgirdtaskset()" class="easyui-linkbutton"
|
||||
data-options="iconCls:'fa-trash',plain:true">删除</a>
|
||||
|
@ -99,25 +103,43 @@
|
|||
pageSize: 20,
|
||||
columns: [[
|
||||
{ field: 'id', title: 'ID', hidden: true },
|
||||
{ field: 'gridlevel', title: '网格层级', width: 100 },
|
||||
{ field: 'gridlevel__dickeyname', title: '网格层级', width: 100 },
|
||||
{ field: 'user__name', title: '执行人', width: 100 },
|
||||
{ field: 'task_schedule', title: '任务周期', width: 80 , styler: function (value, row, index) {
|
||||
switch (value) {
|
||||
case '低风险': return 'background-color:blue;color:white'; break;
|
||||
case '一般风险': return 'background-color:yellow;'; break;
|
||||
case '较大风险': return 'background-color:orange;'; break;
|
||||
case '重大风险': return 'background-color:red;color:white'; break;
|
||||
{ field: 'schedule', title: '任务周期', width: 100 ,
|
||||
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: 'start_send', title: '初次派发时间', width: 100 },
|
||||
{ field: 'last_send', title: '最后派发时间', width: 100 },
|
||||
{ field: 'is_paused', title: '当前状态', width: 100 },
|
||||
}
|
||||
},
|
||||
{ field: 'start_task', title: '最近/初始派发时间', width: 200 },
|
||||
{ field: 'is_paused', title: '派发状态', width: 100,
|
||||
formatter: function (value, row, index) {
|
||||
switch (value) {
|
||||
case false: return '正常'; break;
|
||||
case true: return '暂停'; break;
|
||||
}
|
||||
},
|
||||
styler: function (value, row, index) {
|
||||
switch (value) {
|
||||
case false: return 'font-weight:bold;color:green'; break;
|
||||
case true: return 'color:red;font-weight:bold'; break;
|
||||
}
|
||||
}
|
||||
},
|
||||
{ field: 'count', title: '已派发次数', width: 100 },
|
||||
]],
|
||||
});
|
||||
|
||||
function addgridtaskset(){
|
||||
opendg('新增','html/gridtaskset/add/')
|
||||
|
||||
var row = $('#riskacttable').datagrid('getSelected');
|
||||
if (row) {
|
||||
opendg('新增','html/gridtaskset/add/' + row.id)
|
||||
}
|
||||
else {
|
||||
$.messager.alert('提示', '请先选择一个风险点!');
|
||||
}
|
||||
}
|
||||
function editgridtaskset(){
|
||||
var row = $('#girdtasksettable').datagrid('getSelected');
|
||||
|
@ -128,4 +150,71 @@
|
|||
$.messager.alert('提示', '请先选择一个任务配置!');
|
||||
}
|
||||
}
|
||||
function togglegridtaskset() {
|
||||
var row = $('#girdtasksettable').datagrid('getSelected');
|
||||
if (row) {
|
||||
var msg = '确定暂停派发吗?'
|
||||
if(row.is_paused){
|
||||
msg = '确定启动派发吗?'
|
||||
}
|
||||
$.messager.confirm('提示', msg, function (r) {
|
||||
if (r) {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: 'api/gridtaskset?a=toggle&id=' + row.id,
|
||||
datatype: "json",
|
||||
beforeSend: function () { },
|
||||
success: function (data) {
|
||||
$("#girdtasksettable").datagrid('reload');
|
||||
},
|
||||
|
||||
complete: function (XMLHttpRequest, textStatus) {
|
||||
},
|
||||
|
||||
error: function () {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
else {
|
||||
$.messager.alert('提示', '未选择数据!');
|
||||
}
|
||||
}
|
||||
function delgirdtaskset() {
|
||||
var row = $('#girdtasksettable').datagrid('getSelected');
|
||||
if (row) {
|
||||
$.messager.confirm('提示', '确定删除吗?', function (r) {
|
||||
if (r) {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: 'api/gridtaskset?a=del&id=' + row.id,
|
||||
datatype: "json",
|
||||
beforeSend: function () { },
|
||||
success: function (data) {
|
||||
if (data.code == 1) {
|
||||
$("#girdtasksettable").datagrid('reload');
|
||||
} else {
|
||||
$.messager.alert('提示', '您无权删除!');
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
complete: function (XMLHttpRequest, textStatus) {
|
||||
},
|
||||
|
||||
error: function () {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
else {
|
||||
$.messager.alert('提示', '未选择数据!');
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -8,32 +8,77 @@
|
|||
<div data-options="region:'center'" style="width:100%;height:100%;padding:5px 15px;">
|
||||
<form method="post" id="gridtasksetff">
|
||||
<div style="margin-bottom:10px">
|
||||
<input id="qyname" name="name" style="width:90%;"
|
||||
data-options="label:'区域名',required:true" class="easyui-textbox"></input>
|
||||
<input id="gridlevel" class="easyui-combobox" name="gridlevel" style="width:480px" data-options="
|
||||
label:'网格类型',
|
||||
url: 'getdickey?a=combobox&dicclass=58',
|
||||
method: 'get',
|
||||
editable: false,"
|
||||
required=true>
|
||||
</div>
|
||||
<div style="margin-bottom:10px">
|
||||
<select id="qymap" name="map" style="width:90%" data-options="label:'所属地图'"
|
||||
editable="false" class="easyui-combotree">
|
||||
<input id="username" name="username" class="easyui-textbox" style="width:480px" data-options="label:'执行人', editable:false"
|
||||
required=true >
|
||||
<input type="hidden" name="user" id="user"/>
|
||||
<a class='easyui-linkbutton' onclick="choseuser()" style="width:auto">选择</a>
|
||||
</div>
|
||||
<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_task" name="start_task" class="easyui-datetimebox" style="width:auto"
|
||||
data-options="currentText:'今天',closeText:'关闭',showSeconds:false" required=true />
|
||||
|
||||
</div>
|
||||
<div style="margin-bottom:5px">
|
||||
<label style='display:inline-block;'>定时配置</label>
|
||||
<span style="font-weight:bold">每隔</span>
|
||||
<input id="setnumber" name="setnumber" type="text" class="easyui-numberbox" value="1" data-options="min:1,max:31"/>
|
||||
<select id="unit" class="easyui-combobox" style="width:80px">
|
||||
<option value="seconds">秒</option>
|
||||
<option value="hours">小时</option>
|
||||
<option value="days">天</option>
|
||||
<option value="weeks">周</option>
|
||||
<option value="months">月</option>
|
||||
<option value="years">年</option>
|
||||
</select>
|
||||
</div>
|
||||
<div style="margin-bottom:10px">
|
||||
<input id="qyorder" name="order" style="width:90%" data-options="label:'排序'" class="easyui-numberbox">
|
||||
</input>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<script>
|
||||
$('#qymap').combotree({
|
||||
url: 'api/map?a=tree',
|
||||
loadFilter: function (rows) {
|
||||
return convert(rows);
|
||||
},
|
||||
var riskact = {{riskact}}
|
||||
function choseuser() {
|
||||
var myh = screen.availHeight * 0.5;
|
||||
$('#userdd').dialog({
|
||||
maximizable: true,
|
||||
title: '选择人员',
|
||||
width: 700,
|
||||
height: myh,
|
||||
closed: false,
|
||||
cache: false,
|
||||
href: 'getuserf?a=user',
|
||||
modal: true,
|
||||
border:false,
|
||||
});
|
||||
$('#userdd').window('center');
|
||||
}
|
||||
function aaa(x) {
|
||||
if (x == "user") {
|
||||
$('#user').attr('value', top.$('#in').val());
|
||||
$('#username').textbox('setValue', top.$('#in').attr('show'));
|
||||
}
|
||||
}
|
||||
function submitform() {
|
||||
var data = $('#gridtasksetff').serializeJSON();
|
||||
data['riskact'] = riskact
|
||||
var mm = $('#setnumber').numberbox('getValue')+','+$('#unit').val()
|
||||
data['schedule'] = {'interval':mm}
|
||||
$.messager.confirm('提示', '确定创建并开始派发任务吗?', function (r) {
|
||||
if (r) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: 'api/area?a=add',
|
||||
data: JSON.stringify($('#gridtasksetff').serializeJSON()),
|
||||
url: 'api/gridtaskset/?a=add',
|
||||
data: JSON.stringify(data),
|
||||
datatype: "json",
|
||||
processData: false,
|
||||
contentType: "application/json;charset=utf-8",
|
||||
|
@ -47,12 +92,15 @@
|
|||
},
|
||||
success: function (data) {
|
||||
if (data.code == 1) {
|
||||
$("#qylblist").datagrid('reload');
|
||||
$("#girdtasksettable").datagrid('reload');
|
||||
$("#dd").dialog("close");
|
||||
} else { $.messager.alert('提示', '失败,区域名重复!'); }
|
||||
} else { $.messager.alert('提示', '失败!'); }
|
||||
$('#submitb').linkbutton('enable');
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
</script>
|
||||
</div>
|
|
@ -6,39 +6,97 @@
|
|||
</div>
|
||||
</div>
|
||||
<div data-options="region:'center'" style="width:100%;height:100%;padding:5px 15px;">
|
||||
<form method="post" id="qyff">
|
||||
<form method="post" id="gridtasksetff">
|
||||
<div style="margin-bottom:10px">
|
||||
<input id="qyname" name="name" style="width:90%;"
|
||||
data-options="label:'区域名',required:true" class="easyui-textbox"></input>
|
||||
<input id="gridlevel" class="easyui-combobox" name="gridlevel" style="width:480px" data-options="
|
||||
label:'网格类型',
|
||||
url: 'getdickey?a=combobox&dicclass=58',
|
||||
method: 'get',
|
||||
editable: false,"
|
||||
required=true>
|
||||
</div>
|
||||
<div style="margin-bottom:10px">
|
||||
<select id="qymap" name="map" style="width:90%" data-options="label:'所属地图'"
|
||||
editable="false" class="easyui-combotree">
|
||||
<input id="username" name="username" class="easyui-textbox" style="width:480px" data-options="label:'执行人', editable:false"
|
||||
required=true >
|
||||
<input type="hidden" name="user" id="user"/>
|
||||
<a class='easyui-linkbutton' onclick="choseuser()" style="width:auto">选择</a>
|
||||
</div>
|
||||
<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_task" editable="false" name="start_task" class="easyui-datetimebox" style="width:auto"
|
||||
data-options="currentText:'今天',closeText:'关闭',showSeconds:false" required=true />
|
||||
|
||||
</div>
|
||||
<div style="margin-bottom:5px">
|
||||
<label style='display:inline-block;'>定时配置</label>
|
||||
<span style="font-weight:bold">每隔</span>
|
||||
<input id="setnumber" name="setnumber" type="text" class="easyui-numberbox" value="1" data-options="min:1,max:31"/>
|
||||
<select id="unit" class="easyui-combobox" style="width:80px">
|
||||
<option value="seconds">秒</option>
|
||||
<option value="hours">小时</option>
|
||||
<option value="days">天</option>
|
||||
<option value="weeks">周</option>
|
||||
<option value="months">月</option>
|
||||
<option value="years">年</option>
|
||||
</select>
|
||||
</div>
|
||||
<div style="margin-bottom:10px">
|
||||
<input id="qyorder" name="order" style="width:90%" data-options="label:'排序'" class="easyui-numberbox">
|
||||
</input>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<script>
|
||||
$('#qymap').combotree({
|
||||
url: 'api/map?a=tree',
|
||||
loadFilter: function (rows) {
|
||||
return convert(rows);
|
||||
},
|
||||
var girdtasksetid = {{id}}
|
||||
$.get('api/gridtaskset?a=detail&id='+girdtasksetid,function(res){
|
||||
var data = res.data
|
||||
$('#gridlevel').combobox('setValue', data.gridlevel__dickeyid)
|
||||
$('#username').textbox('setValue',data.user__name)
|
||||
$('#user').val(data.user__userid)
|
||||
$('#note').textbox('setValue',data.note)
|
||||
$('#start_task').datetimebox('setValue', data.start_task)
|
||||
if(data.schedule.hasOwnProperty('interval')){
|
||||
var interval = data.schedule.interval.split(',')
|
||||
$('#setnumber').numberbox('setValue', interval[0])
|
||||
$('#unit').val(interval[1])
|
||||
}
|
||||
})
|
||||
function choseuser() {
|
||||
var myh = screen.availHeight * 0.5;
|
||||
$('#userdd').dialog({
|
||||
maximizable: true,
|
||||
title: '选择人员',
|
||||
width: 700,
|
||||
height: myh,
|
||||
closed: false,
|
||||
cache: false,
|
||||
href: 'getuserf?a=user',
|
||||
modal: true,
|
||||
border:false,
|
||||
});
|
||||
$('#userdd').window('center');
|
||||
}
|
||||
function aaa(x) {
|
||||
if (x == "user") {
|
||||
$('#user').attr('value', top.$('#in').val());
|
||||
$('#username').textbox('setValue', top.$('#in').attr('show'));
|
||||
}
|
||||
}
|
||||
function submitform() {
|
||||
var data = $('#gridtasksetff').serializeJSON();
|
||||
data['id']=girdtasksetid
|
||||
var mm = $('#setnumber').numberbox('getValue')+','+$('#unit').val()
|
||||
data['schedule'] = {'interval':mm}
|
||||
$.messager.confirm('提示', '确定修改吗?', function (r) {
|
||||
if (r) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: 'api/area?a=add',
|
||||
data: JSON.stringify($('#qyff').serializeJSON()),
|
||||
url: 'api/gridtaskset/?a=edit',
|
||||
data: JSON.stringify(data),
|
||||
datatype: "json",
|
||||
processData: false,
|
||||
contentType: "application/json;charset=utf-8",
|
||||
beforeSend: function () {
|
||||
var bo = $('#qyff').form('validate')
|
||||
var bo = $('#gridtasksetff').form('validate')
|
||||
if (bo == false) {
|
||||
return bo
|
||||
} else {
|
||||
|
@ -47,12 +105,15 @@
|
|||
},
|
||||
success: function (data) {
|
||||
if (data.code == 1) {
|
||||
$("#qylblist").datagrid('reload');
|
||||
$("#girdtasksettable").datagrid('reload');
|
||||
$("#dd").dialog("close");
|
||||
} else { $.messager.alert('提示', '失败,区域名重复!'); }
|
||||
} else { $.messager.alert('提示', '失败!'); }
|
||||
$('#submitb').linkbutton('enable');
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
</script>
|
||||
</div>
|
|
@ -35,8 +35,8 @@
|
|||
switch (value) {
|
||||
case 1: return 'color:white;background-color:green'; break;
|
||||
}}},
|
||||
{ field: 'user__userid', title: '执行状态', width: 80, formatter: function (value, row, index) {
|
||||
if(value==null){
|
||||
{ field: '', title: '执行状态', width: 80, formatter: function (value, row, index) {
|
||||
if(row.taskdo==null){
|
||||
return '未执行';
|
||||
}else{
|
||||
return '已完成';
|
||||
|
|
|
@ -83,7 +83,7 @@ urlpatterns = [
|
|||
path('html/inspectitem/detail/<int:id>', views.inspectitemdetail),
|
||||
path('html/risk/<int:kind>/',views.risk),
|
||||
path('html/gridtaskset/', views.gridtaskset),
|
||||
path('html/gridtaskset/add/', views.gridtasksetadd),
|
||||
path('html/gridtaskset/add/<int:riskact>/', views.gridtasksetadd),
|
||||
path('html/gridtaskset/edit/<int:id>/',views.gridtasksetedit),
|
||||
path('html/riskact/add/<int:kind>/',views.riskactadd),
|
||||
path('html/riskact/edit/<int:id>/',views.riskactedit),
|
||||
|
|
|
@ -210,8 +210,8 @@ def risk(req, kind):
|
|||
def gridtaskset(req):
|
||||
return render(req, 'gridtaskset.html')
|
||||
|
||||
def gridtasksetadd(req):
|
||||
return render(req, 'gridtasksetadd.html')
|
||||
def gridtasksetadd(req, riskact):
|
||||
return render(req, 'gridtasksetadd.html', {'riskact': riskact})
|
||||
|
||||
def gridtasksetedit(req, id):
|
||||
return render(req, 'gridtasksetedit.html', {'id': id})
|
||||
|
@ -7069,9 +7069,50 @@ def apigridtaskset(req):
|
|||
objs = objs.filter(riskact__id=req.GET.get('riskact'))
|
||||
total = objs.count()
|
||||
startnum, endnum = fenye(req)
|
||||
objs = objs.order_by('-pk')[startnum:endnum].values('id', 'gridlevel', 'user__name',
|
||||
'task_schedule', 'note', 'start_send', 'last_send', 'is_paused', 'count')
|
||||
objs = objs.order_by('-pk')[startnum:endnum].values('id', 'gridlevel__dickeyname', 'user__name',
|
||||
'schedule', 'note', 'start_task', 'is_paused', 'count')
|
||||
return HttpResponse(transjson(total, objs), content_type="application/json")
|
||||
elif a == 'add':
|
||||
data = json.loads(req.body.decode('utf-8'))
|
||||
obj = GridTaskSet()
|
||||
obj.riskact = RiskAct.objects.get(id=data['riskact'])
|
||||
obj.user = User.objects.get(userid=data['user'])
|
||||
obj.gridlevel = Dickey.objects.get(dickeyid=data['gridlevel'])
|
||||
obj.note = data['note'] if 'note' in data and data['note'] else None
|
||||
obj.start_task = data['start_task']
|
||||
obj.schedule = data['schedule']
|
||||
obj.is_paused = False
|
||||
obj.save()
|
||||
return JsonResponse({'code': 1})
|
||||
elif a == 'detail':
|
||||
objs = GridTaskSet.objects.filter(id=req.GET.get('id'))
|
||||
objdata = objs.values('id', 'gridlevel__dickeyname', 'user__name','user__userid','gridlevel__dickeyid',
|
||||
'schedule', 'note', 'start_task', 'is_paused', 'count')[0]
|
||||
xx = {'code':1, 'data':objdata}
|
||||
return HttpResponse(json.dumps(xx, cls=MyEncoder), content_type="application/json")
|
||||
elif a == 'del':
|
||||
id = req.GET.get('id')
|
||||
obj = GridTaskSet.objects.get(id=id)
|
||||
obj.delete()
|
||||
return JsonResponse({"code": 1})
|
||||
elif a == 'edit':
|
||||
data = json.loads(req.body.decode('utf-8'))
|
||||
obj = GridTaskSet.objects.get(id=data['id'])
|
||||
obj.user = User.objects.get(userid=data['user'])
|
||||
obj.gridlevel = Dickey.objects.get(dickeyid=data['gridlevel'])
|
||||
obj.note = data['note'] if 'note' in data and data['note'] else None
|
||||
obj.start_task = data['start_task']
|
||||
obj.schedule = data['schedule']
|
||||
obj.save()
|
||||
return JsonResponse({'code': 1})
|
||||
elif a == 'toggle':
|
||||
obj = GridTaskSet.objects.get(id=req.GET.get('id'))
|
||||
if obj.is_paused:
|
||||
obj.is_paused = False
|
||||
else:
|
||||
obj.is_paused = True
|
||||
obj.save()
|
||||
return JsonResponse({'code': 1})
|
||||
|
||||
def apirisk(req):
|
||||
a = req.GET.get('a')
|
||||
|
@ -7356,7 +7397,7 @@ def apiriskacttask(req):
|
|||
userid = req.session['userid']
|
||||
companyid = getcompany(userid)
|
||||
if a == 'listalltask': # 全厂任务
|
||||
objs = RiskActTask.objects.filter(riskact__usecomp__partid=companyid, istask=1).order_by('-usable', 'riskact__group__groupid').values('riskact__group__groupname', 'riskact__area__name',
|
||||
objs = RiskActTask.objects.filter(riskact__usecomp__partid=companyid, istask=1).order_by('-pk','-usable', 'riskact__group__groupid').values('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', 'taskdo', 'user__name')
|
||||
total = objs.count()
|
||||
startnum, endnum = fenye(req)
|
||||
|
@ -7401,12 +7442,23 @@ def apiriskacttask(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')
|
||||
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')
|
||||
return HttpResponse(transjson(total, objs), content_type="application/json")
|
||||
elif a == 'todonum':
|
||||
groups = Group.objects.filter(users__userid=userid)
|
||||
objs = RiskActTask.objects.filter(
|
||||
riskact__group__in=groups, usable=1, user=None)
|
||||
total = objs.count()
|
||||
return JsonResponse({"code": 1, "todonum": total})
|
||||
elif a == 'todonum2': # 我的待办统计
|
||||
objs = RiskActTask.objects.filter(usable=1, user__userid=userid,taskdo=None)
|
||||
total = objs.count()
|
||||
return JsonResponse({"code": 1, "todonum": total})
|
||||
# elif a == 'listmydone':
|
||||
# groups = Group.objects.filter(users__userid=userid)
|
||||
# objs = Risktask.objects.filter(Q(group__in=groups)|Q(user__userid=userid),usable__in=[0,2]).values('risk__group__groupname','risk__riskact__area__name','risk__riskact__type__dickeyname','risk__riskact__id','risk__tasktype','taskadd','taskexpire','user__userid','usable').annotate(num = Count('risk__group'))
|
||||
|
@ -7425,8 +7477,10 @@ def apiriskcheck2(req):
|
|||
data = json.loads(req.body.decode('utf-8'))
|
||||
checkrisks = data['checks']
|
||||
user = User.objects.get(userid=userid)
|
||||
# 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=None, istask=1) # 匹配未处理的任务
|
||||
riskact__id=data['riskact'], usable=1, user=user, istask=1, nowtime__gte = taskadd, nowtime__lte = taskexpire) # 匹配本人未处理的任务
|
||||
if objs.exists():
|
||||
obj = objs[0]
|
||||
obj.user = user
|
||||
|
|
Loading…
Reference in New Issue