完成服务器监控
This commit is contained in:
parent
08044640a7
commit
155afa715d
|
|
@ -14,6 +14,7 @@ import com.ruoyi.dfm.service.UserService;
|
|||
import com.ruoyi.dfm.util.TimeUtil;
|
||||
import com.ruoyi.framework.util.ShiroUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.aspectj.weaver.loadtime.Aj;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -853,42 +854,48 @@ public class ProjectController extends com.ruoyi.common.core.controller.BaseCont
|
|||
throws Exception
|
||||
{
|
||||
List servers = this.projectService.getAllServers();
|
||||
String server = req.getParameter("server");
|
||||
if ((server == null) && (servers != null))
|
||||
{
|
||||
server = (String)servers.get(0);
|
||||
}
|
||||
if ((server != null) || ("".equals(server)))
|
||||
{
|
||||
server = new String(server.getBytes("iso-8859-1"), "utf-8");
|
||||
Project project = this.projectService.getProjectByServerState(server, "在查");
|
||||
if (project != null)
|
||||
{
|
||||
int pid = project.getId();
|
||||
List stages = this.projectService.getStagesByProject(pid);
|
||||
req.setAttribute("project", project);
|
||||
req.setAttribute("stages", stages);
|
||||
}
|
||||
}
|
||||
req.setAttribute("servers", servers);
|
||||
req.setAttribute("server", server);
|
||||
return new ModelAndView("serverMonitor");
|
||||
return new ModelAndView("dfm/serverMonitor");
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/serverMonitor/list")
|
||||
@ResponseBody
|
||||
public AjaxResult serverMonitorList(HttpServletRequest req, HttpServletResponse res)
|
||||
throws Exception
|
||||
{
|
||||
String server = req.getParameter("server");
|
||||
if (StringUtils.isBlank(server)) {
|
||||
return AjaxResult.success();
|
||||
}
|
||||
server = new String(server.getBytes("iso-8859-1"), "utf-8");
|
||||
Project project = this.projectService.getProjectByServerState(server, "在查");
|
||||
if (project != null) {
|
||||
int pid = project.getId();
|
||||
List stages = this.projectService.getStagesByProject(pid);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("project", project);
|
||||
jsonObject.put("stages", stages);
|
||||
return AjaxResult.success(jsonObject);
|
||||
}
|
||||
return AjaxResult.error();
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/stopProject")
|
||||
public void stopProject(HttpServletRequest req, HttpServletResponse res)
|
||||
@ResponseBody
|
||||
public AjaxResult stopProject(HttpServletRequest req, HttpServletResponse res)
|
||||
throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
String pid = req.getParameter("pid");
|
||||
this.projectService.stopProject(pid);
|
||||
String server = new String(req.getParameter("server").getBytes("iso-8859-1"), "utf-8");
|
||||
outputMsg(res, "<script>document.location.href='project.do?method=serverMonitor&server=" + server + "';</script>");
|
||||
return AjaxResult.success();
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.error("中止项目失败!", e);
|
||||
outputMsg(res, "<script>alert('中止项目失败,请联系管理员!');window.history.go(-1);</script>");
|
||||
return AjaxResult.error();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,9 +46,6 @@
|
|||
</div>
|
||||
|
||||
<div class="btn-group-sm" id="toolbar" role="group">
|
||||
<!--<a class="btn btn-success" onclick="$.operate.addTab()" >-->
|
||||
<!--<i class="fa fa-plus"></i> 新增-->
|
||||
<!--</a>-->
|
||||
<a class="btn btn-danger multiple disabled" onclick="$.operate.pauseProject(-1)" >
|
||||
<i class="fa fa-edit"></i> 暂停
|
||||
</a>
|
||||
|
|
@ -58,9 +55,6 @@
|
|||
<a class="btn btn-danger multiple disabled" onclick="$.operate.startAllProjects()" >
|
||||
<i class="fa fa-play"></i> 开始
|
||||
</a>
|
||||
<!--<a class="btn btn-warning" onclick="$.table.exportExcel()" >-->
|
||||
<!--<i class="fa fa-download"></i> 导出-->
|
||||
<!--</a>-->
|
||||
</div>
|
||||
|
||||
<div class="col-sm-12 select-table table-striped">
|
||||
|
|
@ -196,19 +190,12 @@
|
|||
} else {
|
||||
pauseOperType = "暂停";
|
||||
}
|
||||
// actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.roleId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
|
||||
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="$.operate.remove(' + row.id + ')"><i class="fa fa-remove"></i>删除</a> ');
|
||||
if("继续" == pauseOperType) {
|
||||
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="$.operate.restoreProject(' + row.id + ')"><i class="fa fa-edit"></i>' + pauseOperType + '</a> ');
|
||||
} else if("暂停" == pauseOperType) {
|
||||
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="$.operate.pauseProject(' + row.id + ')"><i class="fa fa-edit"></i>' + pauseOperType + '</a> ');
|
||||
}
|
||||
|
||||
|
||||
// var more = [];
|
||||
// more.push("<a class='btn btn-default btn-xs " + editFlag + "' href='javascript:void(0)' onclick='authDataScope(" + row.roleId + ")'><i class='fa fa-check-square-o'></i>数据权限</a> ");
|
||||
// more.push("<a class='btn btn-default btn-xs " + editFlag + "' href='javascript:void(0)' onclick='authUser(" + row.roleId + ")'><i class='fa fa-user'></i>分配用户</a>");
|
||||
// actions.push('<a tabindex="0" class="btn btn-info btn-xs" role="button" data-container="body" data-placement="left" data-toggle="popover" data-html="true" data-trigger="hover" data-content="' + more.join('') + '"><i class="fa fa-chevron-circle-right"></i>更多操作</a>');
|
||||
return actions.join('');
|
||||
}
|
||||
}
|
||||
|
|
@ -220,7 +207,6 @@
|
|||
//下载文件
|
||||
function getFile(fid)
|
||||
{
|
||||
// document.location.href='file.do/download?fid=' + fid;
|
||||
var url = ctx + 'file.do/download?fid=' + fid;
|
||||
window.location.href = url;
|
||||
}
|
||||
|
|
@ -228,7 +214,6 @@
|
|||
//下载参数文件
|
||||
function getParamFile(fid,fname)
|
||||
{
|
||||
// document.location.href='project.do/downloadParamFile&fid=' + fid + '&fname=' + encodeURI(fname);
|
||||
var url = ctx + 'project.do/downloadParamFile?fid=' + fid + '&fname=' + encodeURI(fname);
|
||||
window.location.href = url;
|
||||
}
|
||||
|
|
@ -237,12 +222,7 @@
|
|||
//上调优先级
|
||||
function changePri( pid,change )
|
||||
{
|
||||
|
||||
$.operate.changeProjectPri(pid, change);
|
||||
// document.location.href='project.do/changePri?pid='
|
||||
// + pid +
|
||||
// '&change='+change +
|
||||
// '¤tPage=<%=myPage.getCurrentPage()%>';
|
||||
}
|
||||
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,160 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
|
||||
<head>
|
||||
<th:block th:include="include :: header('服务器监控')" />
|
||||
</head>
|
||||
<body class="gray-bg">
|
||||
<div class="container-div">
|
||||
<div class="row">
|
||||
<div class="col-sm-12 search-collapse">
|
||||
<div class="select-list">
|
||||
<ul>
|
||||
<li>
|
||||
<strong>服务器:</strong>
|
||||
<select name="server" onchange='getProject(this.value)'>
|
||||
<option value="-1">--请选择--</option>
|
||||
<option th:each="server : ${servers}" th:text="${server}" th:value="${server}"></option>
|
||||
</select>
|
||||
</li>
|
||||
<li>
|
||||
<strong>状态:</strong><span id="state">-</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="btn-group-sm" id="toolbar" role="group">
|
||||
<strong>当前任务:</strong><span id="projectName">-</span>
|
||||
<strong>版本:</strong><span id="version">-</span>
|
||||
<strong>提交人:</strong><span id="submitUserName">-</span>
|
||||
<strong>提交时间:</strong><span id="submitTime">-</span>
|
||||
<strong>任务类型:</strong><span id="checkType">-</span>
|
||||
<span id="stopOperation"></span>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-12 select-table table-striped">
|
||||
<table id="bootstrap-table"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<th:block th:include="include :: footer" />
|
||||
<script th:inline="javascript">
|
||||
|
||||
var prefix = ctx + "project.do";
|
||||
|
||||
$(function() {
|
||||
var options = {
|
||||
sortName: "roleSort",
|
||||
modalName: "服务器监控",
|
||||
pagination: false,
|
||||
columns: [
|
||||
{
|
||||
field: 'id',
|
||||
visible: false
|
||||
},
|
||||
{
|
||||
field: 'stageOrder',
|
||||
title: '序号',
|
||||
sortable: false
|
||||
},
|
||||
{
|
||||
field: 'stageName',
|
||||
title: '运行阶段',
|
||||
sortable: false
|
||||
},
|
||||
{
|
||||
field: 'statrTime',
|
||||
title: '开始时间',
|
||||
sortable: false
|
||||
},
|
||||
{
|
||||
field: 'endTime',
|
||||
title: '完成时间',
|
||||
sortable: false
|
||||
},
|
||||
{
|
||||
field: 'costTime',
|
||||
title: '耗时(分钟)',
|
||||
sortable: false
|
||||
}
|
||||
]
|
||||
};
|
||||
$.table.init(options);
|
||||
});
|
||||
|
||||
|
||||
function getProject(v) {
|
||||
if ("-1" == v || -1 == v) {
|
||||
fillParams(null);
|
||||
$('#bootstrap-table').bootstrapTable('load',[]);
|
||||
return;
|
||||
}
|
||||
$.ajax({
|
||||
url: prefix + "/serverMonitor/list",
|
||||
data: "server=" + v,
|
||||
cache: false,
|
||||
success: function (json) {
|
||||
if (null == json || "" == json || json.code != 0) {
|
||||
//失败
|
||||
fillParams(null);
|
||||
//清空表格
|
||||
$('#bootstrap-table').bootstrapTable('load',[]);
|
||||
} else {
|
||||
//成功
|
||||
fillParams(json.data.project);
|
||||
if(null == json.data.stages || json.data.stages.length<1) {
|
||||
$('#bootstrap-table').bootstrapTable('load',[]);
|
||||
} else {
|
||||
$('#bootstrap-table').bootstrapTable('load', json.data.stages);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
// document.location.href = 'project.do?method=serverMonitor&server=' + v;
|
||||
}
|
||||
|
||||
function fillParams(project) {
|
||||
if(null == project) {
|
||||
$("#projectName").html("-");
|
||||
$("#version").html("-");
|
||||
$("#submitUserName").html("-");
|
||||
$("#submitTime").html("-");
|
||||
$("#checkType").html("-");
|
||||
$("#stopOperation").hide();
|
||||
$("#state").html("<span style='color:green;'>空闲</span>");
|
||||
} else {
|
||||
$("#projectName").html(project.projectName);
|
||||
$("#version").html(project.version);
|
||||
$("#submitUserName").html(project.submitUserName);
|
||||
$("#submitTime").html(project.submitTime);
|
||||
$("#checkType").html(project.checkTypeStr);
|
||||
var stopOperationHtml = "<a class=\"btn btn-danger single\" onclick=\"stopProject("+project.id+");\" ><i class=\"fa fa-stop\"></i> 中止</a>";
|
||||
$("#stopOperation").html(stopOperationHtml);
|
||||
$("#state").html("<span style='color:red;'>忙</span>");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function stopProject(v) {
|
||||
if ("-1" == v || -1 == v) {
|
||||
return false;
|
||||
}
|
||||
$.ajax({
|
||||
url: prefix + "/stopProject",
|
||||
data: "pid=" + v,
|
||||
cache: false,
|
||||
success: function (json) {
|
||||
if (null == json || "" == json || json.code != 0) {
|
||||
$.modal.alertError("中止项目失败");
|
||||
} else {
|
||||
$.modal.alertSuccess("中止项目成功");
|
||||
}
|
||||
}
|
||||
});
|
||||
// document.location.href = 'project.do?method=stopProject&pid=' + pid + '&server=' + server;
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -13,7 +13,9 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -597,9 +599,29 @@ public class ProjectDAO extends JdbcBaseDao
|
|||
ProjectStage stage = new ProjectStage();
|
||||
stage.setStageName((map.get("F_STAGE_NAME") == null) ? "" : map.get("F_STAGE_NAME").toString());
|
||||
stage.setId((map.get("F_ID") == null) ? 0 : Integer.parseInt(map.get("F_ID").toString()));
|
||||
stage.setEndTime((map.get("F_END_TIME") == null) ? "" : map.get("F_END_TIME").toString());
|
||||
stage.setId((map.get("F_PROJECT_ID") == null) ? 0 : Integer.parseInt(map.get("F_PROJECT_ID").toString()));
|
||||
stage.setStatrTime((map.get("F_START_TIME") == null) ? "" : map.get("F_START_TIME").toString());
|
||||
|
||||
String startTime = (map.get("F_START_TIME") == null) ? "" : map.get("F_START_TIME").toString();
|
||||
if(!"".equalsIgnoreCase(startTime) ){
|
||||
stage.setStatrTime(TimeUtil.getDateStrByFormat(startTime,"yyyy-MM-dd HH:mm:ss"));
|
||||
}
|
||||
String endTime = (map.get("F_END_TIME") == null) ? "" : map.get("F_END_TIME").toString();
|
||||
if(!"".equalsIgnoreCase(endTime) ){
|
||||
stage.setEndTime(TimeUtil.getDateStrByFormat(endTime,"yyyy-MM-dd HH:mm:ss"));
|
||||
}
|
||||
|
||||
try {
|
||||
Date start = TimeUtil.toUtilDateFromStrDateByFormat(startTime,"yyyyMMddHHmmss");
|
||||
Date end = TimeUtil.toUtilDateFromStrDateByFormat(endTime,"yyyyMMddHHmmss");
|
||||
Long start1 = TimeUtil.getMillisOfDate(start);
|
||||
Long end1 = TimeUtil.getMillisOfDate(end);
|
||||
Long m = (end1 - start1)/60000;
|
||||
Long s = (end1 - start1)%60000/1000;
|
||||
stage.setCostTime(m+"分钟"+s+"秒");
|
||||
} catch (ParseException e) {
|
||||
logger.error("计算耗时失败", e);
|
||||
}
|
||||
|
||||
stage.setStageOrder((map.get("F_STAGE_ORDER") == null) ? 0 : Integer.parseInt(map.get("F_STAGE_ORDER").toString()));
|
||||
rs.add(stage);
|
||||
}
|
||||
|
|
@ -608,8 +630,7 @@ public class ProjectDAO extends JdbcBaseDao
|
|||
}
|
||||
|
||||
public void stop(String pid) {
|
||||
String sql = "update t_project set F_CANCEL= 1 where f_id = " +
|
||||
pid;
|
||||
String sql = "update t_project set F_CANCEL= 1 where f_id = " + pid;
|
||||
getJdbcTemplate().update(sql);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ public class ProjectStage implements Serializable {
|
|||
private int stageOrder;
|
||||
private String statrTime;
|
||||
private String endTime;
|
||||
private String costTime;
|
||||
private int projectId;
|
||||
public int getId() {
|
||||
return id;
|
||||
|
|
@ -48,6 +49,11 @@ public class ProjectStage implements Serializable {
|
|||
this.projectId = projectId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getCostTime() {
|
||||
return costTime;
|
||||
}
|
||||
|
||||
public void setCostTime(String costTime) {
|
||||
this.costTime = costTime;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue