隐患跟踪part3

This commit is contained in:
caoqianming 2021-01-27 22:36:01 +08:00
parent 90fee624cd
commit 5767253f21
6 changed files with 143 additions and 1 deletions

View File

@ -0,0 +1,18 @@
# Generated by Django 2.2.8 on 2021-01-27 21:23
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('safesite', '0375_auto_20210125_2120'),
]
operations = [
migrations.AddField(
model_name='troublefollowtask',
name='usable',
field=models.IntegerField(default=1),
),
]

View File

@ -1103,6 +1103,7 @@ class TroubleFollowTask(models.Model):
taskexpire = models.DateTimeField('任务过期时间', null=True, blank=True)
desc = models.TextField('跟踪描述', null=True, blank=True)
tasknote = models.TextField('任务执行说明', null=True, blank=True)
usable = models.IntegerField(default=1) # 1是可用,2是变更计划,0是不可用
taskset = models.ForeignKey(GridTaskSet, null=True, blank=True, verbose_name='由哪个设置派发', on_delete=models.SET_NULL)
class RiskActTask(models.Model): # 风险点排查执行记录

View File

@ -312,6 +312,7 @@ def sendGridtask(obj):
def sendGridtask2(**kwargs):
obj = GridTaskSet.objects.get(id=kwargs['gridtaskset'])
if obj.trouble:
TroubleFollowTask.objects.filter(taskset=obj, usable=1).update(usable=0)
nowtime = datetime.datetime.now()
if obj.expire:
newm = nowtime + datetime.timedelta(hours=int(obj.expire))
@ -338,6 +339,11 @@ def sendGridtask2(**kwargs):
def expireRiskacttask():
RiskActTask.objects.filter(taskexpire__lte = datetime.datetime.now(), usable=1).update(usable=0)
@shared_task
def expireTroublefollowtask():
TroubleFollowTask.objects.filter(taskexpire__lte = datetime.datetime.now(), usable=1).update(usable=0)
@shared_task
def closeExamtest():
# 自动关闭到期的考试

View File

@ -24,6 +24,15 @@
</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 id="yhgzrwtablebar2" style="padding:4px;">
<div>
<a id="delyhgzrw2" onclick="delyhgzrw2()" class="easyui-linkbutton" data-options="iconCls: 'fa-trash',
plain: true">删除任务</a>
<a id="zfyhgzrw2" onclick="zfyhgzrw2()" class="easyui-linkbutton" data-options="iconCls: 'fa-remove',
plain: true">作废任务</a>
</div>
</div>
</div>
</div>
<script>
@ -42,6 +51,9 @@
pageSize: 20,
toolbar: '#yhgzrwtablebar',
border: false,
onSelect: function (index, data) {
$('#yhgzrwtable2').datagrid({url:'api/troublefollowtask?a=listall&gridtaskset='+data.id})
},
columns: [[
{ field: 'id', hidden: true },
{ field: 'trouble__yhnum', title: '隐患编号', width: '150px' },
@ -94,6 +106,37 @@
},
{ field: 'count', title: '已派发次数', width: '100px' },
{ field: 'note', title: '执行备注', width: '200px' },
]],
});
$('#yhgzrwtable2').datagrid({
rownumbers: true,
singleSelect: true,
striped: true,
method: 'get',
url: '',
fitColumns: true,
pagination: true,
pageSize: 20,
toolbar: '#yhgzrwtablebar2',
border: false,
columns: [[
{ field: 'id', hidden: true },
{ field: 'taskadd', title: '任务派发时间', width: 100 },
{ field: 'taskexpire', title: '任务过期时间', width: 100 },
{ field: 'desc', title: '跟踪描述', width: 200 },
{ field: 'taskdo', title: '任务执行时间', width: 100 },
{ field: 'usable', title: '任务状态', width: 80, formatter: function (value, row, index) {
if(value==1){
return '可用'
}else if (value==0&&row.taskdo==null){
return '作废'
}else if(row.taskdo){
return '已执行'
}
}, styler: function (value, row, index) {
switch (value) {
case 1: return 'color:white;background-color:green'; break;
}}},
]]
});
function delyhgzrw() {
@ -112,7 +155,57 @@
$("#yhgzrwtable").datagrid('reload');
}
else {
$.messager.alert('提示', '您无权删除!');
$.messager.alert('提示', '操作失败!');
}
},
});
}
});
}
else { $.messager.alert('提示', '请选择一条数据!'); }
}
function delyhgzrw2() {
var row = $('#yhgzrwtable2').datagrid('getSelected');
if (row) {
$.messager.confirm('提示', '确定删除该任务吗?', function (r) {
if (r) {
$.ajax({
type: "POST",
url: 'api/troublefollowtask/?a=del',
data: { 'id': row.id },
datatype: "json",
beforeSend: function () { },
success: function (data) {
if (data.code == 1) {
$("#yhgzrwtable2").datagrid('reload');
}
else {
$.messager.alert('提示', '操作失败!');
}
},
});
}
});
}
else { $.messager.alert('提示', '请选择一条数据!'); }
}
function zfyhgzrw2() {
var row = $('#yhgzrwtable2').datagrid('getSelected');
if (row) {
$.messager.confirm('提示', '确定作废该任务吗?', function (r) {
if (r) {
$.ajax({
type: "POST",
url: 'api/troublefollowtask/?a=invalid',
data: { 'id': row.id },
datatype: "json",
beforeSend: function () { },
success: function (data) {
if (data.code == 1) {
$("#yhgzrwtable2").datagrid('reload');
}
else {
$.messager.alert('提示', '操作失败!');
}
},
});

View File

@ -215,6 +215,7 @@ urlpatterns = [
path('api/gridtaskset/',views.apigridtaskset),
path('api/myschedule/',views.apimyschedule),
path('api/trainplan/', views.apitrainplan),
path('api/troublefollowtask/', views.apitroublefollowtask),
path('api/examtestrate',views.apiexamtestrate),

View File

@ -7453,6 +7453,7 @@ def apimyschedule(req):
else:
return JsonResponse({'code': 0})
def apigridtaskset(req):
a = req.GET.get('a')
userid = req.session['userid']
@ -7821,6 +7822,28 @@ def apirisktask(req):
return JsonResponse({'code': 1})
def apitroublefollowtask(req):
a = req.GET.get('a')
userid = req.session['userid']
companyid = getcompany(userid)
if a == 'listall':
objs = TroubleFollowTask.objects.filter(trouble__usecomp__partid=companyid)
if req.GET.get('gridtaskset', None):
objs = objs.filter(taskset__id=req.GET.get('gridtaskset'))
objs = objs.order_by('-pk', '-usable', '-taskadd')
total = objs.count()
startnum, endnum = fenye(req)
objs = objs[startnum:endnum].values('id', 'trouble__yhnum', 'trouble', 'taskadd', 'taskdo', 'taskexpire', 'desc', 'user', 'user__name', 'usable')
return HttpResponse(transjson(total, objs), content_type="application/json")
elif a=='del':
data = json.loads(req.body.decode('utf-8'))
TroubleFollowTask.objects.filter(id=data['id']).delete()
return JsonResponse({'code': 1})
elif a=='invalid':
data = json.loads(req.body.decode('utf-8'))
TroubleFollowTask.objects.filter(id=data['id']).update(usable=0)
return JsonResponse({'code': 1})
def apiriskacttask(req):
a = req.GET.get('a')
userid = req.session['userid']