监控系统服务修改

parent dc0463be
......@@ -3,11 +3,13 @@ package com.cc;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
@MapperScan(value = "com.cc.mapper")
@SpringBootApplication
@EnableScheduling
@EnableAsync
public class XzxtControlApplication {
public static void main(String[] args) {
......
package com.cc.common;
import com.cc.bean.Services;
import com.cc.bean.ServicesRest;
import com.cc.service.ServiceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
/**
* Created by changc on 2018/9/11.
*/
@Slf4j
@Component
public class ServiceReport {
@Scheduled(cron = "0/2 * * * * *")
public void work() {
//获取当前时间
LocalDateTime localDateTime = LocalDateTime.now();
System.out.println("当前时间为:" + localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
/* @Autowired
private ServiceService serviceService;
//心跳机制
@Scheduled(cron = "0/5 * * * * *")
@Async("taskExecutor")
public void ServiceReport(){
System.out.print("心跳开始------------------------------------》");
List<Services> ServiceList= (List<Services>) serviceService.SelectServiceList().getData();
for(Services services:ServiceList){
log.info("=====>>>>>使用cron {}",services.getId());
}
}*/
}
package com.cc.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.Executor;
/**
* Created by changc on 2018/9/12.
*/
@Configuration
@EnableAsync
public class AsyncConfig {
/*
此处成员变量应该使用@Value从配置中读取
*/
@Value("${ThreadPool.corePoolSize}")
private int corePoolSize;
@Value("${ThreadPool.maxPoolSize}")
private int maxPoolSize;
@Value("${ThreadPool.queueCapacity}")
private int queueCapacity;
@Bean
public Executor taskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(corePoolSize);
executor.setMaxPoolSize(maxPoolSize);
executor.setQueueCapacity(queueCapacity);
executor.initialize();
return executor;
}
}
......@@ -5,6 +5,7 @@ import java.util.List;
public interface ServiceMapper {
List<Services> selectPageList(Services service);
List<Services> selectServiceList();
int selectPageCount(Services service);
Services selectServices(int id);
int saveService(Services service);
......
......@@ -19,11 +19,11 @@ public interface ServiceService {
* @return
*/
ResultMap ServiceAll(Services service);
XzxtRestResult SelectServiceList();
XzxtRestResult SelectServices(int id);
XzxtRestResult SaveService(Services service);
XzxtRestResult updateService(Services service);
XzxtRestResult updateServiceByid(int id,int status);
XzxtRestResult deleteService(int id);
XzxtRestResult reportSerives();
}
......@@ -37,6 +37,15 @@ public class ServiceIServiceImpl implements ServiceService {
}
@Override
public XzxtRestResult SelectServiceList() {
List<Services> serviceslist=serviceMapper.selectServiceList();
if(!StringUtils.isEmpty(serviceslist)){
return XzxtRestResult.build(201,"读取成功",serviceslist);
}else{
return XzxtRestResult.build(202,"读取失败","");
}
}
@Override
public XzxtRestResult SaveService(Services service) {
int num=serviceMapper.saveService(service);
if(num==1){
......@@ -86,13 +95,6 @@ public class ServiceIServiceImpl implements ServiceService {
}
}
@Override
public XzxtRestResult reportSerives() {
//获取当前时间
LocalDateTime localDateTime = LocalDateTime.now();
System.out.println("当前时间为:" + localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
return null;
}
}
......@@ -43,5 +43,11 @@ service-rest:
startTomcatName: "startTomcat.sh"
stopTomcatName: "shutTomcat.sh"
reportTomcatName: "reportTomcat.sh"
ThreadPool:
#核心线程数
corePoolSize: 20
#最大线程数
maxPoolSize: 200
#任务队列容量(阻塞队列)
queueCapacity: 10
......@@ -26,6 +26,13 @@
</if>
</where>
</sql>
<!-- 查询所有的服务-->
<select id="selectServiceList" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from service
</select>
<!-- 通过条件分页查询,返回数据集 -->
<select id="selectPageList" parameterType="com.cc.bean.Services" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
......
......@@ -34,7 +34,6 @@
</div>
</div>
<%--<table class="layui-hide" id="test" lay-filter="test"></table>--%>
<script type="text/html" id="toolbarDemo">
<div class="layui-btn-container">
......@@ -46,17 +45,18 @@
</script>
<script type="text/html" id="barDemo">
{{# if (d.status=== 0) { }}
{{# if (d.status=== 1) { }}
<a class="layui-btn layui-btn-xs" lay-event="start">启动</a>
{{# } else { }}
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="stop">停止</a>
{{# } }}
</script>
<script type="text/html" id="barDemo1">
{{# if (d.status=== 0) { }}
<i class="fa fa-circle fa-color2"></i>
{{# } else { }}
{{# if (d.status=== 0) {}}
<i class="fa fa-circle fa-color1"></i>
{{# } else { }}
<i class="fa fa-circle fa-color2"></i>
{{# } }}
</script>
<script type="text/html" id="barDemo2">
......@@ -121,7 +121,10 @@
shadeClose: true,
shade: 0.8,
area: ['500px', '90%'],
content: '/serviceform'
content: '/serviceform',
end:function(){
$('.layui-laypage-btn').click();//模拟点击
}
});
break;
//更新
......@@ -137,7 +140,10 @@
shadeClose: true,
shade: 0.8,
area: ['500px', '90%'],
content: '/services/'+data[0].id
content: '/services/'+data[0].id,
end:function(){
$('.layui-laypage-btn').click();//模拟点击
}
});
}
else
......@@ -162,7 +168,7 @@
if (data.status == "201") {
layer.msg("删除成功");
layer.close(index);
window.parent.location.reload(); //刷新父页面
$('.layui-laypage-btn').click();//模拟点击
} else {
layer.close(index);
layer.msg("删除失败");
......@@ -217,11 +223,12 @@
dataType: "json",
success: function(data){
console.log(data);
if(data.data=="0"){
if(data.data=="success"){
debugger;
layer.close(index);
layer.msg("启动成功");
updateStatus(id,1);
window.location.reload();
updateStatus(id,0);
$(".layui-laypage-btn").click();
}else{
layer.close(index);
layer.msg("启动失败");
......@@ -244,11 +251,12 @@
dataType: "json",
success: function(data){
console.log(data);
if(data.data=="0"){
if(data.data=="success"){
debugger;
layer.close(index);
layer.msg("关闭成功");
updateStatus(id,0);
window.location.reload();
updateStatus(id,1);
$(".layui-laypage-btn").click();
}else{
layer.close(index);
layer.msg("关闭失败");
......@@ -258,14 +266,9 @@
}})
}
});
/*$(document).on("click",".layui-form-checkbox",function () {
if($(this).hasClass("layui-form-checked")){
$(this).removeClass("layui-form-checked");
}else{
$(this).addClass("layui-form-checked");
}
})*/
});
//更新服务状态
function updateStatus (id,status) {
$.ajax({
......@@ -273,7 +276,8 @@
url: "/updateservices/"+id+"/"+status,
dataType: "json",
success: function(data){
if(data.data=="0"){
debugger;
if(data.status==201){
layer.msg("状态修改成功");
}else{
layer.msg("状态修改失败");
......@@ -281,6 +285,14 @@
}
});
}
$(function(){
// 开启定时任务,时间间隔为3000 ms。
setInterval(function(){
//window.location.reload();
//当前页的刷新
$(".layui-laypage-btn").click();
}, 3000);
});
</script>
......
......@@ -98,7 +98,7 @@
<div class="layui-form-item" style="display: none">
<label class="layui-form-label">状态:</label>
<div class="layui-input-block">
<input type="text" name="status" value="0" placeholder="请输入应用服务器端口" autocomplete="off" class="layui-input">
<input type="text" name="status" value="1" placeholder="请输入应用服务器端口" autocomplete="off" class="layui-input">
</div>
</div>
<%-- <div class="layui-form-item">
......@@ -163,7 +163,7 @@
layer.msg("保存成功");
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);//关闭当前页
window.parent.location.reload(); //刷新父页面
//window.parent.location.reload(); //刷新父页面
}else{
//layer.close(index);
layer.msg("保存失败");
......
......@@ -168,7 +168,6 @@
layer.msg("修改成功");
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);//关闭当前页
window.parent.location.reload(); //刷新父页面
}else{
//layer.close(index);
layer.msg("修改失败");
......
......@@ -2,6 +2,8 @@ package com.cc;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
......@@ -11,6 +13,18 @@ public class XzxtControlApplicationTests {
@Test
public void contextLoads() {
//记录器
Logger logger = LoggerFactory.getLogger(getClass());
//System.out.println();
//日志的级别;
//由低到高 trace<debug<info<warn<error
//可以调整输出的日志级别;日志就只会在这个级别以以后的高级别生效
logger.trace("这是trace日志...");
logger.debug("这是debug日志...");
//SpringBoot默认给我们使用的是info级别的,没有指定级别的就用SpringBoot默认规定的级别;root级别
logger.info("这是info日志...");
logger.warn("这是warn日志...");
logger.error("这是error日志...");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment