设备监控

monitor
sunjianxi 2 years ago
parent 03c6316022
commit 739d3ca217
  1. 13
      src/main/java/org/springblade/common/utils/HttpUtil.java
  2. 180
      src/main/java/org/springblade/modules/desk/controller/DashBoardController.java
  3. 119
      src/main/java/org/springblade/modules/desk/controller/NoticeController.java
  4. 75
      src/main/java/org/springblade/modules/desk/entity/Notice.java
  5. 46
      src/main/java/org/springblade/modules/desk/mapper/NoticeMapper.java
  6. 39
      src/main/java/org/springblade/modules/desk/mapper/NoticeMapper.xml
  7. 37
      src/main/java/org/springblade/modules/desk/service/INoticeService.java
  8. 38
      src/main/java/org/springblade/modules/desk/service/impl/NoticeServiceImpl.java
  9. 20
      src/main/java/org/springblade/modules/desk/vo/NoticeVO.java
  10. 50
      src/main/java/org/springblade/modules/desk/wrapper/NoticeWrapper.java
  11. 154
      src/main/java/org/springblade/modules/develop/controller/CodeController.java
  12. 126
      src/main/java/org/springblade/modules/develop/controller/DatasourceController.java
  13. 125
      src/main/java/org/springblade/modules/develop/entity/Code.java
  14. 82
      src/main/java/org/springblade/modules/develop/entity/Datasource.java
  15. 28
      src/main/java/org/springblade/modules/develop/mapper/CodeMapper.java
  16. 22
      src/main/java/org/springblade/modules/develop/mapper/CodeMapper.xml
  17. 28
      src/main/java/org/springblade/modules/develop/mapper/DatasourceMapper.java
  18. 22
      src/main/java/org/springblade/modules/develop/mapper/DatasourceMapper.xml
  19. 37
      src/main/java/org/springblade/modules/develop/service/ICodeService.java
  20. 28
      src/main/java/org/springblade/modules/develop/service/IDatasourceService.java
  21. 39
      src/main/java/org/springblade/modules/develop/service/impl/CodeServiceImpl.java
  22. 32
      src/main/java/org/springblade/modules/develop/service/impl/DatasourceServiceImpl.java
  23. 2
      src/main/java/org/springblade/modules/monitor/controller/BusinessMonitorController.java
  24. 4
      src/main/java/org/springblade/modules/monitor/controller/MonitorController.java
  25. 2
      src/main/java/org/springblade/modules/monitor/controller/SystemMonitorController.java
  26. 6
      src/main/java/org/springblade/modules/monitor/entity/ConfigMonitor.java
  27. 6
      src/main/java/org/springblade/modules/monitor/mapper/ConfigMonitorMapper.xml
  28. 2
      src/main/java/org/springblade/modules/monitor/mapper/MonitorMapper.java
  29. 2
      src/main/java/org/springblade/modules/monitor/mapper/MonitorMapper.xml
  30. 39
      src/main/java/org/springblade/modules/monitor/service/impl/ConfigMonitorServiceImpl.java
  31. 2
      src/main/java/org/springblade/modules/monitor/task/MonitorTaskJob.java
  32. 10
      src/main/java/org/springblade/modules/monitor/vo/ConfigMonitorVO.java
  33. 2
      src/main/resources/application.yml

@ -3,7 +3,9 @@ package org.springblade.common.utils;
import com.alibaba.fastjson.JSONObject;
import com.google.common.base.Joiner;
import lombok.RequiredArgsConstructor;
import org.springblade.common.constant.MonitorConstant;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;
@ -27,9 +29,14 @@ public class HttpUtil {
private final RestTemplate restTemplate;
public String doGet(String url, JSONObject params) {
URI uri = getUriByUrl(url,params);
String responseEntity = restTemplate.getForEntity(uri, String.class).getBody();
return responseEntity;
String responseEntity = null;
try {
URI uri = getUriByUrl(url,params);
responseEntity = restTemplate.getForEntity(uri, String.class).getBody();
} catch (RestClientException e) {
return MonitorConstant.RESULT;
}
return responseEntity;
}
/**

@ -1,180 +0,0 @@
package org.springblade.modules.desk.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.support.Kv;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 首页
*
* @author zhuangqian
*/
@ApiIgnore
@RestController
@RequestMapping("/blade-desk/dashboard")
@AllArgsConstructor
@Api(value = "首页", tags = "首页")
public class DashBoardController {
/**
* 活跃用户
*
* @return
*/
@GetMapping("/activities")
@ApiOperation(value = "活跃用户", notes = "活跃用户")
public R activities() {
List<Map<String, Object>> list = new ArrayList<>();
Map<String, Object> map1 = new HashMap<>(16);
map1.put("id", "trend-1");
map1.put("updatedAt", "2019-01-01");
map1.put("user", Kv.init().set("name", "曲丽丽").set("avatar", "https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png"));
map1.put("group", Kv.init().set("name", "高逼格设计天团").set("link", "http://github.com/"));
map1.put("project", Kv.init().set("name", "六月迭代").set("link", "http://github.com/"));
map1.put("template", "在 @{group} 新建项目 @{project}");
list.add(map1);
Map<String, Object> map2 = new HashMap<>(16);
map2.put("id", "trend-2");
map2.put("updatedAt", "2019-01-01");
map2.put("user", Kv.init().set("name", "付小小").set("avatar", "https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png"));
map2.put("group", Kv.init().set("name", "高逼格设计天团").set("link", "http://github.com/"));
map2.put("project", Kv.init().set("name", "七月月迭代").set("link", "http://github.com/"));
map2.put("template", "在 @{group} 新建项目 @{project}");
list.add(map2);
return R.data(list);
}
/**
* 获取消息
*
* @return
*/
@GetMapping("/notices")
@ApiOperation(value = "消息", notes = "消息")
public R notices() {
List<Map<String, String>> list = new ArrayList<>();
Map<String, String> map1 = new HashMap<>(16);
map1.put("logo", "https://spring.io/img/homepage/icon-spring-framework.svg");
map1.put("title", "SpringBoot");
map1.put("description", "现在的web项目几乎都会用到spring框架,而要使用spring难免需要配置大量的xml配置文件,而 springboot的出现解 决了这一问题,一个项目甚至不用部署到服务器上直接开跑,真像springboot所说:“just run”。");
map1.put("member", "Chill");
map1.put("href", "http://spring.io/projects/spring-boot");
list.add(map1);
Map<String, String> map2 = new HashMap<>(16);
map2.put("logo", "https://spring.io/img/homepage/icon-spring-cloud.svg");
map2.put("title", "SpringCloud");
map2.put("description", "SpringCloud是基于SpringBoot的一整套实现微服务的框架。他提供了微服务开发所需的配置管理、服务发现、断路器、智能路由、微代理、控制总线、全局锁、决策竞选、分布式会话和集群状态管理等组件。");
map2.put("member", "Chill");
map2.put("href", "http://spring.io/projects/spring-cloud");
list.add(map2);
Map<String, String> map3 = new HashMap<>(16);
map3.put("logo", "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1546359961068&di=05ff9406e6675ca9a58a525a7e7950b9&imgtype=jpg&src=http%3A%2F%2Fimg0.imgtn.bdimg.com%2Fit%2Fu%3D575314515%2C4268715674%26fm%3D214%26gp%3D0.jpg");
map3.put("title", "Mybatis");
map3.put("description", "MyBatis 是一款优秀的持久层框架,它支持定制化 SQL、存储过程以及高级映射。MyBatis 避免了几乎所有的 JDBC 代码和手动设置参数以及获取结果集。MyBatis 可以使用简单的 XML 或注解来配置和映射原生信息,将接口和 Java 的 POJOs(Plain Old Java Objects,普通的 Java对象)映射成数据库中的记录。");
map3.put("member", "Chill");
map3.put("href", "http://www.mybatis.org/mybatis-3/getting-started.html");
list.add(map3);
Map<String, String> map4 = new HashMap<>(16);
map4.put("logo", "https://gw.alipayobjects.com/zos/rmsportal/kZzEzemZyKLKFsojXItE.png");
map4.put("title", "React");
map4.put("description", "React 起源于 Facebook 的内部项目,因为该公司对市场上所有 JavaScript MVC 框架,都不满意,就决定自己写一套,用来架设Instagram 的网站。做出来以后,发现这套东西很好用,就在2013年5月开源了。");
map4.put("member", "Chill");
map4.put("href", "https://reactjs.org/");
list.add(map4);
Map<String, String> map5 = new HashMap<>(16);
map5.put("logo", "https://gw.alipayobjects.com/zos/rmsportal/dURIMkkrRFpPgTuzkwnB.png");
map5.put("title", "Ant Design");
map5.put("description", "蚂蚁金服体验技术部经过大量的项目实践和总结,沉淀出设计语言 Ant Design,这可不单纯只是设计原则、控件规范和视觉尺寸,还配套有前端代码实现方案。也就是说采用Ant Design后,UI设计和前端界面研发可同步完成,效率大大提升。");
map5.put("member", "Chill");
map5.put("href", "https://ant.design/docs/spec/introduce-cn");
list.add(map5);
Map<String, String> map6 = new HashMap<>(16);
map6.put("logo", "https://gw.alipayobjects.com/zos/rmsportal/sfjbOqnsXXJgNCjCzDBL.png");
map6.put("title", "Ant Design Pro");
map6.put("description", "Ant Design Pro 是一个企业级开箱即用的中后台前端/设计解决方案。符合阿里追求的'敏捷的前端+强大的中台'的思想。");
map6.put("member", "Chill");
map6.put("href", "https://pro.ant.design");
list.add(map6);
return R.data(list);
}
/**
* 获取我的消息
*
* @return
*/
@GetMapping("/my-notices")
@ApiOperation(value = "消息", notes = "消息")
public R myNotices() {
List<Map<String, String>> list = new ArrayList<>();
Map<String, String> map1 = new HashMap<>(16);
map1.put("id", "000000001");
map1.put("avatar", "https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png");
map1.put("title", "你收到了 14 份新周报");
map1.put("datetime", "2018-08-09");
map1.put("type", "notification");
list.add(map1);
Map<String, String> map2 = new HashMap<>(16);
map2.put("id", "000000002");
map2.put("avatar", "https://gw.alipayobjects.com/zos/rmsportal/OKJXDXrmkNshAMvwtvhu.png");
map2.put("title", "你推荐的 曲妮妮 已通过第三轮面试");
map2.put("datetime", "2018-08-08");
map2.put("type", "notification");
list.add(map2);
Map<String, String> map3 = new HashMap<>(16);
map3.put("id", "000000003");
map3.put("avatar", "https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg");
map3.put("title", "曲丽丽 评论了你");
map3.put("description", "描述信息描述信息描述信息");
map3.put("datetime", "2018-08-07");
map3.put("type", "message");
map3.put("clickClose", "true");
list.add(map3);
Map<String, String> map4 = new HashMap<>(16);
map4.put("id", "000000004");
map4.put("avatar", "https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg");
map4.put("title", "朱偏右 回复了你");
map4.put("description", "这种模板用于提醒谁与你发生了互动,左侧放『谁』的头像");
map4.put("type", "message");
map4.put("datetime", "2018-08-07");
map4.put("clickClose", "true");
list.add(map4);
Map<String, String> map5 = new HashMap<>(16);
map5.put("id", "000000005");
map5.put("title", "任务名称");
map5.put("description", "任务需要在 2018-01-12 20:00 前启动");
map5.put("extra", "未开始");
map5.put("status", "todo");
map5.put("type", "event");
list.add(map5);
return R.data(list);
}
}

@ -1,119 +0,0 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springblade.modules.desk.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import io.swagger.annotations.*;
import lombok.AllArgsConstructor;
import org.springblade.common.cache.CacheNames;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.desk.entity.Notice;
import org.springblade.modules.desk.service.INoticeService;
import org.springblade.modules.desk.vo.NoticeVO;
import org.springblade.modules.desk.wrapper.NoticeWrapper;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.Map;
/**
* 控制器
*
* @author Chill
*/
@RestController
@RequestMapping("/blade-desk/notice")
@AllArgsConstructor
@ApiSort(2)
@Api(value = "用户博客", tags = "博客接口")
public class NoticeController extends BladeController implements CacheNames {
private INoticeService noticeService;
/**
* 详情
*/
@GetMapping("/detail")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "详情", notes = "传入notice")
public R<NoticeVO> detail(Notice notice) {
Notice detail = noticeService.getOne(Condition.getQueryWrapper(notice));
return R.data(NoticeWrapper.build().entityVO(detail));
}
/**
* 分页
*/
@GetMapping("/list")
@ApiImplicitParams({
@ApiImplicitParam(name = "category", value = "公告类型", paramType = "query", dataType = "integer"),
@ApiImplicitParam(name = "title", value = "公告标题", paramType = "query", dataType = "string")
})
@ApiOperationSupport(order = 2)
@ApiOperation(value = "分页", notes = "传入notice")
public R<IPage<NoticeVO>> list(@ApiIgnore @RequestParam Map<String, Object> notice, Query query) {
IPage<Notice> pages = noticeService.page(Condition.getPage(query), Condition.getQueryWrapper(notice, Notice.class));
return R.data(NoticeWrapper.build().pageVO(pages));
}
/**
* 新增
*/
@PostMapping("/save")
@ApiOperationSupport(order = 3)
@ApiOperation(value = "新增", notes = "传入notice")
public R save(@RequestBody Notice notice) {
return R.status(noticeService.save(notice));
}
/**
* 修改
*/
@PostMapping("/update")
@ApiOperationSupport(order = 4)
@ApiOperation(value = "修改", notes = "传入notice")
public R update(@RequestBody Notice notice) {
return R.status(noticeService.updateById(notice));
}
/**
* 新增或修改
*/
@PostMapping("/submit")
@ApiOperationSupport(order = 5)
@ApiOperation(value = "新增或修改", notes = "传入notice")
public R submit(@RequestBody Notice notice) {
return R.status(noticeService.saveOrUpdate(notice));
}
/**
* 删除
*/
@PostMapping("/remove")
@ApiOperationSupport(order = 6)
@ApiOperation(value = "逻辑删除", notes = "传入notice")
public R remove(@ApiParam(value = "主键集合") @RequestParam String ids) {
boolean temp = noticeService.deleteLogic(Func.toLongList(ids));
return R.status(temp);
}
}

@ -1,75 +0,0 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springblade.modules.desk.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity;
import java.util.Date;
/**
* 实体类
*
* @author Chill
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("blade_notice")
public class Notice extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 主键id
*/
@ApiModelProperty(value = "主键")
@TableId(value = "id", type = IdType.ASSIGN_ID)
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
/**
* 标题
*/
@ApiModelProperty(value = "标题")
private String title;
/**
* 通知类型
*/
@ApiModelProperty(value = "通知类型")
private Integer category;
/**
* 发布日期
*/
@ApiModelProperty(value = "发布日期")
private Date releaseTime;
/**
* 内容
*/
@ApiModelProperty(value = "内容")
private String content;
}

@ -1,46 +0,0 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springblade.modules.desk.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.modules.desk.entity.Notice;
import java.util.List;
/**
* Mapper 接口
*
* @author Chill
*/
public interface NoticeMapper extends BaseMapper<Notice> {
/**
* 前N条数据
* @param number
* @return
*/
List<Notice> topList(Integer number);
/**
* 自定义分页
* @param page
* @param notice
* @return
*/
List<Notice> selectNoticePage(IPage page, Notice notice);
}

@ -1,39 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.springblade.modules.desk.mapper.NoticeMapper">
<!-- 通用查询映射结果 -->
<resultMap id="noticeResultMap" type="org.springblade.modules.desk.entity.Notice">
<result column="id" property="id"/>
<result column="create_user" property="createUser"/>
<result column="create_time" property="createTime"/>
<result column="update_user" property="updateUser"/>
<result column="update_time" property="updateTime"/>
<result column="status" property="status"/>
<result column="is_deleted" property="isDeleted"/>
<result column="release_time" property="releaseTime"/>
<result column="title" property="title"/>
<result column="content" property="content"/>
</resultMap>
<!-- 通用查询结果列 -->
<sql id="baseColumnList">
select id,
create_user AS createUser,
create_time AS createTime,
update_user AS updateUser,
update_time AS updateTime,
status,
is_deleted AS isDeleted,
title, content
</sql>
<select id="topList" resultMap="noticeResultMap">
select * from blade_notice limit #{number}
</select>
<select id="selectNoticePage" resultMap="noticeResultMap">
select * from blade_notice where title like concat('%', #{notice.title}, '%') and is_deleted = 0
</select>
</mapper>

@ -1,37 +0,0 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springblade.modules.desk.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseService;
import org.springblade.modules.desk.entity.Notice;
/**
* 服务类
*
* @author Chill
*/
public interface INoticeService extends BaseService<Notice> {
/**
* 自定义分页
* @param page
* @param notice
* @return
*/
IPage<Notice> selectNoticePage(IPage<Notice> page, Notice notice);
}

@ -1,38 +0,0 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springblade.modules.desk.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.modules.desk.entity.Notice;
import org.springblade.modules.desk.mapper.NoticeMapper;
import org.springblade.modules.desk.service.INoticeService;
import org.springframework.stereotype.Service;
/**
* 服务实现类
*
* @author Chill
*/
@Service
public class NoticeServiceImpl extends BaseServiceImpl<NoticeMapper, Notice> implements INoticeService {
@Override
public IPage<Notice> selectNoticePage(IPage<Notice> page, Notice notice) {
return page.setRecords(baseMapper.selectNoticePage(page, notice));
}
}

@ -1,20 +0,0 @@
package org.springblade.modules.desk.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.modules.desk.entity.Notice;
/**
* 通知公告视图类
*
* @author Chill
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class NoticeVO extends Notice {
@ApiModelProperty(value = "通知类型名")
private String categoryName;
}

@ -1,50 +0,0 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springblade.modules.desk.wrapper;
import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.SpringUtil;
import org.springblade.modules.desk.entity.Notice;
import org.springblade.modules.desk.vo.NoticeVO;
import org.springblade.modules.system.service.IDictService;
/**
* Notice包装类,返回视图层所需的字段
*
* @author Chill
*/
public class NoticeWrapper extends BaseEntityWrapper<Notice, NoticeVO> {
private static IDictService dictService;
static {
dictService = SpringUtil.getBean(IDictService.class);
}
public static NoticeWrapper build() {
return new NoticeWrapper();
}
@Override
public NoticeVO entityVO(Notice notice) {
NoticeVO noticeVO = BeanUtil.copy(notice, NoticeVO.class);
String categoryName = dictService.getValue("notice", noticeVO.getCategory());
noticeVO.setCategoryName(categoryName);
return noticeVO;
}
}

@ -1,154 +0,0 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springblade.modules.develop.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.*;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.launch.constant.AppConstant;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.annotation.PreAuth;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.constant.RoleConstant;
import org.springblade.core.tool.utils.Func;
import org.springblade.develop.support.BladeCodeGenerator;
import org.springblade.modules.develop.entity.Code;
import org.springblade.modules.develop.entity.Datasource;
import org.springblade.modules.develop.service.ICodeService;
import org.springblade.modules.develop.service.IDatasourceService;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.validation.Valid;
import java.util.Collection;
import java.util.Map;
/**
* 控制器
*
* @author Chill
*/
@ApiIgnore
@RestController
@AllArgsConstructor
@RequestMapping(AppConstant.APPLICATION_DEVELOP_NAME + "/code")
@Api(value = "代码生成", tags = "代码生成")
@PreAuth(RoleConstant.HAS_ROLE_ADMIN)
public class CodeController extends BladeController {
private ICodeService codeService;
private IDatasourceService datasourceService;
/**
* 详情
*/
@GetMapping("/detail")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "详情", notes = "传入code")
public R<Code> detail(Code code) {
Code detail = codeService.getOne(Condition.getQueryWrapper(code));
return R.data(detail);
}
/**
* 分页
*/
@GetMapping("/list")
@ApiImplicitParams({
@ApiImplicitParam(name = "codeName", value = "模块名", paramType = "query", dataType = "string"),
@ApiImplicitParam(name = "tableName", value = "表名", paramType = "query", dataType = "string"),
@ApiImplicitParam(name = "modelName", value = "实体名", paramType = "query", dataType = "string")
})
@ApiOperationSupport(order = 2)
@ApiOperation(value = "分页", notes = "传入code")
public R<IPage<Code>> list(@ApiIgnore @RequestParam Map<String, Object> code, Query query) {
IPage<Code> pages = codeService.page(Condition.getPage(query), Condition.getQueryWrapper(code, Code.class));
return R.data(pages);
}
/**
* 新增或修改
*/
@PostMapping("/submit")
@ApiOperationSupport(order = 3)
@ApiOperation(value = "新增或修改", notes = "传入code")
public R submit(@Valid @RequestBody Code code) {
return R.status(codeService.submit(code));
}
/**
* 删除
*/
@PostMapping("/remove")
@ApiOperationSupport(order = 4)
@ApiOperation(value = "删除", notes = "传入ids")
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
return R.status(codeService.removeByIds(Func.toLongList(ids)));
}
/**
* 复制
*/
@PostMapping("/copy")
@ApiOperationSupport(order = 5)
@ApiOperation(value = "复制", notes = "传入id")
public R copy(@ApiParam(value = "主键", required = true) @RequestParam Long id) {
Code code = codeService.getById(id);
code.setId(null);
code.setCodeName(code.getCodeName() + "-copy");
return R.status(codeService.save(code));
}
/**
* 代码生成
*/
@PostMapping("/gen-code")
@ApiOperationSupport(order = 6)
@ApiOperation(value = "代码生成", notes = "传入ids")
public R genCode(@ApiParam(value = "主键集合", required = true) @RequestParam String ids, @RequestParam(defaultValue = "sword") String system) {
Collection<Code> codes = codeService.listByIds(Func.toLongList(ids));
codes.forEach(code -> {
BladeCodeGenerator generator = new BladeCodeGenerator();
// 设置数据源
Datasource datasource = datasourceService.getById(code.getDatasourceId());
generator.setDriverName(datasource.getDriverClass());
generator.setUrl(datasource.getUrl());
generator.setUsername(datasource.getUsername());
generator.setPassword(datasource.getPassword());
// 设置基础配置
generator.setSystemName(system);
generator.setServiceName(code.getServiceName());
generator.setPackageName(code.getPackageName());
generator.setPackageDir(code.getApiPath());
generator.setPackageWebDir(code.getWebPath());
generator.setTablePrefix(Func.toStrArray(code.getTablePrefix()));
generator.setIncludeTables(Func.toStrArray(code.getTableName()));
// 设置是否继承基础业务字段
generator.setHasSuperEntity(code.getBaseMode() == 2);
// 控制器添加服务名前缀
generator.setHasServiceName(Boolean.TRUE);
// 设置是否开启包装器模式
generator.setHasWrapper(code.getWrapMode() == 2);
generator.run();
});
return R.success("代码生成成功");
}
}

@ -1,126 +0,0 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springblade.modules.develop.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.launch.constant.AppConstant;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.develop.entity.Datasource;
import org.springblade.modules.develop.service.IDatasourceService;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
/**
* 数据源配置表 控制器
*
* @author Chill
*/
@RestController
@AllArgsConstructor
@RequestMapping(AppConstant.APPLICATION_DEVELOP_NAME + "/datasource")
@Api(value = "数据源配置表", tags = "数据源配置表接口")
public class DatasourceController extends BladeController {
private IDatasourceService datasourceService;
/**
* 详情
*/
@GetMapping("/detail")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "详情", notes = "传入datasource")
public R<Datasource> detail(Datasource datasource) {
Datasource detail = datasourceService.getOne(Condition.getQueryWrapper(datasource));
return R.data(detail);
}
/**
* 分页 数据源配置表
*/
@GetMapping("/list")
@ApiOperationSupport(order = 2)
@ApiOperation(value = "分页", notes = "传入datasource")
public R<IPage<Datasource>> list(Datasource datasource, Query query) {
IPage<Datasource> pages = datasourceService.page(Condition.getPage(query), Condition.getQueryWrapper(datasource));
return R.data(pages);
}
/**
* 新增 数据源配置表
*/
@PostMapping("/save")
@ApiOperationSupport(order = 4)
@ApiOperation(value = "新增", notes = "传入datasource")
public R save(@Valid @RequestBody Datasource datasource) {
return R.status(datasourceService.save(datasource));
}
/**
* 修改 数据源配置表
*/
@PostMapping("/update")
@ApiOperationSupport(order = 5)
@ApiOperation(value = "修改", notes = "传入datasource")
public R update(@Valid @RequestBody Datasource datasource) {
return R.status(datasourceService.updateById(datasource));
}
/**
* 新增或修改 数据源配置表
*/
@PostMapping("/submit")
@ApiOperationSupport(order = 6)
@ApiOperation(value = "新增或修改", notes = "传入datasource")
public R submit(@Valid @RequestBody Datasource datasource) {
datasource.setUrl(datasource.getUrl().replace("&amp;", "&"));
return R.status(datasourceService.saveOrUpdate(datasource));
}
/**
* 删除 数据源配置表
*/
@PostMapping("/remove")
@ApiOperationSupport(order = 7)
@ApiOperation(value = "逻辑删除", notes = "传入ids")
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
return R.status(datasourceService.deleteLogic(Func.toLongList(ids)));
}
/**
* 数据源列表
*/
@GetMapping("/select")
@ApiOperationSupport(order = 8)
@ApiOperation(value = "下拉数据源", notes = "查询列表")
public R<List<Datasource>> select() {
List<Datasource> list = datasourceService.list();
return R.data(list);
}
}

@ -1,125 +0,0 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springblade.modules.develop.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 实体类
*
* @author Chill
*/
@Data
@TableName("blade_code")
@ApiModel(value = "Code对象", description = "Code对象")
public class Code implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@ApiModelProperty(value = "主键")
@TableId(value = "id", type = IdType.ASSIGN_ID)
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
/**
* 数据源主键
*/
@ApiModelProperty(value = "数据源主键")
@JsonSerialize(using = ToStringSerializer.class)
private Long datasourceId;
/**
* 模块名称
*/
@ApiModelProperty(value = "服务名称")
private String serviceName;
/**
* 模块名称
*/
@ApiModelProperty(value = "模块名称")
private String codeName;
/**
* 表名
*/
@ApiModelProperty(value = "表名")
private String tableName;
/**
* 实体名
*/
@ApiModelProperty(value = "表前缀")
private String tablePrefix;
/**
* 主键名
*/
@ApiModelProperty(value = "主键名")
private String pkName;
/**
* 基础业务模式
*/
@ApiModelProperty(value = "基础业务模式")
private Integer baseMode;
/**
* 包装器模式
*/
@ApiModelProperty(value = "包装器模式")
private Integer wrapMode;
/**
* 后端包名
*/
@ApiModelProperty(value = "后端包名")
private String packageName;
/**
* 后端路径
*/
@ApiModelProperty(value = "后端路径")
private String apiPath;
/**
* 前端路径
*/
@ApiModelProperty(value = "前端路径")
private String webPath;
/**
* 是否已删除
*/
@TableLogic
@ApiModelProperty(value = "是否已删除")
private Integer isDeleted;
}

@ -1,82 +0,0 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springblade.modules.develop.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity;
/**
* 数据源配置表实体类
*
* @author Chill
*/
@Data
@TableName("blade_datasource")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "Datasource对象", description = "数据源配置表")
public class Datasource extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@ApiModelProperty(value = "主键")
@TableId(value = "id", type = IdType.ASSIGN_ID)
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
/**
* 名称
*/
@ApiModelProperty(value = "名称")
private String name;
/**
* 驱动类
*/
@ApiModelProperty(value = "驱动类")
private String driverClass;
/**
* 连接地址
*/
@ApiModelProperty(value = "连接地址")
private String url;
/**
* 用户名
*/
@ApiModelProperty(value = "用户名")
private String username;
/**
* 密码
*/
@ApiModelProperty(value = "密码")
private String password;
/**
* 备注
*/
@ApiModelProperty(value = "备注")
private String remark;
}

@ -1,28 +0,0 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springblade.modules.develop.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.modules.develop.entity.Code;
/**
* Mapper 接口
*
* @author Chill
*/
public interface CodeMapper extends BaseMapper<Code> {
}

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.springblade.modules.develop.mapper.CodeMapper">
<!-- 通用查询映射结果 -->
<resultMap id="codeResultMap" type="org.springblade.modules.develop.entity.Code">
<id column="id" property="id"/>
<result column="datasource_id" property="datasourceId"/>
<result column="service_name" property="serviceName"/>
<result column="code_name" property="codeName"/>
<result column="table_name" property="tableName"/>
<result column="pk_name" property="pkName"/>
<result column="base_mode" property="baseMode"/>
<result column="wrap_mode" property="wrapMode"/>
<result column="table_prefix" property="tablePrefix"/>
<result column="package_name" property="packageName"/>
<result column="api_path" property="apiPath"/>
<result column="web_path" property="webPath"/>
<result column="is_deleted" property="isDeleted"/>
</resultMap>
</mapper>

@ -1,28 +0,0 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springblade.modules.develop.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.modules.develop.entity.Datasource;
/**
* 数据源配置表 Mapper 接口
*
* @author Chill
*/
public interface DatasourceMapper extends BaseMapper<Datasource> {
}

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.springblade.modules.develop.mapper.DatasourceMapper">
<!-- 通用查询映射结果 -->
<resultMap id="datasourceResultMap" type="org.springblade.modules.develop.entity.Datasource">
<result column="id" property="id"/>
<result column="create_user" property="createUser"/>
<result column="create_dept" property="createDept"/>
<result column="create_time" property="createTime"/>
<result column="update_user" property="updateUser"/>
<result column="update_time" property="updateTime"/>
<result column="status" property="status"/>
<result column="is_deleted" property="isDeleted"/>
<result column="driver_class" property="driverClass"/>
<result column="url" property="url"/>
<result column="username" property="username"/>
<result column="password" property="password"/>
<result column="remark" property="remark"/>
</resultMap>
</mapper>

@ -1,37 +0,0 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springblade.modules.develop.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.modules.develop.entity.Code;
/**
* 服务类
*
* @author Chill
*/
public interface ICodeService extends IService<Code> {
/**
* 提交
*
* @param code
* @return
*/
boolean submit(Code code);
}

@ -1,28 +0,0 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springblade.modules.develop.service;
import org.springblade.core.mp.base.BaseService;
import org.springblade.modules.develop.entity.Datasource;
/**
* 数据源配置表 服务类
*
* @author Chill
*/
public interface IDatasourceService extends BaseService<Datasource> {
}

@ -1,39 +0,0 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springblade.modules.develop.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.core.tool.constant.BladeConstant;
import org.springblade.modules.develop.entity.Code;
import org.springblade.modules.develop.mapper.CodeMapper;
import org.springblade.modules.develop.service.ICodeService;
import org.springframework.stereotype.Service;
/**
* 服务实现类
*
* @author Chill
*/
@Service
public class CodeServiceImpl extends ServiceImpl<CodeMapper, Code> implements ICodeService {
@Override
public boolean submit(Code code) {
code.setIsDeleted(BladeConstant.DB_NOT_DELETED);
return saveOrUpdate(code);
}
}

@ -1,32 +0,0 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springblade.modules.develop.service.impl;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.modules.develop.entity.Datasource;
import org.springblade.modules.develop.mapper.DatasourceMapper;
import org.springblade.modules.develop.service.IDatasourceService;
import org.springframework.stereotype.Service;
/**
* 数据源配置表 服务实现类
*
* @author Chill
*/
@Service
public class DatasourceServiceImpl extends BaseServiceImpl<DatasourceMapper, Datasource> implements IDatasourceService {
}

@ -1,4 +1,4 @@
package org.springblade.modules.desk.controller;
package org.springblade.modules.monitor.controller;
import lombok.AllArgsConstructor;
import org.apache.ibatis.annotations.Param;

@ -28,14 +28,14 @@ public class MonitorController {
/**
* 判断设备是否正常
*/
@GetMapping("/findList")
@GetMapping("/updateMonitorInfo")
public void ifFestival(){
configMonitorService.updateMonitorInfo();
}
/**
* 定时排查监控沈北状态
* 定时排查监控设备状态
*/
@GetMapping("/monitoringEquip")
public void monitoringEquip(){

@ -1,4 +1,4 @@
package org.springblade.modules.desk.controller;
package org.springblade.modules.monitor.controller;
import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R;

@ -99,4 +99,10 @@ public class ConfigMonitor extends BaseEntity {
)
@ApiModelProperty("创建部门")
private Long createDept;
/**
* 服务颜色
*/
@ApiModelProperty(value = "服务颜色")
private String color;
}

@ -20,9 +20,11 @@
<result column="is_deleted" property="isDeleted"/>
</resultMap>
<resultMap id="treeNodeResultMap" type="org.springblade.core.tool.node.TreeNode">
<resultMap id="treeNodeResultMap" type="org.springblade.modules.monitor.vo.ConfigMonitorVO">
<id column="id" property="id"/>
<result column="parent_id" property="parentId"/>
<result column="monitor_type" property="monitorType"/>
<result column="status" property="status"/>
<result column="title" property="title"/>
<result column="value" property="value"/>
<result column="key" property="key"/>
@ -36,6 +38,8 @@
a.type AS title,
a.status AS "value",
a.id AS "key",
a.monitor_type,
a.status,
(
SELECT
CASE WHEN count(1) > 0 THEN 1 ELSE 0 END

@ -1,4 +1,4 @@
package org.springblade.modules.desk.mapper;
package org.springblade.modules.monitor.mapper;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace = "org.springblade.modules.desk.mapper.MonitorMapper">
<mapper namespace = "org.springblade.modules.monitor.mapper.MonitorMapper">
<select id = "resolveTips" resultType = "map">
select id, class_code as classCode, point_code as pointCode, tips, short_num as shortNum

@ -72,9 +72,17 @@ public class ConfigMonitorServiceImpl extends ServiceImpl<ConfigMonitorMapper, C
JSONObject params = new JSONObject();
params.put("query",monitor.getFormula());
String s = httpUtil.doGet(monitorUrl, params);
String[] strs = s.split("\"");
String result = strs[strs.length-2];
String result = null;
if(MonitorConstant.RESULT.equals(s)){
result = s;
}else{
String[] strs = s.split("\"");
result = strs[strs.length-2];
}
monitor.setResult(result);
if(monitor.getType().equals(MonitorConstant.SERVICE) && MonitorConstant.RESULT.equals(result)){
monitor.setColor("red");
}
baseMapper.updateById(monitor);
log.info("调用api结果:"+s);
log.info("最后获取结果:"+result);
@ -104,14 +112,31 @@ public class ConfigMonitorServiceImpl extends ServiceImpl<ConfigMonitorMapper, C
List<ConfigMonitor> monitorList = entry.getValue();
//获取更新时间间隔大于30分钟的数据
List<ConfigMonitor> breakList = monitorList.stream().filter(item->{
if(item.getUpdateTime() == null){
return false;
}
return item.getUpdateTime().compareTo(time) < 0;
}).collect(Collectors.toList());
List<Long> parentIdList = new ArrayList<>();
parentIdList = getParentIdList(parentIdList,parentId);
Collections.reverse(parentIdList);
//前端页面需要根据服务颜色判断是否有异常设备,所以这里添加这一步
Long serviceId = parentIdList.get(0);
LambdaQueryWrapper<ConfigMonitor> serviceWrapper = new LambdaQueryWrapper<>();
serviceWrapper.eq(ConfigMonitor::getId,serviceId);
serviceWrapper.eq(BaseEntity::getIsDeleted,0);
ConfigMonitor serviceConfigMonitor = baseMapper.selectOne(serviceWrapper);
if(serviceConfigMonitor.getType().equals(MonitorConstant.SERVICE) && breakList.size() > 0){
serviceConfigMonitor.setColor("red");
}else{
serviceConfigMonitor.setColor("green");
}
baseMapper.updateById(serviceConfigMonitor);
//如果所有设备都坏了,直接排查父级问题;否则修改设备状态为异常
//modbus设备排查服务、网关;mqtt设备排查服务、mqtt服务、dtu;bacnet设备是通过广播直连,如果全部设备都有问题,直接排查网络问题;
if(breakList.size() == monitorList.size()){
List<Long> parentIdList = new ArrayList<>();
parentIdList = getParentIdList(parentIdList,parentId);
Collections.reverse(parentIdList);
boolean flag = true;
for(Long id : parentIdList){
//通过标识位来判断当前是否应该静默
@ -161,7 +186,7 @@ public class ConfigMonitorServiceImpl extends ServiceImpl<ConfigMonitorMapper, C
updateWrapper.eq(ConfigMonitor::getParentId,parentId);
ConfigMonitor configMonitor = new ConfigMonitor();
configMonitor.setStatus(MonitorConstant.STATUS_4);
configMonitor.setUpdateTime(nowDate);
//configMonitor.setUpdateTime(nowDate);
baseMapper.update(configMonitor,updateWrapper);
parentId = id;
}
@ -169,7 +194,7 @@ public class ConfigMonitorServiceImpl extends ServiceImpl<ConfigMonitorMapper, C
//将所有设备状态改为静默
breakList.forEach(item ->{
item.setStatus(MonitorConstant.STATUS_4);
item.setUpdateTime(nowDate);
//item.setUpdateTime(nowDate);
baseMapper.updateById(item);
});
}else{

@ -10,12 +10,14 @@ import org.springframework.stereotype.Component;
public class MonitorTaskJob {
private final IConfigMonitorService configMonitorService;
//更新服务器监控状态
@Scheduled(cron ="0 0 0 1/1 * ? ")
public void updateMonitorInfo(){
configMonitorService.updateMonitorInfo();
}
//更新设备监控状态
@Scheduled(cron ="0 0/5 * * * ? ")
public void monitoringEquip(){
configMonitorService.monitoringEquip();

@ -61,4 +61,14 @@ public class ConfigMonitorVO extends ConfigMonitor implements INode<ConfigMonito
*/
private String parentName;
private String title;
@JsonSerialize(
using = ToStringSerializer.class
)
private Long key;
@JsonSerialize(
using = ToStringSerializer.class
)
private Long value;
}

@ -116,7 +116,7 @@ blade:
- /blade-test/**
secure:
skip-url:
- /blade-test/**
- /monitor/**
client:
- client-id: sword
path-patterns:

Loading…
Cancel
Save