修正任务日志状态显示和搜索,修正异常日志列表显示字节为0

This commit is contained in:
george
2018-08-09 10:45:40 +08:00
parent 43008e4084
commit 985020b424
3 changed files with 55 additions and 14 deletions

View File

@@ -56,16 +56,15 @@ func (self *TaskLogController) Table() {
}
TextStatus := []string{
"<font color='orange'><i class='fa fa-question-circle'></i> 超时</font>",
"<font color='red'><i class='fa fa-times-circle'></i> 错误</font>",
"<font color='green'><i class='fa fa-check-square'></i> 正常</font>",
"<font color='red'><i class='fa fa-question-circle'></i> 未知</font>",
}
Status, err := self.GetInt("status")
if err == nil && Status != 9 {
status := Status + 1
filters = append(filters, "status", status)
filters = append(filters, "status", Status)
}
filters = append(filters, "task_id", taskId)
@@ -78,9 +77,13 @@ func (self *TaskLogController) Table() {
row["task_id"] = v.TaskId
row["start_time"] = beego.Date(time.Unix(v.CreateTime, 0), "Y-m-d H:i:s")
row["process_time"] = float64(v.ProcessTime) / 1000
row["ouput_size"] = libs.SizeFormat(float64(len(v.Output)))
index := v.Status + 1
if index > 1 {
if v.Status == 0 {
row["output_size"] = libs.SizeFormat(float64(len(v.Output)))
} else {
row["output_size"] = libs.SizeFormat(float64(len(v.Error)))
}
index := v.Status + 2
if index > 2 {
index = 2
}
row["status"] = TextStatus[index]
@@ -101,21 +104,26 @@ func (self *TaskLogController) Detail() {
return
}
LogTextStatus := []string{
"<font color='orange'><i class='fa fa-question-circle'></i>超时</font>",
"<font color='red'><i class='fa fa-times-circle'></i> 错误</font>",
"<font color='green'><i class='fa fa-check-square'></i> 正常</font>",
"<font color='red'><i class='fa fa-question-circle'></i> 未知</font>",
}
row := make(map[string]interface{})
row["id"] = tasklog.Id
row["task_id"] = tasklog.TaskId
row["start_time"] = beego.Date(time.Unix(tasklog.CreateTime, 0), "Y-m-d H:i:s")
row["process_time"] = float64(tasklog.ProcessTime) / 1000
row["ouput_size"] = libs.SizeFormat(float64(len(tasklog.Output)))
row["ouput"] = tasklog.Output
if tasklog.Status == 0 {
row["output_size"] = libs.SizeFormat(float64(len(tasklog.Output)))
} else {
row["output_size"] = libs.SizeFormat(float64(len(tasklog.Error)))
}
row["output"] = tasklog.Output
row["error"] = tasklog.Error
index := tasklog.Status + 1
if index > 1 {
index := tasklog.Status + 2
if index > 2 {
index = 2
}
row["status"] = LogTextStatus[index]
@@ -178,6 +186,12 @@ func (self *TaskLogController) Detail() {
updateName = admin.RealName
}
}
//是否出错通知
self.Data["adminInfo"] = []int{0}
if task.NotifyUserIds != "0" && task.NotifyUserIds != "" {
self.Data["adminInfo"] = AllAdminInfo(task.NotifyUserIds)
}
self.Data["CreateName"] = createName
self.Data["UpdateName"] = updateName
self.Data["pageTitle"] = "日志详细" + "(#" + strconv.Itoa(id) + ")"

View File

@@ -144,6 +144,31 @@
<td></td>
</tr>
<tr>
<td>出错通知</td>
<td>{{if eq .task.IsNotify 0}}{{end}} {{if eq .task.IsNotify 1}}{{end}}</td>
<td></td>
</tr>
{{if eq .task.IsNotify 1}}
<tr>
<td>通知类型</td>
<td>{{if eq .task.NotifyType 1}}短信{{end}} {{if eq .task.NotifyType 0}}邮件{{end}}</td>
<td></td>
</tr>
<tr>
<td>通知用户</td>
<td>
{{range $k, $v := .adminInfo}}
{{$v.RealName}} &nbsp;&nbsp;&nbsp;
{{end}}
</td>
<td></td>
</tr>
{{end}}
<tr>
<td>创建时间</td>
<td>{{.CreateTime}}</td>

View File

@@ -9,8 +9,10 @@
<div class="layui-inline" style="width: 20%;text-align: left">
<select name="status" lay-filter="status">
<option value="9">全部</option>
<option value="-1">正常</option>
<option value="-2">错误</option>
<option value="0">正常</option>
<option value="-1">错误</option>
<option value="-2">超时</option>
</select>
</div>
<button class="layui-btn" data-type="reload" id="reload">查询</button>
@@ -48,7 +50,7 @@
,{field:'task_id', title: '任务ID', align:'center',sort: true, width:150}
,{field:'start_time',title: '开始时间'}
,{field:'process_time',width:100, title: '执行时间'}
,{field:'ouput_size',title: '输出'}
,{field:'output_size',title: '输出'}
,{field:'status', width:170,title: '状态'}
,{fixed: 'right', align:'center', title:'操作', toolbar: '#bar'}
]]