初次提交代码
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
#Server Configuration
|
||||
server.port=8189
|
||||
server.servlet.context-path=/syslogserve
|
||||
#server.address=0.0.0.0
|
||||
server.tomcat.uri-encoding=UTF-8
|
||||
server.error.include-message=always
|
||||
server.error.include-binding-errors=always
|
||||
|
||||
# Syslog Server Configuration
|
||||
syslog.tcp.port=514
|
||||
syslog.udp.port=514
|
||||
syslog.max.frame.length=262144
|
||||
syslog.buffer.size=1000
|
||||
|
||||
|
||||
# APP Service Configuration
|
||||
app.service.device_id=1
|
||||
app.service.device_name=honeypot
|
||||
app.service.vendor=changting
|
||||
app.service.product_name=diting
|
||||
#采集探针ID
|
||||
app.service.device_collect_id=${DEVICE_COLLECT_ID:1}
|
||||
# syslog message data_type
|
||||
app.service.data_type=json
|
||||
|
||||
# kafka Configuration
|
||||
spring.kafka.producer.bootstrap-servers=192.168.222.130:9092
|
||||
spring.kafka.producer.topic =test-topic
|
||||
|
||||
|
||||
#database Configuration
|
||||
spring.datasource.url=jdbc:postgresql://117.72.68.72:54329/ecosys
|
||||
spring.datasource.username=postgres
|
||||
spring.datasource.password=TnLanWaidYSwTSG5
|
||||
spring.datasource.driver-class-name=org.postgresql.Driver
|
||||
|
||||
# mybatis Configuration
|
||||
mybatis.mapper-locations=classpath:mapper/*.xml
|
||||
mybatis.type-aliases-package=com.common.entity
|
||||
mybatis.configuration.map-underscore-to-camel-case=true
|
||||
|
||||
# 开发环境缓存配置
|
||||
spring.redis.host=localhost
|
||||
spring.redis.port=6379
|
||||
# 密码(如果没有设置密码,可以省略)
|
||||
spring.redis.password=
|
||||
spring.redis.database=0
|
||||
spring.redis.timeout=2000
|
||||
|
||||
spring.redis.lettuce.pool.max-active=8
|
||||
spring.redis.lettuce.pool.max-wait=-1
|
||||
spring.redis.lettuce.pool.max-idle=8
|
||||
spring.redis.lettuce.pool.min-idle=0
|
||||
# 开发环境缓存时间较短,方便调试
|
||||
spring.cache.redis.time-to-live=600000
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
#Server Configuration [zhongcheng]
|
||||
server.port=8189
|
||||
server.servlet.context-path=/syslogserve
|
||||
#server.address=0.0.0.0
|
||||
server.tomcat.uri-encoding=UTF-8
|
||||
server.error.include-message=always
|
||||
server.error.include-binding-errors=always
|
||||
|
||||
# Syslog Server Configuration
|
||||
syslog.tcp.port=514
|
||||
syslog.udp.port=514
|
||||
syslog.max.frame.length=262144
|
||||
syslog.buffer.size=1000
|
||||
|
||||
# APP Service Configuration
|
||||
app.service.device_id=1
|
||||
app.service.device_name=honeypot
|
||||
app.service.vendor=changting
|
||||
app.service.product_name=diting
|
||||
# syslog message data_type
|
||||
app.service.data_type=json
|
||||
#采集探针ID
|
||||
#app.service.device_collect_id=${DEVICE_COLLECT_ID:2}
|
||||
app.service.device_collect_id=${DEVICE_COLLECT_ID:1}
|
||||
|
||||
# kafka Configuration
|
||||
spring.kafka.producer.bootstrap-servers=10.11.2.142:9092
|
||||
spring.kafka.producer.topic =agent-syslog-topic
|
||||
|
||||
#database Configuration
|
||||
spring.datasource.url=jdbc:postgresql://10.11.2.141:5432/ecosys
|
||||
spring.datasource.username=ecosys
|
||||
spring.datasource.password=wsYDPjrpNZPrkPrR
|
||||
spring.datasource.driver-class-name=org.postgresql.Driver
|
||||
|
||||
# mybatis Configuration
|
||||
mybatis.mapper-locations=classpath:mapper/*.xml
|
||||
mybatis.type-aliases-package=com.common.entity
|
||||
mybatis.configuration.map-underscore-to-camel-case=true
|
||||
|
||||
# 生产环境缓存配置
|
||||
spring.redis.host=10.11.2.142
|
||||
spring.redis.port=6379
|
||||
# 密码(如果没有设置密码,可以省略)
|
||||
spring.redis.password=redis_edP6N6
|
||||
spring.redis.database=0
|
||||
spring.redis.timeout=5000
|
||||
#spring.redis.password=${REDIS_PASSWORD:default_prod_password}
|
||||
|
||||
spring.redis.lettuce.pool.max-active=20
|
||||
spring.redis.lettuce.pool.max-wait=5000
|
||||
spring.redis.lettuce.pool.max-idle=10
|
||||
spring.redis.lettuce.pool.min-idle=5
|
||||
|
||||
# 生产环境缓存时间较长
|
||||
spring.cache.redis.time-to-live=3600000
|
||||
@@ -0,0 +1,55 @@
|
||||
#Server Configuration [192.168.4.26]
|
||||
server.port=8189
|
||||
server.servlet.context-path=/syslogserve
|
||||
#server.address=0.0.0.0
|
||||
server.tomcat.uri-encoding=UTF-8
|
||||
server.error.include-message=always
|
||||
server.error.include-binding-errors=always
|
||||
|
||||
# Syslog Server Configuration
|
||||
syslog.tcp.port=514
|
||||
syslog.udp.port=514
|
||||
syslog.max.frame.length=262144
|
||||
syslog.buffer.size=1000
|
||||
|
||||
# APP Service Configuration
|
||||
app.service.device_id=1
|
||||
app.service.device_name=honeypot
|
||||
app.service.vendor=changting
|
||||
app.service.product_name=diting
|
||||
# syslog message data_type
|
||||
app.service.data_type=json
|
||||
#采集探针ID
|
||||
app.service.device_collect_id=${DEVICE_COLLECT_ID:1}
|
||||
|
||||
# kafka Configuration
|
||||
spring.kafka.producer.bootstrap-servers=192.168.4.26:9092
|
||||
spring.kafka.producer.topic =agent-syslog-topic
|
||||
|
||||
#database Configuration
|
||||
spring.datasource.url=jdbc:postgresql://192.168.4.26:5432/ecosys
|
||||
spring.datasource.username=postgres
|
||||
spring.datasource.password=caZ2TcmXNSW8L2Ap
|
||||
spring.datasource.driver-class-name=org.postgresql.Driver
|
||||
|
||||
# mybatis Configuration
|
||||
mybatis.mapper-locations=classpath:mapper/*.xml
|
||||
mybatis.type-aliases-package=com.common.entity
|
||||
mybatis.configuration.map-underscore-to-camel-case=true
|
||||
|
||||
# 生产环境缓存配置
|
||||
spring.redis.host=192.168.4.26
|
||||
spring.redis.port=6379
|
||||
# 密码(如果没有设置密码,可以省略)
|
||||
spring.redis.password=123456
|
||||
spring.redis.database=0
|
||||
spring.redis.timeout=5000
|
||||
#spring.redis.password=${REDIS_PASSWORD:default_prod_password}
|
||||
|
||||
spring.redis.lettuce.pool.max-active=20
|
||||
spring.redis.lettuce.pool.max-wait=5000
|
||||
spring.redis.lettuce.pool.max-idle=10
|
||||
spring.redis.lettuce.pool.min-idle=5
|
||||
|
||||
# 生产环境缓存时间较长
|
||||
spring.cache.redis.time-to-live=3600000
|
||||
@@ -0,0 +1,59 @@
|
||||
#Server Configuration
|
||||
server.port=8189
|
||||
server.servlet.context-path=/syslogserve
|
||||
#server.address=0.0.0.0
|
||||
server.tomcat.uri-encoding=UTF-8
|
||||
server.error.include-message=always
|
||||
server.error.include-binding-errors=always
|
||||
|
||||
# Syslog Server Configuration
|
||||
syslog.tcp.port=514
|
||||
syslog.udp.port=514
|
||||
syslog.max.frame.length=65536
|
||||
syslog.buffer.size=1000
|
||||
|
||||
|
||||
# APP Service Configuration
|
||||
app.service.device_id=1
|
||||
app.service.device_name=honeypot
|
||||
app.service.vendor=changting
|
||||
app.service.product_name=diting
|
||||
# syslog message data_type
|
||||
app.service.data_type=json
|
||||
#采集探针ID
|
||||
app.service.device_collect_id=1
|
||||
|
||||
# kafka Configuration
|
||||
spring.kafka.producer.bootstrap-servers=192.168.4.32:9092
|
||||
spring.kafka.producer.topic =agent-syslog-topic
|
||||
|
||||
|
||||
|
||||
|
||||
#database Configuration
|
||||
spring.datasource.url=jdbc:postgresql://192.168.4.32:5432/ecosys
|
||||
spring.datasource.username=user_eSER8N
|
||||
spring.datasource.password=password_QCYKj6
|
||||
spring.datasource.driver-class-name=org.postgresql.Driver
|
||||
|
||||
# mybatis Configuration
|
||||
mybatis.mapper-locations=classpath:mapper/*.xml
|
||||
mybatis.type-aliases-package=com.common.entity
|
||||
mybatis.configuration.map-underscore-to-camel-case=true
|
||||
|
||||
# 生产环境缓存配置
|
||||
spring.redis.host=192.168.4.32
|
||||
spring.redis.port=6379
|
||||
# 密码(如果没有设置密码,可以省略)
|
||||
spring.redis.password=password_QCYKj6
|
||||
spring.redis.database=0
|
||||
spring.redis.timeout=5000
|
||||
#spring.redis.password=${REDIS_PASSWORD:default_prod_password}
|
||||
|
||||
spring.redis.lettuce.pool.max-active=20
|
||||
spring.redis.lettuce.pool.max-wait=5000
|
||||
spring.redis.lettuce.pool.max-idle=10
|
||||
spring.redis.lettuce.pool.min-idle=5
|
||||
|
||||
# 生产环境缓存时间较长
|
||||
spring.cache.redis.time-to-live=3600000
|
||||
@@ -0,0 +1,57 @@
|
||||
#Server Configuration
|
||||
server.port=8189
|
||||
server.servlet.context-path=/syslogserve
|
||||
#server.address=0.0.0.0
|
||||
server.tomcat.uri-encoding=UTF-8
|
||||
server.error.include-message=always
|
||||
server.error.include-binding-errors=always
|
||||
|
||||
# Syslog Server Configuration
|
||||
syslog.tcp.port=514
|
||||
syslog.udp.port=514
|
||||
syslog.max.frame.length=262144
|
||||
syslog.buffer.size=1000
|
||||
|
||||
|
||||
# APP Service Configuration
|
||||
app.service.device_id=1
|
||||
app.service.device_name=honeypot
|
||||
app.service.vendor=changting
|
||||
app.service.product_name=diting
|
||||
#采集探针ID
|
||||
app.service.device_collect_id=${DEVICE_COLLECT_ID:1}
|
||||
# syslog message data_type
|
||||
app.service.data_type=json
|
||||
|
||||
# kafka Configuration
|
||||
spring.kafka.producer.bootstrap-servers=192.168.222.130:9092
|
||||
spring.kafka.producer.topic =test-topic
|
||||
|
||||
|
||||
#database Configuration
|
||||
spring.datasource.url=jdbc:postgresql://117.72.68.72:54329/ecosys
|
||||
spring.datasource.username=postgres
|
||||
spring.datasource.password=TnLanWaidYSwTSG5
|
||||
spring.datasource.driver-class-name=org.postgresql.Driver
|
||||
|
||||
# mybatis Configuration
|
||||
mybatis.mapper-locations=classpath:mapper/*.xml
|
||||
mybatis.type-aliases-package=com.common.entity
|
||||
mybatis.configuration.map-underscore-to-camel-case=true
|
||||
|
||||
# 开发环境缓存配置
|
||||
spring.redis.host=localhost
|
||||
spring.redis.port=6379
|
||||
# 密码(如果没有设置密码,可以省略)
|
||||
spring.redis.password=
|
||||
spring.redis.database=0
|
||||
spring.redis.timeout=2000
|
||||
|
||||
spring.redis.lettuce.pool.max-active=8
|
||||
spring.redis.lettuce.pool.max-wait=-1
|
||||
spring.redis.lettuce.pool.max-idle=8
|
||||
spring.redis.lettuce.pool.min-idle=0
|
||||
# 开发环境缓存时间较短,方便调试
|
||||
spring.cache.redis.time-to-live=600000
|
||||
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<configuration >
|
||||
|
||||
<!-- 定义日志输出格式 -->
|
||||
<property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n" />
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${LOG_PATTERN}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 文件输出,每天滚动 -->
|
||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>logs/syslog-serve.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 每天滚动 -->
|
||||
<fileNamePattern>logs/syslog-serve.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 保留的日志文件的最大天数 -->
|
||||
<maxHistory>1</maxHistory>
|
||||
<!-- 所有归档日志文件的总大小上限 -->
|
||||
<totalSizeCap>15GB</totalSizeCap>
|
||||
<!-- 启动时是否清理过期日志 -->
|
||||
<cleanHistoryOnStart>true</cleanHistoryOnStart>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${LOG_PATTERN}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 设置日志级别 -->
|
||||
<root level="INFO">
|
||||
<appender-ref ref="CONSOLE" />
|
||||
<appender-ref ref="FILE" />
|
||||
</root>
|
||||
|
||||
<!-- 可以设置特定包的日志级别 -->
|
||||
<!-- 例如,将com.example包的日志级别设置为DEBUG -->
|
||||
|
||||
<!-- 专门屏蔽ProducerConfig的INFO日志 -->
|
||||
<logger name="org.apache.kafka.clients.producer.ProducerConfig" level="WARN"/>
|
||||
<!-- 更通用地屏蔽整个Kafka客户端包的INFO日志 -->
|
||||
<logger name="org.apache.kafka.clients" level="WARN"/>
|
||||
|
||||
<!-- 方法1: 设置 Kafka 相关包为 WARN 级别 -->
|
||||
<logger name="org.apache.kafka" level="WARN"/>
|
||||
<logger name="kafka" level="WARN"/>
|
||||
|
||||
<!-- 方法2: 更精确地控制特定类 -->
|
||||
<logger name="org.apache.kafka.common.utils.AppInfoParser" level="ERROR"/>
|
||||
<logger name="org.apache.kafka.common.metrics.Metrics" level="ERROR"/>
|
||||
|
||||
</configuration>
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
<?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.common.mapper.DeviceCollectTaskMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.common.entity.DeviceCollectTask">
|
||||
<id column="id" property="id" />
|
||||
<result column="created_at" property="createdAt" />
|
||||
<result column="updated_at" property="updatedAt" />
|
||||
<result column="deleted_at" property="deletedAt" />
|
||||
<result column="device_id" property="deviceId" />
|
||||
<result column="method" property="method" />
|
||||
<result column="task_name" property="taskName" />
|
||||
<result column="first_time" property="firstTime" />
|
||||
<result column="last_success_time" property="lastSuccessTime" />
|
||||
<result column="last_failed_time" property="lastFailedTime" />
|
||||
<result column="detail_id" property="detailId" />
|
||||
<result column="epm" property="epm" />
|
||||
<result column="epm_peak" property="epmPeak" />
|
||||
<result column="process_architecture" property="processArchitecture" />
|
||||
<result column="task_count" property="taskCount" />
|
||||
<result column="recent_discover_time" property="recentDiscoverTime" />
|
||||
<result column="epm_upper_limit" property="epmUpperLimit" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id, created_at, updated_at, deleted_at, device_id, method, task_name,
|
||||
first_time, last_success_time, last_failed_time, detail_id, epm, epm_peak,
|
||||
process_architecture, task_count, recent_discover_time, epm_upper_limit
|
||||
</sql>
|
||||
|
||||
<!-- 多条件组合查询 -->
|
||||
<select id="selectByCondition" parameterType="com.common.entity.DeviceCollectTask" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List" />
|
||||
FROM device_collect_task
|
||||
<where>
|
||||
<if test="deviceId != null">
|
||||
AND device_id = #{deviceId}
|
||||
</if>
|
||||
<if test="method != null">
|
||||
AND method = #{method}
|
||||
</if>
|
||||
<if test="taskName != null and taskName != ''">
|
||||
AND task_name LIKE CONCAT('%', #{taskName}, '%')
|
||||
</if>
|
||||
<if test="detailId != null">
|
||||
AND detail_id = #{detailId}
|
||||
</if>
|
||||
<if test="processArchitecture != null">
|
||||
AND process_architecture = #{processArchitecture}
|
||||
</if>
|
||||
<if test="epmUpperLimit != null">
|
||||
AND epm_upper_limit = #{epmUpperLimit}
|
||||
</if>
|
||||
<!-- 时间范围查询 -->
|
||||
<if test="firstTime != null">
|
||||
AND first_time >= #{firstTime}
|
||||
</if>
|
||||
<if test="lastSuccessTime != null">
|
||||
AND last_success_time >= #{lastSuccessTime}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY updated_at DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,238 @@
|
||||
<?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.common.mapper.DeviceDeviceMapper">
|
||||
|
||||
<!-- 基础结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="com.common.entity.DeviceDevice">
|
||||
<id column="id" property="id" />
|
||||
<result column="created_at" property="createdAt" />
|
||||
<result column="updated_at" property="updatedAt" />
|
||||
<result column="deleted_at" property="deletedAt" />
|
||||
<result column="name" property="name" />
|
||||
<result column="ip" property="ip" />
|
||||
<result column="device_group" property="deviceGroup" />
|
||||
<result column="device_type" property="deviceType" />
|
||||
<result column="vendor" property="vendor" />
|
||||
<result column="product_name" property="productName" />
|
||||
<result column="organization_id" property="organizationId" />
|
||||
<result column="last_receive_time" property="lastReceiveTime" />
|
||||
<result column="agent_id" property="agentId" />
|
||||
<result column="detail_id" property="detailId" />
|
||||
<result column="control_agent_id" property="controlAgentId" />
|
||||
<result column="license_start_time" property="licenseStartTime" />
|
||||
<result column="license_end_time" property="licenseEndTime" />
|
||||
<result column="is_monitoring" property="isMonitoring" />
|
||||
<result column="security_scope_id" property="securityScopeId" />
|
||||
<result column="owner_id" property="ownerId" />
|
||||
<result column="ssh_config_id" property="sshConfigId" />
|
||||
<result column="status" property="status" />
|
||||
<result column="created_by_id" property="createdById" />
|
||||
<result column="decode_type" property="decodeType" />
|
||||
<result column="miss_policy" property="missPolicy" />
|
||||
<result column="tenant_id" property="tenantId" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="update_time" property="updateTime" />
|
||||
<result column="create_by" property="createBy" />
|
||||
<result column="update_by" property="updateBy" />
|
||||
<result column="del_flag" property="delFlag" />
|
||||
<result column="manager_name" property="managerName" />
|
||||
<result column="today_parse_count" property="todayParseCount" />
|
||||
<result column="today_non_log_count" property="todayNonLogCount" />
|
||||
<result column="create_dept" property="createDept" />
|
||||
<result column="device_collect_id" property="deviceCollectId" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 基础查询列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, created_at::timestamp , updated_at::timestamp, deleted_at::timestamp, name, ip, device_group, device_type,
|
||||
vendor, product_name, organization_id, last_receive_time::timestamp, agent_id, detail_id,
|
||||
control_agent_id, license_start_time::timestamp, license_end_time::timestamp, is_monitoring,
|
||||
security_scope_id, owner_id, ssh_config_id, status, created_by_id, decode_type,
|
||||
miss_policy, tenant_id, create_time::timestamp, update_time::timestamp, create_by, update_by, del_flag,
|
||||
manager_name, today_parse_count, today_non_log_count, create_dept, device_collect_id
|
||||
</sql>
|
||||
|
||||
<!-- 根据ID查询 -->
|
||||
<select id="selectById" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM device_device
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- 查询所有设备 -->
|
||||
<select id="selectAll" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM device_device
|
||||
</select>
|
||||
|
||||
<!-- 根据IP查询 -->
|
||||
<select id="selectByIp" parameterType="java.lang.String" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM device_device
|
||||
WHERE ip = #{ip} and del_flag='0'
|
||||
</select>
|
||||
|
||||
<!-- 根据名称模糊查询 -->
|
||||
<select id="selectByNameLike" parameterType="java.lang.String" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM device_device
|
||||
WHERE name LIKE CONCAT('%', #{name}, '%')
|
||||
</select>
|
||||
|
||||
<!-- 根据设备组查询 -->
|
||||
<select id="selectByDeviceGroup" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM device_device
|
||||
WHERE device_group = #{deviceGroup}
|
||||
</select>
|
||||
|
||||
<!-- 根据设备类型查询 -->
|
||||
<select id="selectByDeviceType" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM device_device
|
||||
WHERE device_type = #{deviceType}
|
||||
</select>
|
||||
|
||||
<!-- 根据组织ID查询 -->
|
||||
<select id="selectByOrganizationId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM device_device
|
||||
WHERE organization_id = #{organizationId}
|
||||
</select>
|
||||
|
||||
<!-- 根据状态查询 -->
|
||||
<select id="selectByStatus" parameterType="java.lang.Short" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM device_device
|
||||
WHERE status = #{status}
|
||||
</select>
|
||||
|
||||
<!-- 多条件组合查询 -->
|
||||
<select id="selectByCondition" parameterType="com.common.entity.DeviceDevice" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM device_device
|
||||
<where>
|
||||
<if test="name != null and name != ''">
|
||||
AND name LIKE CONCAT('%', #{name}, '%')
|
||||
</if>
|
||||
<if test="ip != null and ip != ''">
|
||||
AND ip = #{ip}
|
||||
</if>
|
||||
<if test="deviceGroup != null">
|
||||
AND device_group = #{deviceGroup}
|
||||
</if>
|
||||
<if test="deviceType != null">
|
||||
AND device_type = #{deviceType}
|
||||
</if>
|
||||
<if test="vendor != null and vendor != ''">
|
||||
AND vendor = #{vendor}
|
||||
</if>
|
||||
<if test="organizationId != null">
|
||||
AND organization_id = #{organizationId}
|
||||
</if>
|
||||
<if test="status != null">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
<if test="isMonitoring != null">
|
||||
AND is_monitoring = #{isMonitoring}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY created_at DESC
|
||||
</select>
|
||||
|
||||
<!-- 动态条件查询 -->
|
||||
<select id="selectByMap" parameterType="java.util.Map" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM device_device
|
||||
<where>
|
||||
<if test="name != null">
|
||||
AND name LIKE CONCAT('%', #{name}, '%')
|
||||
</if>
|
||||
<if test="ip != null">
|
||||
AND ip = #{ip}
|
||||
</if>
|
||||
<if test="deviceGroup != null">
|
||||
AND device_group = #{deviceGroup}
|
||||
</if>
|
||||
<if test="status != null">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
<if test="vendor != null">
|
||||
AND vendor = #{vendor}
|
||||
</if>
|
||||
<if test="startTime != null">
|
||||
AND created_at >= #{startTime}
|
||||
</if>
|
||||
<if test="endTime != null">
|
||||
AND created_at <= #{endTime}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectByPage" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM device_device
|
||||
ORDER BY id
|
||||
LIMIT #{limit} OFFSET #{offset}
|
||||
</select>
|
||||
|
||||
<!-- 统计总数 -->
|
||||
<select id="count" resultType="java.lang.Long">
|
||||
SELECT COUNT(*) FROM device_device
|
||||
</select>
|
||||
|
||||
<!-- 根据条件统计 -->
|
||||
<select id="countByCondition" parameterType="com.common.entity.DeviceDevice" resultType="java.lang.Long">
|
||||
SELECT COUNT(*) FROM device_device
|
||||
<where>
|
||||
<if test="name != null and name != ''">
|
||||
AND name LIKE CONCAT('%', #{name}, '%')
|
||||
</if>
|
||||
<if test="status != null">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
<if test="isMonitoring != null">
|
||||
AND is_monitoring = #{isMonitoring}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!-- 查询监控中的设备 -->
|
||||
<select id="selectMonitoringDevices" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM device_device
|
||||
WHERE is_monitoring = true
|
||||
</select>
|
||||
|
||||
<!-- 查询未删除的设备 -->
|
||||
<select id="selectActiveDevices" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM device_device
|
||||
WHERE del_flag = '0'
|
||||
</select>
|
||||
|
||||
<!-- 根据厂商查询 -->
|
||||
<select id="selectByVendor" parameterType="java.lang.String" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM device_device
|
||||
WHERE vendor = #{vendor}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
+175
@@ -0,0 +1,175 @@
|
||||
<?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.common.mapper.DeviceReceiveLogMapper">
|
||||
|
||||
<!-- 结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="DeviceReceiveLog">
|
||||
<id column="id" property="id" />
|
||||
<result column="created_at" property="createdAt" />
|
||||
<result column="device_collect_id" property="deviceCollectId" />
|
||||
<result column="device_id" property="deviceId" />
|
||||
<result column="device_ip" property="deviceIp" />
|
||||
<result column="receive_time" property="receiveTime" />
|
||||
<result column="receive_time_str" property="receiveTimeStr" />
|
||||
<result column="syslog_message" property="syslogMessage" />
|
||||
<result column="push_success" property="pushSuccess" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 插入单条记录 -->
|
||||
<insert id="insert" parameterType="DeviceReceiveLog" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO device_receive_log (
|
||||
created_at,
|
||||
device_collect_id,
|
||||
device_id,
|
||||
device_ip,
|
||||
receive_time,
|
||||
receive_time_str,
|
||||
syslog_message,
|
||||
push_success
|
||||
) VALUES (
|
||||
COALESCE(#{createdAt}, NOW() AT TIME ZONE 'utc'),
|
||||
#{deviceCollectId},
|
||||
#{deviceId},
|
||||
#{deviceIp}::inet,
|
||||
#{receiveTime},
|
||||
#{receiveTimeStr},
|
||||
#{syslogMessage},
|
||||
#{pushSuccess}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 批量插入(高性能) -->
|
||||
<insert id="batchInsert" parameterType="java.util.List">
|
||||
INSERT INTO device_receive_log (
|
||||
created_at,
|
||||
device_collect_id,
|
||||
device_id,
|
||||
device_ip,
|
||||
receive_time,
|
||||
receive_time_str,
|
||||
syslog_message,
|
||||
push_success
|
||||
) VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
COALESCE(#{item.createdAt}, NOW() AT TIME ZONE 'utc'),
|
||||
#{item.deviceCollectId},
|
||||
#{item.deviceId},
|
||||
#{item.deviceIp}::inet,
|
||||
#{item.receiveTime},
|
||||
#{item.receiveTimeStr},
|
||||
#{item.syslogMessage},
|
||||
#{item.pushSuccess}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 根据ID查询 -->
|
||||
<select id="selectById" resultMap="BaseResultMap">
|
||||
SELECT * FROM device_receive_log
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- 根据设备ID查询 -->
|
||||
<select id="selectByDeviceId" resultMap="BaseResultMap">
|
||||
SELECT * FROM device_receive_log
|
||||
WHERE device_id = #{deviceId}
|
||||
ORDER BY receive_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 根据采集探针ID查询 -->
|
||||
<select id="selectByCollectId" resultMap="BaseResultMap">
|
||||
SELECT * FROM device_receive_log
|
||||
WHERE device_collect_id = #{collectId}
|
||||
ORDER BY receive_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 根据IP地址查询(使用PostgreSQL的inet操作符) -->
|
||||
<select id="selectByDeviceIp" resultMap="BaseResultMap">
|
||||
SELECT * FROM device_receive_log
|
||||
WHERE device_ip >>= #{deviceIp}::inet
|
||||
ORDER BY receive_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 根据时间范围查询(利用created_at索引) -->
|
||||
<select id="selectByTimeRange" resultMap="BaseResultMap">
|
||||
SELECT * FROM device_receive_log
|
||||
WHERE created_at BETWEEN #{startTime} AND #{endTime}
|
||||
ORDER BY created_at DESC
|
||||
</select>
|
||||
|
||||
<!-- 多条件组合查询(动态SQL) -->
|
||||
<select id="selectByCondition" parameterType="DeviceReceiveLog" resultMap="BaseResultMap">
|
||||
SELECT * FROM device_receive_log
|
||||
<where>
|
||||
<if test="deviceId != null">
|
||||
AND device_id = #{deviceId}
|
||||
</if>
|
||||
<if test="deviceCollectId != null">
|
||||
AND device_collect_id = #{deviceCollectId}
|
||||
</if>
|
||||
<if test="deviceIp != null and deviceIp != ''">
|
||||
AND device_ip >>= #{deviceIp}::inet
|
||||
</if>
|
||||
<if test="receiveTime != null">
|
||||
AND receive_time >= #{receiveTime}
|
||||
</if>
|
||||
<if test="syslogMessage != null and syslogMessage != ''">
|
||||
AND syslog_message LIKE CONCAT('%', #{syslogMessage}, '%')
|
||||
</if>
|
||||
<if test="pushSuccess != null and pushSuccess != ''">
|
||||
AND push_success = #{pushSuccess}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY created_at DESC
|
||||
</select>
|
||||
|
||||
<!-- 统计数量 -->
|
||||
<select id="countByCondition" parameterType="DeviceReceiveLog" resultType="java.lang.Long">
|
||||
SELECT COUNT(*) FROM device_receive_log
|
||||
<where>
|
||||
<if test="deviceId != null">
|
||||
AND device_id = #{deviceId}
|
||||
</if>
|
||||
<if test="deviceCollectId != null">
|
||||
AND device_collect_id = #{deviceCollectId}
|
||||
</if>
|
||||
<if test="deviceIp != null and deviceIp != ''">
|
||||
AND device_ip >>= #{deviceIp}::inet
|
||||
</if>
|
||||
<if test="receiveTime != null">
|
||||
AND receive_time >= #{receiveTime}
|
||||
</if>
|
||||
<if test="pushSuccess != null">
|
||||
AND push_success >= #{pushSuccess}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!-- 删除时间范围内的数据 -->
|
||||
<delete id="deleteByTimeRange">
|
||||
DELETE FROM device_receive_log
|
||||
WHERE created_at BETWEEN #{startTime} AND #{endTime}
|
||||
</delete>
|
||||
|
||||
<!-- 获取最近N条记录 -->
|
||||
<select id="selectRecent" resultMap="BaseResultMap">
|
||||
SELECT * FROM device_receive_log
|
||||
ORDER BY created_at DESC
|
||||
LIMIT #{limit}
|
||||
</select>
|
||||
|
||||
<!-- 按设备分组统计 -->
|
||||
<select id="countByDeviceGroup" resultType="java.util.Map">
|
||||
SELECT
|
||||
device_id,
|
||||
COUNT(*) as log_count,
|
||||
MIN(receive_time) as first_receive_time,
|
||||
MAX(receive_time) as last_receive_time
|
||||
FROM device_receive_log
|
||||
GROUP BY device_id
|
||||
ORDER BY log_count DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,294 @@
|
||||
<?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.common.mapper.DeviceUnknownMapper">
|
||||
|
||||
<!-- 通用查询结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="com.common.entity.DeviceUnknown">
|
||||
<id column="id" property="id" jdbcType="BIGINT"/>
|
||||
<result column="created_at" property="createdAt" jdbcType="TIMESTAMP"/>
|
||||
<result column="device_collect_id" property="deviceCollectId" jdbcType="INTEGER"/>
|
||||
<result column="device_collect_name" property="deviceCollectName" jdbcType="VARCHAR"/>
|
||||
<result column="device_ip" property="deviceIp" jdbcType="VARCHAR"/>
|
||||
<result column="first_time" property="firstTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="last_time" property="lastTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="organization_id" property="organizationId" jdbcType="INTEGER"/>
|
||||
<result column="network_protocol" property="networkProtocol" jdbcType="VARCHAR"/>
|
||||
<result column="source_method" property="sourceMethod" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 插入设备记录 -->
|
||||
<insert id="insert" parameterType="com.common.entity.DeviceUnknown"
|
||||
useGeneratedKeys="true" keyProperty="id" keyColumn="id">
|
||||
INSERT INTO device_unknown (
|
||||
created_at,
|
||||
device_collect_id,
|
||||
device_collect_name,
|
||||
device_ip,
|
||||
first_time,
|
||||
last_time,
|
||||
organization_id,
|
||||
network_protocol,
|
||||
source_method
|
||||
) VALUES (
|
||||
COALESCE(#{createdAt}, NOW() AT TIME ZONE 'utc'),
|
||||
#{deviceCollectId},
|
||||
#{deviceCollectName},
|
||||
#{deviceIp}::inet,
|
||||
#{firstTime},
|
||||
#{lastTime},
|
||||
#{organizationId},
|
||||
#{networkProtocol},
|
||||
#{sourceMethod}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 批量插入设备记录 -->
|
||||
<insert id="batchInsert" parameterType="java.util.List">
|
||||
INSERT INTO device_unknown (
|
||||
created_at,
|
||||
device_collect_id,
|
||||
device_collect_name,
|
||||
device_ip,
|
||||
first_time,
|
||||
last_time,
|
||||
organization_id,
|
||||
network_protocol,
|
||||
source_method
|
||||
) VALUES
|
||||
<foreach collection="devices" item="device" separator=",">
|
||||
(
|
||||
COALESCE(#{device.createdAt}, NOW() AT TIME ZONE 'utc'),
|
||||
#{device.deviceCollectId},
|
||||
#{device.deviceCollectName},
|
||||
#{device.deviceIp}::inet,
|
||||
#{device.firstTime},
|
||||
#{device.lastTime},
|
||||
#{device.organizationId},
|
||||
#{device.networkProtocol},
|
||||
#{device.sourceMethod}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 根据ID查询设备 -->
|
||||
<select id="selectById" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
id,
|
||||
created_at,
|
||||
device_collect_id,
|
||||
device_collect_name,
|
||||
device_ip::text as device_ip,
|
||||
first_time,
|
||||
last_time,
|
||||
organization_id,
|
||||
network_protocol,
|
||||
source_method
|
||||
FROM device_unknown
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- 根据IP查询设备 -->
|
||||
<select id="selectByIp" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
id,
|
||||
created_at,
|
||||
device_collect_id,
|
||||
device_collect_name,
|
||||
device_ip::text as device_ip,
|
||||
first_time,
|
||||
last_time,
|
||||
organization_id,
|
||||
network_protocol,
|
||||
source_method
|
||||
FROM device_unknown
|
||||
WHERE device_ip = #{deviceIp}::inet
|
||||
ORDER BY last_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 根据组织ID查询设备 -->
|
||||
<select id="selectByOrganizationId" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
id,
|
||||
created_at,
|
||||
device_collect_id,
|
||||
device_collect_name,
|
||||
device_ip::text as device_ip,
|
||||
first_time,
|
||||
last_time,
|
||||
organization_id,
|
||||
network_protocol,
|
||||
source_method
|
||||
FROM device_unknown
|
||||
WHERE organization_id = #{organizationId}
|
||||
ORDER BY last_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 查询所有设备 -->
|
||||
<select id="selectAll" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
id,
|
||||
created_at,
|
||||
device_collect_id,
|
||||
device_collect_name,
|
||||
device_ip::text as device_ip,
|
||||
first_time,
|
||||
last_time,
|
||||
organization_id,
|
||||
network_protocol,
|
||||
source_method
|
||||
FROM device_unknown
|
||||
ORDER BY last_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 分页查询设备 -->
|
||||
<select id="selectPage" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
id,
|
||||
created_at,
|
||||
device_collect_id,
|
||||
device_collect_name,
|
||||
device_ip::text as device_ip,
|
||||
first_time,
|
||||
last_time,
|
||||
organization_id,
|
||||
network_protocol,
|
||||
source_method
|
||||
FROM device_unknown
|
||||
ORDER BY last_time DESC
|
||||
LIMIT #{limit} OFFSET #{offset}
|
||||
</select>
|
||||
|
||||
<!-- 根据条件查询设备 -->
|
||||
<select id="selectByCondition" parameterType="com.common.entity.DeviceUnknown"
|
||||
resultMap="BaseResultMap">
|
||||
SELECT
|
||||
id,
|
||||
created_at,
|
||||
device_collect_id,
|
||||
device_collect_name,
|
||||
device_ip::text as device_ip,
|
||||
first_time,
|
||||
last_time,
|
||||
organization_id,
|
||||
network_protocol,
|
||||
source_method
|
||||
FROM device_unknown
|
||||
<where>
|
||||
<if test="deviceCollectId != null">
|
||||
AND device_collect_id = #{deviceCollectId}
|
||||
</if>
|
||||
<if test="deviceCollectName != null and deviceCollectName != ''">
|
||||
AND device_collect_name ILIKE CONCAT('%', #{deviceCollectName}, '%')
|
||||
</if>
|
||||
<if test="deviceIp != null and deviceIp != ''">
|
||||
AND device_ip = #{deviceIp}::inet
|
||||
</if>
|
||||
<if test="organizationId != null">
|
||||
AND organization_id = #{organizationId}
|
||||
</if>
|
||||
<if test="networkProtocol != null and networkProtocol != ''">
|
||||
AND network_protocol = #{networkProtocol}
|
||||
</if>
|
||||
<if test="sourceMethod != null and sourceMethod != ''">
|
||||
AND source_method = #{sourceMethod}
|
||||
</if>
|
||||
<if test="firstTime != null">
|
||||
AND first_time >= #{firstTime}
|
||||
</if>
|
||||
<if test="lastTime != null">
|
||||
AND last_time >= #{lastTime}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY last_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 根据ID更新设备信息 -->
|
||||
<update id="updateById" parameterType="com.common.entity.DeviceUnknown">
|
||||
UPDATE device_unknown
|
||||
<set>
|
||||
<if test="deviceCollectId != null">
|
||||
device_collect_id = #{deviceCollectId},
|
||||
</if>
|
||||
<if test="deviceCollectName != null and deviceCollectName != ''">
|
||||
device_collect_name = #{deviceCollectName},
|
||||
</if>
|
||||
<if test="deviceIp != null and deviceIp != ''">
|
||||
device_ip = #{deviceIp}::inet,
|
||||
</if>
|
||||
<if test="firstTime != null">
|
||||
first_time = #{firstTime},
|
||||
</if>
|
||||
<if test="lastTime != null">
|
||||
last_time = #{lastTime},
|
||||
</if>
|
||||
<if test="organizationId != null">
|
||||
organization_id = #{organizationId},
|
||||
</if>
|
||||
<if test="networkProtocol != null and networkProtocol != ''">
|
||||
network_protocol = #{networkProtocol},
|
||||
</if>
|
||||
<if test="sourceMethod != null and sourceMethod != ''">
|
||||
source_method = #{sourceMethod},
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<!-- 更新最后发现时间 -->
|
||||
<update id="updateLastTime">
|
||||
UPDATE device_unknown
|
||||
SET last_time = #{lastTime}
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<!-- 根据ID删除设备 -->
|
||||
<delete id="deleteById">
|
||||
DELETE FROM device_unknown
|
||||
WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
<!-- 根据组织ID删除设备 -->
|
||||
<delete id="deleteByOrganizationId">
|
||||
DELETE FROM device_unknown
|
||||
WHERE organization_id = #{organizationId}
|
||||
</delete>
|
||||
|
||||
<!-- 统计设备数量 -->
|
||||
<select id="count" resultType="java.lang.Long">
|
||||
SELECT COUNT(*) FROM device_unknown
|
||||
</select>
|
||||
|
||||
<!-- 根据条件统计设备数量 -->
|
||||
<select id="countByCondition" parameterType="com.common.entity.DeviceUnknown"
|
||||
resultType="java.lang.Long">
|
||||
SELECT COUNT(*) FROM device_unknown
|
||||
<where>
|
||||
<if test="deviceCollectId != null">
|
||||
AND device_collect_id = #{deviceCollectId}
|
||||
</if>
|
||||
<if test="deviceCollectName != null and deviceCollectName != ''">
|
||||
AND device_collect_name ILIKE CONCAT('%', #{deviceCollectName}, '%')
|
||||
</if>
|
||||
<if test="deviceIp != null and deviceIp != ''">
|
||||
AND device_ip = #{deviceIp}::inet
|
||||
</if>
|
||||
<if test="organizationId != null">
|
||||
AND organization_id = #{organizationId}
|
||||
</if>
|
||||
<if test="networkProtocol != null and networkProtocol != ''">
|
||||
AND network_protocol = #{networkProtocol}
|
||||
</if>
|
||||
<if test="sourceMethod != null and sourceMethod != ''">
|
||||
AND source_method = #{sourceMethod}
|
||||
</if>
|
||||
<if test="firstTime != null">
|
||||
AND first_time >= #{firstTime}
|
||||
</if>
|
||||
<if test="lastTime != null">
|
||||
AND last_time >= #{lastTime}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user