Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xzxt-control
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
常超
xzxt-control
Commits
e589cfa9
Commit
e589cfa9
authored
Sep 15, 2018
by
chang_chao@founder.com.cn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
监控系统服务修改
parent
dc0463be
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
135 additions
and
39 deletions
+135
-39
src/main/java/com/cc/XzxtControlApplication.java
+2
-0
src/main/java/com/cc/common/ServiceReport.java
+23
-5
src/main/java/com/cc/config/AsyncConfig.java
+35
-0
src/main/java/com/cc/mapper/ServiceMapper.java
+1
-0
src/main/java/com/cc/service/ServiceService.java
+1
-1
src/main/java/com/cc/service/serviceimpl/ServiceIServiceImpl.java
+9
-7
src/main/resources/application.yml
+7
-1
src/main/resources/mybatis/mapper/ServiceMapper.xml
+7
-0
src/main/webapp/WEB-INF/view/servicefenye.jsp
+34
-22
src/main/webapp/WEB-INF/view/servicefrom.jsp
+2
-2
src/main/webapp/WEB-INF/view/serviceupdate.jsp
+0
-1
src/test/java/com/cc/XzxtControlApplicationTests.java
+14
-0
No files found.
src/main/java/com/cc/XzxtControlApplication.java
View file @
e589cfa9
...
@@ -3,11 +3,13 @@ package com.cc;
...
@@ -3,11 +3,13 @@ package com.cc;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.scheduling.annotation.EnableAsync
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
@MapperScan
(
value
=
"com.cc.mapper"
)
@MapperScan
(
value
=
"com.cc.mapper"
)
@SpringBootApplication
@SpringBootApplication
@EnableScheduling
@EnableScheduling
@EnableAsync
public
class
XzxtControlApplication
{
public
class
XzxtControlApplication
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
...
...
src/main/java/com/cc/common/ServiceReport.java
View file @
e589cfa9
package
com
.
cc
.
common
;
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.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.time.format.DateTimeFormatter
;
import
java.util.List
;
/**
/**
* Created by changc on 2018/9/11.
* Created by changc on 2018/9/11.
*/
*/
@Slf4j
@Component
@Component
public
class
ServiceReport
{
public
class
ServiceReport
{
@Scheduled
(
cron
=
"0/2 * * * * *"
)
/* @Autowired
public
void
work
()
{
private ServiceService serviceService;
//获取当前时间
//心跳机制
LocalDateTime
localDateTime
=
LocalDateTime
.
now
();
@Scheduled(cron = "0/5 * * * * *")
System
.
out
.
println
(
"当前时间为:"
+
localDateTime
.
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
)));
@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());
}
}
}*/
}
}
src/main/java/com/cc/config/AsyncConfig.java
0 → 100644
View file @
e589cfa9
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
;
}
}
src/main/java/com/cc/mapper/ServiceMapper.java
View file @
e589cfa9
...
@@ -5,6 +5,7 @@ import java.util.List;
...
@@ -5,6 +5,7 @@ import java.util.List;
public
interface
ServiceMapper
{
public
interface
ServiceMapper
{
List
<
Services
>
selectPageList
(
Services
service
);
List
<
Services
>
selectPageList
(
Services
service
);
List
<
Services
>
selectServiceList
();
int
selectPageCount
(
Services
service
);
int
selectPageCount
(
Services
service
);
Services
selectServices
(
int
id
);
Services
selectServices
(
int
id
);
int
saveService
(
Services
service
);
int
saveService
(
Services
service
);
...
...
src/main/java/com/cc/service/ServiceService.java
View file @
e589cfa9
...
@@ -19,11 +19,11 @@ public interface ServiceService {
...
@@ -19,11 +19,11 @@ public interface ServiceService {
* @return
* @return
*/
*/
ResultMap
ServiceAll
(
Services
service
);
ResultMap
ServiceAll
(
Services
service
);
XzxtRestResult
SelectServiceList
();
XzxtRestResult
SelectServices
(
int
id
);
XzxtRestResult
SelectServices
(
int
id
);
XzxtRestResult
SaveService
(
Services
service
);
XzxtRestResult
SaveService
(
Services
service
);
XzxtRestResult
updateService
(
Services
service
);
XzxtRestResult
updateService
(
Services
service
);
XzxtRestResult
updateServiceByid
(
int
id
,
int
status
);
XzxtRestResult
updateServiceByid
(
int
id
,
int
status
);
XzxtRestResult
deleteService
(
int
id
);
XzxtRestResult
deleteService
(
int
id
);
XzxtRestResult
reportSerives
();
}
}
src/main/java/com/cc/service/serviceimpl/ServiceIServiceImpl.java
View file @
e589cfa9
...
@@ -37,6 +37,15 @@ public class ServiceIServiceImpl implements ServiceService {
...
@@ -37,6 +37,15 @@ public class ServiceIServiceImpl implements ServiceService {
}
}
@Override
@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
)
{
public
XzxtRestResult
SaveService
(
Services
service
)
{
int
num
=
serviceMapper
.
saveService
(
service
);
int
num
=
serviceMapper
.
saveService
(
service
);
if
(
num
==
1
){
if
(
num
==
1
){
...
@@ -86,13 +95,6 @@ public class ServiceIServiceImpl implements ServiceService {
...
@@ -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
;
}
}
}
src/main/resources/application.yml
View file @
e589cfa9
...
@@ -43,5 +43,11 @@ service-rest:
...
@@ -43,5 +43,11 @@ service-rest:
startTomcatName
:
"
startTomcat.sh"
startTomcatName
:
"
startTomcat.sh"
stopTomcatName
:
"
shutTomcat.sh"
stopTomcatName
:
"
shutTomcat.sh"
reportTomcatName
:
"
reportTomcat.sh"
reportTomcatName
:
"
reportTomcat.sh"
ThreadPool
:
#核心线程数
corePoolSize
:
20
#最大线程数
maxPoolSize
:
200
#任务队列容量(阻塞队列)
queueCapacity
:
10
src/main/resources/mybatis/mapper/ServiceMapper.xml
View file @
e589cfa9
...
@@ -26,6 +26,13 @@
...
@@ -26,6 +26,13 @@
</if>
</if>
</where>
</where>
</sql>
</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
id=
"selectPageList"
parameterType=
"com.cc.bean.Services"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
select
<include
refid=
"Base_Column_List"
/>
...
...
src/main/webapp/WEB-INF/view/servicefenye.jsp
View file @
e589cfa9
...
@@ -34,7 +34,6 @@
...
@@ -34,7 +34,6 @@
</div>
</div>
</div>
</div>
<
%
--
<
table
class=
"layui-hide"
id=
"test"
lay-filter=
"test"
></table>
--%>
<script
type=
"text/html"
id=
"toolbarDemo"
>
<script
type=
"text/html"
id=
"toolbarDemo"
>
<
div
class
=
"layui-btn-container"
>
<
div
class
=
"layui-btn-container"
>
...
@@ -46,17 +45,18 @@
...
@@ -46,17 +45,18 @@
</script>
</script>
<script
type=
"text/html"
id=
"barDemo"
>
<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
>
<
a
class
=
"layui-btn layui-btn-xs"
lay
-
event
=
"start"
>
启动
<
/a
>
{{
#
}
else
{
}}
{{
#
}
else
{
}}
<
a
class
=
"layui-btn layui-btn-danger layui-btn-xs"
lay
-
event
=
"stop"
>
停止
<
/a
>
<
a
class
=
"layui-btn layui-btn-danger layui-btn-xs"
lay
-
event
=
"stop"
>
停止
<
/a
>
{{
#
}
}}
{{
#
}
}}
</script>
</script>
<script
type=
"text/html"
id=
"barDemo1"
>
<script
type=
"text/html"
id=
"barDemo1"
>
{{
#
if
(
d
.
status
===
0
)
{
}}
<
i
class
=
"fa fa-circle fa-color2"
><
/i
>
{{
#
if
(
d
.
status
===
0
)
{}}
{{
#
}
else
{
}}
<
i
class
=
"fa fa-circle fa-color1"
><
/i
>
<
i
class
=
"fa fa-circle fa-color1"
><
/i
>
{{
#
}
else
{
}}
<
i
class
=
"fa fa-circle fa-color2"
><
/i
>
{{
#
}
}}
{{
#
}
}}
</script>
</script>
<script
type=
"text/html"
id=
"barDemo2"
>
<script
type=
"text/html"
id=
"barDemo2"
>
...
@@ -121,7 +121,10 @@
...
@@ -121,7 +121,10 @@
shadeClose
:
true
,
shadeClose
:
true
,
shade
:
0.8
,
shade
:
0.8
,
area
:
[
'500px'
,
'90%'
],
area
:
[
'500px'
,
'90%'
],
content
:
'/serviceform'
content
:
'/serviceform'
,
end
:
function
(){
$
(
'.layui-laypage-btn'
).
click
();
//模拟点击
}
});
});
break
;
break
;
//更新
//更新
...
@@ -137,7 +140,10 @@
...
@@ -137,7 +140,10 @@
shadeClose
:
true
,
shadeClose
:
true
,
shade
:
0.8
,
shade
:
0.8
,
area
:
[
'500px'
,
'90%'
],
area
:
[
'500px'
,
'90%'
],
content
:
'/services/'
+
data
[
0
].
id
content
:
'/services/'
+
data
[
0
].
id
,
end
:
function
(){
$
(
'.layui-laypage-btn'
).
click
();
//模拟点击
}
});
});
}
}
else
else
...
@@ -162,7 +168,7 @@
...
@@ -162,7 +168,7 @@
if
(
data
.
status
==
"201"
)
{
if
(
data
.
status
==
"201"
)
{
layer
.
msg
(
"删除成功"
);
layer
.
msg
(
"删除成功"
);
layer
.
close
(
index
);
layer
.
close
(
index
);
window
.
parent
.
location
.
reload
();
//刷新父页面
$
(
'.layui-laypage-btn'
).
click
();
//模拟点击
}
else
{
}
else
{
layer
.
close
(
index
);
layer
.
close
(
index
);
layer
.
msg
(
"删除失败"
);
layer
.
msg
(
"删除失败"
);
...
@@ -217,11 +223,12 @@
...
@@ -217,11 +223,12 @@
dataType
:
"json"
,
dataType
:
"json"
,
success
:
function
(
data
){
success
:
function
(
data
){
console
.
log
(
data
);
console
.
log
(
data
);
if
(
data
.
data
==
"0"
){
if
(
data
.
data
==
"success"
){
debugger
;
layer
.
close
(
index
);
layer
.
close
(
index
);
layer
.
msg
(
"启动成功"
);
layer
.
msg
(
"启动成功"
);
updateStatus
(
id
,
1
);
updateStatus
(
id
,
0
);
window
.
location
.
reload
();
$
(
".layui-laypage-btn"
).
click
();
}
else
{
}
else
{
layer
.
close
(
index
);
layer
.
close
(
index
);
layer
.
msg
(
"启动失败"
);
layer
.
msg
(
"启动失败"
);
...
@@ -244,11 +251,12 @@
...
@@ -244,11 +251,12 @@
dataType
:
"json"
,
dataType
:
"json"
,
success
:
function
(
data
){
success
:
function
(
data
){
console
.
log
(
data
);
console
.
log
(
data
);
if
(
data
.
data
==
"0"
){
if
(
data
.
data
==
"success"
){
debugger
;
layer
.
close
(
index
);
layer
.
close
(
index
);
layer
.
msg
(
"关闭成功"
);
layer
.
msg
(
"关闭成功"
);
updateStatus
(
id
,
0
);
updateStatus
(
id
,
1
);
window
.
location
.
reload
();
$
(
".layui-laypage-btn"
).
click
();
}
else
{
}
else
{
layer
.
close
(
index
);
layer
.
close
(
index
);
layer
.
msg
(
"关闭失败"
);
layer
.
msg
(
"关闭失败"
);
...
@@ -258,14 +266,9 @@
...
@@ -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
)
{
function
updateStatus
(
id
,
status
)
{
$
.
ajax
({
$
.
ajax
({
...
@@ -273,7 +276,8 @@
...
@@ -273,7 +276,8 @@
url
:
"/updateservices/"
+
id
+
"/"
+
status
,
url
:
"/updateservices/"
+
id
+
"/"
+
status
,
dataType
:
"json"
,
dataType
:
"json"
,
success
:
function
(
data
){
success
:
function
(
data
){
if
(
data
.
data
==
"0"
){
debugger
;
if
(
data
.
status
==
201
){
layer
.
msg
(
"状态修改成功"
);
layer
.
msg
(
"状态修改成功"
);
}
else
{
}
else
{
layer
.
msg
(
"状态修改失败"
);
layer
.
msg
(
"状态修改失败"
);
...
@@ -281,6 +285,14 @@
...
@@ -281,6 +285,14 @@
}
}
});
});
}
}
$
(
function
(){
// 开启定时任务,时间间隔为3000 ms。
setInterval
(
function
(){
//window.location.reload();
//当前页的刷新
$
(
".layui-laypage-btn"
).
click
();
},
3000
);
});
</script>
</script>
...
...
src/main/webapp/WEB-INF/view/servicefrom.jsp
View file @
e589cfa9
...
@@ -98,7 +98,7 @@
...
@@ -98,7 +98,7 @@
<div
class=
"layui-form-item"
style=
"display: none"
>
<div
class=
"layui-form-item"
style=
"display: none"
>
<label
class=
"layui-form-label"
>
状态:
</label>
<label
class=
"layui-form-label"
>
状态:
</label>
<div
class=
"layui-input-block"
>
<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>
</div>
<
%
--
<
div
class=
"layui-form-item"
>
<
%
--
<
div
class=
"layui-form-item"
>
...
@@ -163,7 +163,7 @@
...
@@ -163,7 +163,7 @@
layer
.
msg
(
"保存成功"
);
layer
.
msg
(
"保存成功"
);
var
index
=
parent
.
layer
.
getFrameIndex
(
window
.
name
);
var
index
=
parent
.
layer
.
getFrameIndex
(
window
.
name
);
parent
.
layer
.
close
(
index
);
//关闭当前页
parent
.
layer
.
close
(
index
);
//关闭当前页
window
.
parent
.
location
.
reload
();
//刷新父页面
//
window.parent.location.reload(); //刷新父页面
}
else
{
}
else
{
//layer.close(index);
//layer.close(index);
layer
.
msg
(
"保存失败"
);
layer
.
msg
(
"保存失败"
);
...
...
src/main/webapp/WEB-INF/view/serviceupdate.jsp
View file @
e589cfa9
...
@@ -168,7 +168,6 @@
...
@@ -168,7 +168,6 @@
layer
.
msg
(
"修改成功"
);
layer
.
msg
(
"修改成功"
);
var
index
=
parent
.
layer
.
getFrameIndex
(
window
.
name
);
var
index
=
parent
.
layer
.
getFrameIndex
(
window
.
name
);
parent
.
layer
.
close
(
index
);
//关闭当前页
parent
.
layer
.
close
(
index
);
//关闭当前页
window
.
parent
.
location
.
reload
();
//刷新父页面
}
else
{
}
else
{
//layer.close(index);
//layer.close(index);
layer
.
msg
(
"修改失败"
);
layer
.
msg
(
"修改失败"
);
...
...
src/test/java/com/cc/XzxtControlApplicationTests.java
View file @
e589cfa9
...
@@ -2,6 +2,8 @@ package com.cc;
...
@@ -2,6 +2,8 @@ package com.cc;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.test.context.junit4.SpringRunner
;
...
@@ -11,6 +13,18 @@ public class XzxtControlApplicationTests {
...
@@ -11,6 +13,18 @@ public class XzxtControlApplicationTests {
@Test
@Test
public
void
contextLoads
()
{
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日志..."
);
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment