renwuzuiou

This commit is contained in:
shilixia 2020-04-26 15:03:42 +08:00
parent 9163474c8f
commit dd402fe5a9
10 changed files with 464 additions and 98 deletions

View File

@ -0,0 +1,19 @@
# Generated by Django 2.2.8 on 2020-04-24 10:00
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('safesite', '0332_auto_20200421_1354'),
]
operations = [
migrations.AddField(
model_name='checktask',
name='taskstate',
field=models.IntegerField(default=1),
),
]

View File

@ -1249,6 +1249,7 @@ class Checktask(models.Model):
tasktype = models.IntegerField(default=0)#任务执行频率1每天2每周3每月4每季度5每半年6每年
userlist = models.CharField(max_length=200,null=True,)#检查人列表
zxstate = models.IntegerField(default=1)#1同时执行2一个执行就执行
taskstate = models.IntegerField(default=1)#是否暂停1运行2暂停
class Checkjob(models.Model):
id=models.AutoField(primary_key=True)#主键
checktask=models.ForeignKey(Checktask,on_delete=models.CASCADE)#关联任务表

View File

@ -282,7 +282,7 @@ def riskacttask():
@shared_task
def checktask():
nowtime = datetime.datetime.now()
for i in Checktask.objects.filter(deletemark=1):
for i in Checktask.objects.filter(deletemark=1,taskstate=1):
if i.tasktype==1:
if i.checktime:

View File

@ -9,36 +9,49 @@
<option value="listchuli">验收任务</option>
<option value="listallx">全部任务</option>
</select>
<a onclick="javascript:$('#sdg_job').dialog('open')" class="easyui-linkbutton" data-options="iconCls: 'fa-search',plain:true">详细筛选</a>
</div>
<div>
{% load myfilter %}
{% if request|has_permission:'b_checkjob_add' %}
<a id="addtask" class="easyui-linkbutton" onclick="addcheckrw()" data-options="iconCls: 'fa-plus',plain:true">执行任务</a>
{% endif %}
<a id="deljob" class="easyui-linkbutton" onclick="deljob()" data-options="iconCls: 'fa-trash',plain:true">删除</a>
{% if request|has_permission:'b_checkjob_detail' %}
<a id="detailprg" class="easyui-linkbutton" onclick="detailtask()" data-options="iconCls: 'fa-info-circle',plain:true">详情</a>
{% endif %}
</div>
<div id="sdg_job" class="easyui-dialog" title="筛选条件" style="width:400px;height:420px;"
data-options="iconCls:'fa-search',resizable:true,modal:true,closed:true,border:false">
<div class="easyui-layout" style="width:100%;height:100%;">
<div data-options="region:'center'" style="height:100%;text-align:right;">
<form id='searchyhff' style="margin-right: 10px">
<div style="margin-top:4px"><label>起始时间:</label><input name='qssj' id='qssjyh' style="width:300px"></div>
<div style="margin-top:4px"><label>结束时间:</label><input name='jssj' id='jssjyh' style="width:300px"></div>
<div style="margin-top:4px"><label>检查表名:</label><input id="checktabtitle" name="checktabtitle" style="width:300px" /></div>
<div style="margin-top:4px"><label>任务名称:</label><input id="checktaskname" name="checktaskname" style="width:300px"/></div>
</form>
</div>
<div id='southdiv' data-options="region:'south'" style="height:44px;text-align:center;padding:4px">
<a id="yhsearch" onclick="yhsearch()">查询</a>
</div>
</div>
</div>
</div>
<table id="jobtab" style="width:100%;height:100%;text-align: center;"></table>
<script>
$(function () {
var option = $('#main').attr('value')
$("#searchyhff").form('clear');
})
$('#kjcxyh').combobox({
editable: false,
onSelect: function (node) {
if (node.value != '') {
$('#jobtab').datagrid({ url: 'api/checkproject', queryParams: { a: node.value } });
}
}
})
$('#jobtab').datagrid({
$('#jobtab').datagrid({
url: 'api/checkproject?a=listall4',
rownumbers: true,
singleSelect: true,
@ -80,23 +93,7 @@
}}},
// {
// field: 'jobstate', title: '任务状态', width: 100, styler: function (value, row, index) {
// if (value == 1) {
// return 'background-color:yellow;';
// }
// else {
// return 'background-color:green;';
// }
// }, formatter: function (value, row, index) {
// if (value == 1) {
// return '可执行';
// }
// else {
// return '已过期'
// }
// }
//},
{ field: 'createdate', title: '创建时间', width: 100 },
{ field: 'yanshou', title: '验收时间', width: 100 },
//
@ -106,14 +103,55 @@
]]
});
function addcheckrw() {
$('#kjcxyh').combobox({
editable: false,
onSelect: function (node) {
if (node.value != '') {
$('#jobtab').datagrid({ url: 'api/checkproject', queryParams: { a: node.value } });
}
}
})
$('#yhsearch').linkbutton({
iconCls: 'fa-search',
});
$("#qssjyh").datebox({
editable: false
});
$("#jssjyh").datebox({
editable: false
});
$("#checktabtitle").combobox({
url: 'api/checkproject?a=checktablist',
valueField: 'value',
textField: 'text',
editable: false,
});
$("#checktaskname").combobox({
url: 'api/checkproject?a=checktablist2',
valueField: 'value',
textField: 'text',
editable: false,
});
function yhsearch() {
var querydata = $('#searchyhff').serializeJSON();
querydata['a'] = 'listsearch'
$('#sdg_job').dialog('close')
$('#jobtab').datagrid('load', querydata);
}
function addcheckrw() {
var row = $('#jobtab').datagrid('getSelected');
if (row) {
$.get('api/checkproject?a=jobdetail&id=' + row.id, function (res) {
var data = res.data
console.log(data)
if (data.taskstate ==3) {
if (data.taskstate == 3) {
$.messager.alert('提示', '该任务已关闭不能执行!');
}
else if (data.taskstate ==2) {
@ -149,5 +187,38 @@
}
}
function deljob() {
var row = $('#jobtab').datagrid('getSelected');
if (row) {
$.messager.confirm('提示', '确定删除吗?', function (r) {
if (r) {
$.ajax({
type: "GET",
url: 'api/checkproject?a=deljob',
data: { 'id': row.id },
datatype: "json",
beforeSend: function () { },
success: function (data) {
if (data.code == 1) {
$("#jobtab").datagrid('reload');
}
else {
$.messager.alert('提示', '你无权删除该条任务信息!');
}
},
complete: function (XMLHttpRequest, textStatus) {
},
error: function () {
}
});
}
});
}
else {
$.messager.alert('提示', '请选择一行数据!');
}
}
</script>

View File

@ -10,9 +10,13 @@
{% if request|has_permission:'b_checklist_add' %}
<a id="addtask" class="easyui-linkbutton" onclick="addcheckrw()" data-options="iconCls: 'fa-plus',plain:true">发布任务</a>
{% endif %}
<a id="addtask2" class="easyui-linkbutton" onclick="addcheckrw2()" data-options="iconCls: 'fa-plus',plain:true">发布专项任务</a>
{% if request|has_permission:'b_checklist_del' %}
<a id="delprg" class="easyui-linkbutton" onclick="deltask()" data-options="iconCls: 'fa-trash',plain:true">删除</a>
{% endif %}
<a id="stopstate" class="easyui-linkbutton" onclick="stopstate()" data-options="iconCls: 'fa-info-circle',plain:true">停止</a>
<a id="detailcheck" class="easyui-linkbutton" onclick="detailcheck()" data-options="iconCls: 'fa-info-circle',plain:true">详情</a>
</div>
</div>
@ -36,12 +40,12 @@
columns: [[
{ field: 'id', title: 'ID', hidden: true },
{ field: 'checktaskname', title: '任务名称', width: 150 },
{ field: 'checktype__checktitle', title: '检查表', width: 100 },
{ field: 'checktime', title: '更新时间', width: 300 },
{ field: 'checktype__checktitle', title: '检查表', width: 300 },
//{ field: 'checktime', title: '更新时间', width: 300 },
{ field: 'createuser__name', title: '创建人', width: 300 },
{ field: 'createdate', title: '创建时间', width: 300 },
{ field: 'checkplace', title: '检查地点', width: 300 },
{ field: 'checkplace', title: '检查地点', width: 200 },
{ field: 'tasktype', title: '排查频次', width: 100, formatter: function (value, row, index) {
switch (value) {
@ -52,6 +56,7 @@
case 4: return '每季度一次'; break;
case 5: return '每半年一次'; break;
case 6: return '每年一次'; break;
case 7: return '专项检查'; break;
}
}, styler: function (value, row, index) {
switch (value) {
@ -62,13 +67,28 @@
case 4: return 'color:green;font-weight:bold'; break;
case 5: return 'color:green;font-weight:bold'; break;
case 6: return 'color:green;font-weight:bold'; break;
case 7: return 'color:green;font-weight:bold'; break;
}}},
{ field: 'taskstate', title: '派发状态', width: 100, formatter: function (value, row, index) {
switch (value) {
case 1: return '正常派发'; break;
case 2: return '停止派发'; break;
}
}, styler: function (value, row, index) {
switch (value) {
case 1: return 'background-color:green;font-weight:bold;color:#fafafa'; break;
case 2: return 'background-color:yellow;font-weight:bold;'; break;
}}},
]]
});
function addcheckrw(){
opendg('发布检查任务','html/addcheckrw')
opendg('发布检查任务','html/addcheckrw')//普通检查任务
}
function addcheckrw2(){
opendg('发布专项检查任务','html/addcheckrw2')//专项检查任务
}
function detailcheck() {
var row = $('#tasktab').datagrid('getSelected');
@ -79,6 +99,38 @@
$.messager.alert('提示', '请先选择一条数据!');
}
}
function stopstate(){
var row = $('#tasktab').datagrid('getSelected');
if (row) {
$.messager.confirm('提示', '确定停止该条任务吗?', function (r) {
if (r) {
$.ajax({
type: "GET",
url: 'api/checkproject?a=checkstop',
data: { 'id': row.id },
datatype: "json",
beforeSend: function () { },
success: function (data) {
if (data.code == 1) {
$("#tasktab").datagrid('reload');
}
else {
$.messager.alert('提示', '你无权停止该条任务信息!');
}
},
complete: function (XMLHttpRequest, textStatus) {
},
error: function () {
}
});
}
});
}
else {
$.messager.alert('提示', '请选择一行数据!');
}
}
function deltask() {
var row = $('#tasktab').datagrid('getSelected');
@ -112,4 +164,5 @@
$.messager.alert('提示', '请选择一行数据!');
}
}
</script>

View File

@ -29,7 +29,6 @@
<option value="4">每季度一次</option>
<option value="5">每半年一次</option>
<option value="6">每年一次</option>
<option value="7">专项检查</option>
</select>
</div>
<div style="margin-top:10px;margin-bottom:5px">
@ -68,6 +67,7 @@
})
function aaa(x) {
if (x == "participant") {
$('#participant').attr('value', top.$('#in').val());

View File

@ -0,0 +1,102 @@
<div class="easyui-layout" style="width:100%;height:100%;">
<div id='southdiv' data-options="region:'south'" style="height:50px;text-align:center;padding:5px">
<a href="javascript:void(0)" iconCls="fa-check" class="easyui-linkbutton" onclick="wssubmitForm()" id="submitb">提交</a>
<a href="javascript:void(0)" iconCls="fa-close" class="easyui-linkbutton" onclick="closeForm()">取消</a>
</div>
<div data-options="region:'center'" style="height:100%;padding:15px 15px;">
<form id="wsff" method="post" name="wsff" enctype="multipart/form-data">
<div style="margin-top:10px;margin-bottom:5px">
<input id="checktaskname" class="easyui-textbox" name="checktaskname" style="width:480px;height:40px" data-options="label:'任务名称'"
required=true />
</div>
<div style="margin-top:10px;margin-bottom:5px">
<input class="easyui-textbox" id="participantname" style="width:480px;height:60px" editable="false"
data-options="label:'检查人员',multiline:true,prompt:'请选择'" required=true>
<input type="hidden" id="participant" name="participant" />
<a id="chooserys" class='easyui-linkbutton' onclick="choseusers()" style="width:auto">选择</a>
</div>
<div style="margin-top:6px;margin-left:200px">
<input type="radio" name="zxstate" value="1" checked="true">同时执行</input>
<input type="radio" name="zxstate" value="2">单人执行</input>
</div>
<div style="margin-top:10px;margin-bottom:5px">
<input id="starttime" editable="false" name="starttime" class="easyui-datetimebox" style="width:480px;height:40px"
data-options="label:'开始时间',currentText:'今天',closeText:'关闭',showSeconds:false" required=true />
</div>
<div style="margin-top:10px;margin-bottom:5px">
<input id="endtime" editable="false" name="endtime" class="easyui-datetimebox" style="width:480px;height:40px"
data-options="label:'结束时间时间',currentText:'今天',closeText:'关闭',showSeconds:false" required=true />
</div>
<div style="margin-bottom:5px">
<input id="checktabtitle" class="easyui-textbox" name="checktabtitle" style=" width: 480px;
height: 40px
" data-options="label:'检查项目'" required=true />
</div>
<div style="margin-top:10px;margin-bottom:5px">
<input id="checkplace" class="easyui-textbox" name="checkplace" style=" width: 480px;
height: 40px
" data-options="label:'检查地点'"
required=true />
</div>
</form>
</div>
</div>
<script>
$(function () {
$("#checktabtitle").combobox({
url: 'api/checkproject?a=checktablist',
valueField: 'value',
textField: 'text',
editable: false,
});
})
function aaa(x) {
if (x == "participant") {
$('#participant').attr('value', top.$('#in').val());
$('#participantname').textbox('setValue', top.$('#in').attr('show'));
$('#participantnum').textbox('setValue', top.$('#in').attr('total'));
}
}
function wssubmitForm() {
var wsdata = $('#wsff').serializeJSON();
$.ajax({
type: "POST",
url: 'api/checkproject?a=addchecklist2',
data: JSON.stringify(wsdata),
datatype: "json",
processData: false,
contentType: "application/json;charset=utf-8",
beforeSend: function () {
var bo = $('#wsff').form('validate')
if (bo == false) {
return bo
} else {
$('#submitb').linkbutton('disable');
}
},
success: function (data) {
if (data.code == 1) {
$('#tasktab').datagrid('reload');
$("#dd").dialog("close");
} else { $.messager.alert('提示', '失败!'); }
$('#submitb').linkbutton('enable');
},
});
}
</script>

View File

@ -1,7 +1,7 @@
<div id="yhtablebar" style="padding:4px;">
<div>
<label>快捷查询</label>
<select id='kjcxyh' style='width:150px;'>
<label>快捷查询</label>
<select id='kjcxyh' style='width:150px;'>
<option value="">请选择</option>
<option value="listself">我的隐患</option>
<option value="listtodo">待办隐患</option>
@ -22,8 +22,8 @@
{% if request|has_permission:'b_trouble_import' %}
<a onclick="javascript:$('#drtroubledg').dialog('open').window('center');" class="easyui-linkbutton"
data-options="iconCls:'fa-upload',plain:true">导入待整改隐患</a>
{% endif %}
data-options="iconCls:'fa-upload',plain:true">导入待整改隐患</a>
{% endif %}
{% if request|has_permission:'b_trouble_exportdoc' %}
<a id="exportword" onclick="exportyhword()">导出Word</a>
{% endif %}
@ -33,47 +33,49 @@
{% endif %}
</div>
<div id="sdg_yh" class="easyui-dialog" title="筛选条件" style="width:400px;height:420px;"
data-options="iconCls:'fa-search',resizable:true,modal:true,closed:true,border:false">
<div class="easyui-layout" style="width:100%;height:100%;">
<div data-options="region:'center'" style="height:100%;text-align:right;">
<form id='searchyhff' style="margin-right: 10px">
<div style="margin-top:4px"><label>起始时间</label><input name='qssj' id='qssjyh' style="width:300px"></div>
<div style="margin-top:4px"><label>结束时间</label><input name='jssj' id='jssjyh' style="width:300px"></div>
<div style="margin-top:4px"><label>流程状态</label>
<select name='yhzt' id='syhzt' style="width:300px">
<option value="">请选择</option>
<option value="0">待新增</option>
<option value="1">待评估</option>
<option value="7">措施/方案待提交</option>
<option value="2">措施/方案待确认</option>
<option value="3">待整改</option>
<option value="4">待审核</option>
<option value="5">待复查</option>
<option value="6">已归档</option>
</select></div>
<div style="margin-top:4px"><label>隐患类型</label><input name='yhlx' id="syhlx" style="width:300px;" /></div>
<div style="margin-top:4px"><label>隐患类别</label><input name='yhlb' id="syhlb" style="width:300px;" /></div>
<div style="margin-top:4px"><label>检查类型</label><input name='jclx' id="sjclx" style="width:300px;" /></div>
<div style="margin-top:4px"><label>隐患评估</label><input name='yhpg' id="syhpg" style="width:300px;" /></div>
<div style="margin-top:4px"><label>发现部门</label><input id="sfxbm" name="fxbm" style="width:300px;" /></div>
<!-- <div style="margin-top:4px"><label>发现人</label><input id="sfxr" name="fxr" style="width:300px" /></div> -->
<div style="margin-top:4px"><label>整改部门</label><input id="szgbm" name="zgbm" style="width:300px" /></div>
</form>
</div>
<div id='southdiv' data-options="region:'south'" style="height:44px;text-align:center;padding:4px">
<a id="yhsearch" onclick="yhsearch()">查询</a>
</div>
data-options="iconCls:'fa-search',resizable:true,modal:true,closed:true,border:false">
<div class="easyui-layout" style="width:100%;height:100%;">
<div data-options="region:'center'" style="height:100%;text-align:right;">
<form id='searchyhff' style="margin-right: 10px">
<div style="margin-top:4px"><label>起始时间</label><input name='qssj' id='qssjyh' style="width:300px"></div>
<div style="margin-top:4px"><label>结束时间</label><input name='jssj' id='jssjyh' style="width:300px"></div>
<div style="margin-top:4px">
<label>流程状态</label>
<select name='yhzt' id='syhzt' style="width:300px">
<option value="">请选择</option>
<option value="0">待新增</option>
<option value="1">待评估</option>
<option value="7">措施/方案待提交</option>
<option value="2">措施/方案待确认</option>
<option value="3">待整改</option>
<option value="4">待审核</option>
<option value="5">待复查</option>
<option value="6">已归档</option>
</select>
</div>
<div style="margin-top:4px"><label>隐患类型</label><input name='yhlx' id="syhlx" style="width:300px;" /></div>
<div style="margin-top:4px"><label>隐患类别</label><input name='yhlb' id="syhlb" style="width:300px;" /></div>
<div style="margin-top:4px"><label>检查类型</label><input name='jclx' id="sjclx" style="width:300px;" /></div>
<div style="margin-top:4px"><label>隐患评估</label><input name='yhpg' id="syhpg" style="width:300px;" /></div>
<div style="margin-top:4px"><label>发现部门</label><input id="sfxbm" name="fxbm" style="width:300px;" /></div>
<!-- <div style="margin-top:4px"><label>发现人</label><input id="sfxr" name="fxr" style="width:300px" /></div> -->
<div style="margin-top:4px"><label>整改部门</label><input id="szgbm" name="zgbm" style="width:300px" /></div>
</form>
</div>
<div id='southdiv' data-options="region:'south'" style="height:44px;text-align:center;padding:4px">
<a id="yhsearch" onclick="yhsearch()">查询</a>
</div>
</div>
</div>
</div>
</div>
</div>
<table id="yhtable" style="width:100%;height:100%;"></table>
<div id="drtroubledg" class="easyui-dialog" title="导入隐患" style="width:400px;height:200px;"
data-options="iconCls:'fa-upload',resizable:true,modal:true,closed:true,border:false">
<p style="color:red;margin-left: 10px">请按模板录入后导入</p>
<p style="margin-left: 10px"><a href="/static/safesite/muban/trouble.xlsx" target="_blank">点击下载模板</a></p>
<p style="margin-left: 10px">录入完成后点击下方按钮上传文件</p>
<input type="file" id="drfile" name="" accept=".xls,.xlsx" style="margin-left: 10px" />
data-options="iconCls:'fa-upload',resizable:true,modal:true,closed:true,border:false">
<p style="color:red;margin-left: 10px">请按模板录入后导入</p>
<p style="margin-left: 10px"><a href="/static/safesite/muban/trouble.xlsx" target="_blank">点击下载模板</a></p>
<p style="margin-left: 10px">录入完成后点击下方按钮上传文件</p>
<input type="file" id="drfile" name="" accept=".xls,.xlsx" style="margin-left: 10px" />
</div>
<!-- <a id="downa" href="" target="_blank" style="display:none"></a> -->
<script>
@ -90,10 +92,10 @@ data-options="iconCls:'fa-upload',resizable:true,modal:true,closed:true,border:f
method: 'get',
url: '',
fitColumns: true,
pagination:true,
pagination: true,
pageSize: 20,
toolbar: '#yhtablebar',
border:false,
border: false,
columns: [[
{ field: 'troubleid', hidden: true },
{ field: 'yhnum', title: '编号', width: 100 },
@ -109,7 +111,7 @@ data-options="iconCls:'fa-upload',resizable:true,modal:true,closed:true,border:f
case 6: return 'background-color:green;'; break;
case 7: return 'background-color:yellow;'; break;
}
if(row.zgqx){
if (row.zgqx) {
}
}, formatter: function (value, row, index) {
@ -143,7 +145,7 @@ data-options="iconCls:'fa-upload',resizable:true,modal:true,closed:true,border:f
case 6: return 'color:orange;font-weight:bold'; break;
}
let zgqx = new Date(row.zgqx);
if(new Date()>zgqx&&row.yhzt==3){
if (new Date() > zgqx && row.yhzt == 3) {
return 'color:red;font-weight:bold'
}
}, formatter: function (value, row, index) {
@ -156,7 +158,7 @@ data-options="iconCls:'fa-upload',resizable:true,modal:true,closed:true,border:f
case 6: return '未采纳'; break;
}
let zgqx = new Date(row.zgqx);
if(new Date()>zgqx&&row.yhzt==3){
if (new Date() > zgqx && row.yhzt == 3) {
return '超期未整改'
}
}
@ -262,8 +264,8 @@ data-options="iconCls:'fa-upload',resizable:true,modal:true,closed:true,border:f
function detailyh() {
var row = $('#yhtable').datagrid('getSelected');
if (row) {
url='troublehandle?a=detailhtml&troubleid=' + row.troubleid
opendg('查看详情',url)
url = 'troublehandle?a=detailhtml&troubleid=' + row.troubleid
opendg('查看详情', url)
}
else { $.messager.alert('提示', '请选择一行数据!'); }
}
@ -307,7 +309,7 @@ data-options="iconCls:'fa-upload',resizable:true,modal:true,closed:true,border:f
}
function exportyhexcel() {
var querydata = $('#searchyhff').serializeJSON();
let url = 'troublehandle?a=exportexcel&'+parseParams(querydata)
let url = 'troublehandle?a=exportexcel&' + parseParams(querydata)
$('<form method="post" action="' + url + '"></form>').appendTo('body').submit().remove();
}
function delyh() {
@ -341,12 +343,12 @@ data-options="iconCls:'fa-upload',resizable:true,modal:true,closed:true,border:f
if (row.yhzt != 6) {
if ($("#userindex").attr('userid') == row.todouser__userid) {
if (row.yhzt == 0) {
opendg('编辑隐患','addtrouble?a=edityh&troubleid=' + row.troubleid)
opendg('编辑隐患', 'addtrouble?a=edityh&troubleid=' + row.troubleid)
} else {
var troubleid = row.troubleid;
var yhzt = row.yhzt;
var url = 'accesstrouble?troubleid=' + troubleid + '&yhzt=' + yhzt;
opendg('处理隐患',url)
opendg('处理隐患', url)
}
} else { $.messager.alert('提示', '该条您无权操作!'); }

View File

@ -111,6 +111,7 @@ urlpatterns = [
path('html/addchecktask',views.addchecktask),#检查任务
path('html/checklist',views.checklist),#检查任务
path('html/addcheckrw',views.addcheckrw),#检查任务
path('html/addcheckrw2',views.addcheckrw2),#专项检查任务
path('html/checkjob',views.checkjob),#检查任务
path('html/addcheckjob/<int:id>/',views.addcheckjob),#检查任务
path('html/detailjob/<int:id>/',views.detailjob),#任务详情

View File

@ -516,6 +516,8 @@ def checklist(req):
return render(req,'checklist.html')
def addcheckrw(req):
return render(req,'checklistadd.html')
def addcheckrw2(req):
return render(req,'checklistadd2.html')
def detailjob(req,id):
return render(req,'checkjobdetail.html',{'id':id})
def updchecktable(req,id):
@ -2002,6 +2004,7 @@ def troublehandle(req):
obj = a.order_by('-fxsj')[startnum:endnum].values('troubleid', 'fxr__userid', 'fxr__name', 'yhms', 'yhzt', 'fxsj', 'tbsj', 'yhlb__dickeyname',
'todouser__name', 'yhpg__dickeyname', 'yhnum', 'yhdj__dickeyname', 'shresult', 'zgqx', 'yhtp', 'zghtp', 'todouser__userid')
return HttpResponse(transjson(total, obj), content_type="application/json")
elif a == 'listarea':
userid = req.session['userid']
companyid = getcompany(userid)
@ -7765,7 +7768,7 @@ def checkprojects(req):
total = a.count()
startnum, endnum = fenye(req)
a = a[startnum:endnum].values('id','checktaskname','tasktype','checktype__checktitle','checkplace', 'checktime','createuser__name','createdate')
a = a[startnum:endnum].values('id','checktaskname','taskstate','tasktype','checktype__checktitle','checkplace', 'checktime','createuser__name','createdate')
return HttpResponse(transjson(total, a), content_type="application/json")
elif a == 'listall4':
@ -7889,6 +7892,9 @@ def checkprojects(req):
elif a=='checktablist':
projectlist = Checktable.objects.filter(usecomp__partid=companyid,deletemark=1).values('id', 'checktitle')
return HttpResponse(transstr(projectlist,'id','checktitle'),content_type="application/json")
elif a=='checktablist2':
projectlist = Checktask.objects.filter(usecomp__partid=companyid,deletemark=1).values('id', 'checktaskname')
return HttpResponse(transstr(projectlist,'id','checktaskname'),content_type="application/json")
elif a=='addchecklist':
data = json.loads(req.body.decode('utf-8'))
@ -7957,6 +7963,70 @@ def checkprojects(req):
}
send_wechatmsgs.delay(postdict, s)
return JsonResponse({"code": 1})
#专项检查
elif a=='addchecklist2':
data = json.loads(req.body.decode('utf-8'))
starttime =datetime.strptime(str(data['starttime']), '%Y-%m-%d %H:%M')
endtime =datetime.strptime(str(data['endtime']), '%Y-%m-%d %H:%M')
obj = Checktask()
obj.checktaskname = data['checktaskname']
obj.checktime=starttime
obj.checkplace=data['checkplace']
obj.zxstate=data['zxstate']
obj.tasktype=7#专项检查
obj.checktype =Checktable.objects.get(id=data['checktabtitle'])
obj.createuser = User.objects.get(userid=userid)
obj.usecomp=Partment.objects.get(partid=companyid)
obj.userlist=data['participant'].split(',')
obj.save()
list = data['participant'].split(',')
s=[]
for i in list:
x = User.objects.get(userid=i)
obj.checkname.add(x)
objs = Checkjob()
objs.checktask=obj
objs.checkname=x
objs.taskstate=4
objs.starttime=starttime
objs.endtime=endtime
objs.usecomp=Partment.objects.get(partid=companyid)
objs.save()
s.append(x.openid)
postdict = {
'touser': '',
'template_id': 'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
"miniprogram": {"appid": "wx5c39b569f01c27db"},
'data': {
'first': {
'value': '检查任务通知:'
},
'keyword1': {
'value':'任务名:'+ obj.checktaskname
},
'keyword2': {
'value': '执行时间:'+str(data['starttime'])
},
'keyword3': {
'value': '发布人:'+obj.createuser.name
},
'remark': {
'value': '请及时查看阅读'
}
}
}
send_wechatmsgs.delay(postdict, s)
return JsonResponse({"code": 1})
#删除
elif a == 'del':
id =req.GET.get('id')
@ -7993,6 +8063,17 @@ def checkprojects(req):
return JsonResponse({"code":0})
elif a == 'deljob':
id =req.GET.get('id')
a = Checkjob.objects.get(id=id)
if a.createuser==User.objects.get(userid=userid):
a.deletemark=0
a.save()
return JsonResponse({"code":1})
else:
return JsonResponse({"code":0})
elif a == 'checkjobdetail':
id = req.GET.get('id')
@ -8025,3 +8106,39 @@ def checkprojects(req):
x = a.values('checktaskname','zxstate','tasktype','checkplace','checktime','checktype__checktitle','checktype__checkcontent')[0]
x['bcfr'] = uselist
return HttpResponse(json.dumps(x, cls=MyEncoder), content_type="application/json")
elif a=='checkstop':
id = req.GET.get('id')
a = Checktask.objects.get(id=id)
if a.createuser==User.objects.get(userid=userid):
a.taskstate=2
a.save()
return JsonResponse({"code":1})
else:
return JsonResponse({"code":0})
#筛选
elif a == 'listsearch':
a = Checkjob.objects.filter(usecomp=Partment.objects.get(
partid=companyid)).exclude(deletemark=0)
qssj = req.GET.get('qssj')#开始时间
jssj = req.GET.get('jssj')#结束时间
checktabtitle = req.GET.get('checktabtitle')#检查表名
checktaskname = req.GET.get('checktaskname')#任务名称
if qssj:
a = a.filter(starttime__gte=qssj)
if jssj:
a = a.filter(starttime__lte=jssj)
if checktabtitle:
a = a.filter(checktask__checktype__id=checktabtitle)
if checktaskname:
a = a.filter(checktask__id=checktaskname)
total = a.count()
startnum, endnum = fenye(req)
a = a.order_by('-starttime')[startnum:endnum].values('id','checktask__checktaskname','jobstate','starttime','endtime','yanshou','checkquestion','zguser__username','zgtime','checktask__checktype__checktitle','checkname__username','checkname__name', 'taskstate','checktask__checktime','createuser__username','createdate')
return HttpResponse(transjson(total, a), content_type="application/json")