summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortanghao <admin@LAPTOP-QCSKVLI9>2021-05-08 19:33:06 +0800
committertanghao <admin@LAPTOP-QCSKVLI9>2021-05-08 19:33:06 +0800
commitcae28168a575d7209bd6b2b3c707a0afc169e5b2 (patch)
treefefb208c544f6e344cf68b5462f559df9309453b
parentf6a373eec180f06efcf2ee6cefd67f71f333dca9 (diff)
init
-rw-r--r--pom.xml101
-rw-r--r--src/main/java/com/nis/TransferApplication.java16
-rw-r--r--src/main/java/com/nis/config/MybatisPlusConfig.java104
-rw-r--r--src/main/java/com/nis/dao/AccountDao.java16
-rw-r--r--src/main/java/com/nis/dao/AlertMessageActiveDao.java12
-rw-r--r--src/main/java/com/nis/dao/AlertMessageDao.java17
-rw-r--r--src/main/java/com/nis/dao/AlertMessageHistoryDao.java14
-rw-r--r--src/main/java/com/nis/dao/AlertRuleDao.java14
-rw-r--r--src/main/java/com/nis/dao/AssetAssetDao.java17
-rw-r--r--src/main/java/com/nis/dao/AssetBrandDao.java17
-rw-r--r--src/main/java/com/nis/dao/AssetDao.java19
-rw-r--r--src/main/java/com/nis/dao/AssetFieldMetaDao.java18
-rw-r--r--src/main/java/com/nis/dao/AssetFieldValueDao.java12
-rw-r--r--src/main/java/com/nis/dao/AssetModelDao.java15
-rw-r--r--src/main/java/com/nis/dao/AssetTagDao.java13
-rw-r--r--src/main/java/com/nis/dao/AssetTypeConfDao.java22
-rw-r--r--src/main/java/com/nis/dao/ChartDao.java22
-rw-r--r--src/main/java/com/nis/dao/ChartElementDao.java22
-rw-r--r--src/main/java/com/nis/dao/DcDao.java21
-rw-r--r--src/main/java/com/nis/dao/EndpointDao.java21
-rw-r--r--src/main/java/com/nis/dao/IdcDao.java23
-rw-r--r--src/main/java/com/nis/dao/ModelDao.java24
-rw-r--r--src/main/java/com/nis/dao/ModuleDao.java24
-rw-r--r--src/main/java/com/nis/dao/MonitorEndpointDao.java24
-rw-r--r--src/main/java/com/nis/dao/MonitorModuleDao.java24
-rw-r--r--src/main/java/com/nis/dao/MonitorProjectDao.java24
-rw-r--r--src/main/java/com/nis/dao/PanelDao.java23
-rw-r--r--src/main/java/com/nis/dao/ProjectDao.java24
-rw-r--r--src/main/java/com/nis/dao/SnmpCredentialDao.java11
-rw-r--r--src/main/java/com/nis/dao/SqlDao.java24
-rw-r--r--src/main/java/com/nis/dao/SysDictDao.java19
-rw-r--r--src/main/java/com/nis/dao/VisualChartDao.java23
-rw-r--r--src/main/java/com/nis/dao/VisualChartElementDao.java21
-rw-r--r--src/main/java/com/nis/dao/VisualPanelDao.java21
-rw-r--r--src/main/java/com/nis/entity/Account.java27
-rw-r--r--src/main/java/com/nis/entity/AlertMessageActiveEntity.java123
-rw-r--r--src/main/java/com/nis/entity/AlertMessageEntity.java116
-rw-r--r--src/main/java/com/nis/entity/AlertMessageHistoryEntity.java122
-rw-r--r--src/main/java/com/nis/entity/AlertRuleEntity.java82
-rw-r--r--src/main/java/com/nis/entity/AlertSeverityConf.java29
-rw-r--r--src/main/java/com/nis/entity/AlertSilenceConf.java58
-rw-r--r--src/main/java/com/nis/entity/Asset.java95
-rw-r--r--src/main/java/com/nis/entity/AssetAsset.java180
-rw-r--r--src/main/java/com/nis/entity/AssetBrand.java36
-rw-r--r--src/main/java/com/nis/entity/AssetFieldGroup.java21
-rw-r--r--src/main/java/com/nis/entity/AssetFieldMeta.java53
-rw-r--r--src/main/java/com/nis/entity/AssetFieldValue.java21
-rw-r--r--src/main/java/com/nis/entity/AssetModel.java53
-rw-r--r--src/main/java/com/nis/entity/AssetStateConf.java51
-rw-r--r--src/main/java/com/nis/entity/AssetTag.java40
-rw-r--r--src/main/java/com/nis/entity/AssetTypeConf.java83
-rw-r--r--src/main/java/com/nis/entity/Chart.java81
-rw-r--r--src/main/java/com/nis/entity/ChartElement.java44
-rw-r--r--src/main/java/com/nis/entity/Dc.java80
-rw-r--r--src/main/java/com/nis/entity/Endpoint.java44
-rw-r--r--src/main/java/com/nis/entity/Idc.java77
-rw-r--r--src/main/java/com/nis/entity/Model.java59
-rw-r--r--src/main/java/com/nis/entity/Module.java39
-rw-r--r--src/main/java/com/nis/entity/MonitorEndpoint.java79
-rw-r--r--src/main/java/com/nis/entity/MonitorModule.java69
-rw-r--r--src/main/java/com/nis/entity/MonitorProject.java74
-rw-r--r--src/main/java/com/nis/entity/Panel.java53
-rw-r--r--src/main/java/com/nis/entity/Project.java17
-rw-r--r--src/main/java/com/nis/entity/Promserver.java42
-rw-r--r--src/main/java/com/nis/entity/SnmpCredential.java23
-rw-r--r--src/main/java/com/nis/entity/StateInfo.java9
-rw-r--r--src/main/java/com/nis/entity/SysConfigEntity.java30
-rw-r--r--src/main/java/com/nis/entity/SysDictEntity.java82
-rw-r--r--src/main/java/com/nis/entity/VisualChart.java57
-rw-r--r--src/main/java/com/nis/entity/VisualChartElement.java27
-rw-r--r--src/main/java/com/nis/entity/VisualPanel.java43
-rw-r--r--src/main/java/com/nis/handler/AfterHandler.java39
-rw-r--r--src/main/java/com/nis/handler/BeforeHandler.java53
-rw-r--r--src/main/java/com/nis/handler/SqlHandler.java1002
-rw-r--r--src/main/java/com/nis/handler/TransferDataHandler.java41
-rw-r--r--src/main/java/com/nis/service/AccountService.java10
-rw-r--r--src/main/java/com/nis/service/AlertMessageActiveService.java14
-rw-r--r--src/main/java/com/nis/service/AlertMessageHistoryService.java14
-rw-r--r--src/main/java/com/nis/service/AlertMessageService.java14
-rw-r--r--src/main/java/com/nis/service/AlertRuleService.java15
-rw-r--r--src/main/java/com/nis/service/AssetAssetService.java12
-rw-r--r--src/main/java/com/nis/service/AssetBrandService.java12
-rw-r--r--src/main/java/com/nis/service/AssetFieldMetaService.java12
-rw-r--r--src/main/java/com/nis/service/AssetFieldValueService.java8
-rw-r--r--src/main/java/com/nis/service/AssetModelService.java13
-rw-r--r--src/main/java/com/nis/service/AssetService.java8
-rw-r--r--src/main/java/com/nis/service/AssetTagService.java10
-rw-r--r--src/main/java/com/nis/service/AssetTypeConfService.java10
-rw-r--r--src/main/java/com/nis/service/ChartElementService.java12
-rw-r--r--src/main/java/com/nis/service/ChartService.java14
-rw-r--r--src/main/java/com/nis/service/DcService.java13
-rw-r--r--src/main/java/com/nis/service/EndpointService.java13
-rw-r--r--src/main/java/com/nis/service/IdcService.java10
-rw-r--r--src/main/java/com/nis/service/ModelService.java11
-rw-r--r--src/main/java/com/nis/service/ModuleService.java11
-rw-r--r--src/main/java/com/nis/service/MonitorEndpointService.java11
-rw-r--r--src/main/java/com/nis/service/MonitorModuleService.java11
-rw-r--r--src/main/java/com/nis/service/MonitorProjectService.java11
-rw-r--r--src/main/java/com/nis/service/PanelService.java12
-rw-r--r--src/main/java/com/nis/service/ProjectService.java11
-rw-r--r--src/main/java/com/nis/service/SnmpCredentialService.java10
-rw-r--r--src/main/java/com/nis/service/SysDictService.java25
-rw-r--r--src/main/java/com/nis/service/VisualChartElementService.java12
-rw-r--r--src/main/java/com/nis/service/VisualChartService.java12
-rw-r--r--src/main/java/com/nis/service/VisualPanelService.java12
-rw-r--r--src/main/java/com/nis/service/impl/AccountServiceImpl.java28
-rw-r--r--src/main/java/com/nis/service/impl/AlertMessageActiveServiceImpl.java23
-rw-r--r--src/main/java/com/nis/service/impl/AlertMessageHistoryServiceImpl.java23
-rw-r--r--src/main/java/com/nis/service/impl/AlertMessageServiceImpl.java91
-rw-r--r--src/main/java/com/nis/service/impl/AlertRuleServiceImpl.java26
-rw-r--r--src/main/java/com/nis/service/impl/AssetAssetServiceImpl.java234
-rw-r--r--src/main/java/com/nis/service/impl/AssetBrandServiceImpl.java56
-rw-r--r--src/main/java/com/nis/service/impl/AssetFieldMetaServiceImpl.java26
-rw-r--r--src/main/java/com/nis/service/impl/AssetFieldValueServiceImpl.java13
-rw-r--r--src/main/java/com/nis/service/impl/AssetModelServiceImpl.java57
-rw-r--r--src/main/java/com/nis/service/impl/AssetServiceImpl.java25
-rw-r--r--src/main/java/com/nis/service/impl/AssetTagServiceImpl.java14
-rw-r--r--src/main/java/com/nis/service/impl/AssetTypeConfServiceImpl.java28
-rw-r--r--src/main/java/com/nis/service/impl/ChartElementServiceImpl.java24
-rw-r--r--src/main/java/com/nis/service/impl/ChartServiceImpl.java153
-rw-r--r--src/main/java/com/nis/service/impl/DcServiceImpl.java51
-rw-r--r--src/main/java/com/nis/service/impl/EndpointServiceImpl.java213
-rw-r--r--src/main/java/com/nis/service/impl/IdcServiceImpl.java17
-rw-r--r--src/main/java/com/nis/service/impl/ModelServiceImpl.java23
-rw-r--r--src/main/java/com/nis/service/impl/ModuleServiceImpl.java20
-rw-r--r--src/main/java/com/nis/service/impl/MonitorEndpointServiceImpl.java20
-rw-r--r--src/main/java/com/nis/service/impl/MonitorModuleServiceImpl.java20
-rw-r--r--src/main/java/com/nis/service/impl/MonitorProjectServiceImpl.java20
-rw-r--r--src/main/java/com/nis/service/impl/PanelServiceImpl.java23
-rw-r--r--src/main/java/com/nis/service/impl/ProjectServiceImpl.java20
-rw-r--r--src/main/java/com/nis/service/impl/SnmpCredentialServiceImpl.java21
-rw-r--r--src/main/java/com/nis/service/impl/SysDictServiceImpl.java29
-rw-r--r--src/main/java/com/nis/service/impl/VisualChartElementServiceImpl.java24
-rw-r--r--src/main/java/com/nis/service/impl/VisualChartServiceImpl.java24
-rw-r--r--src/main/java/com/nis/service/impl/VisualPanelServiceImpl.java26
-rw-r--r--src/main/java/com/nis/util/Constant.java69
-rw-r--r--src/main/java/com/nis/util/SQLUtils.java102
-rw-r--r--src/main/java/com/nis/util/SpringContextUtils.java49
-rw-r--r--src/main/java/com/nis/util/SqlHelper/KeywordsType.java16
-rw-r--r--src/main/java/com/nis/util/SqlHelper/MysqlHelper.java188
-rw-r--r--src/main/java/com/nis/util/ToolUtil.java331
-rw-r--r--src/main/resources/application.yml29
-rw-r--r--src/main/resources/mapper/sql.xml21
143 files changed, 6716 insertions, 0 deletions
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..dfd7c68
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-parent</artifactId>
+ <version>2.4.5</version>
+ <relativePath/> <!-- lookup parent from repository -->
+ </parent>
+ <groupId>com.nis</groupId>
+ <artifactId>transfer</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <name>transfer</name>
+ <description>data transfer</description>
+ <properties>
+ <java.version>1.8</java.version>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-logging</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>cn.hutool</groupId>
+ <artifactId>hutool-all</artifactId>
+ <version>5.5.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <!-- mysql驱动 -->
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.1.38</version>
+ </dependency>
+ <dependency>
+ <groupId>com.baomidou</groupId>
+ <artifactId>mybatis-plus-boot-starter</artifactId>
+ <version>3.0.7.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>com.baomidou</groupId>
+ <artifactId>mybatis-plus-generator</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>com.alibaba</groupId>
+ <artifactId>fastjson</artifactId>
+ <version>1.2.45</version>
+ </dependency>
+ <dependency>
+ <groupId>com.alibaba</groupId>
+ <artifactId>druid-spring-boot-starter</artifactId>
+ <version>1.1.13</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.5</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>transfer</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.2</version>
+ <configuration>
+ <source>8</source>
+ <target>8</target>
+ <encoding>UTF-8</encoding>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ </plugin>
+ <!-- 跳过单元测试 -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>true</skipTests>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/src/main/java/com/nis/TransferApplication.java b/src/main/java/com/nis/TransferApplication.java
new file mode 100644
index 0000000..e480a8e
--- /dev/null
+++ b/src/main/java/com/nis/TransferApplication.java
@@ -0,0 +1,16 @@
+package com.nis;
+
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+
+@SpringBootApplication
+public class TransferApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(TransferApplication.class, args);
+ }
+
+}
diff --git a/src/main/java/com/nis/config/MybatisPlusConfig.java b/src/main/java/com/nis/config/MybatisPlusConfig.java
new file mode 100644
index 0000000..6f10943
--- /dev/null
+++ b/src/main/java/com/nis/config/MybatisPlusConfig.java
@@ -0,0 +1,104 @@
+package com.nis.config;
+
+import cn.hutool.log.Log;
+import com.baomidou.mybatisplus.core.incrementer.IKeyGenerator;
+import com.baomidou.mybatisplus.core.injector.ISqlInjector;
+import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector;
+import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
+import com.nis.util.Constant;
+import com.nis.util.ToolUtil;
+
+import org.apache.ibatis.mapping.DatabaseIdProvider;
+import org.apache.ibatis.mapping.VendorDatabaseIdProvider;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.DependsOn;
+
+import javax.sql.DataSource;
+import java.sql.SQLException;
+import java.util.Properties;
+
+/**
+ * mybatis-plus配置
+ *
+
+ */
+@Configuration
+public class MybatisPlusConfig {
+ private static final Log logger = Log.get();
+ /**
+ * 分页插件
+ */
+ @Bean
+ public PaginationInterceptor paginationInterceptor() {
+ return new PaginationInterceptor();
+ }
+
+ /*@Bean
+ public SeqKeyGenerator seqKeyGenerator() {
+ return new SeqKeyGenerator();
+ }*/
+
+ @Bean
+ public ISqlInjector sqlInjector() {
+ return new LogicSqlInjector();
+ }
+
+ /**
+ * 自定义主键生成器
+ * @author fang
+ *
+
+ static class SeqKeyGenerator implements IKeyGenerator {
+ @Autowired
+ DatabaseIdProvider databaseIdProvider;
+ @Autowired
+ DataSource dataSource;
+
+ @Override
+ public String executeSql(String incrementerName) {
+ String databaseId = null;
+ try {
+ databaseId = databaseIdProvider.getDatabaseId(dataSource);
+ } catch (SQLException e) {
+ logger.error(e);
+ }
+
+ if(ToolUtil.isEmpty(databaseId)){
+ throw new RuntimeException("MybatisPlusConfig databaseId error");
+ }
+
+ switch (databaseId){
+ case Constant.MYSQL:
+ return String.format("select seq_nextval('%s')", incrementerName);
+ case Constant.POSTGRESQL:
+ return String.format("select seq_nextval('%s')", incrementerName);
+ case Constant.ORACLE:
+ return String.format("select %s.nextval from dual", incrementerName);
+ default:
+ return String.format("select seq_nextval('%s')", incrementerName);
+ }
+ }
+
+ }*/
+ @Bean
+ public DatabaseIdProvider getDatabaseIdProvider(){
+ DatabaseIdProvider databaseIdProvider = new VendorDatabaseIdProvider();
+ Properties properties = new Properties();
+ properties.setProperty("Oracle","oracle");
+ properties.setProperty("MySQL","mysql");
+ properties.setProperty("DB2","db2");
+ properties.setProperty("Derby","derby");
+ properties.setProperty("H2","h2");
+ properties.setProperty("HSQL","hsql");
+ properties.setProperty("Informix","informix");
+ properties.setProperty("MS-SQL","ms-sql");
+ properties.setProperty("PostgreSQL","postgresql");
+ properties.setProperty("Sybase","sybase");
+ properties.setProperty("Hana","hana");
+ databaseIdProvider.setProperties(properties);
+
+ return databaseIdProvider;
+ }
+}
diff --git a/src/main/java/com/nis/dao/AccountDao.java b/src/main/java/com/nis/dao/AccountDao.java
new file mode 100644
index 0000000..d90e432
--- /dev/null
+++ b/src/main/java/com/nis/dao/AccountDao.java
@@ -0,0 +1,16 @@
+package com.nis.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.nis.entity.Account;
+import com.nis.entity.Asset;
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+/**
+ * 资产 dao
+ */
+@Mapper
+@Repository
+public interface AccountDao extends BaseMapper<Account> {
+
+}
diff --git a/src/main/java/com/nis/dao/AlertMessageActiveDao.java b/src/main/java/com/nis/dao/AlertMessageActiveDao.java
new file mode 100644
index 0000000..7b1f4fc
--- /dev/null
+++ b/src/main/java/com/nis/dao/AlertMessageActiveDao.java
@@ -0,0 +1,12 @@
+package com.nis.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.nis.entity.AlertMessageActiveEntity;
+import com.nis.entity.AlertMessageEntity;
+import org.apache.ibatis.annotations.Mapper;
+
+
+@Mapper
+public interface AlertMessageActiveDao extends BaseMapper<AlertMessageActiveEntity> {
+
+}
diff --git a/src/main/java/com/nis/dao/AlertMessageDao.java b/src/main/java/com/nis/dao/AlertMessageDao.java
new file mode 100644
index 0000000..077b2de
--- /dev/null
+++ b/src/main/java/com/nis/dao/AlertMessageDao.java
@@ -0,0 +1,17 @@
+package com.nis.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.nis.entity.AlertMessageEntity;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+@Mapper
+public interface AlertMessageDao extends BaseMapper<AlertMessageEntity> {
+
+}
diff --git a/src/main/java/com/nis/dao/AlertMessageHistoryDao.java b/src/main/java/com/nis/dao/AlertMessageHistoryDao.java
new file mode 100644
index 0000000..b9efba3
--- /dev/null
+++ b/src/main/java/com/nis/dao/AlertMessageHistoryDao.java
@@ -0,0 +1,14 @@
+package com.nis.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.nis.entity.AlertMessageActiveEntity;
+import com.nis.entity.AlertMessageEntity;
+import com.nis.entity.AlertMessageHistoryEntity;
+
+import org.apache.ibatis.annotations.Mapper;
+
+
+@Mapper
+public interface AlertMessageHistoryDao extends BaseMapper<AlertMessageHistoryEntity> {
+
+}
diff --git a/src/main/java/com/nis/dao/AlertRuleDao.java b/src/main/java/com/nis/dao/AlertRuleDao.java
new file mode 100644
index 0000000..4a4d427
--- /dev/null
+++ b/src/main/java/com/nis/dao/AlertRuleDao.java
@@ -0,0 +1,14 @@
+package com.nis.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.nis.entity.AlertMessageActiveEntity;
+import com.nis.entity.AlertMessageEntity;
+import com.nis.entity.AlertRuleEntity;
+
+import org.apache.ibatis.annotations.Mapper;
+
+
+@Mapper
+public interface AlertRuleDao extends BaseMapper<AlertRuleEntity> {
+
+}
diff --git a/src/main/java/com/nis/dao/AssetAssetDao.java b/src/main/java/com/nis/dao/AssetAssetDao.java
new file mode 100644
index 0000000..298b262
--- /dev/null
+++ b/src/main/java/com/nis/dao/AssetAssetDao.java
@@ -0,0 +1,17 @@
+package com.nis.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.nis.entity.Asset;
+import com.nis.entity.AssetAsset;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+/**
+ * 资产 dao
+ */
+@Mapper
+@Repository
+public interface AssetAssetDao extends BaseMapper<AssetAsset> {
+
+}
diff --git a/src/main/java/com/nis/dao/AssetBrandDao.java b/src/main/java/com/nis/dao/AssetBrandDao.java
new file mode 100644
index 0000000..e92e3c5
--- /dev/null
+++ b/src/main/java/com/nis/dao/AssetBrandDao.java
@@ -0,0 +1,17 @@
+package com.nis.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.nis.entity.Asset;
+import com.nis.entity.AssetBrand;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+/**
+ * 资产 dao
+ */
+@Mapper
+@Repository
+public interface AssetBrandDao extends BaseMapper<AssetBrand> {
+
+}
diff --git a/src/main/java/com/nis/dao/AssetDao.java b/src/main/java/com/nis/dao/AssetDao.java
new file mode 100644
index 0000000..188e7ff
--- /dev/null
+++ b/src/main/java/com/nis/dao/AssetDao.java
@@ -0,0 +1,19 @@
+package com.nis.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.nis.entity.Asset;
+
+import java.util.List;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+/**
+ * 资产 dao
+ */
+@Mapper
+@Repository
+public interface AssetDao extends BaseMapper<Asset> {
+
+
+}
diff --git a/src/main/java/com/nis/dao/AssetFieldMetaDao.java b/src/main/java/com/nis/dao/AssetFieldMetaDao.java
new file mode 100644
index 0000000..4a64364
--- /dev/null
+++ b/src/main/java/com/nis/dao/AssetFieldMetaDao.java
@@ -0,0 +1,18 @@
+package com.nis.dao;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.nis.entity.AssetFieldMeta;
+
+@Mapper
+@Repository
+public interface AssetFieldMetaDao extends BaseMapper<AssetFieldMeta>{
+
+}
diff --git a/src/main/java/com/nis/dao/AssetFieldValueDao.java b/src/main/java/com/nis/dao/AssetFieldValueDao.java
new file mode 100644
index 0000000..989b7b5
--- /dev/null
+++ b/src/main/java/com/nis/dao/AssetFieldValueDao.java
@@ -0,0 +1,12 @@
+package com.nis.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.nis.entity.AssetFieldValue;
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+@Mapper
+@Repository
+public interface AssetFieldValueDao extends BaseMapper<AssetFieldValue>{
+
+}
diff --git a/src/main/java/com/nis/dao/AssetModelDao.java b/src/main/java/com/nis/dao/AssetModelDao.java
new file mode 100644
index 0000000..ab26981
--- /dev/null
+++ b/src/main/java/com/nis/dao/AssetModelDao.java
@@ -0,0 +1,15 @@
+package com.nis.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.nis.entity.Asset;
+import com.nis.entity.AssetModel;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+
+@Mapper
+@Repository
+public interface AssetModelDao extends BaseMapper<AssetModel> {
+
+}
diff --git a/src/main/java/com/nis/dao/AssetTagDao.java b/src/main/java/com/nis/dao/AssetTagDao.java
new file mode 100644
index 0000000..ac49547
--- /dev/null
+++ b/src/main/java/com/nis/dao/AssetTagDao.java
@@ -0,0 +1,13 @@
+package com.nis.dao;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.nis.entity.AssetTag;
+
+@Mapper
+@Repository
+public interface AssetTagDao extends BaseMapper<AssetTag>{
+
+}
diff --git a/src/main/java/com/nis/dao/AssetTypeConfDao.java b/src/main/java/com/nis/dao/AssetTypeConfDao.java
new file mode 100644
index 0000000..01e52af
--- /dev/null
+++ b/src/main/java/com/nis/dao/AssetTypeConfDao.java
@@ -0,0 +1,22 @@
+/**
+
+ *
+
+ *
+
+ */
+
+package com.nis.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.nis.entity.AssetTypeConf;
+import com.nis.entity.Dc;
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+
+@Mapper
+@Repository
+public interface AssetTypeConfDao extends BaseMapper<AssetTypeConf> {
+
+}
diff --git a/src/main/java/com/nis/dao/ChartDao.java b/src/main/java/com/nis/dao/ChartDao.java
new file mode 100644
index 0000000..b8ff83a
--- /dev/null
+++ b/src/main/java/com/nis/dao/ChartDao.java
@@ -0,0 +1,22 @@
+/**
+
+ *
+
+ *
+
+ */
+
+package com.nis.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.nis.entity.Chart;
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+
+
+@Mapper
+@Repository
+public interface ChartDao extends BaseMapper<Chart> {
+
+}
diff --git a/src/main/java/com/nis/dao/ChartElementDao.java b/src/main/java/com/nis/dao/ChartElementDao.java
new file mode 100644
index 0000000..27721cf
--- /dev/null
+++ b/src/main/java/com/nis/dao/ChartElementDao.java
@@ -0,0 +1,22 @@
+/**
+
+ *
+
+ *
+
+ */
+
+package com.nis.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.nis.entity.ChartElement;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+
+@Mapper
+@Repository
+public interface ChartElementDao extends BaseMapper<ChartElement> {
+
+}
diff --git a/src/main/java/com/nis/dao/DcDao.java b/src/main/java/com/nis/dao/DcDao.java
new file mode 100644
index 0000000..20fbac6
--- /dev/null
+++ b/src/main/java/com/nis/dao/DcDao.java
@@ -0,0 +1,21 @@
+/**
+
+ *
+
+ *
+
+ */
+
+package com.nis.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.nis.entity.Dc;
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+
+@Mapper
+@Repository
+public interface DcDao extends BaseMapper<Dc> {
+
+}
diff --git a/src/main/java/com/nis/dao/EndpointDao.java b/src/main/java/com/nis/dao/EndpointDao.java
new file mode 100644
index 0000000..e506b2b
--- /dev/null
+++ b/src/main/java/com/nis/dao/EndpointDao.java
@@ -0,0 +1,21 @@
+/**
+
+ *
+
+ *
+
+ */
+
+package com.nis.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.nis.entity.Endpoint;
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+
+@Mapper
+@Repository
+public interface EndpointDao extends BaseMapper<Endpoint> {
+
+}
diff --git a/src/main/java/com/nis/dao/IdcDao.java b/src/main/java/com/nis/dao/IdcDao.java
new file mode 100644
index 0000000..e556ebe
--- /dev/null
+++ b/src/main/java/com/nis/dao/IdcDao.java
@@ -0,0 +1,23 @@
+/**
+
+ *
+
+ *
+
+ */
+
+package com.nis.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.nis.entity.Dc;
+import com.nis.entity.Idc;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+
+@Mapper
+@Repository
+public interface IdcDao extends BaseMapper<Idc> {
+
+}
diff --git a/src/main/java/com/nis/dao/ModelDao.java b/src/main/java/com/nis/dao/ModelDao.java
new file mode 100644
index 0000000..b6014a2
--- /dev/null
+++ b/src/main/java/com/nis/dao/ModelDao.java
@@ -0,0 +1,24 @@
+package com.nis.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.nis.entity.Model;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 资产型号 dao
+ *
+ * @author shizhendong
+ * @date 2019-11-21
+ */
+@Mapper
+@Repository
+public interface ModelDao extends BaseMapper<Model> {
+
+}
diff --git a/src/main/java/com/nis/dao/ModuleDao.java b/src/main/java/com/nis/dao/ModuleDao.java
new file mode 100644
index 0000000..8f4e9c4
--- /dev/null
+++ b/src/main/java/com/nis/dao/ModuleDao.java
@@ -0,0 +1,24 @@
+/**
+
+ *
+
+ *
+
+ */
+
+package com.nis.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.nis.entity.Dc;
+import com.nis.entity.Idc;
+import com.nis.entity.Module;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+
+@Mapper
+@Repository
+public interface ModuleDao extends BaseMapper<Module> {
+
+}
diff --git a/src/main/java/com/nis/dao/MonitorEndpointDao.java b/src/main/java/com/nis/dao/MonitorEndpointDao.java
new file mode 100644
index 0000000..fd101e1
--- /dev/null
+++ b/src/main/java/com/nis/dao/MonitorEndpointDao.java
@@ -0,0 +1,24 @@
+/**
+
+ *
+
+ *
+
+ */
+
+package com.nis.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.nis.entity.Dc;
+import com.nis.entity.Idc;
+import com.nis.entity.MonitorEndpoint;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+
+@Mapper
+@Repository
+public interface MonitorEndpointDao extends BaseMapper<MonitorEndpoint> {
+
+}
diff --git a/src/main/java/com/nis/dao/MonitorModuleDao.java b/src/main/java/com/nis/dao/MonitorModuleDao.java
new file mode 100644
index 0000000..21b07b4
--- /dev/null
+++ b/src/main/java/com/nis/dao/MonitorModuleDao.java
@@ -0,0 +1,24 @@
+/**
+
+ *
+
+ *
+
+ */
+
+package com.nis.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.nis.entity.Dc;
+import com.nis.entity.Idc;
+import com.nis.entity.MonitorModule;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+
+@Mapper
+@Repository
+public interface MonitorModuleDao extends BaseMapper<MonitorModule> {
+
+}
diff --git a/src/main/java/com/nis/dao/MonitorProjectDao.java b/src/main/java/com/nis/dao/MonitorProjectDao.java
new file mode 100644
index 0000000..0e721dc
--- /dev/null
+++ b/src/main/java/com/nis/dao/MonitorProjectDao.java
@@ -0,0 +1,24 @@
+/**
+
+ *
+
+ *
+
+ */
+
+package com.nis.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.nis.entity.Dc;
+import com.nis.entity.Idc;
+import com.nis.entity.MonitorProject;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+
+@Mapper
+@Repository
+public interface MonitorProjectDao extends BaseMapper<MonitorProject> {
+
+}
diff --git a/src/main/java/com/nis/dao/PanelDao.java b/src/main/java/com/nis/dao/PanelDao.java
new file mode 100644
index 0000000..1107a97
--- /dev/null
+++ b/src/main/java/com/nis/dao/PanelDao.java
@@ -0,0 +1,23 @@
+/**
+
+ *
+
+ *
+
+ */
+
+package com.nis.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.nis.entity.Panel;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+
+
+@Mapper
+@Repository
+public interface PanelDao extends BaseMapper<Panel> {
+
+}
diff --git a/src/main/java/com/nis/dao/ProjectDao.java b/src/main/java/com/nis/dao/ProjectDao.java
new file mode 100644
index 0000000..22d3063
--- /dev/null
+++ b/src/main/java/com/nis/dao/ProjectDao.java
@@ -0,0 +1,24 @@
+/**
+
+ *
+
+ *
+
+ */
+
+package com.nis.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.nis.entity.Dc;
+import com.nis.entity.Idc;
+import com.nis.entity.Project;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+
+@Mapper
+@Repository
+public interface ProjectDao extends BaseMapper<Project> {
+
+}
diff --git a/src/main/java/com/nis/dao/SnmpCredentialDao.java b/src/main/java/com/nis/dao/SnmpCredentialDao.java
new file mode 100644
index 0000000..cd1e98e
--- /dev/null
+++ b/src/main/java/com/nis/dao/SnmpCredentialDao.java
@@ -0,0 +1,11 @@
+package com.nis.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.nis.entity.SnmpCredential;
+
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface SnmpCredentialDao extends BaseMapper<SnmpCredential>{
+
+}
diff --git a/src/main/java/com/nis/dao/SqlDao.java b/src/main/java/com/nis/dao/SqlDao.java
new file mode 100644
index 0000000..65c57b4
--- /dev/null
+++ b/src/main/java/com/nis/dao/SqlDao.java
@@ -0,0 +1,24 @@
+package com.nis.dao;
+
+import java.util.List;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+@Mapper
+@Repository
+public interface SqlDao {
+
+ // 获取数据库所有表名
+ public List<String> allTables();
+
+ // 查询所有删除_copy表的sql语句
+ public List<String> allRemoveCopyTables();
+
+ // 执行用户传入的sql语句
+ public void execute(@Param("sql")String sql);
+
+ // 查询所有触发器
+ public List<String> allTriggers(String databaseName);
+}
diff --git a/src/main/java/com/nis/dao/SysDictDao.java b/src/main/java/com/nis/dao/SysDictDao.java
new file mode 100644
index 0000000..fb0e2e9
--- /dev/null
+++ b/src/main/java/com/nis/dao/SysDictDao.java
@@ -0,0 +1,19 @@
+/**
+
+ *
+
+ *
+
+ */
+
+package com.nis.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.nis.entity.SysDictEntity;
+import org.apache.ibatis.annotations.Mapper;
+
+
+@Mapper
+public interface SysDictDao extends BaseMapper<SysDictEntity> {
+
+}
diff --git a/src/main/java/com/nis/dao/VisualChartDao.java b/src/main/java/com/nis/dao/VisualChartDao.java
new file mode 100644
index 0000000..37d2833
--- /dev/null
+++ b/src/main/java/com/nis/dao/VisualChartDao.java
@@ -0,0 +1,23 @@
+/**
+
+ *
+
+ *
+
+ */
+
+package com.nis.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.nis.entity.VisualChart;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+
+
+@Mapper
+@Repository
+public interface VisualChartDao extends BaseMapper<VisualChart> {
+
+}
diff --git a/src/main/java/com/nis/dao/VisualChartElementDao.java b/src/main/java/com/nis/dao/VisualChartElementDao.java
new file mode 100644
index 0000000..4362c1c
--- /dev/null
+++ b/src/main/java/com/nis/dao/VisualChartElementDao.java
@@ -0,0 +1,21 @@
+/**
+
+ *
+
+ *
+
+ */
+
+package com.nis.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.nis.entity.VisualChartElement;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+@Mapper
+@Repository
+public interface VisualChartElementDao extends BaseMapper<VisualChartElement> {
+
+}
diff --git a/src/main/java/com/nis/dao/VisualPanelDao.java b/src/main/java/com/nis/dao/VisualPanelDao.java
new file mode 100644
index 0000000..410ae01
--- /dev/null
+++ b/src/main/java/com/nis/dao/VisualPanelDao.java
@@ -0,0 +1,21 @@
+/**
+
+ *
+
+ *
+
+ */
+
+package com.nis.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.nis.entity.VisualPanel;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+@Mapper
+@Repository
+public interface VisualPanelDao extends BaseMapper<VisualPanel> {
+
+}
diff --git a/src/main/java/com/nis/entity/Account.java b/src/main/java/com/nis/entity/Account.java
new file mode 100644
index 0000000..6c9d5f3
--- /dev/null
+++ b/src/main/java/com/nis/entity/Account.java
@@ -0,0 +1,27 @@
+package com.nis.entity;
+
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.util.Map;
+
+@Data
+@TableName("account")
+public class Account {
+ @TableId
+ private Integer id;
+
+ private Integer assetId;
+
+ private String protocol;
+
+ private Integer port;
+
+ private Object params;
+
+ private String seq;
+
+}
diff --git a/src/main/java/com/nis/entity/AlertMessageActiveEntity.java b/src/main/java/com/nis/entity/AlertMessageActiveEntity.java
new file mode 100644
index 0000000..8177e62
--- /dev/null
+++ b/src/main/java/com/nis/entity/AlertMessageActiveEntity.java
@@ -0,0 +1,123 @@
+package com.nis.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+
+@Data
+@TableName("alert_message_active")
+public class AlertMessageActiveEntity implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 主键
+ */
+ @TableId(type = IdType.INPUT)
+ private Integer id;
+
+ /**
+ * 告警规则id
+ */
+ private Integer ruleId;
+
+ /**
+ * 告警级别
+ */
+ private Integer severityId;
+ /**
+ * 告警摘要
+ */
+ private String summary;
+ /**
+ * 告警描述
+ */
+ private String description;
+ /**
+ * 告警labels信息
+ */
+ private String labels;
+ /**
+ * 开始时间
+ */
+ private Date startAt;
+ /**
+ * 结束时间
+ */
+ private Date endAt;
+ /**
+ * 状态
+ */
+ private Integer state;
+ /**
+ * 关联project id
+ */
+ private Integer projectId;
+ /**
+ * 关联module Id
+ */
+ private Integer moduleId;
+ /**
+ * 关联endpoint_id
+ */
+ private Integer endpointId;
+ /**
+ * 关联asset id
+ */
+ private Integer assetId;
+ /**
+ * 关联dc
+ */
+ private Integer dcId;
+
+ /**
+ * redis hash key
+ * */
+ private String hashKey;
+
+ /**
+ * remark 修改时使用此参数 记录手动关闭的备注信息
+ */
+ private String remark;
+
+ /**
+ * linkId对应实体类
+ * */
+ @TableField(exist = false)
+ private Object linkObject;
+
+ @TableField(exist = false)
+ private AlertRuleEntity alertRule;
+
+ /**
+ * 对应的project
+ */
+ @TableField(exist = false)
+ private Project project;
+
+ /**
+ * module
+ */
+ @TableField(exist = false)
+ private Module module;
+
+ /**
+ * endpoint
+ */
+ @TableField(exist = false)
+ private Endpoint endpoint;
+
+ /**
+ * dc
+ */
+ @TableField(exist = false)
+ private Dc dc;
+
+
+ private String severity;
+}
diff --git a/src/main/java/com/nis/entity/AlertMessageEntity.java b/src/main/java/com/nis/entity/AlertMessageEntity.java
new file mode 100644
index 0000000..0f05b90
--- /dev/null
+++ b/src/main/java/com/nis/entity/AlertMessageEntity.java
@@ -0,0 +1,116 @@
+package com.nis.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+
+@Data
+@TableName("alert_message")
+public class AlertMessageEntity implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 主键
+ */
+ @TableId
+ private Integer id;
+
+ /**
+ * 告警规则id
+ */
+ private Integer ruleId;
+
+ /**
+ * 告警级别
+ */
+ @TableField(exist = false)
+ private Integer severityId;
+ /**
+ * 告警摘要
+ */
+ private String summary;
+ /**
+ * 告警描述
+ */
+ private String description;
+ /**
+ * 告警labels信息
+ */
+ private String labels;
+ /**
+ * 开始时间
+ */
+ private Date startAt;
+ /**
+ * 结束时间
+ */
+ private Date endAt;
+ /**
+ * 状态
+ */
+ private Integer state;
+ /**
+ * 关联project id
+ */
+ private Integer projectId;
+ /**
+ * 关联module Id
+ */
+ private Integer moduleId;
+ /**
+ * 关联endpoint_id
+ */
+ private Integer endpointId;
+ /**
+ * 关联asset id
+ */
+ private Integer assetId;
+ /**
+ * 关联dc
+ */
+ private Integer dcId;
+
+ /**
+ * redis hash key
+ * */
+ private String hashKey;
+
+ /**
+ * remark 修改时使用此参数 记录手动关闭的备注信息
+ */
+ private String remark;
+
+ /**
+ * linkId对应实体类
+ * */
+ @TableField(exist = false)
+ private Object linkObject;
+
+ @TableField(exist = false)
+ private AlertRuleEntity alertRule;
+
+ /**
+ * 对应的project
+ */
+ @TableField(exist = false)
+ private Project project;
+
+ /**
+ * module
+ */
+ @TableField(exist = false)
+ private Module module;
+
+ /**
+ * endpoint
+ */
+ @TableField(exist = false)
+ private Endpoint endpoint;
+
+ private String severity;
+}
diff --git a/src/main/java/com/nis/entity/AlertMessageHistoryEntity.java b/src/main/java/com/nis/entity/AlertMessageHistoryEntity.java
new file mode 100644
index 0000000..d728858
--- /dev/null
+++ b/src/main/java/com/nis/entity/AlertMessageHistoryEntity.java
@@ -0,0 +1,122 @@
+package com.nis.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+@Data
+@TableName("alert_message_history")
+public class AlertMessageHistoryEntity implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 主键
+ */
+ @TableId(type = IdType.INPUT)
+ private Integer id;
+
+ /**
+ * 告警规则id
+ */
+ private Integer ruleId;
+
+ /**
+ * 告警级别
+ */
+ private Integer severityId;
+ /**
+ * 告警摘要
+ */
+ private String summary;
+ /**
+ * 告警描述
+ */
+ private String description;
+ /**
+ * 告警labels信息
+ */
+ private String labels;
+ /**
+ * 开始时间
+ */
+ private Date startAt;
+ /**
+ * 结束时间
+ */
+ private Date endAt;
+ /**
+ * 状态
+ */
+ private Integer state;
+ /**
+ * 关联project id
+ */
+ private Integer projectId;
+ /**
+ * 关联module Id
+ */
+ private Integer moduleId;
+ /**
+ * 关联endpoint_id
+ */
+ private Integer endpointId;
+ /**
+ * 关联asset id
+ */
+ private Integer assetId;
+ /**
+ * 关联dc
+ */
+ private Integer dcId;
+
+ /**
+ * redis hash key
+ * */
+ private String hashKey;
+
+ /**
+ * remark 修改时使用此参数 记录手动关闭的备注信息
+ */
+ private String remark;
+
+ /**
+ * linkId对应实体类
+ * */
+ @TableField(exist = false)
+ private Object linkObject;
+
+ @TableField(exist = false)
+ private AlertRuleEntity alertRule;
+
+ /**
+ * 对应的project
+ */
+ @TableField(exist = false)
+ private Project project;
+
+ /**
+ * module
+ */
+ @TableField(exist = false)
+ private Module module;
+
+ /**
+ * endpoint
+ */
+ @TableField(exist = false)
+ private Endpoint endpoint;
+
+ /**
+ * dc
+ */
+ @TableField(exist = false)
+ private Dc dc;
+
+
+ private String severity;
+}
diff --git a/src/main/java/com/nis/entity/AlertRuleEntity.java b/src/main/java/com/nis/entity/AlertRuleEntity.java
new file mode 100644
index 0000000..8b8af9f
--- /dev/null
+++ b/src/main/java/com/nis/entity/AlertRuleEntity.java
@@ -0,0 +1,82 @@
+package com.nis.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+
+@Data
+@TableName("alert_rule")
+public class AlertRuleEntity implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 主键id
+ */
+ @TableId(type = IdType.INPUT)
+ private Integer id;
+ /**
+ * 告警名称
+ */
+ private String name;
+
+ /**
+ * 运算表达式
+ */
+ private String expr;
+
+ /**
+ * 比较符号
+ */
+ private String operator;
+
+ /**
+ * 阈值
+ */
+ private Double threshold;
+
+ /**
+ * 单位
+ */
+ private Integer unit;
+ /**
+ * 持续时间,单位s
+ */
+ private Integer last;
+ /**
+ * 告警级别
+ */
+ private Integer severityId;
+ /**
+ * 告警摘要
+ */
+ private String summary;
+ /**
+ * 告警详细描述
+ */
+ private String description;
+
+ /**
+ * 通知用户ids 可多个
+ */
+ private String receiver;
+
+ /**
+ * 是否为内置规则
+ */
+ private Integer buildIn;
+
+ /**
+ * 导入唯一标识
+ */
+ private String seq;
+
+ private String severity;
+
+ private Integer method;
+}
diff --git a/src/main/java/com/nis/entity/AlertSeverityConf.java b/src/main/java/com/nis/entity/AlertSeverityConf.java
new file mode 100644
index 0000000..a6f18af
--- /dev/null
+++ b/src/main/java/com/nis/entity/AlertSeverityConf.java
@@ -0,0 +1,29 @@
+package com.nis.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+@Data
+@TableName("alert_severity_conf")
+public class AlertSeverityConf {
+
+ @TableId
+ private Integer id;
+
+ private String name;
+
+ private String color;
+
+ private Integer weight;
+
+ private String remark;
+
+ private String methods;
+
+}
diff --git a/src/main/java/com/nis/entity/AlertSilenceConf.java b/src/main/java/com/nis/entity/AlertSilenceConf.java
new file mode 100644
index 0000000..43c053a
--- /dev/null
+++ b/src/main/java/com/nis/entity/AlertSilenceConf.java
@@ -0,0 +1,58 @@
+package com.nis.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+@TableName("alert_silence_conf")
+public class AlertSilenceConf {
+
+ @TableId
+ private Integer id;
+
+ private Integer ruleId;
+
+ private String type;
+
+ private Integer linkId;
+
+ private String reason;
+
+ private Date startAt;
+
+ private Date endAt;
+
+ private Date utime;
+
+ private Integer state;
+
+ private String seq;
+
+ @TableField(exist = false)
+ private Dc datacenter;
+
+ @TableField(exist = false)
+ private Project project;
+
+ @TableField(exist = false)
+ private Module module;
+
+ @TableField(exist = false)
+ private Asset asset;
+
+ @TableField(exist = false)
+ private Endpoint endpoint;
+
+ @TableField(exist = false)
+ private AlertRuleEntity alertRule;
+
+ @TableField(exist = false)
+ private String ruleName;
+
+ @TableField(exist = false)
+ private String linkName;
+}
diff --git a/src/main/java/com/nis/entity/Asset.java b/src/main/java/com/nis/entity/Asset.java
new file mode 100644
index 0000000..70842e8
--- /dev/null
+++ b/src/main/java/com/nis/entity/Asset.java
@@ -0,0 +1,95 @@
+package com.nis.entity;
+
+import com.baomidou.mybatisplus.annotation.*;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+@Data
+@TableName("asset")
+public class Asset implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 主键
+ */
+ @TableId(type = IdType.AUTO)
+ private Integer id;
+
+ /**
+ * 资产序列化 (唯一)
+ */
+ private String sn;
+
+ /**
+ * 产品型号ID 与model表关联
+ */
+ private Integer modelId;
+
+ /**
+ * 数据中心id
+ */
+ private Integer idcId;
+
+ /**
+ * 机柜编号
+ */
+ @TableField(strategy = FieldStrategy.IGNORED)
+ private Integer cabinetId;
+
+ /**
+ * 主机地址 ip
+ */
+ private String host;
+
+ /**
+ * 资产状态
+ */
+ private Integer state;
+
+ /**
+ * 购买日期
+ */
+ private String purchaseDate;
+
+ /**
+ * 添加日期
+ */
+ private Date createAt;
+
+ /**
+ * 更新日期
+ */
+ private Date updateAt;
+
+ /**
+ * 添加人 user表关联
+ */
+ private Long createBy;
+
+ /**
+ * 更新人
+ */
+ private Long updateBy;
+
+
+ /**
+ * 用于撤销具体某次批量导入的uuid
+ */
+ private String seq;
+
+ /**
+ * 机柜开始位置
+ */
+ @TableField(strategy = FieldStrategy.IGNORED)
+ private Integer cabinetStart;
+
+ /**
+ * 机柜结束位置
+ */
+ @TableField(strategy = FieldStrategy.IGNORED)
+ private Integer cabinetEnd;
+
+}
diff --git a/src/main/java/com/nis/entity/AssetAsset.java b/src/main/java/com/nis/entity/AssetAsset.java
new file mode 100644
index 0000000..42e52b7
--- /dev/null
+++ b/src/main/java/com/nis/entity/AssetAsset.java
@@ -0,0 +1,180 @@
+package com.nis.entity;
+
+import com.baomidou.mybatisplus.annotation.*;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+
+/**
+ * 资产实体
+ *
+ * @author shizhendong
+ * @date 2019-11-21
+ */
+@Data
+@TableName("asset_asset")
+public class AssetAsset implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 主键
+ */
+ @TableId(type = IdType.INPUT)
+ private Integer id;
+
+ /**
+ * 资产名称 唯一
+ */
+ private String name;
+
+ /**
+ * 资产编号 不重复
+ */
+ private String number;
+
+ /**
+ * 资产序列化 (唯一)
+ */
+ private String sn;
+
+ /**
+ * 默认:-1 只有type vm = 1可以且必须填写此字段,且 pid.type vmh = 1
+ */
+ @TableField(strategy = FieldStrategy.IGNORED)
+ private Integer pid;
+
+ /**
+ * 资产状态
+ */
+ private Integer stateId;
+
+ /**
+ * 资产类型
+ */
+ private Integer typeId;
+
+ /**
+ * 品牌
+ */
+ private Integer brandId;
+
+ /**
+ * 产品型号ID 与model表关联
+ */
+ private Integer modelId;
+
+ /**
+ * 数据中心id
+ */
+ private Integer dcId;
+
+ /**
+ * 认证服务端口
+ */
+ @TableField(strategy = FieldStrategy.IGNORED)
+ private Integer authProtocolPort;
+
+ /**
+ * 认证方式
+ */
+ @TableField(strategy = FieldStrategy.IGNORED)
+ private Integer authType;
+
+ /**
+ * 用户名
+ */
+ @TableField(strategy = FieldStrategy.IGNORED)
+ private String authUsername;
+
+ /**
+ * 密码
+ */
+ @TableField(strategy = FieldStrategy.IGNORED)
+ private String authPin;
+
+ /**
+ * 秘钥
+ */
+ @TableField(strategy = FieldStrategy.IGNORED)
+ private String authPriKey;
+
+ /**
+ * 用户名提示
+ */
+ @TableField(strategy = FieldStrategy.IGNORED)
+ private String authUserTip;
+
+ /**
+ * 密码提示
+ */
+ @TableField(strategy = FieldStrategy.IGNORED)
+ private String authPinTip;
+
+ /**
+ * 协议 SSH / TELNET
+ */
+ @TableField(exist = false)
+ private String protocol;
+
+ /**
+ * snmp凭证id
+ */
+ private Integer snmpCredentialId;
+
+ /**
+ * 机柜编号
+ */
+ @TableField(strategy = FieldStrategy.IGNORED)
+ private Integer cabinetId;
+
+ /**
+ * 机柜开始位置
+ */
+ @TableField(strategy = FieldStrategy.IGNORED)
+ private Integer cabinetStart;
+
+ /**
+ * 机柜结束位置
+ */
+ @TableField(strategy = FieldStrategy.IGNORED)
+ private Integer cabinetEnd;
+
+ /**
+ * 管理ip
+ */
+ private String manageIp;
+
+ /**
+ * 购买日期
+ */
+ private String purchaseDate;
+
+ /**
+ * 添加日期
+ */
+ private Date createAt;
+
+ /**
+ * 更新日期
+ */
+ private Date updateAt;
+
+
+ /**
+ * 添加人 user表关联
+ */
+ private Long createBy;
+
+ /**
+ * 更新人
+ */
+ private Long updateBy;
+
+ /**
+ * 用于撤销具体某次批量导入的uuid
+ */
+ private String seq;
+}
diff --git a/src/main/java/com/nis/entity/AssetBrand.java b/src/main/java/com/nis/entity/AssetBrand.java
new file mode 100644
index 0000000..ea0b726
--- /dev/null
+++ b/src/main/java/com/nis/entity/AssetBrand.java
@@ -0,0 +1,36 @@
+package com.nis.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+
+
+
+@Data
+@TableName("asset_brand")
+public class AssetBrand implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 主键
+ */
+ private Integer id;
+
+ /**
+ * 名称
+ */
+ private String name;
+
+ /**
+ * 备注
+ */
+ private String remark;
+
+ /**
+ * 导入seq
+ */
+ private String seq;
+}
diff --git a/src/main/java/com/nis/entity/AssetFieldGroup.java b/src/main/java/com/nis/entity/AssetFieldGroup.java
new file mode 100644
index 0000000..0d91f2e
--- /dev/null
+++ b/src/main/java/com/nis/entity/AssetFieldGroup.java
@@ -0,0 +1,21 @@
+package com.nis.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import lombok.Data;
+
+@Data
+@TableName("asset_field_group")
+public class AssetFieldGroup {
+
+ private Integer id;
+
+ private String name;
+
+ private String remark;
+
+ private Integer buildIn;
+
+ private String seq;
+
+}
diff --git a/src/main/java/com/nis/entity/AssetFieldMeta.java b/src/main/java/com/nis/entity/AssetFieldMeta.java
new file mode 100644
index 0000000..e2fb986
--- /dev/null
+++ b/src/main/java/com/nis/entity/AssetFieldMeta.java
@@ -0,0 +1,53 @@
+package com.nis.entity;
+
+import java.util.List;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import lombok.Data;
+
+@Data
+@TableName("asset_field_meta")
+public class AssetFieldMeta {
+
+ private Integer id;
+
+ private String name;
+
+ private String metaKey;
+
+ private String groupId;
+
+ private Integer search;
+
+ private Integer display;
+
+ private String type;
+
+ private String param;
+
+ private Integer buildIn;
+
+ private String seq;
+
+ private String remark;
+
+ @TableField(exist = false)
+ private AssetFieldGroup group;
+
+ @TableField(exist = false)
+ private String key;
+
+ /**
+ * field value value
+ */
+ @TableField(exist = false)
+ private List<String> value;
+
+ /**
+ * field value assetId
+ */
+ @TableField(exist = false)
+ private Integer assetId;
+}
diff --git a/src/main/java/com/nis/entity/AssetFieldValue.java b/src/main/java/com/nis/entity/AssetFieldValue.java
new file mode 100644
index 0000000..bcc7484
--- /dev/null
+++ b/src/main/java/com/nis/entity/AssetFieldValue.java
@@ -0,0 +1,21 @@
+package com.nis.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import lombok.Data;
+
+@Data
+@TableName("asset_field_value")
+public class AssetFieldValue {
+
+ private Integer id;
+
+ private Integer assetId;
+
+ private Integer metaId;
+
+ private String value;
+
+ private String seq;
+
+}
diff --git a/src/main/java/com/nis/entity/AssetModel.java b/src/main/java/com/nis/entity/AssetModel.java
new file mode 100644
index 0000000..c549024
--- /dev/null
+++ b/src/main/java/com/nis/entity/AssetModel.java
@@ -0,0 +1,53 @@
+package com.nis.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+
+
+@Data
+@TableName("asset_model")
+public class AssetModel implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 主键
+ */
+ @TableId(type = IdType.INPUT)
+ private Integer id;
+
+ /**
+ * 品牌id
+ */
+ private Integer brandId;
+
+ /**
+ * 名称
+ */
+ private String name;
+
+ /**
+ * 备注
+ */
+ private String remark;
+
+ /**
+ * 导入seq
+ */
+ private String seq;
+
+ /**
+ * u位大小
+ */
+ private Integer usize;
+
+ private String chartIds;
+
+}
diff --git a/src/main/java/com/nis/entity/AssetStateConf.java b/src/main/java/com/nis/entity/AssetStateConf.java
new file mode 100644
index 0000000..3d6b7bb
--- /dev/null
+++ b/src/main/java/com/nis/entity/AssetStateConf.java
@@ -0,0 +1,51 @@
+package com.nis.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+
+
+@Data
+@TableName("asset_state_conf")
+public class AssetStateConf implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 主键
+ */
+ private Integer id;
+
+ /**
+ * 名称
+ */
+ private String name;
+
+ /**
+ * 开启ping 0:关闭 1:开启
+ */
+ private Integer ping;
+
+ /**
+ * 开启监控 0:关闭 1:开启
+ */
+ private Integer monitor;
+
+ /**
+ * 开启告警 0:关闭 1:开启
+ */
+ private Integer alert;
+
+ /**
+ * 是否内置 1:内置,0:非内置,默认:0 内置数据不允许删除
+ */
+ private Integer buildIn;
+
+ /**
+ * 描述
+ */
+ private String remark;
+}
diff --git a/src/main/java/com/nis/entity/AssetTag.java b/src/main/java/com/nis/entity/AssetTag.java
new file mode 100644
index 0000000..52512fe
--- /dev/null
+++ b/src/main/java/com/nis/entity/AssetTag.java
@@ -0,0 +1,40 @@
+package com.nis.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+
+
+@Data
+@TableName("asset_tag")
+public class AssetTag implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 主键
+ */
+ private Integer id;
+
+ /**
+ * 关联assetId
+ */
+ private Integer assetId;
+
+ /**
+ * 键
+ */
+ private String tag;
+
+ /**
+ * 值
+ */
+ private String value;
+
+ /**
+ * 导入UUID
+ */
+ private String seq;
+}
diff --git a/src/main/java/com/nis/entity/AssetTypeConf.java b/src/main/java/com/nis/entity/AssetTypeConf.java
new file mode 100644
index 0000000..439662c
--- /dev/null
+++ b/src/main/java/com/nis/entity/AssetTypeConf.java
@@ -0,0 +1,83 @@
+package com.nis.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+@Data
+@TableName("asset_type_conf")
+public class AssetTypeConf implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 主键
+ */
+ private Integer id;
+
+ /**
+ * 父id
+ */
+ private Integer pid;
+
+ /**
+ * 父名称
+ */
+ @TableField(exist = false)
+ private String pname;
+
+ /**
+ * 是否为虚拟机宿主 0:不是宿主机,不支持挂载 虚拟机 1:是宿主机,支持挂载虚拟机
+ */
+ private Integer vm;
+
+ /**
+ * 是否为虚拟机宿主 0:不是宿主机,不支持挂载 虚拟机 1:是宿主机,支持挂载虚拟机
+ */
+ private Integer vmh;
+
+ /**
+ * 名称
+ */
+ private String name;
+
+ /**
+ * 认证协议
+ */
+ private Integer authProtocol;
+
+ /**
+ * 是否支持snmp
+ */
+ private Integer snmpEnable;
+
+ /**
+ * 是否开启snmp采集
+ */
+ private Integer snmpCollect;
+
+ /**
+ * 是否开启ssh采集
+ */
+ private Integer sshCollect;
+
+ /**
+ * ssh自动化采集脚本路径
+ */
+ private String sshCollectScript;
+
+ /**
+ * 描述
+ */
+ private String remark;
+
+ /**
+ * 是否内置 1:内置,0:非内置,默认:0 内置数据不允许删除
+ */
+ private Integer buildIn;
+
+}
diff --git a/src/main/java/com/nis/entity/Chart.java b/src/main/java/com/nis/entity/Chart.java
new file mode 100644
index 0000000..49abad3
--- /dev/null
+++ b/src/main/java/com/nis/entity/Chart.java
@@ -0,0 +1,81 @@
+package com.nis.entity;
+
+import com.baomidou.mybatisplus.annotation.FieldStrategy;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+@Data
+@TableName("chart")
+public class Chart{
+
+
+ @TableId
+ public Integer id;
+
+ /**
+ * 排序字段,前一个元素
+ */
+ public Integer prev;
+
+ /**
+ * 排序字段,后一个元素
+ */
+ public Integer next;
+
+ /**
+ * 图表id,关联panel表
+ * */
+ private Integer panelId;
+ /**
+ *图表标题
+ * */
+ private String title;
+ /**
+ * 宽
+ * */
+ private Integer span;
+ /**
+ * 高
+ * */
+ private Integer height;
+ /**
+ * 创建时间
+ * */
+ private Date createAt;
+ /**
+ * 图标类型 line,bar,table
+ * */
+ private String type;
+
+ /**
+ * 单位
+ */
+ private Integer unit;
+
+ /**
+ * 默认为 0,用于chart排序
+ */
+ private Integer weight;
+
+ /**
+ * 模板ID
+ */
+ private Integer pid;
+
+ /**
+ * 是否为内置规则
+ */
+ private Integer buildIn;
+
+ /**
+ * 导入唯一标识
+ */
+ private String seq;
+
+ private String param;
+}
diff --git a/src/main/java/com/nis/entity/ChartElement.java b/src/main/java/com/nis/entity/ChartElement.java
new file mode 100644
index 0000000..53fe61d
--- /dev/null
+++ b/src/main/java/com/nis/entity/ChartElement.java
@@ -0,0 +1,44 @@
+package com.nis.entity;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+@Data
+@TableName("chart_element")
+public class ChartElement {
+
+ @TableId
+ private Integer id;
+ /**
+ *图表id
+ * */
+ private Integer chartId;
+ /**
+ * promql表达式
+ * */
+ private String expression;
+ /**
+ * 表达式类型
+ * normal:简单表达式,可页面解析,如:up{asset="192.168.40.40",module="kafka"}
+ *
+ * expert:用户输入表达式,解析困难,直接在页面显示
+ * */
+ private String type;
+
+ /**
+ * 图表legend表达式
+ */
+ private String legend;
+
+ /**
+ * 是否为内置规则
+ */
+ private Integer buildIn;
+
+ /**
+ * 导入唯一标识
+ */
+ private String seq;
+
+}
diff --git a/src/main/java/com/nis/entity/Dc.java b/src/main/java/com/nis/entity/Dc.java
new file mode 100644
index 0000000..20922e7
--- /dev/null
+++ b/src/main/java/com/nis/entity/Dc.java
@@ -0,0 +1,80 @@
+package com.nis.entity;
+
+import com.baomidou.mybatisplus.annotation.FieldStrategy;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+
+
+/**
+ * 数据中心实体
+ *
+ */
+@Data
+@TableName("dc")
+public class Dc implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 主键
+ */
+ @TableId(type = IdType.INPUT)
+ private Integer id;
+
+ /**
+ * 数据中心名称
+ */
+ private String name;
+
+ /**
+ * 数据中心位置
+ */
+ private String location;
+
+ /**
+ * 联系电话
+ */
+ private String tel;
+
+ /**
+ * 机房负责人
+ */
+ private Integer principal;
+
+ /**
+ * 用于撤销具体某次批量导入的uuid
+ */
+ private String seq;
+
+ /**
+ * 列
+ */
+ private Integer x;
+
+ /**
+ * 行
+ */
+ private Integer y;
+
+ /**
+ * 经度
+ */
+ @TableField(strategy = FieldStrategy.IGNORED)
+ private Double longitude;
+
+ /**
+ * 纬度
+ */
+ @TableField(strategy = FieldStrategy.IGNORED)
+ private Double latitude;
+
+ /**
+ * 状态
+ */
+ private String state;
+
+}
diff --git a/src/main/java/com/nis/entity/Endpoint.java b/src/main/java/com/nis/entity/Endpoint.java
new file mode 100644
index 0000000..80d42d1
--- /dev/null
+++ b/src/main/java/com/nis/entity/Endpoint.java
@@ -0,0 +1,44 @@
+package com.nis.entity;
+
+import com.baomidou.mybatisplus.annotation.FieldStrategy;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+@Data
+@TableName("endpoint")
+public class Endpoint {
+ @TableId
+ private Integer id;
+ private Integer moduleId;
+ private Integer assetId;
+ private String host;
+ private Integer port;
+
+ @TableField(strategy = FieldStrategy.IGNORED)
+ private String param;
+
+ @TableField(strategy = FieldStrategy.IGNORED)
+ private String labels;
+ private String path;
+ private Integer enabled;
+ @TableField(exist = false)
+ private Module module;
+ @TableField(exist = false)
+ private Asset asset;
+ @TableField(exist = false)
+ private Project project;
+ @TableField(exist = false)
+ private Long lastUpdate;
+ @TableField(exist = false)
+ private Integer state;
+ private String seq;
+ @TableField(exist = false)
+ private StateInfo stateInfo;
+ @TableField(exist = false)
+ private Promserver promserver;
+
+ @TableField(exist = false)
+ private Integer alertNum;
+}
diff --git a/src/main/java/com/nis/entity/Idc.java b/src/main/java/com/nis/entity/Idc.java
new file mode 100644
index 0000000..2d4c6b9
--- /dev/null
+++ b/src/main/java/com/nis/entity/Idc.java
@@ -0,0 +1,77 @@
+package com.nis.entity;
+
+import com.baomidou.mybatisplus.annotation.FieldStrategy;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Map;
+
+
+@Data
+@TableName("idc")
+public class Idc implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 主键
+ */
+ @TableId
+ private Integer id;
+
+ /**
+ * 数据中心名称
+ */
+ private String name;
+
+ /**
+ * 数据中心位置
+ */
+ private String location;
+
+ /**
+ * 联系电话
+ */
+ private String tel;
+
+ /**
+ * 机房负责人
+ */
+ private Integer principal;
+
+ /**
+ * 用于撤销具体某次批量导入的uuid
+ */
+ private String seq;
+
+ /**
+ * 列
+ */
+ private Integer x;
+
+ /**
+ * 行
+ */
+ private Integer y;
+
+ /**
+ * 经度
+ */
+ @TableField(strategy = FieldStrategy.IGNORED)
+ private Double longitude;
+
+ /**
+ * 纬度
+ */
+ @TableField(strategy = FieldStrategy.IGNORED)
+ private Double latitude;
+
+ /**
+ * 状态
+ */
+ private String state;
+
+
+}
diff --git a/src/main/java/com/nis/entity/Model.java b/src/main/java/com/nis/entity/Model.java
new file mode 100644
index 0000000..d35fb63
--- /dev/null
+++ b/src/main/java/com/nis/entity/Model.java
@@ -0,0 +1,59 @@
+package com.nis.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+
+
+/**
+ * 资产型号实体
+ *
+ * @author shizhendong
+ * @date 2019-11-21
+ */
+@Data
+@TableName("model")
+public class Model implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 主键
+ */
+ @TableId
+ private Integer id;
+
+ /**
+ * 型号名称
+ */
+ private String name;
+
+ /**
+ * 厂商
+ */
+ @TableField(value = "vendor")
+ private Integer vendorCode;
+
+ /**
+ * 类型
+ */
+ @TableField(value = "type")
+ private Integer typeCode;
+
+ /**
+ * 备注
+ */
+ private String remark;
+
+ /**
+ * 用于撤销具体某次批量导入的uuid
+ */
+ private String seq;
+
+ /**
+ * u位大小
+ */
+ private Integer usize;
+} \ No newline at end of file
diff --git a/src/main/java/com/nis/entity/Module.java b/src/main/java/com/nis/entity/Module.java
new file mode 100644
index 0000000..72a1773
--- /dev/null
+++ b/src/main/java/com/nis/entity/Module.java
@@ -0,0 +1,39 @@
+package com.nis.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+@Data
+@TableName("module")
+public class Module {
+ @TableId
+ private Integer id;
+ @TableField(exist = false)
+ private Project project;
+ private Integer projectId;
+ private String name;
+ private Integer port;
+ private String param;
+ private String labels;
+ private String path;
+ private String remark;
+ private Integer buildIn;
+ private String seq;
+
+ /**
+ * modulle 类型 可选值 : http 、snmp
+ */
+ private String type;
+
+ /**
+ * snmp配置参数
+ */
+ private String snmpParam;
+
+ /**
+ * snmp_exporter需要的配置部分, 由web端根据snmp_param生成
+ */
+ private String snmpYml;
+}
diff --git a/src/main/java/com/nis/entity/MonitorEndpoint.java b/src/main/java/com/nis/entity/MonitorEndpoint.java
new file mode 100644
index 0000000..a2c9237
--- /dev/null
+++ b/src/main/java/com/nis/entity/MonitorEndpoint.java
@@ -0,0 +1,79 @@
+package com.nis.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Map;
+
+@Data
+@TableName("monitor_endpoint")
+public class MonitorEndpoint implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 主键
+ */
+ @TableId(type = IdType.INPUT)
+ private Integer id;
+
+ /**
+ * 名称
+ */
+ private String name;
+
+ /**
+ * 组件id
+ */
+ private Integer moduleId;
+
+ /**
+ * 资产id
+ */
+ private Integer assetId;
+
+ /**
+ * 配置参数 当type=HTTP,默认为 module.configs
+ */
+ private String configs;
+
+ @TableField(exist = false)
+ private Map config;
+ /**
+ * 计算 moduleId + assetId + host + port + configs 的hash值,用于确保相同配置不重复
+ */
+ private String hash;
+
+ /**
+ * 是否启用 可选值
+ * 0:停用
+ * 1:启用
+ */
+ private Integer enabled;
+
+ private String seq;
+
+ @TableField(exist = false)
+ private Integer state;
+
+ @TableField(exist = false)
+ private MonitorModule module;
+
+ @TableField(exist = false)
+ private AssetAsset asset;
+
+ @TableField(exist = false)
+ private Dc dc;
+
+ @TableField(exist = false)
+ private MonitorProject project;
+
+ @TableField(exist = false)
+ private Integer alertNum;
+
+ @TableField(exist = false)
+ private Promserver promserver;
+}
diff --git a/src/main/java/com/nis/entity/MonitorModule.java b/src/main/java/com/nis/entity/MonitorModule.java
new file mode 100644
index 0000000..cc6d0ee
--- /dev/null
+++ b/src/main/java/com/nis/entity/MonitorModule.java
@@ -0,0 +1,69 @@
+package com.nis.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+@Data
+@TableName("monitor_module")
+public class MonitorModule implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 主键
+ */
+ @TableId(type = IdType.INPUT)
+ private Integer id;
+
+ /**
+ * 组件名称
+ */
+ private String name;
+
+ /**
+ * 业务系统id
+ */
+ private Integer projectId;
+
+ /**
+ * modulle 类型 可选值 : http 、snmp
+ */
+ private String type;
+
+ /**
+ * endpoint name模板
+ * 支持 {{}} 变量替换,asset,module
+ * 例:{{asset.name}}-{{module.name}}
+ * 最终endpoint的name为: 192.168.40.1-mysql
+ */
+ private String endpointNameTmpl;
+
+ /**
+ * 描述
+ */
+ private String remark;
+
+ /**
+ * 配置参数
+ */
+ private String configs;
+
+
+ /**
+ * snmp_exporter需要的配置部分, 由web端根据snmp_param生成
+ */
+ private String snmpYml;
+
+ /**
+ * 是否内置 1:内置,0:非内置,默认:0 内置数据不允许删除
+ */
+ private Integer buildIn;
+
+ private String seq;
+
+}
diff --git a/src/main/java/com/nis/entity/MonitorProject.java b/src/main/java/com/nis/entity/MonitorProject.java
new file mode 100644
index 0000000..23d20db
--- /dev/null
+++ b/src/main/java/com/nis/entity/MonitorProject.java
@@ -0,0 +1,74 @@
+package com.nis.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+@Data
+@TableName("monitor_project")
+public class MonitorProject implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 主键
+ */
+ @TableId(type = IdType.INPUT)
+ private Integer id;
+
+ /**
+ * 应用名称
+ */
+ private String name;
+
+ /**
+ * 描述
+ */
+ private String remark;
+
+ /**
+ * 是否内置 1:内置,0:非内置,默认:0 内置数据不允许删除
+ */
+ private Integer buildIn;
+
+ private String seq;
+
+ @TableField(exist = false)
+ private List<Integer> alertStat = new ArrayList<Integer>();
+
+ /**
+ * module 列表
+ */
+ @TableField(exist = false)
+ private List<MonitorModule> children;
+
+ /**
+ * module数量
+ */
+ @TableField(exist = false)
+ private Integer moduleNum;
+
+ /**
+ * endpoint数量
+ */
+ @TableField(exist = false)
+ private Integer endpointNum;
+
+ /**
+ * asset数量
+ */
+ @TableField(exist = false)
+ private Integer assetNum;
+
+ /**
+ * alert数量
+ */
+ @TableField(exist = false)
+ private Integer alertNum;
+
+}
diff --git a/src/main/java/com/nis/entity/Panel.java b/src/main/java/com/nis/entity/Panel.java
new file mode 100644
index 0000000..731eb28
--- /dev/null
+++ b/src/main/java/com/nis/entity/Panel.java
@@ -0,0 +1,53 @@
+package com.nis.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+@TableName("panel")
+public class Panel{
+
+ private Integer id;
+ /**
+ * 图表名
+ * */
+ private String name;
+ /**
+ *创建人id
+ * */
+ private Integer createBy;
+
+ /**
+ * panel类型
+ */
+ private String type;
+
+ /**
+ * 关联id
+ */
+ private Integer link;
+
+ /**
+ * 是否为内置规则
+ */
+ private Integer buildIn;
+
+ /**
+ * 导入唯一标识
+ */
+ private String seq;
+
+ /**
+ * 父ID
+ */
+ private Integer pid;
+
+ /**
+ * 排序
+ */
+ private Integer weight;
+
+}
diff --git a/src/main/java/com/nis/entity/Project.java b/src/main/java/com/nis/entity/Project.java
new file mode 100644
index 0000000..08cc0f3
--- /dev/null
+++ b/src/main/java/com/nis/entity/Project.java
@@ -0,0 +1,17 @@
+package com.nis.entity;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+
+@Data
+@TableName("project")
+public class Project {
+ @TableId
+ private Integer id;
+ private String name;
+ private String remark;
+ private Integer buildIn;
+ private String seq;
+}
diff --git a/src/main/java/com/nis/entity/Promserver.java b/src/main/java/com/nis/entity/Promserver.java
new file mode 100644
index 0000000..10c85f6
--- /dev/null
+++ b/src/main/java/com/nis/entity/Promserver.java
@@ -0,0 +1,42 @@
+package com.nis.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import java.util.Date;
+
+@Data
+@TableName("prom_server")
+public class Promserver {
+ @TableId
+ private Integer id;
+ private Integer dcId;
+ private String host;
+ private Integer type;
+ private Integer port;
+ /**
+ * 默认:1
+ * 1:正常
+ * 0:异常
+ * -1:认证失败
+ */
+ private Integer status;
+ private Date checkTime;
+
+ /**
+ * json格式保存状态详情
+ * {
+ * "prometheus": "UP",
+ * "confagent": "UP",
+ * "snmp_exporter": "UP"
+ * }
+ */
+ private String statusInfo;
+
+
+ /**
+ * confagent令牌
+ */
+ private String token;
+}
diff --git a/src/main/java/com/nis/entity/SnmpCredential.java b/src/main/java/com/nis/entity/SnmpCredential.java
new file mode 100644
index 0000000..be1e50d
--- /dev/null
+++ b/src/main/java/com/nis/entity/SnmpCredential.java
@@ -0,0 +1,23 @@
+package com.nis.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import lombok.Data;
+
+@Data
+@TableName("snmp_credential")
+public class SnmpCredential {
+
+ private Integer id;
+
+ private String name;
+
+ private String remark;
+
+ private Integer type;
+
+ private String config;
+
+ private Integer port;
+
+}
diff --git a/src/main/java/com/nis/entity/StateInfo.java b/src/main/java/com/nis/entity/StateInfo.java
new file mode 100644
index 0000000..b8a01a1
--- /dev/null
+++ b/src/main/java/com/nis/entity/StateInfo.java
@@ -0,0 +1,9 @@
+package com.nis.entity;
+
+import lombok.Data;
+
+@Data
+public class StateInfo {
+ private Integer code;
+ private String msg;
+}
diff --git a/src/main/java/com/nis/entity/SysConfigEntity.java b/src/main/java/com/nis/entity/SysConfigEntity.java
new file mode 100644
index 0000000..3a8563a
--- /dev/null
+++ b/src/main/java/com/nis/entity/SysConfigEntity.java
@@ -0,0 +1,30 @@
+/**
+
+ *
+
+ *
+
+ */
+
+package com.nis.entity;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+/**
+ * 系统配置信息
+ *
+
+ */
+@Data
+@TableName("sys_config")
+public class SysConfigEntity {
+ @TableId
+ private Long id;
+ private String paramKey;
+ private String paramValue;
+ private String status;
+ private String remark;
+
+}
diff --git a/src/main/java/com/nis/entity/SysDictEntity.java b/src/main/java/com/nis/entity/SysDictEntity.java
new file mode 100644
index 0000000..17d2620
--- /dev/null
+++ b/src/main/java/com/nis/entity/SysDictEntity.java
@@ -0,0 +1,82 @@
+/**
+
+ *
+
+ *
+
+ */
+
+package com.nis.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 数据字典
+ *
+
+ */
+@Data
+@TableName("sys_dict")
+public class SysDictEntity implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @TableId
+ private Long id;
+ /**
+ * 字典名称
+ */
+ private String name;
+ /**
+ * 字典类型
+ */
+ private String type;
+ /**
+ * 字典码
+ */
+ private Integer code;
+ /**
+ * 字典值
+ */
+ private String value;
+ /**
+ * 排序
+ */
+ private Integer orderNum;
+ /**
+ * 备注
+ */
+ private String remark;
+ /**
+ * 删除标记 -1:已删除 0:正常
+ */
+ @TableLogic
+ private Integer delFlag;
+
+ /**
+ * 操作人
+ */
+ private Long operator;
+
+ /**
+ * 操作时间
+ */
+ private Date opTime;
+
+ /**
+ * 国际化code
+ */
+ private String i18nCode;
+
+ /**
+ * 用于撤销具体某次批量导入的uuid
+ */
+ private String seq;
+
+}
diff --git a/src/main/java/com/nis/entity/VisualChart.java b/src/main/java/com/nis/entity/VisualChart.java
new file mode 100644
index 0000000..e7b832d
--- /dev/null
+++ b/src/main/java/com/nis/entity/VisualChart.java
@@ -0,0 +1,57 @@
+package com.nis.entity;
+
+import java.util.Date;
+import java.util.List;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import lombok.Data;
+
+@Data
+@TableName("visual_chart")
+public class VisualChart {
+
+ @TableId(type = IdType.INPUT)
+ private Integer id;
+
+ private String name;
+
+ private Integer panelId;
+
+ private Integer groupId;
+
+ private Integer span;
+
+ private Integer height;
+
+ private Integer updateBy;
+
+ private Date updateAt;
+
+ private String type;
+
+ private Integer unit;
+
+ private Integer weight;
+
+ private Object param;
+
+ private Integer pid;
+
+ private Integer buildIn;
+
+ private String remark;
+
+ private String seq;
+
+ @TableField(exist = false)
+ private List<VisualChartElement> elements;
+
+ private Integer varType;
+
+ private Integer varId;
+
+}
diff --git a/src/main/java/com/nis/entity/VisualChartElement.java b/src/main/java/com/nis/entity/VisualChartElement.java
new file mode 100644
index 0000000..2d0f513
--- /dev/null
+++ b/src/main/java/com/nis/entity/VisualChartElement.java
@@ -0,0 +1,27 @@
+package com.nis.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import lombok.Data;
+
+@Data
+@TableName("visual_chart_element")
+public class VisualChartElement {
+
+ @TableId(type = IdType.INPUT)
+ private Integer id;
+
+ private Integer chartId;
+
+ private String expression;
+
+ private String type;
+
+ private String legend;
+
+ private Integer buildIn;
+
+ private String seq;
+}
diff --git a/src/main/java/com/nis/entity/VisualPanel.java b/src/main/java/com/nis/entity/VisualPanel.java
new file mode 100644
index 0000000..c26ff6e
--- /dev/null
+++ b/src/main/java/com/nis/entity/VisualPanel.java
@@ -0,0 +1,43 @@
+package com.nis.entity;
+
+import java.util.List;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import lombok.Data;
+
+@Data
+@TableName("visual_panel")
+public class VisualPanel {
+
+ @TableId(type = IdType.INPUT)
+ private Integer id;
+
+ private String name;
+
+ private Integer createBy;
+
+ private String type;
+
+ private Integer link;
+
+ private Integer pid;
+
+ private Integer weight;
+
+ private Integer buildIn;
+
+ private String seq;
+
+ @TableField(exist = false)
+ private List<VisualPanel> children;
+
+ @TableField(exist = false)
+ private VisualPanel parent;
+
+ @TableField(exist = false)
+ private Integer chartNum;
+}
diff --git a/src/main/java/com/nis/handler/AfterHandler.java b/src/main/java/com/nis/handler/AfterHandler.java
new file mode 100644
index 0000000..72dc652
--- /dev/null
+++ b/src/main/java/com/nis/handler/AfterHandler.java
@@ -0,0 +1,39 @@
+package com.nis.handler;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.context.annotation.DependsOn;
+import org.springframework.core.annotation.Order;
+import org.springframework.stereotype.Component;
+
+import cn.hutool.log.Log;
+
+/**
+ * 此类用于数据同步完成后 清除无用表
+ * @author admin
+ *
+ */
+@Component
+@Order(3)
+public class AfterHandler implements CommandLineRunner {
+
+ private Log log = Log.get();
+
+ @Autowired
+ private SqlHandler sqlHandler;
+
+ @Override
+ public void run(String... args) throws Exception {
+
+ sqlHandler.removeTable();
+ log.info("remove table successful");
+
+ sqlHandler.removeCopy();
+ log.info("remove copy back successful");
+
+ log.info("-----------------program end-----------------------");
+ log.info("-----------------transfer data success-----------------------");
+
+ }
+
+}
diff --git a/src/main/java/com/nis/handler/BeforeHandler.java b/src/main/java/com/nis/handler/BeforeHandler.java
new file mode 100644
index 0000000..d091a88
--- /dev/null
+++ b/src/main/java/com/nis/handler/BeforeHandler.java
@@ -0,0 +1,53 @@
+package com.nis.handler;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.core.annotation.Order;
+import org.springframework.stereotype.Component;
+
+import com.nis.util.Constant;
+
+import cn.hutool.core.util.RuntimeUtil;
+import cn.hutool.log.Log;
+
+/**
+ *
+ * 此类主要用于数据处理前的数据备份 执行数据库结构变更的sql 如清除触发器 个别表的字段信息变更
+ * @author admin
+ *
+ */
+@Component
+@Order(1)
+public class BeforeHandler implements CommandLineRunner {
+
+ private Log log = Log.get();
+
+ @Value("{spring.datasource.druid.password}")
+ private String password;
+
+ @Autowired
+ private SqlHandler sqlHandler;
+
+ @Override
+ public void run(String... args) throws Exception {
+
+ // 每个表进行复制 进行双重备份
+ sqlHandler.tableCopy();
+ log.info("backup database successful");
+
+ // 删除触发器
+ sqlHandler.dropTriggers();
+ log.info("drop all trigger successful");
+
+ // 修改表结构
+ sqlHandler.alterTable();
+ log.info("alter table successful");
+
+ // 新增表
+ sqlHandler.batchAddTable();
+
+ log.info("all sql execute successful , before handler close");
+
+ }
+}
diff --git a/src/main/java/com/nis/handler/SqlHandler.java b/src/main/java/com/nis/handler/SqlHandler.java
new file mode 100644
index 0000000..9d7b6ca
--- /dev/null
+++ b/src/main/java/com/nis/handler/SqlHandler.java
@@ -0,0 +1,1002 @@
+package com.nis.handler;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import com.nis.dao.SqlDao;
+import com.nis.service.AlertMessageService;
+import com.nis.service.AssetAssetService;
+import com.nis.service.AssetBrandService;
+import com.nis.service.AssetModelService;
+import com.nis.service.ChartService;
+import com.nis.service.DcService;
+import com.nis.service.EndpointService;
+import com.nis.util.Constant;
+
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.log.Log;
+
+/**
+ * 此类主要为执行各类sql语句
+ * @author admin
+ *
+ */
+@Service
+public class SqlHandler {
+
+ private Log log = Log.get();
+
+ @Autowired
+ private SqlDao sqlDao;
+
+ @Autowired
+ private AssetBrandService assetBrandService;
+
+ @Autowired
+ private AssetModelService assetModelService;
+
+ @Autowired
+ private AssetAssetService assetAssetService;
+
+ @Autowired
+ private DcService dcService;
+
+ @Autowired
+ private AlertMessageService alertMessageService;
+
+ @Autowired
+ private EndpointService endpointService;
+
+ @Autowired
+ private ChartService chartService;
+
+ public void removeData() {
+ String assetPing = "delete from asset_ping";
+ sqlDao.execute(assetPing);
+ }
+
+ public void removeTable() {
+ String dropSql = "drop table account;"
+ + "drop table alert_message;"
+ + "drop table asset;"
+ + "drop table asset_tag;"
+ + "drop table chart;"
+ + "drop table chart_element;"
+ + "drop table conf_event;"
+ + "drop table endpoint;"
+ + "drop table endpoint_state;"
+ + "drop table idc_traffic;"
+ + "drop table model;"
+ + "drop table module;"
+ + "drop table notification_script;"
+ + "drop table panel;"
+ + "drop table project;"
+ + "drop table metadata_metric;"
+ + "drop table metadata_label;"
+ + "drop table qrtz_blob_triggers;"
+ + "drop table qrtz_calendars;"
+ + "drop table qrtz_cron_triggers;"
+ + "drop table qrtz_fired_triggers;"
+ + "drop table qrtz_locks;"
+ + "drop table qrtz_paused_trigger_grps;"
+ + "drop table qrtz_scheduler_state;"
+ + "drop table qrtz_simple_triggers;"
+ + "drop table qrtz_simprop_triggers;"
+ + "drop table qrtz_triggers;"
+ + "drop table sys_area;"
+ + "drop table idc;"
+ + "drop table terminal_log;"
+ + "drop table user_group;"
+ + "drop table user_group_rel;"
+ + "drop table user_notification;"
+ + "drop table qrtz_job_details;";
+ sqlDao.execute(dropSql);
+ }
+
+ public void tableCopy() {
+ StringBuilder sb =new StringBuilder();
+ List<String> tableNames = sqlDao.allTables();
+ for(String tableName : tableNames) {
+ sb.append("CREATE TABLE "+tableName+"_copy SELECT * FROM "+tableName+";");
+ }
+ sqlDao.execute(sb.toString());
+ }
+
+
+ public void removeCopy() {
+ StringBuilder sb =new StringBuilder();
+ List<String> sqls = sqlDao.allRemoveCopyTables();
+ for(String sql : sqls) {
+ sb.append(sql);
+ }
+ sqlDao.execute(sb.toString());
+ }
+
+ public void dropTriggers() {
+ String databaseName = Constant.DATABASE_NAME;
+ log.info("databaseName is {}",databaseName);
+ if(StrUtil.isEmpty(databaseName)) {
+ throw new RuntimeException("database name error");
+ }
+ // 批量删除触发器
+ StringBuilder sb =new StringBuilder();
+ List<String> allTriggers = sqlDao.allTriggers(databaseName);
+ for(String trigger : allTriggers) {
+ sb.append("drop trigger "+trigger+";");
+ }
+ if(StrUtil.isNotBlank(sb.toString())) {
+ sqlDao.execute(sb.toString());
+ }
+
+ }
+
+ public void alterTable() {
+ String sysLog = "ALTER TABLE `sys_log` \r\n"
+ + "ADD COLUMN `sys_api_key` int(10) NULL COMMENT '关联 sys_api_key.id' AFTER `create_date`;";
+ sqlDao.execute(sysLog);
+
+ String sysMenu = "ALTER TABLE `sys_menu` \r\n"
+ + "ADD COLUMN `description` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL,\r\n"
+ + "ADD COLUMN `icon` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT 'nz-icon nz-alert-add';";
+ sqlDao.execute(sysMenu);
+
+ String alertRule = "ALTER TABLE `alert_rule` \r\n"
+ + "CHANGE COLUMN `alert_name` `name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '告警名称',\r\n"
+ + "ADD COLUMN `severity_id` int(10) NULL COMMENT '告警级别id,关联ALERT_SEVERITY_CONF',"
+ + "ADD COLUMN `method` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL;";
+ sqlDao.execute(alertRule);
+
+ String assetPing = "ALTER TABLE `asset_ping` \r\n"
+ + "ADD COLUMN `asset_id` int(10) NULL;";
+ sqlDao.execute(assetPing);
+
+ String cabinet = "ALTER TABLE `cabinet` \r\n"
+ + "CHANGE COLUMN `idc_id` `dc_id` int(10) NOT NULL COMMENT '数据中心id';";
+ sqlDao.execute(cabinet);
+
+ String link = "ALTER TABLE `link` \r\n"
+ + "DROP COLUMN `prev`,\r\n"
+ + "DROP COLUMN `next`,\r\n"
+ + "ADD COLUMN `weight` int(10) NULL;";
+ sqlDao.execute(link);
+
+ String projectTopo = "ALTER TABLE `project_topo` \r\n"
+ + "MODIFY COLUMN `topo` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '拓扑图配置信息';";
+ sqlDao.execute(projectTopo);
+
+ String projectTopoIcon = "ALTER TABLE `project_topo_icon` \r\n"
+ + "ADD COLUMN `unit` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'icon组',\r\n"
+ + "ADD COLUMN `width` int(10) NULL COMMENT '图片宽度 默认:-1 未知' ,\r\n"
+ + "ADD COLUMN `height` int(10) NULL COMMENT '图片高度 默认:-1 未知' ;";
+ sqlDao.execute(projectTopoIcon);
+
+ String promServer = "ALTER TABLE `prom_server` \r\n"
+ + "CHANGE COLUMN `idc_id` `dc_id` int(10) NOT NULL COMMENT '所在idc',\r\n"
+ + "ADD COLUMN `status_info` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,\r\n"
+ + "ADD COLUMN `token` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;";
+ sqlDao.execute(promServer);
+
+ String sysUser = "ALTER TABLE `sys_user` \r\n"
+ + "CHANGE COLUMN `user_id` `id` int(10) NOT NULL AUTO_INCREMENT,\r\n"
+ + "CHANGE COLUMN `password` `pin` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '密码',\r\n"
+ + "CHANGE COLUMN `create_time` `create_at` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',\r\n"
+ + "ADD COLUMN `name` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户姓名\\r\\n\\r\\n(用于系统内展示用户名称)',\r\n"
+ + "ADD COLUMN `last_login_time` datetime NULL COMMENT '最后登陆时间',\r\n"
+ + "ADD COLUMN `last_login_ip` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '最后登陆ip',\r\n"
+ + "ADD COLUMN `mobile` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '手机号',\r\n"
+ + "ADD COLUMN `create_by` int(10) NULL COMMENT '添加人',\r\n"
+ + "DROP PRIMARY KEY,\r\n"
+ + "ADD PRIMARY KEY (`id`) USING BTREE;";
+ sqlDao.execute(sysUser);
+ }
+
+ public void batchAddTable() {
+ String alertNotifyLog = "CREATE TABLE `alert_notify_log` (\r\n"
+ + " `id` int(10) NOT NULL AUTO_INCREMENT,\r\n"
+ + " `message_id` int(10) NOT NULL COMMENT '关联 alert_message.id',\r\n"
+ + " `user_id` int(10) NOT NULL COMMENT '关联 sys_user.id',\r\n"
+ + " `method` varchar(128) NOT NULL COMMENT '通知方式 VARCHARemail 或 NOTIFICATION_SCRIPT.name',\r\n"
+ + " `message_state` char(1) NOT NULL COMMENT '消息状态1: active2: expired',\r\n"
+ + " `state` char(1) NOT NULL COMMENT '通知状态0:失败1:成功',\r\n"
+ + " `error_msg` varchar(1024) NOT NULL DEFAULT '' COMMENT '发送错误信息',\r\n"
+ + " `time` datetime NOT NULL COMMENT '发送时间',\r\n"
+ + " PRIMARY KEY (`id`) USING BTREE\r\n"
+ + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
+
+ String alertNotifyMethod = "CREATE TABLE `alert_notify_method` (\r\n"
+ + " `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键',\r\n"
+ + " `name` varchar(64) NOT NULL COMMENT '通知方式名称',\r\n"
+ + " `file_path` varchar(255) NOT NULL COMMENT '除内置外,必填脚本路径,nz-web所在服务器路径',\r\n"
+ + " `account` varchar(255) NOT NULL COMMENT '可选值为user表属性id,name,username,email,mobile',\r\n"
+ + " `state` int(1) DEFAULT NULL COMMENT '状态0:停用1:可用',\r\n"
+ + " `build_in` int(1) NOT NULL COMMENT '可选值:0:非内置1:内置默认:0系统内置一条 email 通知',\r\n"
+ + " PRIMARY KEY (`id`) USING BTREE\r\n"
+ + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
+
+ String alertSeverityConf = "CREATE TABLE `alert_severity_conf` (\r\n"
+ + " `id` int(10) NOT NULL AUTO_INCREMENT,\r\n"
+ + " `name` varchar(64) NOT NULL,\r\n"
+ + " `color` varchar(64) NOT NULL,\r\n"
+ + " `weight` int(3) NOT NULL COMMENT '1-100 顺序取值不重复,值越小告警级别越高',\r\n"
+ + " `remark` varchar(255) NOT NULL,\r\n"
+ + " PRIMARY KEY (`id`) USING BTREE\r\n"
+ + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
+
+ String alertSilenceConf = "CREATE TABLE `alert_silence_conf` (\r\n"
+ + " `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键',\r\n"
+ + " `name` varchar(255) DEFAULT NULL,\r\n"
+ + " `matchers` varchar(4096) NOT NULL,\r\n"
+ + " `reason` varchar(1024) NOT NULL COMMENT '记录告警静音原因\\r\\n\\r\\n默认:“”',\r\n"
+ + " `start_at` datetime NOT NULL COMMENT '开始时间',\r\n"
+ + " `end_at` datetime NOT NULL COMMENT '结束时间',\r\n"
+ + " `utime` datetime NOT NULL,\r\n"
+ + " `state` int(1) NOT NULL COMMENT '可选值:\\r\\n\\r\\n1:active\\r\\n\\r\\n2:pending\\r\\n\\r\\n3:expired',\r\n"
+ + " `seq` varchar(64) CHARACTER SET utf8 NOT NULL DEFAULT '' COMMENT '全局唯一,用于导入撤销\\r\\n\\r\\n默认:“”',\r\n"
+ + " PRIMARY KEY (`id`) USING BTREE\r\n"
+ + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
+
+ String assetAsset = "CREATE TABLE `asset_asset` (\r\n"
+ + " `id` int(10) NOT NULL AUTO_INCREMENT,\r\n"
+ + " `name` varchar(128) NOT NULL COMMENT '不重复,唯一索引',\r\n"
+ + " `number` varchar(128) NOT NULL DEFAULT '' COMMENT '资产编号',\r\n"
+ + " `sn` varchar(128) NOT NULL DEFAULT '' COMMENT '资产序列号',\r\n"
+ + " `pid` int(10) NOT NULL DEFAULT -1 COMMENT '默认:-1\\r\\n\\r\\n只有type vm = 1可以且必须填写此字段,且 pid.type vmh = 1',\r\n"
+ + " `type_id` int(10) NOT NULL,\r\n"
+ + " `state_id` int(10) NOT NULL,\r\n"
+ + " `brand_id` int(10) NOT NULL,\r\n"
+ + " `model_id` int(10) NOT NULL,\r\n"
+ + " `dc_id` int(10) NOT NULL,\r\n"
+ + " `cabinet_id` int(10) DEFAULT NULL,\r\n"
+ + " `cabinet_start` int(10) DEFAULT NULL,\r\n"
+ + " `cabinet_end` int(10) DEFAULT NULL,\r\n"
+ + " `manage_ip` varchar(64) NOT NULL COMMENT '管理ip',\r\n"
+ + " `purchase_date` date DEFAULT NULL COMMENT '购买日期',\r\n"
+ + " `create_at` datetime DEFAULT NULL COMMENT '添加时间',\r\n"
+ + " `update_at` datetime DEFAULT NULL COMMENT '更新时间',\r\n"
+ + " `create_by` int(10) DEFAULT NULL COMMENT '添加人,与user表关联',\r\n"
+ + " `update_by` int(10) DEFAULT NULL COMMENT '最后更新人',\r\n"
+ + " `seq` varchar(64) DEFAULT NULL,\r\n"
+ + " `auth_protocol_port` int(10) DEFAULT NULL COMMENT '认证服务端口',\r\n"
+ + " `auth_type` char(1) DEFAULT NULL COMMENT '认证方式1:用户名密码\\r\\n\\r\\n2:密钥',\r\n"
+ + " `auth_username` varchar(64) DEFAULT NULL COMMENT '用户名',\r\n"
+ + " `auth_pin` varchar(256) DEFAULT NULL COMMENT '密码auth_type =1 : 记录登录密码\\r\\n\\r\\nauth_type=2 : 记录密钥密码',\r\n"
+ + " `auth_pri_key` text DEFAULT NULL COMMENT '秘钥',\r\n"
+ + " `auth_user_tip` varchar(64) DEFAULT NULL COMMENT '用户名提示 telnet协议有效',\r\n"
+ + " `auth_pin_tip` varchar(64) DEFAULT NULL COMMENT '密码提示 telnet协议有效',\r\n"
+ + " `snmp_credential_id` int(10) DEFAULT NULL COMMENT 'snmp凭证id type 开启snmp有效',\r\n"
+ + " PRIMARY KEY (`id`) USING BTREE\r\n"
+ + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
+
+ String assetBrand = "CREATE TABLE `asset_brand` (\r\n"
+ + " `id` int(10) NOT NULL AUTO_INCREMENT,\r\n"
+ + " `name` varchar(64) DEFAULT NULL COMMENT '名称',\r\n"
+ + " `remark` varchar(256) DEFAULT '' COMMENT '备注',\r\n"
+ + " `seq` varchar(64) DEFAULT NULL,\r\n"
+ + " PRIMARY KEY (`id`) USING BTREE\r\n"
+ + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
+
+ String assetFieldGroup = "CREATE TABLE `asset_field_group` (\r\n"
+ + " `id` int(10) NOT NULL AUTO_INCREMENT,\r\n"
+ + " `name` varchar(64) DEFAULT NULL COMMENT '名称',\r\n"
+ + " `remark` varchar(1024) DEFAULT NULL,\r\n"
+ + " `build_in` char(1) DEFAULT NULL COMMENT '1:内置,0:非内置,默认:0\\r\\n\\r\\n内置数据不允许删除',\r\n"
+ + " `seq` varchar(64) DEFAULT NULL COMMENT '用户导入撤销',\r\n"
+ + " PRIMARY KEY (`id`) USING BTREE\r\n"
+ + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
+
+ String assetFieldMeta = "CREATE TABLE `asset_field_meta` (\r\n"
+ + " `id` int(10) NOT NULL AUTO_INCREMENT,\r\n"
+ + " `name` varchar(64) NOT NULL,\r\n"
+ + " `meta_key` varchar(128) NOT NULL COMMENT '唯一不重复 正则:[\\\\w]+',\r\n"
+ + " `group_id` varchar(128) NOT NULL COMMENT '关联 asset_field_group.id',\r\n"
+ + " `search` char(1) NOT NULL DEFAULT '0' COMMENT '默认:0 0:不可查询\\r\\n\\r\\n1:可查询',\r\n"
+ + " `display` char(1) NOT NULL DEFAULT '0' COMMENT '默认:0 0:列表不展示\\r\\n\\r\\n1:列表展示',\r\n"
+ + " `type` varchar(32) NOT NULL DEFAULT 'TEXT' COMMENT '属性输入类型',\r\n"
+ + " `remark` varchar(64) DEFAULT NULL,\r\n"
+ + " `param` text NOT NULL COMMENT '默认:{}',\r\n"
+ + " `build_in` int(1) NOT NULL DEFAULT 0 COMMENT '1:内置,0:非内置,默认:0',\r\n"
+ + " `seq` varchar(64) DEFAULT NULL COMMENT '用户导入撤销',\r\n"
+ + " PRIMARY KEY (`id`) USING BTREE\r\n"
+ + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
+
+ String assetFieldValue = "CREATE TABLE `asset_field_value` (\r\n"
+ + " `id` int(10) NOT NULL AUTO_INCREMENT,\r\n"
+ + " `asset_id` int(10) NOT NULL COMMENT ' 关联 asset.id',\r\n"
+ + " `meta_id` int(10) NOT NULL COMMENT '关联asset_field_meta.id',\r\n"
+ + " `value` text DEFAULT NULL,\r\n"
+ + " `seq` varchar(64) DEFAULT NULL COMMENT '用户导入撤销',\r\n"
+ + " PRIMARY KEY (`id`) USING BTREE\r\n"
+ + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
+
+ String assetModel = "CREATE TABLE `asset_model` (\r\n"
+ + " `id` int(10) NOT NULL AUTO_INCREMENT,\r\n"
+ + " `brand_id` int(10) NOT NULL,\r\n"
+ + " `name` varchar(64) NOT NULL COMMENT '型号名称',\r\n"
+ + " `remark` varchar(256) NOT NULL DEFAULT '',\r\n"
+ + " `seq` varchar(64) DEFAULT NULL,\r\n"
+ + " `usize` int(2) NOT NULL DEFAULT 1,\r\n"
+ + " `chart_ids` varchar(4096) DEFAULT NULL COMMENT 'chart 模板id',\r\n"
+ + " PRIMARY KEY (`id`) USING BTREE\r\n"
+ + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
+
+ String assetStateConf = "CREATE TABLE `asset_state_conf` (\r\n"
+ + " `id` int(10) NOT NULL AUTO_INCREMENT,\r\n"
+ + " `name` varchar(64) NOT NULL COMMENT '型号名称',\r\n"
+ + " `ping` char(1) NOT NULL COMMENT '0:关闭\\r\\n\\r\\n1:开启',\r\n"
+ + " `monitor` char(1) NOT NULL COMMENT '0:关闭\\r\\n\\r\\n1:开启',\r\n"
+ + " `alert` char(1) NOT NULL COMMENT '0:关闭\\r\\n\\r\\n1:开启',\r\n"
+ + " `remark` varchar(1024) NOT NULL DEFAULT '' COMMENT '默认“”',\r\n"
+ + " `build_in` char(1) NOT NULL DEFAULT '0' COMMENT '是否内置1:内置,0:非内置,默认:0\\r\\n\\r\\n内置数据不允许删除',\r\n"
+ + " PRIMARY KEY (`id`) USING BTREE\r\n"
+ + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
+
+ String assetTypeConf = "CREATE TABLE `asset_type_conf` (\r\n"
+ + " `id` int(10) NOT NULL AUTO_INCREMENT,\r\n"
+ + " `pid` int(10) NOT NULL DEFAULT 0 COMMENT '父id 默认为0',\r\n"
+ + " `vm` char(1) NOT NULL COMMENT '是否为虚拟机 0:不是虚拟机\\r\\n\\r\\n1:是虚拟机',\r\n"
+ + " `vmh` char(1) NOT NULL COMMENT '是否为虚拟机宿主 0:不是宿主机,不支持挂载 虚拟机\\r\\n\\r\\n1:是宿主机,支持挂载虚拟机',\r\n"
+ + " `name` varchar(64) NOT NULL COMMENT '名称',\r\n"
+ + " `remark` varchar(1024) NOT NULL DEFAULT '',\r\n"
+ + " `build_in` char(1) NOT NULL DEFAULT '0' COMMENT '1:内置,0:非内置,默认:0\\r\\n\\r\\n内置数据不允许删除',\r\n"
+ + " `auth_protocol` int(1) NOT NULL DEFAULT 0 COMMENT '认证协议 默认:0 \\r\\n\\r\\n0:无\\r\\n\\r\\n1:ssh\\r\\n\\r\\n2:telnet',\r\n"
+ + " `snmp_enable` int(1) NOT NULL DEFAULT 0 COMMENT '是否支持snmp 默认:0 \\r\\n\\r\\n0:不支持\\r\\n\\r\\n1:支持',\r\n"
+ + " `snmp_collect` int(1) NOT NULL DEFAULT 0 COMMENT '是否开启snmp采集 默认:0 \\r\\n\\r\\n0:不开启\\r\\n\\r\\n1:开启\\r\\n\\r\\n当snmp_enable=1时有效',\r\n"
+ + " `ssh_collect` int(1) NOT NULL COMMENT '是否开启ssh采集 默认:0 \\r\\n\\r\\n0:不开启\\r\\n\\r\\n1:开启\\r\\n\\r\\n当 auth_protocol=1时有效',\r\n"
+ + " `ssh_collect_script` varchar(256) NOT NULL DEFAULT '',\r\n"
+ + " PRIMARY KEY (`id`) USING BTREE\r\n"
+ + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
+
+ String dc = "CREATE TABLE `dc` (\r\n"
+ + " `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键自增',\r\n"
+ + " `name` varchar(64) NOT NULL COMMENT '名称',\r\n"
+ + " `location` varchar(256) DEFAULT NULL COMMENT '位置',\r\n"
+ + " `tel` varchar(128) DEFAULT NULL COMMENT '联系电话',\r\n"
+ + " `principal` int(10) DEFAULT NULL COMMENT '机房负责人',\r\n"
+ + " `seq` varchar(64) DEFAULT NULL COMMENT '全局唯一,用于导入撤销',\r\n"
+ + " `x` int(10) DEFAULT NULL COMMENT '列',\r\n"
+ + " `y` int(10) DEFAULT NULL COMMENT '行',\r\n"
+ + " `longitude` double(8,5) DEFAULT NULL COMMENT '经度 -180,180',\r\n"
+ + " `latitude` double(8,5) DEFAULT NULL COMMENT '纬度 -90,90',\r\n"
+ + " `state` varchar(8) NOT NULL DEFAULT 'ON' COMMENT '可选值:ON,OFF 默认:ON',\r\n"
+ + " PRIMARY KEY (`id`) USING BTREE\r\n"
+ + ") ENGINE=InnoDB DEFAULT CHARSET=utf8;";
+
+ String monitorEndpoint = "CREATE TABLE `monitor_endpoint` (\r\n"
+ + " `id` int(10) NOT NULL AUTO_INCREMENT,\r\n"
+ + " `name` varchar(128) NOT NULL COMMENT '名称',\r\n"
+ + " `module_id` int(10) NOT NULL,\r\n"
+ + " `asset_id` int(10) NOT NULL,\r\n"
+ + " `configs` text NOT NULL,\r\n"
+ + " `hash` varchar(64) NOT NULL COMMENT '计算 moduleId + assetId + host + port + configs 的hash值,用于确保相同配置不重复',\r\n"
+ + " `enabled` int(4) NOT NULL COMMENT '是否启用 可选值\\r\\n\\r\\n0:停用\\r\\n\\r\\n1:启用',\r\n"
+ + " `seq` varchar(64) DEFAULT NULL,\r\n"
+ + " PRIMARY KEY (`id`) USING BTREE\r\n"
+ + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
+
+ String monitorEndpointState = "CREATE TABLE `monitor_endpoint_state` (\r\n"
+ + " `endpoint_id` int(10) NOT NULL,\r\n"
+ + " `state` int(4) NOT NULL COMMENT ' ',\r\n"
+ + " `time` datetime NOT NULL,\r\n"
+ + " PRIMARY KEY (`endpoint_id`) USING BTREE\r\n"
+ + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
+
+ String monitorEventLog = "CREATE TABLE `monitor_event_log` (\r\n"
+ + " `id` int(10) NOT NULL AUTO_INCREMENT,\r\n"
+ + " `event` varchar(64) NOT NULL COMMENT '唯一不重复\\r\\n\\r\\n包含值:cmd,prometheus,rule,snmp,blackbox',\r\n"
+ + " `counter` int(10) NOT NULL COMMENT '描述信息,update +1',\r\n"
+ + " PRIMARY KEY (`id`) USING BTREE\r\n"
+ + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
+
+ String monitorModule = "CREATE TABLE `monitor_module` (\r\n"
+ + " `id` int(10) NOT NULL AUTO_INCREMENT,\r\n"
+ + " `name` varchar(64) DEFAULT NULL COMMENT '组件名称 唯一索引,表内不重复',\r\n"
+ + " `project_id` int(10) NOT NULL,\r\n"
+ + " `type` varchar(64) NOT NULL COMMENT '可选值http snmp',\r\n"
+ + " `endpoint_name_tmpl` varchar(64) NOT NULL COMMENT 'endpoint name模板 支持 {{}} 变量替换,asset,module\\r\\n\\r\\n例:{{asset.name}}-{{module.name}}\\r\\n\\r\\n最终endpoint的name为: 192.168.40.1-mysql',\r\n"
+ + " `remark` varchar(256) DEFAULT NULL,\r\n"
+ + " `configs` text NOT NULL COMMENT '配置参数 ',\r\n"
+ + " `snmp_yml` text DEFAULT NULL COMMENT 'snmp_exporter需要的配置部分',\r\n"
+ + " `build_in` char(1) NOT NULL DEFAULT '0',\r\n"
+ + " `seq` varchar(64) DEFAULT NULL,\r\n"
+ + " PRIMARY KEY (`id`) USING BTREE\r\n"
+ + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
+
+ String monitorProject = "CREATE TABLE `monitor_project` (\r\n"
+ + " `id` int(10) NOT NULL AUTO_INCREMENT,\r\n"
+ + " `name` varchar(64) DEFAULT NULL COMMENT '应用名称',\r\n"
+ + " `remark` varchar(256) DEFAULT NULL COMMENT '描述信息',\r\n"
+ + " `build_in` char(1) NOT NULL DEFAULT '0' COMMENT '是否内置 1:内置,0:非内置,默认:0',\r\n"
+ + " `seq` varchar(64) DEFAULT NULL,\r\n"
+ + " PRIMARY KEY (`id`) USING BTREE\r\n"
+ + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
+
+ String snmpCredential = "CREATE TABLE `snmp_credential` (\r\n"
+ + " `id` int(11) NOT NULL AUTO_INCREMENT,\r\n"
+ + " `name` varchar(64) NOT NULL COMMENT '名称',\r\n"
+ + " `remark` varchar(1024) DEFAULT NULL COMMENT '描述信息',\r\n"
+ + " `type` int(1) NOT NULL COMMENT '1,2,3 -- > V1,V2,V3 创建人id',\r\n"
+ + " `config` varchar(1024) DEFAULT NULL COMMENT '具体配置',\r\n"
+ + " `port` int(1) NOT NULL DEFAULT 161 COMMENT '端口号 默认161',\r\n"
+ + " PRIMARY KEY (`id`) USING BTREE\r\n"
+ + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
+
+ String sysApiKey = "CREATE TABLE `sys_api_key` (\r\n"
+ + " `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键',\r\n"
+ + " `name` varchar(64) NOT NULL COMMENT '名称 唯一不重复',\r\n"
+ + " `token` varchar(512) NOT NULL COMMENT '密钥 唯一不重复',\r\n"
+ + " `role_id` int(10) NOT NULL COMMENT '角色id',\r\n"
+ + " `create_by` int(10) NOT NULL COMMENT '创建用户',\r\n"
+ + " `create_at` datetime NOT NULL COMMENT '创建时间',\r\n"
+ + " `expire_at` datetime DEFAULT NULL COMMENT '失效时间 为空不失效',\r\n"
+ + " PRIMARY KEY (`id`) USING BTREE\r\n"
+ + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
+
+ String sysTimezone = "CREATE TABLE `sys_timezone` (\r\n"
+ + " `id` int(4) NOT NULL AUTO_INCREMENT,\r\n"
+ + " `name` varchar(255) NOT NULL COMMENT 'timezone id',\r\n"
+ + " `offset` int(10) NOT NULL COMMENT '单位:milliseconds',\r\n"
+ + " PRIMARY KEY (`id`) USING BTREE\r\n"
+ + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
+
+ String terminalCmd = "CREATE TABLE `terminal_cmd` (\r\n"
+ + " `id` int(10) NOT NULL AUTO_INCREMENT,\r\n"
+ + " `uuid` varchar(256) NOT NULL COMMENT '会话id',\r\n"
+ + " `cmd` varchar(4096) DEFAULT NULL COMMENT '用户输入命令',\r\n"
+ + " `time` int(10) DEFAULT NULL COMMENT '单位:ms\\r\\n\\r\\n记录的是 session开始后的时间偏移量',\r\n"
+ + " PRIMARY KEY (`id`) USING BTREE\r\n"
+ + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
+
+ String terminalRecord = "CREATE TABLE `terminal_record` (\r\n"
+ + " `id` int(10) NOT NULL AUTO_INCREMENT,\r\n"
+ + " `uuid` varchar(256) NOT NULL COMMENT '会话ID',\r\n"
+ + " `start_time` int(10) NOT NULL COMMENT '单位:ms\\r\\n\\r\\nrecord 开始时间,记录的是会话开始后的时间偏移量',\r\n"
+ + " `end_time` int(10) NOT NULL COMMENT '单位:ms\\r\\n\\r\\nrecord 结束时间,记录的是会话开始后的时间偏移量',\r\n"
+ + " `content` mediumblob NOT NULL COMMENT '记录的是 session开始后的时间偏移量\\r\\n\\r\\n最大储存 65K,超过部分再新增一条记录',\r\n"
+ + " PRIMARY KEY (`id`) USING BTREE\r\n"
+ + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
+
+ String terminalSession = "CREATE TABLE `terminal_session` (\r\n"
+ + " `id` int(10) NOT NULL AUTO_INCREMENT,\r\n"
+ + " `uuid` varchar(256) DEFAULT NULL COMMENT '会话id',\r\n"
+ + " `asset_id` int(10) DEFAULT NULL COMMENT '关联资产id',\r\n"
+ + " `host` varchar(128) DEFAULT NULL COMMENT '登录主机',\r\n"
+ + " `port` int(10) DEFAULT NULL COMMENT '端口',\r\n"
+ + " `protocol` varchar(32) DEFAULT NULL COMMENT '协议,可选值:SSH,TELNET。统一大写',\r\n"
+ + " `auth_type` int(10) DEFAULT NULL COMMENT '认证类型,1:密码,2:私钥证书 认证类型,1:密码,2:私钥证书\\r\\n\\r\\nssh可选值:1、2\\r\\n\\r\\ntelnet可选值:1',\r\n"
+ + " `login_user` varchar(128) DEFAULT NULL COMMENT '登录主机的用户名',\r\n"
+ + " `user_id` int(10) NOT NULL COMMENT 'nezha系统内用户id',\r\n"
+ + " `remote_addr` varchar(128) NOT NULL COMMENT '客户端ip地址',\r\n"
+ + " `start_time` datetime NOT NULL COMMENT '开始时间',\r\n"
+ + " `end_time` datetime DEFAULT NULL COMMENT '结束时间',\r\n"
+ + " `status` int(1) NOT NULL COMMENT '0:连接中\\r\\n\\r\\n1:发送失败(没有通过ssh或telnet发送成功)\\r\\n\\r\\n2:已结束\\r\\n\\r\\n3:强制退出\\r\\n\\r\\n4:未知错误',\r\n"
+ + " `kill_user_id` int(10) DEFAULT NULL COMMENT '强制关闭用户id',\r\n"
+ + " PRIMARY KEY (`id`) USING BTREE\r\n"
+ + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
+
+ String visualChart = "CREATE TABLE `visual_chart` (\r\n"
+ + " `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键',\r\n"
+ + " `name` varchar(255) NOT NULL COMMENT '图表标题',\r\n"
+ + " `panel_id` int(10) NOT NULL COMMENT '图表id,关联panel表\\r\\n\\r\\n当 panel_id =0 代表为模板',\r\n"
+ + " `group_id` int(10) NOT NULL COMMENT '关联 visual_chart.id,关联 chart 的 type 只能为 group',\r\n"
+ + " `span` int(10) NOT NULL COMMENT 'type = group,span = 12, 用户修改无效',\r\n"
+ + " `height` int(10) NOT NULL COMMENT 'type = group,height = -1,用户修改无效',\r\n"
+ + " `update_by` int(10) NOT NULL COMMENT '更新人',\r\n"
+ + " `update_at` datetime NOT NULL COMMENT '更新时间',\r\n"
+ + " `type` varchar(32) NOT NULL COMMENT '图表类型 line\\r\\nbar\\r\\ntable\\r\\nstackArea\\r\\nsingleStat\\r\\nurl\\r\\nassetInfo\\r\\nalertList\\r\\ngroup',\r\n"
+ + " `unit` int(10) NOT NULL DEFAULT 2 COMMENT '界面显示采用二级菜单',\r\n"
+ + " `weight` int(10) NOT NULL DEFAULT 0 COMMENT '默认为 0,用于chart排序',\r\n"
+ + " `param` text DEFAULT NULL COMMENT '参数 记录type的具体参数信息,数据格式为json对象\\r\\n\\r\\n当type = url时\\r\\n\\r\\n{\\r\\n\\r\\n “url”:\"https://www.baidu.com\"\\r\\n\\r\\n}',\r\n"
+ + " `pid` int(10) DEFAULT NULL COMMENT '模板id 图表通过模板创建时不能为空,便于后续模板修改同步修改',\r\n"
+ + " `build_in` char(1) NOT NULL DEFAULT '0' COMMENT '1:内置,0:非内置,默认:0',\r\n"
+ + " `remark` varchar(1024) NOT NULL DEFAULT '' COMMENT '默认:\"\"',\r\n"
+ + " `seq` varchar(64) DEFAULT NULL COMMENT '导入唯一标识',\r\n"
+ + " `var_type` int(1) DEFAULT NULL COMMENT '模板或使用模板创建有效,pid != null | panel_id == 0 时不能为空\\r\\n\\r\\n1: asset\\r\\n\\r\\n2: endpoint',\r\n"
+ + " `var_id` int(10) DEFAULT NULL COMMENT 'pid != null 时不能为空\\r\\n\\r\\n根据var_type 分别对应 asset.id, endpoint.id,用于 表达式变量替换',\r\n"
+ + " PRIMARY KEY (`id`) USING BTREE\r\n"
+ + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
+
+ String visualChartElement = "CREATE TABLE `visual_chart_element` (\r\n"
+ + " `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键',\r\n"
+ + " `chart_id` int(10) NOT NULL COMMENT '图表id,关联chart表',\r\n"
+ + " `expression` varchar(4096) NOT NULL COMMENT 'promql表达式',\r\n"
+ + " `type` varchar(32) NOT NULL COMMENT 'normal:简单表达式,可页面解析,如:up{asset=\"192.168.40.40\",module=\"kafka\"}\\r\\n\\r\\nexpert:用户输入表达式,解析困难,直接在页面显示',\r\n"
+ + " `legend` varchar(512) DEFAULT NULL COMMENT '图例别名表达式',\r\n"
+ + " `build_in` char(1) NOT NULL DEFAULT '0' COMMENT '是否内置',\r\n"
+ + " `seq` varchar(64) DEFAULT NULL COMMENT '导入唯一标识 用于导入撤销',\r\n"
+ + " PRIMARY KEY (`id`) USING BTREE\r\n"
+ + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
+
+ String visualPanel = "CREATE TABLE `visual_panel` (\r\n"
+ + " `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',\r\n"
+ + " `name` varchar(64) NOT NULL COMMENT '图表名',\r\n"
+ + " `create_by` int(10) NOT NULL COMMENT '创建人id',\r\n"
+ + " `type` varchar(64) NOT NULL DEFAULT 'dashboard' COMMENT '可选值:dashboard,asset,project,module,endpoint, model\\r\\n\\r\\n默认值:dashboard',\r\n"
+ + " `link` int(10) DEFAULT NULL COMMENT '关联id',\r\n"
+ + " `pid` int(10) NOT NULL DEFAULT 0 COMMENT '父id 默认0',\r\n"
+ + " `weight` int(10) NOT NULL DEFAULT 0 COMMENT '排序 默认0',\r\n"
+ + " `build_in` char(1) NOT NULL DEFAULT '0' COMMENT '是否内置',\r\n"
+ + " `seq` varchar(64) NOT NULL DEFAULT '' COMMENT '默认:“”\\r\\n\\r\\n用于导入撤销',\r\n"
+ + " PRIMARY KEY (`id`) USING BTREE\r\n"
+ + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
+
+ String visualExpressionTmpl = "CREATE TABLE `visual_expression_tmpl` (\r\n"
+ + " `id` int(10) NOT NULL AUTO_INCREMENT,\r\n"
+ + " `name` varchar(64) NOT NULL COMMENT '模板名称',\r\n"
+ + " `gname` varchar(64) NOT NULL DEFAULT 'default' COMMENT '组名,默认:default',\r\n"
+ + " `expression` varchar(4096) NOT NULL COMMENT '表达式,不能为空',\r\n"
+ + " `remark` varchar(512) NOT NULL COMMENT '描述',\r\n"
+ + " `build_in` char(1) NOT NULL DEFAULT '0' COMMENT '1:内置,0:非内置,默认:0',\r\n"
+ + " `seq` varchar(64) NOT NULL DEFAULT '' COMMENT '用于导入撤销,默认:“”',\r\n"
+ + " PRIMARY KEY (`id`) USING BTREE\r\n"
+ + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
+
+ String alertMessageActive = "CREATE TABLE `alert_message_active` (\r\n"
+ + " `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键',\r\n"
+ + " `severity` varchar(64) DEFAULT NULL COMMENT '告警级别',\r\n"
+ + " `summary` text DEFAULT NULL COMMENT '告警摘要',\r\n"
+ + " `description` text DEFAULT NULL COMMENT '告警描述',\r\n"
+ + " `labels` text DEFAULT NULL COMMENT '告警labels信息',\r\n"
+ + " `start_at` datetime DEFAULT NULL COMMENT '开始时间',\r\n"
+ + " `end_at` datetime DEFAULT NULL COMMENT '结束时间',\r\n"
+ + " `state` int(10) DEFAULT NULL COMMENT '状态1:pending,2:Expired',\r\n"
+ + " `rule_id` int(10) NOT NULL COMMENT '告警规则ID',\r\n"
+ + " `project_id` int(10) DEFAULT NULL COMMENT '关联project id',\r\n"
+ + " `module_id` int(10) DEFAULT NULL COMMENT '关联module id',\r\n"
+ + " `endpoint_id` int(10) DEFAULT NULL COMMENT '关联endpoint id',\r\n"
+ + " `asset_id` int(10) DEFAULT NULL COMMENT '关联资产id',\r\n"
+ + " `dc_id` int(10) DEFAULT NULL COMMENT '关联idc id',\r\n"
+ + " `hash_key` varchar(255) NOT NULL DEFAULT '' COMMENT 'redis hash key',\r\n"
+ + " `remark` text DEFAULT NULL COMMENT '备注 记录手动关闭记录信息,格式\\r\\n\\r\\ntime username\\r\\n\\r\\nmessage',\r\n"
+ + " `severity_id` int(10) DEFAULT NULL COMMENT '告警级别id,关联ALERT_SEVERITY_CONF',\r\n"
+ + " PRIMARY KEY (`id`) USING BTREE,\r\n"
+ + " KEY `idx_severity` (`severity`) USING BTREE,\r\n"
+ + " KEY `idx_state` (`state`) USING BTREE,\r\n"
+ + " KEY `idx_rule_id` (`rule_id`) USING BTREE,\r\n"
+ + " KEY `idx_project_id` (`project_id`) USING BTREE,\r\n"
+ + " KEY `idx_module_id` (`module_id`) USING BTREE,\r\n"
+ + " KEY `idx_endpoint_id` (`endpoint_id`) USING BTREE,\r\n"
+ + " KEY `idx_asset_id` (`asset_id`) USING BTREE,\r\n"
+ + " KEY `idx_dc_id` (`dc_id`) USING BTREE\r\n"
+ + ") ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;";
+
+ String alertMessageHistory = "CREATE TABLE `alert_message_history` (\r\n"
+ + " `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键',\r\n"
+ + " `severity` varchar(64) DEFAULT NULL COMMENT '告警级别',\r\n"
+ + " `summary` text DEFAULT NULL COMMENT '告警摘要',\r\n"
+ + " `description` text DEFAULT NULL COMMENT '告警描述',\r\n"
+ + " `labels` text DEFAULT NULL COMMENT '告警labels信息',\r\n"
+ + " `start_at` datetime DEFAULT NULL COMMENT '开始时间',\r\n"
+ + " `end_at` datetime DEFAULT NULL COMMENT '结束时间',\r\n"
+ + " `state` int(10) DEFAULT NULL COMMENT '状态1:pending,2:Expired',\r\n"
+ + " `rule_id` int(10) NOT NULL COMMENT '告警规则ID',\r\n"
+ + " `project_id` int(10) DEFAULT NULL COMMENT '关联project id',\r\n"
+ + " `module_id` int(10) DEFAULT NULL COMMENT '关联module id',\r\n"
+ + " `endpoint_id` int(10) DEFAULT NULL COMMENT '关联endpoint id',\r\n"
+ + " `asset_id` int(10) DEFAULT NULL COMMENT '关联资产id',\r\n"
+ + " `dc_id` int(10) DEFAULT NULL COMMENT '关联idc id',\r\n"
+ + " `hash_key` varchar(255) NOT NULL DEFAULT '' COMMENT 'redis hash key',\r\n"
+ + " `remark` text DEFAULT NULL COMMENT '备注 记录手动关闭记录信息,格式\\r\\n\\r\\ntime username\\r\\n\\r\\nmessage',\r\n"
+ + " `severity_id` int(10) DEFAULT NULL COMMENT '告警级别id,关联ALERT_SEVERITY_CONF',\r\n"
+ + " PRIMARY KEY (`id`) USING BTREE,\r\n"
+ + " KEY `idx_severity` (`severity`) USING BTREE,\r\n"
+ + " KEY `idx_state` (`state`) USING BTREE,\r\n"
+ + " KEY `idx_rule_id` (`rule_id`) USING BTREE,\r\n"
+ + " KEY `idx_project_id` (`project_id`) USING BTREE,\r\n"
+ + " KEY `idx_module_id` (`module_id`) USING BTREE,\r\n"
+ + " KEY `idx_endpoint_id` (`endpoint_id`) USING BTREE,\r\n"
+ + " KEY `idx_asset_id` (`asset_id`) USING BTREE,\r\n"
+ + " KEY `idx_dc_id` (`dc_id`) USING BTREE\r\n"
+ + ") ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;";
+
+ String alertMessageSilence = "CREATE TABLE `alert_message_silence` (\r\n"
+ + " `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键',\r\n"
+ + " `severity` varchar(64) DEFAULT NULL COMMENT '告警级别',\r\n"
+ + " `summary` text DEFAULT NULL COMMENT '告警摘要',\r\n"
+ + " `description` text DEFAULT NULL COMMENT '告警描述',\r\n"
+ + " `labels` text DEFAULT NULL COMMENT '告警labels信息',\r\n"
+ + " `start_at` datetime DEFAULT NULL COMMENT '开始时间',\r\n"
+ + " `end_at` datetime DEFAULT NULL COMMENT '结束时间',\r\n"
+ + " `state` int(10) DEFAULT NULL COMMENT '状态1:pending,2:Expired',\r\n"
+ + " `rule_id` int(10) NOT NULL COMMENT '告警规则ID',\r\n"
+ + " `project_id` int(10) DEFAULT NULL COMMENT '关联project id',\r\n"
+ + " `module_id` int(10) DEFAULT NULL COMMENT '关联module id',\r\n"
+ + " `endpoint_id` int(10) DEFAULT NULL COMMENT '关联endpoint id',\r\n"
+ + " `asset_id` int(10) DEFAULT NULL COMMENT '关联资产id',\r\n"
+ + " `dc_id` int(10) DEFAULT NULL COMMENT '关联idc id',\r\n"
+ + " `hash_key` varchar(255) NOT NULL DEFAULT '' COMMENT 'redis hash key',\r\n"
+ + " `remark` text DEFAULT NULL COMMENT '备注 记录手动关闭记录信息,格式\\r\\n\\r\\ntime username\\r\\n\\r\\nmessage',\r\n"
+ + " `severity_id` int(10) DEFAULT NULL COMMENT '告警级别id,关联ALERT_SEVERITY_CONF',\r\n"
+ + " PRIMARY KEY (`id`) USING BTREE,\r\n"
+ + " KEY `idx_severity` (`severity`) USING BTREE,\r\n"
+ + " KEY `idx_state` (`state`) USING BTREE,\r\n"
+ + " KEY `idx_rule_id` (`rule_id`) USING BTREE,\r\n"
+ + " KEY `idx_project_id` (`project_id`) USING BTREE,\r\n"
+ + " KEY `idx_module_id` (`module_id`) USING BTREE,\r\n"
+ + " KEY `idx_endpoint_id` (`endpoint_id`) USING BTREE,\r\n"
+ + " KEY `idx_asset_id` (`asset_id`) USING BTREE,\r\n"
+ + " KEY `idx_dc_id` (`dc_id`) USING BTREE\r\n"
+ + ") ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;";
+
+ String alertSilenceMessageRel = "CREATE TABLE `alert_silence_message_rel` (\r\n"
+ + " `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键',\r\n"
+ + " `silence_conf_id` int(10) NOT NULL,\r\n"
+ + " `message_id` bigint(20) NOT NULL,\r\n"
+ + " `hash_key` varchar(255) NOT NULL,\r\n"
+ + " PRIMARY KEY (`id`) USING BTREE\r\n"
+ + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
+ StringBuilder sb = new StringBuilder();
+ sb.append(alertSilenceConf);
+ sb.append(alertSeverityConf);
+ sb.append(alertNotifyMethod);
+ sb.append(alertNotifyLog);
+ sb.append(assetAsset);
+ sb.append(assetBrand);
+ sb.append(assetFieldGroup);
+ sb.append(assetFieldMeta);
+ sb.append(assetFieldValue);
+ sb.append(assetModel);
+ sb.append(assetStateConf);
+ sb.append(assetTypeConf);
+ sb.append(dc);
+ sb.append(monitorEndpoint);
+ sb.append(monitorEndpointState);
+ sb.append(monitorEventLog);
+ sb.append(monitorModule);
+ sb.append(monitorProject);
+ sb.append(snmpCredential);
+ sb.append(sysApiKey);
+ sb.append(sysTimezone);
+ sb.append(terminalCmd);
+ sb.append(terminalRecord);
+ sb.append(terminalSession);
+ sb.append(visualChart);
+ sb.append(visualChartElement);
+ sb.append(visualPanel);
+ sb.append(visualExpressionTmpl);
+ sb.append(alertMessageHistory);
+ sb.append(alertMessageSilence);
+ sb.append(alertMessageActive);
+ sb.append(alertSilenceMessageRel);
+ sqlDao.execute(sb.toString());
+ }
+
+ /**
+ * alert_severity_conf
+ * asset_field_group
+ * asset_brand
+ * asset_model
+ * asset_state_conf
+ * asset_type_conf
+ * monitor_event_log
+ * sys_timezone
+ */
+ public void initData() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("INSERT INTO `asset_field_group`(`id`, `name`, `remark`, `build_in`, `seq`) VALUES (1, 'default', 'Default meta group', '1', '');");
+ sb.append("INSERT INTO `alert_severity_conf`(`id`, `name`, `color`, `weight`, `remark`) VALUES (1, 'P1', '#f2866e', 1, '高级告警');");
+ sb.append("INSERT INTO `alert_severity_conf`(`id`, `name`, `color`, `weight`, `remark`) VALUES (2, 'P2', '#f89984', 2, '中级告警');");
+ sb.append("INSERT INTO `alert_severity_conf`(`id`, `name`, `color`, `weight`, `remark`) VALUES (3, 'P3', '#f7ba78', 3, '低级告警');");
+ sb.append("INSERT INTO `asset_state_conf`(`id`, `name`, `ping`, `monitor`, `alert`, `remark`, `build_in`) VALUES (1, 'In use', '1', '1', '1', '', '1');");
+ sb.append("INSERT INTO `asset_state_conf`(`id`, `name`, `ping`, `monitor`, `alert`, `remark`, `build_in`) VALUES (2, 'Not in storage', '0', '0', '0', '', '1');");
+ sb.append("INSERT INTO `asset_state_conf`(`id`, `name`, `ping`, `monitor`, `alert`, `remark`, `build_in`) VALUES (3, 'Idle', '1', '0', '1', '', '1');");
+ sb.append("INSERT INTO `asset_state_conf`(`id`, `name`, `ping`, `monitor`, `alert`, `remark`, `build_in`) VALUES (4, 'Repair', '1', '1', '0', '', '1'); ");
+ sb.append("INSERT INTO `asset_state_conf`(`id`, `name`, `ping`, `monitor`, `alert`, `remark`, `build_in`) VALUES (5, 'Scrapped', '1', '0', '0', '', '1');");
+ sb.append("INSERT INTO `asset_type_conf`(`id`, `pid`, `vm`, `vmh`, `name`, `remark`, `build_in`, `auth_protocol`, `snmp_enable`, `snmp_collect`, `ssh_collect`, `ssh_collect_script`) VALUES (1, 0, '1', '1', 'Network devices', 'Network devices', '1', 2, 1, 1, 1, '');");
+ sb.append("INSERT INTO `asset_type_conf`(`id`, `pid`, `vm`, `vmh`, `name`, `remark`, `build_in`, `auth_protocol`, `snmp_enable`, `snmp_collect`, `ssh_collect`, `ssh_collect_script`) VALUES (2, 0, '0', '0', 'Router', '', '1', 2, 1, 0, 0, '');");
+ sb.append("INSERT INTO `asset_type_conf`(`id`, `pid`, `vm`, `vmh`, `name`, `remark`, `build_in`, `auth_protocol`, `snmp_enable`, `snmp_collect`, `ssh_collect`, `ssh_collect_script`) VALUES (3, 0, '0', '0', 'Firewall', '', '1', 2, 1, 0, 0, '');");
+ sb.append("INSERT INTO `asset_type_conf`(`id`, `pid`, `vm`, `vmh`, `name`, `remark`, `build_in`, `auth_protocol`, `snmp_enable`, `snmp_collect`, `ssh_collect`, `ssh_collect_script`) VALUES (4, 0, '0', '0', 'Switch', '', '1', 2, 1, 0, 0, '');");
+ sb.append("INSERT INTO `asset_type_conf`(`id`, `pid`, `vm`, `vmh`, `name`, `remark`, `build_in`, `auth_protocol`, `snmp_enable`, `snmp_collect`, `ssh_collect`, `ssh_collect_script`) VALUES (5, 0, '0', '1', 'Computer', '', '1', 1, 0, 0, 0, '');");
+ sb.append("INSERT INTO `asset_type_conf`(`id`, `pid`, `vm`, `vmh`, `name`, `remark`, `build_in`, `auth_protocol`, `snmp_enable`, `snmp_collect`, `ssh_collect`, `ssh_collect_script`) VALUES (6, 0, '0', '1', 'Server', '', '1', 1, 0, 0, 0, '');");
+ sb.append("INSERT INTO `asset_type_conf`(`id`, `pid`, `vm`, `vmh`, `name`, `remark`, `build_in`, `auth_protocol`, `snmp_enable`, `snmp_collect`, `ssh_collect`, `ssh_collect_script`) VALUES (7, 0, '1', '0', 'Virtual machine', '', '1', 1, 0, 0, 0, '');");
+ sb.append("INSERT INTO `asset_type_conf`(`id`, `pid`, `vm`, `vmh`, `name`, `remark`, `build_in`, `auth_protocol`, `snmp_enable`, `snmp_collect`, `ssh_collect`, `ssh_collect_script`) VALUES (8, 0, '0', '0', 'ADC', '', '1', 1, 1, 0, 0, '');");
+ sb.append("INSERT INTO `monitor_event_log`(`event`, `counter`) VALUES ('blackbox', 0);");
+ sb.append("INSERT INTO `monitor_event_log`(`event`, `counter`) VALUES ('cmd', 0);");
+ sb.append("INSERT INTO `monitor_event_log`(`event`, `counter`) VALUES ('global', 0);");
+ sb.append("INSERT INTO `monitor_event_log`(`event`, `counter`) VALUES ('per-datacenter', 0);");
+ sb.append("INSERT INTO `monitor_event_log`(`event`, `counter`) VALUES ('snmp', 0);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (1, 'Africa/Abidjan', 0);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (2, 'Africa/Accra', 0);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (3, 'Africa/Algiers', 3600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (4, 'Africa/Bissau', 0);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (5, 'Africa/Cairo', 7200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (6, 'Africa/Casablanca', 0);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (7, 'Africa/Ceuta', 3600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (8, 'Africa/El_Aaiun', 0);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (9, 'Africa/Johannesburg', 7200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (10, 'Africa/Juba', 10800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (11, 'Africa/Khartoum', 10800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (12, 'Africa/Lagos', 3600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (13, 'Africa/Maputo', 7200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (14, 'Africa/Monrovia', 0);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (15, 'Africa/Nairobi', 10800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (16, 'Africa/Ndjamena', 3600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (17, 'Africa/Sao_Tome', 0);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (18, 'Africa/Tripoli', 7200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (19, 'Africa/Tunis', 3600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (20, 'Africa/Windhoek', 3600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (21, 'Antarctica/Casey', 28800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (22, 'Antarctica/Davis', 25200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (23, 'Antarctica/DumontDUrville', 36000000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (24, 'Antarctica/Macquarie', 39600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (25, 'Antarctica/Mawson', 18000000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (26, 'Antarctica/Palmer', -14400000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (27, 'Antarctica/Rothera', -10800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (28, 'Antarctica/Syowa', 10800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (29, 'Antarctica/Troll', 0);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (30, 'Antarctica/Vostok', 21600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (31, 'Asia/Almaty', 21600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (32, 'Asia/Amman', 7200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (33, 'Asia/Anadyr', 43200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (34, 'Asia/Aqtau', 18000000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (35, 'Asia/Aqtobe', 18000000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (36, 'Asia/Ashgabat', 18000000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (37, 'Asia/Atyrau', 0);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (38, 'Asia/Baghdad', 10800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (39, 'Asia/Baku', 14400000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (40, 'Asia/Bangkok', 25200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (41, 'Asia/Barnaul', 25200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (42, 'Asia/Beirut', 7200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (43, 'Asia/Bishkek', 21600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (44, 'Asia/Brunei', 28800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (45, 'Asia/Chita', 32400000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (46, 'Asia/Choibalsan', 28800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (47, 'Asia/Colombo', 19800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (48, 'Asia/Damascus', 7200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (49, 'Asia/Dhaka', 21600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (50, 'Asia/Dili', 32400000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (51, 'Asia/Dubai', 14400000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (52, 'Asia/Dushanbe', 18000000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (53, 'Asia/Famagusta', 0);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (54, 'Asia/Gaza', 7200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (55, 'Asia/Hebron', 7200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (56, 'Asia/Ho_Chi_Minh', 25200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (57, 'Asia/Hong_Kong', 28800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (58, 'Asia/Hovd', 25200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (59, 'Asia/Irkutsk', 28800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (60, 'Asia/Jakarta', 25200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (61, 'Asia/Jayapura', 32400000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (62, 'Asia/Jerusalem', 7200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (63, 'Asia/Kabul', 16200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (64, 'Asia/Kamchatka', 43200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (65, 'Asia/Karachi', 18000000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (66, 'Asia/Kathmandu', 20700000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (67, 'Asia/Khandyga', 32400000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (68, 'Asia/Kolkata', 19800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (69, 'Asia/Krasnoyarsk', 25200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (70, 'Asia/Kuala_Lumpur', 28800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (71, 'Asia/Kuching', 28800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (72, 'Asia/Macau', 28800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (73, 'Asia/Magadan', 39600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (74, 'Asia/Makassar', 28800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (75, 'Asia/Manila', 28800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (76, 'Asia/Nicosia', 7200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (77, 'Asia/Novokuznetsk', 25200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (78, 'Asia/Novosibirsk', 21600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (79, 'Asia/Omsk', 21600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (80, 'Asia/Oral', 18000000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (81, 'Asia/Pontianak', 25200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (82, 'Asia/Pyongyang', 30600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (83, 'Asia/Qatar', 10800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (84, 'Asia/Qostanay', 0);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (85, 'Asia/Qyzylorda', 21600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (86, 'Asia/Riyadh', 10800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (87, 'Asia/Sakhalin', 39600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (88, 'Asia/Samarkand', 18000000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (89, 'Asia/Seoul', 32400000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (90, 'Asia/Shanghai', 28800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (91, 'Asia/Singapore', 28800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (92, 'Asia/Srednekolymsk', 39600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (93, 'Asia/Taipei', 28800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (94, 'Asia/Tashkent', 18000000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (95, 'Asia/Tbilisi', 14400000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (96, 'Asia/Tehran', 12600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (97, 'Asia/Thimphu', 21600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (98, 'Asia/Tokyo', 32400000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (99, 'Asia/Tomsk', 25200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (100, 'Asia/Ulaanbaatar', 28800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (101, 'Asia/Urumqi', 21600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (102, 'Asia/Ust-Nera', 36000000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (103, 'Asia/Vladivostok', 36000000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (104, 'Asia/Yakutsk', 32400000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (105, 'Asia/Yangon', 0);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (106, 'Asia/Yekaterinburg', 18000000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (107, 'Asia/Yerevan', 14400000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (108, 'Atlantic/Azores', -3600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (109, 'Atlantic/Bermuda', -14400000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (110, 'Atlantic/Canary', 0);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (111, 'Atlantic/Cape_Verde', -3600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (112, 'Atlantic/Faroe', 0);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (113, 'Atlantic/Madeira', 0);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (114, 'Atlantic/Reykjavik', 0);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (115, 'Atlantic/South_Georgia', -7200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (116, 'Atlantic/Stanley', -10800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (117, 'Australia/Adelaide', 34200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (118, 'Australia/Brisbane', 36000000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (119, 'Australia/Broken_Hill', 34200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (120, 'Australia/Darwin', 34200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (121, 'Australia/Eucla', 31500000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (122, 'Australia/Hobart', 36000000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (123, 'Australia/Lindeman', 36000000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (124, 'Australia/Lord_Howe', 37800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (125, 'Australia/Melbourne', 36000000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (126, 'Australia/Perth', 28800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (127, 'Australia/Sydney', 36000000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (128, 'Etc/GMT', 0);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (129, 'Etc/GMT+1', -3600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (130, 'Etc/GMT+10', -36000000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (131, 'Etc/GMT+11', -39600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (132, 'Etc/GMT+12', -43200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (133, 'Etc/GMT+2', -7200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (134, 'Etc/GMT+3', -10800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (135, 'Etc/GMT+4', -14400000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (136, 'Etc/GMT+5', -18000000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (137, 'Etc/GMT+6', -21600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (138, 'Etc/GMT+7', -25200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (139, 'Etc/GMT+8', -28800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (140, 'Etc/GMT+9', -32400000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (141, 'Etc/GMT-1', 3600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (142, 'Etc/GMT-10', 36000000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (143, 'Etc/GMT-11', 39600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (144, 'Etc/GMT-12', 43200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (145, 'Etc/GMT-13', 46800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (146, 'Etc/GMT-14', 50400000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (147, 'Etc/GMT-2', 7200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (148, 'Etc/GMT-3', 10800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (149, 'Etc/GMT-4', 14400000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (150, 'Etc/GMT-5', 18000000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (151, 'Etc/GMT-6', 21600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (152, 'Etc/GMT-7', 25200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (153, 'Etc/GMT-8', 28800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (154, 'Etc/GMT-9', 32400000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (155, 'Etc/UTC', 0);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (156, 'Europe/Amsterdam', 3600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (157, 'Europe/Andorra', 3600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (158, 'Europe/Astrakhan', 14400000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (159, 'Europe/Athens', 7200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (160, 'Europe/Belgrade', 3600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (161, 'Europe/Berlin', 3600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (162, 'Europe/Brussels', 3600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (163, 'Europe/Bucharest', 7200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (164, 'Europe/Budapest', 3600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (165, 'Europe/Chisinau', 7200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (166, 'Europe/Copenhagen', 3600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (167, 'Europe/Dublin', 0);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (168, 'Europe/Gibraltar', 3600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (169, 'Europe/Helsinki', 7200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (170, 'Europe/Istanbul', 7200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (171, 'Europe/Kaliningrad', 7200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (172, 'Europe/Kiev', 7200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (173, 'Europe/Kirov', 10800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (174, 'Europe/Lisbon', 0);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (175, 'Europe/London', 0);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (176, 'Europe/Luxembourg', 3600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (177, 'Europe/Madrid', 3600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (178, 'Europe/Malta', 3600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (179, 'Europe/Minsk', 10800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (180, 'Europe/Monaco', 3600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (181, 'Europe/Moscow', 10800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (182, 'Europe/Oslo', 3600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (183, 'Europe/Paris', 3600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (184, 'Europe/Prague', 3600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (185, 'Europe/Riga', 7200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (186, 'Europe/Rome', 3600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (187, 'Europe/Samara', 14400000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (188, 'Europe/Saratov', 0);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (189, 'Europe/Simferopol', 10800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (190, 'Europe/Sofia', 7200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (191, 'Europe/Stockholm', 3600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (192, 'Europe/Tallinn', 7200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (193, 'Europe/Tirane', 3600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (194, 'Europe/Ulyanovsk', 14400000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (195, 'Europe/Uzhgorod', 7200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (196, 'Europe/Vienna', 3600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (197, 'Europe/Vilnius', 7200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (198, 'Europe/Volgograd', 10800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (199, 'Europe/Warsaw', 3600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (200, 'Europe/Zaporozhye', 7200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (201, 'Europe/Zurich', 3600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (202, 'Factory', 0);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (203, 'Indian/Chagos', 21600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (204, 'Indian/Christmas', 25200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (205, 'Indian/Cocos', 23400000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (206, 'Indian/Kerguelen', 18000000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (207, 'Indian/Mahe', 14400000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (208, 'Indian/Maldives', 18000000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (209, 'Indian/Mauritius', 14400000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (210, 'Indian/Reunion', 14400000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (211, 'Pacific/Apia', 46800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (212, 'Pacific/Auckland', 43200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (213, 'Pacific/Bougainville', 39600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (214, 'Pacific/Chatham', 45900000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (215, 'Pacific/Chuuk', 36000000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (216, 'Pacific/Easter', -21600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (217, 'Pacific/Efate', 39600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (218, 'Pacific/Enderbury', 46800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (219, 'Pacific/Fakaofo', 46800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (220, 'Pacific/Fiji', 43200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (221, 'Pacific/Funafuti', 43200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (222, 'Pacific/Galapagos', -21600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (223, 'Pacific/Gambier', -32400000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (224, 'Pacific/Guadalcanal', 39600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (225, 'Pacific/Guam', 36000000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (226, 'Pacific/Honolulu', -36000000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (227, 'Pacific/Kiritimati', 50400000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (228, 'Pacific/Kosrae', 39600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (229, 'Pacific/Kwajalein', 43200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (230, 'Pacific/Majuro', 43200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (231, 'Pacific/Marquesas', -34200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (232, 'Pacific/Nauru', 43200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (233, 'Pacific/Niue', -39600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (234, 'Pacific/Norfolk', 39600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (235, 'Pacific/Noumea', 39600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (236, 'Pacific/Pago_Pago', -39600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (237, 'Pacific/Palau', 32400000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (238, 'Pacific/Pitcairn', -28800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (239, 'Pacific/Pohnpei', 39600000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (240, 'Pacific/Port_Moresby', 36000000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (241, 'Pacific/Rarotonga', -36000000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (242, 'Pacific/Tahiti', -36000000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (243, 'Pacific/Tarawa', 43200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (244, 'Pacific/Tongatapu', 46800000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (245, 'Pacific/Wake', 43200000);");
+ sb.append("INSERT INTO `sys_timezone`(`id`, `name`, `offset`) VALUES (246, 'Pacific/Wallis', 43200000);");
+ sb.append("INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('asset_asset_export_header', '{\\r\\n \\\"cn\\\": {\\r\\n \\\"*资产名称\\\": \\\"资产名称,唯一标识(必填) \\\\n示例: DELL服务器\\\",\\r\\n \\\"*SN码\\\": \\\"资产序列号,唯一标识(必填) \\\\n示例: A0420200101\\\",\\r\\n \\\"虚拟机宿主\\\": \\\"虚拟机宿主,当资产为虚拟机时必填 \\\\n示例: DELL物理机\\\",\\r\\n \\\"*管理ip\\\": \\\"主机地址(必填),IP格式 \\\\n示例: 172.0.0.1\\\",\\r\\n \\\"*品牌\\\": \\\"品牌(必填) \\\\n示例: DELL\\\",\\r\\n \\\"*型号\\\": \\\"型号(必填) \\\\n示例: DELL-D3\\\",\\r\\n \\\"*数据中心\\\": \\\"数据中心(必填) \\\\n示例: 北京电信中心机房\\\",\\r\\n \\\"机柜\\\": \\\"机柜 \\\\n示例: cabinet-001\\\",\\r\\n \\\"开始U位\\\": \\\"机柜开始位置 此信息一般和机柜结束位置联合使用 \\\\n示例: 1\\\",\\r\\n \\\"结束U位\\\": \\\"机柜结束位置 此信息一般与机柜开始位置联合使用 \\\\n示例: 2\\\",\\r\\n \\\"*资产状态\\\": \\\"资产状态 \\\\n示例: 在库\\\",\\r\\n \\\"*资产类型\\\": \\\"资产类型 \\\\n示例: 服务器\\\",\\r\\n \\\"购买日期\\\": \\\"购买日期 \\\\n示例: 2020/2/25\\\",\\r\\n \\\"属性信息\\\": \\\"资产属性信息,格式: key=value 如需填写多个请使用回车换行 \\\\n示例: NetworkCard=eth0 \\\\n user=root\\\",\\r\\n \\\"认证服务端口\\\": \\\"ssh/telnet端口 \\\\n示例: 22/23\\\",\\r\\n \\\"认证方式\\\":\\\"用户名密码/密钥 \\\\n示例:111111\\\",\\r\\n \\\"用户名\\\":\\\"用户名 \\\\n示例:root\\\",\\r\\n \\\"密码\\\":\\\"auth_type =1 : 记录登录密码 auth_type=2 : 记录密钥密码\\\",\\r\\n \\\"密钥\\\":\\\"密钥内容\\\",\\r\\n \\\"用户名提示\\\":\\\"telnet协议有效\\\",\\r\\n \\\"密码提示\\\":\\\"telnet协议有效\\\",\\r\\n \\\"snmp凭证\\\":\\\"type 开启snmp有效\\\"\\r\\n },\\r\\n \\\"en\\\": {\\r\\n \\\"*Asset Name\\\": \\\"Asset name, unique identifier (required) \\\\nExample: DELL server\\\",\\r\\n \\\"*Sn\\\": \\\"Asset serial number, unique identifier (required) \\\\nExample: A0420200101\\\",\\r\\n \\\"*Virtual machine host\\\": \\\"Virtual machine host, required when the asset is a virtual machine \\\\nExample: DELL physical machine\\\",\\r\\n \\\"*Management ip\\\": \\\"Host address (required), IP format \\\\nExample: 172.0.0.1\\\",\\r\\n \\\"*Brand\\\": \\\"Brand (required) \\\\nExample: DELL\\\",\\r\\n \\\"*Model\\\": \\\"Model (required) \\\\nExample: DELL-D3\\\",\\r\\n \\\"*DC\\\": \\\"Data Center (Required) \\\\nExample: Beijing Telecom Center Computer Room\\\",\\r\\n \\\"Cabinet\\\": \\\"Cabinet \\\\nExample: cabinet-001\\\",\\r\\n \\\"Cabinet Start\\\": \\\"Cabinet start position This information is generally used in conjunction with the cabinet end position \\\\nExample: 1\\\",\\r\\n \\\"Cabinet End\\\": \\\"Cabinet end position This information is generally used in conjunction with the cabinet start position \\\\nExample: 2\\\",\\r\\n \\\"*Asset state\\\": \\\"Asset status \\\\nExample: In stock\\\",\\r\\n \\\"*Asset type\\\": \\\"Asset Type\\\\nExample: Server\\\",\\r\\n \\\"Purchase date\\\": \\\"Purchase date \\\\nExample: 2020/2/25\\\",\\r\\n \\\"Field Information\\\": \\\"Asset field information, format: key=value If you need to fill in more than one, please use carriage return and line feed \\\\nExample: NetworkCard=eth0 \\\\n user=root\\\",\\r\\n \\\"Auth protocol Port\\\": \\\"ssh/telnet \\\\nExample: 22/23\\\",\\r\\n \\\"Auth Type\\\":\\\"User name password / pri key \\\\nExample: 111111\\\",\\r\\n \\\"Auth Username\\\":\\\"username \\\\nExample: root\\\",\\r\\n \\\"Auth Pin\\\":\\\"auth_type =1 : pin value auth_type=2 : pri key pin\\\",\\r\\n \\\"Auth Pri Key\\\":\\\"pri key content\\\",\\r\\n \\\"Auth User Tip\\\":\\\"telnet protocol valid\\\",\\r\\n \\\"Auth Pin Tip\\\":\\\"telnet protocol valid\\\",\\r\\n \\\"Snmp Credential\\\":\\\"snmp protocol valid\\\"\\r\\n }\\r\\n}', 1, NULL);\r\n"
+ + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('asset_chart_tpl', '{\\\"name\\\":\\\"{{asset.sn}}\\\",\\\"type\\\":\\\"assetInfo\\\",\\\"span\\\":12,\\\"height\\\":400,\\\"unit\\\":2}', 1, NULL);\r\n"
+ + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('asset_ping_from', '2', 1, '1: global\\r\\n\\r\\n2: per-datacenter\\r\\n\\r\\n默认:1');\r\n"
+ + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('confagent_name', '{\\\"centos\\\":\\\"confagent-v2.0-x86.rpm\\\",\\\"ubuntu\\\":\\\"confagent-v2.0-x86.zip\\\"}', 1, 'confagent 下载文件名称');\r\n"
+ + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('email_auth_account', '', 1, '');\r\n"
+ + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('email_auth_password', '', 1, '');\r\n"
+ + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('email_host', '', 1, '');\r\n"
+ + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('email_port', '25', 1, '');\r\n"
+ + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('email_security_type', 'NONE', 1, 'NONE SSL TLS');\r\n"
+ + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('email_test_account', '', 1, '');\r\n"
+ + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('email_timeout', '10', 1, '默认:10');\r\n"
+ + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('endpoint_chart_tpl', '{\\\"name\\\":\\\"{{endpoint.name}}\\\",\\\"type\\\":\\\"endpointInfo\\\",\\\"span\\\":12,\\\"height\\\":400,\\\"unit\\\":2}', 1, NULL);\r\n"
+ + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('expretmpl_export_header', '{\\\"cn\\\":{\\\"*名称\\\":\\\"模板名称(必填) \\\\n示例: CPU利用率模板\\\",\\\"组名\\\":\\\"组名 \\\\n示例: base,默认值: default\\\",\\\"*表达式\\\":\\\"表达式内容(必填) \\\\n示例: node_cpu_usage(asset=\\\\\\\"{{asset.host}}\\\\\\\",device=\\\\\\\"{{device}}\\\\\\\")\\\",\\\"描述\\\":\\\"描述 \\\\n示例: node_export CPU利用率模板\\\"},\\\"en\\\":{\\\"*Name\\\":\\\"Template name (required) \\\\nExample: CPU utilization template\\\",\\\"Group Name\\\":\\\"Group Name \\\\nExample: base, Default value: default\\\",\\\"*Expression\\\":\\\"Expression content (required) Optional: node_cpu_usage(asset=\\\\\\\"{{asset.host}}\\\\\\\",device=\\\\\\\"{{device}}\\\\\\\")\\\",\\\"Remark\\\":\\\"Remark \\\\nExample: node_export CPU utilization template\\\"}}', 1, '表达式导入导出模板表头信息');\r\n"
+ + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('license', '<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?><license><product><maximumAssets>2000</maximumAssets><name>NEZHA</name><version>base</version></product><endDate>2021-06-03T14:52:43Z</endDate><signature><digestValue>3403d697d45c594a0d147d556d94ad087272830c</digestValue><signatureValue>35af0e65b3b6d6474db62359a42adf685413144e3ff57f3551f33c54614ed8eb4d705efd25ca873a73af08912242b74d3272cef149ac0b39ac4247e7263f9b395c1892aea7dce0d941ea14ee901f052192ce555c4c438510b31d6fef30b109125a42b19fbcf3190482adab2ffc64d01c31f3dd020a712fc97138c3c52df41f0116c56543faddba8a7393581dee612fec9646ca4edb6f46bf2894eeaff1436feb126ce7155dd8b5514038320b297fab40ca4ed0402eb71951e8b00185fe7fe7f0f0ba13de3d4dc9416a5762214bb8f2bfa7ec688bd119aeaa2a4c4153383b64a463892d63301070c295404538b54f8de7d36ca7fbf40011b9e057cbb1d4a15147</signatureValue></signature><contract>[email protected]</contract><by>abc</by><genDate>2021-04-16T13:52:38Z</genDate><comment>test license</comment><tokens/><licenseId>111</licenseId><startDate>2021-03-03T14:52:43Z</startDate><customer>zhangsan</customer></license>', 1, '3403d697d45c594a0d147d556d94ad087272830c');\r\n"
+ + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('license_token', 'abbbb', 1, NULL);\r\n"
+ + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('ldap_timeout', '30', 1, '超时时间秒');\r\n"
+ + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('monitor_endpoint_export_header', '{\\\"cn\\\":{\\\"*系统\\\":\\\"系统名称(必填) \\\\n示例: Nezha\\\",\\\"*组件\\\":\\\"组件名称(必填) \\\\n示例: node_exporter\\\",\\\"名称\\\":\\\"实例名称 \\\\n示例: node_exporter\\\",\\\"资产名称\\\":\\\"资产名称(非必填) 与 主机地址 不能同时为空 \\\\n示例: A0420200101\\\",\\\"配置\\\":\\\"实例配置,JSON格式, \\\\n示例: {\\\\\\\"key\\\\\\\":\\\\\\\"value\\\\\\\"}\\\",\\\"启用\\\":\\\"启用状态(非必填) 可选 0:停用 1:启用,为空时默认为1 \\\\n示例: 1\\\"},\\\"en\\\":{\\\"*Project Name\\\":\\\"Project Name(Required) \\\\nExample: Nezha\\\",\\\"*Module Name\\\":\\\"Module Name(Required) \\\\nExample: node_exporter\\\",\\\"Name\\\":\\\"Endpoint name \\\\nExample: node_exporter\\\",\\\"Asset Name\\\":\\\"Asset name(Not required) And host address cannot be empty at the same time \\\\n示例: A0420200101\\\",\\\"Configs\\\":\\\"Endpoint Configs,JSON format, \\\\nExample: {\\\\\\\"key\\\\\\\":\\\\\\\"value\\\\\\\"}\\\",\\\"Enabled\\\":\\\"Enable state (not required) Optional values 0: Disable 1: Enable, when empty, the default is 1 \\\\nExample: 1\\\"}}', 1, 'monitor endpoint 导入表头');\r\n"
+ + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('prometheus_federation_enabled', '1', 1, '配置prometheus是否开启联邦模式,1:开启,0:关闭(界面禁用 添加选择 per-datacenter agent,所有endpoint 配置信息 hash 分布到 global prometheus)');\r\n"
+ + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('prom_cmd_tmpl', 'OPTION=\\\" --config.file=\\'/opt/nezha/nz-confagent/prometheus/prometheus.yml\\' --web.listen-address=\\'127.0.0.1:9090\\' --web.enable-admin-api --storage.tsdb.path=\\'/data/prometheusData\\' --web.enable-lifecycle --storage.tsdb.retention.time=${storageDays}d \\\"', 1, 'prometheus 启动参数模板');\r\n"
+ + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('prom_rule_tmpl', '{\\r\\n \\\"groups\\\": [{\\r\\n \\\"name\\\": \\\"alertRule\\\",\\r\\n \\\"rules\\\": [\\r\\n <#if endpointAlert>\\r\\n {\\r\\n \\\"alert\\\": \\\"0\\\",\\r\\n \\\"expr\\\": \\\"up{endpoint!=\\'\\'}>-1\\\",\\r\\n \\\"for\\\": \\\"30s\\\",\\r\\n \\\"annotations\\\": {\\r\\n \\\"summary\\\": \\\"{{$value}}\\\"\\r\\n }\\r\\n }, \\r\\n </#if>\\r\\n <#list ruleList as rule>\\r\\n {\\r\\n \\\"alert\\\": ${rule.id?c},\\r\\n \\\"expr\\\": \\\"(${rule.expr})${rule.operator}${rule.threshold}\\\",\\r\\n \\\"for\\\": \\\"${rule.last}s\\\",\\r\\n \\\"labels\\\": {\\r\\n \\\"severity\\\": \\\"${rule.severity_name}\\\",\\r\\n \\\"severity_id\\\": ${rule.severity_id?c}\\r\\n },\\r\\n \\\"annotations\\\": {\\r\\n \\\"summary\\\": <#if rule.summary?default(\\\"\\\")?trim?length gt 1>\\r\\n \\\"${rule.summary}\\\",\\r\\n <#else>\\\"\\\",</#if>\\r\\n \\\"description\\\": <#if rule.description?default(\\\"\\\")?trim?length gt 1>\\r\\n \\\"${rule.description}\\\"\\r\\n <#else>\\\"\\\"</#if>\\r\\n \\r\\n }\\r\\n }\\r\\n <#sep>,</#sep>\\r\\n </#list>]\\r\\n }]\\r\\n}', 1, 'prometheus rule文件模板');\r\n"
+ + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('prom_yml_tmpl', '{\\r\\n \\\"global\\\": {\\r\\n \\\"scrape_interval\\\": \\\"${scrape_interval}s\\\",\\r\\n \\\"scrape_timeout\\\": <#if scrape_timeout??> \\r\\n \\\"${scrape_timeout}s\\\",\\r\\n <#else>\\r\\n \\\"10s\\\",\\r\\n </#if>\\r\\n \\\"evaluation_interval\\\": \\\"${scrape_interval}s\\\"\\r\\n },\\r\\n \\r\\n <#-- alert 配置 -->\\r\\n <#if isAlert>\\r\\n \\\"alerting\\\": {\\r\\n \\\"alertmanagers\\\": [{\\r\\n \\\"path_prefix\\\": \\\"${path_prefix}\\\",\\r\\n \\\"static_configs\\\": [{\\r\\n \\\"targets\\\": [\\\"${alert_url}\\\"]\\r\\n }]\\r\\n }],\\r\\n \\\"alert_relabel_configs\\\": [{\\r\\n \\\"regex\\\": \\\"instance\\\",\\r\\n \\\"action\\\": \\\"labeldrop\\\"\\r\\n }, {\\r\\n \\\"regex\\\": \\\"replica\\\",\\r\\n \\\"action\\\": \\\"labeldrop\\\"\\r\\n }]\\r\\n },\\r\\n \\\"rule_files\\\": [\\\"rule.yml\\\"],\\r\\n </#if>\\r\\n \\r\\n \\r\\n \\r\\n <#-- per-datacenter 配置 -->\\r\\n <#if !isGlobal>\\r\\n \\\"scrape_configs\\\": [\\r\\n <#list endpointList as endpoint>\\r\\n {\\r\\n \\\"job_name\\\": ${endpoint.id?c},\\r\\n \\\"metrics_path\\\": <#if endpoint.config.metrics_path?default(\\\"\\\")?trim?length gt 0>\\r\\n \\\"${endpoint.config.metrics_path}\\\",\\r\\n <#else>\\r\\n \\\"/metrics\\\",\\r\\n </#if>\\r\\n \\\"scrape_interval\\\": <#if endpoint.config.scrape_interval?default(\\\"\\\")?trim?length gt 0>\\r\\n \\\"${endpoint.config.scrape_interval}s\\\",\\r\\n <#else>\\r\\n \\\"${scrape_interval}s\\\",\\r\\n </#if>\\r\\n \\\"scrape_timeout\\\": <#if endpoint.config.scrape_timeout?default(\\\"\\\")?trim?length gt 0>\\r\\n \\\"${endpoint.config.scrape_timeout}s\\\",\\r\\n <#else>\\r\\n <#if scrape_timeout??> \\r\\n \\\"${scrape_timeout}s\\\",\\r\\n <#else>\\r\\n \\\"10s\\\",\\r\\n </#if>\\r\\n </#if>\\r\\n\\r\\n\\r\\n\\r\\n <#if endpoint.config.basic_auth??&& (endpoint.config.basic_auth?size >0)>\\r\\n <#if endpoint.config.basic_auth.username?default(\\\"\\\")?trim?length gt 0 && endpoint.config.basic_auth.password?default(\\\"\\\")?trim?length gt 0>\\r\\n \\\"basic_auth\\\":{\\r\\n \\\"username\\\": \\\"${endpoint.config.basic_auth.username}\\\",\\r\\n \\\"password\\\": \\\"${endpoint.config.basic_auth.password}\\\"\\r\\n },\\r\\n </#if>\\r\\n </#if>\\r\\n \\r\\n \\r\\n <#if endpoint.config.bearer_token??&&endpoint.config.bearer_token?trim?length gt 0>\\r\\n \\\"authorization\\\":{\\r\\n \\\"type\\\":\\\"Bearer\\\",\\r\\n \\\"credentials\\\":\\\"${endpoint.config.bearer_token}\\\"\\r\\n },\\r\\n </#if>\\r\\n\\r\\n \\r\\n <#-- params 不为空且类型为 http ,添加 params -->\\r\\n <#if endpoint.config.params??&& (endpoint.config.params?size >0) && endpoint.module.type == \\\"http\\\">\\r\\n \\\"params\\\":{\\r\\n <#list endpoint.config.params?keys as itemKey>\\r\\n \\\"${itemKey}\\\":[\\r\\n <#list endpoint.config.params[itemKey] as pojo>\\r\\n \\\"${pojo}\\\"\\r\\n <#sep>,</#sep>\\r\\n </#list>\\r\\n ]\\r\\n <#sep>,</#sep>\\r\\n </#list>\\r\\n },\\r\\n <#elseif endpoint.module.type == \\\"snmp\\\">\\r\\n <#-- 类型是 snmp ,组织 param 数据 , 原来params弃用,因为 snmp_exporter 不支持其他参数 -->\\r\\n \\\"params\\\":{\\r\\n \\\"target\\\":[ \\\"${endpoint.config.host}:${endpoint.config.port?c}\\\" ],\\r\\n \\\"module\\\":[ \\\"${endpoint.module.name}\\\" ]\\r\\n },\\r\\n </#if>\\r\\n \\r\\n \\\"static_configs\\\": [{\\r\\n \\\"targets\\\": [<#if endpoint.module.type == \\\"http\\\">\\r\\n \\\"${endpoint.config.host}:${endpoint.config.port?c}\\\"\\r\\n <#else>\\r\\n \\\"127.0.0.1:9116\\\"\\r\\n </#if>\\r\\n ],\\r\\n \\\"labels\\\": {\\r\\n \\\"datacenter\\\": \\\"${endpoint.dc.name}\\\",\\r\\n \\\"datacenter_id\\\":${endpoint.dc.id?c},\\r\\n \\r\\n \\\"project\\\": \\\"${endpoint.project.name}\\\",\\r\\n \\\"project_id\\\": ${endpoint.project.id?c},\\r\\n \\r\\n \\\"asset\\\": \\\"${endpoint.asset.name}\\\",\\r\\n \\\"asset_id\\\": ${endpoint.asset.id?c},\\r\\n \\r\\n \\\"module\\\": \\\"${endpoint.module.name}\\\",\\r\\n \\\"module_id\\\": ${endpoint.module.id?c},\\r\\n \\r\\n \\\"endpoint\\\": \\\"${endpoint.name}\\\",\\r\\n \\\"endpoint_id\\\": ${endpoint.id?c},\\r\\n \\r\\n \\\"nz_agent_id\\\": ${endpoint.promserver.id?c}\\r\\n \\r\\n \\r\\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\\r\\n ,\\r\\n </#if>\\r\\n <#-- 补充用户自定义 Labels -->\\r\\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\\r\\n <#list endpoint.config.labels?keys as key>\\r\\n <#if key != \\\"datacenter\\\" && key != \\\"datacenter_id\\\" && key != \\\"project\\\" && key != \\\"project_id\\\" && key != \\\"asset\\\" && key != \\\"asset_id\\\" && key != \\\"module\\\" && key != \\\"module_id\\\" && key != \\\"endpoint\\\" && key != \\\"endpoint_id\\\">\\r\\n \\\"${key}\\\":\\\"${endpoint.config.labels[key]}\\\"<#sep>,</#sep>\\r\\n </#if>\\r\\n </#list>\\r\\n </#if>\\r\\n }\\r\\n }],\\r\\n \\\"relabel_configs\\\": [\\r\\n {\\r\\n \\\"regex\\\": \\\"instance\\\",\\r\\n \\\"action\\\": \\\"labeldrop\\\"\\r\\n },\\r\\n {\\r\\n \\\"regex\\\": \\\"job\\\",\\r\\n \\\"action\\\": \\\"labeldrop\\\"\\r\\n }\\r\\n ],\\r\\n \\\"metric_relabel_configs\\\": [\\r\\n {\\r\\n \\\"regex\\\": \\\"instance\\\",\\r\\n \\\"action\\\": \\\"labeldrop\\\"\\r\\n }\\r\\n ]\\r\\n }\\r\\n <#sep>,</#sep>\\r\\n </#list>\\r\\n \\r\\n <#-- ping 配置 -->\\r\\n \\r\\n <#if endpointList??&&(endpointList?size>0)>\\r\\n ,\\r\\n </#if>\\r\\n \\r\\n <#list assetList as asset>\\r\\n {\\r\\n \\\"job_name\\\": \\\"asset_ping_${asset.id?c}\\\",\\r\\n \\\"metrics_path\\\": \\\"/probe\\\",\\r\\n \\\"scrape_interval\\\": <#if asset.assetPingInterval?default(\\\"\\\")?trim?length gt 0>\\r\\n \\\"${asset.assetPingInterval}s\\\",\\r\\n <#else>\\r\\n \\\"${scrape_interval}s\\\",\\r\\n </#if>\\r\\n \\\"scrape_timeout\\\": <#if asset.scrape_timeout?default(\\\"\\\")?trim?length gt 0>\\r\\n \\\"${asset.scrape_timeout}s\\\",\\r\\n <#else>\\r\\n <#if scrape_timeout??> \\r\\n \\\"${scrape_timeout}s\\\",\\r\\n <#else>\\r\\n \\\"10s\\\",\\r\\n </#if>\\r\\n </#if>\\r\\n \\\"params\\\": {\\r\\n \\\"target\\\":[ \\\"${asset.manageIp}\\\" ],\\r\\n \\\"module\\\":[ \\\"ping\\\" ]\\r\\n },\\r\\n \\\"static_configs\\\": [{\\r\\n \\\"targets\\\": [\\\"127.0.0.1:9115\\\"],\\r\\n \\\"labels\\\": {\\r\\n \\\"datacenter\\\": \\\"${asset.dc.name}\\\",\\r\\n \\\"host\\\": \\\"${asset.manageIp}\\\",\\r\\n \\\"module\\\": \\\"ping\\\",\\r\\n \\\"source_ip\\\": \\\"${asset.promserver.host}\\\",\\r\\n \\\"nz_agent_id\\\": ${asset.promserver.id?c}\\r\\n }\\r\\n }],\\r\\n \\\"relabel_configs\\\": [\\r\\n {\\r\\n \\\"regex\\\": \\\"instance\\\",\\r\\n \\\"action\\\": \\\"labeldrop\\\"\\r\\n }\\r\\n ],\\r\\n \\\"metric_relabel_configs\\\": [\\r\\n {\\r\\n \\\"regex\\\": \\\"instance\\\",\\r\\n \\\"action\\\": \\\"labeldrop\\\"\\r\\n }\\r\\n ]\\r\\n }\\r\\n <#sep>,</#sep>\\r\\n </#list>\\r\\n ]\\r\\n <#else>\\r\\n <#-- global 配置 -->\\r\\n \\\"scrape_configs\\\": [\\r\\n <#list jobList as jobPojo>\\r\\n {\\r\\n \\\"job_name\\\": \\\"${jobPojo.job_name}\\\",\\r\\n <#if jobPojo.isFederate> \\r\\n \\\"honor_labels\\\": ${jobPojo.honor_labels},\\r\\n \\\"params\\\": {\\r\\n \\\"match[]\\\": [\\r\\n <#-- 开启联邦 -->\\r\\n <#if jobPojo.fedeEnabled>\\r\\n <#if jobPojo.scrapePing> \\r\\n \\\"{job=~\\\\\\\"asset_ping_.+\\\\\\\",nz_agent_id != \\\\\\\"${jobPojo.excludeAgentId}\\\\\\\"}\\\"\\r\\n <#else>\\r\\n \\\"{__name__=~\\\\\\\".+\\\\\\\",nz_agent_id != \\\\\\\"${jobPojo.excludeAgentId}\\\\\\\"}\\\"\\r\\n </#if>\\r\\n <#else>\\r\\n <#-- 联邦关闭,抓取所有指标即可 -->\\r\\n \\\"{__name__=~\\\\\\\".+\\\\\\\",nz_agent_id != \\\\\\\"${jobPojo.excludeAgentId}\\\\\\\"}\\\"\\r\\n </#if>\\r\\n ]\\r\\n },\\r\\n \\\"authorization\\\":{\\r\\n \\\"type\\\":\\\"Bearer\\\",\\r\\n \\\"credentials\\\":\\\"${jobPojo.token}\\\"\\r\\n },\\r\\n </#if>\\r\\n \\\"metrics_path\\\": <#if jobPojo.metrics_path?default(\\\"\\\")?trim?length gt 0>\\r\\n \\\"${jobPojo.metrics_path}\\\",\\r\\n <#else>\\r\\n \\\"/metrics\\\",\\r\\n </#if>\\r\\n \\\"static_configs\\\":[\\r\\n <#list jobPojo.staticConfigList as staticConf >\\r\\n {\\r\\n \\\"targets\\\": [\\r\\n <#list staticConf.targets as targetConf>\\r\\n \\\"${targetConf}\\\"<#sep>,</#sep>\\r\\n </#list>\\r\\n ]\\r\\n <#if staticConf.labels ??&& (staticConf.labels?size >0)>\\r\\n ,\\r\\n \\\"labels\\\": {\\r\\n <#list staticConf.labels?keys as itemKey>\\r\\n \\\"${itemKey}\\\":<#if staticConf.labels[itemKey]?default(\\\"\\\")?trim?length gt 0>\\r\\n \\\"${staticConf.labels[itemKey]}\\\"\\r\\n <#else>\\\"\\\"</#if><#sep>,</#sep>\\r\\n </#list>\\r\\n } \\r\\n </#if>\\r\\n }<#sep>,</#sep>\\r\\n </#list>\\r\\n ],\\r\\n \\\"relabel_configs\\\": [\\r\\n {\\r\\n \\\"regex\\\": \\\"job\\\",\\r\\n \\\"action\\\": \\\"labeldrop\\\"\\r\\n }\\r\\n <#if jobPojo.instanceRelabel> \\r\\n ,\\r\\n {\\r\\n \\\"regex\\\": \\\"instance\\\",\\r\\n \\\"action\\\": \\\"labeldrop\\\"\\r\\n }\\r\\n </#if>\\r\\n ],\\r\\n \\\"metric_relabel_configs\\\": [\\r\\n {\\r\\n \\\"regex\\\": \\\"instance\\\",\\r\\n \\\"action\\\": \\\"labeldrop\\\"\\r\\n }\\r\\n ]\\r\\n }<#sep>,</#sep>\\r\\n </#list>\\r\\n \\r\\n <#-- ping 配置 -->\\r\\n \\r\\n <#if jobList??&&(jobList?size>0)>\\r\\n ,\\r\\n </#if>\\r\\n \\r\\n <#list assetList as asset>\\r\\n {\\r\\n \\\"job_name\\\": \\\"asset_ping_${asset.id?c}\\\",\\r\\n \\\"metrics_path\\\": \\\"/probe\\\",\\r\\n \\\"scrape_interval\\\": <#if asset.assetPingInterval?default(\\\"\\\")?trim?length gt 0>\\r\\n \\\"${asset.assetPingInterval}s\\\",\\r\\n <#else>\\r\\n \\\"${scrape_interval}s\\\",\\r\\n </#if>\\r\\n \\\"scrape_timeout\\\": <#if asset.scrape_timeout?default(\\\"\\\")?trim?length gt 0>\\r\\n \\\"${asset.scrape_timeout}s\\\",\\r\\n <#else>\\r\\n <#if scrape_timeout??> \\r\\n \\\"${scrape_timeout}s\\\",\\r\\n <#else>\\r\\n \\\"10s\\\",\\r\\n </#if>\\r\\n </#if>\\r\\n \\\"params\\\": {\\r\\n \\\"target\\\":[ \\\"${asset.manageIp}\\\" ],\\r\\n \\\"module\\\":[ \\\"ping\\\" ]\\r\\n },\\r\\n \\\"static_configs\\\": [{\\r\\n \\\"targets\\\": [\\\"127.0.0.1:9115\\\"],\\r\\n \\\"labels\\\": {\\r\\n \\\"datacenter\\\": \\\"${asset.dc.name}\\\",\\r\\n \\\"host\\\": \\\"${asset.manageIp}\\\",\\r\\n \\\"module\\\": \\\"ping\\\",\\r\\n \\\"source_ip\\\": \\\"${asset.promserver.host}\\\",\\r\\n \\\"nz_agent_id\\\": ${asset.promserver.id?c}\\r\\n }\\r\\n }],\\r\\n \\\"relabel_configs\\\": [\\r\\n {\\r\\n \\\"regex\\\": \\\"instance\\\",\\r\\n \\\"action\\\": \\\"labeldrop\\\"\\r\\n }\\r\\n ],\\r\\n \\\"metric_relabel_configs\\\": [\\r\\n {\\r\\n \\\"regex\\\": \\\"instance\\\",\\r\\n \\\"action\\\": \\\"labeldrop\\\"\\r\\n }\\r\\n ]\\r\\n }\\r\\n <#sep>,</#sep>\\r\\n </#list>\\r\\n \\r\\n \\r\\n <#if ( jobList??&&(jobList?size>0)) || assetList??&&(assetList?size>0)>\\r\\n ,\\r\\n </#if>\\r\\n \\r\\n <#list endpointList as endpoint>\\r\\n {\\r\\n \\\"job_name\\\": ${endpoint.id?c},\\r\\n \\\"metrics_path\\\": <#if endpoint.config.metrics_path?default(\\\"\\\")?trim?length gt 0>\\r\\n \\\"${endpoint.config.metrics_path}\\\",\\r\\n <#else>\\r\\n \\\"/metrics\\\",\\r\\n </#if>\\r\\n \\\"scrape_interval\\\": <#if endpoint.config.scrape_interval?default(\\\"\\\")?trim?length gt 0>\\r\\n \\\"${endpoint.config.scrape_interval}s\\\",\\r\\n <#else>\\r\\n \\\"${scrape_interval}s\\\",\\r\\n </#if>\\r\\n \\\"scrape_timeout\\\": <#if endpoint.config.scrape_timeout?default(\\\"\\\")?trim?length gt 0>\\r\\n \\\"${endpoint.config.scrape_timeout}s\\\",\\r\\n <#else>\\r\\n <#if scrape_timeout??> \\r\\n \\\"${scrape_timeout}s\\\",\\r\\n <#else>\\r\\n \\\"10s\\\",\\r\\n </#if>\\r\\n </#if>\\r\\n\\r\\n\\r\\n\\r\\n <#if endpoint.config.basic_auth??&& (endpoint.config.basic_auth?size >0)>\\r\\n <#if endpoint.config.basic_auth.username?default(\\\"\\\")?trim?length gt 0 && endpoint.config.basic_auth.password?default(\\\"\\\")?trim?length gt 0>\\r\\n \\\"basic_auth\\\":{\\r\\n \\\"username\\\": \\\"${endpoint.config.basic_auth.username}\\\",\\r\\n \\\"password\\\": \\\"${endpoint.config.basic_auth.password}\\\"\\r\\n },\\r\\n </#if>\\r\\n </#if>\\r\\n \\r\\n \\r\\n <#if endpoint.config.bearer_token??&&endpoint.config.bearer_token?trim?length gt 0>\\r\\n \\\"authorization\\\":{\\r\\n \\\"type\\\":\\\"Bearer\\\",\\r\\n \\\"credentials\\\":\\\"${endpoint.config.bearer_token}\\\"\\r\\n },\\r\\n </#if>\\r\\n\\r\\n \\r\\n <#-- params 不为空且类型为 http ,添加 params -->\\r\\n <#if endpoint.config.params??&& (endpoint.config.params?size >0) && endpoint.module.type == \\\"http\\\">\\r\\n \\\"params\\\":{\\r\\n <#list endpoint.config.params?keys as itemKey>\\r\\n \\\"${itemKey}\\\":[\\r\\n <#list endpoint.config.params[itemKey] as pojo>\\r\\n \\\"${pojo}\\\"\\r\\n <#sep>,</#sep>\\r\\n </#list>\\r\\n ]\\r\\n <#sep>,</#sep>\\r\\n </#list>\\r\\n },\\r\\n <#elseif endpoint.module.type == \\\"snmp\\\">\\r\\n <#-- 类型是 snmp ,组织 param 数据 , 原来params弃用,因为 snmp_exporter 不支持其他参数 -->\\r\\n \\\"params\\\":{\\r\\n \\\"target\\\":[ \\\"${endpoint.config.host}:${endpoint.config.port?c}\\\" ],\\r\\n \\\"module\\\":[ \\\"${endpoint.module.name}\\\" ]\\r\\n },\\r\\n </#if>\\r\\n \\r\\n \\\"static_configs\\\": [{\\r\\n \\\"targets\\\": [<#if endpoint.module.type == \\\"http\\\">\\r\\n \\\"${endpoint.config.host}:${endpoint.config.port?c}\\\"\\r\\n <#else>\\r\\n \\\"127.0.0.1:9116\\\"\\r\\n </#if>\\r\\n ],\\r\\n \\\"labels\\\": {\\r\\n \\\"datacenter\\\": \\\"${endpoint.dc.name}\\\",\\r\\n \\\"datacenter_id\\\":${endpoint.dc.id?c},\\r\\n \\r\\n \\\"project\\\": \\\"${endpoint.project.name}\\\",\\r\\n \\\"project_id\\\": ${endpoint.project.id?c},\\r\\n \\r\\n \\\"asset\\\": \\\"${endpoint.asset.name}\\\",\\r\\n \\\"asset_id\\\": ${endpoint.asset.id?c},\\r\\n \\r\\n \\\"module\\\": \\\"${endpoint.module.name}\\\",\\r\\n \\\"module_id\\\": ${endpoint.module.id?c},\\r\\n \\r\\n \\\"endpoint\\\": \\\"${endpoint.name}\\\",\\r\\n \\\"endpoint_id\\\": ${endpoint.id?c},\\r\\n \\r\\n \\\"nz_agent_id\\\": ${endpoint.promserver.id?c}\\r\\n \\r\\n \\r\\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\\r\\n ,\\r\\n </#if>\\r\\n <#-- 补充用户自定义 Labels -->\\r\\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\\r\\n <#list endpoint.config.labels?keys as key>\\r\\n <#if key != \\\"datacenter\\\" && key != \\\"datacenter_id\\\" && key != \\\"project\\\" && key != \\\"project_id\\\" && key != \\\"asset\\\" && key != \\\"asset_id\\\" && key != \\\"module\\\" && key != \\\"module_id\\\" && key != \\\"endpoint\\\" && key != \\\"endpoint_id\\\">\\r\\n \\\"${key}\\\":\\\"${endpoint.config.labels[key]}\\\"<#sep>,</#sep>\\r\\n </#if>\\r\\n </#list>\\r\\n </#if>\\r\\n }\\r\\n }],\\r\\n \\\"relabel_configs\\\": [\\r\\n {\\r\\n \\\"regex\\\": \\\"instance\\\",\\r\\n \\\"action\\\": \\\"labeldrop\\\"\\r\\n },\\r\\n {\\r\\n \\\"regex\\\": \\\"job\\\",\\r\\n \\\"action\\\": \\\"labeldrop\\\"\\r\\n }\\r\\n ],\\r\\n \\\"metric_relabel_configs\\\": [\\r\\n {\\r\\n \\\"regex\\\": \\\"instance\\\",\\r\\n \\\"action\\\": \\\"labeldrop\\\"\\r\\n }\\r\\n ]\\r\\n }\\r\\n <#sep>,</#sep>\\r\\n </#list>\\r\\n \\r\\n ]\\r\\n </#if>\\r\\n}', 1, 'prometheus config文件模板');\r\n"
+ + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('session_timeout', '30', 1, '默认:30,不小于 15 单位:minute');\r\n"
+ + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('system_logo', '', 1, NULL);\r\n"
+ + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('unsaved_change', 'on', 1, '未保存提示开关');\r\n"
+ + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('terminal_record_local_retention', '365', 1, '默认:365,单位:天,record数据保留天数');\r\n"
+ + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('terminal_telnet_pin_tip', 'assword:', 1, '默认:assword:');\r\n"
+ + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('terminal_telnet_user_tip', 'ogin:', 1, '默认:ogin:');\r\n"
+ + "INSERT INTO `sys_config`(`param_key`, `param_value`, `status`, `remark`) VALUES ('terminal_timeout', '30', 1, '默认:30,单位:minute');\r\n"
+ + "update sys_config set param_key =\"default_scrape_interval\" where param_key=\"scrape_interval\";\r\n"
+ + "update sys_config set param_key =\"default_scrape_timeout\" where param_key=\"scrape_timeout\";\r\n"
+ );
+ // 修改sys_user表数据 初始化name字段内容
+ sb.append("update sys_user set name = username;");
+ sqlDao.execute(sb.toString());
+ // asset_brand表数据单独处理
+ assetBrandService.handler();
+ // asset_model表数据处理 前提先处理好brand表数据信息
+ assetModelService.handler();
+ }
+
+ public void transferData() {
+ // dc数据同步
+ dcService.handler();
+ // 资产数据同步 snmp认证表数据同步 tag相关数据同步
+ assetAssetService.handler();
+
+ // 告警相关数据同步
+ alertMessageService.handler();
+
+ // project module endpoint 数据同步
+ endpointService.handler();
+
+ // 图表相关数据同步
+ chartService.handler();
+
+ }
+}
diff --git a/src/main/java/com/nis/handler/TransferDataHandler.java b/src/main/java/com/nis/handler/TransferDataHandler.java
new file mode 100644
index 0000000..1b5df6b
--- /dev/null
+++ b/src/main/java/com/nis/handler/TransferDataHandler.java
@@ -0,0 +1,41 @@
+package com.nis.handler;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.context.annotation.DependsOn;
+import org.springframework.core.annotation.Order;
+import org.springframework.stereotype.Component;
+import com.nis.service.AssetService;
+
+import cn.hutool.log.Log;
+
+/**
+ * 此类用于数据库的数据处理操作
+ * @author admin
+ *
+ */
+@Component
+@Order(2)
+public class TransferDataHandler implements CommandLineRunner {
+
+ private Log log = Log.get();
+
+ @Autowired
+ private SqlHandler sqlHandler;
+
+ @Override
+ public void run(String... args) throws Exception {
+
+ // 数据同步前相关新增表数据初始化
+ sqlHandler.initData();
+ log.info("init data successful");
+
+ // 新旧表数据同步
+ sqlHandler.transferData();
+ log.info("transfer data successful");
+
+ // 表清空数据
+ sqlHandler.removeData();
+ log.info("remove data successful");
+ }
+}
diff --git a/src/main/java/com/nis/service/AccountService.java b/src/main/java/com/nis/service/AccountService.java
new file mode 100644
index 0000000..39c1804
--- /dev/null
+++ b/src/main/java/com/nis/service/AccountService.java
@@ -0,0 +1,10 @@
+package com.nis.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.nis.entity.Account;
+import com.nis.entity.Asset;
+
+public interface AccountService extends IService<Account> {
+
+
+} \ No newline at end of file
diff --git a/src/main/java/com/nis/service/AlertMessageActiveService.java b/src/main/java/com/nis/service/AlertMessageActiveService.java
new file mode 100644
index 0000000..e1d2175
--- /dev/null
+++ b/src/main/java/com/nis/service/AlertMessageActiveService.java
@@ -0,0 +1,14 @@
+package com.nis.service;
+
+import java.util.List;
+import java.util.Map;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.nis.entity.AlertMessageActiveEntity;
+import com.nis.entity.AlertMessageEntity;
+
+
+public interface AlertMessageActiveService extends IService<AlertMessageActiveEntity> {
+
+
+}
+
diff --git a/src/main/java/com/nis/service/AlertMessageHistoryService.java b/src/main/java/com/nis/service/AlertMessageHistoryService.java
new file mode 100644
index 0000000..9a9461b
--- /dev/null
+++ b/src/main/java/com/nis/service/AlertMessageHistoryService.java
@@ -0,0 +1,14 @@
+package com.nis.service;
+
+import java.util.List;
+import java.util.Map;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.nis.entity.AlertMessageEntity;
+import com.nis.entity.AlertMessageHistoryEntity;
+
+
+
+public interface AlertMessageHistoryService extends IService<AlertMessageHistoryEntity> {
+
+}
+
diff --git a/src/main/java/com/nis/service/AlertMessageService.java b/src/main/java/com/nis/service/AlertMessageService.java
new file mode 100644
index 0000000..7d1d1eb
--- /dev/null
+++ b/src/main/java/com/nis/service/AlertMessageService.java
@@ -0,0 +1,14 @@
+package com.nis.service;
+
+import java.util.List;
+import java.util.Map;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.nis.entity.AlertMessageEntity;
+
+
+
+public interface AlertMessageService extends IService<AlertMessageEntity> {
+
+ public void handler();
+}
+
diff --git a/src/main/java/com/nis/service/AlertRuleService.java b/src/main/java/com/nis/service/AlertRuleService.java
new file mode 100644
index 0000000..03e3fb9
--- /dev/null
+++ b/src/main/java/com/nis/service/AlertRuleService.java
@@ -0,0 +1,15 @@
+package com.nis.service;
+
+import java.util.List;
+import java.util.Map;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.nis.entity.AlertMessageEntity;
+import com.nis.entity.AlertMessageHistoryEntity;
+import com.nis.entity.AlertRuleEntity;
+
+
+
+public interface AlertRuleService extends IService<AlertRuleEntity> {
+
+}
+
diff --git a/src/main/java/com/nis/service/AssetAssetService.java b/src/main/java/com/nis/service/AssetAssetService.java
new file mode 100644
index 0000000..dd138ef
--- /dev/null
+++ b/src/main/java/com/nis/service/AssetAssetService.java
@@ -0,0 +1,12 @@
+package com.nis.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.nis.entity.AssetAsset;
+
+/**
+ * 资产 service
+ */
+public interface AssetAssetService extends IService<AssetAsset> {
+
+ public void handler();
+} \ No newline at end of file
diff --git a/src/main/java/com/nis/service/AssetBrandService.java b/src/main/java/com/nis/service/AssetBrandService.java
new file mode 100644
index 0000000..d15c9a2
--- /dev/null
+++ b/src/main/java/com/nis/service/AssetBrandService.java
@@ -0,0 +1,12 @@
+package com.nis.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.nis.entity.AssetBrand;
+
+/**
+ * 资产品牌 service
+ */
+public interface AssetBrandService extends IService<AssetBrand> {
+
+ public void handler();
+} \ No newline at end of file
diff --git a/src/main/java/com/nis/service/AssetFieldMetaService.java b/src/main/java/com/nis/service/AssetFieldMetaService.java
new file mode 100644
index 0000000..deed0eb
--- /dev/null
+++ b/src/main/java/com/nis/service/AssetFieldMetaService.java
@@ -0,0 +1,12 @@
+package com.nis.service;
+
+import java.util.List;
+import java.util.Map;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.nis.entity.AssetFieldMeta;
+
+
+public interface AssetFieldMetaService extends IService<AssetFieldMeta>{
+
+}
diff --git a/src/main/java/com/nis/service/AssetFieldValueService.java b/src/main/java/com/nis/service/AssetFieldValueService.java
new file mode 100644
index 0000000..9e3a7aa
--- /dev/null
+++ b/src/main/java/com/nis/service/AssetFieldValueService.java
@@ -0,0 +1,8 @@
+package com.nis.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.nis.entity.AssetFieldValue;
+
+public interface AssetFieldValueService extends IService<AssetFieldValue>{
+
+}
diff --git a/src/main/java/com/nis/service/AssetModelService.java b/src/main/java/com/nis/service/AssetModelService.java
new file mode 100644
index 0000000..3d3ee2e
--- /dev/null
+++ b/src/main/java/com/nis/service/AssetModelService.java
@@ -0,0 +1,13 @@
+package com.nis.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.nis.entity.AssetModel;
+
+/**
+ * 资产类型 service
+ */
+public interface AssetModelService extends IService<AssetModel> {
+
+ public void handler();
+
+} \ No newline at end of file
diff --git a/src/main/java/com/nis/service/AssetService.java b/src/main/java/com/nis/service/AssetService.java
new file mode 100644
index 0000000..620ee98
--- /dev/null
+++ b/src/main/java/com/nis/service/AssetService.java
@@ -0,0 +1,8 @@
+package com.nis.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.nis.entity.Asset;
+
+public interface AssetService extends IService<Asset> {
+
+} \ No newline at end of file
diff --git a/src/main/java/com/nis/service/AssetTagService.java b/src/main/java/com/nis/service/AssetTagService.java
new file mode 100644
index 0000000..136c410
--- /dev/null
+++ b/src/main/java/com/nis/service/AssetTagService.java
@@ -0,0 +1,10 @@
+package com.nis.service;
+
+import java.util.List;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.nis.entity.AssetTag;
+
+public interface AssetTagService extends IService<AssetTag> {
+
+}
diff --git a/src/main/java/com/nis/service/AssetTypeConfService.java b/src/main/java/com/nis/service/AssetTypeConfService.java
new file mode 100644
index 0000000..d93d719
--- /dev/null
+++ b/src/main/java/com/nis/service/AssetTypeConfService.java
@@ -0,0 +1,10 @@
+package com.nis.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.nis.entity.AssetTypeConf;
+
+
+public interface AssetTypeConfService extends IService<AssetTypeConf> {
+
+
+} \ No newline at end of file
diff --git a/src/main/java/com/nis/service/ChartElementService.java b/src/main/java/com/nis/service/ChartElementService.java
new file mode 100644
index 0000000..4ec6a37
--- /dev/null
+++ b/src/main/java/com/nis/service/ChartElementService.java
@@ -0,0 +1,12 @@
+package com.nis.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.nis.entity.ChartElement;
+import com.nis.entity.Dc;
+import com.nis.entity.Idc;
+import com.nis.entity.Module;
+
+
+public interface ChartElementService extends IService<ChartElement> {
+
+} \ No newline at end of file
diff --git a/src/main/java/com/nis/service/ChartService.java b/src/main/java/com/nis/service/ChartService.java
new file mode 100644
index 0000000..db313a9
--- /dev/null
+++ b/src/main/java/com/nis/service/ChartService.java
@@ -0,0 +1,14 @@
+package com.nis.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.nis.entity.Chart;
+import com.nis.entity.Dc;
+import com.nis.entity.Idc;
+import com.nis.entity.Module;
+
+
+public interface ChartService extends IService<Chart> {
+
+ public void handler();
+
+} \ No newline at end of file
diff --git a/src/main/java/com/nis/service/DcService.java b/src/main/java/com/nis/service/DcService.java
new file mode 100644
index 0000000..61093eb
--- /dev/null
+++ b/src/main/java/com/nis/service/DcService.java
@@ -0,0 +1,13 @@
+package com.nis.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.nis.entity.Asset;
+import com.nis.entity.Dc;
+
+/**
+ * 资产 service
+ */
+public interface DcService extends IService<Dc> {
+
+ public void handler();
+} \ No newline at end of file
diff --git a/src/main/java/com/nis/service/EndpointService.java b/src/main/java/com/nis/service/EndpointService.java
new file mode 100644
index 0000000..174b762
--- /dev/null
+++ b/src/main/java/com/nis/service/EndpointService.java
@@ -0,0 +1,13 @@
+package com.nis.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.nis.entity.Dc;
+import com.nis.entity.Endpoint;
+import com.nis.entity.Idc;
+
+
+public interface EndpointService extends IService<Endpoint> {
+
+ public void handler();
+
+} \ No newline at end of file
diff --git a/src/main/java/com/nis/service/IdcService.java b/src/main/java/com/nis/service/IdcService.java
new file mode 100644
index 0000000..3390e5d
--- /dev/null
+++ b/src/main/java/com/nis/service/IdcService.java
@@ -0,0 +1,10 @@
+package com.nis.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.nis.entity.Dc;
+import com.nis.entity.Idc;
+
+
+public interface IdcService extends IService<Idc> {
+
+} \ No newline at end of file
diff --git a/src/main/java/com/nis/service/ModelService.java b/src/main/java/com/nis/service/ModelService.java
new file mode 100644
index 0000000..b105a35
--- /dev/null
+++ b/src/main/java/com/nis/service/ModelService.java
@@ -0,0 +1,11 @@
+package com.nis.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.nis.entity.Model;
+
+import java.util.Map;
+
+public interface ModelService extends IService<Model> {
+
+}
+
diff --git a/src/main/java/com/nis/service/ModuleService.java b/src/main/java/com/nis/service/ModuleService.java
new file mode 100644
index 0000000..73a9e38
--- /dev/null
+++ b/src/main/java/com/nis/service/ModuleService.java
@@ -0,0 +1,11 @@
+package com.nis.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.nis.entity.Dc;
+import com.nis.entity.Idc;
+import com.nis.entity.Module;
+
+
+public interface ModuleService extends IService<Module> {
+
+} \ No newline at end of file
diff --git a/src/main/java/com/nis/service/MonitorEndpointService.java b/src/main/java/com/nis/service/MonitorEndpointService.java
new file mode 100644
index 0000000..3c55112
--- /dev/null
+++ b/src/main/java/com/nis/service/MonitorEndpointService.java
@@ -0,0 +1,11 @@
+package com.nis.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.nis.entity.Dc;
+import com.nis.entity.Idc;
+import com.nis.entity.MonitorEndpoint;
+
+
+public interface MonitorEndpointService extends IService<MonitorEndpoint> {
+
+} \ No newline at end of file
diff --git a/src/main/java/com/nis/service/MonitorModuleService.java b/src/main/java/com/nis/service/MonitorModuleService.java
new file mode 100644
index 0000000..b2e7d30
--- /dev/null
+++ b/src/main/java/com/nis/service/MonitorModuleService.java
@@ -0,0 +1,11 @@
+package com.nis.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.nis.entity.Dc;
+import com.nis.entity.Idc;
+import com.nis.entity.MonitorModule;
+
+
+public interface MonitorModuleService extends IService<MonitorModule> {
+
+} \ No newline at end of file
diff --git a/src/main/java/com/nis/service/MonitorProjectService.java b/src/main/java/com/nis/service/MonitorProjectService.java
new file mode 100644
index 0000000..1b44756
--- /dev/null
+++ b/src/main/java/com/nis/service/MonitorProjectService.java
@@ -0,0 +1,11 @@
+package com.nis.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.nis.entity.Dc;
+import com.nis.entity.Idc;
+import com.nis.entity.MonitorProject;
+
+
+public interface MonitorProjectService extends IService<MonitorProject> {
+
+} \ No newline at end of file
diff --git a/src/main/java/com/nis/service/PanelService.java b/src/main/java/com/nis/service/PanelService.java
new file mode 100644
index 0000000..ea8e59e
--- /dev/null
+++ b/src/main/java/com/nis/service/PanelService.java
@@ -0,0 +1,12 @@
+package com.nis.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.nis.entity.Dc;
+import com.nis.entity.Idc;
+import com.nis.entity.Module;
+import com.nis.entity.Panel;
+
+
+public interface PanelService extends IService<Panel> {
+
+} \ No newline at end of file
diff --git a/src/main/java/com/nis/service/ProjectService.java b/src/main/java/com/nis/service/ProjectService.java
new file mode 100644
index 0000000..50ed214
--- /dev/null
+++ b/src/main/java/com/nis/service/ProjectService.java
@@ -0,0 +1,11 @@
+package com.nis.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.nis.entity.Dc;
+import com.nis.entity.Idc;
+import com.nis.entity.Project;
+
+
+public interface ProjectService extends IService<Project> {
+
+} \ No newline at end of file
diff --git a/src/main/java/com/nis/service/SnmpCredentialService.java b/src/main/java/com/nis/service/SnmpCredentialService.java
new file mode 100644
index 0000000..5dc6229
--- /dev/null
+++ b/src/main/java/com/nis/service/SnmpCredentialService.java
@@ -0,0 +1,10 @@
+package com.nis.service;
+
+import java.util.Map;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.nis.entity.SnmpCredential;
+
+public interface SnmpCredentialService extends IService<SnmpCredential>{
+
+}
diff --git a/src/main/java/com/nis/service/SysDictService.java b/src/main/java/com/nis/service/SysDictService.java
new file mode 100644
index 0000000..5990bf6
--- /dev/null
+++ b/src/main/java/com/nis/service/SysDictService.java
@@ -0,0 +1,25 @@
+/**
+
+ *
+
+ *
+
+ */
+
+package com.nis.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.nis.entity.SysDictEntity;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 数据字典
+ *
+
+ */
+public interface SysDictService extends IService<SysDictEntity> {
+
+}
+
diff --git a/src/main/java/com/nis/service/VisualChartElementService.java b/src/main/java/com/nis/service/VisualChartElementService.java
new file mode 100644
index 0000000..2001ed1
--- /dev/null
+++ b/src/main/java/com/nis/service/VisualChartElementService.java
@@ -0,0 +1,12 @@
+package com.nis.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.nis.entity.Dc;
+import com.nis.entity.Idc;
+import com.nis.entity.Module;
+import com.nis.entity.VisualChartElement;
+
+
+public interface VisualChartElementService extends IService<VisualChartElement> {
+
+} \ No newline at end of file
diff --git a/src/main/java/com/nis/service/VisualChartService.java b/src/main/java/com/nis/service/VisualChartService.java
new file mode 100644
index 0000000..f5af787
--- /dev/null
+++ b/src/main/java/com/nis/service/VisualChartService.java
@@ -0,0 +1,12 @@
+package com.nis.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.nis.entity.Dc;
+import com.nis.entity.Idc;
+import com.nis.entity.Module;
+import com.nis.entity.VisualChart;
+
+
+public interface VisualChartService extends IService<VisualChart> {
+
+} \ No newline at end of file
diff --git a/src/main/java/com/nis/service/VisualPanelService.java b/src/main/java/com/nis/service/VisualPanelService.java
new file mode 100644
index 0000000..d8551a1
--- /dev/null
+++ b/src/main/java/com/nis/service/VisualPanelService.java
@@ -0,0 +1,12 @@
+package com.nis.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.nis.entity.Dc;
+import com.nis.entity.Idc;
+import com.nis.entity.Module;
+import com.nis.entity.VisualPanel;
+
+
+public interface VisualPanelService extends IService<VisualPanel> {
+
+} \ No newline at end of file
diff --git a/src/main/java/com/nis/service/impl/AccountServiceImpl.java b/src/main/java/com/nis/service/impl/AccountServiceImpl.java
new file mode 100644
index 0000000..ab982bf
--- /dev/null
+++ b/src/main/java/com/nis/service/impl/AccountServiceImpl.java
@@ -0,0 +1,28 @@
+package com.nis.service.impl;
+
+import cn.hutool.log.Log;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.nis.dao.AccountDao;
+import com.nis.dao.AssetDao;
+import com.nis.entity.Account;
+import com.nis.entity.Asset;
+import com.nis.entity.AssetAsset;
+import com.nis.service.AccountService;
+import com.nis.service.AssetAssetService;
+import com.nis.service.AssetService;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+
+/**
+ * 资产 serviceImpl
+ *
+ */
+@Service("accountService")
+public class AccountServiceImpl extends ServiceImpl<AccountDao, Account> implements AccountService {
+ private static Log logger = Log.get();
+
+}
diff --git a/src/main/java/com/nis/service/impl/AlertMessageActiveServiceImpl.java b/src/main/java/com/nis/service/impl/AlertMessageActiveServiceImpl.java
new file mode 100644
index 0000000..f6cfabf
--- /dev/null
+++ b/src/main/java/com/nis/service/impl/AlertMessageActiveServiceImpl.java
@@ -0,0 +1,23 @@
+package com.nis.service.impl;
+
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.nis.dao.AlertMessageActiveDao;
+import com.nis.dao.AlertMessageDao;
+import com.nis.entity.AlertMessageActiveEntity;
+import com.nis.entity.AlertMessageEntity;
+import com.nis.service.AlertMessageActiveService;
+import com.nis.service.AlertMessageService;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+
+
+
+@Service("alertMessageActiveService")
+public class AlertMessageActiveServiceImpl extends ServiceImpl<AlertMessageActiveDao, AlertMessageActiveEntity> implements AlertMessageActiveService {
+
+
+
+}
diff --git a/src/main/java/com/nis/service/impl/AlertMessageHistoryServiceImpl.java b/src/main/java/com/nis/service/impl/AlertMessageHistoryServiceImpl.java
new file mode 100644
index 0000000..3dee934
--- /dev/null
+++ b/src/main/java/com/nis/service/impl/AlertMessageHistoryServiceImpl.java
@@ -0,0 +1,23 @@
+package com.nis.service.impl;
+
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.nis.dao.AlertMessageDao;
+import com.nis.dao.AlertMessageHistoryDao;
+import com.nis.entity.AlertMessageEntity;
+import com.nis.entity.AlertMessageHistoryEntity;
+import com.nis.service.AlertMessageHistoryService;
+import com.nis.service.AlertMessageService;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+
+
+
+@Service("alertMessageHistoryService")
+public class AlertMessageHistoryServiceImpl extends ServiceImpl<AlertMessageHistoryDao, AlertMessageHistoryEntity> implements AlertMessageHistoryService {
+
+
+
+}
diff --git a/src/main/java/com/nis/service/impl/AlertMessageServiceImpl.java b/src/main/java/com/nis/service/impl/AlertMessageServiceImpl.java
new file mode 100644
index 0000000..51af684
--- /dev/null
+++ b/src/main/java/com/nis/service/impl/AlertMessageServiceImpl.java
@@ -0,0 +1,91 @@
+package com.nis.service.impl;
+
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.nis.dao.AlertMessageDao;
+import com.nis.entity.AlertMessageActiveEntity;
+import com.nis.entity.AlertMessageEntity;
+import com.nis.entity.AlertMessageHistoryEntity;
+import com.nis.entity.AlertRuleEntity;
+import com.nis.service.AlertMessageActiveService;
+import com.nis.service.AlertMessageHistoryService;
+import com.nis.service.AlertMessageService;
+import com.nis.service.AlertRuleService;
+import com.nis.util.ToolUtil;
+
+import cn.hutool.core.bean.BeanUtil;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+
+
+
+@Service("alertMessageService")
+public class AlertMessageServiceImpl extends ServiceImpl<AlertMessageDao, AlertMessageEntity> implements AlertMessageService {
+
+ @Autowired
+ private AlertMessageActiveService alertMessageActiveService;
+
+ @Autowired
+ private AlertMessageHistoryService alertMessageHistoryService;
+
+ @Autowired
+ private AlertRuleService alertRuleService;
+
+ @Override
+ public void handler() {
+
+ // alert rule数据修改
+ List<AlertRuleEntity> rules = alertRuleService.list();
+ for(AlertRuleEntity rule : rules) {
+ if(rule.getSeverity().equals("P1")) {
+ rule.setSeverityId(1);
+ }else if(rule.getSeverity().equals("P2")) {
+ rule.setSeverityId(2);
+ }else if(rule.getSeverity().equals("P3")){
+ rule.setSeverityId(3);
+ }
+ rule.setMethod(1);
+ }
+ if(ToolUtil.isNotEmpty(rules)) {
+ alertRuleService.updateBatchById(rules);
+ }
+
+ List<AlertMessageEntity> messages = this.list();
+
+ List<AlertMessageActiveEntity> activeMessages = new ArrayList<AlertMessageActiveEntity>();
+ List<AlertMessageHistoryEntity> historyMessages = new ArrayList<AlertMessageHistoryEntity>();
+
+ for(AlertMessageEntity message : messages) {
+ if(message.getSeverity().equals("P1")) {
+ message.setSeverityId(1);
+ }else if(message.getSeverity().equals("P2")) {
+ message.setSeverityId(2);
+ }else if(message.getSeverity().equals("P3")){
+ message.setSeverityId(3);
+ }
+ if(message.getState().equals(1)) {
+ AlertMessageActiveEntity activeMessage = new AlertMessageActiveEntity();
+ BeanUtil.copyProperties(message, activeMessage);
+ activeMessages.add(activeMessage);
+ }else {
+ AlertMessageHistoryEntity historyMessage = new AlertMessageHistoryEntity();
+ BeanUtil.copyProperties(message, historyMessage);
+ historyMessages.add(historyMessage);
+ }
+ }
+
+ if(ToolUtil.isNotEmpty(activeMessages)) {
+ alertMessageActiveService.saveBatch(activeMessages);
+ }
+ if(ToolUtil.isNotEmpty(historyMessages)) {
+ alertMessageHistoryService.saveBatch(historyMessages);
+ }
+ }
+
+
+}
diff --git a/src/main/java/com/nis/service/impl/AlertRuleServiceImpl.java b/src/main/java/com/nis/service/impl/AlertRuleServiceImpl.java
new file mode 100644
index 0000000..cb640b7
--- /dev/null
+++ b/src/main/java/com/nis/service/impl/AlertRuleServiceImpl.java
@@ -0,0 +1,26 @@
+package com.nis.service.impl;
+
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.nis.dao.AlertMessageDao;
+import com.nis.dao.AlertMessageHistoryDao;
+import com.nis.dao.AlertRuleDao;
+import com.nis.entity.AlertMessageEntity;
+import com.nis.entity.AlertMessageHistoryEntity;
+import com.nis.entity.AlertRuleEntity;
+import com.nis.service.AlertMessageHistoryService;
+import com.nis.service.AlertMessageService;
+import com.nis.service.AlertRuleService;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+
+
+
+@Service
+public class AlertRuleServiceImpl extends ServiceImpl<AlertRuleDao, AlertRuleEntity> implements AlertRuleService {
+
+
+
+}
diff --git a/src/main/java/com/nis/service/impl/AssetAssetServiceImpl.java b/src/main/java/com/nis/service/impl/AssetAssetServiceImpl.java
new file mode 100644
index 0000000..5cf0927
--- /dev/null
+++ b/src/main/java/com/nis/service/impl/AssetAssetServiceImpl.java
@@ -0,0 +1,234 @@
+package com.nis.service.impl;
+
+import cn.hutool.core.lang.UUID;
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.log.Log;
+
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.nis.dao.AssetAssetDao;
+import com.nis.entity.Account;
+import com.nis.entity.Asset;
+import com.nis.entity.AssetAsset;
+import com.nis.entity.AssetFieldMeta;
+import com.nis.entity.AssetFieldValue;
+import com.nis.entity.AssetModel;
+import com.nis.entity.AssetTag;
+import com.nis.entity.AssetTypeConf;
+import com.nis.entity.Model;
+import com.nis.entity.SnmpCredential;
+import com.nis.entity.SysDictEntity;
+import com.nis.service.AccountService;
+import com.nis.service.AssetAssetService;
+import com.nis.service.AssetFieldMetaService;
+import com.nis.service.AssetFieldValueService;
+import com.nis.service.AssetModelService;
+import com.nis.service.AssetService;
+import com.nis.service.AssetTagService;
+import com.nis.service.AssetTypeConfService;
+import com.nis.service.ModelService;
+import com.nis.service.SnmpCredentialService;
+import com.nis.service.SysDictService;
+import com.nis.util.ToolUtil;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+
+/**
+ * 资产 serviceImpl
+ *
+ */
+@Service("assetAssetService")
+public class AssetAssetServiceImpl extends ServiceImpl<AssetAssetDao, AssetAsset> implements AssetAssetService {
+ private static Log logger = Log.get();
+
+ @Autowired
+ private AssetService assetService;
+
+ @Autowired
+ private AccountService accountService;
+
+ @Autowired
+ private AssetModelService assetModelService;
+
+ @Autowired
+ private ModelService modelService;
+
+ @Autowired
+ private SysDictService sysDictService;
+
+ @Autowired
+ private AssetTypeConfService assetTypeConfService;
+
+ @Autowired
+ private SnmpCredentialService snmpCredentialService;
+
+ @Autowired
+ private AssetTagService assetTagService;
+
+ @Autowired
+ private AssetFieldMetaService assetFieldMetaService;
+
+ @Autowired
+ private AssetFieldValueService assetFieldValueService;
+
+ @Override
+ public void handler() {
+ List<Asset> assets = assetService.list();
+
+ // 查询model关联品牌信息
+ List<AssetModel> assetModels = assetModelService.list();
+ Map<Integer, Integer> modelAndBrand = assetModels.stream().collect(Collectors.toMap(AssetModel::getId, AssetModel::getBrandId));
+
+ // 查询model关联资产类型信息
+ List<Model> models = modelService.list();
+ Map<Integer, Integer> modelAndType = models.stream().collect(Collectors.toMap(Model::getId, Model::getTypeCode));
+ List<SysDictEntity> sysDicts = sysDictService.list(new QueryWrapper<SysDictEntity>().lambda().eq(SysDictEntity::getType, "assetType"));
+ Map<Integer, String> dictAndType = sysDicts.stream().collect(Collectors.toMap(SysDictEntity::getCode, SysDictEntity::getValue));
+ Map<Integer,String> modelIdAndTypeName = new HashMap<Integer,String>();
+ for(Integer key : modelAndType.keySet()) {
+ Integer typeId = modelAndType.get(key);
+ String typeName = dictAndType.get(typeId);
+ modelIdAndTypeName.put(key,typeName);
+ }
+ //查询所有assetType数据信息
+ List<AssetTypeConf> assetTypeConfs = assetTypeConfService.list();
+ Map<String, Integer> assetTypeNameAndId = assetTypeConfs.stream().collect(Collectors.toMap(AssetTypeConf::getName,AssetTypeConf::getId));
+ Map<Integer,Map<String,Object>> assetAccountInfo = new HashMap<Integer,Map<String,Object>>();
+
+ List<Account> accounts = accountService.list();
+ Map<Integer, List<Account>> assetIdAccounts = accounts.stream().collect(Collectors.groupingBy(Account::getAssetId));
+
+ Map<Integer,SnmpCredential> assetIdAndSnmpCredential = new HashMap<Integer,SnmpCredential>();
+ List<SnmpCredential> snmpCredentials = new ArrayList<SnmpCredential>();
+ //snmp凭证表添加数据信息
+ for(Account account : accounts) {
+ if(account.getProtocol().equals("SNMP")) {
+ String params = (String) account.getParams();
+ Map<String,Object> map = (Map<String, Object>) JSON.parse(params);
+ Map<String,Object> config = new HashMap<String,Object>();
+ if(((Integer)map.get("version")).equals(2)) {
+ config.put("readCommunity","public");
+ config.put("writeCommunity","public");
+ }else {
+ config.put("username",map.get("username"));
+ config.put("contextname",map.get("contextname"));
+ config.put("securityLevel",map.get("securityLevel"));
+ config.put("authProtocol",map.get("authProtocol"));
+ config.put("authPin",map.get("password"));
+ config.put("privProtocol",map.get("privProtocol"));
+ config.put("privPin",map.get("privPassword"));
+ }
+
+ SnmpCredential snmpCredential = new SnmpCredential();
+ snmpCredential.setName("import_"+UUID.randomUUID().toString());
+ snmpCredential.setType((Integer)map.get("version"));
+ snmpCredential.setPort(account.getPort());
+ snmpCredential.setConfig(JSON.toJSONString(config));
+ snmpCredentials.add(snmpCredential);
+ assetIdAndSnmpCredential.put(account.getAssetId(), snmpCredential);
+ }else {
+ String params = (String) account.getParams();
+ Map<String,Object> map = (Map<String, Object>) JSON.parse(params);
+ map.put("authProtocolPort", account.getPort());
+ assetAccountInfo.put(account.getAssetId(), map);
+ }
+ }
+
+ if(ToolUtil.isNotEmpty(snmpCredentials)) {
+ snmpCredentialService.saveBatch(snmpCredentials);
+ }
+
+ List<AssetAsset> assetAssets = new ArrayList<AssetAsset>();
+ for(Asset asset : assets) {
+ AssetAsset assetAsset = new AssetAsset();
+ assetAsset.setId(asset.getId());
+ assetAsset.setName(asset.getSn());
+ assetAsset.setNumber(asset.getSn());
+ assetAsset.setSn(asset.getSn());
+ assetAsset.setPid(-1);
+ assetAsset.setBrandId(modelAndBrand.get(asset.getModelId()));
+ Integer typeId = assetTypeNameAndId.get(modelIdAndTypeName.get(asset.getModelId()));
+ assetAsset.setTypeId(typeId);
+ assetAsset.setModelId(asset.getModelId());
+ assetAsset.setStateId(asset.getState());
+ assetAsset.setDcId(asset.getIdcId());
+ assetAsset.setCabinetId(asset.getCabinetId());
+ assetAsset.setCabinetStart(asset.getCabinetStart());
+ assetAsset.setCabinetEnd(asset.getCabinetEnd());
+ assetAsset.setManageIp(asset.getHost());
+ assetAsset.setPurchaseDate(asset.getPurchaseDate());
+ assetAsset.setCreateAt(asset.getCreateAt());
+ assetAsset.setUpdateAt(asset.getUpdateAt());
+ assetAsset.setCreateBy(asset.getCreateBy());
+ assetAsset.setUpdateBy(asset.getUpdateBy());
+ assetAsset.setSeq(asset.getSeq());
+ Map<String, Object> sshInfo = assetAccountInfo.get(asset.getId());
+ if(ToolUtil.isNotEmpty(sshInfo)) {
+ assetAsset.setAuthProtocolPort((Integer)sshInfo.get("authProtocolPort"));
+ String method = (String) sshInfo.get("method");
+ if(StrUtil.equals(method, "key")) {
+ assetAsset.setAuthType(2);
+ assetAsset.setAuthPin((String) sshInfo.get("keyPassword"));
+ }else {
+ assetAsset.setAuthType(1);
+ assetAsset.setAuthPin((String) sshInfo.get("password"));
+ }
+ assetAsset.setAuthUsername((String) sshInfo.get("username"));
+
+ assetAsset.setAuthPriKey((String) sshInfo.get("key"));
+ }
+ SnmpCredential snmpCredential = assetIdAndSnmpCredential.get(asset.getId());
+ assetAsset.setSnmpCredentialId(ToolUtil.isEmpty(snmpCredential)? null : snmpCredential.getId());
+ assetAssets.add(assetAsset);
+ }
+
+ if(ToolUtil.isNotEmpty(assetAssets)) {
+ this.saveBatch(assetAssets);
+ }
+
+
+ //处理meta value关系
+ List<AssetTag> tags = assetTagService.list();
+ Map<String, List<AssetTag>> collectMap = tags.stream().collect(Collectors.groupingBy(AssetTag::getTag));
+ Set<String> keySets = collectMap.keySet();
+
+ Map<String,AssetFieldMeta> keyAndMeta = new HashMap<String,AssetFieldMeta>();
+ List<AssetFieldMeta> assetFieldMetas = new ArrayList<AssetFieldMeta>();
+ List<AssetFieldValue> assetFieldValues = new ArrayList<AssetFieldValue>();
+ for(String key : keySets) {
+ AssetFieldMeta assetFieldMeta = new AssetFieldMeta();
+ assetFieldMeta.setName("import_"+key);
+ assetFieldMeta.setMetaKey(key);
+ assetFieldMeta.setGroupId("1");
+ assetFieldMeta.setType("TEXT");
+ assetFieldMeta.setParam("{}");
+ assetFieldMetas.add(assetFieldMeta);
+ keyAndMeta.put(key,assetFieldMeta);
+ }
+
+ if(ToolUtil.isNotEmpty(assetFieldMetas)) {
+ assetFieldMetaService.saveBatch(assetFieldMetas);
+
+ for(AssetTag tag : tags) {
+ AssetFieldValue value = new AssetFieldValue();
+ value.setAssetId(tag.getAssetId());
+ value.setMetaId(keyAndMeta.get(tag.getTag()).getId());
+ value.setValue(tag.getValue());
+ assetFieldValues.add(value);
+ }
+
+ if(ToolUtil.isNotEmpty(assetFieldValues)) {
+ assetFieldValueService.saveBatch(assetFieldValues);
+ }
+ }
+ }
+}
diff --git a/src/main/java/com/nis/service/impl/AssetBrandServiceImpl.java b/src/main/java/com/nis/service/impl/AssetBrandServiceImpl.java
new file mode 100644
index 0000000..c6af484
--- /dev/null
+++ b/src/main/java/com/nis/service/impl/AssetBrandServiceImpl.java
@@ -0,0 +1,56 @@
+package com.nis.service.impl;
+
+import cn.hutool.log.Log;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.nis.dao.AssetBrandDao;
+import com.nis.entity.AssetBrand;
+import com.nis.entity.SysDictEntity;
+import com.nis.service.AssetBrandService;
+import com.nis.service.SysDictService;
+import com.nis.util.Constant;
+import com.nis.util.ToolUtil;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+
+/**
+ * 资产 serviceImpl
+ *
+ */
+@Service("assetBrandService")
+public class AssetBrandServiceImpl extends ServiceImpl<AssetBrandDao, AssetBrand> implements AssetBrandService {
+ private static Log logger = Log.get();
+
+ @Autowired
+ private SysDictService sysDictService;
+
+ @Override
+ public void handler() {
+ // 初始化数据
+ this.initData();
+ }
+
+ public void initData() {
+ List<SysDictEntity> brands = sysDictService.list(new QueryWrapper<SysDictEntity>().lambda().eq(SysDictEntity::getType, "vendor"));
+
+ List<AssetBrand> assetBrands = new ArrayList<AssetBrand>();
+ for(SysDictEntity brand : brands) {
+ AssetBrand assetBrand = new AssetBrand();
+ assetBrand.setName(brand.getName());
+ assetBrand.setRemark(brand.getRemark());
+ assetBrands.add(assetBrand);
+ Constant.assetBrands.put(brand.getCode(), assetBrand);
+ }
+
+ if(ToolUtil.isNotEmpty(assetBrands)) {
+ this.saveBatch(assetBrands);
+ }
+ }
+
+}
diff --git a/src/main/java/com/nis/service/impl/AssetFieldMetaServiceImpl.java b/src/main/java/com/nis/service/impl/AssetFieldMetaServiceImpl.java
new file mode 100644
index 0000000..4e039ae
--- /dev/null
+++ b/src/main/java/com/nis/service/impl/AssetFieldMetaServiceImpl.java
@@ -0,0 +1,26 @@
+package com.nis.service.impl;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.nis.dao.AssetFieldMetaDao;
+import com.nis.entity.AssetFieldMeta;
+import com.nis.service.AssetFieldMetaService;
+
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
+
+@Service("assetFieldMetaService")
+public class AssetFieldMetaServiceImpl extends ServiceImpl<AssetFieldMetaDao,AssetFieldMeta> implements AssetFieldMetaService{
+
+}
diff --git a/src/main/java/com/nis/service/impl/AssetFieldValueServiceImpl.java b/src/main/java/com/nis/service/impl/AssetFieldValueServiceImpl.java
new file mode 100644
index 0000000..05f19d2
--- /dev/null
+++ b/src/main/java/com/nis/service/impl/AssetFieldValueServiceImpl.java
@@ -0,0 +1,13 @@
+package com.nis.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.nis.dao.AssetFieldValueDao;
+import com.nis.entity.AssetFieldValue;
+import com.nis.service.AssetFieldValueService;
+
+import org.springframework.stereotype.Service;
+
+@Service
+public class AssetFieldValueServiceImpl extends ServiceImpl<AssetFieldValueDao, AssetFieldValue> implements AssetFieldValueService {
+
+}
diff --git a/src/main/java/com/nis/service/impl/AssetModelServiceImpl.java b/src/main/java/com/nis/service/impl/AssetModelServiceImpl.java
new file mode 100644
index 0000000..d9211db
--- /dev/null
+++ b/src/main/java/com/nis/service/impl/AssetModelServiceImpl.java
@@ -0,0 +1,57 @@
+package com.nis.service.impl;
+
+import cn.hutool.log.Log;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.nis.dao.AssetModelDao;
+import com.nis.entity.AssetBrand;
+import com.nis.entity.AssetModel;
+import com.nis.entity.Model;
+import com.nis.service.AssetModelService;
+import com.nis.service.ModelService;
+import com.nis.util.Constant;
+import com.nis.util.ToolUtil;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+
+@Service("assetModelService")
+public class AssetModelServiceImpl extends ServiceImpl<AssetModelDao, AssetModel> implements AssetModelService {
+ private static Log logger = Log.get();
+
+ @Autowired
+ private ModelService modelService;
+
+ @Override
+ public void handler() {
+ // 初始化数据
+ this.initData();
+ }
+
+ public void initData() {
+ List<Model> models = modelService.list();
+
+ List<AssetModel> assetModels = new ArrayList<AssetModel>();
+
+ for(Model model : models) {
+ AssetModel assetModel = new AssetModel();
+ assetModel.setId(model.getId());
+ assetModel.setName(model.getName());
+ assetModel.setRemark(model.getRemark());
+ assetModel.setSeq(model.getSeq());
+ assetModel.setUsize(model.getUsize());
+ AssetBrand assetBrand = Constant.assetBrands.get(model.getVendorCode());
+ assetModel.setBrandId(assetBrand.getId());
+ assetModels.add(assetModel);
+ }
+
+ if(ToolUtil.isNotEmpty(assetModels)) {
+ this.saveBatch(assetModels);
+ }
+ }
+
+
+}
diff --git a/src/main/java/com/nis/service/impl/AssetServiceImpl.java b/src/main/java/com/nis/service/impl/AssetServiceImpl.java
new file mode 100644
index 0000000..875613c
--- /dev/null
+++ b/src/main/java/com/nis/service/impl/AssetServiceImpl.java
@@ -0,0 +1,25 @@
+package com.nis.service.impl;
+
+import cn.hutool.log.Log;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.nis.dao.AssetDao;
+import com.nis.entity.Asset;
+import com.nis.entity.AssetAsset;
+import com.nis.service.AssetAssetService;
+import com.nis.service.AssetService;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+
+/**
+ * 资产 serviceImpl
+ *
+ */
+@Service("assetService")
+public class AssetServiceImpl extends ServiceImpl<AssetDao, Asset> implements AssetService {
+ private static Log logger = Log.get();
+
+}
diff --git a/src/main/java/com/nis/service/impl/AssetTagServiceImpl.java b/src/main/java/com/nis/service/impl/AssetTagServiceImpl.java
new file mode 100644
index 0000000..20e08e6
--- /dev/null
+++ b/src/main/java/com/nis/service/impl/AssetTagServiceImpl.java
@@ -0,0 +1,14 @@
+package com.nis.service.impl;
+
+import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.nis.dao.AssetTagDao;
+import com.nis.entity.AssetTag;
+import com.nis.service.AssetTagService;
+
+@Service
+public class AssetTagServiceImpl extends ServiceImpl<AssetTagDao, AssetTag> implements AssetTagService {
+
+}
+
diff --git a/src/main/java/com/nis/service/impl/AssetTypeConfServiceImpl.java b/src/main/java/com/nis/service/impl/AssetTypeConfServiceImpl.java
new file mode 100644
index 0000000..a8f8c0f
--- /dev/null
+++ b/src/main/java/com/nis/service/impl/AssetTypeConfServiceImpl.java
@@ -0,0 +1,28 @@
+package com.nis.service.impl;
+
+import cn.hutool.log.Log;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.nis.dao.AssetTypeConfDao;
+import com.nis.dao.DcDao;
+import com.nis.entity.AssetTypeConf;
+import com.nis.entity.Dc;
+import com.nis.entity.Idc;
+import com.nis.service.AssetTypeConfService;
+import com.nis.service.DcService;
+import com.nis.service.IdcService;
+import com.nis.util.ToolUtil;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service("assetTypeConfService")
+public class AssetTypeConfServiceImpl extends ServiceImpl<AssetTypeConfDao, AssetTypeConf> implements AssetTypeConfService {
+ private static Log logger = Log.get();
+
+
+
+
+}
diff --git a/src/main/java/com/nis/service/impl/ChartElementServiceImpl.java b/src/main/java/com/nis/service/impl/ChartElementServiceImpl.java
new file mode 100644
index 0000000..7154413
--- /dev/null
+++ b/src/main/java/com/nis/service/impl/ChartElementServiceImpl.java
@@ -0,0 +1,24 @@
+package com.nis.service.impl;
+
+import cn.hutool.log.Log;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.nis.dao.ChartElementDao;
+import com.nis.dao.DcDao;
+import com.nis.dao.IdcDao;
+import com.nis.dao.ModuleDao;
+import com.nis.entity.ChartElement;
+import com.nis.entity.Dc;
+import com.nis.entity.Idc;
+import com.nis.entity.Module;
+import com.nis.service.ChartElementService;
+import com.nis.service.DcService;
+import com.nis.service.IdcService;
+import com.nis.service.ModuleService;
+
+import org.springframework.stereotype.Service;
+
+@Service
+public class ChartElementServiceImpl extends ServiceImpl<ChartElementDao, ChartElement> implements ChartElementService {
+ private static Log logger = Log.get();
+
+}
diff --git a/src/main/java/com/nis/service/impl/ChartServiceImpl.java b/src/main/java/com/nis/service/impl/ChartServiceImpl.java
new file mode 100644
index 0000000..8bcf62c
--- /dev/null
+++ b/src/main/java/com/nis/service/impl/ChartServiceImpl.java
@@ -0,0 +1,153 @@
+package com.nis.service.impl;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.log.Log;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.nis.dao.ChartDao;
+import com.nis.dao.DcDao;
+import com.nis.dao.IdcDao;
+import com.nis.dao.ModuleDao;
+import com.nis.entity.AssetModel;
+import com.nis.entity.Chart;
+import com.nis.entity.ChartElement;
+import com.nis.entity.Dc;
+import com.nis.entity.Idc;
+import com.nis.entity.Module;
+import com.nis.entity.Panel;
+import com.nis.entity.VisualChart;
+import com.nis.entity.VisualChartElement;
+import com.nis.entity.VisualPanel;
+import com.nis.service.AssetModelService;
+import com.nis.service.ChartElementService;
+import com.nis.service.ChartService;
+import com.nis.service.DcService;
+import com.nis.service.IdcService;
+import com.nis.service.ModuleService;
+import com.nis.service.PanelService;
+import com.nis.service.VisualChartElementService;
+import com.nis.service.VisualChartService;
+import com.nis.service.VisualPanelService;
+import com.nis.util.ToolUtil;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class ChartServiceImpl extends ServiceImpl<ChartDao, Chart> implements ChartService {
+ private static Log logger = Log.get();
+
+ @Autowired
+ private PanelService panelService;
+
+ @Autowired
+ private VisualPanelService visualPanelService;
+
+ @Autowired
+ private VisualChartService visualChartService;
+
+ @Autowired
+ private VisualChartElementService visualChartElementService;
+
+ @Autowired
+ private ChartElementService chartElementService;
+
+ @Autowired
+ private AssetModelService assetModelService;
+
+ @Override
+ public void handler() {
+
+ // 同步panel
+ List<VisualPanel> visualPanels = new ArrayList<VisualPanel>();
+ List<Panel> panels = panelService.list();
+ Map<Integer, Panel> panelIdAndPanel = panels.stream().collect(Collectors.toMap(Panel::getId, Function.identity()));
+ for(Panel panel:panels) {
+ if(panel.getType().equals("model")) {
+ continue;
+ }
+ VisualPanel visualPanel = new VisualPanel();
+ BeanUtil.copyProperties(panel, visualPanel, "prev","next");
+ visualPanels.add(visualPanel);
+ }
+ if(ToolUtil.isNotEmpty(visualPanels)) {
+ visualPanelService.saveBatch(visualPanels);
+ }
+
+ // 同步chart
+ Map<Integer,String> modelIdAndChartIds = new HashMap<Integer,String>();
+ List<VisualChart> visualCharts = new ArrayList<VisualChart>();
+ List<Chart> charts = this.list();
+ for(Chart chart : charts) {
+ VisualChart visualChart = new VisualChart();
+ visualChart.setId(chart.getId());
+ visualChart.setGroupId(0);
+ visualChart.setName(chart.getTitle());
+ visualChart.setHeight(chart.getHeight());
+ visualChart.setPid(chart.getPid());
+ Panel panel = panelIdAndPanel.get(chart.getPanelId());
+ if(panel.getType().equals("model")) {
+ visualChart.setPanelId(0);
+ String string = modelIdAndChartIds.get(panel.getLink());
+ if(StrUtil.isBlank(string)) {
+ string = ""+chart.getId();
+ }else {
+ string = string +","+chart.getId();
+ }
+ modelIdAndChartIds.put(panel.getLink(), string);
+ }else {
+ visualChart.setPanelId(chart.getPanelId());
+ }
+ visualChart.setSpan(chart.getSpan());
+ visualChart.setUpdateAt(chart.getCreateAt());
+ visualChart.setType(chart.getType());
+ visualChart.setUnit(chart.getUnit());
+ visualChart.setWeight(chart.getWeight());
+ visualChart.setParam(chart.getParam());
+ visualChart.setBuildIn(chart.getBuildIn());
+ visualChart.setSeq(chart.getSeq());
+ visualChart.setUpdateBy(-1);
+ visualCharts.add(visualChart);
+ }
+ if(ToolUtil.isNotEmpty(visualCharts)) {
+ visualChartService.saveBatch(visualCharts);
+ }
+
+ // 同步chartElement
+ List<VisualChartElement> visualChartElements = new ArrayList<VisualChartElement>();
+ List<ChartElement> chartElements = chartElementService.list();
+ for(ChartElement chartElement:chartElements) {
+ VisualChartElement visualChartElement = new VisualChartElement();
+ BeanUtil.copyProperties(chartElement, visualChartElement);
+ visualChartElements.add(visualChartElement);
+ }
+ if(ToolUtil.isNotEmpty(visualChartElements)) {
+ visualChartElementService.saveBatch(visualChartElements);
+ }
+
+ // 将chart归属model的赋值给asset_model
+ Set<Integer> keySet = modelIdAndChartIds.keySet();
+ List<AssetModel> assetModels = assetModelService.list(new QueryWrapper<AssetModel>().lambda().in(ToolUtil.isNotEmpty(keySet),AssetModel::getId, keySet));
+ for(AssetModel assetModel : assetModels) {
+ String chatIds = modelIdAndChartIds.get(assetModel.getId());
+ assetModel.setChartIds(chatIds);
+ }
+ if(ToolUtil.isNotEmpty(assetModels)) {
+ assetModelService.updateBatchById(assetModels);
+ }
+
+ // 删除panel类型为model的数据
+ visualPanelService.remove(new QueryWrapper<VisualPanel>().lambda().eq(VisualPanel::getType, "model"));
+ }
+
+}
diff --git a/src/main/java/com/nis/service/impl/DcServiceImpl.java b/src/main/java/com/nis/service/impl/DcServiceImpl.java
new file mode 100644
index 0000000..49622f0
--- /dev/null
+++ b/src/main/java/com/nis/service/impl/DcServiceImpl.java
@@ -0,0 +1,51 @@
+package com.nis.service.impl;
+
+import cn.hutool.log.Log;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.nis.dao.DcDao;
+import com.nis.entity.Dc;
+import com.nis.entity.Idc;
+import com.nis.service.DcService;
+import com.nis.service.IdcService;
+import com.nis.util.ToolUtil;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service("dcService")
+public class DcServiceImpl extends ServiceImpl<DcDao, Dc> implements DcService {
+ private static Log logger = Log.get();
+
+ @Autowired
+ private IdcService idcService;
+
+ @Override
+ public void handler() {
+ List<Idc> idcs = idcService.list();
+ List<Dc> dcs = new ArrayList<Dc>();
+
+ for(Idc idc : idcs) {
+ Dc dc = new Dc();
+ dc.setName(idc.getName());
+ dc.setLocation(idc.getLocation());
+ dc.setTel(idc.getTel());
+ dc.setPrincipal(idc.getPrincipal());
+ dc.setSeq(idc.getSeq());
+ dc.setX(idc.getX());
+ dc.setY(idc.getY());
+ dc.setLongitude(idc.getLongitude());
+ dc.setLatitude(idc.getLatitude());
+ dc.setState(idc.getState());
+ dcs.add(dc);
+ }
+
+ if(ToolUtil.isNotEmpty(idcs)) {
+ this.saveBatch(dcs);
+ }
+ }
+
+
+}
diff --git a/src/main/java/com/nis/service/impl/EndpointServiceImpl.java b/src/main/java/com/nis/service/impl/EndpointServiceImpl.java
new file mode 100644
index 0000000..21ae7ec
--- /dev/null
+++ b/src/main/java/com/nis/service/impl/EndpointServiceImpl.java
@@ -0,0 +1,213 @@
+package com.nis.service.impl;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.lang.UUID;
+import cn.hutool.core.lang.hash.MurmurHash;
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.log.Log;
+
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.nis.dao.DcDao;
+import com.nis.dao.EndpointDao;
+import com.nis.dao.IdcDao;
+import com.nis.entity.Dc;
+import com.nis.entity.Endpoint;
+import com.nis.entity.Idc;
+import com.nis.entity.Module;
+import com.nis.entity.MonitorEndpoint;
+import com.nis.entity.MonitorModule;
+import com.nis.entity.MonitorProject;
+import com.nis.entity.Project;
+import com.nis.entity.SnmpCredential;
+import com.nis.service.DcService;
+import com.nis.service.EndpointService;
+import com.nis.service.IdcService;
+import com.nis.service.ModuleService;
+import com.nis.service.MonitorEndpointService;
+import com.nis.service.MonitorModuleService;
+import com.nis.service.MonitorProjectService;
+import com.nis.service.ProjectService;
+import com.nis.service.SnmpCredentialService;
+import com.nis.util.ToolUtil;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class EndpointServiceImpl extends ServiceImpl<EndpointDao, Endpoint> implements EndpointService {
+ private static Log logger = Log.get();
+
+ @Autowired
+ private ProjectService projectService;
+
+ @Autowired
+ private MonitorProjectService monitorProjectService;
+
+ @Autowired
+ private ModuleService moduleService;
+
+ @Autowired
+ private MonitorModuleService monitorModuleService;
+
+ @Autowired
+ private MonitorEndpointService monitorEndpointService;
+
+ @Autowired
+ private EndpointService endpointService;
+
+ @Autowired
+ private SnmpCredentialService snmpCredentialService;
+
+ @Override
+ public void handler() {
+
+ // 同步project数据
+ List<MonitorProject> monitorProjects = new ArrayList<MonitorProject>();
+ List<Project> projects = projectService.list();
+ for(Project project : projects) {
+ MonitorProject monitorProject = new MonitorProject();
+ BeanUtil.copyProperties(project, monitorProject);
+ monitorProjects.add(monitorProject);
+ }
+ if(ToolUtil.isNotEmpty(monitorProjects)) {
+ monitorProjectService.saveBatch(monitorProjects);
+ }
+
+
+ // 同步module数据 首先需要将module中snmp类型的新增凭证
+ List<SnmpCredential> snmpCredentials = new ArrayList<SnmpCredential>();
+ List<Module> snmpModules = moduleService.list(new QueryWrapper<Module>().eq("type", "snmp"));
+ Map<Integer,SnmpCredential> moduleIdAndSnmpcredentialMap = new HashMap<Integer,SnmpCredential>();
+ for(Module snmpModule : snmpModules) {
+ String snmpParam = snmpModule.getSnmpParam();
+ if(StrUtil.isNotBlank(snmpParam)) {
+ Map<String,Object> config = new HashMap<String,Object>();
+ Map<String,Object> snmpParamMap = JSON.parseObject(snmpParam,Map.class);
+ Object object = snmpParamMap.get("walk");
+ Integer version = (Integer) snmpParamMap.get("version");
+ if(version.equals(2)) {
+ config.put("readCommunity","public");
+ config.put("writeCommunity","public");
+ }else {
+ Object auth = snmpParamMap.get("auth");
+ Map authMap = JSON.parseObject(JSON.toJSONString(auth),Map.class);
+ config.put("username",authMap.get("username"));
+ config.put("contextname",authMap.get("context_name"));
+ config.put("securityLevel",authMap.get("security_level"));
+ config.put("authProtocol",authMap.get("auth_protocol"));
+ config.put("authPin",authMap.get("password"));
+ config.put("privProtocol",authMap.get("priv_protocol"));
+ config.put("privPin",authMap.get("priv_password"));
+ }
+ SnmpCredential snmpCredential = new SnmpCredential();
+ snmpCredential.setName("import_"+UUID.randomUUID().toString());
+ snmpCredential.setType((Integer)snmpParamMap.get("version"));
+ snmpCredential.setPort(snmpModule.getPort());
+ snmpCredential.setConfig(JSON.toJSONString(config));
+ snmpCredentials.add(snmpCredential);
+ moduleIdAndSnmpcredentialMap.put(snmpModule.getId(), snmpCredential);
+ }
+ }
+
+ if(ToolUtil.isNotEmpty(snmpCredentials)) {
+ snmpCredentialService.saveBatch(snmpCredentials);
+ }
+
+
+ List<MonitorModule> monitorModules =new ArrayList<MonitorModule>();
+ List<Module> modules = moduleService.list();
+ for(Module module : modules) {
+ Map<String,Object> configs =new HashMap<String,Object>();
+ configs.put("metrics_path", module.getPath());
+ configs.put("port", module.getPort());
+ configs.put("host", "{{asset.manageIp}}");
+ if(StrUtil.isNotBlank(module.getParam())) {
+ String param = module.getParam();
+ Map<String,Object> paramMap = JSON.parseObject(param,Map.class);
+ Map<String,Object> params = new HashMap<String,Object>();
+ for(String key : paramMap.keySet()) {
+ Object value = paramMap.get(key);
+ List values = new ArrayList();
+ values.add(value);
+ params.put(key, values);
+ }
+ configs.put("params", params);
+ }
+ if(module.getType().equals("snmp")) {
+ String snmpParam = module.getSnmpParam();
+ if(StrUtil.isNotBlank(snmpParam)) {
+ Map<String,Object> snmpParamMap = JSON.parseObject(snmpParam,Map.class);
+ Object object = snmpParamMap.get("walk");
+ configs.put("walk", object);
+ }
+ SnmpCredential snmpCredential = moduleIdAndSnmpcredentialMap.get(module.getId());
+ configs.put("snmpCredentialsId", ToolUtil.isNotEmpty(snmpCredential)?snmpCredential.getId() : "");
+ }
+ String labels = module.getLabels();
+ if(StrUtil.isNotBlank(labels)) {
+ configs.put("labels",labels);
+ }
+ MonitorModule monitorModule = new MonitorModule();
+ monitorModule.setName(module.getName());
+ monitorModule.setId(module.getId());
+ monitorModule.setProjectId(module.getId());
+ monitorModule.setRemark(module.getRemark());
+ monitorModule.setSeq(module.getSeq());
+ monitorModule.setBuildIn(module.getBuildIn());
+ monitorModule.setType(module.getType());
+ monitorModule.setEndpointNameTmpl("{{asset.name}}-{{module.name}}");
+ monitorModule.setConfigs(JSON.toJSONString(configs));
+ monitorModules.add(monitorModule);
+ }
+
+ if(ToolUtil.isNotEmpty(monitorModules)) {
+ monitorModuleService.saveBatch(monitorModules);
+ }
+
+ // 同步endpoint信息
+ List<Endpoint> endpoints = endpointService.list();
+ List<MonitorEndpoint> monitorEndpoints =new ArrayList<MonitorEndpoint>();
+ for(Endpoint endpoint : endpoints) {
+ Map<String,Object> configs =new HashMap<String,Object>();
+ configs.put("metrics_path", endpoint.getPath());
+ configs.put("port", endpoint.getPort());
+ configs.put("host", endpoint.getHost());
+ if(StrUtil.isNotBlank(endpoint.getParam())) {
+ String param = endpoint.getParam();
+ Map<String,Object> paramMap = JSON.parseObject(param,Map.class);
+ Map<String,Object> params = new HashMap<String,Object>();
+ for(String key : paramMap.keySet()) {
+ Object value = paramMap.get(key);
+ List values = new ArrayList();
+ values.add(value);
+ params.put(key, values);
+ }
+ configs.put("params", params);
+ }
+ configs.put("labels",endpoint.getLabels());
+ MonitorEndpoint monitorEndpoint = new MonitorEndpoint();
+ monitorEndpoint.setId(endpoint.getId());
+ monitorEndpoint.setEnabled(endpoint.getEnabled());
+ monitorEndpoint.setModuleId(endpoint.getModuleId());
+ monitorEndpoint.setAssetId(endpoint.getAssetId());
+ monitorEndpoint.setName("import_endpoint_"+endpoint.getId());
+ monitorEndpoint.setSeq(endpoint.getSeq());
+ monitorEndpoint.setConfigs(JSON.toJSONString(configs));
+ String hash = endpoint.getModuleId() + endpoint.getAssetId() + JSON.toJSONString(configs);
+ monitorEndpoint.setHash(String.valueOf(Math.abs(MurmurHash.hash64(hash))));
+ monitorEndpoints.add(monitorEndpoint);
+ }
+
+ if(ToolUtil.isNotEmpty(monitorEndpoints)) {
+ monitorEndpointService.saveBatch(monitorEndpoints);
+ }
+ }
+
+}
diff --git a/src/main/java/com/nis/service/impl/IdcServiceImpl.java b/src/main/java/com/nis/service/impl/IdcServiceImpl.java
new file mode 100644
index 0000000..88350a4
--- /dev/null
+++ b/src/main/java/com/nis/service/impl/IdcServiceImpl.java
@@ -0,0 +1,17 @@
+package com.nis.service.impl;
+
+import cn.hutool.log.Log;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.nis.dao.DcDao;
+import com.nis.dao.IdcDao;
+import com.nis.entity.Dc;
+import com.nis.entity.Idc;
+import com.nis.service.DcService;
+import com.nis.service.IdcService;
+
+import org.springframework.stereotype.Service;
+
+@Service("idcService")
+public class IdcServiceImpl extends ServiceImpl<IdcDao, Idc> implements IdcService {
+
+}
diff --git a/src/main/java/com/nis/service/impl/ModelServiceImpl.java b/src/main/java/com/nis/service/impl/ModelServiceImpl.java
new file mode 100644
index 0000000..96d02de
--- /dev/null
+++ b/src/main/java/com/nis/service/impl/ModelServiceImpl.java
@@ -0,0 +1,23 @@
+package com.nis.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.nis.dao.ModelDao;
+import com.nis.entity.Model;
+import com.nis.service.ModelService;
+
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+
+@Service("modelService")
+public class ModelServiceImpl extends ServiceImpl<ModelDao, Model> implements ModelService {
+
+}
diff --git a/src/main/java/com/nis/service/impl/ModuleServiceImpl.java b/src/main/java/com/nis/service/impl/ModuleServiceImpl.java
new file mode 100644
index 0000000..7ec219f
--- /dev/null
+++ b/src/main/java/com/nis/service/impl/ModuleServiceImpl.java
@@ -0,0 +1,20 @@
+package com.nis.service.impl;
+
+import cn.hutool.log.Log;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.nis.dao.DcDao;
+import com.nis.dao.IdcDao;
+import com.nis.dao.ModuleDao;
+import com.nis.entity.Dc;
+import com.nis.entity.Idc;
+import com.nis.entity.Module;
+import com.nis.service.DcService;
+import com.nis.service.IdcService;
+import com.nis.service.ModuleService;
+
+import org.springframework.stereotype.Service;
+
+@Service
+public class ModuleServiceImpl extends ServiceImpl<ModuleDao, Module> implements ModuleService {
+
+}
diff --git a/src/main/java/com/nis/service/impl/MonitorEndpointServiceImpl.java b/src/main/java/com/nis/service/impl/MonitorEndpointServiceImpl.java
new file mode 100644
index 0000000..9ae49d2
--- /dev/null
+++ b/src/main/java/com/nis/service/impl/MonitorEndpointServiceImpl.java
@@ -0,0 +1,20 @@
+package com.nis.service.impl;
+
+import cn.hutool.log.Log;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.nis.dao.DcDao;
+import com.nis.dao.IdcDao;
+import com.nis.dao.MonitorEndpointDao;
+import com.nis.entity.Dc;
+import com.nis.entity.Idc;
+import com.nis.entity.MonitorEndpoint;
+import com.nis.service.DcService;
+import com.nis.service.IdcService;
+import com.nis.service.MonitorEndpointService;
+
+import org.springframework.stereotype.Service;
+
+@Service
+public class MonitorEndpointServiceImpl extends ServiceImpl<MonitorEndpointDao, MonitorEndpoint> implements MonitorEndpointService {
+
+}
diff --git a/src/main/java/com/nis/service/impl/MonitorModuleServiceImpl.java b/src/main/java/com/nis/service/impl/MonitorModuleServiceImpl.java
new file mode 100644
index 0000000..34ccd47
--- /dev/null
+++ b/src/main/java/com/nis/service/impl/MonitorModuleServiceImpl.java
@@ -0,0 +1,20 @@
+package com.nis.service.impl;
+
+import cn.hutool.log.Log;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.nis.dao.DcDao;
+import com.nis.dao.IdcDao;
+import com.nis.dao.MonitorModuleDao;
+import com.nis.entity.Dc;
+import com.nis.entity.Idc;
+import com.nis.entity.MonitorModule;
+import com.nis.service.DcService;
+import com.nis.service.IdcService;
+import com.nis.service.MonitorModuleService;
+
+import org.springframework.stereotype.Service;
+
+@Service
+public class MonitorModuleServiceImpl extends ServiceImpl<MonitorModuleDao, MonitorModule> implements MonitorModuleService {
+
+}
diff --git a/src/main/java/com/nis/service/impl/MonitorProjectServiceImpl.java b/src/main/java/com/nis/service/impl/MonitorProjectServiceImpl.java
new file mode 100644
index 0000000..779f809
--- /dev/null
+++ b/src/main/java/com/nis/service/impl/MonitorProjectServiceImpl.java
@@ -0,0 +1,20 @@
+package com.nis.service.impl;
+
+import cn.hutool.log.Log;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.nis.dao.DcDao;
+import com.nis.dao.IdcDao;
+import com.nis.dao.MonitorProjectDao;
+import com.nis.entity.Dc;
+import com.nis.entity.Idc;
+import com.nis.entity.MonitorProject;
+import com.nis.service.DcService;
+import com.nis.service.IdcService;
+import com.nis.service.MonitorProjectService;
+
+import org.springframework.stereotype.Service;
+
+@Service
+public class MonitorProjectServiceImpl extends ServiceImpl<MonitorProjectDao, MonitorProject> implements MonitorProjectService {
+
+}
diff --git a/src/main/java/com/nis/service/impl/PanelServiceImpl.java b/src/main/java/com/nis/service/impl/PanelServiceImpl.java
new file mode 100644
index 0000000..f630708
--- /dev/null
+++ b/src/main/java/com/nis/service/impl/PanelServiceImpl.java
@@ -0,0 +1,23 @@
+package com.nis.service.impl;
+
+import cn.hutool.log.Log;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.nis.dao.DcDao;
+import com.nis.dao.IdcDao;
+import com.nis.dao.ModuleDao;
+import com.nis.dao.PanelDao;
+import com.nis.entity.Dc;
+import com.nis.entity.Idc;
+import com.nis.entity.Module;
+import com.nis.entity.Panel;
+import com.nis.service.DcService;
+import com.nis.service.IdcService;
+import com.nis.service.ModuleService;
+import com.nis.service.PanelService;
+
+import org.springframework.stereotype.Service;
+
+@Service
+public class PanelServiceImpl extends ServiceImpl<PanelDao, Panel> implements PanelService {
+
+}
diff --git a/src/main/java/com/nis/service/impl/ProjectServiceImpl.java b/src/main/java/com/nis/service/impl/ProjectServiceImpl.java
new file mode 100644
index 0000000..632b2a8
--- /dev/null
+++ b/src/main/java/com/nis/service/impl/ProjectServiceImpl.java
@@ -0,0 +1,20 @@
+package com.nis.service.impl;
+
+import cn.hutool.log.Log;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.nis.dao.DcDao;
+import com.nis.dao.IdcDao;
+import com.nis.dao.ProjectDao;
+import com.nis.entity.Dc;
+import com.nis.entity.Idc;
+import com.nis.entity.Project;
+import com.nis.service.DcService;
+import com.nis.service.IdcService;
+import com.nis.service.ProjectService;
+
+import org.springframework.stereotype.Service;
+
+@Service("projectService")
+public class ProjectServiceImpl extends ServiceImpl<ProjectDao, Project> implements ProjectService {
+
+}
diff --git a/src/main/java/com/nis/service/impl/SnmpCredentialServiceImpl.java b/src/main/java/com/nis/service/impl/SnmpCredentialServiceImpl.java
new file mode 100644
index 0000000..db6d21f
--- /dev/null
+++ b/src/main/java/com/nis/service/impl/SnmpCredentialServiceImpl.java
@@ -0,0 +1,21 @@
+package com.nis.service.impl;
+
+import java.util.Arrays;
+import java.util.Map;
+
+import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.nis.dao.SnmpCredentialDao;
+import com.nis.entity.SnmpCredential;
+import com.nis.service.SnmpCredentialService;
+
+import cn.hutool.core.util.ObjectUtil;
+
+@Service
+public class SnmpCredentialServiceImpl extends ServiceImpl<SnmpCredentialDao,SnmpCredential> implements SnmpCredentialService{
+
+}
diff --git a/src/main/java/com/nis/service/impl/SysDictServiceImpl.java b/src/main/java/com/nis/service/impl/SysDictServiceImpl.java
new file mode 100644
index 0000000..473c399
--- /dev/null
+++ b/src/main/java/com/nis/service/impl/SysDictServiceImpl.java
@@ -0,0 +1,29 @@
+/**
+
+ *
+
+ *
+
+ */
+
+package com.nis.service.impl;
+
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.nis.dao.SysDictDao;
+import com.nis.entity.SysDictEntity;
+import com.nis.service.SysDictService;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+
+@Service("sysDictService")
+public class SysDictServiceImpl extends ServiceImpl<SysDictDao, SysDictEntity> implements SysDictService {
+
+}
diff --git a/src/main/java/com/nis/service/impl/VisualChartElementServiceImpl.java b/src/main/java/com/nis/service/impl/VisualChartElementServiceImpl.java
new file mode 100644
index 0000000..2ee7e08
--- /dev/null
+++ b/src/main/java/com/nis/service/impl/VisualChartElementServiceImpl.java
@@ -0,0 +1,24 @@
+package com.nis.service.impl;
+
+import cn.hutool.log.Log;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.nis.dao.DcDao;
+import com.nis.dao.IdcDao;
+import com.nis.dao.ModuleDao;
+import com.nis.dao.VisualChartElementDao;
+import com.nis.entity.Dc;
+import com.nis.entity.Idc;
+import com.nis.entity.Module;
+import com.nis.entity.VisualChartElement;
+import com.nis.service.DcService;
+import com.nis.service.IdcService;
+import com.nis.service.ModuleService;
+import com.nis.service.VisualChartElementService;
+
+import org.springframework.stereotype.Service;
+
+@Service
+public class VisualChartElementServiceImpl extends ServiceImpl<VisualChartElementDao, VisualChartElement> implements VisualChartElementService {
+ private static Log logger = Log.get();
+
+}
diff --git a/src/main/java/com/nis/service/impl/VisualChartServiceImpl.java b/src/main/java/com/nis/service/impl/VisualChartServiceImpl.java
new file mode 100644
index 0000000..e4dc32f
--- /dev/null
+++ b/src/main/java/com/nis/service/impl/VisualChartServiceImpl.java
@@ -0,0 +1,24 @@
+package com.nis.service.impl;
+
+import cn.hutool.log.Log;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.nis.dao.DcDao;
+import com.nis.dao.IdcDao;
+import com.nis.dao.ModuleDao;
+import com.nis.dao.VisualChartDao;
+import com.nis.entity.Dc;
+import com.nis.entity.Idc;
+import com.nis.entity.Module;
+import com.nis.entity.VisualChart;
+import com.nis.service.DcService;
+import com.nis.service.IdcService;
+import com.nis.service.ModuleService;
+import com.nis.service.VisualChartService;
+
+import org.springframework.stereotype.Service;
+
+@Service
+public class VisualChartServiceImpl extends ServiceImpl<VisualChartDao, VisualChart> implements VisualChartService {
+ private static Log logger = Log.get();
+
+}
diff --git a/src/main/java/com/nis/service/impl/VisualPanelServiceImpl.java b/src/main/java/com/nis/service/impl/VisualPanelServiceImpl.java
new file mode 100644
index 0000000..631fb73
--- /dev/null
+++ b/src/main/java/com/nis/service/impl/VisualPanelServiceImpl.java
@@ -0,0 +1,26 @@
+package com.nis.service.impl;
+
+import cn.hutool.log.Log;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.nis.dao.DcDao;
+import com.nis.dao.IdcDao;
+import com.nis.dao.ModuleDao;
+import com.nis.dao.PanelDao;
+import com.nis.dao.VisualPanelDao;
+import com.nis.entity.Dc;
+import com.nis.entity.Idc;
+import com.nis.entity.Module;
+import com.nis.entity.Panel;
+import com.nis.entity.VisualPanel;
+import com.nis.service.DcService;
+import com.nis.service.IdcService;
+import com.nis.service.ModuleService;
+import com.nis.service.PanelService;
+import com.nis.service.VisualPanelService;
+
+import org.springframework.stereotype.Service;
+
+@Service
+public class VisualPanelServiceImpl extends ServiceImpl<VisualPanelDao, VisualPanel> implements VisualPanelService {
+
+}
diff --git a/src/main/java/com/nis/util/Constant.java b/src/main/java/com/nis/util/Constant.java
new file mode 100644
index 0000000..e2774e2
--- /dev/null
+++ b/src/main/java/com/nis/util/Constant.java
@@ -0,0 +1,69 @@
+/**
+
+ *
+
+ *
+
+ */
+
+package com.nis.util;
+
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.log.Log;
+import org.apache.ibatis.mapping.DatabaseIdProvider;
+
+import com.nis.entity.AssetBrand;
+import com.nis.entity.AssetTypeConf;
+import com.nis.entity.SysDictEntity;
+
+import javax.sql.DataSource;
+
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 常量
+ *
+
+ */
+public class Constant {
+ private final static Log logger = Log.get();
+
+ public static Boolean rollBack = false;
+ /**
+ * 当前数据库类型
+ */
+ public static final String DB_TYPE;
+ public static final String DATABASE_NAME;
+ public static final String ORACLE = "oracle";
+ public static final String MYSQL = "mysql";
+ public static final String POSTGRESQL = "postgresql";
+
+
+ static {
+ DatabaseIdProvider databaseIdProvider = SpringContextUtils.getBean("getDatabaseIdProvider", DatabaseIdProvider.class);
+ DataSource dataSource = SpringContextUtils.getBean("dataSource",DataSource.class);
+ String databaseId = null;
+ String databaseName=null;
+ try {
+ databaseId = databaseIdProvider.getDatabaseId(dataSource);
+ Connection connection = dataSource.getConnection();
+ DatabaseMetaData metaData = connection.getMetaData();
+ String url = metaData.getURL();
+ if(StrUtil.isNotBlank(url)) {
+ String[] split = StrUtil.split(url, "?");
+ databaseName = StrUtil.subAfter(split[0], "/", true);
+ }
+ } catch (SQLException e) {
+ logger.error(e);
+ }
+ DB_TYPE = databaseId;
+ DATABASE_NAME = databaseName;
+ }
+
+ public static Map<Integer,AssetBrand> assetBrands = new HashMap<Integer,AssetBrand>();
+}
diff --git a/src/main/java/com/nis/util/SQLUtils.java b/src/main/java/com/nis/util/SQLUtils.java
new file mode 100644
index 0000000..e5f2c55
--- /dev/null
+++ b/src/main/java/com/nis/util/SQLUtils.java
@@ -0,0 +1,102 @@
+package com.nis.util;
+
+import java.util.Map;
+
+import com.nis.util.SqlHelper.KeywordsType;
+
+public abstract class SQLUtils {
+ protected Map<KeywordsType, String> keywords;
+
+
+ /**
+ * @Description 创建表
+ * @Author rui
+ * @Date 2019/7/31
+ * @Param tableName:表名 fields:字段及其字段约束 字段名--字段约束
+ * @Return
+ * @Exception
+ */
+ public abstract String createTable(String tableName, Map<String,String> fields);
+
+ /**
+ * @Description 根据表名查询表是否存在数据库
+ * @Author rui
+ * @Date 2019/7/31
+ * @Param tableName:表名
+ * @Return
+ * @Exception
+ */
+ public abstract String queryTables(String tableName);
+
+ /**
+ * @Description 添加索引
+ * @Author rui
+ * @Date 2019/7/31
+ * @Param tableName:表名 indexs:索引名称及要添加索引的字段名称数组
+ * @Return
+ * @Exception
+ */
+ public abstract String addIndexs(String tableName,Map<String,String[]> indexs);
+
+ /**
+ * @Description 删除索引
+ * @Author rui
+ * @Date 2019/7/31
+ * @Param tableName:表名 indexNames :索引名称数组
+ * @Return
+ * @Exception
+ */
+ public abstract String delIndexs(String tableName,String ... indexNames);
+
+ /**
+ * @Description 删除表
+ * @Author rui
+ * @Date 2019/7/31
+ * @Param tableName:表名
+ * @Return
+ * @Exception
+ */
+ public abstract String dropTable(String tableName);
+
+ /**
+ * @Description 添加表字段
+ * @Author rui
+ * @Date 2019/7/31
+ * @Param tableName:表名 fields:字段及其字段约束 字段名--字段约束
+ * @Return
+ * @Exception
+ */
+ public abstract String addFields(String tableName,Map<String,String> fields);
+
+ /**
+ * @Description 删除表字段
+ * @Author rui
+ * @Date 2019/7/31
+ * @Param tableName:表名 fields:字段名称数组
+ * @Return
+ * @Exception
+ */
+ public abstract String delFields(String tableName,String ... fields);
+
+ /**
+ * @Description 修改字段类型及长度
+ * @Author rui
+ * @Date 2019/7/31
+ * @Param tableName:表名 fields:字段及其字段约束 字段名--字段约束
+ * @Return
+ * @Exception
+ */
+ public abstract String modifyFields(String tableName,Map<String,String> fields);
+
+ /**
+ * @Description 生成字段约束
+ * @Author rui
+ * @Date 2019/7/31
+ * @Param key :字段的类型 dataLenth 字段长度,
+ *@Param decimal类型默认及最大长度65 整数类型 mysql默认及最大长度20 postgresql默认及最大64 oracle默认及最大38
+ * @Param limit 只对decimal类型生效,默认2
+ * @Return
+ * @Exception
+ */
+ public abstract String getRestrict(KeywordsType key, Integer dataLenth, Integer limit);
+}
diff --git a/src/main/java/com/nis/util/SpringContextUtils.java b/src/main/java/com/nis/util/SpringContextUtils.java
new file mode 100644
index 0000000..d111e55
--- /dev/null
+++ b/src/main/java/com/nis/util/SpringContextUtils.java
@@ -0,0 +1,49 @@
+/**
+
+ *
+
+ *
+ *
+ */
+
+package com.nis.util;
+
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.stereotype.Component;
+
+/**
+ * Spring Context 工具类
+ *
+ * @author Mark [email protected]
+ */
+@Component
+public class SpringContextUtils implements ApplicationContextAware {
+ public static ApplicationContext applicationContext;
+
+ @Override
+ public void setApplicationContext(ApplicationContext applicationContext)
+ throws BeansException {
+ SpringContextUtils.applicationContext = applicationContext;
+ }
+
+ public static Object getBean(String name) {
+ return applicationContext.getBean(name);
+ }
+
+ public static <T> T getBean(Class<T> requiredType) {
+ return applicationContext.getBean(requiredType);
+ }
+
+ public static <T> T getBean(String name, Class<T> requiredType) {
+ return applicationContext.getBean(name, requiredType);
+ }
+
+
+
+ public static Class<? extends Object> getType(String name) {
+ return applicationContext.getType(name);
+ }
+
+} \ No newline at end of file
diff --git a/src/main/java/com/nis/util/SqlHelper/KeywordsType.java b/src/main/java/com/nis/util/SqlHelper/KeywordsType.java
new file mode 100644
index 0000000..cac0758
--- /dev/null
+++ b/src/main/java/com/nis/util/SqlHelper/KeywordsType.java
@@ -0,0 +1,16 @@
+package com.nis.util.SqlHelper;
+
+public enum KeywordsType {
+ STRING("string"),//字符串类型
+ NUMBER("number"),//普通数字类型
+ DATE("date"),//时间戳类型
+ PRIMARYKEY("primaryKey"),//主键类型,项目内主键统一为Long类型
+ COMPUTE("compute");//计算类型
+
+
+ private String key;
+
+ KeywordsType(String key){
+ this.key=key;
+ }
+}
diff --git a/src/main/java/com/nis/util/SqlHelper/MysqlHelper.java b/src/main/java/com/nis/util/SqlHelper/MysqlHelper.java
new file mode 100644
index 0000000..c371ad5
--- /dev/null
+++ b/src/main/java/com/nis/util/SqlHelper/MysqlHelper.java
@@ -0,0 +1,188 @@
+package com.nis.util.SqlHelper;
+
+import cn.hutool.log.Log;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import com.nis.util.SQLUtils;
+
+public class MysqlHelper extends SQLUtils {
+ private Log log= Log.get();
+
+ public MysqlHelper(){
+ keywords=new HashMap<KeywordsType, String>();
+
+ keywords.put(KeywordsType.COMPUTE,"decimal");
+
+ keywords.put(KeywordsType.NUMBER,"bigint");
+
+ keywords.put(KeywordsType.STRING,"varchar");
+
+ keywords.put(KeywordsType.DATE,"timestamp default current_timestamp");
+
+ keywords.put(KeywordsType.PRIMARYKEY,"bigint(20) primary key");
+
+ }
+
+ @Override
+ public String createTable(String tableName, Map<String, String> fields) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("create table if not exists `"+tableName+"`(");
+ Set<Map.Entry<String, String>> entries = fields.entrySet();
+ int i=0;
+ for(Map.Entry<String,String> entry:entries){
+ String field=entry.getKey();
+ String restrict=entry.getValue();
+ sb.append("`"+field+"` "+restrict);
+ if(i!=entries.size()-1){
+ sb.append(",");
+ }
+ i++;
+ }
+ sb.append(")");
+
+ log.debug("create table SQL--> "+sb.toString());
+ return sb.toString();
+ }
+
+ @Override
+ public String queryTables(String tableName) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("SELECT t.table_name AS name,t.TABLE_COMMENT AS comments FROM information_schema.`TABLES` t WHERE t.TABLE_SCHEMA = (select database()) AND t.TABLE_NAME = ");
+ sb.append("'"+tableName+"'");
+ sb.append(" ORDER BY t.TABLE_NAME");
+
+ log.debug("query tables SQL--> "+sb.toString());
+ return sb.toString();
+ }
+
+ @Override
+ public String addIndexs(String tableName, Map<String, String[]> indexs) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("alter table `"+ tableName +"` ");
+
+ Set<Map.Entry<String, String[]>> entries = indexs.entrySet();
+ int i=0;
+ for(Map.Entry<String, String[]> entry:entries){
+ String indexName=entry.getKey();
+ String[] fieldNames=entry.getValue();
+ sb.append("add index if not exists `"+indexName+"`(");
+ for(int j=0;j<fieldNames.length;j++){
+ String fieldName=fieldNames[j];
+ sb.append("`"+fieldName+"`");
+
+ if(j!=fieldNames.length-1){
+ sb.append(",");
+ }
+ }
+ sb.append(")");
+ if(i!=entries.size()-1){
+ sb.append(",");
+ }
+ i++;
+ }
+
+ log.debug("add index SQL--> "+sb.toString());
+ return sb.toString();
+ }
+
+ @Override
+ public String delIndexs(String tableName, String... indexNames) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("alter table `"+ tableName +"` ");
+ for(int i=0;i<indexNames.length;i++){
+ String indexName=indexNames[i];
+ sb.append("drop index if exists `"+indexName+"`");
+ if(i!=indexNames.length-1){
+ sb.append(",");
+ }
+ }
+ log.debug("drop index SQL--> "+sb.toString());
+ return sb.toString();
+ }
+
+ @Override
+ public String dropTable(String tableName) {
+ String sql=("drop table if exists `"+ tableName +"` ");
+ log.debug("drop table SQL--> "+sql);
+ return sql;
+ }
+
+ @Override
+ public String addFields(String tableName, Map<String, String> fields) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("alter table `"+ tableName +"` ");
+
+ Set<Map.Entry<String, String>> entries = fields.entrySet();
+ int i=0;
+ for(Map.Entry<String, String> entry:entries){
+ String fieldName=entry.getKey();
+ String restrict=entry.getValue();
+ sb.append("add column if not exists `"+fieldName+"`"+restrict);
+ if(i!=entries.size()-1){
+ sb.append(",");
+ }
+ i++;
+ }
+
+ log.debug("add fields SQL--> "+sb.toString());
+ return sb.toString();
+ }
+
+ @Override
+ public String delFields(String tableName, String... fields) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("alter table `"+ tableName +"` ");
+ for(int i=0;i<fields.length;i++){
+ String field=fields[i];
+ sb.append("drop column if exists `"+field+"`");
+ if(i!=fields.length-1){
+ sb.append(",");
+ }
+ }
+ log.debug("drop fields SQL--> "+sb.toString());
+ return sb.toString();
+ }
+
+ @Override
+ public String modifyFields(String tableName, Map<String, String> fields) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("alter table `"+ tableName +"` ");
+
+ Set<Map.Entry<String, String>> entries = fields.entrySet();
+ int i=0;
+ for(Map.Entry<String, String> entry:entries){
+ String fieldName=entry.getKey();
+ String restrict=entry.getValue();
+ sb.append("modify column `"+fieldName+"` "+restrict);
+ if(i!=entries.size()-1){
+ sb.append(",");
+ }
+ i++;
+ }
+
+ log.debug("modify fields SQL--> "+sb.toString());
+ return sb.toString();
+ }
+
+ @Override
+ public String getRestrict(KeywordsType key, Integer dataLenth, Integer limit) {
+
+ if(key.equals(KeywordsType.PRIMARYKEY)||key.equals(KeywordsType.DATE)){
+ return keywords.get(key);
+ }else if(key.equals(KeywordsType.COMPUTE)){
+ dataLenth=(dataLenth==null||dataLenth>65||dataLenth<1)?65:dataLenth;
+ limit=(limit==null||limit<1)?2:limit;
+ return keywords.get(key)+"("+dataLenth+","+limit+")";
+ }else if(key.equals(KeywordsType.NUMBER)){
+ dataLenth=dataLenth>20||dataLenth<1?20:dataLenth;
+ return keywords.get(key)+"("+dataLenth+")";
+ } else{
+ dataLenth=dataLenth==null||dataLenth<1?255:dataLenth;
+ return keywords.get(key)+"("+dataLenth+")";
+ }
+ }
+
+
+}
diff --git a/src/main/java/com/nis/util/ToolUtil.java b/src/main/java/com/nis/util/ToolUtil.java
new file mode 100644
index 0000000..d398aca
--- /dev/null
+++ b/src/main/java/com/nis/util/ToolUtil.java
@@ -0,0 +1,331 @@
+/**
+ * Copyright (c) 2015-2016, Chill Zhuang 庄骞 ([email protected]).
+ * <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 com.nis.util;
+
+
+import cn.hutool.log.Log;
+import java.lang.reflect.Array;
+import java.util.*;
+
+/**
+ * 高频方法集合类
+ */
+public class ToolUtil {
+
+ public final static Log logger = Log.get();
+ /**
+ * 字符连接符
+ */
+ private static final char SEPARATOR = '_';
+
+ /**
+ * 下划线命名 转 驼峰命名 首字母小写
+ *
+ * @param s the s
+ * @return String toCamelCase("hello_world") == "helloWorld" toCapitalizeCamelCase("hello_world") == "HelloWorld" toUnderScoreCase("helloWorld") = "hello_world"
+ */
+ public static String toCamelCase(String s) {
+ if (s == null) {
+ return null;
+ }
+
+ String ls = s.toLowerCase();
+
+ StringBuilder sb = new StringBuilder(ls.length());
+ boolean upperCase = false;
+ for (int i = 0; i < ls.length(); i++) {
+ char c = ls.charAt(i);
+
+ if (c == SEPARATOR) {
+ upperCase = true;
+ } else if (upperCase) {
+ sb.append(Character.toUpperCase(c));
+ upperCase = false;
+ } else {
+ sb.append(c);
+ }
+ }
+
+ return sb.toString();
+ }
+
+
+
+
+ /**
+ * 比较两个对象是否相等。<br>
+ * 相同的条件有两个,满足其一即可:<br>
+ * 1. obj1 == null && obj2 == null; 2. obj1.equals(obj2)
+ *
+ * @param obj1 对象1
+ * @param obj2 对象2
+ * @return 是否相等
+ */
+ public static boolean equals(Object obj1, Object obj2) {
+ return (obj1 != null) ? (obj1.equals(obj2)) : (obj2 == null);
+ }
+
+ /**
+ * 计算对象长度,如果是字符串调用其length函数,集合类调用其size函数,数组调用其length属性,其他可遍历对象遍历计算长度
+ *
+ * @param obj 被计算长度的对象
+ * @return 长度
+ */
+ public static int length(Object obj) {
+ if (obj == null) {
+ return 0;
+ }
+ if (obj instanceof CharSequence) {
+ return ((CharSequence) obj).length();
+ }
+ if (obj instanceof Collection) {
+ return ((Collection<?>) obj).size();
+ }
+ if (obj instanceof Map) {
+ return ((Map<?, ?>) obj).size();
+ }
+
+ int count;
+ if (obj instanceof Iterator) {
+ Iterator<?> iter = (Iterator<?>) obj;
+ count = 0;
+ while (iter.hasNext()) {
+ count++;
+ iter.next();
+ }
+ return count;
+ }
+ if (obj instanceof Enumeration) {
+ Enumeration<?> enumeration = (Enumeration<?>) obj;
+ count = 0;
+ while (enumeration.hasMoreElements()) {
+ count++;
+ enumeration.nextElement();
+ }
+ return count;
+ }
+ if (obj.getClass().isArray() == true) {
+ return Array.getLength(obj);
+ }
+ return -1;
+ }
+
+ /**
+ * 对象中是否包含元素
+ *
+ * @param obj 对象
+ * @param element 元素
+ * @return 是否包含
+ */
+ public static boolean contains(Object obj, Object element) {
+ if (obj == null) {
+ return false;
+ }
+ if (obj instanceof String) {
+ if (element == null) {
+ return false;
+ }
+ return ((String) obj).contains(element.toString());
+ }
+ if (obj instanceof Collection) {
+ return ((Collection<?>) obj).contains(element);
+ }
+ if (obj instanceof Map) {
+ return ((Map<?, ?>) obj).values().contains(element);
+ }
+
+ if (obj instanceof Iterator) {
+ Iterator<?> iter = (Iterator<?>) obj;
+ while (iter.hasNext()) {
+ Object o = iter.next();
+ if (equals(o, element)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ if (obj instanceof Enumeration) {
+ Enumeration<?> enumeration = (Enumeration<?>) obj;
+ while (enumeration.hasMoreElements()) {
+ Object o = enumeration.nextElement();
+ if (equals(o, element)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ if (obj.getClass().isArray() == true) {
+ int len = Array.getLength(obj);
+ for (int i = 0; i < len; i++) {
+ Object o = Array.get(obj, i);
+ if (equals(o, element)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * 对象是否不为空(新增)
+ *
+ * @param o String,List,Map,Object[],int[],long[]
+ * @return
+ */
+ public static boolean isNotEmpty(Object o) {
+ return !isEmpty(o);
+ }
+
+ /**
+ * 对象是否为空
+ *
+ * @param o String,List,Map,Object[],int[],long[]
+ * @return
+ */
+ @SuppressWarnings("rawtypes")
+ public static boolean isEmpty(Object o) {
+ if (o == null) {
+ return true;
+ }
+ if (o instanceof String) {
+ if (o.toString().trim().equals("")) {
+ return true;
+ }
+ } else if (o instanceof List) {
+ if (((List) o).size() == 0) {
+ return true;
+ }
+ } else if (o instanceof Map) {
+ if (((Map) o).size() == 0) {
+ return true;
+ }
+ } else if (o instanceof Set) {
+ if (((Set) o).size() == 0) {
+ return true;
+ }
+ } else if (o instanceof Object[]) {
+ if (((Object[]) o).length == 0) {
+ return true;
+ }
+ } else if (o instanceof int[]) {
+ if (((int[]) o).length == 0) {
+ return true;
+ }
+ } else if (o instanceof long[]) {
+ if (((long[]) o).length == 0) {
+ return true;
+ }
+ }
+ return false;
+ }
+ /**
+ * 对象组都不是empty
+ */
+ public static boolean isNotAllEmpty(Object... obj){
+ for (Object o:obj){
+ if (isEmpty(o)){
+ return false;
+ }
+ }
+ return true;
+ }
+
+
+ /**
+ * 如果为空, 则调用默认值
+ *
+ * @param str
+ * @return
+ */
+ public static Object getValue(Object str, Object defaultValue) {
+ if (isEmpty(str)) {
+ return defaultValue;
+ }
+ return str;
+ }
+
+
+
+ /**
+ * 强转->string,并去掉多余空格
+ *
+ * @param str
+ * @return
+ */
+ public static String toStr(Object str) {
+ return toStr(str, "");
+ }
+
+ /**
+ * 强转->string,并去掉多余空格
+ *
+ * @param str
+ * @param defaultValue
+ * @return
+ */
+ public static String toStr(Object str, String defaultValue) {
+ if (null == str) {
+ return defaultValue;
+ }
+ return str.toString().trim();
+ }
+
+ /**
+ * JSON字符串特殊字符处理
+ *
+ * @param s
+ * @return String
+ */
+ public static String string2Json(String s) {
+ if (isEmpty(s)) {
+ return "";
+ }
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < s.length(); i++) {
+ char c = s.charAt(i);
+ switch (c) {
+ case '\"':
+ sb.append("\\\"");
+ break;
+ case '\\':
+ sb.append("\\\\");
+ break;
+ case '/':
+ sb.append("\\/");
+ break;
+ case '\b':
+ sb.append("\\b");
+ break;
+ case '\f':
+ sb.append("\\f");
+ break;
+ case '\n':
+ sb.append("\\n");
+ break;
+ case '\r':
+ sb.append("\\r");
+ break;
+ case '\t':
+ sb.append("\\t");
+ break;
+ default:
+ sb.append(c);
+ }
+ }
+ return sb.toString();
+ }
+
+}
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
new file mode 100644
index 0000000..9d68118
--- /dev/null
+++ b/src/main/resources/application.yml
@@ -0,0 +1,29 @@
+spring:
+#logging:
+# config: ./logback-config.xml
+
+#mybatis
+mybatis-plus:
+ mapper-locations: classpath*:/mapper/*.xml
+ #实体扫描,多个package用逗号或者分号分隔
+ typeAliasesPackage: com.nis.entity
+ global-config:
+ #数据库相关配置
+ db-config:
+ #主键类型 AUTO:"数据库ID自增", INPUT:"用户输入ID", ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID";
+ id-type: AUTO
+ #字段策略 IGNORED:"忽略判断",NOT_NULL:"非 NULL 判断"),NOT_EMPTY:"非空判断"
+ field-strategy: NOT_NULL
+ #驼峰下划线转换
+ column-underline: true
+ logic-delete-value: 1
+ logic-not-delete-value: 0
+ banner: false
+ key-generator: com.nis.util.MybatisPlusConfig.SeqKeyGenerator
+ #原生配置
+ configuration:
+ map-underscore-to-camel-case: true
+ cache-enabled: false
+ call-setters-on-nulls: true
+ jdbc-type-for-null: 'null'
+
diff --git a/src/main/resources/mapper/sql.xml b/src/main/resources/mapper/sql.xml
new file mode 100644
index 0000000..ab025ca
--- /dev/null
+++ b/src/main/resources/mapper/sql.xml
@@ -0,0 +1,21 @@
+<?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.nis.dao.SqlDao">
+
+ <select id="allTables" resultType="java.lang.String">
+ show tables
+ </select>
+
+ <select id="allRemoveCopyTables" resultType="java.lang.String">
+ select CONCAT( 'drop table ', table_name, ';' ) FROM information_schema.tables Where table_name LIKE '%_copy'
+ </select>
+
+ <select id="execute">
+ ${sql}
+ </select>
+
+ <select id="allTriggers" resultType="java.lang.String">
+ select trigger_name FROM information_schema.`TRIGGERS` where trigger_schema = #{databaseName}
+ </select>
+</mapper> \ No newline at end of file