| 2025-12-02 | kongdeqiang | ![]() |
| 2025-12-02 | kongdeqiang | ![]() |
| 2025-12-02 | kongdeqiang | ![]() |
| 2025-12-02 | kongdeqiang | ![]() |
| 2025-12-02 | kongdeqiang | ![]() |
pom.xml
@@ -78,6 +78,11 @@ <artifactId>lombok</artifactId> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.83</version> </dependency> <dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> <version>5.6.5</version> @@ -229,4 +234,4 @@ </build> </project> </project> src/main/java/com/wgcloud/WgcloudServiceApplication.java
@@ -31,7 +31,7 @@ @ServletComponentScan("com.wgcloud.filter") @ComponentScan(basePackages = "com.wgcloud") @EnableCaching //@EnableScheduling @EnableScheduling public class WgcloudServiceApplication { public static void main(String[] args) { SpringApplication.run(WgcloudServiceApplication.class, args); src/main/java/com/wgcloud/controller/dp/DpController.java
@@ -1,7 +1,9 @@ package com.wgcloud.controller.dp; import com.wgcloud.entity.OspfErrorLog; import com.wgcloud.entity.OspfInfo; import com.wgcloud.entity.SnmpInfo; import com.wgcloud.service.OspfErrorLogService; import com.wgcloud.service.OspfInfoService; import com.wgcloud.service.SnmpInfoService; import com.wgcloud.util.R; @@ -27,6 +29,8 @@ @Autowired private OspfInfoService ospfInfoService; @Autowired private OspfErrorLogService ospfErrorLogService; @GetMapping("/getTop") public R getTop5() throws Exception { @@ -68,14 +72,20 @@ SimpleDateFormat sdf = new SimpleDateFormat("MM/dd"); String format = sdf.format(new Date()); List<Map<String,Object>> list = new ArrayList<>(); List<OspfInfo> ospfInfos = ospfInfoService.selectAllByParams(null); Map<String,Object> query = new HashMap<>(); query.put("state","1"); List<OspfErrorLog> ospfErrorLogs = ospfErrorLogService.selectAllByParams(query); Map<String,Object> query2 = new HashMap<>(); query2.put("state","0"); List<OspfErrorLog> ospfErrorLogs2 = ospfErrorLogService.selectAllByParams(query2); ospfErrorLogs.addAll(ospfErrorLogs2); for (OspfInfo ospfInfo : ospfInfos) { for (OspfErrorLog ospfInfo : ospfErrorLogs) { HashMap<String, Object> map = new HashMap<>(); map.put("date",format); map.put("date",sdf.format(ospfInfo.getCreateTime())); map.put("name",ospfInfo.getInfoContent()); map.put("ipaddress",ospfInfo.getHostname()); map.put("status",1); map.put("status",ospfInfo.getState()); list.add(map); } return R.ok(list); @@ -83,13 +93,16 @@ @GetMapping("/getCount") public R getCount() throws Exception { Map<String,Object> queryMap = new HashMap<>(); queryMap.put("state","1"); List<OspfInfo> ospfInfos = ospfInfoService.selectAllByParams(null); List<OspfInfo> errorOspfInfos = ospfInfoService.selectAllByParams(queryMap); Map<String,Object> map = new HashMap<>(); map.put("allCount",ospfInfos.size()); map.put("normalCount",ospfInfos.size()-2); map.put("errorCount",2); double i = (double)(ospfInfos.size() - 2) /(double) ospfInfos.size(); double o = (double)2 /(double) ospfInfos.size(); map.put("normalCount",ospfInfos.size()-errorOspfInfos.size()); map.put("errorCount",errorOspfInfos.size()); double i = (double)(ospfInfos.size()-errorOspfInfos.size()) /(double) ospfInfos.size(); double o = (double)errorOspfInfos.size() /(double) ospfInfos.size(); BigDecimal n = new BigDecimal(i).setScale(2, BigDecimal.ROUND_HALF_UP); BigDecimal e = new BigDecimal(o).setScale(2, BigDecimal.ROUND_HALF_UP); map.put("normalProp",n); @@ -100,10 +113,16 @@ public R getInfo() throws Exception { List<Map<String,Object>> list = new ArrayList<>(); List<OspfInfo> ospfInfos = ospfInfoService.selectAllByParams(null); HashMap<String, Object> hxMap = new HashMap<>(); hxMap.put("ipAddress","\n电信:192.168.1.1\n 联通:192.168.2.1\n 移动:192.168.3.1"); hxMap.put("name","北国核心"); hxMap.put("status","0"); list.add(hxMap); for (OspfInfo ospfInfo : ospfInfos) { HashMap<String, Object> map = new HashMap<>(); map.put("ipAddress",ospfInfo.getHostname()); map.put("status",1); map.put("name",ospfInfo.getInfoContent()); map.put("status",ospfInfo.getState()); list.add(map); } return R.ok(list); src/main/java/com/wgcloud/entity/OspfErrorLog.java
New file @@ -0,0 +1,82 @@ package com.wgcloud.entity; import java.util.Date; /** * @version v3.3 * @ClassName:ospf.java * @author: http://www.wgstart.com * @date: 2021年1月16日 * @Description: ospf监控设备 * @Copyright: 2019-2021 wgcloud. All rights reserved. */ public class OspfErrorLog extends BaseEntity { /** * */ private static final long serialVersionUID = 1L; /** * 标题 */ private String hostname; /** * 描述 */ private String infoContent; /** * 0已处理,1未处理 */ private String state; /** * 创建时间 */ private Date createTime; public String getHostname() { return hostname; } public void setHostname(String hostname) { this.hostname = hostname; } public String getInfoContent() { return infoContent; } public void setInfoContent(String infoContent) { this.infoContent = infoContent; } public String getState() { return state; } public void setState(String state) { this.state = state; } public Date getCreateTime() { return createTime; } public void setCreateTime(Date createTime) { this.createTime = createTime; } } src/main/java/com/wgcloud/mapper/OspfErrorLogMapper.java
New file @@ -0,0 +1,39 @@ package com.wgcloud.mapper; import com.wgcloud.entity.OspfErrorLog; import com.wgcloud.entity.OspfMonitor; import org.springframework.stereotype.Repository; import java.util.List; import java.util.Map; /** * @version v3.3 * @ClassName:LogInfoDao.java * @author: http://www.wgstart.com * @date: 2021年1月16日 * @Description: 查看日志信息 * @Copyright: 2019-2021 wgcloud. All rights reserved. */ @Repository public interface OspfErrorLogMapper { public List<OspfErrorLog> selectAllByParams(Map<String, Object> map); public int countByParams(Map<String, Object> params) throws Exception; public List<OspfErrorLog> selectByParams(Map<String, Object> params) throws Exception; public OspfErrorLog selectById(String id) throws Exception; public void save(OspfErrorLog LogInfo) throws Exception; public int deleteById(String[] id) throws Exception; public void insertList(List<OspfErrorLog> recordList) throws Exception; public int deleteByDate(Map<String, Object> map) throws Exception; public void updateById(OspfErrorLog ospfInfo); } src/main/java/com/wgcloud/service/OspfErrorLogService.java
New file @@ -0,0 +1,94 @@ package com.wgcloud.service; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.wgcloud.entity.OspfErrorLog; import com.wgcloud.entity.OspfErrorLog; import com.wgcloud.mapper.OspfErrorLogMapper; import com.wgcloud.util.DateUtil; import com.wgcloud.util.UUIDUtil; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @version v3.3 * @ClassName:OspfErrorLogService.java * @author: http://www.wgstart.com * @date: 2021年1月16日 * @Description: OspfErrorLogService.java * @Copyright: 2019-2021 wgcloud. All rights reserved. */ @Service public class OspfErrorLogService { private static final Logger logger = LoggerFactory.getLogger(OspfErrorLogService.class); public PageInfo selectByParams(Map<String, Object> params, int currPage, int pageSize) throws Exception { PageHelper.startPage(currPage, pageSize); List<OspfErrorLog> list = ospfErrorLogMapper.selectByParams(params); PageInfo<OspfErrorLog> pageInfo = new PageInfo<OspfErrorLog>(list); return pageInfo; } public void saveRecord(List<OspfErrorLog> recordList) throws Exception { if (recordList.size() < 1) { return; } Map<String, Object> map = new HashMap<String, Object>(); for (OspfErrorLog as : recordList) { as.setId(UUIDUtil.getUUID()); as.setCreateTime(DateUtil.getNowTime()); } ospfErrorLogMapper.insertList(recordList); } public void save(OspfErrorLog OspfErrorLog) { OspfErrorLog.setId(UUIDUtil.getUUID()); OspfErrorLog.setCreateTime(DateUtil.getNowTime()); try { ospfErrorLogMapper.save(OspfErrorLog); } catch (Exception e) { logger.error("保存日志信息异常:", e); } } public void updateById(OspfErrorLog OspfErrorLog) throws Exception { if (StringUtils.isEmpty(OspfErrorLog.getHostname())) { OspfErrorLog.setHostname(OspfErrorLog.getHostname().trim()); } ospfErrorLogMapper.updateById(OspfErrorLog); } public int countByParams(Map<String, Object> params) throws Exception { return ospfErrorLogMapper.countByParams(params); } public int deleteById(String[] id) throws Exception { return ospfErrorLogMapper.deleteById(id); } public OspfErrorLog selectById(String id) throws Exception { return ospfErrorLogMapper.selectById(id); } public List<OspfErrorLog> selectAllByParams(Map<String, Object> params) throws Exception { return ospfErrorLogMapper.selectAllByParams(params); } public int deleteByDate(Map<String, Object> map) throws Exception{ return ospfErrorLogMapper.deleteByDate(map); } @Autowired private OspfErrorLogMapper ospfErrorLogMapper; } src/main/java/com/wgcloud/service/OspfInfoService.java
@@ -1,17 +1,25 @@ package com.wgcloud.service; import cn.hutool.http.HttpRequest; import com.alibaba.fastjson.TypeReference; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.wgcloud.entity.OspfErrorLog; import com.wgcloud.entity.OspfInfo; import com.wgcloud.entity.SnmpInfo; import com.wgcloud.entity.vo.OspfNeighbor; import com.wgcloud.mapper.OspfErrorLogMapper; import com.wgcloud.mapper.OspfInfoMapper; import com.wgcloud.util.DateUtil; import com.wgcloud.util.OspfNeighborUtil; import com.wgcloud.util.UUIDUtil; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import com.alibaba.fastjson.JSON; import java.util.HashMap; import java.util.List; @@ -30,6 +38,15 @@ @Autowired private RouterConnectionService routerConnectionService; @Autowired private OspfNeighborUtil ospfNeighborUtil; @Autowired private OspfErrorLogMapper errorLogMapper; @Value("${osfService.host}") private String remoteHost; @Value("${osfService.port}") private String remotePort; private static final Logger logger = LoggerFactory.getLogger(OspfInfoService.class); @@ -70,44 +87,111 @@ OspfInfoMapper.updateById(ospfInfo); } public boolean checkOspfStatus() { String command = "display ospf brief"; String output = routerConnectionService.executeCommand(command); if (output == null) { return false; } // 检查输出中是否包含OSPF相关信息 boolean containsRouterId = StringUtils.containsIgnoreCase(output, "Router ID"); boolean containsArea = StringUtils.containsIgnoreCase(output, "Area"); boolean containsProcessId = StringUtils.containsIgnoreCase(output, "Process ID"); // 检查是否有错误信息 boolean containsError = StringUtils.containsIgnoreCase(output, "Error") || StringUtils.containsIgnoreCase(output, "Fail") || StringUtils.containsIgnoreCase(output, "Invalid"); return (containsRouterId && containsArea && containsProcessId) && !containsError; } /** * 获取详细的OSPF邻居信息 */ public String getDetailedOspfNeighborInfo() { String command = "display ospf peer"; return routerConnectionService.executeCommand(command); public void getDetailedOspfNeighborInfo() { List<OspfInfo> ospfInfos = OspfInfoMapper.selectAllByParams(null); for (OspfInfo ospfInfo : ospfInfos) { String command = "display ospf peer "+ospfInfo.getHostname(); String result = routerConnectionService.executeCommand(command,ospfInfo.getMonitorUsername(),ospfInfo.getMonitorPassword(),ospfInfo.getMonitorIp()); System.out.println("获取到的邻居信息为:"+result); if(StringUtils.isNotBlank(result)){ List<OspfNeighbor> neighbors = ospfNeighborUtil.analysisStr(result); if(neighbors != null || neighbors.size()>0){ OspfNeighbor ospfNeighbor = neighbors.get(0); String state = ospfNeighbor.getState(); if (state.contains("Down") || state.contains("Init")) { ospfInfo.setState("1"); OspfInfoMapper.updateById(ospfInfo); HashMap<String, Object> hashMap = new HashMap<>(); hashMap.put("state","1"); hashMap.put("hostname",ospfInfo.getHostname()); List<OspfErrorLog> ospfErrorLogs = errorLogMapper.selectAllByParams(hashMap); if(ospfErrorLogs==null||ospfErrorLogs.size()==0){ OspfErrorLog ospfErrorLog = new OspfErrorLog(); ospfErrorLog.setInfoContent(ospfInfo.getInfoContent()); ospfErrorLog.setHostname(ospfInfo.getHostname()); ospfErrorLog.setState("1"); try { errorLogMapper.save(ospfErrorLog); }catch (Exception e){ e.printStackTrace(); } } }else { ospfInfo.setState("0"); OspfInfoMapper.updateById(ospfInfo); } } }else { ospfInfo.setState("1"); OspfInfoMapper.updateById(ospfInfo); } } } public void getRouterStatus() { List<OspfInfo> ospfInfos = OspfInfoMapper.selectAllByParams(null); for (OspfInfo ospfInfo : ospfInfos) { String command = "display ospf peer "+ospfInfo.getHostname(); Map<String,String> map = new HashMap<>(); map.put("command",command); map.put("username",ospfInfo.getMonitorUsername()); map.put("password",ospfInfo.getMonitorPassword()); map.put("monitorIp",ospfInfo.getMonitorIp()); String str = JSON.toJSONString(map); System.out.println(str); try { String url = "http://"+remoteHost+":"+remotePort+"/api/connect/getResult"; String responseBody = HttpRequest.post(url) .timeout(5000) .body(str) .execute() .body(); System.out.println(responseBody); if(responseBody.equals("1")){ HashMap<String, Object> hashMap = new HashMap<>(); hashMap.put("state","1"); hashMap.put("hostname",ospfInfo.getHostname()); List<OspfErrorLog> ospfErrorLogs = errorLogMapper.selectAllByParams(hashMap); if(ospfErrorLogs==null||ospfErrorLogs.size()==0){ OspfErrorLog ospfErrorLog = new OspfErrorLog(); ospfErrorLog.setInfoContent(ospfInfo.getInfoContent()); ospfErrorLog.setHostname(ospfInfo.getHostname()); ospfErrorLog.setState("1"); ospfErrorLog.setId(UUIDUtil.getUUID()); ospfErrorLog.setCreateTime(DateUtil.getNowTime()); try { errorLogMapper.save(ospfErrorLog); }catch (Exception e){ e.printStackTrace(); } } } ospfInfo.setState(responseBody); OspfInfoMapper.updateById(ospfInfo); } catch (Exception e) { e.printStackTrace(); ospfInfo.setState("1"); OspfInfoMapper.updateById(ospfInfo); } } } /** * 获取OSPF接口状态 */ public String getOspfInterfaceStatus() { String command = "display ospf interface"; return routerConnectionService.executeCommand(command); } // public String getOspfInterfaceStatus() { // String command = "display ospf interface"; // return routerConnectionService.executeCommand(command); // } public int countByParams(Map<String, Object> params) throws Exception { src/main/java/com/wgcloud/service/RouterConnectionService.java
@@ -14,25 +14,38 @@ @Service public class RouterConnectionService { @Value("${router.host}") private String routerHost; @Value("${router.username}") private String routerUsername; @Value("${router.password}") private String routerPassword; private Session session; // /** // * 连接到路由器 // */ // public boolean connect() { // try { // JSch jsch = new JSch(); // session = jsch.getSession(routerUsername, routerHost, 22); // session.setPassword(routerPassword); // // // 设置不进行主机密钥检查 // Properties config = new Properties(); // config.put("StrictHostKeyChecking", "no"); // session.setConfig(config); // // session.connect(5000); // 5秒超时 // return true; // } catch (JSchException e) { // System.err.println("连接路由器失败: " + e.getMessage()); // return false; // } // } /** * 连接到路由器 */ public boolean connect() { public boolean connect(String username,String hostname,String password) { try { JSch jsch = new JSch(); session = jsch.getSession(routerUsername, routerHost, 22); session.setPassword(routerPassword); session = jsch.getSession(username, hostname, 22); session.setPassword(password); // 设置不进行主机密钥检查 Properties config = new Properties(); @@ -59,18 +72,19 @@ /** * 执行路由器命令 */ public String executeCommand(String command) { if (!isConnected()) { if (!connect()) { return null; } public String executeCommand(String command,String username,String password,String hostname) { // if (!isConnected()) { // if (!connect(username,hostname,password)) { // return null; // } // } if (!connect(username,hostname,password)) { return null; } try { ChannelExec channel = (ChannelExec) session.openChannel("exec"); channel.setCommand(command); channel.connect(); BufferedReader reader = new BufferedReader(new InputStreamReader(channel.getInputStream())); StringBuilder output = new StringBuilder(); String line; @@ -81,6 +95,7 @@ reader.close(); channel.disconnect(); disconnect(); return output.toString(); } catch (Exception e) { System.err.println("执行命令失败: " + e.getMessage()); @@ -95,4 +110,4 @@ public boolean isConnected() { return session != null && session.isConnected(); } } } src/main/java/com/wgcloud/task/DataScheduledTask.java
@@ -97,7 +97,7 @@ * 29秒后执行,之后每隔29秒执行, 单位:ms。 * 批量提交数据 */ @Scheduled(initialDelay = 29000L, fixedRate = 29 * 1000) //@Scheduled(initialDelay = 29000L, fixedRate = 29 * 1000) public synchronized void commitTask() { if (DateUtil.isClearTime()) { logger.info("正在清空历史趋势图数据,不执行提交监控数据----------" + DateUtil.getCurrentDateTime()); @@ -470,7 +470,7 @@ * 每天凌晨8:24:30执行 * 清理历史数据过程即将结束时,将主机、端口、进程、docker的更新时间刷新为当前时间 */ @Scheduled(cron = "30 24 8 * * ?") //@Scheduled(cron = "30 24 8 * * ?") public void refreshCommitDate() { try { taskUtilService.refreshCommitDate(); @@ -483,7 +483,7 @@ * 每天凌晨8:10执行 * 删除历史趋势图数据,默认15天 */ @Scheduled(cron = "0 10 8 * * ?") //@Scheduled(cron = "0 10 8 * * ?") public void clearHisdataTask() { if (!StaticKeys.NODE_MASTER.equals(commonConfig.getNodeType())) { logger.info("slave节点不执行清空历史趋势图数据任务"); src/main/java/com/wgcloud/task/ScheduledTask.java
@@ -69,12 +69,25 @@ @Autowired private SnmpInfoService snmpInfoService; @Autowired private OspfInfoService ospfInfoService; @Autowired private CommonConfig commonConfig; @Autowired private MailConfig mailConfig; @Autowired private ServletContext servletContext; /** * 30秒后执行,每1分钟检测一次 * 检测ospf状态 */ @Scheduled(initialDelay = 30000L, fixedRate = 2 * 60 * 1000) public void ospfDownCheckTask() { logger.info("ospf链路检测任务开始------------" + DateUtil.getDateTimeString(new Date())); //ospfInfoService.getDetailedOspfNeighborInfo(); ospfInfoService.getRouterStatus(); logger.info("ospf链路检测任务结束------------" + DateUtil.getDateTimeString(new Date())); } /** * 5秒后执行,之后每24小时刷新一次 @@ -113,7 +126,7 @@ * 20秒后执行,之后每6分钟刷新一次 * 初始化一些任务 */ @Scheduled(initialDelay = 20000L, fixedRate = 6 * 60 * 1000) //@Scheduled(initialDelay = 20000L, fixedRate = 6 * 60 * 1000) public void initTask() { logger.info("initTask------------" + DateUtil.getDateTimeString(new Date())); try { @@ -149,7 +162,7 @@ * 15秒后执行,之后每小时刷新一次 * 获取所有磁盘总容量之和,缓存起来 */ @Scheduled(initialDelay = 15000L, fixedRate = 60 * 60 * 1000) //@Scheduled(initialDelay = 15000L, fixedRate = 60 * 60 * 1000) public void sumDiskSizeCacheTask() { logger.info("sumDiskSizeCacheTask------------" + DateUtil.getDateTimeString(new Date())); try { @@ -163,7 +176,7 @@ * 150秒后执行,之后每隔15分钟执行, 单位:ms。 * snmp设备监测 */ @Scheduled(initialDelay = 150000L, fixedRateString = "${base.snmpTimes}" + "000") //@Scheduled(initialDelay = 150000L, fixedRateString = "${base.snmpTimes}" + "000") public void snmpInfoTask() { if (!StaticKeys.NODE_MASTER.equals(commonConfig.getNodeType())) { logger.info("slave节点不执行snmp设备监测任务"); @@ -200,7 +213,7 @@ * 60秒后执行,之后每隔10分钟执行, 单位:ms。 * 检测服务接口 */ @Scheduled(initialDelay = 60000L, fixedRateString = "${base.heathTimes}" + "000") //@Scheduled(initialDelay = 60000L, fixedRateString = "${base.heathTimes}" + "000") public void heathMonitorTask() { if (!StaticKeys.NODE_MASTER.equals(commonConfig.getNodeType())) { logger.info("slave节点不执行检测服务接口任务"); @@ -236,7 +249,7 @@ * 90秒后执行,之后每隔15分钟执行, 单位:ms。 * 检测数通PING设备 */ @Scheduled(initialDelay = 90000L, fixedRateString = "${base.dceTimes}" + "000") //@Scheduled(initialDelay = 90000L, fixedRateString = "${base.dceTimes}" + "000") public void dceInfoTask() { if (!StaticKeys.NODE_MASTER.equals(commonConfig.getNodeType())) { logger.info("slave节点不执行检测数通设备PING任务"); @@ -272,7 +285,7 @@ * 120秒后执行,之后每隔120分钟执行, 单位:ms。 * 数据表监控 */ @Scheduled(initialDelay = 120000L, fixedRateString = "${base.dbTableTimes}" + "000") //@Scheduled(initialDelay = 120000L, fixedRateString = "${base.dbTableTimes}" + "000") public void tableCountTask() { if (!StaticKeys.NODE_MASTER.equals(commonConfig.getNodeType())) { logger.info("slave节点不执行数据表监控任务"); @@ -291,7 +304,7 @@ * 300秒后执行,每6分钟检测一次 * 检测主机是否已经下线,检测进程、端口、docker、文件防篡改是否恢复 */ @Scheduled(initialDelay = 300000L, fixedRate = 5 * 60 * 1000) //@Scheduled(initialDelay = 300000L, fixedRate = 5 * 60 * 1000) public void hostDownCheckTask() { if (!StaticKeys.NODE_MASTER.equals(commonConfig.getNodeType())) { logger.info("slave节点不执行检测主机/进程/docker/端口是否恢复任务"); src/main/resources/application.yml
@@ -1,5 +1,5 @@ server: port: 10001 port: 8889 servlet: session: timeout: 120m @@ -14,7 +14,7 @@ name: wgcloud-server datasource: driver-class-name: com.mysql.jdbc.Driver url: jdbc:mysql://localhost:3306/wgcloud?characterEncoding=utf-8&characterSetResults=utf8&autoReconnect=true&useSSL=false&allowMultiQueries=true&allowPublicKeyRetrieval=true url: jdbc:mysql://120.1.33.103:10001/wgcloud?characterEncoding=utf-8&characterSetResults=utf8&autoReconnect=true&useSSL=false&allowMultiQueries=true&allowPublicKeyRetrieval=true username: root password: rootroot # hikari连接池的参数 相关设置 @@ -209,9 +209,8 @@ varDatas: /collect/api/realData/varDatas alarm: /collect/api/alarm/findByPage router: host: 192.168.1.1 username: xxxxx password: xxxxx osfService: host: 127.0.0.1 port: 8081 src/main/resources/mybatis/mapper/OspfErrorLogMapper.xml
New file @@ -0,0 +1,178 @@ <?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="com.wgcloud.mapper.OspfErrorLogMapper"> <resultMap id="resultMap" type="com.wgcloud.entity.OspfErrorLog"> <id column="ID" property="id" jdbcType="CHAR" /> <result column="HOST_NAME" property="hostname" jdbcType="CHAR" /> <result column="INFO_CONTENT" property="infoContent" jdbcType="CHAR" /> <result column="STATE" property="state" jdbcType="CHAR" /> <result column="CREATE_TIME" property="createTime" jdbcType="TIMESTAMP" /> </resultMap> <sql id="tableColumnList"> ID,HOST_NAME, INFO_CONTENT, STATE,CREATE_TIME </sql> <sql id="queryByParams"> <if test="hostname != null"> <choose> <when test="_databaseId == 'oracle'"> <![CDATA[ AND HOST_NAME LIKE CONCAT(CONCAT('%',#{hostname}),'%') ]]> </when> <otherwise> <![CDATA[ AND HOST_NAME LIKE CONCAT('%',#{hostname},'%') ]]> </otherwise> </choose> </if> <if test="hostnameNe != null"> <choose> <when test="_databaseId == 'oracle'"> <![CDATA[ AND HOST_NAME NOT LIKE CONCAT(CONCAT('%',#{hostnameNe}),'%') ]]> </when> <otherwise> <![CDATA[ AND HOST_NAME NOT LIKE CONCAT('%',#{hostnameNe},'%') ]]> </otherwise> </choose> </if> <if test="startTime != null and endTime !=null and startTime !='' and endTime != '' "> <if test="_databaseId == 'mysql'"> <![CDATA[ AND CREATE_TIME >= #{startTime} and CREATE_TIME <=#{endTime}]]> </if> <if test="_databaseId == 'postgresql'"> <![CDATA[ AND CREATE_TIME >= cast(#{startTime} as timestamp) and CREATE_TIME <= cast(#{endTime} as timestamp)]]> </if> <if test="_databaseId == 'oracle'"> <![CDATA[ AND CREATE_TIME >= to_date(#{startTime},'yyyy-MM-dd hh24:mi:ss') and CREATE_TIME <= to_date(#{endTime},'yyyy-MM-dd hh24:mi:ss')]]> </if> </if> <if test="state != null"> <![CDATA[ AND STATE = #{state} ]]> </if> </sql> <select id="selectById" resultMap="resultMap" parameterType="java.lang.String"> SELECT <include refid="tableColumnList" /> FROM OSPF_ERROR_LOG WHERE ID=#{id} </select> <delete id="deleteByPrimaryKey" parameterType="java.lang.String"> DELETE FROM OSPF_ERROR_LOG WHERE ID = #{id} </delete> <delete id="deleteByDate" parameterType="map"> DELETE FROM OSPF_ERROR_LOG WHERE <if test="_databaseId == 'mysql'"> <![CDATA[ CREATE_TIME <=#{endTime}]]> </if> <if test="_databaseId == 'postgresql'"> <![CDATA[ CREATE_TIME <= cast(#{endTime} as timestamp)]]> </if> <if test="_databaseId == 'oracle'"> <![CDATA[ CREATE_TIME <= to_date(#{endTime},'yyyy-MM-dd hh24:mi:ss')]]> </if> </delete> <delete id="deleteByAccHname" parameterType="map"> DELETE FROM OSPF_ERROR_LOG WHERE ACCOUNT = #{account} AND HOST_NAME = #{hostname} </delete> <delete id="deleteById" parameterType="java.lang.String"> DELETE FROM OSPF_ERROR_LOG WHERE ID IN <foreach item="item" index="index" collection="array" open="(" separator="," close=")"> #{item} </foreach> </delete> <insert id="insertList" parameterType="java.util.List" > <choose> <when test="_databaseId == 'oracle'"> begin <foreach collection="list" item="item" index="index"> INSERT INTO OSPF_ERROR_LOG (ID,HOST_NAME,INFO_CONTENT,STATE,CREATE_TIME) VALUES (#{item.id},#{item.hostname},#{item.infoContent},#{item.state},#{item.createTime}); </foreach> end; </when> <otherwise> INSERT INTO OSPF_ERROR_LOG (ID,HOST_NAME,INFO_CONTENT,STATE,CREATE_TIME) VALUES <foreach collection="list" item="item" index="index" separator="," > (#{item.id},#{item.hostname},#{item.infoContent},#{item.state},#{item.createTime}) </foreach> </otherwise> </choose> </insert> <insert id="save" parameterType="com.wgcloud.entity.OspfErrorLog"> INSERT INTO OSPF_ERROR_LOG <trim prefix="(" suffix=")" suffixOverrides="," > <if test="id != null" >ID,</if> <if test="hostname != null" > HOST_NAME,</if> <if test="infoContent != null">INFO_CONTENT,</if> <if test="state != null" >STATE,</if> <if test="createTime != null" >CREATE_TIME</if> </trim> <trim prefix="values (" suffix=")" suffixOverrides="," > <if test="id != null" >#{id},</if> <if test="hostname != null" >#{hostname},</if> <if test="infoContent != null" >#{infoContent},</if> <if test="state != null" >#{state},</if> <if test="createTime != null" >#{createTime}</if> </trim> </insert> <select id="countByParams" parameterType="map" resultType="java.lang.Integer"> SELECT count(*) FROM OSPF_ERROR_LOG t <where> <include refid="queryByParams" /> </where> </select> <select id="selectAllByParams" parameterType="map" resultMap="resultMap"> SELECT <include refid="tableColumnList" /> FROM OSPF_ERROR_LOG t <where> <include refid="queryByParams" /> </where> ORDER BY CREATE_TIME DESC </select> <select id="selectByParams" parameterType="map" resultMap="resultMap"> SELECT <include refid="tableColumnList" /> FROM OSPF_ERROR_LOG <where> <include refid="queryByParams" /> </where> ORDER BY CREATE_TIME DESC </select> <update id="updateById" parameterType="com.wgcloud.entity.OspfErrorLog"> UPDATE OSPF_ERROR_LOG <set> <if test="hostname != null"> HOST_NAME = #{hostname}, </if> <if test="infoContent != null"> INFO_CONTENT = #{infoContent}, </if> <if test="state != null"> STATE = #{state}, </if> <if test="createTime != null"> CREATE_TIME = #{createTime}, </if> </set> WHERE ID = #{id} </update> </mapper> wgcloud-server.iml
@@ -1,132 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> <module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> <module version="4"> <component name="FacetManager"> <facet type="web" name="Web"> <configuration> <webroots /> </configuration> </facet> <facet type="Spring" name="Spring"> <configuration /> </facet> </component> <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8"> <output url="file://$MODULE_DIR$/target/classes" /> <output-test url="file://$MODULE_DIR$/target/test-classes" /> <content url="file://$MODULE_DIR$"> <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" /> <excludeFolder url="file://$MODULE_DIR$/target" /> </content> <orderEntry type="inheritedJdk" /> <orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-thymeleaf:2.6.6" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:2.6.6" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:2.6.6" level="project" /> <orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.2.11" level="project" /> <orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.2.11" level="project" /> <orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-to-slf4j:2.17.2" level="project" /> <orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.17.2" level="project" /> <orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.36" level="project" /> <orderEntry type="library" name="Maven: jakarta.annotation:jakarta.annotation-api:1.3.5" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-core:5.3.18" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.3.18" level="project" /> <orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.29" level="project" /> <orderEntry type="library" name="Maven: org.thymeleaf:thymeleaf-spring5:3.0.15.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.thymeleaf:thymeleaf:3.0.15.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.attoparser:attoparser:2.0.5.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.unbescape:unbescape:1.1.6.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.thymeleaf.extras:thymeleaf-extras-java8time:3.0.4.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:2.6.6" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-json:2.6.6" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:2.6.6" level="project" /> <orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:9.0.60" level="project" /> <orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:9.0.60" level="project" /> <orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:9.0.60" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-web:5.3.18" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-beans:5.3.18" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-webmvc:5.3.18" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-aop:5.3.18" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-context:5.3.18" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-expression:5.3.18" level="project" /> <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.14.0-rc3" level="project" /> <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.13.2" level="project" /> <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.13.2" level="project" /> <orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.14.0-rc3" level="project" /> <orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.14.0-rc3" level="project" /> <orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.14.0-rc3" level="project" /> <orderEntry type="library" name="Maven: org.projectlombok:lombok:1.18.22" level="project" /> <orderEntry type="library" name="Maven: cn.hutool:hutool-all:5.6.5" level="project" /> <orderEntry type="library" name="Maven: mysql:mysql-connector-java:8.0.28" level="project" /> <orderEntry type="library" name="Maven: org.mariadb.jdbc:mariadb-java-client:2.7.3" level="project" /> <orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-starter:1.4.2" level="project" /> <orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-autoconfigure:1.4.2" level="project" /> <orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper:5.3.0" level="project" /> <orderEntry type="library" name="Maven: com.github.jsqlparser:jsqlparser:4.2" level="project" /> <orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.12.0" level="project" /> <orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.4" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:2.6.6" level="project" /> <orderEntry type="library" name="Maven: com.zaxxer:HikariCP:4.0.3" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-jdbc:5.3.18" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-tx:5.3.18" level="project" /> <orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:2.1.4" level="project" /> <orderEntry type="library" name="Maven: org.mybatis:mybatis-spring:2.0.6" level="project" /> <orderEntry type="library" name="Maven: org.mybatis:mybatis:3.5.6" level="project" /> <orderEntry type="library" name="Maven: net.sourceforge.htmlunit:htmlunit:2.66.0" level="project" /> <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpmime:4.5.13" level="project" /> <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.13" level="project" /> <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.15" level="project" /> <orderEntry type="library" name="Maven: net.sourceforge.htmlunit:htmlunit-core-js:2.66.0" level="project" /> <orderEntry type="library" name="Maven: net.sourceforge.htmlunit:neko-htmlunit:2.66.0" level="project" /> <orderEntry type="library" name="Maven: xerces:xercesImpl:2.12.2" level="project" /> <orderEntry type="library" name="Maven: xml-apis:xml-apis:1.4.01" level="project" /> <orderEntry type="library" name="Maven: net.sourceforge.htmlunit:htmlunit-cssparser:1.12.0" level="project" /> <orderEntry type="library" name="Maven: net.sourceforge.htmlunit:htmlunit-xpath:2.66.0" level="project" /> <orderEntry type="library" name="Maven: org.apache.commons:commons-text:1.10.0" level="project" /> <orderEntry type="library" name="Maven: commons-io:commons-io:2.10.0" level="project" /> <orderEntry type="library" name="Maven: commons-net:commons-net:3.8.0" level="project" /> <orderEntry type="library" name="Maven: commons-codec:commons-codec:1.15" level="project" /> <orderEntry type="library" name="Maven: org.brotli:dec:0.1.2" level="project" /> <orderEntry type="library" name="Maven: com.shapesecurity:salvation2:3.0.1" level="project" /> <orderEntry type="library" name="Maven: org.eclipse.jetty.websocket:websocket-client:9.4.45.v20220203" level="project" /> <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-client:9.4.45.v20220203" level="project" /> <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-http:9.4.45.v20220203" level="project" /> <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-util:9.4.45.v20220203" level="project" /> <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-io:9.4.45.v20220203" level="project" /> <orderEntry type="library" name="Maven: org.eclipse.jetty.websocket:websocket-common:9.4.45.v20220203" level="project" /> <orderEntry type="library" name="Maven: org.eclipse.jetty.websocket:websocket-api:9.4.45.v20220203" level="project" /> <orderEntry type="library" name="Maven: org.apache.commons:commons-email:1.5" level="project" /> <orderEntry type="library" name="Maven: com.sun.mail:javax.mail:1.5.6" level="project" /> <orderEntry type="library" name="Maven: javax.activation:activation:1.1" level="project" /> <orderEntry type="library" name="Maven: org.postgresql:postgresql:42.5.0" level="project" /> <orderEntry type="library" scope="RUNTIME" name="Maven: org.checkerframework:checker-qual:3.5.0" level="project" /> <orderEntry type="library" name="Maven: com.jcraft:jsch:0.1.55" level="project" /> <orderEntry type="library" name="Maven: io.netty:netty-all:4.1.63.Final" level="project" /> <orderEntry type="library" name="Maven: com.alibaba:easyexcel:2.2.10" level="project" /> <orderEntry type="library" name="Maven: org.apache.poi:poi:3.17" level="project" /> <orderEntry type="library" name="Maven: org.apache.commons:commons-collections4:4.1" level="project" /> <orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml:3.17" level="project" /> <orderEntry type="library" name="Maven: com.github.virtuald:curvesapi:1.04" level="project" /> <orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml-schemas:3.17" level="project" /> <orderEntry type="library" name="Maven: org.apache.xmlbeans:xmlbeans:2.6.0" level="project" /> <orderEntry type="library" name="Maven: stax:stax-api:1.0.1" level="project" /> <orderEntry type="library" name="Maven: cglib:cglib:3.1" level="project" /> <orderEntry type="library" name="Maven: org.ow2.asm:asm:4.2" level="project" /> <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.36" level="project" /> <orderEntry type="library" name="Maven: org.ehcache:ehcache:3.9.9" level="project" /> <orderEntry type="library" name="Maven: net.jodah:expiringmap:0.5.10" level="project" /> <orderEntry type="library" name="Maven: com.googlecode.aviator:aviator:5.3.0" level="project" /> <orderEntry type="library" name="Maven: org.snmp4j:snmp4j:2.8.10" level="project" /> <orderEntry type="library" name="Maven: com.cronutils:cron-utils:9.1.6" level="project" /> <orderEntry type="library" name="Maven: org.javassist:javassist:3.27.0-GA" level="project" /> <orderEntry type="library" name="Maven: org.glassfish:javax.el:3.0.0" level="project" /> <orderEntry type="library" name="Maven: redis.clients:jedis:4.3.1" level="project" /> <orderEntry type="library" name="Maven: org.apache.commons:commons-pool2:2.11.1" level="project" /> <orderEntry type="library" name="Maven: org.json:json:20220320" level="project" /> <orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.9" level="project" /> <orderEntry type="library" name="Maven: org.mongodb:mongo-java-driver:3.12.11" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-devtools:2.6.6" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.6.6" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:2.6.6" level="project" /> </component> </module>