导出检查记录详情word
This commit is contained in:
parent
8639e4eae5
commit
82c123ba76
|
@ -2,7 +2,7 @@ from docxtpl import DocxTemplate, InlineImage
|
|||
from docx.shared import Mm, Inches, Pt
|
||||
from openpyxl import Workbook, load_workbook
|
||||
from openpyxl.drawing.image import Image
|
||||
from .models import User,Trouble,Dickey,Partment,Dicclass,Train,Drill,TroubleAccess,Group,Yjyc,ExamPaper,ExamPaperDetail,Question,Operation,Operzyry,Operspxq,Fxcs,Suggest,Suggestflow,Trainuser,Miss
|
||||
from .models import Checkjob, User,Trouble,Dickey,Partment,Dicclass,Train,Drill,TroubleAccess,Group,Yjyc,ExamPaper,ExamPaperDetail,Question,Operation,Operzyry,Operspxq,Fxcs,Suggest,Suggestflow,Trainuser,Miss
|
||||
from datetime import datetime,date
|
||||
import base64
|
||||
import os
|
||||
|
@ -735,6 +735,32 @@ def exportxlsx(a,objs,pic=1):
|
|||
res['Content-Disposition'] = 'attachment;filename='+filename+'.xlsx'
|
||||
res.write(output.getvalue())
|
||||
return res
|
||||
elif a == 'chekjob':
|
||||
#查询数据
|
||||
wb = load_workbook(dirname + 'safesite/exportemp/checkjob.xlsx')
|
||||
sheet = wb.active
|
||||
for i, x in enumerate(objs):
|
||||
num = str(i+3)
|
||||
sheet['a'+num] = x.num
|
||||
sheet['b'+num] = x.name
|
||||
if x.cate:
|
||||
sheet['c'+num] = x.cate.dickeyname
|
||||
sheet['d'+num] = x.type
|
||||
if x.area:
|
||||
sheet['e'+num] = x.area.name
|
||||
sheet['f'+num] = '正常' if x.state==1 else '异常'
|
||||
sheet['g'+num] = 'https://safeyun.ctcshe.com/miniprogram/equipment?id='+str(x.id)
|
||||
|
||||
#开始生成excel
|
||||
sheet['b1'] = datetime.now().strftime('%Y%m%d%H%M%S')
|
||||
filename = '安全检查整改记录'
|
||||
output = BytesIO()
|
||||
wb.save(output)
|
||||
output.seek(0)
|
||||
res = HttpResponse(content_type='application/vnd.ms-excel')
|
||||
res['Content-Disposition'] = 'attachment;filename='+filename+'.xlsx'
|
||||
res.write(output.getvalue())
|
||||
return res
|
||||
|
||||
def exportyjdoc(vl):
|
||||
doc = DocxTemplate(dirname + "safesite/exportemp/fxbg.docx")
|
||||
|
|
Binary file not shown.
|
@ -1360,6 +1360,14 @@ class Checktable(models.Model):
|
|||
|
||||
#检查任务
|
||||
class Checktask(models.Model):
|
||||
tasktype_choice = (
|
||||
(1, '每天一次'),
|
||||
(2, '每周一次'),
|
||||
(3, '每月一次'),
|
||||
(4, '每季度一次'),
|
||||
(5, '每半年一次'),
|
||||
(6, '每年一次'),
|
||||
)
|
||||
id=models.AutoField(primary_key=True)#主键
|
||||
checktaskname=models.CharField(max_length=300)#任务名
|
||||
checktype=models.ForeignKey(Checktable,on_delete=models.CASCADE)#关联检查表
|
||||
|
@ -1370,12 +1378,18 @@ class Checktask(models.Model):
|
|||
createdate = models.DateTimeField(default = timezone.now)#创建时间
|
||||
usecomp = models.ForeignKey(Partment,related_name='taskscomp',on_delete=models.CASCADE,null=True,blank=True)#创建公司
|
||||
deletemark = models.IntegerField(default=1)#是否删除
|
||||
tasktype = models.IntegerField(default=0)#任务执行频率(1每天,2每周,3每月,4每季度,5每半年,6每年)
|
||||
tasktype = models.IntegerField(default=1, choices=tasktype_choice)#任务执行频率(1每天,2每周,3每月,4每季度,5每半年,6每年)
|
||||
userlist = models.TextField(default='')#检查人列表
|
||||
zxstate = models.IntegerField(default=1)#1同时执行,2一个执行就执行
|
||||
taskstate = models.IntegerField(default=1)#是否暂停,1运行,2暂停
|
||||
|
||||
class Checkjob(models.Model):
|
||||
taskstate_choice = (
|
||||
(1, '正在整改中'),
|
||||
(2, '已整改完成'),
|
||||
(3, '任务关闭'),
|
||||
(4, '待执行')
|
||||
)
|
||||
id=models.AutoField(primary_key=True)#主键
|
||||
checktask=models.ForeignKey(Checktask,on_delete=models.CASCADE)#关联任务表
|
||||
checkname=models.ForeignKey(User,related_name='jianchas',on_delete=models.CASCADE)#检查人员
|
||||
|
|
|
@ -138,7 +138,6 @@
|
|||
});
|
||||
function yhsearch() {
|
||||
var querydata = $('#searchyhff').serializeJSON();
|
||||
querydata['a'] = 'listsearch'
|
||||
$('#sdg_job').dialog('close')
|
||||
$('#jobtab').datagrid('load', querydata);
|
||||
|
||||
|
@ -146,7 +145,7 @@
|
|||
function reset() {
|
||||
$('#searchyhff').form('clear')
|
||||
$('#jobtab').datagrid('options').queryParams = {
|
||||
a:'listall'
|
||||
a:'listall4'
|
||||
}
|
||||
$('#jobtab').datagrid('load');
|
||||
|
||||
|
|
|
@ -6,8 +6,9 @@
|
|||
<a id="yanshou" onclick="yanshou()" class="easyui-linkbutton" data-options="iconCls: 'fa-download'">验收</a>
|
||||
{{/if}}
|
||||
<a iconCls="fa-close" class="easyui-linkbutton" onclick="closeForm()">关闭</a>
|
||||
<a iconCls="fa-download" class="easyui-linkbutton" onclick="exportcheckjobword()" data-options="{ iconCls: 'fa-download'}">导出</a>
|
||||
</div>
|
||||
<div data-options="region:'center'" style="height:100%;padding:15px 15px;">
|
||||
<div data-options="region:'center'" style="height:100%;padding:15px 15px;" id="checkjobdiv">
|
||||
<div style="text-align:center;font-size: 24px;font-weight: bold;margin-bottom: 20px;">{{checktask__checktaskname}}</div>
|
||||
<table class='detailtable' style="text-align:center;">
|
||||
<tr>
|
||||
|
@ -211,4 +212,7 @@
|
|||
}
|
||||
});
|
||||
}
|
||||
function exportcheckjobword(e) {
|
||||
$("#checkjobdiv").wordExport('安全检查整改记录');
|
||||
}
|
||||
</script>
|
|
@ -36,9 +36,9 @@
|
|||
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;
|
||||
<input id="checktabtitlex" class="easyui-textbox" name="checktabtitle" style=" width: 480px;
|
||||
height: 40px
|
||||
" data-options="label:'检查项目'" required=true />
|
||||
" 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;
|
||||
|
@ -55,7 +55,7 @@
|
|||
|
||||
|
||||
$(function () {
|
||||
$("#checktabtitle").combobox({
|
||||
$("#checktabtitlex").combobox({
|
||||
url: 'api/checkproject?a=checktablist',
|
||||
valueField: 'value',
|
||||
textField: 'text',
|
||||
|
|
|
@ -8659,6 +8659,9 @@ def checkprojects(req):
|
|||
|
||||
return HttpResponse(transjson(total, a), content_type="application/json")
|
||||
elif a == 'listall3':
|
||||
"""
|
||||
任务分配列表
|
||||
"""
|
||||
startnum,endnum = fenye(req)
|
||||
a = Checktask.objects.filter(usecomp=Partment.objects.get(partid=companyid), deletemark=1).order_by('-createdate')
|
||||
total = a.count()
|
||||
|
@ -8668,8 +8671,27 @@ def checkprojects(req):
|
|||
|
||||
return HttpResponse(transjson(total, a), content_type="application/json")
|
||||
elif a == 'listall4':
|
||||
"""
|
||||
检查工作列表
|
||||
"""
|
||||
startnum,endnum = fenye(req)
|
||||
a = Checkjob.objects.filter(usecomp=Partment.objects.get(partid=companyid),checkname__userid=userid,deletemark=1).order_by('-starttime')
|
||||
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')#任务名称
|
||||
checkername = req.GET.get('checkername', None)
|
||||
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)
|
||||
if checkername:
|
||||
a = a.filter(checkname__name=checkername)
|
||||
total = a.count()
|
||||
startnum, endnum = fenye(req)
|
||||
|
||||
|
@ -9041,6 +9063,44 @@ def checkprojects(req):
|
|||
return HttpResponse(transjson(total, a), content_type="application/json")
|
||||
|
||||
|
||||
def apicheckjob(req):
|
||||
a = req.GET.get('a')
|
||||
userid = req.session['userid']
|
||||
companyid = getcompany(userid)
|
||||
if a == 'exportexcel':
|
||||
"""
|
||||
检查工作列表导出
|
||||
"""
|
||||
objs = Checkjob.objects.filter(usecomp=Partment.objects.get(
|
||||
partid=companyid)).exclude(deletemark=0)
|
||||
qssj = req.GET.get('qssj', None)#开始时间
|
||||
jssj = req.GET.get('jssj', None)#结束时间
|
||||
checktabtitle = req.GET.get('checktabtitle', None)#检查表名
|
||||
checktaskname = req.GET.get('checktaskname', None)#任务名称
|
||||
checkername = req.GET.get('checkername', None)
|
||||
if qssj:
|
||||
objs = objs.filter(starttime__gte=qssj)
|
||||
if jssj:
|
||||
objs = objs.filter(starttime__lte=jssj)
|
||||
if checktabtitle:
|
||||
objs = objs.filter(checktask__checktype__id=checktabtitle)
|
||||
if checktaskname:
|
||||
objs = objs.filter(checktask__id=checktaskname)
|
||||
if checkername:
|
||||
objs = objs.filter(checkname__name=checkername)
|
||||
total = objs.count()
|
||||
if total > 200:
|
||||
res = HttpResponse()
|
||||
res.write('数量超过200,请筛选后导出!')
|
||||
return res
|
||||
objs = objs.order_by('-starttime').values('id','checktask__checktaskname','jobstate',
|
||||
'starttime','endtime','yanshou','checkquestion','zguser__username','zgtime','yanshouren__name'
|
||||
'checktask__checktype__checktitle','checkname__username','checkname__name',
|
||||
'taskstate','checktask__checktime','createuser__username','createdate', 'taskstate__display', 'checktask__tasktype__display')
|
||||
# res = exportxlsx('checkjob', objs)
|
||||
# return res
|
||||
|
||||
|
||||
|
||||
@apicheck_login
|
||||
def apioffence(req):
|
||||
|
|
Loading…
Reference in New Issue