隐患跟踪计划part2
This commit is contained in:
parent
628676d28e
commit
90fee624cd
|
@ -311,16 +311,28 @@ def sendGridtask(obj):
|
|||
@shared_task
|
||||
def sendGridtask2(**kwargs):
|
||||
obj = GridTaskSet.objects.get(id=kwargs['gridtaskset'])
|
||||
RiskActTask.objects.filter(taskset=obj, usable=1).update(usable=0)
|
||||
nowtime = datetime.datetime.now()
|
||||
if obj.expire:
|
||||
newm = nowtime + datetime.timedelta(hours=int(obj.expire))
|
||||
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()
|
||||
if obj.trouble:
|
||||
nowtime = datetime.datetime.now()
|
||||
if obj.expire:
|
||||
newm = nowtime + datetime.timedelta(hours=int(obj.expire))
|
||||
TroubleFollowTask.objects.create(trouble=obj.trouble,taskexpire = newm,taskadd=nowtime,taskset=obj,tasknote=obj.note,user=obj.user)
|
||||
else:
|
||||
TroubleFollowTask.objects.create(trouble=obj.trouble,taskadd=nowtime,istask=1,taskset=obj,tasknote=obj.note,user=obj.user)
|
||||
obj.last_run_at = nowtime
|
||||
obj.count = obj.count+1
|
||||
obj.save()
|
||||
|
||||
elif obj.riskact:
|
||||
RiskActTask.objects.filter(taskset=obj, usable=1).update(usable=0)
|
||||
nowtime = datetime.datetime.now()
|
||||
if obj.expire:
|
||||
newm = nowtime + datetime.timedelta(hours=int(obj.expire))
|
||||
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():
|
||||
|
|
|
@ -1,12 +1,31 @@
|
|||
<div id="yhgzrwtablebar" style="padding:4px;">
|
||||
<div>
|
||||
<a id="addyhgzrw" onclick="javascript:opendg('创建隐患跟踪任务','/html/troublefollowtaskset/add')" class="easyui-linkbutton" data-options="iconCls: 'fa-plus',
|
||||
plain: true">创建隐患跟踪任务</a>
|
||||
<a id="delyhgzrw" onclick="delyhgzrw()" class="easyui-linkbutton" data-options="iconCls: 'fa-trash',
|
||||
<div class="easyui-layout" style="width:100%;height:100%;">
|
||||
<div data-options="region:'center',title:'计划',split:true,border:false" style="width:50%;height:100%;">
|
||||
<div id="yhgzrwtablebar" style="padding:4px;">
|
||||
<div>
|
||||
{% load myfilter %}
|
||||
{% if request|has_permission:'b_troublefollowtaskset_add' %}
|
||||
<a id="addyhgzrw" onclick="javascript:opendg('创建隐患跟踪计划','/html/troublefollowtaskset/add')"
|
||||
class="easyui-linkbutton" data-options="iconCls: 'fa-plus',
|
||||
plain: true">创建隐患跟踪计划</a>
|
||||
{% endif %}
|
||||
{% if request|has_permission:'b_troublefollowtaskset_edit' %}
|
||||
<a id="edityhgzrw" onclick="edityhgzrw()" class="easyui-linkbutton" data-options="iconCls: 'fa-pencil',
|
||||
plain: true">编辑计划</a>
|
||||
{% endif %}
|
||||
{% if request|has_permission:'b_troublefollowtaskset_del' %}
|
||||
<a id="delyhgzrw" onclick="delyhgzrw()" class="easyui-linkbutton" data-options="iconCls: 'fa-trash',
|
||||
plain: true">删除</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<table id="yhgzrwtable" style="width:100%;height:100%;"></table>
|
||||
</div>
|
||||
<div data-options="region:'east',title:'执行情况',split:true,border:false" style="width:50%;height:100%;">
|
||||
<table id="yhgzrwtable2" style="width:100%;height:100%;"></table>
|
||||
</div>
|
||||
</div>
|
||||
<table id="yhgzrwtable" style="width:100%;height:100%;"></table>
|
||||
<script>
|
||||
$(function () {
|
||||
$('#yhgzrwtable').datagrid({ url: 'api/gridtaskset', queryParams: { a: 'list1' } });
|
||||
|
@ -25,9 +44,9 @@
|
|||
border: false,
|
||||
columns: [[
|
||||
{ field: 'id', hidden: true },
|
||||
{ field: 'trouble__yhnum', title: '隐患编号', width: 100 },
|
||||
{ field: 'trouble__yhnum', title: '隐患编号', width: '150px' },
|
||||
{
|
||||
field: 'trouble__yhzt', title: '隐患状态', width: 80, styler: function (value, row, index) {
|
||||
field: 'trouble__yhzt', title: '隐患状态', width: '80px', styler: function (value, row, index) {
|
||||
switch (value) {
|
||||
case 0: return 'background-color:yellow;'; break;
|
||||
case 1: return 'background-color:yellow;'; break;
|
||||
|
@ -54,12 +73,13 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
{ field: 'gridlevel__dickeyname', title: '网格层级', width: 80 },
|
||||
{ field: 'user__name', title: '跟踪人', width: 80 },
|
||||
{ field: 'myschedule__name', title: '任务策略', width: 100},
|
||||
{ field: 'last_run_at', title: '最近派发时间', width: 100 },
|
||||
{ field: 'periodictask__enabled', title: '派发状态', width: 50,
|
||||
formatter: function (value, row, index) {
|
||||
{ field: 'gridlevel__dickeyname', title: '网格层级', width: '80px' },
|
||||
{ field: 'user__name', title: '跟踪人', width: '80px' },
|
||||
{ field: 'myschedule__name', title: '任务策略', width: '150px' },
|
||||
{ field: 'last_run_at', title: '最近派发时间', width: '100px' },
|
||||
{
|
||||
field: 'periodictask__enabled', title: '派发状态', width: '60px',
|
||||
formatter: function (value, row, index) {
|
||||
switch (value) {
|
||||
case true: return '正常'; break;
|
||||
case false: return '暂停'; break;
|
||||
|
@ -70,10 +90,10 @@
|
|||
case true: return 'font-weight:bold;color:green'; break;
|
||||
case false: return 'color:red;font-weight:bold'; break;
|
||||
}
|
||||
}
|
||||
},
|
||||
{ field: 'count', title: '已派发次数', width: 50 },
|
||||
{ field: 'note', title: '执行备注', width: 100 },
|
||||
}
|
||||
},
|
||||
{ field: 'count', title: '已派发次数', width: '100px' },
|
||||
{ field: 'note', title: '执行备注', width: '200px' },
|
||||
]]
|
||||
});
|
||||
function delyhgzrw() {
|
||||
|
@ -82,9 +102,9 @@
|
|||
$.messager.confirm('提示', '确定删除吗?', function (r) {
|
||||
if (r) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: 'troublehandle?a=del',
|
||||
data: { 'troubleid': row.troubleid },
|
||||
type: "GET",
|
||||
url: 'api/gridtaskset/?a=del',
|
||||
data: { 'id': row.id },
|
||||
datatype: "json",
|
||||
beforeSend: function () { },
|
||||
success: function (data) {
|
||||
|
@ -92,7 +112,7 @@
|
|||
$("#yhgzrwtable").datagrid('reload');
|
||||
}
|
||||
else {
|
||||
$.messager.alert('提示', '流程已进行,您无权删除!');
|
||||
$.messager.alert('提示', '您无权删除!');
|
||||
}
|
||||
},
|
||||
});
|
||||
|
@ -101,6 +121,15 @@
|
|||
}
|
||||
else { $.messager.alert('提示', '请选择一条数据!'); }
|
||||
}
|
||||
function edityhgzrw() {
|
||||
var row = $('#yhgzrwtable').datagrid('getSelected');
|
||||
if (row) {
|
||||
opendg('编辑', 'html/troublefollowtaskset/edit/' + row.id)
|
||||
}
|
||||
else {
|
||||
$.messager.alert('提示', '请先选择一个任务配置!');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
|
|
@ -57,7 +57,6 @@
|
|||
</form>
|
||||
</div>
|
||||
<script>
|
||||
var riskact = {{riskact}}
|
||||
function choseuser() {
|
||||
var myh = screen.availHeight * 0.5;
|
||||
$('#userdd').dialog({
|
||||
|
@ -85,9 +84,6 @@
|
|||
}
|
||||
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({
|
||||
|
@ -107,7 +103,7 @@
|
|||
},
|
||||
success: function (data) {
|
||||
if (data.code == 1) {
|
||||
$("#girdtasksettable").datagrid('reload');
|
||||
$("#yhgzrwtable").datagrid('reload');
|
||||
$("#dd").dialog("close");
|
||||
} else { $.messager.alert('提示', '失败!'); }
|
||||
$('#submitb').linkbutton('enable');
|
||||
|
|
|
@ -35,19 +35,6 @@
|
|||
<div style="margin-bottom:10px">
|
||||
<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>
|
||||
<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> -->
|
||||
</form>
|
||||
</div>
|
||||
<script>
|
||||
|
|
|
@ -7489,7 +7489,10 @@ def apigridtaskset(req):
|
|||
pobj.crontab = schobj.crontab if schobj.crontab else None
|
||||
pobj.save()
|
||||
obj = GridTaskSet()
|
||||
obj.riskact = RiskAct.objects.get(id=data['riskact'])
|
||||
if 'riskact' in data and data['riskact']:
|
||||
obj.riskact = RiskAct.objects.get(id=data['riskact'])
|
||||
elif 'trouble' in data and data['trouble']:
|
||||
obj.trouble = Trouble.objects.get(troubleid=data['trouble'])
|
||||
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
|
||||
|
@ -7503,7 +7506,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')[0]
|
||||
'myschedule__name', 'note', 'expire')[0]
|
||||
xx = {'code':1, 'data':objdata}
|
||||
return HttpResponse(json.dumps(xx, cls=MyEncoder), content_type="application/json")
|
||||
elif a == 'del':
|
||||
|
|
Loading…
Reference in New Issue