1、新增功能探针联动处置、心跳在线检测
2、syslog-consumer模块拆分 syslog-consumer-rule模块实现日志数据消费、解析、泛化入库。
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
package com.common.entity;
|
||||
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public class Alarm {
|
||||
private String id;
|
||||
private LocalDateTime createdAt;
|
||||
private String alarmName;
|
||||
private String alarmLevel;
|
||||
private String alarmType;
|
||||
private String alarmMajorType;
|
||||
private String alarmMinorType;
|
||||
private Integer alarmAreaId;
|
||||
private String[] attackIp;
|
||||
private String[] victimIp;
|
||||
private String[] victimWebUrl;
|
||||
private Integer[] attackChainPhase;
|
||||
private Integer[] deviceId;
|
||||
private String[] tag;
|
||||
private String comment;
|
||||
private String[] originLogIds;
|
||||
private String queryId;
|
||||
private Integer judgedState;
|
||||
private Integer disposedState;
|
||||
private String dispositionAdvice;
|
||||
private Integer attackResult;
|
||||
private Integer fall;
|
||||
private byte[] payload;
|
||||
private Integer[] operateEvent;
|
||||
private Integer[] attackPort;
|
||||
private Integer[] victimPort;
|
||||
private String attackMethod;
|
||||
private String businessExt;
|
||||
private LocalDateTime logStartAt;
|
||||
private LocalDateTime logEndAt;
|
||||
private String httpStatus;
|
||||
private String dnsInfo;
|
||||
private String accountInfo;
|
||||
private String attackerInfo;
|
||||
private String victimInfo;
|
||||
private String suspiciousAction;
|
||||
private String vulnInfo;
|
||||
private String weakPwd;
|
||||
private String complianceBaseline;
|
||||
private String fileInfo;
|
||||
private String fileTags;
|
||||
private String endpointInfo;
|
||||
private String endpointProtection;
|
||||
private String originInfo;
|
||||
private String protocolInfo;
|
||||
private String emailInfo;
|
||||
private String sensitiveData;
|
||||
private Integer hitIntelligence;
|
||||
private String windowTime;
|
||||
private LocalDateTime updatedAt;
|
||||
private String engineType;
|
||||
private String attackIpPic;
|
||||
private String victimIpPic;
|
||||
private LocalDateTime operationAt;
|
||||
private String attackDirection;
|
||||
private LocalDateTime etlTime;
|
||||
private Integer logCount;
|
||||
private Integer isAssetHit;
|
||||
private Boolean focused;
|
||||
private Boolean baseFocused;
|
||||
private Boolean isUpdated;
|
||||
private int alarmSource;
|
||||
private String[] httpReqHeader;
|
||||
private String[] httpReqBody;
|
||||
private String[] httpRespHeader;
|
||||
private String[] httpRespBody;
|
||||
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
package com.common.entity;
|
||||
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public class AlarmVisit {
|
||||
private String id;
|
||||
private LocalDateTime createdAt;
|
||||
private String alarmName;
|
||||
private String alarmLevel;
|
||||
private String alarmType;
|
||||
private String alarmMajorType;
|
||||
private String alarmMinorType;
|
||||
private Integer alarmAreaId;
|
||||
private String[] attackIp;
|
||||
private String[] victimIp;
|
||||
private String[] victimWebUrl;
|
||||
private Integer[] attackChainPhase;
|
||||
private Integer[] deviceId;
|
||||
private String[] tag;
|
||||
private String comment;
|
||||
private String[] originLogIds;
|
||||
private String queryId;
|
||||
private Integer judgedState;
|
||||
private Integer disposedState;
|
||||
private String dispositionAdvice;
|
||||
private Integer attackResult;
|
||||
private Integer fall;
|
||||
private byte[] payload;
|
||||
private Integer[] operateEvent;
|
||||
private Integer[] attackPort;
|
||||
private Integer[] victimPort;
|
||||
private String attackMethod;
|
||||
private String businessExt;
|
||||
private LocalDateTime logStartAt;
|
||||
private LocalDateTime logEndAt;
|
||||
private String httpStatus;
|
||||
private String dnsInfo;
|
||||
private String accountInfo;
|
||||
private String attackerInfo;
|
||||
private String victimInfo;
|
||||
private String suspiciousAction;
|
||||
private String vulnInfo;
|
||||
private String weakPwd;
|
||||
private String complianceBaseline;
|
||||
private String fileInfo;
|
||||
private String fileTags;
|
||||
private String endpointInfo;
|
||||
private String endpointProtection;
|
||||
private String originInfo;
|
||||
private String protocolInfo;
|
||||
private String emailInfo;
|
||||
private String sensitiveData;
|
||||
private Integer hitIntelligence;
|
||||
private String windowTime;
|
||||
private LocalDateTime updatedAt;
|
||||
private String engineType;
|
||||
private String attackIpPic;
|
||||
private String victimIpPic;
|
||||
private LocalDateTime operationAt;
|
||||
private String attackDirection;
|
||||
private LocalDateTime etlTime;
|
||||
private Integer logCount;
|
||||
private Integer isAssetHit;
|
||||
private Boolean focused;
|
||||
private Boolean baseFocused;
|
||||
private Boolean isUpdated;
|
||||
private int alarmSource;
|
||||
private String[] httpReqHeader;
|
||||
private String[] httpReqBody;
|
||||
private String[] httpRespHeader;
|
||||
private String[] httpRespBody;
|
||||
}
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
package com.common.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* 分析规则实体类
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AnalysisAnalysisRule {
|
||||
|
||||
/**
|
||||
* 规则唯一标识(UUID)
|
||||
*/
|
||||
private String ruleId;
|
||||
|
||||
/**
|
||||
* 创建用户账号
|
||||
*/
|
||||
private String createUser;
|
||||
|
||||
/**
|
||||
* 规则名称(界面显示用)
|
||||
*/
|
||||
private String ruleName;
|
||||
|
||||
/**
|
||||
* 分析方式:高级版/基础版
|
||||
*/
|
||||
private String analysisMethod;
|
||||
|
||||
/**
|
||||
* 运行模式:realtime-实时流式/offline-离线批处理
|
||||
*/
|
||||
private String runMode;
|
||||
|
||||
/**
|
||||
* 规则输出类型:risk_alarm-风险告警/statistics-统计报表
|
||||
*/
|
||||
private String ruleOutput;
|
||||
|
||||
/**
|
||||
* 所属组织机构编码
|
||||
*/
|
||||
private String organization;
|
||||
|
||||
/**
|
||||
* 任务状态:running-正在执行/stopped-已停止/waiting-等待中
|
||||
*/
|
||||
private String taskStatus;
|
||||
|
||||
/**
|
||||
* 创建部门ID
|
||||
*/
|
||||
private Long createDept;
|
||||
|
||||
/**
|
||||
* 删除标志:0-未删除 1-已删除
|
||||
*/
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 记录创建时间(带时区)
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 记录更新时间(带时区)
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新人ID
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 规则备注说明文本
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 多租户隔离ID
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 规则详细描述
|
||||
*/
|
||||
private String ruleDesc;
|
||||
|
||||
/**
|
||||
* 规则分类编码(预留扩展用)
|
||||
*/
|
||||
private Integer ruleType;
|
||||
|
||||
/**
|
||||
* 规则启用状态(0-禁用/1-启用等)
|
||||
*/
|
||||
private Integer ruleStatus;
|
||||
|
||||
/**
|
||||
* 规则配置内容(JSON或结构化文本)
|
||||
*/
|
||||
private String ruleContent;
|
||||
|
||||
/**
|
||||
* 规则计算表达式(如SQL片段或自定义脚本)
|
||||
*/
|
||||
private String ruleExpression;
|
||||
|
||||
/**
|
||||
* 规则执行优先级(数值越大优先级越高)
|
||||
*/
|
||||
private Long priority;
|
||||
|
||||
/**
|
||||
* 规则标签,多个标签用逗号分隔
|
||||
*/
|
||||
private String tags;
|
||||
|
||||
/**
|
||||
* 规则版本号,用于版本管理
|
||||
*/
|
||||
private Integer version;
|
||||
|
||||
/**
|
||||
* 分组ID
|
||||
*/
|
||||
private Integer subsetId;
|
||||
}
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
package com.common.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 分析字段配置实体类
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AnalysisField {
|
||||
|
||||
/**
|
||||
* 主键ID,自增序列
|
||||
*/
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 关联的规则配置UUID
|
||||
*/
|
||||
private String ruleId;
|
||||
|
||||
/**
|
||||
* 字段类型(如维度/指标/计算字段等)
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 数据源名称,如数据库连接名或数据流标识
|
||||
*/
|
||||
private String dataSource;
|
||||
|
||||
/**
|
||||
* 数据库名称
|
||||
*/
|
||||
private String database;
|
||||
|
||||
/**
|
||||
* 表名
|
||||
*/
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 表别名,用于SQL语句中的表引用
|
||||
*/
|
||||
private String tableAlias;
|
||||
|
||||
/**
|
||||
* 字段名
|
||||
*/
|
||||
private String columnName;
|
||||
|
||||
/**
|
||||
* 字段描述
|
||||
*/
|
||||
private String columnDesc;
|
||||
|
||||
/**
|
||||
* 字段数据类型(如int/varchar/decimal等)
|
||||
*/
|
||||
private String dataType;
|
||||
|
||||
/**
|
||||
* 计算函数名(如SUM/COUNT/自定义函数,NULL表示原始字段)
|
||||
*/
|
||||
private String fn;
|
||||
|
||||
/**
|
||||
* 函数参数列表,JSON数组格式(即使无参数也保留空数组)
|
||||
*/
|
||||
private String arguments;
|
||||
|
||||
/**
|
||||
* 字段显示占位符(用于前端展示的默认文本)
|
||||
*/
|
||||
private String placeholder;
|
||||
|
||||
/**
|
||||
* 基础类型编码(预留分类扩展用)
|
||||
*/
|
||||
private Integer baseType;
|
||||
|
||||
/**
|
||||
* 字段分类ID
|
||||
*/
|
||||
private Integer categoryId;
|
||||
|
||||
/**
|
||||
* 创建部门ID
|
||||
*/
|
||||
private Long createDept;
|
||||
|
||||
/**
|
||||
* 删除标志(0-未删除/1-已删除)
|
||||
*/
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 记录创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 记录更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新人ID
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 备注说明
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 租户ID,默认000000表示系统级配置
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 告警字段名(别名)
|
||||
*/
|
||||
private String alarmColumnName;
|
||||
|
||||
/**
|
||||
* 告警字段描述
|
||||
*/
|
||||
private String alarmColumnDesc;
|
||||
}
|
||||
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
package com.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 分析过滤条件实体类
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("analysis_filter")
|
||||
public class AnalysisFilter {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 规则ID
|
||||
*/
|
||||
private String ruleId;
|
||||
|
||||
/**
|
||||
* 数据源
|
||||
*/
|
||||
private String dataSource;
|
||||
|
||||
/**
|
||||
* 数据库名
|
||||
*/
|
||||
private String database;
|
||||
|
||||
/**
|
||||
* 表名
|
||||
*/
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 表别名
|
||||
*/
|
||||
private String tableAlias;
|
||||
|
||||
/**
|
||||
* 列名
|
||||
*/
|
||||
private String columnName;
|
||||
|
||||
/**
|
||||
* 列描述
|
||||
*/
|
||||
private String columnDesc;
|
||||
|
||||
/**
|
||||
* 数据类型
|
||||
*/
|
||||
private String dataType;
|
||||
|
||||
/**
|
||||
* 函数名
|
||||
*/
|
||||
private String fn;
|
||||
|
||||
/**
|
||||
* 函数参数
|
||||
*/
|
||||
private Object arguments;
|
||||
|
||||
/**
|
||||
* 操作符
|
||||
*/
|
||||
private String operator;
|
||||
|
||||
/**
|
||||
* 筛选值
|
||||
*/
|
||||
private Object value;
|
||||
|
||||
/**
|
||||
* 基础类型
|
||||
*/
|
||||
private Integer baseType;
|
||||
|
||||
/**
|
||||
* 分类ID
|
||||
*/
|
||||
private Integer categoryId;
|
||||
|
||||
/**
|
||||
* 创建部门ID
|
||||
*/
|
||||
private Long createDept;
|
||||
|
||||
/**
|
||||
* 删除标志:0-正常 1-删除
|
||||
*/
|
||||
@TableLogic
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新人ID
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 备注信息
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 关联条件逻辑表ID
|
||||
*/
|
||||
private Integer condId;
|
||||
|
||||
/**
|
||||
* 表达式执行顺序号
|
||||
*/
|
||||
private Integer seqNum;
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
package com.common.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 分组规则配置实体类
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AnalysisGroupBy {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 规则ID
|
||||
*/
|
||||
private String ruleId;
|
||||
|
||||
/**
|
||||
* 分组类型:1-标准分组 2-窗口分组
|
||||
*/
|
||||
private Integer groupType;
|
||||
|
||||
/**
|
||||
* 窗口类型:tumble/hop/session
|
||||
*/
|
||||
private String windowType;
|
||||
|
||||
/**
|
||||
* 窗口配置(关联AnalysisGroupByWindow)
|
||||
*/
|
||||
private AnalysisGroupByWindow window;
|
||||
|
||||
/**
|
||||
* 创建部门
|
||||
*/
|
||||
private Long createDept;
|
||||
|
||||
/**
|
||||
* 删除标志:0-未删除,1-已删除
|
||||
*/
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private String updateTime;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
}
|
||||
+133
@@ -0,0 +1,133 @@
|
||||
package com.common.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 分析分组字段配置实体类
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AnalysisGroupByColumn {
|
||||
|
||||
/**
|
||||
* 主键ID:自增唯一标识符
|
||||
*/
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 分组ID:关联分析分组的外键
|
||||
*/
|
||||
private Integer groupById;
|
||||
|
||||
/**
|
||||
* 数据源名称:数据来源系统标识
|
||||
*/
|
||||
private String dataSource;
|
||||
|
||||
/**
|
||||
* 数据库名称:字段所在的数据库
|
||||
*/
|
||||
private String database;
|
||||
|
||||
/**
|
||||
* 表名:字段所在的物理表名
|
||||
*/
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 表别名:查询时使用的表别名
|
||||
*/
|
||||
private String tableAlias;
|
||||
|
||||
/**
|
||||
* 字段名:物理字段名称
|
||||
*/
|
||||
private String columnName;
|
||||
|
||||
/**
|
||||
* 字段描述:业务层面的字段说明
|
||||
*/
|
||||
private String columnDesc;
|
||||
|
||||
/**
|
||||
* 数据类型:字段的数据类型(如varchar、int4)
|
||||
*/
|
||||
private String dataType;
|
||||
|
||||
/**
|
||||
* 基础类型:字段的业务基础类型编码
|
||||
*/
|
||||
private Integer baseType;
|
||||
|
||||
/**
|
||||
* 分类ID:字段所属的业务分类ID
|
||||
*/
|
||||
private Integer categoryId;
|
||||
|
||||
/**
|
||||
* 创建部门:创建记录的部门ID
|
||||
*/
|
||||
private Long createDept;
|
||||
|
||||
/**
|
||||
* 删除标志:0-未删除,1-已删除
|
||||
*/
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 创建时间:记录创建时间戳
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间:记录最后更新时间戳
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人:记录创建者ID
|
||||
*/
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新人:记录最后更新者ID
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 备注:扩展说明信息
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 租户ID:多租户环境下的租户标识
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 规则ID:关联的业务规则UUID
|
||||
*/
|
||||
private String ruleId;
|
||||
|
||||
/**
|
||||
* 用户组ID:关联的权限用户组ID
|
||||
*/
|
||||
private Long groupId;
|
||||
|
||||
/**
|
||||
* 字段唯一ID:跨表唯一的字段标识符
|
||||
*/
|
||||
private Long fieldId;
|
||||
|
||||
/**
|
||||
* 排序号:字段展示顺序
|
||||
*/
|
||||
private Integer sort;
|
||||
}
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
package com.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 分析分组聚合条件配置实体类
|
||||
* 存储GROUP BY后的HAVING筛选条件定义
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("analysis_group_by_having")
|
||||
public class AnalysisGroupByHaving {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 分组ID
|
||||
*/
|
||||
private Integer groupById;
|
||||
|
||||
/**
|
||||
* 数据源名称
|
||||
*/
|
||||
private String dataSource;
|
||||
|
||||
/**
|
||||
* 数据库名称
|
||||
*/
|
||||
private String database;
|
||||
|
||||
/**
|
||||
* 表名
|
||||
*/
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 表别名
|
||||
*/
|
||||
private String tableAlias;
|
||||
|
||||
/**
|
||||
* 字段名
|
||||
*/
|
||||
private String columnName;
|
||||
|
||||
/**
|
||||
* 字段描述
|
||||
*/
|
||||
private String columnDesc;
|
||||
|
||||
/**
|
||||
* 字段数据类型
|
||||
*/
|
||||
private String dataType;
|
||||
|
||||
/**
|
||||
* 聚合函数名(如SUM/COUNT/AVG等)
|
||||
*/
|
||||
private String fn;
|
||||
|
||||
/**
|
||||
* 聚合函数参数列表,JSON数组格式
|
||||
*/
|
||||
private Object arguments;
|
||||
|
||||
/**
|
||||
* 比较运算符(如>、<、=、>=、<=、IN、LIKE等)
|
||||
*/
|
||||
private String operator;
|
||||
|
||||
/**
|
||||
* 比较值,JSON格式存储
|
||||
*/
|
||||
private Object value;
|
||||
|
||||
/**
|
||||
* 基础类型标识
|
||||
*/
|
||||
private Integer baseType;
|
||||
|
||||
/**
|
||||
* 分类ID,用于条件分组归类
|
||||
*/
|
||||
private Integer categoryId;
|
||||
|
||||
/**
|
||||
* 创建部门ID
|
||||
*/
|
||||
private Long createDept;
|
||||
|
||||
/**
|
||||
* 删除标志:0-未删除 1-已删除
|
||||
*/
|
||||
@TableLogic
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 记录创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 记录更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新人ID
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 备注说明
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
}
|
||||
+139
@@ -0,0 +1,139 @@
|
||||
package com.common.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 分析时间窗口配置实体类
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AnalysisGroupByWindow {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 分组ID
|
||||
*/
|
||||
private Integer groupById;
|
||||
|
||||
/**
|
||||
* 窗口类型:tumble/hop/session
|
||||
*/
|
||||
private String windowType;
|
||||
|
||||
// ============ 滚动窗口配置 ============
|
||||
|
||||
/**
|
||||
* 滚动窗口时间类型:second/minute/hour
|
||||
*/
|
||||
private String tumbleWindowTimeType;
|
||||
|
||||
/**
|
||||
* 滚动窗口大小
|
||||
*/
|
||||
private Integer tumbleWindowSize;
|
||||
|
||||
/**
|
||||
* 滚动窗口单位:s/m/h/d
|
||||
*/
|
||||
private String tumbleWindowSizeUnit;
|
||||
|
||||
// ============ 滑动窗口配置 ============
|
||||
|
||||
/**
|
||||
* 滑动窗口时间类型
|
||||
*/
|
||||
private String hopWindowTimeType;
|
||||
|
||||
/**
|
||||
* 滑动窗口大小
|
||||
*/
|
||||
private Integer hopWindowSize;
|
||||
|
||||
/**
|
||||
* 滑动窗口单位:s/m/h/d
|
||||
*/
|
||||
private String hopWindowSizeUnit;
|
||||
|
||||
/**
|
||||
* 滑动窗口步长
|
||||
*/
|
||||
private Integer hopWindowSlide;
|
||||
|
||||
/**
|
||||
* 滑动窗口步长单位:s/m/h/d
|
||||
*/
|
||||
private String hopWindowSlideUnit;
|
||||
|
||||
/**
|
||||
* 滑动窗口告警频率:是否每个窗口仅告警一次
|
||||
*/
|
||||
private Boolean hopWindowAlarmOncePerWindow;
|
||||
|
||||
// ============ 会话窗口配置 ============
|
||||
|
||||
/**
|
||||
* 会话窗口时间类型
|
||||
*/
|
||||
private String sessionWindowTimeType;
|
||||
|
||||
/**
|
||||
* 会话窗口超时时间
|
||||
*/
|
||||
private Integer sessionWindowSize;
|
||||
|
||||
/**
|
||||
* 会话窗口单位:s/m/h/d
|
||||
*/
|
||||
private String sessionWindowSizeUnit;
|
||||
|
||||
// ============ 公共字段 ============
|
||||
|
||||
/**
|
||||
* 创建部门
|
||||
*/
|
||||
private Long createDept;
|
||||
|
||||
/**
|
||||
* 删除标志:0-未删除,1-已删除
|
||||
*/
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private String updateTime;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
}
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
package com.common.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import java.util.UUID;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 分析规则任务运行历史及状态记录
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AnalysisTaskHistory {
|
||||
|
||||
/**
|
||||
* 记录ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 规则ID
|
||||
*/
|
||||
private String ruleId;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
private LocalDateTime startTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private LocalDateTime endTime;
|
||||
|
||||
/**
|
||||
* 持续时间(秒)
|
||||
*/
|
||||
private Long durationTime;
|
||||
|
||||
/**
|
||||
* 进度百分比
|
||||
*/
|
||||
private Integer progressPercent;
|
||||
|
||||
/**
|
||||
* 输入数据量
|
||||
*/
|
||||
private Long inputCount;
|
||||
|
||||
/**
|
||||
* 输出数据量
|
||||
*/
|
||||
private Long outputCount;
|
||||
|
||||
/**
|
||||
* 状态(RUNNING/CANCELED/KILLED/COMPLETED/FAILED)
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 创建部门ID
|
||||
*/
|
||||
private Long createDept;
|
||||
|
||||
/**
|
||||
* 删除标志(0-正常,1-删除)
|
||||
*/
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新人ID
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 备注信息
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
package com.common.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 用户自定义函数实体类
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AnalysisUserDefinedFunction {
|
||||
|
||||
/**
|
||||
* 函数ID
|
||||
*/
|
||||
private String functionId;
|
||||
|
||||
/**
|
||||
* 规则ID
|
||||
*/
|
||||
private String ruleId;
|
||||
|
||||
/**
|
||||
* 函数名称
|
||||
*/
|
||||
private String functionName;
|
||||
|
||||
/**
|
||||
* 函数类型:AGGREGATE-聚合函数/SCALAR-标量函数/WINDOW-窗口函数
|
||||
*/
|
||||
private String functionType;
|
||||
|
||||
/**
|
||||
* 函数描述
|
||||
*/
|
||||
private String functionDesc;
|
||||
|
||||
/**
|
||||
* 函数实现SQL
|
||||
*/
|
||||
private String functionSql;
|
||||
|
||||
/**
|
||||
* 返回类型
|
||||
*/
|
||||
private String returnType;
|
||||
|
||||
/**
|
||||
* 参数定义(JSON格式)
|
||||
*/
|
||||
private String params;
|
||||
|
||||
/**
|
||||
* 启用状态
|
||||
*/
|
||||
private Boolean enabled;
|
||||
|
||||
/**
|
||||
* 删除标志:0-未删除 1-已删除
|
||||
*/
|
||||
private String delFlag;
|
||||
}
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
package com.common.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* WHERE条件逻辑表实体类(仅存储条件逻辑组信息)
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AnalysisWhereCondition {
|
||||
|
||||
/**
|
||||
* 条件ID
|
||||
*/
|
||||
private Integer condId;
|
||||
|
||||
/**
|
||||
* 规则ID
|
||||
*/
|
||||
private String ruleId;
|
||||
|
||||
/**
|
||||
* 逻辑运算符:AND, OR
|
||||
*/
|
||||
private String logicalOp;
|
||||
|
||||
/**
|
||||
* 序号
|
||||
*/
|
||||
private Integer seqNum;
|
||||
|
||||
/**
|
||||
* 父节点ID
|
||||
*/
|
||||
private Integer parentCondId;
|
||||
|
||||
/**
|
||||
* 创建部门ID
|
||||
*/
|
||||
private Long createDept;
|
||||
|
||||
/**
|
||||
* 删除标志:0-未删除 1-已删除
|
||||
*/
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新人ID
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 备注信息
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
package com.common.entity;
|
||||
|
||||
public class ApiResponse<T> {
|
||||
|
||||
private boolean success;
|
||||
private String message;
|
||||
private T data;
|
||||
private String errorCode;
|
||||
|
||||
// 成功响应
|
||||
public static <T> ApiResponse<T> success(T data) {
|
||||
ApiResponse<T> response = new ApiResponse<>();
|
||||
response.setSuccess(true);
|
||||
response.setMessage("操作成功");
|
||||
response.setData(data);
|
||||
return response;
|
||||
}
|
||||
|
||||
public static <T> ApiResponse<T> success(String message, T data) {
|
||||
ApiResponse<T> response = new ApiResponse<>();
|
||||
response.setSuccess(true);
|
||||
response.setMessage(message);
|
||||
response.setData(data);
|
||||
return response;
|
||||
}
|
||||
|
||||
// 失败响应
|
||||
public static <T> ApiResponse<T> error(String message) {
|
||||
ApiResponse<T> response = new ApiResponse<>();
|
||||
response.setSuccess(false);
|
||||
response.setMessage(message);
|
||||
return response;
|
||||
}
|
||||
|
||||
public static <T> ApiResponse<T> error(String message, String errorCode) {
|
||||
ApiResponse<T> response = new ApiResponse<>();
|
||||
response.setSuccess(false);
|
||||
response.setMessage(message);
|
||||
response.setErrorCode(errorCode);
|
||||
return response;
|
||||
}
|
||||
|
||||
// Getter和Setter方法
|
||||
public boolean isSuccess() {
|
||||
return success;
|
||||
}
|
||||
|
||||
public void setSuccess(boolean success) {
|
||||
this.success = success;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public String getErrorCode() {
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
public void setErrorCode(String errorCode) {
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.common.entity;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.elasticsearch.annotations.Document;
|
||||
import org.springframework.data.elasticsearch.annotations.Field;
|
||||
import org.springframework.data.elasticsearch.annotations.FieldType;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
//@Document(indexName = "applog-#{T(java.time.LocalDate).now().format(T(java.time.format.DateTimeFormatter).ofPattern('yyyyMMdd'))}")
|
||||
public class AppLog {
|
||||
|
||||
// ES元数据字段
|
||||
@Id
|
||||
private String id;
|
||||
|
||||
@Field(type = FieldType.Keyword)
|
||||
private String index;
|
||||
|
||||
@Field(type = FieldType.Keyword)
|
||||
private String type = "_doc";
|
||||
|
||||
@Field(type = FieldType.Float)
|
||||
private Float score = 1.0f;
|
||||
|
||||
// 日志内容字段(对应_source)
|
||||
@Field(name = "dtTime", type = FieldType.Long)
|
||||
private Long dtTime;
|
||||
|
||||
@Field(name = "collecttime", type = FieldType.Long)
|
||||
private Long collectTime;
|
||||
|
||||
@Field(name = "logType", type = FieldType.Keyword)
|
||||
private String logType;
|
||||
|
||||
@Field(name = "traceId", type = FieldType.Keyword)
|
||||
private String traceId;
|
||||
|
||||
@Field(name = "method", type = FieldType.Text)
|
||||
private String method;
|
||||
|
||||
@Field(name = "appName", type = FieldType.Keyword)
|
||||
private String appName;
|
||||
|
||||
@Field(name = "ip", type = FieldType.Keyword)
|
||||
private String ip;
|
||||
|
||||
@Field(name = "className", type = FieldType.Text)
|
||||
private String className;
|
||||
|
||||
@Field(name = "env", type = FieldType.Keyword)
|
||||
private String env;
|
||||
|
||||
@Field(name = "content", type = FieldType.Text)
|
||||
private String content;
|
||||
|
||||
@Field(name = "threadName", type = FieldType.Text)
|
||||
private String threadName;
|
||||
|
||||
@Field(name = "logLevel", type = FieldType.Keyword)
|
||||
private String logLevel;
|
||||
|
||||
@Field(name = "seq", type = FieldType.Keyword)
|
||||
private String seq;
|
||||
|
||||
@Field(name = "_indexed_at", type = FieldType.Long)
|
||||
private Long indexedAt;
|
||||
|
||||
// 系统字段
|
||||
private Date createTime = new Date();
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package com.common.entity;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class AppLogEntity {
|
||||
private Long id;
|
||||
|
||||
// ES元数据字段
|
||||
private String esIndex;
|
||||
private String esType = "_doc";
|
||||
private String esId;
|
||||
private Float esScore = 1.0f;
|
||||
|
||||
// 日志内容字段
|
||||
private Long dtTime;
|
||||
private Long collectTime;
|
||||
private String logType;
|
||||
private String traceId;
|
||||
private String method;
|
||||
private String appName;
|
||||
private String ip;
|
||||
private String className;
|
||||
private String env;
|
||||
private String content;
|
||||
private String threadName;
|
||||
private String logLevel;
|
||||
private String seq;
|
||||
private Long indexedAt;
|
||||
|
||||
// 分区字段
|
||||
private LocalDateTime logDate;
|
||||
|
||||
// 系统字段
|
||||
private LocalDateTime createdAt;
|
||||
private LocalDateTime updatedAt;
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
package com.common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 探针心跳状态实体类
|
||||
* 对应表: device_collect_heartbeat
|
||||
*/
|
||||
@Data
|
||||
public class DeviceCollectHeartbeat {
|
||||
|
||||
/** 自增主键 */
|
||||
private Long id;
|
||||
|
||||
/** 探针唯一标识(由探针上报) */
|
||||
private String collectId;
|
||||
|
||||
/** 探针名称(可选) */
|
||||
private String collectName;
|
||||
|
||||
/** 探针IP(支持IPv6) */
|
||||
private String deviceIp;
|
||||
|
||||
/** 探针版本 */
|
||||
private String appVersion;
|
||||
|
||||
/** 最后一次心跳时间(毫秒精度) */
|
||||
private LocalDateTime lastHeartbeat;
|
||||
|
||||
/** 累计心跳次数(可监控丢包率) */
|
||||
private Long heartbeatCount;
|
||||
|
||||
/** 在线状态:online / offline */
|
||||
private String status;
|
||||
|
||||
/** 连续心跳失败次数(平台侧计算) */
|
||||
private Integer failCount;
|
||||
|
||||
/** 最后更新时间 */
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
|
||||
|
||||
|
||||
public DeviceCollectHeartbeat() {
|
||||
this.heartbeatCount = 1L;
|
||||
this.status = "online";
|
||||
this.failCount = 0;
|
||||
this.updateTime = LocalDateTime.now();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新心跳
|
||||
*/
|
||||
public void updateHeartbeat() {
|
||||
this.lastHeartbeat = LocalDateTime.now();
|
||||
this.heartbeatCount = (this.heartbeatCount == null ? 1L : this.heartbeatCount + 1);
|
||||
this.status = "online";
|
||||
this.failCount = 0;
|
||||
this.updateTime = LocalDateTime.now();
|
||||
}
|
||||
|
||||
/**
|
||||
* 标记为离线
|
||||
*/
|
||||
public void markOffline() {
|
||||
this.status = "offline";
|
||||
this.failCount = (this.failCount == null ? 1 : this.failCount + 1);
|
||||
this.updateTime = LocalDateTime.now();
|
||||
}
|
||||
|
||||
/**
|
||||
* 恢复在线
|
||||
*/
|
||||
public void markOnline() {
|
||||
this.status = "online";
|
||||
this.failCount = 0;
|
||||
this.updateTime = LocalDateTime.now();
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package com.common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 探针心跳历史记录实体类
|
||||
* 对应表: device_collect_heartbeat_history
|
||||
*/
|
||||
@Data
|
||||
public class DeviceCollectHeartbeatHistory {
|
||||
|
||||
/** 自增主键 */
|
||||
private Long id;
|
||||
|
||||
/** 探针唯一标识 */
|
||||
private String collectId;
|
||||
|
||||
/** 心跳上报时间 */
|
||||
private LocalDateTime heartbeatTime;
|
||||
|
||||
/** 探针IP */
|
||||
private String deviceIp;
|
||||
|
||||
/** 探针版本 */
|
||||
private String appVersion;
|
||||
|
||||
/** 记录创建时间 */
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
|
||||
public DeviceCollectHeartbeatHistory() {
|
||||
this.createdAt = LocalDateTime.now();
|
||||
}
|
||||
|
||||
/**
|
||||
* 从心跳状态创建历史记录
|
||||
*/
|
||||
public static DeviceCollectHeartbeatHistory fromHeartbeat(DeviceCollectHeartbeat heartbeat) {
|
||||
DeviceCollectHeartbeatHistory history = new DeviceCollectHeartbeatHistory();
|
||||
history.setCollectId(heartbeat.getCollectId());
|
||||
history.setHeartbeatTime(heartbeat.getLastHeartbeat());
|
||||
history.setDeviceIp(heartbeat.getDeviceIp());
|
||||
history.setAppVersion(heartbeat.getAppVersion());
|
||||
history.setCreatedAt(LocalDateTime.now());
|
||||
return history;
|
||||
}
|
||||
}
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
package com.common.entity;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
public class DeviceCollectTask {
|
||||
private Integer id;
|
||||
private OffsetDateTime createdAt;
|
||||
private OffsetDateTime updatedAt;
|
||||
private OffsetDateTime deletedAt;
|
||||
private Integer deviceId;
|
||||
private Integer method;
|
||||
private String taskName;
|
||||
private OffsetDateTime firstTime;
|
||||
private OffsetDateTime lastSuccessTime;
|
||||
private OffsetDateTime lastFailedTime;
|
||||
private Integer detailId;
|
||||
private Integer epm;
|
||||
private Integer epmPeak;
|
||||
private Integer processArchitecture;
|
||||
private Integer taskCount;
|
||||
private OffsetDateTime recentDiscoverTime;
|
||||
private Integer epmUpperLimit;
|
||||
|
||||
// Getter and Setter 方法
|
||||
public Integer getId() { return id; }
|
||||
public void setId(Integer id) { this.id = id; }
|
||||
|
||||
public OffsetDateTime getCreatedAt() { return createdAt; }
|
||||
public void setCreatedAt(OffsetDateTime createdAt) { this.createdAt = createdAt; }
|
||||
|
||||
public OffsetDateTime getUpdatedAt() { return updatedAt; }
|
||||
public void setUpdatedAt(OffsetDateTime updatedAt) { this.updatedAt = updatedAt; }
|
||||
|
||||
public OffsetDateTime getDeletedAt() { return deletedAt; }
|
||||
public void setDeletedAt(OffsetDateTime deletedAt) { this.deletedAt = deletedAt; }
|
||||
|
||||
public Integer getDeviceId() { return deviceId; }
|
||||
public void setDeviceId(Integer deviceId) { this.deviceId = deviceId; }
|
||||
|
||||
public Integer getMethod() { return method; }
|
||||
public void setMethod(Integer method) { this.method = method; }
|
||||
|
||||
public String getTaskName() { return taskName; }
|
||||
public void setTaskName(String taskName) { this.taskName = taskName; }
|
||||
|
||||
public OffsetDateTime getFirstTime() { return firstTime; }
|
||||
public void setFirstTime(OffsetDateTime firstTime) { this.firstTime = firstTime; }
|
||||
|
||||
public OffsetDateTime getLastSuccessTime() { return lastSuccessTime; }
|
||||
public void setLastSuccessTime(OffsetDateTime lastSuccessTime) { this.lastSuccessTime = lastSuccessTime; }
|
||||
|
||||
public OffsetDateTime getLastFailedTime() { return lastFailedTime; }
|
||||
public void setLastFailedTime(OffsetDateTime lastFailedTime) { this.lastFailedTime = lastFailedTime; }
|
||||
|
||||
public Integer getDetailId() { return detailId; }
|
||||
public void setDetailId(Integer detailId) { this.detailId = detailId; }
|
||||
|
||||
public Integer getEpm() { return epm; }
|
||||
public void setEpm(Integer epm) { this.epm = epm; }
|
||||
|
||||
public Integer getEpmPeak() { return epmPeak; }
|
||||
public void setEpmPeak(Integer epmPeak) { this.epmPeak = epmPeak; }
|
||||
|
||||
public Integer getProcessArchitecture() { return processArchitecture; }
|
||||
public void setProcessArchitecture(Integer processArchitecture) { this.processArchitecture = processArchitecture; }
|
||||
|
||||
public Integer getTaskCount() { return taskCount; }
|
||||
public void setTaskCount(Integer taskCount) { this.taskCount = taskCount; }
|
||||
|
||||
public OffsetDateTime getRecentDiscoverTime() { return recentDiscoverTime; }
|
||||
public void setRecentDiscoverTime(OffsetDateTime recentDiscoverTime) { this.recentDiscoverTime = recentDiscoverTime; }
|
||||
|
||||
public Integer getEpmUpperLimit() { return epmUpperLimit; }
|
||||
public void setEpmUpperLimit(Integer epmUpperLimit) { this.epmUpperLimit = epmUpperLimit; }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DeviceCollectTask{" +
|
||||
"id=" + id +
|
||||
", createdAt=" + createdAt +
|
||||
", updatedAt=" + updatedAt +
|
||||
", deletedAt=" + deletedAt +
|
||||
", deviceId=" + deviceId +
|
||||
", method=" + method +
|
||||
", taskName='" + taskName + '\'' +
|
||||
", firstTime=" + firstTime +
|
||||
", lastSuccessTime=" + lastSuccessTime +
|
||||
", lastFailedTime=" + lastFailedTime +
|
||||
", detailId=" + detailId +
|
||||
", epm=" + epm +
|
||||
", epmPeak=" + epmPeak +
|
||||
", processArchitecture=" + processArchitecture +
|
||||
", taskCount=" + taskCount +
|
||||
", recentDiscoverTime=" + recentDiscoverTime +
|
||||
", epmUpperLimit=" + epmUpperLimit +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
@Data
|
||||
public class DeviceCollectTaskTime {
|
||||
private String deviceCollectId;
|
||||
private LocalDateTime firstTime; // 首次成功时间
|
||||
private LocalDateTime lastSuccessTime; // 最后成功时间
|
||||
private LocalDateTime lastFailTime; // 最后失败时间
|
||||
}
|
||||
+376
@@ -0,0 +1,376 @@
|
||||
package com.common.entity;
|
||||
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.OffsetDateTime;
|
||||
public class DeviceDevice {
|
||||
public Integer id;
|
||||
public LocalDateTime createdAt;
|
||||
public LocalDateTime updatedAt;
|
||||
public LocalDateTime deletedAt;
|
||||
public String name;
|
||||
public String ip;
|
||||
public Integer deviceGroup;
|
||||
public Integer deviceType;
|
||||
public String vendor;
|
||||
public String productName;
|
||||
public Integer organizationId;
|
||||
public LocalDateTime lastReceiveTime;
|
||||
public Integer agentId;
|
||||
public Integer detailId;
|
||||
public Integer controlAgentId;
|
||||
public LocalDateTime licenseStartTime;
|
||||
public LocalDateTime licenseEndTime;
|
||||
public Boolean isMonitoring;
|
||||
public Long securityScopeId;
|
||||
public Long ownerId;
|
||||
public Long sshConfigId;
|
||||
public Short status;
|
||||
public Long createdById;
|
||||
public Integer decodeType;
|
||||
public Integer missPolicy;
|
||||
public String tenantId;
|
||||
public LocalDateTime createTime;
|
||||
public LocalDateTime updateTime;
|
||||
public Long createBy;
|
||||
public Long updateBy;
|
||||
public String delFlag;
|
||||
public String managerName;
|
||||
public Integer todayParseCount;
|
||||
public Integer todayNonLogCount;
|
||||
public Long createDept;
|
||||
public Integer deviceCollectId;
|
||||
|
||||
|
||||
// Getter and Setter methods
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(LocalDateTime createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public LocalDateTime getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(LocalDateTime updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public LocalDateTime getDeletedAt() {
|
||||
return deletedAt;
|
||||
}
|
||||
|
||||
public void setDeletedAt(LocalDateTime deletedAt) {
|
||||
this.deletedAt = deletedAt;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
public Integer getDeviceGroup() {
|
||||
return deviceGroup;
|
||||
}
|
||||
|
||||
public void setDeviceGroup(Integer deviceGroup) {
|
||||
this.deviceGroup = deviceGroup;
|
||||
}
|
||||
|
||||
public Integer getDeviceType() {
|
||||
return deviceType;
|
||||
}
|
||||
|
||||
public void setDeviceType(Integer deviceType) {
|
||||
this.deviceType = deviceType;
|
||||
}
|
||||
|
||||
public String getVendor() {
|
||||
return vendor;
|
||||
}
|
||||
|
||||
public void setVendor(String vendor) {
|
||||
this.vendor = vendor;
|
||||
}
|
||||
|
||||
public String getProductName() {
|
||||
return productName;
|
||||
}
|
||||
|
||||
public void setProductName(String productName) {
|
||||
this.productName = productName;
|
||||
}
|
||||
|
||||
public Integer getOrganizationId() {
|
||||
return organizationId;
|
||||
}
|
||||
|
||||
public void setOrganizationId(Integer organizationId) {
|
||||
this.organizationId = organizationId;
|
||||
}
|
||||
|
||||
public LocalDateTime getLastReceiveTime() {
|
||||
return lastReceiveTime;
|
||||
}
|
||||
|
||||
public void setLastReceiveTime(LocalDateTime lastReceiveTime) {
|
||||
this.lastReceiveTime = lastReceiveTime;
|
||||
}
|
||||
|
||||
public Integer getAgentId() {
|
||||
return agentId;
|
||||
}
|
||||
|
||||
public void setAgentId(Integer agentId) {
|
||||
this.agentId = agentId;
|
||||
}
|
||||
|
||||
public Integer getDetailId() {
|
||||
return detailId;
|
||||
}
|
||||
|
||||
public void setDetailId(Integer detailId) {
|
||||
this.detailId = detailId;
|
||||
}
|
||||
|
||||
public Integer getControlAgentId() {
|
||||
return controlAgentId;
|
||||
}
|
||||
|
||||
public void setControlAgentId(Integer controlAgentId) {
|
||||
this.controlAgentId = controlAgentId;
|
||||
}
|
||||
|
||||
public LocalDateTime getLicenseStartTime() {
|
||||
return licenseStartTime;
|
||||
}
|
||||
|
||||
public void setLicenseStartTime(LocalDateTime licenseStartTime) {
|
||||
this.licenseStartTime = licenseStartTime;
|
||||
}
|
||||
|
||||
public LocalDateTime getLicenseEndTime() {
|
||||
return licenseEndTime;
|
||||
}
|
||||
|
||||
public void setLicenseEndTime(LocalDateTime licenseEndTime) {
|
||||
this.licenseEndTime = licenseEndTime;
|
||||
}
|
||||
|
||||
public Boolean getIsMonitoring() {
|
||||
return isMonitoring;
|
||||
}
|
||||
|
||||
public void setIsMonitoring(Boolean isMonitoring) {
|
||||
this.isMonitoring = isMonitoring;
|
||||
}
|
||||
|
||||
public Long getSecurityScopeId() {
|
||||
return securityScopeId;
|
||||
}
|
||||
|
||||
public void setSecurityScopeId(Long securityScopeId) {
|
||||
this.securityScopeId = securityScopeId;
|
||||
}
|
||||
|
||||
public Long getOwnerId() {
|
||||
return ownerId;
|
||||
}
|
||||
|
||||
public void setOwnerId(Long ownerId) {
|
||||
this.ownerId = ownerId;
|
||||
}
|
||||
|
||||
public Long getSshConfigId() {
|
||||
return sshConfigId;
|
||||
}
|
||||
|
||||
public void setSshConfigId(Long sshConfigId) {
|
||||
this.sshConfigId = sshConfigId;
|
||||
}
|
||||
|
||||
public Short getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Short status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Long getCreatedById() {
|
||||
return createdById;
|
||||
}
|
||||
|
||||
public void setCreatedById(Long createdById) {
|
||||
this.createdById = createdById;
|
||||
}
|
||||
|
||||
public Integer getDecodeType() {
|
||||
return decodeType;
|
||||
}
|
||||
|
||||
public void setDecodeType(Integer decodeType) {
|
||||
this.decodeType = decodeType;
|
||||
}
|
||||
|
||||
public Integer getMissPolicy() {
|
||||
return missPolicy;
|
||||
}
|
||||
|
||||
public void setMissPolicy(Integer missPolicy) {
|
||||
this.missPolicy = missPolicy;
|
||||
}
|
||||
|
||||
public String getTenantId() {
|
||||
return tenantId;
|
||||
}
|
||||
|
||||
public void setTenantId(String tenantId) {
|
||||
this.tenantId = tenantId;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(LocalDateTime createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public LocalDateTime getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(LocalDateTime updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public Long getCreateBy() {
|
||||
return createBy;
|
||||
}
|
||||
|
||||
public void setCreateBy(Long createBy) {
|
||||
this.createBy = createBy;
|
||||
}
|
||||
|
||||
public Long getUpdateBy() {
|
||||
return updateBy;
|
||||
}
|
||||
|
||||
public void setUpdateBy(Long updateBy) {
|
||||
this.updateBy = updateBy;
|
||||
}
|
||||
|
||||
public String getDelFlag() {
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
public void setDelFlag(String delFlag) {
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public String getManagerName() {
|
||||
return managerName;
|
||||
}
|
||||
|
||||
public void setManagerName(String managerName) {
|
||||
this.managerName = managerName;
|
||||
}
|
||||
|
||||
public Integer getTodayParseCount() {
|
||||
return todayParseCount;
|
||||
}
|
||||
|
||||
public void setTodayParseCount(Integer todayParseCount) {
|
||||
this.todayParseCount = todayParseCount;
|
||||
}
|
||||
|
||||
public Integer getTodayNonLogCount() {
|
||||
return todayNonLogCount;
|
||||
}
|
||||
|
||||
public void setTodayNonLogCount(Integer todayNonLogCount) {
|
||||
this.todayNonLogCount = todayNonLogCount;
|
||||
}
|
||||
|
||||
public Long getCreateDept() {
|
||||
return createDept;
|
||||
}
|
||||
|
||||
public void setCreateDept(Long createDept) {
|
||||
this.createDept = createDept;
|
||||
}
|
||||
|
||||
public Integer getDeviceCollectId() {
|
||||
return deviceCollectId;
|
||||
}
|
||||
|
||||
public void setDeviceCollectId(Integer deviceCollectId) {
|
||||
this.deviceCollectId = deviceCollectId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DeviceDevice{" +
|
||||
"id=" + id +
|
||||
", createdAt=" + createdAt +
|
||||
", updatedAt=" + updatedAt +
|
||||
", deletedAt=" + deletedAt +
|
||||
", name='" + name + '\'' +
|
||||
", ip='" + ip + '\'' +
|
||||
", deviceGroup=" + deviceGroup +
|
||||
", deviceType=" + deviceType +
|
||||
", vendor='" + vendor + '\'' +
|
||||
", productName='" + productName + '\'' +
|
||||
", organizationId=" + organizationId +
|
||||
", lastReceiveTime=" + lastReceiveTime +
|
||||
", agentId=" + agentId +
|
||||
", detailId=" + detailId +
|
||||
", controlAgentId=" + controlAgentId +
|
||||
", licenseStartTime=" + licenseStartTime +
|
||||
", licenseEndTime=" + licenseEndTime +
|
||||
", isMonitoring=" + isMonitoring +
|
||||
", securityScopeId=" + securityScopeId +
|
||||
", ownerId=" + ownerId +
|
||||
", sshConfigId=" + sshConfigId +
|
||||
", status=" + status +
|
||||
", createdById=" + createdById +
|
||||
", decodeType=" + decodeType +
|
||||
", missPolicy=" + missPolicy +
|
||||
", tenantId='" + tenantId + '\'' +
|
||||
", createTime=" + createTime +
|
||||
", updateTime=" + updateTime +
|
||||
", createBy=" + createBy +
|
||||
", updateBy=" + updateBy +
|
||||
", delFlag='" + delFlag + '\'' +
|
||||
", managerName='" + managerName + '\'' +
|
||||
", todayParseCount=" + todayParseCount +
|
||||
", todayNonLogCount=" + todayNonLogCount +
|
||||
", createDept=" + createDept +
|
||||
", deviceCollectId=" + deviceCollectId +
|
||||
'}';
|
||||
}
|
||||
|
||||
}
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
package com.common.entity;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
/**
|
||||
* 联动设备表实体类(防火墙设备信息)
|
||||
* 对应表: device_interlocking
|
||||
*/
|
||||
public class DeviceInterlocking {
|
||||
private Long id;
|
||||
private String deviceName; // 联动安全设备名称(防火墙)
|
||||
private String vendor; // 厂商
|
||||
private String deptId; // 所属组织机构(部门ID)
|
||||
private Integer banLimit; // 封禁上限
|
||||
private String ip; // IP地址
|
||||
private String apiUrl; // API地址
|
||||
private String tenantId;
|
||||
private Long createDept;
|
||||
private Long createBy;
|
||||
private OffsetDateTime createTime;
|
||||
private Long updateBy;
|
||||
private OffsetDateTime updateTime;
|
||||
private String remark;
|
||||
private String authUsername; // 用户名
|
||||
private String authPassword; // 密码
|
||||
|
||||
// Getter and Setter
|
||||
public Long getId() { return id; }
|
||||
public void setId(Long id) { this.id = id; }
|
||||
|
||||
public String getDeviceName() { return deviceName; }
|
||||
public void setDeviceName(String deviceName) { this.deviceName = deviceName; }
|
||||
|
||||
public String getVendor() { return vendor; }
|
||||
public void setVendor(String vendor) { this.vendor = vendor; }
|
||||
|
||||
public String getDeptId() { return deptId; }
|
||||
public void setDeptId(String deptId) { this.deptId = deptId; }
|
||||
|
||||
public Integer getBanLimit() { return banLimit; }
|
||||
public void setBanLimit(Integer banLimit) { this.banLimit = banLimit; }
|
||||
|
||||
public String getIp() { return ip; }
|
||||
public void setIp(String ip) { this.ip = ip; }
|
||||
|
||||
public String getApiUrl() { return apiUrl; }
|
||||
public void setApiUrl(String apiUrl) { this.apiUrl = apiUrl; }
|
||||
|
||||
public String getTenantId() { return tenantId; }
|
||||
public void setTenantId(String tenantId) { this.tenantId = tenantId; }
|
||||
|
||||
public Long getCreateDept() { return createDept; }
|
||||
public void setCreateDept(Long createDept) { this.createDept = createDept; }
|
||||
|
||||
public Long getCreateBy() { return createBy; }
|
||||
public void setCreateBy(Long createBy) { this.createBy = createBy; }
|
||||
|
||||
public OffsetDateTime getCreateTime() { return createTime; }
|
||||
public void setCreateTime(OffsetDateTime createTime) { this.createTime = createTime; }
|
||||
|
||||
public Long getUpdateBy() { return updateBy; }
|
||||
public void setUpdateBy(Long updateBy) { this.updateBy = updateBy; }
|
||||
|
||||
public OffsetDateTime getUpdateTime() { return updateTime; }
|
||||
public void setUpdateTime(OffsetDateTime updateTime) { this.updateTime = updateTime; }
|
||||
|
||||
public String getRemark() { return remark; }
|
||||
public void setRemark(String remark) { this.remark = remark; }
|
||||
|
||||
public String getAuthUsername() { return authUsername; }
|
||||
public void setAuthUsername(String authUsername) { this.authUsername = authUsername; }
|
||||
|
||||
public String getAuthPassword() { return authPassword; }
|
||||
public void setAuthPassword(String authPassword) { this.authPassword = authPassword; }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DeviceInterlocking{" +
|
||||
"id=" + id +
|
||||
", deviceName='" + deviceName + '\'' +
|
||||
", vendor='" + vendor + '\'' +
|
||||
", ip='" + ip + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
package com.common.entity;
|
||||
|
||||
import com.Modules.etl.handler.ArrayIntegerTypeHandler;
|
||||
import com.Modules.etl.handler.ArrayStringTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.apache.ibatis.type.TypeHandler;
|
||||
import org.apache.ibatis.type.ArrayTypeHandler;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 封禁指令表实体类
|
||||
* 对应表: device_interlocking_cmd
|
||||
*/
|
||||
public class DeviceInterlockingCmd {
|
||||
private Long id;
|
||||
private Long probeId; // 探针ID
|
||||
private String probeIp; // 探针IP
|
||||
private Integer[] deviceInterlockingId; // 联动设备ID(数组)
|
||||
private String[] deviceInterlockingIp; // 联动设备IP(数组)
|
||||
private String[] banIps; // 封禁IP(数组)
|
||||
private String banMethod; // 封禁方式(0:手工、1:自动)
|
||||
private String banType; // 封禁类型(1:白名单、0:黑名单)
|
||||
private String cmdStatus; // 指令状态(0:未执行、1:已完成、2:执行中)
|
||||
private Integer banDuration; // 封禁时长(秒,-1表示永久)
|
||||
private OffsetDateTime createTime;
|
||||
private OffsetDateTime updateTime;
|
||||
private String tenantId;
|
||||
private Long createDept;
|
||||
private Long createBy;
|
||||
private Long updateBy;
|
||||
private String remark;
|
||||
private Integer banOperationType; // 封禁操作类型(0:新增、1:删除)
|
||||
|
||||
// Getter and Setter
|
||||
public Long getId() { return id; }
|
||||
public void setId(Long id) { this.id = id; }
|
||||
|
||||
public Long getProbeId() { return probeId; }
|
||||
public void setProbeId(Long probeId) { this.probeId = probeId; }
|
||||
|
||||
public String getProbeIp() { return probeIp; }
|
||||
public void setProbeIp(String probeIp) { this.probeIp = probeIp; }
|
||||
|
||||
public Integer[] getDeviceInterlockingId() { return deviceInterlockingId; }
|
||||
public void setDeviceInterlockingId(Integer[] deviceInterlockingId) { this.deviceInterlockingId = deviceInterlockingId; }
|
||||
|
||||
public String[] getDeviceInterlockingIp() { return deviceInterlockingIp; }
|
||||
public void setDeviceInterlockingIp(String[] deviceInterlockingIp) { this.deviceInterlockingIp = deviceInterlockingIp; }
|
||||
|
||||
public String[] getBanIps() { return banIps; }
|
||||
public void setBanIps(String[] banIps) { this.banIps = banIps; }
|
||||
|
||||
public String getBanMethod() { return banMethod; }
|
||||
public void setBanMethod(String banMethod) { this.banMethod = banMethod; }
|
||||
|
||||
public String getBanType() { return banType; }
|
||||
public void setBanType(String banType) { this.banType = banType; }
|
||||
|
||||
public String getCmdStatus() { return cmdStatus; }
|
||||
public void setCmdStatus(String cmdStatus) { this.cmdStatus = cmdStatus; }
|
||||
|
||||
public Integer getBanDuration() { return banDuration; }
|
||||
public void setBanDuration(Integer banDuration) { this.banDuration = banDuration; }
|
||||
|
||||
public OffsetDateTime getCreateTime() { return createTime; }
|
||||
public void setCreateTime(OffsetDateTime createTime) { this.createTime = createTime; }
|
||||
|
||||
public OffsetDateTime getUpdateTime() { return updateTime; }
|
||||
public void setUpdateTime(OffsetDateTime updateTime) { this.updateTime = updateTime; }
|
||||
|
||||
public String getTenantId() { return tenantId; }
|
||||
public void setTenantId(String tenantId) { this.tenantId = tenantId; }
|
||||
|
||||
public Long getCreateDept() { return createDept; }
|
||||
public void setCreateDept(Long createDept) { this.createDept = createDept; }
|
||||
|
||||
public Long getCreateBy() { return createBy; }
|
||||
public void setCreateBy(Long createBy) { this.createBy = createBy; }
|
||||
|
||||
public Long getUpdateBy() { return updateBy; }
|
||||
public void setUpdateBy(Long updateBy) { this.updateBy = updateBy; }
|
||||
|
||||
public String getRemark() { return remark; }
|
||||
public void setRemark(String remark) { this.remark = remark; }
|
||||
|
||||
public Integer getBanOperationType() { return banOperationType; }
|
||||
public void setBanOperationType(Integer banOperationType) { this.banOperationType = banOperationType; }
|
||||
|
||||
// ========== 便利方法:数组与List互转 ==========
|
||||
|
||||
/**
|
||||
* 获取设备联动ID列表
|
||||
*/
|
||||
public List<Integer> getDeviceInterlockingIdList() {
|
||||
return deviceInterlockingId != null ? Arrays.asList(deviceInterlockingId) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置设备联动ID列表
|
||||
*/
|
||||
public void setDeviceInterlockingIdList(List<Integer> list) {
|
||||
this.deviceInterlockingId = list != null ? list.toArray(new Integer[0]) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备联动IP列表
|
||||
*/
|
||||
public List<String> getDeviceInterlockingIpList() {
|
||||
return deviceInterlockingIp != null ? Arrays.asList(deviceInterlockingIp) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置设备联动IP列表
|
||||
*/
|
||||
public void setDeviceInterlockingIpList(List<String> list) {
|
||||
this.deviceInterlockingIp = list != null ? list.toArray(new String[0]) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取封禁IP列表
|
||||
*/
|
||||
public List<String> getBanIpsList() {
|
||||
return banIps != null ? Arrays.asList(banIps) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置封禁IP列表
|
||||
*/
|
||||
public void setBanIpsList(List<String> list) {
|
||||
this.banIps = list != null ? list.toArray(new String[0]) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DeviceInterlockingCmd{" +
|
||||
"id=" + id +
|
||||
", probeId=" + probeId +
|
||||
", probeIp='" + probeIp + '\'' +
|
||||
", banType='" + banType + '\'' +
|
||||
", cmdStatus='" + cmdStatus + '\'' +
|
||||
", banOperationType=" + banOperationType +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
package com.common.entity;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
/**
|
||||
* 封禁记录表实体类
|
||||
* 对应表: device_interlocking_log
|
||||
*/
|
||||
public class DeviceInterlockingLog {
|
||||
private Long id;
|
||||
private Long deviceInterlockingCmdId; // 封禁指令ID
|
||||
private Long deviceInterlockingId; // 封禁设备ID
|
||||
private String banIp; // 封禁IP地址
|
||||
private String deviceName; // 封禁设备名称
|
||||
private OffsetDateTime banTime; // 封禁时间
|
||||
private String banMethod; // 封禁方式(0.人工、1.自动化封禁)
|
||||
private Integer banResult; // 联动结果(成功:1、失败:0)
|
||||
private String tenantId;
|
||||
private Long createDept;
|
||||
private Long createBy;
|
||||
private OffsetDateTime createTime;
|
||||
private Long updateBy;
|
||||
private OffsetDateTime updateTime;
|
||||
private String remark;
|
||||
private String respBody; // 响应body
|
||||
private String reqBody; // 请求body
|
||||
|
||||
// Getter and Setter
|
||||
public Long getId() { return id; }
|
||||
public void setId(Long id) { this.id = id; }
|
||||
|
||||
public Long getDeviceInterlockingCmdId() { return deviceInterlockingCmdId; }
|
||||
public void setDeviceInterlockingCmdId(Long deviceInterlockingCmdId) { this.deviceInterlockingCmdId = deviceInterlockingCmdId; }
|
||||
|
||||
public Long getDeviceInterlockingId() { return deviceInterlockingId; }
|
||||
public void setDeviceInterlockingId(Long deviceInterlockingId) { this.deviceInterlockingId = deviceInterlockingId; }
|
||||
|
||||
public String getBanIp() { return banIp; }
|
||||
public void setBanIp(String banIp) { this.banIp = banIp; }
|
||||
|
||||
public String getDeviceName() { return deviceName; }
|
||||
public void setDeviceName(String deviceName) { this.deviceName = deviceName; }
|
||||
|
||||
public OffsetDateTime getBanTime() { return banTime; }
|
||||
public void setBanTime(OffsetDateTime banTime) { this.banTime = banTime; }
|
||||
|
||||
public String getBanMethod() { return banMethod; }
|
||||
public void setBanMethod(String banMethod) { this.banMethod = banMethod; }
|
||||
|
||||
public Integer getBanResult() { return banResult; }
|
||||
public void setBanResult(Integer banResult) { this.banResult = banResult; }
|
||||
|
||||
public String getTenantId() { return tenantId; }
|
||||
public void setTenantId(String tenantId) { this.tenantId = tenantId; }
|
||||
|
||||
public Long getCreateDept() { return createDept; }
|
||||
public void setCreateDept(Long createDept) { this.createDept = createDept; }
|
||||
|
||||
public Long getCreateBy() { return createBy; }
|
||||
public void setCreateBy(Long createBy) { this.createBy = createBy; }
|
||||
|
||||
public OffsetDateTime getCreateTime() { return createTime; }
|
||||
public void setCreateTime(OffsetDateTime createTime) { this.createTime = createTime; }
|
||||
|
||||
public Long getUpdateBy() { return updateBy; }
|
||||
public void setUpdateBy(Long updateBy) { this.updateBy = updateBy; }
|
||||
|
||||
public OffsetDateTime getUpdateTime() { return updateTime; }
|
||||
public void setUpdateTime(OffsetDateTime updateTime) { this.updateTime = updateTime; }
|
||||
|
||||
public String getRemark() { return remark; }
|
||||
public void setRemark(String remark) { this.remark = remark; }
|
||||
|
||||
public String getRespBody() { return respBody; }
|
||||
public void setRespBody(String respBody) { this.respBody = respBody; }
|
||||
|
||||
public String getReqBody() { return reqBody; }
|
||||
public void setReqBody(String reqBody) { this.reqBody = reqBody; }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DeviceInterlockingLog{" +
|
||||
"id=" + id +
|
||||
", deviceInterlockingCmdId=" + deviceInterlockingCmdId +
|
||||
", banIp='" + banIp + '\'' +
|
||||
", deviceName='" + deviceName + '\'' +
|
||||
", banResult=" + banResult +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
package com.common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Builder;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DeviceReceiveLog {
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 记录创建时间(UTC时间)
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
/**
|
||||
* 采集探针ID
|
||||
*/
|
||||
private Integer deviceCollectId;
|
||||
|
||||
/**
|
||||
* 设备ID
|
||||
*/
|
||||
private Integer deviceId;
|
||||
|
||||
/**
|
||||
* 设备IP(PostgreSQL inet类型,用String处理)
|
||||
*/
|
||||
private String deviceIp;
|
||||
|
||||
/**
|
||||
* 日志收到时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime receiveTime;
|
||||
|
||||
/**
|
||||
* 接收时间字符串(冗余字段)
|
||||
*/
|
||||
private String receiveTimeStr;
|
||||
|
||||
/**
|
||||
* 原始syslog消息
|
||||
*/
|
||||
private String syslogMessage;
|
||||
|
||||
// 推送是否成功
|
||||
private Boolean pushSuccess;
|
||||
/**
|
||||
* 分页参数(非表字段)
|
||||
*/
|
||||
private Integer pageNum;
|
||||
private Integer pageSize;
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.common.entity;
|
||||
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class DeviceStatsDTO {
|
||||
private Long deviceId;
|
||||
private LocalDateTime lastReceiveTime;
|
||||
private Integer parseCount;
|
||||
private Integer nonLogCount;
|
||||
}
|
||||
+131
@@ -0,0 +1,131 @@
|
||||
package com.common.entity;
|
||||
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class DmColumn {
|
||||
private Long id;
|
||||
private LocalDateTime createdAt;
|
||||
private LocalDateTime updatedAt;
|
||||
private LocalDateTime deletedAt;
|
||||
private String name;
|
||||
private String displayName;
|
||||
private Long storageDataType;
|
||||
private Long businessDataType;
|
||||
private Boolean isBuiltIn;
|
||||
private Boolean isHidden;
|
||||
private Boolean isNotNormalizable;
|
||||
private Boolean isRequired;
|
||||
private Integer categoryId;
|
||||
private Integer customAssetCategoryId;
|
||||
private Boolean isVirtual;
|
||||
private Integer tableId;
|
||||
private Integer assetTableId;
|
||||
private Integer columnSetId;
|
||||
private Integer baseType;
|
||||
private Integer userTaskId;
|
||||
private Long createdById;
|
||||
private Long createDept;
|
||||
private Long createBy;
|
||||
private LocalDateTime createTime;
|
||||
private Long updateBy;
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
// 构造方法
|
||||
public DmColumn() {}
|
||||
|
||||
public DmColumn(String name, String displayName) {
|
||||
this.name = name;
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
// getter 和 setter 方法
|
||||
public Long getId() { return id; }
|
||||
public void setId(Long id) { this.id = id; }
|
||||
|
||||
public LocalDateTime getCreatedAt() { return createdAt; }
|
||||
public void setCreatedAt(LocalDateTime createdAt) { this.createdAt = createdAt; }
|
||||
|
||||
public LocalDateTime getUpdatedAt() { return updatedAt; }
|
||||
public void setUpdatedAt(LocalDateTime updatedAt) { this.updatedAt = updatedAt; }
|
||||
|
||||
public LocalDateTime getDeletedAt() { return deletedAt; }
|
||||
public void setDeletedAt(LocalDateTime deletedAt) { this.deletedAt = deletedAt; }
|
||||
|
||||
public String getName() { return name; }
|
||||
public void setName(String name) { this.name = name; }
|
||||
|
||||
public String getDisplayName() { return displayName; }
|
||||
public void setDisplayName(String displayName) { this.displayName = displayName; }
|
||||
|
||||
public Long getStorageDataType() { return storageDataType; }
|
||||
public void setStorageDataType(Long storageDataType) { this.storageDataType = storageDataType; }
|
||||
|
||||
public Long getBusinessDataType() { return businessDataType; }
|
||||
public void setBusinessDataType(Long businessDataType) { this.businessDataType = businessDataType; }
|
||||
|
||||
public Boolean getIsBuiltIn() { return isBuiltIn; }
|
||||
public void setIsBuiltIn(Boolean isBuiltIn) { this.isBuiltIn = isBuiltIn; }
|
||||
|
||||
public Boolean getIsHidden() { return isHidden; }
|
||||
public void setIsHidden(Boolean isHidden) { this.isHidden = isHidden; }
|
||||
|
||||
public Boolean getIsNotNormalizable() { return isNotNormalizable; }
|
||||
public void setIsNotNormalizable(Boolean isNotNormalizable) { this.isNotNormalizable = isNotNormalizable; }
|
||||
|
||||
public Boolean getIsRequired() { return isRequired; }
|
||||
public void setIsRequired(Boolean isRequired) { this.isRequired = isRequired; }
|
||||
|
||||
public Integer getCategoryId() { return categoryId; }
|
||||
public void setCategoryId(Integer categoryId) { this.categoryId = categoryId; }
|
||||
|
||||
public Integer getCustomAssetCategoryId() { return customAssetCategoryId; }
|
||||
public void setCustomAssetCategoryId(Integer customAssetCategoryId) { this.customAssetCategoryId = customAssetCategoryId; }
|
||||
|
||||
public Boolean getIsVirtual() { return isVirtual; }
|
||||
public void setIsVirtual(Boolean isVirtual) { this.isVirtual = isVirtual; }
|
||||
|
||||
public Integer getTableId() { return tableId; }
|
||||
public void setTableId(Integer tableId) { this.tableId = tableId; }
|
||||
|
||||
public Integer getAssetTableId() { return assetTableId; }
|
||||
public void setAssetTableId(Integer assetTableId) { this.assetTableId = assetTableId; }
|
||||
|
||||
public Integer getColumnSetId() { return columnSetId; }
|
||||
public void setColumnSetId(Integer columnSetId) { this.columnSetId = columnSetId; }
|
||||
|
||||
public Integer getBaseType() { return baseType; }
|
||||
public void setBaseType(Integer baseType) { this.baseType = baseType; }
|
||||
|
||||
public Integer getUserTaskId() { return userTaskId; }
|
||||
public void setUserTaskId(Integer userTaskId) { this.userTaskId = userTaskId; }
|
||||
|
||||
public Long getCreatedById() { return createdById; }
|
||||
public void setCreatedById(Long createdById) { this.createdById = createdById; }
|
||||
|
||||
public Long getCreateDept() { return createDept; }
|
||||
public void setCreateDept(Long createDept) { this.createDept = createDept; }
|
||||
|
||||
public Long getCreateBy() { return createBy; }
|
||||
public void setCreateBy(Long createBy) { this.createBy = createBy; }
|
||||
|
||||
public LocalDateTime getCreateTime() { return createTime; }
|
||||
public void setCreateTime(LocalDateTime createTime) { this.createTime = createTime; }
|
||||
|
||||
public Long getUpdateBy() { return updateBy; }
|
||||
public void setUpdateBy(Long updateBy) { this.updateBy = updateBy; }
|
||||
|
||||
public LocalDateTime getUpdateTime() { return updateTime; }
|
||||
public void setUpdateTime(LocalDateTime updateTime) { this.updateTime = updateTime; }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DmColumn{" +
|
||||
"id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
", displayName='" + displayName + '\'' +
|
||||
", isBuiltIn=" + isBuiltIn +
|
||||
", isHidden=" + isHidden +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
+131
@@ -0,0 +1,131 @@
|
||||
package com.common.entity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class DmNormalizeRule {
|
||||
private Long id;
|
||||
private LocalDateTime createdAt;
|
||||
private LocalDateTime updatedAt;
|
||||
private LocalDateTime deletedAt;
|
||||
private String name;
|
||||
private String displayName;
|
||||
private String description;
|
||||
private Boolean isBuiltIn;
|
||||
private Boolean isRunning;
|
||||
private LocalDateTime firstDataSavedAt;
|
||||
private String dataType;
|
||||
private Integer fieldCateId;
|
||||
private String logParsed;
|
||||
private String[] sampleLogs;
|
||||
private Boolean isDataMergeEnabled;
|
||||
private Long dataMergeInterval;
|
||||
private String dataMergeTimeUnit;
|
||||
private Long dataMergeRowLimit;
|
||||
private String dataMergeColumns;
|
||||
private Short dataStorageMedium;
|
||||
private Integer createdById;
|
||||
private Integer groupId;
|
||||
private String ruleContent;
|
||||
private String builtInVersion;
|
||||
private String tenantId;
|
||||
private LocalDateTime createTime;
|
||||
private LocalDateTime updateTime;
|
||||
private Long createBy;
|
||||
private Long updateBy;
|
||||
private String delFlag;
|
||||
private Long createDept;
|
||||
|
||||
// getters and setters
|
||||
public Long getId() { return id; }
|
||||
public void setId(Long id) { this.id = id; }
|
||||
|
||||
public LocalDateTime getCreatedAt() { return createdAt; }
|
||||
public void setCreatedAt(LocalDateTime createdAt) { this.createdAt = createdAt; }
|
||||
|
||||
public LocalDateTime getUpdatedAt() { return updatedAt; }
|
||||
public void setUpdatedAt(LocalDateTime updatedAt) { this.updatedAt = updatedAt; }
|
||||
|
||||
public LocalDateTime getDeletedAt() { return deletedAt; }
|
||||
public void setDeletedAt(LocalDateTime deletedAt) { this.deletedAt = deletedAt; }
|
||||
|
||||
public String getName() { return name; }
|
||||
public void setName(String name) { this.name = name; }
|
||||
|
||||
public String getDisplayName() { return displayName; }
|
||||
public void setDisplayName(String displayName) { this.displayName = displayName; }
|
||||
|
||||
public String getDescription() { return description; }
|
||||
public void setDescription(String description) { this.description = description; }
|
||||
|
||||
public Boolean getIsBuiltIn() { return isBuiltIn; }
|
||||
public void setIsBuiltIn(Boolean isBuiltIn) { this.isBuiltIn = isBuiltIn; }
|
||||
|
||||
public Boolean getIsRunning() { return isRunning; }
|
||||
public void setIsRunning(Boolean isRunning) { this.isRunning = isRunning; }
|
||||
|
||||
public LocalDateTime getFirstDataSavedAt() { return firstDataSavedAt; }
|
||||
public void setFirstDataSavedAt(LocalDateTime firstDataSavedAt) { this.firstDataSavedAt = firstDataSavedAt; }
|
||||
|
||||
public String getDataType() { return dataType; }
|
||||
public void setDataType(String dataType) { this.dataType = dataType; }
|
||||
|
||||
public Integer getFieldCateId() { return fieldCateId; }
|
||||
public void setFieldCateId(Integer fieldCateId) { this.fieldCateId = fieldCateId; }
|
||||
|
||||
public String getLogParsed() { return logParsed; }
|
||||
public void setLogParsed(String logParsed) { this.logParsed = logParsed; }
|
||||
|
||||
public String[] getSampleLogs() { return sampleLogs; }
|
||||
public void setSampleLogs(String[] sampleLogs) { this.sampleLogs = sampleLogs; }
|
||||
|
||||
public Boolean getIsDataMergeEnabled() { return isDataMergeEnabled; }
|
||||
public void setIsDataMergeEnabled(Boolean isDataMergeEnabled) { this.isDataMergeEnabled = isDataMergeEnabled; }
|
||||
|
||||
public Long getDataMergeInterval() { return dataMergeInterval; }
|
||||
public void setDataMergeInterval(Long dataMergeInterval) { this.dataMergeInterval = dataMergeInterval; }
|
||||
|
||||
public String getDataMergeTimeUnit() { return dataMergeTimeUnit; }
|
||||
public void setDataMergeTimeUnit(String dataMergeTimeUnit) { this.dataMergeTimeUnit = dataMergeTimeUnit; }
|
||||
|
||||
public Long getDataMergeRowLimit() { return dataMergeRowLimit; }
|
||||
public void setDataMergeRowLimit(Long dataMergeRowLimit) { this.dataMergeRowLimit = dataMergeRowLimit; }
|
||||
|
||||
public String getDataMergeColumns() { return dataMergeColumns; }
|
||||
public void setDataMergeColumns(String dataMergeColumns) { this.dataMergeColumns = dataMergeColumns; }
|
||||
|
||||
public Short getDataStorageMedium() { return dataStorageMedium; }
|
||||
public void setDataStorageMedium(Short dataStorageMedium) { this.dataStorageMedium = dataStorageMedium; }
|
||||
|
||||
public Integer getCreatedById() { return createdById; }
|
||||
public void setCreatedById(Integer createdById) { this.createdById = createdById; }
|
||||
|
||||
public Integer getGroupId() { return groupId; }
|
||||
public void setGroupId(Integer groupId) { this.groupId = groupId; }
|
||||
|
||||
public String getRuleContent() { return ruleContent; }
|
||||
public void setRuleContent(String ruleContent) { this.ruleContent = ruleContent; }
|
||||
|
||||
public String getBuiltInVersion() { return builtInVersion; }
|
||||
public void setBuiltInVersion(String builtInVersion) { this.builtInVersion = builtInVersion; }
|
||||
|
||||
public String getTenantId() { return tenantId; }
|
||||
public void setTenantId(String tenantId) { this.tenantId = tenantId; }
|
||||
|
||||
public LocalDateTime getCreateTime() { return createTime; }
|
||||
public void setCreateTime(LocalDateTime createTime) { this.createTime = createTime; }
|
||||
|
||||
public LocalDateTime getUpdateTime() { return updateTime; }
|
||||
public void setUpdateTime(LocalDateTime updateTime) { this.updateTime = updateTime; }
|
||||
|
||||
public Long getCreateBy() { return createBy; }
|
||||
public void setCreateBy(Long createBy) { this.createBy = createBy; }
|
||||
|
||||
public Long getUpdateBy() { return updateBy; }
|
||||
public void setUpdateBy(Long updateBy) { this.updateBy = updateBy; }
|
||||
|
||||
public String getDelFlag() { return delFlag; }
|
||||
public void setDelFlag(String delFlag) { this.delFlag = delFlag; }
|
||||
|
||||
public Long getCreateDept() { return createDept; }
|
||||
public void setCreateDept(Long createDept) { this.createDept = createDept; }
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package com.common.entity;
|
||||
import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class GroupedSyslogData {
|
||||
private String logDate;
|
||||
private String srcIp;
|
||||
private String destIp;
|
||||
private String[] attackIps;
|
||||
private String originEventName;
|
||||
private Integer attackResult; // 单个attack_result值
|
||||
private LocalDateTime minLogTime;
|
||||
private LocalDateTime maxLogTime;
|
||||
private Long logCount;
|
||||
private String[] victimIps;
|
||||
private String[] victimWebUrls;
|
||||
private Integer[] deviceIds;
|
||||
private String[] originLogIds;
|
||||
private Integer maxEventLevel;
|
||||
private String firstEventType;
|
||||
private String eventType;
|
||||
private String minEventType;
|
||||
private Integer[] attackPorts;
|
||||
private Integer[] victimPorts;
|
||||
private String[] httpStatusCodes;
|
||||
private byte[][] payloadSamples;
|
||||
private String[] httpReqHeaders;
|
||||
private String[] httpReqBodys;
|
||||
private String[] httpRespHeaders;
|
||||
private String[] httpRespBodys;
|
||||
private String dnsInfo;
|
||||
private String victimIpsStr;
|
||||
private Integer[] allAttackResults; // 所有不同的attack_result值
|
||||
private Integer mostCommonAttackResult; // 最常见的attack_result值
|
||||
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.common.entity;
|
||||
|
||||
public class RFC3164Message extends SyslogMessage {
|
||||
private String tag;
|
||||
|
||||
public String getTag() { return tag; }
|
||||
public void setTag(String tag) { this.tag = tag; }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("RFC3164 [Facility: %d, Severity: %d, Host: %s, Tag: %s, Time: %s, Msg: %s]",
|
||||
facility, severity, hostname, tag, timestamp, message);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.common.entity;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class RFC5424Message extends SyslogMessage {
|
||||
private int version;
|
||||
private Map<String, Map<String, String>> structuredData;
|
||||
|
||||
public RFC5424Message() {
|
||||
this.structuredData = new HashMap<>();
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(int version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public Map<String, Map<String, String>> getStructuredData() {
|
||||
return structuredData;
|
||||
}
|
||||
|
||||
public void setStructuredData(Map<String, Map<String, String>> structuredData) {
|
||||
this.structuredData = structuredData;
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package com.common.entity.RuleContent;
|
||||
|
||||
|
||||
public class ActionType {
|
||||
private String type;
|
||||
private String relation_parser_id;
|
||||
private Object sparser_param;
|
||||
private Object param;
|
||||
|
||||
// Constructors
|
||||
public ActionType() {}
|
||||
|
||||
// Getters and Setters
|
||||
public String gettype() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void settype(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getrelation_parser_id() {
|
||||
return relation_parser_id;
|
||||
}
|
||||
|
||||
public void setrelation_parser_id(String relation_parser_id) {
|
||||
this.relation_parser_id = relation_parser_id;
|
||||
}
|
||||
|
||||
public Object getsparser_param() {
|
||||
return sparser_param;
|
||||
}
|
||||
|
||||
public void setsparser_param(Object sparser_param) {
|
||||
this.sparser_param = sparser_param;
|
||||
}
|
||||
|
||||
public Object getparam() {
|
||||
return param;
|
||||
}
|
||||
|
||||
public void setparam(Object param) {
|
||||
this.param = param;
|
||||
}
|
||||
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package com.common.entity.RuleContent;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class CompleteColumn {
|
||||
private String columnName; // 要补全的字段名
|
||||
private Object value; // 补全的值
|
||||
private String filtersRelation; // 条件关系: "and" 或 "or"
|
||||
private List<Condition> conditions; // 条件列表
|
||||
|
||||
// 导入数据相关字段(扩展功能)
|
||||
private String importedDataTableName;
|
||||
private String filtersImportedRelation;
|
||||
private List<Condition> importedConditions;
|
||||
private List<CompleteColumn> completeImportedColumns;
|
||||
}
|
||||
|
||||
@Data
|
||||
class Condition {
|
||||
private String columnName; // 条件字段名
|
||||
private String op; // 操作符: =, !=, in, zero_len, contain, regexp
|
||||
private Object value; // 条件值
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package com.common.entity.RuleContent;
|
||||
|
||||
|
||||
public class Complete_paramsType {
|
||||
private String name;
|
||||
private String value;
|
||||
private FiltersType filters;
|
||||
|
||||
// Constructors
|
||||
public Complete_paramsType() {}
|
||||
|
||||
// Getters and Setters
|
||||
public String getname() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setname(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getvalue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setvalue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public FiltersType getfilters() {
|
||||
return filters;
|
||||
}
|
||||
|
||||
public void setfilters(FiltersType filters) {
|
||||
this.filters = filters;
|
||||
}
|
||||
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package com.common.entity.RuleContent;
|
||||
|
||||
|
||||
public class Cropper_paramsType {
|
||||
private String head_key;
|
||||
private Integer head_offset;
|
||||
private String tail_key;
|
||||
private Integer tail_offset;
|
||||
|
||||
// Constructors
|
||||
public Cropper_paramsType() {}
|
||||
|
||||
// Getters and Setters
|
||||
public String gethead_key() {
|
||||
return head_key;
|
||||
}
|
||||
|
||||
public void sethead_key(String head_key) {
|
||||
this.head_key = head_key;
|
||||
}
|
||||
|
||||
public Integer gethead_offset() {
|
||||
return head_offset;
|
||||
}
|
||||
|
||||
public void sethead_offset(Integer head_offset) {
|
||||
this.head_offset = head_offset;
|
||||
}
|
||||
|
||||
public String gettail_key() {
|
||||
return tail_key;
|
||||
}
|
||||
|
||||
public void settail_key(String tail_key) {
|
||||
this.tail_key = tail_key;
|
||||
}
|
||||
|
||||
public Integer gettail_offset() {
|
||||
return tail_offset;
|
||||
}
|
||||
|
||||
public void settail_offset(Integer tail_offset) {
|
||||
this.tail_offset = tail_offset;
|
||||
}
|
||||
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.common.entity.RuleContent;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class FilterParam {
|
||||
private List<FilterGroup> filtersParams;
|
||||
}
|
||||
|
||||
@Data
|
||||
class FilterGroup {
|
||||
private List<FilterExpression> expressions;
|
||||
private String filtersRelation; // "and" 或 "or"
|
||||
}
|
||||
|
||||
@Data
|
||||
class FilterExpression {
|
||||
private String columnName; // 字段名
|
||||
private String op; // 操作符: =, !=, in, zero_len, contain, regexp
|
||||
private Object value; // 值,可能是字符串、数组等
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package com.common.entity.RuleContent;
|
||||
|
||||
public class FiltersType {
|
||||
|
||||
// Constructors
|
||||
public FiltersType() {}
|
||||
|
||||
// Getters and Setters
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
package com.common.entity.RuleContent;
|
||||
|
||||
|
||||
public class MappersType {
|
||||
private Integer capture_group_index;
|
||||
private String origin_field;
|
||||
private String src_field;
|
||||
private String dest_field;
|
||||
private String value;
|
||||
private String assigned_value;
|
||||
private Integer strategy;
|
||||
private String mapping_rule_name;
|
||||
private ActionType action;
|
||||
|
||||
// Constructors
|
||||
public MappersType() {}
|
||||
|
||||
// Getters and Setters
|
||||
public Integer getcapture_group_index() {
|
||||
return capture_group_index;
|
||||
}
|
||||
|
||||
public void setcapture_group_index(Integer capture_group_index) {
|
||||
this.capture_group_index = capture_group_index;
|
||||
}
|
||||
|
||||
public String getorigin_field() {
|
||||
return origin_field;
|
||||
}
|
||||
|
||||
public void setorigin_field(String origin_field) {
|
||||
this.origin_field = origin_field;
|
||||
}
|
||||
|
||||
public String getsrc_field() {
|
||||
return src_field;
|
||||
}
|
||||
|
||||
public void setsrc_field(String src_field) {
|
||||
this.src_field = src_field;
|
||||
}
|
||||
|
||||
public String getdest_field() {
|
||||
return dest_field;
|
||||
}
|
||||
|
||||
public void setdest_field(String dest_field) {
|
||||
this.dest_field = dest_field;
|
||||
}
|
||||
|
||||
public String getvalue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setvalue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getassigned_value() {
|
||||
return assigned_value;
|
||||
}
|
||||
|
||||
public void setassigned_value(String assigned_value) {
|
||||
this.assigned_value = assigned_value;
|
||||
}
|
||||
|
||||
public Integer getstrategy() {
|
||||
return strategy;
|
||||
}
|
||||
|
||||
public void setstrategy(Integer strategy) {
|
||||
this.strategy = strategy;
|
||||
}
|
||||
|
||||
public String getmapping_rule_name() {
|
||||
return mapping_rule_name;
|
||||
}
|
||||
|
||||
public void setmapping_rule_name(String mapping_rule_name) {
|
||||
this.mapping_rule_name = mapping_rule_name;
|
||||
}
|
||||
|
||||
public ActionType getaction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setaction(ActionType action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
}
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
package com.common.entity.RuleContent;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.common.entity.RuleContent.*;
|
||||
|
||||
|
||||
public class Root {
|
||||
private Integer field_cate_id;
|
||||
private Integer field_cate_table_name;
|
||||
private String rule_name;
|
||||
private String data_type;
|
||||
private String decode;
|
||||
private List<String> keywords;
|
||||
private Cropper_paramsType cropper_params;
|
||||
private Object second_parsers;
|
||||
private Object second_parsers_v2;
|
||||
private List<MappersType> mappers;
|
||||
private String filters_params;
|
||||
private List<Complete_paramsType> complete_params;
|
||||
private String complete_columns;
|
||||
private Integer data_storage_medium;
|
||||
|
||||
// Constructors
|
||||
public Root() {}
|
||||
|
||||
// Getters and Setters
|
||||
public Integer getfield_cate_id() {
|
||||
return field_cate_id;
|
||||
}
|
||||
|
||||
public void setfield_cate_id(Integer field_cate_id) {
|
||||
this.field_cate_id = field_cate_id;
|
||||
}
|
||||
|
||||
public Integer getfield_cate_table_name() {
|
||||
return field_cate_table_name;
|
||||
}
|
||||
|
||||
public void setfield_cate_table_name(Integer field_cate_table_name) {
|
||||
this.field_cate_table_name = field_cate_table_name;
|
||||
}
|
||||
|
||||
public String getrule_name() {
|
||||
return rule_name;
|
||||
}
|
||||
|
||||
public void setrule_name(String rule_name) {
|
||||
this.rule_name = rule_name;
|
||||
}
|
||||
|
||||
public String getdata_type() {
|
||||
return data_type;
|
||||
}
|
||||
|
||||
public void setdata_type(String data_type) {
|
||||
this.data_type = data_type;
|
||||
}
|
||||
|
||||
public String getdecode() {
|
||||
return decode;
|
||||
}
|
||||
|
||||
public void setdecode(String decode) {
|
||||
this.decode = decode;
|
||||
}
|
||||
|
||||
public List<String> getkeywords() {
|
||||
return keywords;
|
||||
}
|
||||
|
||||
public void setkeywords(List<String> keywords) {
|
||||
this.keywords = keywords;
|
||||
}
|
||||
|
||||
public Cropper_paramsType getcropper_params() {
|
||||
return cropper_params;
|
||||
}
|
||||
|
||||
public void setcropper_params(Cropper_paramsType cropper_params) {
|
||||
this.cropper_params = cropper_params;
|
||||
}
|
||||
|
||||
public Object getsecond_parsers() {
|
||||
return second_parsers;
|
||||
}
|
||||
|
||||
public void setsecond_parsers(Object second_parsers) {
|
||||
this.second_parsers = second_parsers;
|
||||
}
|
||||
|
||||
public Object getsecond_parsers_v2() {
|
||||
return second_parsers_v2;
|
||||
}
|
||||
|
||||
public void setsecond_parsers_v2(Object second_parsers_v2) {
|
||||
this.second_parsers_v2 = second_parsers_v2;
|
||||
}
|
||||
|
||||
public List<MappersType> getmappers() {
|
||||
return mappers;
|
||||
}
|
||||
|
||||
public void setmappers(List<MappersType> mappers) {
|
||||
this.mappers = mappers;
|
||||
}
|
||||
|
||||
public String getfilters_params() {
|
||||
return filters_params;
|
||||
}
|
||||
|
||||
public void setfilters_params(String filters_params) {
|
||||
this.filters_params = filters_params;
|
||||
}
|
||||
|
||||
public List<Complete_paramsType> getcomplete_params() {
|
||||
return complete_params;
|
||||
}
|
||||
|
||||
public void setcomplete_params(List<Complete_paramsType> complete_params) {
|
||||
this.complete_params = complete_params;
|
||||
}
|
||||
|
||||
public String getcomplete_columns() {
|
||||
return complete_columns;
|
||||
}
|
||||
|
||||
public void setcomplete_columns(String complete_columns) {
|
||||
this.complete_columns = complete_columns;
|
||||
}
|
||||
|
||||
public Integer getdata_storage_medium() {
|
||||
return data_storage_medium;
|
||||
}
|
||||
|
||||
public void setdata_storage_medium(Integer data_storage_medium) {
|
||||
this.data_storage_medium = data_storage_medium;
|
||||
}
|
||||
|
||||
}
|
||||
+139
@@ -0,0 +1,139 @@
|
||||
package com.common.entity.RuleContent;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.common.entity.RuleContent.*;
|
||||
public class RuleContent {
|
||||
|
||||
private Integer field_cate_id;
|
||||
private Integer field_cate_table_name;
|
||||
private String rule_name;
|
||||
private String data_type;
|
||||
private String decode;
|
||||
private List<String> keywords;
|
||||
private Cropper_paramsType cropper_params;
|
||||
private Object second_parsers;
|
||||
private Object second_parsers_v2;
|
||||
private List<MappersType> mappers;
|
||||
private String filters_params;
|
||||
private List<Complete_paramsType> complete_params;
|
||||
private String complete_columns;
|
||||
private Integer data_storage_medium;
|
||||
|
||||
// Constructors
|
||||
public RuleContent() {}
|
||||
|
||||
// Getters and Setters
|
||||
public Integer getfield_cate_id() {
|
||||
return field_cate_id;
|
||||
}
|
||||
|
||||
public void setfield_cate_id(Integer field_cate_id) {
|
||||
this.field_cate_id = field_cate_id;
|
||||
}
|
||||
|
||||
public Integer getfield_cate_table_name() {
|
||||
return field_cate_table_name;
|
||||
}
|
||||
|
||||
public void setfield_cate_table_name(Integer field_cate_table_name) {
|
||||
this.field_cate_table_name = field_cate_table_name;
|
||||
}
|
||||
|
||||
public String getrule_name() {
|
||||
return rule_name;
|
||||
}
|
||||
|
||||
public void setrule_name(String rule_name) {
|
||||
this.rule_name = rule_name;
|
||||
}
|
||||
|
||||
public String getdata_type() {
|
||||
return data_type;
|
||||
}
|
||||
|
||||
public void setdata_type(String data_type) {
|
||||
this.data_type = data_type;
|
||||
}
|
||||
|
||||
public String getdecode() {
|
||||
return decode;
|
||||
}
|
||||
|
||||
public void setdecode(String decode) {
|
||||
this.decode = decode;
|
||||
}
|
||||
|
||||
public List<String> getkeywords() {
|
||||
return keywords;
|
||||
}
|
||||
|
||||
public void setkeywords(List<String> keywords) {
|
||||
this.keywords = keywords;
|
||||
}
|
||||
|
||||
public Cropper_paramsType getcropper_params() {
|
||||
return cropper_params;
|
||||
}
|
||||
|
||||
public void setcropper_params(Cropper_paramsType cropper_params) {
|
||||
this.cropper_params = cropper_params;
|
||||
}
|
||||
|
||||
public Object getsecond_parsers() {
|
||||
return second_parsers;
|
||||
}
|
||||
|
||||
public void setsecond_parsers(Object second_parsers) {
|
||||
this.second_parsers = second_parsers;
|
||||
}
|
||||
|
||||
public Object getsecond_parsers_v2() {
|
||||
return second_parsers_v2;
|
||||
}
|
||||
|
||||
public void setsecond_parsers_v2(Object second_parsers_v2) {
|
||||
this.second_parsers_v2 = second_parsers_v2;
|
||||
}
|
||||
|
||||
public List<MappersType> getmappers() {
|
||||
return mappers;
|
||||
}
|
||||
|
||||
public void setmappers(List<MappersType> mappers) {
|
||||
this.mappers = mappers;
|
||||
}
|
||||
|
||||
public String getfilters_params() {
|
||||
return filters_params;
|
||||
}
|
||||
|
||||
public void setfilters_params(String filters_params) {
|
||||
this.filters_params = filters_params;
|
||||
}
|
||||
|
||||
public List<Complete_paramsType> getcomplete_params() {
|
||||
return complete_params;
|
||||
}
|
||||
|
||||
public void setcomplete_params(List<Complete_paramsType> complete_params) {
|
||||
this.complete_params = complete_params;
|
||||
}
|
||||
|
||||
public String getcomplete_columns() {
|
||||
return complete_columns;
|
||||
}
|
||||
|
||||
public void setcomplete_columns(String complete_columns) {
|
||||
this.complete_columns = complete_columns;
|
||||
}
|
||||
|
||||
public Integer getdata_storage_medium() {
|
||||
return data_storage_medium;
|
||||
}
|
||||
|
||||
public void setdata_storage_medium(Integer data_storage_medium) {
|
||||
this.data_storage_medium = data_storage_medium;
|
||||
}
|
||||
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.common.entity.RuleContent;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class kv_paramsType {
|
||||
private String internal;
|
||||
private String external;
|
||||
private String l_trim;
|
||||
private String r_trim;
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.common.entity;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class RuleHitTimeDTO {
|
||||
/**
|
||||
* 泛化规则ID
|
||||
*/
|
||||
private Long normalizeRuleId;
|
||||
|
||||
/**
|
||||
* 最大命中时间(从标准化表中统计)
|
||||
*/
|
||||
private LocalDateTime maxLogTime;
|
||||
|
||||
/**
|
||||
* 数据来源表
|
||||
*/
|
||||
private String sourceTable;
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class SecExceptionAlgorithm {
|
||||
private Long id;
|
||||
private String algorithmName;
|
||||
private String exceptionType;
|
||||
private String dataSource;
|
||||
private Integer status; // 1启用
|
||||
private String description;
|
||||
private String configInfo;
|
||||
private String operatorZipUrl;
|
||||
private String remark;
|
||||
private String createBy;
|
||||
private LocalDateTime createTime;
|
||||
private String updateBy;
|
||||
private LocalDateTime updateTime;
|
||||
private String tenantId;
|
||||
private String delFlag;
|
||||
private Long createDept;
|
||||
private String apiUrl; // API URL
|
||||
private String apiMethod; // GET/POST
|
||||
private String respUrl;
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package com.common.entity;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
// 基础 Syslog 消息类
|
||||
public abstract class SyslogMessage {
|
||||
protected int priority;
|
||||
protected int facility;
|
||||
protected int severity;
|
||||
protected String hostname;
|
||||
protected String appName;
|
||||
protected String procId;
|
||||
protected String msgId;
|
||||
protected String message;
|
||||
protected OffsetDateTime timestamp;
|
||||
|
||||
// Getters and Setters
|
||||
public int getPriority() { return priority; }
|
||||
public void setPriority(int priority) {
|
||||
this.priority = priority;
|
||||
this.facility = priority / 8;
|
||||
this.severity = priority % 8;
|
||||
}
|
||||
|
||||
public int getFacility() { return facility; }
|
||||
public int getSeverity() { return severity; }
|
||||
public String getHostname() { return hostname; }
|
||||
public void setHostname(String hostname) { this.hostname = hostname; }
|
||||
public String getAppName() { return appName; }
|
||||
public void setAppName(String appName) { this.appName = appName; }
|
||||
public String getProcId() { return procId; }
|
||||
public void setProcId(String procId) { this.procId = procId; }
|
||||
public String getMsgId() { return msgId; }
|
||||
public void setMsgId(String msgId) { this.msgId = msgId; }
|
||||
public String getMessage() { return message; }
|
||||
public void setMessage(String message) { this.message = message; }
|
||||
public OffsetDateTime getTimestamp() { return timestamp; }
|
||||
public void setTimestamp(OffsetDateTime timestamp) { this.timestamp = timestamp; }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("Facility: %d, Severity: %d, Host: %s, App: %s, Time: %s, Msg: %s",
|
||||
facility, severity, hostname, appName, timestamp, message);
|
||||
}
|
||||
}
|
||||
+162
@@ -0,0 +1,162 @@
|
||||
package com.common.entity;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
/**
|
||||
* 非标日志实体类
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("syslog_non_normal_message")
|
||||
public class SyslogNonNormalMessage {
|
||||
|
||||
/**
|
||||
* 非标ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.INPUT)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 记录时间(UTC时区)
|
||||
*/
|
||||
@TableField("created_at")
|
||||
private OffsetDateTime createdAt;
|
||||
|
||||
/**
|
||||
* log处理时间
|
||||
*/
|
||||
@TableField("log_time")
|
||||
private LocalDateTime logTime;
|
||||
|
||||
/**
|
||||
* 设备ID
|
||||
*/
|
||||
@TableField("device_id")
|
||||
private Integer deviceId;
|
||||
|
||||
/**
|
||||
* 原始日志
|
||||
*/
|
||||
@TableField("syslog_message")
|
||||
private String syslogMessage;
|
||||
|
||||
/**
|
||||
* 安全日志ID
|
||||
*/
|
||||
@TableField("syslog_uuid")
|
||||
private String syslogUuid;
|
||||
|
||||
/**
|
||||
* kafka topic
|
||||
*/
|
||||
@TableField("syslog_topic")
|
||||
private String syslogTopic;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@TableField("tenant_id")
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("create_time")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField("update_time")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
@TableField("create_by")
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
@TableField("update_by")
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 创建部门
|
||||
*/
|
||||
@TableField("create_dept")
|
||||
private Long createDept;
|
||||
|
||||
/**
|
||||
* 采集头部消息
|
||||
*/
|
||||
@TableField("header_message")
|
||||
private String headerMessage;
|
||||
|
||||
/**
|
||||
* 接收时间
|
||||
*/
|
||||
@TableField("receive_time")
|
||||
private LocalDateTime receiveTime;
|
||||
|
||||
/**
|
||||
* 泛化时间
|
||||
*/
|
||||
@TableField("rule_time")
|
||||
private LocalDateTime ruleTime;
|
||||
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
@TableField("device_name")
|
||||
private String deviceName;
|
||||
|
||||
/**
|
||||
* ETL处理节点
|
||||
*/
|
||||
@TableField("etl_node")
|
||||
private String etlNode;
|
||||
|
||||
/**
|
||||
* 采集任务ID
|
||||
*/
|
||||
@TableField("collect_task_id")
|
||||
private Integer collectTaskId;
|
||||
|
||||
/**
|
||||
* 采集任务名称
|
||||
*/
|
||||
@TableField("collect_task_name")
|
||||
private String collectTaskName;
|
||||
|
||||
/**
|
||||
* 非标原因
|
||||
*/
|
||||
@TableField("reason")
|
||||
private String reason;
|
||||
|
||||
/**
|
||||
* 详细原因
|
||||
*/
|
||||
@TableField("reason_detail")
|
||||
private String reasonDetail;
|
||||
|
||||
/**
|
||||
* 泛化结果
|
||||
*/
|
||||
@TableField("rule_result")
|
||||
private String ruleResult;
|
||||
|
||||
/**
|
||||
* 删除标志
|
||||
*/
|
||||
@TableField("del_flag")
|
||||
private String delFlag;
|
||||
}
|
||||
+383
@@ -0,0 +1,383 @@
|
||||
package com.common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class SyslogNormalAlarm {
|
||||
private String id;
|
||||
private LocalDateTime createdAt;
|
||||
private LocalDateTime logTime;
|
||||
private Integer deviceId;
|
||||
private String webshellType;
|
||||
private String vuirsType;
|
||||
private String vuirsUrl;
|
||||
private String classFilename;
|
||||
private String classPath;
|
||||
private String parentClass;
|
||||
private String jarPath;
|
||||
private String classMd5;
|
||||
private String classLoader;
|
||||
private String classHashcode;
|
||||
private String classLoaderHashcode;
|
||||
private String tcNameip;
|
||||
private String performSql;
|
||||
private String tcAccount;
|
||||
private String tcAppname;
|
||||
private String processUname;
|
||||
private String pProcessUname;
|
||||
private String containerName;
|
||||
private String containerId;
|
||||
private String httpRespServer;
|
||||
private Long srcipId;
|
||||
private String cdnip;
|
||||
private String natip;
|
||||
private String mailSender;
|
||||
private String mailReceiver;
|
||||
private String vpnMac;
|
||||
private String vpnOs;
|
||||
private String vpnUser;
|
||||
private String vpnGroupname;
|
||||
private String vpnAccessIp;
|
||||
private Boolean destIpApt;
|
||||
private String originAttackResult;
|
||||
private String description;
|
||||
private String solution;
|
||||
private String attackCause;
|
||||
private String username;
|
||||
private String tcFlowId;
|
||||
private String loginResult;
|
||||
private String cmdline;
|
||||
private String originAttackAction;
|
||||
private String victimDomain;
|
||||
private String vpnDeviceid;
|
||||
private String vpnAccessAction;
|
||||
private Long fileAccessTime;
|
||||
private String fileName;
|
||||
private String tcClass;
|
||||
private String tcName2;
|
||||
private Long loginLasttime;
|
||||
private String originPermissions;
|
||||
private String beginPermissions;
|
||||
private Long printTime;
|
||||
private String printer;
|
||||
private String printerType;
|
||||
private Long printPages;
|
||||
private Long printCopies;
|
||||
private String srcDevice;
|
||||
private String dstDevice;
|
||||
private String srcFile;
|
||||
private String srcFileType;
|
||||
private String srcFilePath;
|
||||
private String dstFile;
|
||||
private String dstFileType;
|
||||
private String dstFilePath;
|
||||
private String dlpPolicyName;
|
||||
private String dlpPolicyType;
|
||||
private String dstUploadUrl;
|
||||
private String processUuid;
|
||||
private String pProcessUuid;
|
||||
private String env;
|
||||
private String bruteForceService;
|
||||
private String vuirsName;
|
||||
private Long httpReqLength;
|
||||
private String httpReqContentType;
|
||||
private String tcScanPort;
|
||||
private String tcLabels;
|
||||
private String httpRespContentType;
|
||||
private String dnsMsgType;
|
||||
private String dnsAnswerLength;
|
||||
private Boolean dnsIoc;
|
||||
private BigDecimal txBytes;
|
||||
private BigDecimal rxBytes;
|
||||
private BigDecimal allBytes;
|
||||
private Long durationTime;
|
||||
private String mailAttachName;
|
||||
private String mailSubject;
|
||||
private String mailMessage;
|
||||
private String mailSendServer;
|
||||
private String mailAgent;
|
||||
private String tlsVersion;
|
||||
private String tlsServerCert;
|
||||
private String tlsServerSuite;
|
||||
private String tlsClientSuitesLen;
|
||||
private String tlsJa3;
|
||||
private String tlsJa3s;
|
||||
private String vpnAccessPort;
|
||||
private String logTopic;
|
||||
private Long collectTime;
|
||||
private Boolean srcIsIntranetip;
|
||||
private Boolean srcIpIoc;
|
||||
private Boolean srcIpApt;
|
||||
private String srcipName;
|
||||
private String tcClient;
|
||||
private Long srcipOrganizationId;
|
||||
private Boolean destIpIntranetip;
|
||||
private Boolean destIpIoc;
|
||||
private Long desipId;
|
||||
private String desipName;
|
||||
private String tcHostip;
|
||||
private Long desipOrganizationId;
|
||||
private String originConfidence;
|
||||
private String originMalscore;
|
||||
private String attackerIcampaign;
|
||||
private Long attackerHostAssetId;
|
||||
private Long attackerOrganizationId;
|
||||
private Long victimHostAssetId;
|
||||
private Long victimOrganizationId;
|
||||
private Long logoutTime;
|
||||
private String httpReqLine;
|
||||
private String desipSecurityScopeId;
|
||||
private String srcipSecurityScopeId;
|
||||
private Long httpRespLength;
|
||||
private String tcAttackType;
|
||||
private String tcRealip;
|
||||
private String attackerIpLists;
|
||||
private String loginPassword;
|
||||
private String detail;
|
||||
private String attackerCountryCode;
|
||||
private String attackerRegionCode;
|
||||
private String victimRegionCode;
|
||||
private String payload;
|
||||
private String httpReferer;
|
||||
private String httpUserAgent;
|
||||
private String httpSession;
|
||||
private String httpQueryString;
|
||||
private String filePath;
|
||||
private String filePermission;
|
||||
private String loginAbnormalType;
|
||||
private String fileTag;
|
||||
private String filePlatform;
|
||||
private String targetIp;
|
||||
private String collectDate;
|
||||
private String tcClientIp;
|
||||
private String tcServerIp;
|
||||
private String tcExternalip;
|
||||
private Long httpStatusCode;
|
||||
private String deviceDomian;
|
||||
private String srcIpStr;
|
||||
private String srcPortStr;
|
||||
private String destIpStr;
|
||||
private String destPortStr;
|
||||
private String pcap;
|
||||
private String ioc;
|
||||
private String maliciousFamily;
|
||||
private String vulnCve;
|
||||
private String aliyunType;
|
||||
private String attackerHostAssetName;
|
||||
private String attackerOrganizationName;
|
||||
private String ctId;
|
||||
private String cveList;
|
||||
private String desipOrganizationName;
|
||||
private String destIpGroup;
|
||||
private String fileGid;
|
||||
private String fileOwner;
|
||||
private String fileOwnergroup;
|
||||
private String fileUid;
|
||||
private String httpRespCookie;
|
||||
private String originRuleId;
|
||||
private String originRuleName;
|
||||
private String serviceName;
|
||||
private String srcIpAssetGroup;
|
||||
private String srcipOrganizationName;
|
||||
private String victimHostAssetName;
|
||||
private Long httpRespCodes;
|
||||
private String victimOrganizationName;
|
||||
private String tcType;
|
||||
private String direction;
|
||||
private String httpReqCookie;
|
||||
private String httpReqProtocol;
|
||||
private String httpReqHeaderRaw;
|
||||
private String httpUrl;
|
||||
private String uname;
|
||||
private String originHostname;
|
||||
private String originOs;
|
||||
private String originAgentMac;
|
||||
private String originHostId;
|
||||
private String originAgentVersion;
|
||||
private String originAgentId;
|
||||
private String originAgentName;
|
||||
private String originWorkGroup;
|
||||
private String originAssetGroup;
|
||||
private Long originLocalPort;
|
||||
private String originAgentIp;
|
||||
private String originInternalIp;
|
||||
private String originExternalIp;
|
||||
private String originLocalAddr;
|
||||
private Long agentId;
|
||||
private String agentName;
|
||||
private String tcTitle;
|
||||
private String logId;
|
||||
private LocalDateTime eventDate;
|
||||
private Long eventTimeTs;
|
||||
private Integer eventLevel;
|
||||
private String srcIp;
|
||||
private Long srcPort;
|
||||
private String destIp;
|
||||
private Long destPort;
|
||||
private Long eventTime;
|
||||
private String attackerCountry;
|
||||
private String srcMac;
|
||||
private String destMac;
|
||||
private String proto;
|
||||
private Long devId;
|
||||
private Long createdTime;
|
||||
private String srcCountry;
|
||||
private String srcCountryCode;
|
||||
private String srcRegion;
|
||||
private String srcRegionCode;
|
||||
private String srcCity;
|
||||
private String srcLon;
|
||||
private String httpMethod;
|
||||
private String httpHost;
|
||||
private String httpReqHeader;
|
||||
private String httpReqBody;
|
||||
private String httpRespHeader;
|
||||
private String httpRespBody;
|
||||
private String fileType;
|
||||
private String fileMd5;
|
||||
private String fileSize;
|
||||
private String process;
|
||||
private Long startTime;
|
||||
private String action;
|
||||
private String attackerRegion;
|
||||
private Long endTime;
|
||||
private Long fileCreatedTime;
|
||||
private Long fileModifiedTime;
|
||||
private String tcMiguanScanPort;
|
||||
private String processPath;
|
||||
private String parentProcessPath;
|
||||
private String gname;
|
||||
private String exeName;
|
||||
private String exePath;
|
||||
private Long loginTime;
|
||||
private Long loginTimes;
|
||||
private String checkItem;
|
||||
private String checkType;
|
||||
private String attackerIp;
|
||||
private Long attackerPort;
|
||||
private String victimIp;
|
||||
private Long victimPort;
|
||||
private String attackerCity;
|
||||
private String attackerLon;
|
||||
private String attackerLat;
|
||||
private String victimCountry;
|
||||
private String victimRegion;
|
||||
private String victimCity;
|
||||
private String victimLon;
|
||||
private String victimLat;
|
||||
private String originEventId;
|
||||
private String originEventName;
|
||||
private String originEventCategory;
|
||||
private String originEventLevel;
|
||||
private String originAttackChain;
|
||||
private String engineType;
|
||||
private String evilPayload;
|
||||
private String httpRespStatus;
|
||||
private String dnsQuery;
|
||||
private String dnsQueryType;
|
||||
private String dnsTtl;
|
||||
private String dnsAnswer;
|
||||
private String dnsSubdomains;
|
||||
private String fileSha256;
|
||||
private String fileSsdeep;
|
||||
private String victimCountryCode;
|
||||
private String httpXffIp;
|
||||
private String tcMiguanClass;
|
||||
private String pid;
|
||||
private String ppid;
|
||||
private String processName;
|
||||
private String backdoorType;
|
||||
private String tty;
|
||||
private String sudoUser;
|
||||
private String sudoGroup;
|
||||
private String originEventType;
|
||||
private String destDomain;
|
||||
private String shellCmdline;
|
||||
private String parentCmdline;
|
||||
private String attackChain;
|
||||
private String processTree;
|
||||
private String hostFileSha256;
|
||||
private String hostFileMd5;
|
||||
private String hostFileSize;
|
||||
private String hostFileType;
|
||||
private String destCountry;
|
||||
private String destCountryCode;
|
||||
private String logOrigin;
|
||||
private String destRegion;
|
||||
private String srcLat;
|
||||
private String destRegionCode;
|
||||
private String destCity;
|
||||
private String destLon;
|
||||
private String destLat;
|
||||
private Integer eventCategory;
|
||||
private Integer attackResult;
|
||||
private String probeIp;
|
||||
private String deviceIp;
|
||||
private String deviceManufacturer;
|
||||
private String deviceName;
|
||||
private String productName;
|
||||
private String id1;
|
||||
private Long count;
|
||||
private String countReason;
|
||||
private Integer eventType;
|
||||
private String protocol;
|
||||
private String shellCmd;
|
||||
private String parentName;
|
||||
private String hostFilePath;
|
||||
private String uid;
|
||||
private Integer fall;
|
||||
private String tcMiguanServerIp;
|
||||
private Integer devType;
|
||||
private Integer collectMethod;
|
||||
private Integer fieldCateId;
|
||||
private Integer deviceType;
|
||||
private String tcMiguanClientIp;
|
||||
private String tcMiguanName;
|
||||
private Long originTotalPackages;
|
||||
private Long originTotalBytes;
|
||||
private Long originPeakPackagesRate;
|
||||
private Long originPeakBytesRate;
|
||||
private Long originPeakFlowsRate;
|
||||
private String aptOrgname;
|
||||
private String aptOrgmsg;
|
||||
private String mailMessageId;
|
||||
private String mailBcc;
|
||||
private String mailSize;
|
||||
private String mailAttachHashcode;
|
||||
private String mailUrl;
|
||||
private String mailCc;
|
||||
private String algorithm;
|
||||
private String miningpoolIp;
|
||||
private String processMd5;
|
||||
private String pprocessMd5;
|
||||
private String sourceServername;
|
||||
private String originSourceServername;
|
||||
private String mailFilename;
|
||||
private String dstUploadAppname;
|
||||
private Long targetPort;
|
||||
private String gid;
|
||||
private String originUid;
|
||||
private String originGid;
|
||||
private Long targetPorts;
|
||||
private String tcMiguanName1;
|
||||
private String tcMiguanClass1;
|
||||
private Long etlTime;
|
||||
private String tcMiguanScanPort2;
|
||||
private String desipSecurityScope;
|
||||
private String srcipSecurityScope;
|
||||
private Long collectTimeTs;
|
||||
private String tcMiguanScanPort1;
|
||||
private String srcDevName;
|
||||
private String collectProtocol;
|
||||
private String destinationSystemType;
|
||||
private String destinationSystem;
|
||||
private String etlHost;
|
||||
private Integer normalizeRuleId;
|
||||
private String normalizeRuleName;
|
||||
private String syslogUuid;
|
||||
private String syslogTopic;
|
||||
|
||||
}
|
||||
+381
@@ -0,0 +1,381 @@
|
||||
package com.common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class SyslogNormalData {
|
||||
private String id;
|
||||
private LocalDateTime createdAt;
|
||||
private LocalDateTime logTime;
|
||||
private Integer deviceId;
|
||||
private String webshellType;
|
||||
private String vuirsType;
|
||||
private String vuirsUrl;
|
||||
private String classFilename;
|
||||
private String classPath;
|
||||
private String parentClass;
|
||||
private String jarPath;
|
||||
private String classMd5;
|
||||
private String classLoader;
|
||||
private String classHashcode;
|
||||
private String classLoaderHashcode;
|
||||
private String tcNameip;
|
||||
private String performSql;
|
||||
private String tcAccount;
|
||||
private String tcAppname;
|
||||
private String processUname;
|
||||
private String pProcessUname;
|
||||
private String containerName;
|
||||
private String containerId;
|
||||
private String httpRespServer;
|
||||
private Long srcipId;
|
||||
private String cdnip;
|
||||
private String natip;
|
||||
private String mailSender;
|
||||
private String mailReceiver;
|
||||
private String vpnMac;
|
||||
private String vpnOs;
|
||||
private String vpnUser;
|
||||
private String vpnGroupname;
|
||||
private String vpnAccessIp;
|
||||
private Boolean destIpApt;
|
||||
private String originAttackResult;
|
||||
private String description;
|
||||
private String solution;
|
||||
private String attackCause;
|
||||
private String username;
|
||||
private String tcFlowId;
|
||||
private String loginResult;
|
||||
private String cmdline;
|
||||
private String originAttackAction;
|
||||
private String victimDomain;
|
||||
private String vpnDeviceid;
|
||||
private String vpnAccessAction;
|
||||
private Long fileAccessTime;
|
||||
private String fileName;
|
||||
private String tcClass;
|
||||
private String tcName2;
|
||||
private Long loginLasttime;
|
||||
private String originPermissions;
|
||||
private String beginPermissions;
|
||||
private Long printTime;
|
||||
private String printer;
|
||||
private String printerType;
|
||||
private Long printPages;
|
||||
private Long printCopies;
|
||||
private String srcDevice;
|
||||
private String dstDevice;
|
||||
private String srcFile;
|
||||
private String srcFileType;
|
||||
private String srcFilePath;
|
||||
private String dstFile;
|
||||
private String dstFileType;
|
||||
private String dstFilePath;
|
||||
private String dlpPolicyName;
|
||||
private String dlpPolicyType;
|
||||
private String dstUploadUrl;
|
||||
private String processUuid;
|
||||
private String pProcessUuid;
|
||||
private String env;
|
||||
private String bruteForceService;
|
||||
private String vuirsName;
|
||||
private Long httpReqLength;
|
||||
private String httpReqContentType;
|
||||
private String tcScanPort;
|
||||
private String tcLabels;
|
||||
private String httpRespContentType;
|
||||
private String dnsMsgType;
|
||||
private String dnsAnswerLength;
|
||||
private Boolean dnsIoc;
|
||||
private BigDecimal txBytes;
|
||||
private BigDecimal rxBytes;
|
||||
private BigDecimal allBytes;
|
||||
private Long durationTime;
|
||||
private String mailAttachName;
|
||||
private String mailSubject;
|
||||
private String mailMessage;
|
||||
private String mailSendServer;
|
||||
private String mailAgent;
|
||||
private String tlsVersion;
|
||||
private String tlsServerCert;
|
||||
private String tlsServerSuite;
|
||||
private String tlsClientSuitesLen;
|
||||
private String tlsJa3;
|
||||
private String tlsJa3s;
|
||||
private String vpnAccessPort;
|
||||
private String logTopic;
|
||||
private Long collectTime;
|
||||
private Boolean srcIsIntranetip;
|
||||
private Boolean srcIpIoc;
|
||||
private Boolean srcIpApt;
|
||||
private String srcipName;
|
||||
private String tcClient;
|
||||
private Long srcipOrganizationId;
|
||||
private Boolean destIpIntranetip;
|
||||
private Boolean destIpIoc;
|
||||
private Long desipId;
|
||||
private String desipName;
|
||||
private String tcHostip;
|
||||
private Long desipOrganizationId;
|
||||
private String originConfidence;
|
||||
private String originMalscore;
|
||||
private String attackerIcampaign;
|
||||
private Long attackerHostAssetId;
|
||||
private Long attackerOrganizationId;
|
||||
private Long victimHostAssetId;
|
||||
private Long victimOrganizationId;
|
||||
private Long logoutTime;
|
||||
private String httpReqLine;
|
||||
private String desipSecurityScopeId;
|
||||
private String srcipSecurityScopeId;
|
||||
private Long httpRespLength;
|
||||
private String tcAttackType;
|
||||
private String tcRealip;
|
||||
private String attackerIpLists;
|
||||
private String loginPassword;
|
||||
private String detail;
|
||||
private String attackerCountryCode;
|
||||
private String attackerRegionCode;
|
||||
private String victimRegionCode;
|
||||
private String payload;
|
||||
private String httpReferer;
|
||||
private String httpUserAgent;
|
||||
private String httpSession;
|
||||
private String httpQueryString;
|
||||
private String filePath;
|
||||
private String filePermission;
|
||||
private String loginAbnormalType;
|
||||
private String fileTag;
|
||||
private String filePlatform;
|
||||
private String targetIp;
|
||||
private String collectDate;
|
||||
private String tcClientIp;
|
||||
private String tcServerIp;
|
||||
private String tcExternalip;
|
||||
private Long httpStatusCode;
|
||||
private String deviceDomian;
|
||||
private String srcIpStr;
|
||||
private String srcPortStr;
|
||||
private String destIpStr;
|
||||
private String destPortStr;
|
||||
private String pcap;
|
||||
private String ioc;
|
||||
private String maliciousFamily;
|
||||
private String vulnCve;
|
||||
private String aliyunType;
|
||||
private String attackerHostAssetName;
|
||||
private String attackerOrganizationName;
|
||||
private String ctId;
|
||||
private String cveList;
|
||||
private String desipOrganizationName;
|
||||
private String destIpGroup;
|
||||
private String fileGid;
|
||||
private String fileOwner;
|
||||
private String fileOwnergroup;
|
||||
private String fileUid;
|
||||
private String httpRespCookie;
|
||||
private String originRuleId;
|
||||
private String originRuleName;
|
||||
private String serviceName;
|
||||
private String srcIpAssetGroup;
|
||||
private String srcipOrganizationName;
|
||||
private String victimHostAssetName;
|
||||
private Long httpRespCodes;
|
||||
private String victimOrganizationName;
|
||||
private String tcType;
|
||||
private String direction;
|
||||
private String httpReqCookie;
|
||||
private String httpReqProtocol;
|
||||
private String httpReqHeaderRaw;
|
||||
private String httpUrl;
|
||||
private String uname;
|
||||
private String originHostname;
|
||||
private String originOs;
|
||||
private String originAgentMac;
|
||||
private String originHostId;
|
||||
private String originAgentVersion;
|
||||
private String originAgentId;
|
||||
private String originAgentName;
|
||||
private String originWorkGroup;
|
||||
private String originAssetGroup;
|
||||
private Long originLocalPort;
|
||||
private String originAgentIp;
|
||||
private String originInternalIp;
|
||||
private String originExternalIp;
|
||||
private String originLocalAddr;
|
||||
private Long agentId;
|
||||
private String agentName;
|
||||
private String tcTitle;
|
||||
private String logId;
|
||||
private LocalDateTime eventDate;
|
||||
private Long eventTimeTs;
|
||||
private Integer eventLevel;
|
||||
private String srcIp;
|
||||
private Long srcPort;
|
||||
private String destIp;
|
||||
private Long destPort;
|
||||
private Long eventTime;
|
||||
private String attackerCountry;
|
||||
private String srcMac;
|
||||
private String destMac;
|
||||
private String proto;
|
||||
private Long devId;
|
||||
private Long createdTime;
|
||||
private String srcCountry;
|
||||
private String srcCountryCode;
|
||||
private String srcRegion;
|
||||
private String srcRegionCode;
|
||||
private String srcCity;
|
||||
private String srcLon;
|
||||
private String httpMethod;
|
||||
private String httpHost;
|
||||
private String httpReqHeader;
|
||||
private String httpReqBody;
|
||||
private String httpRespHeader;
|
||||
private String httpRespBody;
|
||||
private String fileType;
|
||||
private String fileMd5;
|
||||
private String fileSize;
|
||||
private String process;
|
||||
private Long startTime;
|
||||
private String action;
|
||||
private String attackerRegion;
|
||||
private Long endTime;
|
||||
private Long fileCreatedTime;
|
||||
private Long fileModifiedTime;
|
||||
private String tcMiguanScanPort;
|
||||
private String processPath;
|
||||
private String parentProcessPath;
|
||||
private String gname;
|
||||
private String exeName;
|
||||
private String exePath;
|
||||
private Long loginTime;
|
||||
private Long loginTimes;
|
||||
private String checkItem;
|
||||
private String checkType;
|
||||
private String attackerIp;
|
||||
private Long attackerPort;
|
||||
private String victimIp;
|
||||
private Long victimPort;
|
||||
private String attackerCity;
|
||||
private String attackerLon;
|
||||
private String attackerLat;
|
||||
private String victimCountry;
|
||||
private String victimRegion;
|
||||
private String victimCity;
|
||||
private String victimLon;
|
||||
private String victimLat;
|
||||
private String originEventId;
|
||||
private String originEventName;
|
||||
private String originEventCategory;
|
||||
private String originEventLevel;
|
||||
private String originAttackChain;
|
||||
private String engineType;
|
||||
private String evilPayload;
|
||||
private String httpRespStatus;
|
||||
private String dnsQuery;
|
||||
private String dnsQueryType;
|
||||
private String dnsTtl;
|
||||
private String dnsAnswer;
|
||||
private String dnsSubdomains;
|
||||
private String fileSha256;
|
||||
private String fileSsdeep;
|
||||
private String victimCountryCode;
|
||||
private String httpXffIp;
|
||||
private String tcMiguanClass;
|
||||
private String pid;
|
||||
private String ppid;
|
||||
private String processName;
|
||||
private String backdoorType;
|
||||
private String tty;
|
||||
private String sudoUser;
|
||||
private String sudoGroup;
|
||||
private String originEventType;
|
||||
private String destDomain;
|
||||
private String shellCmdline;
|
||||
private String parentCmdline;
|
||||
private String attackChain;
|
||||
private String processTree;
|
||||
private String hostFileSha256;
|
||||
private String hostFileMd5;
|
||||
private String hostFileSize;
|
||||
private String hostFileType;
|
||||
private String destCountry;
|
||||
private String destCountryCode;
|
||||
private String logOrigin;
|
||||
private String destRegion;
|
||||
private String srcLat;
|
||||
private String destRegionCode;
|
||||
private String destCity;
|
||||
private String destLon;
|
||||
private String destLat;
|
||||
private Integer eventCategory;
|
||||
private Integer attackResult;
|
||||
private String probeIp;
|
||||
private String deviceIp;
|
||||
private String deviceManufacturer;
|
||||
private String deviceName;
|
||||
private String productName;
|
||||
private String id1;
|
||||
private Long count;
|
||||
private String countReason;
|
||||
private Integer eventType;
|
||||
private String protocol;
|
||||
private String shellCmd;
|
||||
private String parentName;
|
||||
private String hostFilePath;
|
||||
private String uid;
|
||||
private Integer fall;
|
||||
private String tcMiguanServerIp;
|
||||
private Integer devType;
|
||||
private Integer collectMethod;
|
||||
private Integer fieldCateId;
|
||||
private Integer deviceType;
|
||||
private String tcMiguanClientIp;
|
||||
private String tcMiguanName;
|
||||
private Long originTotalPackages;
|
||||
private Long originTotalBytes;
|
||||
private Long originPeakPackagesRate;
|
||||
private Long originPeakBytesRate;
|
||||
private Long originPeakFlowsRate;
|
||||
private String aptOrgname;
|
||||
private String aptOrgmsg;
|
||||
private String mailMessageId;
|
||||
private String mailBcc;
|
||||
private String mailSize;
|
||||
private String mailAttachHashcode;
|
||||
private String mailUrl;
|
||||
private String mailCc;
|
||||
private String algorithm;
|
||||
private String miningpoolIp;
|
||||
private String processMd5;
|
||||
private String pprocessMd5;
|
||||
private String sourceServername;
|
||||
private String originSourceServername;
|
||||
private String mailFilename;
|
||||
private String dstUploadAppname;
|
||||
private Long targetPort;
|
||||
private String gid;
|
||||
private String originUid;
|
||||
private String originGid;
|
||||
private Long targetPorts;
|
||||
private String tcMiguanName1;
|
||||
private String tcMiguanClass1;
|
||||
private Long etlTime;
|
||||
private String tcMiguanScanPort2;
|
||||
private String desipSecurityScope;
|
||||
private String srcipSecurityScope;
|
||||
private Long collectTimeTs;
|
||||
private String tcMiguanScanPort1;
|
||||
private String srcDevName;
|
||||
private String collectProtocol;
|
||||
private String destinationSystemType;
|
||||
private String destinationSystem;
|
||||
private String etlHost;
|
||||
private Integer normalizeRuleId;
|
||||
private String normalizeRuleName;
|
||||
private String syslogUuid;
|
||||
private String syslogTopic;
|
||||
}
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
package com.common.entity;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
public class SyslogRequest {
|
||||
|
||||
@NotBlank(message = "IP地址不能为空")
|
||||
private String ip;
|
||||
|
||||
@NotNull(message = "端口号不能为空")
|
||||
private Integer port;
|
||||
|
||||
@NotBlank(message = "日志内容不能为空")
|
||||
private String logContent;
|
||||
|
||||
private String protocol = "UDP"; // 默认UDP协议
|
||||
private String facility = "USER"; // 设施
|
||||
private String severity = "INFO"; // 严重级别
|
||||
|
||||
// 构造函数
|
||||
public SyslogRequest() {}
|
||||
|
||||
public SyslogRequest(String ip, Integer port, String logContent) {
|
||||
this.ip = ip;
|
||||
this.port = port;
|
||||
this.logContent = logContent;
|
||||
}
|
||||
|
||||
// Getter和Setter方法
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
public Integer getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(Integer port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public String getLogContent() {
|
||||
return logContent;
|
||||
}
|
||||
|
||||
public void setLogContent(String logContent) {
|
||||
this.logContent = logContent;
|
||||
}
|
||||
|
||||
public String getProtocol() {
|
||||
return protocol;
|
||||
}
|
||||
|
||||
public void setProtocol(String protocol) {
|
||||
this.protocol = protocol;
|
||||
}
|
||||
|
||||
public String getFacility() {
|
||||
return facility;
|
||||
}
|
||||
|
||||
public void setFacility(String facility) {
|
||||
this.facility = facility;
|
||||
}
|
||||
|
||||
public String getSeverity() {
|
||||
return severity;
|
||||
}
|
||||
|
||||
public void setSeverity(String severity) {
|
||||
this.severity = severity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SyslogRequest{" +
|
||||
"ip='" + ip + '\'' +
|
||||
", port=" + port +
|
||||
", logContent='" + logContent + '\'' +
|
||||
", protocol='" + protocol + '\'' +
|
||||
", facility='" + facility + '\'' +
|
||||
", severity='" + severity + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
package com.common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 微信通知实体类
|
||||
* 对应表: wecom_notification
|
||||
*/
|
||||
@Data
|
||||
public class WecomNotification {
|
||||
|
||||
/** 企微通知id */
|
||||
private Long wecomNotificationId;
|
||||
|
||||
/** 用户信息 */
|
||||
private String userId;
|
||||
|
||||
/** 通知名称 */
|
||||
private String wecomNotificationName;
|
||||
|
||||
/** 通知IP */
|
||||
private String wecomNotificationIp;
|
||||
|
||||
/** 通知类型 */
|
||||
private String wecomNotificationType;
|
||||
|
||||
/** 通知等级 */
|
||||
private String wecomNotificationLevel;
|
||||
|
||||
/** 通知内容 */
|
||||
private String wecomNotificationContent;
|
||||
|
||||
/** 告警通知时间 */
|
||||
private LocalDateTime wecomNotificationTime;
|
||||
|
||||
/** 租户编号 */
|
||||
private String tenantId;
|
||||
|
||||
/** 创建部门 */
|
||||
private Long createDept;
|
||||
|
||||
/** 创建者 */
|
||||
private Long createBy;
|
||||
|
||||
/** 创建时间 */
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/** 更新者 */
|
||||
private Long updateBy;
|
||||
|
||||
/** 更新时间 */
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
/** 通知状态(0:已发送, 1:未发送) */
|
||||
private String wecomNotificationStatus;
|
||||
|
||||
public WecomNotification() {
|
||||
}
|
||||
|
||||
public WecomNotification(String wecomNotificationName, String wecomNotificationType,
|
||||
String wecomNotificationLevel, String wecomNotificationContent) {
|
||||
this.wecomNotificationName = wecomNotificationName;
|
||||
this.wecomNotificationType = wecomNotificationType;
|
||||
this.wecomNotificationLevel = wecomNotificationLevel;
|
||||
this.wecomNotificationContent = wecomNotificationContent;
|
||||
this.wecomNotificationTime = LocalDateTime.now();
|
||||
this.wecomNotificationStatus = "1"; // 默认未发送
|
||||
this.createTime = LocalDateTime.now();
|
||||
}
|
||||
}
|
||||
+260
@@ -0,0 +1,260 @@
|
||||
package com.common.entity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* XDR Honeypot 实体类
|
||||
* 对应数据库表 xdr_honeypot
|
||||
*/
|
||||
public class XdrHoneypot {
|
||||
private Long id;
|
||||
private String vcsource;
|
||||
private String dstartTime;
|
||||
private String dtime;
|
||||
private String riskLevel;
|
||||
private String vcconnection;
|
||||
private String fileInfo;
|
||||
private String extra;
|
||||
private String vctype;
|
||||
private String agentSn;
|
||||
private String agentName;
|
||||
private String honeypotId;
|
||||
private String honeypotName;
|
||||
private String srcIp;
|
||||
private String srcPort;
|
||||
private String srcMac;
|
||||
private String destIp;
|
||||
private String destPort;
|
||||
private String proxyIp;
|
||||
private String node;
|
||||
private LocalDateTime createTime;
|
||||
|
||||
// 默认构造函数
|
||||
public XdrHoneypot() {
|
||||
this.createTime = LocalDateTime.now();
|
||||
}
|
||||
|
||||
// 带参构造函数
|
||||
public XdrHoneypot(String vcsource, String dstartTime, String dtime, String riskLevel,
|
||||
String vcconnection, String fileInfo, String extra, String vctype,
|
||||
String agentSn, String agentName, String honeypotId, String honeypotName,
|
||||
String srcIp, String srcPort, String srcMac, String destIp,
|
||||
String destPort, String proxyIp, String node) {
|
||||
this();
|
||||
this.vcsource = vcsource;
|
||||
this.dstartTime = dstartTime;
|
||||
this.dtime = dtime;
|
||||
this.riskLevel = riskLevel;
|
||||
this.vcconnection = vcconnection;
|
||||
this.fileInfo = fileInfo;
|
||||
this.extra = extra;
|
||||
this.vctype = vctype;
|
||||
this.agentSn = agentSn;
|
||||
this.agentName = agentName;
|
||||
this.honeypotId = honeypotId;
|
||||
this.honeypotName = honeypotName;
|
||||
this.srcIp = srcIp;
|
||||
this.srcPort = srcPort;
|
||||
this.srcMac = srcMac;
|
||||
this.destIp = destIp;
|
||||
this.destPort = destPort;
|
||||
this.proxyIp = proxyIp;
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
// Getter 和 Setter 方法
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getVcsource() {
|
||||
return vcsource;
|
||||
}
|
||||
|
||||
public void setVcsource(String vcsource) {
|
||||
this.vcsource = vcsource;
|
||||
}
|
||||
|
||||
public String getDstartTime() {
|
||||
return dstartTime;
|
||||
}
|
||||
|
||||
public void setDstartTime(String dstartTime) {
|
||||
this.dstartTime = dstartTime;
|
||||
}
|
||||
|
||||
public String getDtime() {
|
||||
return dtime;
|
||||
}
|
||||
|
||||
public void setDtime(String dtime) {
|
||||
this.dtime = dtime;
|
||||
}
|
||||
|
||||
public String getRiskLevel() {
|
||||
return riskLevel;
|
||||
}
|
||||
|
||||
public void setRiskLevel(String riskLevel) {
|
||||
this.riskLevel = riskLevel;
|
||||
}
|
||||
|
||||
public String getVcconnection() {
|
||||
return vcconnection;
|
||||
}
|
||||
|
||||
public void setVcconnection(String vcconnection) {
|
||||
this.vcconnection = vcconnection;
|
||||
}
|
||||
|
||||
public String getFileInfo() {
|
||||
return fileInfo;
|
||||
}
|
||||
|
||||
public void setFileInfo(String fileInfo) {
|
||||
this.fileInfo = fileInfo;
|
||||
}
|
||||
|
||||
public String getExtra() {
|
||||
return extra;
|
||||
}
|
||||
|
||||
public void setExtra(String extra) {
|
||||
this.extra = extra;
|
||||
}
|
||||
|
||||
public String getVctype() {
|
||||
return vctype;
|
||||
}
|
||||
|
||||
public void setVctype(String vctype) {
|
||||
this.vctype = vctype;
|
||||
}
|
||||
|
||||
public String getAgentSn() {
|
||||
return agentSn;
|
||||
}
|
||||
|
||||
public void setAgentSn(String agentSn) {
|
||||
this.agentSn = agentSn;
|
||||
}
|
||||
|
||||
public String getAgentName() {
|
||||
return agentName;
|
||||
}
|
||||
|
||||
public void setAgentName(String agentName) {
|
||||
this.agentName = agentName;
|
||||
}
|
||||
|
||||
public String getHoneypotId() {
|
||||
return honeypotId;
|
||||
}
|
||||
|
||||
public void setHoneypotId(String honeypotId) {
|
||||
this.honeypotId = honeypotId;
|
||||
}
|
||||
|
||||
public String getHoneypotName() {
|
||||
return honeypotName;
|
||||
}
|
||||
|
||||
public void setHoneypotName(String honeypotName) {
|
||||
this.honeypotName = honeypotName;
|
||||
}
|
||||
|
||||
public String getSrcIp() {
|
||||
return srcIp;
|
||||
}
|
||||
|
||||
public void setSrcIp(String srcIp) {
|
||||
this.srcIp = srcIp;
|
||||
}
|
||||
|
||||
public String getSrcPort() {
|
||||
return srcPort;
|
||||
}
|
||||
|
||||
public void setSrcPort(String srcPort) {
|
||||
this.srcPort = srcPort;
|
||||
}
|
||||
|
||||
public String getSrcMac() {
|
||||
return srcMac;
|
||||
}
|
||||
|
||||
public void setSrcMac(String srcMac) {
|
||||
this.srcMac = srcMac;
|
||||
}
|
||||
|
||||
public String getDestIp() {
|
||||
return destIp;
|
||||
}
|
||||
|
||||
public void setDestIp(String destIp) {
|
||||
this.destIp = destIp;
|
||||
}
|
||||
|
||||
public String getDestPort() {
|
||||
return destPort;
|
||||
}
|
||||
|
||||
public void setDestPort(String destPort) {
|
||||
this.destPort = destPort;
|
||||
}
|
||||
|
||||
public String getProxyIp() {
|
||||
return proxyIp;
|
||||
}
|
||||
|
||||
public void setProxyIp(String proxyIp) {
|
||||
this.proxyIp = proxyIp;
|
||||
}
|
||||
|
||||
public String getNode() {
|
||||
return node;
|
||||
}
|
||||
|
||||
public void setNode(String node) {
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(LocalDateTime createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "XdrHoneypot{" +
|
||||
"id=" + id +
|
||||
", vcsource='" + vcsource + '\'' +
|
||||
", dstartTime='" + dstartTime + '\'' +
|
||||
", dtime='" + dtime + '\'' +
|
||||
", riskLevel='" + riskLevel + '\'' +
|
||||
", vcconnection='" + vcconnection + '\'' +
|
||||
", fileInfo='" + fileInfo + '\'' +
|
||||
", extra='" + extra + '\'' +
|
||||
", vctype='" + vctype + '\'' +
|
||||
", agentSn='" + agentSn + '\'' +
|
||||
", agentName='" + agentName + '\'' +
|
||||
", honeypotId='" + honeypotId + '\'' +
|
||||
", honeypotName='" + honeypotName + '\'' +
|
||||
", srcIp='" + srcIp + '\'' +
|
||||
", srcPort='" + srcPort + '\'' +
|
||||
", srcMac='" + srcMac + '\'' +
|
||||
", destIp='" + destIp + '\'' +
|
||||
", destPort='" + destPort + '\'' +
|
||||
", proxyIp='" + proxyIp + '\'' +
|
||||
", node='" + node + '\'' +
|
||||
", createTime=" + createTime +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.Alarm;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Mapper
|
||||
public interface AlarmMapper {
|
||||
|
||||
/**
|
||||
* 批量插入告警数据
|
||||
*/
|
||||
@Insert({"<script>",
|
||||
"INSERT INTO alarm (",
|
||||
"id, created_at, alarm_name, alarm_level, alarm_type, ",
|
||||
"alarm_major_type, alarm_minor_type,alarm_area_id, attack_ip, victim_ip, victim_web_url, ",
|
||||
"device_id, comment,origin_log_ids,log_start_at, log_end_at, window_time, http_status, ",
|
||||
"attack_port, victim_port, attack_method, etl_time, log_count, ",
|
||||
"attack_chain_phase, disposition_advice, attack_direction, ",
|
||||
"judged_state, disposed_state, attack_result, fall, payload, dns_info, engine_type, " ,
|
||||
"http_req_header , http_req_body,http_resp_header , http_resp_body ",
|
||||
") VALUES ",
|
||||
"<foreach collection='list' item='item' separator=','>",
|
||||
"( #{item.id}, #{item.createdAt}, #{item.alarmName}, #{item.alarmLevel}, ",
|
||||
"#{item.alarmType}, #{item.alarmMajorType}, #{item.alarmMinorType}, #{item.alarmAreaId}, ",
|
||||
"#{item.attackIp, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, ",
|
||||
"#{item.victimIp, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, ",
|
||||
"#{item.victimWebUrl, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, ",
|
||||
"#{item.deviceId, typeHandler=com.Modules.etl.handler.ArrayIntegerTypeHandler}, ",
|
||||
"#{item.comment}, " ,
|
||||
"#{item.originLogIds, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, ",
|
||||
"#{item.logStartAt}, #{item.logEndAt}, #{item.windowTime}, #{item.httpStatus}, ",
|
||||
"#{item.attackPort, typeHandler=com.Modules.etl.handler.ArrayIntegerTypeHandler}, ",
|
||||
"#{item.victimPort, typeHandler=com.Modules.etl.handler.ArrayIntegerTypeHandler}, ",
|
||||
"#{item.attackMethod}, #{item.etlTime}, #{item.logCount}, ",
|
||||
"#{item.attackChainPhase, typeHandler=com.Modules.etl.handler.ArrayIntegerTypeHandler}, ",
|
||||
"#{item.dispositionAdvice}, #{item.attackDirection}, ",
|
||||
"#{item.judgedState}, #{item.disposedState}, #{item.attackResult}, #{item.fall}, ",
|
||||
"#{item.payload},#{item.dnsInfo}, #{item.engineType}, ",
|
||||
"#{item.httpReqHeader, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, ",
|
||||
"#{item.httpReqBody, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, ",
|
||||
"#{item.httpRespHeader, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, ",
|
||||
"#{item.httpRespBody, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler})",
|
||||
"</foreach>",
|
||||
"</script>"})
|
||||
void batchInsert(@Param("list") List<Alarm> alarmList);
|
||||
|
||||
/**
|
||||
* 单条插入告警数据
|
||||
*/
|
||||
@Insert("INSERT INTO alarm (" +
|
||||
"id, created_at, alarm_name, alarm_level, alarm_type, " +
|
||||
"alarm_major_type, alarm_minor_type,alarm_area_id, attack_ip, victim_ip, victim_web_url, " +
|
||||
"device_id, comment,origin_log_ids, log_start_at, log_end_at, window_time, http_status, " +
|
||||
"attack_port, victim_port, attack_method, etl_time, log_count, " +
|
||||
"attack_chain_phase, disposition_advice, attack_direction, " +
|
||||
"judged_state, disposed_state, attack_result, fall, payload, dns_info, engine_type, " +
|
||||
"http_req_header , http_req_body,http_resp_header , http_resp_body " +
|
||||
") VALUES (" +
|
||||
"#{id}, #{createdAt}, #{alarmName}, #{alarmLevel}, " +
|
||||
"#{alarmType}, #{alarmMajorType}, #{alarmMinorType}, #{alarmAreaId}, " +
|
||||
"#{attackIp, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, " +
|
||||
"#{victimIp, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, " +
|
||||
"#{victimWebUrl, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, "+
|
||||
"#{deviceId, typeHandler=com.Modules.etl.handler.ArrayIntegerTypeHandler}, " +
|
||||
"#{comment}, " +
|
||||
"#{originLogIds, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, " +
|
||||
"#{logStartAt}, #{logEndAt}, #{windowTime},#{httpStatus}, " +
|
||||
"#{attackPort, typeHandler=com.Modules.etl.handler.ArrayIntegerTypeHandler}, " +
|
||||
"#{victimPort, typeHandler=com.Modules.etl.handler.ArrayIntegerTypeHandler}, " +
|
||||
"#{attackMethod}, #{etlTime}, #{logCount}, " +
|
||||
"#{attackChainPhase, typeHandler=com.Modules.etl.handler.ArrayIntegerTypeHandler}, " +
|
||||
"#{dispositionAdvice}, #{attackDirection}, " +
|
||||
"#{judgedState}, #{disposedState}, #{attackResult}, #{fall}, #{payload}, #{dnsInfo},#{engineType}, " +
|
||||
"#{httpReqHeader, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, " +
|
||||
"#{httpReqBody, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, " +
|
||||
"#{httpRespHeader, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, " +
|
||||
"#{httpRespBody, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler} " +
|
||||
")")
|
||||
void insert(Alarm alarm);
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.Alarm;
|
||||
import com.common.entity.AlarmVisit;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Mapper
|
||||
public interface AlarmVisitMapper {
|
||||
|
||||
/**
|
||||
* 批量插入告警数据
|
||||
*/
|
||||
@Insert({"<script>",
|
||||
"INSERT INTO alarm_visit (",
|
||||
"id, created_at, alarm_name, alarm_level, alarm_type, ",
|
||||
"alarm_major_type, alarm_minor_type,alarm_area_id, attack_ip, victim_ip, victim_web_url, ",
|
||||
"device_id, comment,origin_log_ids,log_start_at, log_end_at,window_time, http_status, ",
|
||||
"attack_port, victim_port, attack_method, etl_time, log_count, ",
|
||||
"attack_chain_phase, disposition_advice, attack_direction, ",
|
||||
"judged_state, disposed_state, attack_result, fall, payload, dns_info, engine_type, " ,
|
||||
"http_req_header , http_req_body,http_resp_header , http_resp_body ",
|
||||
") VALUES ",
|
||||
"<foreach collection='list' item='item' separator=','>",
|
||||
"(#{item.id}, #{item.createdAt}, #{item.alarmName}, #{item.alarmLevel}, ",
|
||||
"#{item.alarmType}, #{item.alarmMajorType}, #{item.alarmMinorType}, #{item.alarmAreaId}, ",
|
||||
"#{item.attackIp, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, ",
|
||||
"#{item.victimIp, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, ",
|
||||
"#{item.victimWebUrl, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, ",
|
||||
"#{item.deviceId, typeHandler=com.Modules.etl.handler.ArrayIntegerTypeHandler}, ",
|
||||
"#{item.comment}, " ,
|
||||
"#{item.originLogIds, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, ",
|
||||
"#{item.logStartAt}, #{item.logEndAt},, #{item.windowTime} #{item.httpStatus}, ",
|
||||
"#{item.attackPort, typeHandler=com.Modules.etl.handler.ArrayIntegerTypeHandler}, ",
|
||||
"#{item.victimPort, typeHandler=com.Modules.etl.handler.ArrayIntegerTypeHandler}, ",
|
||||
"#{item.attackMethod}, #{item.etlTime}, #{item.logCount}, ",
|
||||
"#{item.attackChainPhase, typeHandler=com.Modules.etl.handler.ArrayIntegerTypeHandler}, ",
|
||||
"#{item.dispositionAdvice}, #{item.attackDirection}, ",
|
||||
"#{item.judgedState}, #{item.disposedState}, #{item.attackResult}, #{item.fall}, ",
|
||||
"#{item.payload},#{item.dnsInfo}, #{item.engineType}, ",
|
||||
"#{item.httpReqHeader, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, ",
|
||||
"#{item.httpReqBody, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, ",
|
||||
"#{item.httpRespHeader, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, ",
|
||||
"#{item.httpRespBody, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}) ",
|
||||
"</foreach>",
|
||||
"</script>"})
|
||||
void batchInsert(@Param("list") List<AlarmVisit> alarmList);
|
||||
|
||||
/**
|
||||
* 单条插入告警数据
|
||||
*/
|
||||
@Insert("INSERT INTO alarm_visit (" +
|
||||
"id, created_at, alarm_name, alarm_level, alarm_type, " +
|
||||
"alarm_major_type, alarm_minor_type,alarm_area_id, attack_ip, victim_ip, victim_web_url, " +
|
||||
"device_id, comment,origin_log_ids, log_start_at, log_end_at, window_time,http_status, " +
|
||||
"attack_port, victim_port, attack_method, etl_time, log_count, " +
|
||||
"attack_chain_phase, disposition_advice, attack_direction, " +
|
||||
"judged_state, disposed_state, attack_result, fall, payload, dns_info,engine_type, " +
|
||||
"http_req_header , http_req_body,http_resp_header , http_resp_body " +
|
||||
") VALUES (" +
|
||||
"#{id}, #{createdAt}, #{alarmName}, #{alarmLevel}, " +
|
||||
"#{alarmType}, #{alarmMajorType}, #{alarmMinorType}, #{alarmAreaId}, " +
|
||||
"#{attackIp, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, " +
|
||||
"#{victimIp, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, " +
|
||||
"#{victimWebUrl, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, "+
|
||||
"#{deviceId, typeHandler=com.Modules.etl.handler.ArrayIntegerTypeHandler}, " +
|
||||
"#{comment}, " +
|
||||
"#{originLogIds, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, " +
|
||||
"#{logStartAt}, #{logEndAt}, #{windowTime}, #{httpStatus}, " +
|
||||
"#{attackPort, typeHandler=com.Modules.etl.handler.ArrayIntegerTypeHandler}, " +
|
||||
"#{victimPort, typeHandler=com.Modules.etl.handler.ArrayIntegerTypeHandler}, " +
|
||||
"#{attackMethod}, #{etlTime}, #{logCount}, " +
|
||||
"#{attackChainPhase, typeHandler=com.Modules.etl.handler.ArrayIntegerTypeHandler}, " +
|
||||
"#{dispositionAdvice}, #{attackDirection}, " +
|
||||
"#{judgedState}, #{disposedState}, #{attackResult}, #{fall}, #{payload},#{dnsInfo} ,#{engineType}, " +
|
||||
"#{httpReqHeader, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, " +
|
||||
"#{httpReqBody, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, " +
|
||||
"#{httpRespHeader, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, " +
|
||||
"#{httpRespBody, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler} " +
|
||||
")")
|
||||
void insert(AlarmVisit alarm);
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.AnalysisAnalysisRule;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
/**
|
||||
* 分析规则Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface AnalysisAnalysisRuleMapper {
|
||||
|
||||
/**
|
||||
* 查询指定运行模式的活动规则
|
||||
*
|
||||
* @param runMode 运行模式:realtime-实时/offline-离线
|
||||
* @return 规则列表
|
||||
*/
|
||||
List<AnalysisAnalysisRule> selectActiveRulesByRunMode(@Param("runMode") String runMode);
|
||||
|
||||
/**
|
||||
* 根据规则ID查询规则
|
||||
*
|
||||
* @param ruleId 规则ID
|
||||
* @return 规则信息
|
||||
*/
|
||||
AnalysisAnalysisRule selectByRuleId(@Param("ruleId") String ruleId);
|
||||
|
||||
/**
|
||||
* 更新规则任务状态
|
||||
*
|
||||
* @param ruleId 规则ID
|
||||
* @param taskStatus 任务状态
|
||||
* @param updateBy 更新人ID
|
||||
* @return 影响行数
|
||||
*/
|
||||
int updateTaskStatus(@Param("ruleId") String ruleId,
|
||||
@Param("taskStatus") String taskStatus,
|
||||
@Param("updateBy") Long updateBy);
|
||||
|
||||
/**
|
||||
* 根据ID查询规则
|
||||
*
|
||||
* @param ruleId 规则ID
|
||||
* @return 规则信息
|
||||
*/
|
||||
AnalysisAnalysisRule selectById(@Param("ruleId") String ruleId);
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.AnalysisField;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
/**
|
||||
* 分析字段配置Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface AnalysisFieldMapper {
|
||||
|
||||
/**
|
||||
* 根据规则ID查询字段配置
|
||||
*
|
||||
* @param ruleId 规则ID
|
||||
* @return 字段列表
|
||||
*/
|
||||
List<AnalysisField> selectByRuleId(@Param("ruleId") String ruleId);
|
||||
|
||||
/**
|
||||
* 查询规则中用于SELECT的字段
|
||||
*
|
||||
* @param ruleId 规则ID
|
||||
* @return 字段列表
|
||||
*/
|
||||
List<AnalysisField> selectSelectFieldsByRuleId(@Param("ruleId") String ruleId);
|
||||
|
||||
/**
|
||||
* 查询规则中用于GROUP BY的字段
|
||||
*
|
||||
* @param ruleId 规则ID
|
||||
* @return 字段列表
|
||||
*/
|
||||
List<AnalysisField> selectGroupByFieldsByRuleId(@Param("ruleId") String ruleId);
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.AnalysisFilter;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分析过滤条件Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface AnalysisFilterMapper {
|
||||
|
||||
/**
|
||||
* 根据规则ID查询过滤条件
|
||||
*
|
||||
* @param ruleId 规则ID
|
||||
* @return 过滤条件列表
|
||||
*/
|
||||
List<AnalysisFilter> selectByRuleId(@Param("ruleId") String ruleId);
|
||||
|
||||
/**
|
||||
* 根据字段ID查询过滤条件
|
||||
*
|
||||
* @param fieldId 字段ID
|
||||
* @return 过滤条件列表
|
||||
*/
|
||||
List<AnalysisFilter> selectByFieldId(@Param("fieldId") Long fieldId);
|
||||
|
||||
/**
|
||||
* 根据条件ID查询过滤条件(与where_condition表关联)
|
||||
*
|
||||
* @param condId 条件ID
|
||||
* @return 过滤条件列表
|
||||
*/
|
||||
List<AnalysisFilter> selectByCondId(@Param("condId") Integer condId);
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.AnalysisGroupByColumn;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分组字段配置Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface AnalysisGroupByColumnMapper {
|
||||
|
||||
/**
|
||||
* 根据规则ID查询分组字段配置
|
||||
*
|
||||
* @param ruleId 规则ID
|
||||
* @return 分组字段列表
|
||||
*/
|
||||
List<AnalysisGroupByColumn> selectByRuleId(@Param("ruleId") String ruleId);
|
||||
|
||||
/**
|
||||
* 根据分组ID查询分组字段配置
|
||||
*
|
||||
* @param groupById 分组ID
|
||||
* @return 分组字段列表
|
||||
*/
|
||||
List<AnalysisGroupByColumn> selectByGroupById(@Param("groupById") Integer groupById);
|
||||
|
||||
/**
|
||||
* 根据用户组ID查询分组字段配置
|
||||
*
|
||||
* @param groupId 用户组ID
|
||||
* @return 分组字段列表
|
||||
*/
|
||||
List<AnalysisGroupByColumn> selectByGroupId(@Param("groupId") Long groupId);
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.AnalysisGroupByHaving;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分析分组聚合条件Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface AnalysisGroupByHavingMapper {
|
||||
|
||||
/**
|
||||
* 根据分组ID查询HAVING条件
|
||||
*
|
||||
* @param groupById 分组ID
|
||||
* @return HAVING条件列表
|
||||
*/
|
||||
List<AnalysisGroupByHaving> selectByGroupById(@Param("groupById") Integer groupById);
|
||||
|
||||
/**
|
||||
* 根据规则ID查询HAVING条件(通过关联分组表)
|
||||
*
|
||||
* @param ruleId 规则ID
|
||||
* @return HAVING条件列表
|
||||
*/
|
||||
List<AnalysisGroupByHaving> selectByRuleId(@Param("ruleId") String ruleId);
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.AnalysisGroupBy;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分组规则配置Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface AnalysisGroupByMapper {
|
||||
|
||||
/**
|
||||
* 根据规则ID查询分组配置
|
||||
*
|
||||
* @param ruleId 规则ID
|
||||
* @return 分组配置列表
|
||||
*/
|
||||
List<AnalysisGroupBy> selectByRuleId(@Param("ruleId") String ruleId);
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.AnalysisGroupByWindow;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 分析时间窗口配置Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface AnalysisGroupByWindowMapper {
|
||||
|
||||
/**
|
||||
* 根据分组ID查询窗口配置
|
||||
*
|
||||
* @param groupById 分组ID
|
||||
* @return 窗口配置
|
||||
*/
|
||||
AnalysisGroupByWindow selectByGroupById(@Param("groupById") Integer groupById);
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.AnalysisTaskHistory;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分析任务历史Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface AnalysisTaskHistoryMapper {
|
||||
|
||||
/**
|
||||
* 插入任务历史记录
|
||||
*
|
||||
* @param history 任务历史
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insert(AnalysisTaskHistory history);
|
||||
|
||||
/**
|
||||
* 更新任务历史记录
|
||||
*
|
||||
* @param history 任务历史
|
||||
* @return 影响行数
|
||||
*/
|
||||
int update(AnalysisTaskHistory history);
|
||||
|
||||
/**
|
||||
* 根据规则ID查询最近的任务历史
|
||||
*
|
||||
* @param ruleId 规则ID
|
||||
* @param limit 查询数量
|
||||
* @return 任务历史列表
|
||||
*/
|
||||
List<AnalysisTaskHistory> selectRecentByRuleId(@Param("ruleId") String ruleId,
|
||||
@Param("limit") int limit);
|
||||
|
||||
/**
|
||||
* 根据规则ID和状态查询任务历史
|
||||
*
|
||||
* @param ruleId 规则ID
|
||||
* @param status 状态
|
||||
* @return 任务历史
|
||||
*/
|
||||
AnalysisTaskHistory selectByRuleIdAndStatus(@Param("ruleId") String ruleId,
|
||||
@Param("status") String status);
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.AnalysisWhereCondition;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* WHERE条件Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface AnalysisWhereConditionMapper {
|
||||
|
||||
/**
|
||||
* 根据规则ID查询WHERE条件
|
||||
*
|
||||
* @param ruleId 规则ID
|
||||
* @return WHERE条件列表
|
||||
*/
|
||||
List<AnalysisWhereCondition> selectByRuleId(@Param("ruleId") String ruleId);
|
||||
|
||||
/**
|
||||
* 查询根节点条件(无父节点)
|
||||
*
|
||||
* @param ruleId 规则ID
|
||||
* @return 根条件列表
|
||||
*/
|
||||
List<AnalysisWhereCondition> selectRootConditions(@Param("ruleId") String ruleId);
|
||||
|
||||
/**
|
||||
* 查询指定条件的子条件
|
||||
*
|
||||
* @param parentCondId 父条件ID
|
||||
* @return 子条件列表
|
||||
*/
|
||||
List<AnalysisWhereCondition> selectChildConditions(@Param("parentCondId") String parentCondId);
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package com.common.mapper;
|
||||
|
||||
|
||||
import com.common.entity.AppLogEntity;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface AppLogMapper {
|
||||
|
||||
/**
|
||||
* 插入日志
|
||||
*/
|
||||
@Insert("INSERT INTO applog (es_index, es_type, es_id, es_score, dt_time, collect_time, log_type, " +
|
||||
"trace_id, method, app_name, ip, class_name, env, content, thread_name, log_level, seq, " +
|
||||
"indexed_at, log_date, created_at, updated_at) " +
|
||||
"VALUES (#{esIndex}, #{esType}, #{esId}, #{esScore}, #{dtTime}, #{collectTime}, #{logType}, " +
|
||||
"#{traceId}, #{method}, #{appName}, #{ip}, #{className}, #{env}, #{content}, #{threadName}, " +
|
||||
"#{logLevel}, #{seq}, #{indexedAt}, #{logDate}, #{createdAt}, #{updatedAt})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
int insert(AppLogEntity appLog);
|
||||
|
||||
/**
|
||||
* 批量插入
|
||||
*/
|
||||
int batchInsert(@Param("list") List<AppLogEntity> appLogs);
|
||||
|
||||
/**
|
||||
* 根据ES ID检查是否存在
|
||||
*/
|
||||
@Select("SELECT COUNT(1) FROM applog WHERE es_id = #{esId}")
|
||||
boolean existsByEsId(String esId);
|
||||
|
||||
/**
|
||||
* 根据ES ID和索引检查是否存在
|
||||
*/
|
||||
@Select("SELECT COUNT(1) FROM applog WHERE es_id = #{esId} AND es_index = #{esIndex}")
|
||||
boolean existsByEsIdAndIndex(@Param("esId") String esId, @Param("esIndex") String esIndex);
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.DeviceCollectHeartbeatHistory;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 探针心跳历史 Mapper 接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface DeviceCollectHeartbeatHistoryMapper {
|
||||
|
||||
/**
|
||||
* 插入心跳历史记录
|
||||
*/
|
||||
@Insert("INSERT INTO device_collect_heartbeat_history (" +
|
||||
"collect_id, heartbeat_time, device_ip, app_version, created_at " +
|
||||
") VALUES (" +
|
||||
"#{collectId}, #{heartbeatTime}, #{deviceIp}, #{appVersion}, #{createdAt} " +
|
||||
")")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
int insert(DeviceCollectHeartbeatHistory history);
|
||||
|
||||
/**
|
||||
* 批量插入心跳历史记录
|
||||
*/
|
||||
@Insert("<script>" +
|
||||
"INSERT INTO device_collect_heartbeat_history " +
|
||||
"(collect_id, heartbeat_time, device_ip, app_version, created_at ) " +
|
||||
"VALUES " +
|
||||
"<foreach collection='list' item='item' separator=','>" +
|
||||
"(#{item.collectId}, #{item.heartbeatTime}, #{item.deviceIp}, #{item.appVersion}, " +
|
||||
"#{item.createdAt} )" +
|
||||
"</foreach>" +
|
||||
"</script>")
|
||||
int batchInsert(@Param("list") List<DeviceCollectHeartbeatHistory> histories);
|
||||
|
||||
/**
|
||||
* 根据探针ID查询历史记录
|
||||
*/
|
||||
@Select("SELECT * FROM device_collect_heartbeat_history " +
|
||||
"WHERE collect_id = #{collectId} ORDER BY heartbeat_time DESC LIMIT #{limit}")
|
||||
List<DeviceCollectHeartbeatHistory> selectByCollectId(@Param("collectId") String collectId,
|
||||
@Param("limit") Integer limit);
|
||||
|
||||
/**
|
||||
* 删除指定日期之前的记录
|
||||
*/
|
||||
@Delete("DELETE FROM device_collect_heartbeat_history WHERE created_at < #{beforeTime}")
|
||||
int deleteBeforeTime(@Param("beforeTime") LocalDateTime beforeTime);
|
||||
|
||||
/**
|
||||
* 统计指定日期之前的记录数
|
||||
*/
|
||||
@Select("SELECT COUNT(*) FROM device_collect_heartbeat_history WHERE created_at < #{beforeTime}")
|
||||
long countBeforeTime(@Param("beforeTime") LocalDateTime beforeTime);
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.DeviceCollectHeartbeat;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 探针心跳状态 Mapper 接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface DeviceCollectHeartbeatMapper {
|
||||
|
||||
/**
|
||||
* 根据探针ID查询
|
||||
*/
|
||||
@Select("SELECT * FROM device_collect_heartbeat WHERE collect_id = #{collectId}")
|
||||
DeviceCollectHeartbeat selectByCollectId(@Param("collectId") String collectId);
|
||||
|
||||
/**
|
||||
* 查询所有探针
|
||||
*/
|
||||
@Select("SELECT * FROM device_collect_heartbeat ORDER BY update_time DESC")
|
||||
List<DeviceCollectHeartbeat> selectAll();
|
||||
|
||||
/**
|
||||
* 查询所有在线探针
|
||||
*/
|
||||
@Select("SELECT * FROM device_collect_heartbeat WHERE status = 'online' ORDER BY update_time DESC")
|
||||
List<DeviceCollectHeartbeat> selectAllOnline();
|
||||
|
||||
/**
|
||||
* 查询所有离线探针
|
||||
*/
|
||||
@Select("SELECT * FROM device_collect_heartbeat WHERE status = 'offline' ORDER BY update_time DESC")
|
||||
List<DeviceCollectHeartbeat> selectAllOffline();
|
||||
|
||||
/**
|
||||
* 插入或更新(根据collect_id)
|
||||
*/
|
||||
@Insert("INSERT INTO device_collect_heartbeat (" +
|
||||
"collect_id, collect_name, device_ip, app_version, last_heartbeat, " +
|
||||
"heartbeat_count, status, fail_count, update_time " +
|
||||
") VALUES (" +
|
||||
"#{collectId}, #{collectName}, #{deviceIp}, #{appVersion}, #{lastHeartbeat}, " +
|
||||
"#{heartbeatCount}, #{status}, #{failCount}, #{updateTime} " +
|
||||
") ON CONFLICT (collect_id) DO UPDATE SET " +
|
||||
"collect_name = EXCLUDED.collect_name, " +
|
||||
"device_ip = EXCLUDED.device_ip, " +
|
||||
"app_version = EXCLUDED.app_version, " +
|
||||
"last_heartbeat = EXCLUDED.last_heartbeat, " +
|
||||
"heartbeat_count = EXCLUDED.heartbeat_count, " +
|
||||
"status = EXCLUDED.status, " +
|
||||
"fail_count = EXCLUDED.fail_count, " +
|
||||
"update_time = EXCLUDED.update_time")
|
||||
int upsert(DeviceCollectHeartbeat heartbeat);
|
||||
|
||||
/**
|
||||
* 更新探针状态
|
||||
*/
|
||||
@Update("UPDATE device_collect_heartbeat SET " +
|
||||
"status = #{status}, fail_count = #{failCount}, update_time = #{updateTime} " +
|
||||
"WHERE collect_id = #{collectId}")
|
||||
int updateStatus(@Param("collectId") String collectId,
|
||||
@Param("status") String status,
|
||||
@Param("failCount") Integer failCount,
|
||||
@Param("updateTime") java.time.LocalDateTime updateTime);
|
||||
|
||||
/**
|
||||
* 查询超过指定时间未心跳的探针(用于检测离线)
|
||||
*/
|
||||
@Select("SELECT * FROM device_collect_heartbeat " +
|
||||
"WHERE status = 'online' AND last_heartbeat < #{thresholdTime} " +
|
||||
"ORDER BY last_heartbeat ASC")
|
||||
List<DeviceCollectHeartbeat> selectOfflineCandidates(@Param("thresholdTime") java.time.LocalDateTime thresholdTime);
|
||||
|
||||
/**
|
||||
* 删除指定日期之前的记录
|
||||
*/
|
||||
@Delete("DELETE FROM device_collect_heartbeat WHERE update_time < #{beforeTime}")
|
||||
int deleteBeforeTime(@Param("beforeTime") java.time.LocalDateTime beforeTime);
|
||||
}
|
||||
+192
@@ -0,0 +1,192 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.DeviceCollectTask;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface DeviceCollectTaskMapper extends BaseMapper<DeviceCollectTask>{
|
||||
|
||||
/**
|
||||
* 根据ID查询采集任务
|
||||
*/
|
||||
@Select("SELECT * FROM device_collect_task WHERE id = #{id}")
|
||||
DeviceCollectTask selectById(Integer id);
|
||||
|
||||
/**
|
||||
* 查询所有采集任务
|
||||
*/
|
||||
@Select("SELECT * FROM device_collect_task")
|
||||
List<DeviceCollectTask> selectAll();
|
||||
|
||||
/**
|
||||
* 根据设备ID查询采集任务
|
||||
*/
|
||||
@Select("SELECT * FROM device_collect_task WHERE device_id = #{deviceId}")
|
||||
List<DeviceCollectTask> selectByDeviceId(Integer deviceId);
|
||||
|
||||
/**
|
||||
* 根据方法类型查询采集任务
|
||||
*/
|
||||
@Select("SELECT * FROM device_collect_task WHERE method = #{method}")
|
||||
List<DeviceCollectTask> selectByMethod(Integer method);
|
||||
|
||||
/**
|
||||
* 根据任务名称模糊查询
|
||||
*/
|
||||
@Select("SELECT * FROM device_collect_task WHERE task_name LIKE CONCAT('%', #{taskName}, '%')")
|
||||
List<DeviceCollectTask> selectByTaskNameLike(String taskName);
|
||||
|
||||
/**
|
||||
* 查询成功的采集任务
|
||||
*/
|
||||
@Select("SELECT * FROM device_collect_task WHERE last_success_time IS NOT NULL")
|
||||
List<DeviceCollectTask> selectSuccessTasks();
|
||||
|
||||
/**
|
||||
* 查询失败的采集任务
|
||||
*/
|
||||
@Select("SELECT * FROM device_collect_task WHERE last_failed_time IS NOT NULL")
|
||||
List<DeviceCollectTask> selectFailedTasks();
|
||||
|
||||
/**
|
||||
* 多条件组合查询
|
||||
*/
|
||||
List<DeviceCollectTask> selectByCondition(DeviceCollectTask condition);
|
||||
|
||||
/**
|
||||
* 插入采集任务
|
||||
*/
|
||||
@Insert("INSERT INTO device_collect_task (created_at, updated_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) " +
|
||||
"VALUES (NOW(), NOW(), #{deviceId}, #{method}, #{taskName}, #{firstTime}, " +
|
||||
"#{lastSuccessTime}, #{lastFailedTime}, #{detailId}, #{epm}, #{epmPeak}, " +
|
||||
"#{processArchitecture}, #{taskCount}, #{recentDiscoverTime}, #{epmUpperLimit})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
int insert(DeviceCollectTask task);
|
||||
|
||||
/**
|
||||
* 更新采集任务
|
||||
*/
|
||||
@Update("UPDATE device_collect_task SET " +
|
||||
"updated_at = NOW(), " +
|
||||
"device_id = #{deviceId}, " +
|
||||
"method = #{method}, " +
|
||||
"task_name = #{taskName}, " +
|
||||
"first_time = #{firstTime}, " +
|
||||
"last_success_time = #{lastSuccessTime}, " +
|
||||
"last_failed_time = #{lastFailedTime}, " +
|
||||
"detail_id = #{detailId}, " +
|
||||
"epm = #{epm}, " +
|
||||
"epm_peak = #{epmPeak}, " +
|
||||
"process_architecture = #{processArchitecture}, " +
|
||||
"task_count = #{taskCount}, " +
|
||||
"recent_discover_time = #{recentDiscoverTime}, " +
|
||||
"epm_upper_limit = #{epmUpperLimit} " +
|
||||
"WHERE id = #{id}")
|
||||
int update(DeviceCollectTask task);
|
||||
|
||||
/**
|
||||
* 删除采集任务
|
||||
*/
|
||||
@Delete("DELETE FROM device_collect_task WHERE id = #{id}")
|
||||
int deleteById(Integer id);
|
||||
|
||||
/**
|
||||
* 根据设备ID删除采集任务
|
||||
*/
|
||||
@Delete("DELETE FROM device_collect_task WHERE device_id = #{deviceId}")
|
||||
int deleteByDeviceId(Integer deviceId);
|
||||
|
||||
/**
|
||||
* 更新任务成功状态
|
||||
*/
|
||||
@Update("UPDATE device_collect_task SET " +
|
||||
"last_success_time = NOW(), " +
|
||||
"updated_at = NOW(), " +
|
||||
"task_count = COALESCE(task_count, 0) + 1 " +
|
||||
"WHERE id = #{id}")
|
||||
int updateSuccessStatus(Integer id);
|
||||
|
||||
/**
|
||||
* 更新任务失败状态
|
||||
*/
|
||||
@Update("UPDATE device_collect_task SET " +
|
||||
"last_failed_time = NOW(), " +
|
||||
"updated_at = NOW() " +
|
||||
"WHERE id = #{id}")
|
||||
int updateFailedStatus(Integer id);
|
||||
|
||||
/**
|
||||
* 更新EPM指标
|
||||
*/
|
||||
@Update("UPDATE device_collect_task SET " +
|
||||
"epm = #{epm}, " +
|
||||
"epm_peak = GREATEST(COALESCE(epm_peak, 0), #{epm}), " +
|
||||
"updated_at = NOW() " +
|
||||
"WHERE id = #{id}")
|
||||
int updateEpm(@Param("id") Integer id, @Param("epm") Integer epm);
|
||||
|
||||
/**
|
||||
* 统计设备采集任务数量
|
||||
*/
|
||||
@Select("SELECT COUNT(*) FROM device_collect_task WHERE device_id = #{deviceId}")
|
||||
int countByDeviceId(Integer deviceId);
|
||||
|
||||
/**
|
||||
* 获取设备的最新采集任务
|
||||
*/
|
||||
@Select("SELECT * FROM device_collect_task WHERE device_id = #{deviceId} ORDER BY updated_at DESC LIMIT 1")
|
||||
DeviceCollectTask selectLatestByDeviceId(Integer deviceId);
|
||||
|
||||
|
||||
/**
|
||||
* 批量更新设备采集任务的时间
|
||||
*/
|
||||
@Update("<script>" +
|
||||
"<foreach collection='tasks' item='task' separator=';'>" +
|
||||
"UPDATE device_collect_task SET " +
|
||||
" first_time = CASE " +
|
||||
" WHEN first_time IS NULL AND #{task.firstTime}::TIMESTAMP IS NOT NULL THEN #{task.firstTime}::TIMESTAMP " +
|
||||
" ELSE first_time " +
|
||||
" END, " +
|
||||
" last_success_time = #{task.lastSuccessTime}::TIMESTAMP, " +
|
||||
" last_failed_time = #{task.lastFailedTime}::TIMESTAMP, " +
|
||||
" updated_at = #{task.updatedAt}::TIMESTAMP " +
|
||||
"WHERE id = #{task.id}" +
|
||||
"</foreach>" +
|
||||
"</script>")
|
||||
int batchUpdateTimes(@Param("tasks") List<DeviceCollectTask> tasks);
|
||||
|
||||
/**
|
||||
* 更新单个任务的时间
|
||||
*/
|
||||
@Update("UPDATE device_collect_task " +
|
||||
"SET first_time = CASE " +
|
||||
" WHEN first_time IS NULL AND #{firstTime}::TIMESTAMP IS NOT NULL THEN #{firstTime}::TIMESTAMP " +
|
||||
" ELSE first_time " +
|
||||
" END, " +
|
||||
" last_success_time = #{lastSuccessTime}::TIMESTAMP, " +
|
||||
" last_failed_time = #{lastFailTime}::TIMESTAMP, " +
|
||||
" updated_at = #{updateTime}::TIMESTAMP " +
|
||||
"WHERE id = #{deviceCollectId}")
|
||||
int updateTaskTime(@Param("deviceCollectId") String deviceCollectId,
|
||||
@Param("firstTime") LocalDateTime firstTime,
|
||||
@Param("lastSuccessTime") LocalDateTime lastSuccessTime,
|
||||
@Param("lastFailTime") LocalDateTime lastFailTime,
|
||||
@Param("updateTime") LocalDateTime updateTime);
|
||||
|
||||
/**
|
||||
* 查询所有设备任务
|
||||
*/
|
||||
@Select("SELECT * FROM device_collect_task")
|
||||
List<DeviceCollectTask> selectAllTasks();
|
||||
}
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
package com.common.mapper;
|
||||
|
||||
|
||||
import com.common.entity.DeviceDevice;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface DeviceDeviceMapper {
|
||||
|
||||
/**
|
||||
* 根据ID查询设备
|
||||
*/
|
||||
DeviceDevice selectById(Integer id);
|
||||
|
||||
/**
|
||||
* 查询所有设备
|
||||
*/
|
||||
List<DeviceDevice> selectAll();
|
||||
|
||||
/**
|
||||
* 根据IP地址查询设备
|
||||
*/
|
||||
List<DeviceDevice> selectByIp(String ip);
|
||||
|
||||
/**
|
||||
* 根据设备名称模糊查询
|
||||
*/
|
||||
List<DeviceDevice> selectByNameLike(String name);
|
||||
|
||||
/**
|
||||
* 根据设备组查询
|
||||
*/
|
||||
List<DeviceDevice> selectByDeviceGroup(Integer deviceGroup);
|
||||
|
||||
/**
|
||||
* 根据设备类型查询
|
||||
*/
|
||||
List<DeviceDevice> selectByDeviceType(Integer deviceType);
|
||||
|
||||
/**
|
||||
* 根据组织ID查询
|
||||
*/
|
||||
List<DeviceDevice> selectByOrganizationId(Integer organizationId);
|
||||
|
||||
/**
|
||||
* 根据状态查询设备
|
||||
*/
|
||||
List<DeviceDevice> selectByStatus(Short status);
|
||||
|
||||
/**
|
||||
* 多条件组合查询
|
||||
*/
|
||||
List<DeviceDevice> selectByCondition(DeviceDevice condition);
|
||||
|
||||
/**
|
||||
* 动态条件查询
|
||||
*/
|
||||
List<DeviceDevice> selectByMap(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
List<DeviceDevice> selectByPage(@Param("offset") int offset, @Param("limit") int limit);
|
||||
|
||||
/**
|
||||
* 统计设备数量
|
||||
*/
|
||||
Long count();
|
||||
|
||||
/**
|
||||
* 根据条件统计数量
|
||||
*/
|
||||
Long countByCondition(DeviceDevice condition);
|
||||
|
||||
/**
|
||||
* 查询监控中的设备
|
||||
*/
|
||||
List<DeviceDevice> selectMonitoringDevices();
|
||||
|
||||
/**
|
||||
* 查询未删除的设备(del_flag = '0')
|
||||
*/
|
||||
List<DeviceDevice> selectActiveDevices();
|
||||
|
||||
/**
|
||||
* 根据厂商查询设备
|
||||
*/
|
||||
List<DeviceDevice> selectByVendor(String vendor);
|
||||
}
|
||||
+129
@@ -0,0 +1,129 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.Modules.etl.handler.ArrayIntegerTypeHandler;
|
||||
import com.Modules.etl.handler.ArrayStringTypeHandler;
|
||||
import com.common.entity.DeviceInterlockingCmd;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface DeviceInterlockingCmdMapper {
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
@Select("SELECT * FROM device_interlocking_cmd WHERE id = #{id}")
|
||||
@Results({
|
||||
@Result(column = "device_interlocking_id", property = "deviceInterlockingId",
|
||||
typeHandler = ArrayIntegerTypeHandler.class),
|
||||
@Result(column = "device_interlocking_ip", property = "deviceInterlockingIp",
|
||||
typeHandler = ArrayStringTypeHandler.class),
|
||||
@Result(column = "ban_ips", property = "banIps",
|
||||
typeHandler = ArrayStringTypeHandler.class)
|
||||
})
|
||||
DeviceInterlockingCmd selectById(Long id);
|
||||
|
||||
/**
|
||||
* 查询待执行的指令
|
||||
* @param probeId 探针ID
|
||||
* @return 待执行指令列表
|
||||
*/
|
||||
@Select("SELECT * FROM device_interlocking_cmd WHERE probe_id = #{probeId} AND cmd_status = '0' ORDER BY create_time ASC")
|
||||
@Results({
|
||||
@Result(column = "device_interlocking_id", property = "deviceInterlockingId",
|
||||
typeHandler = ArrayIntegerTypeHandler.class),
|
||||
@Result(column = "device_interlocking_ip", property = "deviceInterlockingIp",
|
||||
typeHandler = ArrayStringTypeHandler.class),
|
||||
@Result(column = "ban_ips", property = "banIps",
|
||||
typeHandler = ArrayStringTypeHandler.class)
|
||||
})
|
||||
List<DeviceInterlockingCmd> selectPendingCommands(@Param("probeId") Long probeId);
|
||||
|
||||
/**
|
||||
* 根据探针ID和状态查询
|
||||
*/
|
||||
@Select("SELECT * FROM device_interlocking_cmd WHERE probe_id = #{probeId} AND cmd_status = #{cmdStatus}")
|
||||
@Results({
|
||||
@Result(column = "device_interlocking_id", property = "deviceInterlockingId",
|
||||
typeHandler = ArrayIntegerTypeHandler.class),
|
||||
@Result(column = "device_interlocking_ip", property = "deviceInterlockingIp",
|
||||
typeHandler = ArrayStringTypeHandler.class),
|
||||
@Result(column = "ban_ips", property = "banIps",
|
||||
typeHandler = ArrayStringTypeHandler.class)
|
||||
})
|
||||
List<DeviceInterlockingCmd> selectByProbeIdAndStatus(@Param("probeId") Long probeId, @Param("cmdStatus") String cmdStatus);
|
||||
|
||||
/**
|
||||
* 插入指令
|
||||
*/
|
||||
@Insert("INSERT INTO device_interlocking_cmd (probe_id, probe_ip, device_interlocking_id, device_interlocking_ip, " +
|
||||
"ban_ips, ban_method, ban_type, cmd_status, ban_duration, create_time, update_time, " +
|
||||
"tenant_id, create_dept, create_by, remark, ban_operation_type) " +
|
||||
"VALUES (#{probeId}, #{probeIp}, ARRAY[:ids], ARRAY[:ips], ARRAY[:banIps], " +
|
||||
"#{banMethod}, #{banType}, #{cmdStatus}, #{banDuration}, NOW(), NOW(), " +
|
||||
"#{tenantId}, #{createDept}, #{createBy}, #{remark}, #{banOperationType})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
int insert(DeviceInterlockingCmd cmd);
|
||||
|
||||
/**
|
||||
* 更新指令状态
|
||||
* @param id 指令ID
|
||||
* @param cmdStatus 新状态
|
||||
* @return 影响行数
|
||||
*/
|
||||
@Update("UPDATE device_interlocking_cmd SET cmd_status = #{cmdStatus}, update_time = NOW() WHERE id = #{id}")
|
||||
int updateStatus(@Param("id") Long id, @Param("cmdStatus") String cmdStatus);
|
||||
|
||||
/**
|
||||
* 更新指令状态为执行中
|
||||
*/
|
||||
@Update("UPDATE device_interlocking_cmd SET cmd_status = '2', update_time = NOW() WHERE id = #{id}")
|
||||
int updateStatusToExecuting(@Param("id") Long id);
|
||||
|
||||
/**
|
||||
* 更新指令状态为执行完成
|
||||
*/
|
||||
@Update("UPDATE device_interlocking_cmd SET cmd_status = '1', update_time = NOW() WHERE id = #{id}")
|
||||
int updateStatusToCompleted(@Param("id") Long id);
|
||||
|
||||
/**
|
||||
* 更新指令状态为执行失败
|
||||
*/
|
||||
@Update("UPDATE device_interlocking_cmd SET cmd_status = '3', update_time = NOW() WHERE id = #{id}")
|
||||
int updateStatusToFailed(@Param("id") Long id);
|
||||
|
||||
/**
|
||||
* 根据多个ID查询
|
||||
*/
|
||||
@Select("<script>" +
|
||||
"SELECT * FROM device_interlocking_cmd WHERE id IN " +
|
||||
"<foreach collection='ids' item='id' open='(' separator=',' close=')'>" +
|
||||
"#{id}" +
|
||||
"</foreach>" +
|
||||
"</script>")
|
||||
@Results({
|
||||
@Result(column = "device_interlocking_id", property = "deviceInterlockingId",
|
||||
typeHandler = ArrayIntegerTypeHandler.class),
|
||||
@Result(column = "device_interlocking_ip", property = "deviceInterlockingIp",
|
||||
typeHandler = ArrayStringTypeHandler.class),
|
||||
@Result(column = "ban_ips", property = "banIps",
|
||||
typeHandler = ArrayStringTypeHandler.class)
|
||||
})
|
||||
List<DeviceInterlockingCmd> selectByIds(@Param("ids") List<Long> ids);
|
||||
|
||||
/**
|
||||
* 查询所有指令
|
||||
*/
|
||||
@Select("SELECT * FROM device_interlocking_cmd ORDER BY create_time DESC")
|
||||
@Results({
|
||||
@Result(column = "device_interlocking_id", property = "deviceInterlockingId",
|
||||
typeHandler = ArrayIntegerTypeHandler.class),
|
||||
@Result(column = "device_interlocking_ip", property = "deviceInterlockingIp",
|
||||
typeHandler = ArrayStringTypeHandler.class),
|
||||
@Result(column = "ban_ips", property = "banIps",
|
||||
typeHandler = ArrayStringTypeHandler.class)
|
||||
})
|
||||
List<DeviceInterlockingCmd> selectAll();
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.DeviceInterlockingLog;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface DeviceInterlockingLogMapper {
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
@Select("SELECT * FROM device_interlocking_log WHERE id = #{id}")
|
||||
DeviceInterlockingLog selectById(Long id);
|
||||
|
||||
/**
|
||||
* 根据指令ID查询
|
||||
*/
|
||||
@Select("SELECT * FROM device_interlocking_log WHERE device_interlocking_cmd_id = #{cmdId}")
|
||||
List<DeviceInterlockingLog> selectByCmdId(@Param("cmdId") Long cmdId);
|
||||
|
||||
/**
|
||||
* 插入记录
|
||||
*/
|
||||
@Insert("INSERT INTO device_interlocking_log (device_interlocking_cmd_id, device_interlocking_id, ban_ip, " +
|
||||
"device_name, ban_time, ban_method, ban_result, tenant_id, create_dept, create_by, " +
|
||||
"create_time, remark, resp_body, req_body) " +
|
||||
"VALUES (#{deviceInterlockingCmdId}, #{deviceInterlockingId}, #{banIp}, #{deviceName}, " +
|
||||
"#{banTime}, #{banMethod}, #{banResult}, #{tenantId}, #{createDept}, #{createBy}, " +
|
||||
"NOW(), #{remark}, #{respBody}, #{reqBody})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
int insert(DeviceInterlockingLog log);
|
||||
|
||||
/**
|
||||
* 批量插入记录
|
||||
*/
|
||||
@Insert("<script>" +
|
||||
"INSERT INTO device_interlocking_log (device_interlocking_cmd_id, device_interlocking_id, ban_ip, " +
|
||||
"device_name, ban_time, ban_method, ban_result, tenant_id, create_dept, create_by, " +
|
||||
"create_time, remark, resp_body, req_body) VALUES " +
|
||||
"<foreach collection='logs' item='item' separator=','>" +
|
||||
"(#{item.deviceInterlockingCmdId}, #{item.deviceInterlockingId}, #{item.banIp}, " +
|
||||
"#{item.deviceName}, #{item.banTime}, #{item.banMethod}, #{item.banResult}, " +
|
||||
"#{item.tenantId}, #{item.createDept}, #{item.createBy}, NOW(), " +
|
||||
"#{item.remark}, #{item.respBody}, #{item.reqBody})" +
|
||||
"</foreach>" +
|
||||
"</script>")
|
||||
int batchInsert(@Param("logs") List<DeviceInterlockingLog> logs);
|
||||
|
||||
/**
|
||||
* 查询所有记录
|
||||
*/
|
||||
@Select("SELECT * FROM device_interlocking_log ORDER BY create_time DESC")
|
||||
List<DeviceInterlockingLog> selectAll();
|
||||
|
||||
/**
|
||||
* 统计某指令的成功/失败数量
|
||||
*/
|
||||
@Select("SELECT ban_result, COUNT(*) as count FROM device_interlocking_log " +
|
||||
"WHERE device_interlocking_cmd_id = #{cmdId} GROUP BY ban_result")
|
||||
List<java.util.Map<String, Object>> countByCmdId(@Param("cmdId") Long cmdId);
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.DeviceInterlocking;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface DeviceInterlockingMapper {
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
@Select("SELECT * FROM device_interlocking WHERE id = #{id}")
|
||||
DeviceInterlocking selectById(Long id);
|
||||
|
||||
/**
|
||||
* 根据部门ID查询联动设备
|
||||
*/
|
||||
@Select("SELECT * FROM device_interlocking WHERE dept_id = #{deptId}")
|
||||
List<DeviceInterlocking> selectByDeptId(@Param("deptId") String deptId);
|
||||
|
||||
/**
|
||||
* 根据厂商查询
|
||||
*/
|
||||
@Select("SELECT * FROM device_interlocking WHERE vendor = #{vendor}")
|
||||
List<DeviceInterlocking> selectByVendor(@Param("vendor") String vendor);
|
||||
|
||||
/**
|
||||
* 插入记录
|
||||
*/
|
||||
@Insert("INSERT INTO device_interlocking (device_name, vendor, dept_id, ban_limit, ip, api_url, " +
|
||||
"tenant_id, create_dept, create_by, create_time, update_time, remark, auth_username, auth_password) " +
|
||||
"VALUES (#{deviceName}, #{vendor}, #{deptId}, #{banLimit}, #{ip}, #{apiUrl}, " +
|
||||
"#{tenantId}, #{createDept}, #{createBy}, NOW(), NOW(), #{remark}, #{authUsername}, #{authPassword})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
int insert(DeviceInterlocking device);
|
||||
|
||||
/**
|
||||
* 更新记录
|
||||
*/
|
||||
@Update("UPDATE device_interlocking SET device_name = #{deviceName}, vendor = #{vendor}, " +
|
||||
"dept_id = #{deptId}, ban_limit = #{banLimit}, ip = #{ip}, api_url = #{apiUrl}, " +
|
||||
"update_time = NOW(), remark = #{remark}, auth_username = #{authUsername}, " +
|
||||
"auth_password = #{authPassword} WHERE id = #{id}")
|
||||
int update(DeviceInterlocking device);
|
||||
|
||||
/**
|
||||
* 查询所有记录
|
||||
*/
|
||||
@Select("SELECT * FROM device_interlocking ORDER BY create_time DESC")
|
||||
List<DeviceInterlocking> selectAll();
|
||||
}
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
package com.common.mapper;
|
||||
|
||||
|
||||
import com.common.entity.DeviceCollectTaskTime;
|
||||
import com.common.entity.DeviceReceiveLog;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
@Mapper
|
||||
public interface DeviceReceiveLogMapper {
|
||||
|
||||
/**
|
||||
* 插入单条记录
|
||||
*/
|
||||
int insert(DeviceReceiveLog log);
|
||||
|
||||
/**
|
||||
* 批量插入记录
|
||||
*/
|
||||
int batchInsert(@Param("list") List<DeviceReceiveLog> logs);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
DeviceReceiveLog selectById(@Param("id") Long id);
|
||||
|
||||
/**
|
||||
* 根据设备ID查询
|
||||
*/
|
||||
List<DeviceReceiveLog> selectByDeviceId(@Param("deviceId") Integer deviceId);
|
||||
|
||||
/**
|
||||
* 根据采集探针ID查询
|
||||
*/
|
||||
List<DeviceReceiveLog> selectByCollectId(@Param("collectId") Integer collectId);
|
||||
|
||||
/**
|
||||
* 根据IP地址查询
|
||||
*/
|
||||
List<DeviceReceiveLog> selectByDeviceIp(@Param("deviceIp") String deviceIp);
|
||||
|
||||
/**
|
||||
* 根据时间范围查询
|
||||
*/
|
||||
List<DeviceReceiveLog> selectByTimeRange(
|
||||
@Param("startTime") LocalDateTime startTime,
|
||||
@Param("endTime") LocalDateTime endTime);
|
||||
|
||||
/**
|
||||
* 多条件组合查询
|
||||
*/
|
||||
List<DeviceReceiveLog> selectByCondition(DeviceReceiveLog condition);
|
||||
|
||||
/**
|
||||
* 统计设备接收日志数量
|
||||
*/
|
||||
Long countByCondition(DeviceReceiveLog condition);
|
||||
|
||||
/**
|
||||
* 根据时间范围删除旧数据
|
||||
*/
|
||||
int deleteByTimeRange(
|
||||
@Param("startTime") LocalDateTime startTime,
|
||||
@Param("endTime") LocalDateTime endTime);
|
||||
|
||||
/**
|
||||
* 获取最近N条记录
|
||||
*/
|
||||
List<DeviceReceiveLog> selectRecent(@Param("limit") Integer limit);
|
||||
|
||||
/**
|
||||
* 按设备分组统计日志数量
|
||||
*/
|
||||
List<Map<String, Object>> countByDeviceGroup();
|
||||
|
||||
|
||||
/**
|
||||
* 查询当天每个设备的最新成功时间
|
||||
*/
|
||||
@Select("SELECT device_collect_id, MAX(created_at) AS last_success_time " +
|
||||
"FROM device_receive_log " +
|
||||
"WHERE push_success = true " +
|
||||
"AND created_at >= CURRENT_DATE " +
|
||||
"GROUP BY device_collect_id")
|
||||
List<DeviceCollectTaskTime> selectDailySuccessTimes();
|
||||
|
||||
/**
|
||||
* 查询当天每个设备的最新失败时间
|
||||
*/
|
||||
@Select("SELECT device_collect_id, MAX(created_at) AS last_fail_time " +
|
||||
"FROM device_receive_log " +
|
||||
"WHERE push_success = false " +
|
||||
"AND created_at >= CURRENT_DATE " +
|
||||
"GROUP BY device_collect_id")
|
||||
List<DeviceCollectTaskTime> selectDailyFailTimes();
|
||||
|
||||
/**
|
||||
* 查询每个设备的首次成功时间(历史最早)
|
||||
*/
|
||||
@Select("SELECT device_collect_id, MIN(created_at) AS first_success_time " +
|
||||
"FROM device_receive_log " +
|
||||
"WHERE push_success = true " +
|
||||
"GROUP BY device_collect_id")
|
||||
List<DeviceCollectTaskTime> selectFirstSuccessTimes();
|
||||
|
||||
/**
|
||||
* 查询指定时间范围内的成功记录
|
||||
*/
|
||||
@Select("SELECT device_collect_id, MIN(created_at) AS first_time, " +
|
||||
"MAX(created_at) AS last_success_time " +
|
||||
"FROM device_receive_log " +
|
||||
"WHERE push_success = true " +
|
||||
"AND created_at >= #{startTime} " +
|
||||
"AND created_at < #{endTime} " +
|
||||
"GROUP BY device_collect_id")
|
||||
List<DeviceCollectTaskTime> selectSuccessTimesByRange(
|
||||
@Param("startTime") LocalDateTime startTime,
|
||||
@Param("endTime") LocalDateTime endTime);
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
package com.common.mapper;
|
||||
|
||||
|
||||
import com.common.entity.DmColumn;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface DmColumnMapper {
|
||||
|
||||
// 查询所有列
|
||||
@Select("SELECT * FROM dm_column WHERE deleted_at IS NULL")
|
||||
List<DmColumn> findAll();
|
||||
|
||||
// 根据ID查询
|
||||
// @Select("SELECT * FROM dm_column WHERE id = #{id} AND deleted_at IS NULL")
|
||||
DmColumn findById(Long id);
|
||||
|
||||
// 根据名称查询
|
||||
@Select("SELECT * FROM dm_column WHERE name = #{name} AND deleted_at IS NULL")
|
||||
DmColumn findByName(String name);
|
||||
|
||||
// 根据显示名称模糊查询
|
||||
@Select("SELECT * FROM dm_column WHERE display_name LIKE CONCAT('%', #{displayName}, '%') AND deleted_at IS NULL")
|
||||
List<DmColumn> findByDisplayName(String displayName);
|
||||
|
||||
// 根据是否内置查询
|
||||
@Select("SELECT * FROM dm_column WHERE is_built_in = #{isBuiltIn} AND deleted_at IS NULL")
|
||||
List<DmColumn> findByIsBuiltIn(Boolean isBuiltIn);
|
||||
|
||||
// 插入数据
|
||||
@Insert("INSERT INTO dm_column (created_at, updated_at, name, display_name, storage_data_type, " +
|
||||
"business_data_type, is_built_in, is_hidden, is_not_normalizable, is_required, category_id, " +
|
||||
"custom_asset_category_id, is_virtual, table_id, asset_table_id, column_set_id, base_type, " +
|
||||
"user_task_id, created_by_id, create_dept, create_by, create_time, update_by, update_time) " +
|
||||
"VALUES (NOW(), NOW(), #{name}, #{displayName}, #{storageDataType}, #{businessDataType}, " +
|
||||
"#{isBuiltIn}, #{isHidden}, #{isNotNormalizable}, #{isRequired}, #{categoryId}, " +
|
||||
"#{customAssetCategoryId}, #{isVirtual}, #{tableId}, #{assetTableId}, #{columnSetId}, " +
|
||||
"#{baseType}, #{userTaskId}, #{createdById}, #{createDept}, #{createBy}, #{createTime}, " +
|
||||
"#{updateBy}, #{updateTime})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
int insert(DmColumn dmColumn);
|
||||
|
||||
// 批量插入
|
||||
@Insert("<script>" +
|
||||
"INSERT INTO dm_column (created_at, updated_at, name, display_name, is_built_in, is_hidden) " +
|
||||
"VALUES " +
|
||||
"<foreach collection='list' item='item' separator=','>" +
|
||||
"(NOW(), NOW(), #{item.name}, #{item.displayName}, #{item.isBuiltIn}, #{item.isHidden})" +
|
||||
"</foreach>" +
|
||||
"</script>")
|
||||
int batchInsert(List<DmColumn> dmColumns);
|
||||
|
||||
// 查询条件构造(使用XML方式)
|
||||
List<DmColumn> findByCondition(DmColumn condition);
|
||||
|
||||
// 统计数量
|
||||
@Select("SELECT COUNT(*) FROM dm_column WHERE deleted_at IS NULL")
|
||||
Long count();
|
||||
|
||||
|
||||
/**
|
||||
* 查询所有数据标准化字段
|
||||
* @param
|
||||
* @return 数据标准化字段
|
||||
*/
|
||||
List<Map<String, Object>> selectAllNormal();
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package com.common.mapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.common.entity.DmNormalizeRule;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface DmNormalizeRuleMapper {
|
||||
|
||||
/**
|
||||
* 根据ID查询数据标准化规则
|
||||
* @param id 主键ID
|
||||
* @return 数据标准化规则对象
|
||||
*/
|
||||
DmNormalizeRule selectById(@Param("id") Long id);
|
||||
|
||||
/**
|
||||
* 根据Device ID查询数据标准化规则
|
||||
* @param id 主键device ID
|
||||
* @return 数据标准化规则对象
|
||||
*/
|
||||
List<Map<String, Object>> selectByDeviceId(@Param("id") Long id);
|
||||
|
||||
/**
|
||||
* 根据ID更新数据标准化规则
|
||||
* @param rule 数据标准化规则对象
|
||||
* @return 更新影响的行数
|
||||
*/
|
||||
int updateById(DmNormalizeRule rule);
|
||||
|
||||
/**
|
||||
* 根据ID和租户ID查询(带租户隔离)
|
||||
* @param id 主键ID
|
||||
* @param tenantId 租户ID
|
||||
* @return 数据标准化规则对象
|
||||
*/
|
||||
DmNormalizeRule selectByIdAndTenant(@Param("id") Long id, @Param("tenantId") String tenantId);
|
||||
|
||||
/**
|
||||
* 根据ID和租户ID更新(带租户隔离)
|
||||
* @param rule 数据标准化规则对象
|
||||
* @return 更新影响的行数
|
||||
*/
|
||||
int updateByIdAndTenant(DmNormalizeRule rule);
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package com.common.mapper;
|
||||
|
||||
|
||||
import com.common.entity.RuleHitTimeDTO;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface NormalizeRuleStatsMapper {
|
||||
|
||||
@Select("SELECT normalize_rule_id AS normalizeRuleId, " +
|
||||
" MAX(log_time) AS maxLogTime " +
|
||||
"FROM syslog_normal_data " +
|
||||
"WHERE created_at >= #{startDate} " +
|
||||
"GROUP BY normalize_rule_id")
|
||||
List<RuleHitTimeDTO> selectMaxHitTimeFromNormalData(
|
||||
@Param("startDate") LocalDateTime startDate
|
||||
);
|
||||
|
||||
@Select("SELECT normalize_rule_id AS normalizeRuleId, " +
|
||||
" MAX(log_time) AS maxLogTime " +
|
||||
"FROM syslog_normal_alarm " +
|
||||
"WHERE created_at >= #{startDate} " +
|
||||
"GROUP BY normalize_rule_id")
|
||||
List<RuleHitTimeDTO> selectMaxHitTimeFromNormalAlarm(
|
||||
@Param("startDate") LocalDateTime startDate
|
||||
);
|
||||
|
||||
@Select("SELECT id FROM dm_normalize_rule " +
|
||||
"WHERE del_flag = '0' " +
|
||||
"ORDER BY id")
|
||||
List<Long> selectActiveRuleIds();
|
||||
|
||||
@Update("UPDATE dm_normalize_rule " +
|
||||
"SET updated_at = NOW(), " +
|
||||
" first_data_saved_at = #{hitTime} " +
|
||||
"WHERE id = #{ruleId} " +
|
||||
" AND (first_data_saved_at IS NULL OR first_data_saved_at < #{hitTime})")
|
||||
int updateRuleHitTime(
|
||||
@Param("ruleId") Long ruleId,
|
||||
@Param("hitTime") LocalDateTime hitTime
|
||||
);
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// SecExceptionAlgorithmMapper.java
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.SecExceptionAlgorithm;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface SecExceptionAlgorithmMapper {
|
||||
|
||||
@Select("SELECT * FROM sec_exception_algorithm WHERE status = 1 AND del_flag = '0'")
|
||||
List<SecExceptionAlgorithm> findEnabledAlgorithms();
|
||||
|
||||
@Select("SELECT * FROM sec_exception_algorithm WHERE id = #{id}")
|
||||
SecExceptionAlgorithm findById(@Param("id") Long id);
|
||||
}
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
package com.common.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.common.entity.SyslogNonNormalMessage;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 非标日志Mapper接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface SyslogNonNormalMessageMapper extends BaseMapper<SyslogNonNormalMessage> {
|
||||
|
||||
/**
|
||||
* 批量插入非标日志
|
||||
* @param list 日志列表
|
||||
* @return 插入数量
|
||||
*/
|
||||
int batchInsert(@Param("list") List<SyslogNonNormalMessage> list);
|
||||
|
||||
/**
|
||||
* 根据时间段查询非标日志
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @return 日志列表
|
||||
*/
|
||||
@Select("SELECT * FROM syslog_non_normal_message WHERE log_time BETWEEN #{startTime} AND #{endTime} AND del_flag = '0'")
|
||||
List<SyslogNonNormalMessage> findByTimeRange(@Param("startTime") LocalDateTime startTime,
|
||||
@Param("endTime") LocalDateTime endTime);
|
||||
|
||||
/**
|
||||
* 根据设备ID和状态统计
|
||||
* @param deviceId 设备ID
|
||||
* @param ruleResult 规则结果
|
||||
* @return 统计结果
|
||||
*/
|
||||
@Select("SELECT COUNT(*) as count FROM syslog_non_normal_message " +
|
||||
"WHERE device_id = #{deviceId} AND rule_result = #{ruleResult} AND del_flag = '0'")
|
||||
Map<String, Object> countByDeviceAndResult(@Param("deviceId") Integer deviceId,
|
||||
@Param("ruleResult") String ruleResult);
|
||||
|
||||
/**
|
||||
* 逻辑删除非标日志
|
||||
* @param id 日志ID
|
||||
* @return 更新数量
|
||||
*/
|
||||
@Select("UPDATE syslog_non_normal_message SET del_flag = '1', update_time = NOW() WHERE id = #{id}")
|
||||
int logicalDelete(@Param("id") String id);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据ID和创建时间批量查询非标日志
|
||||
* @param ids ID列表
|
||||
* @param createdAts 创建时间列表
|
||||
* @return 非标日志列表
|
||||
*/
|
||||
List<SyslogNonNormalMessage> getMessagesByIdsAndCreatedAts(
|
||||
@Param("ids") List<String> ids,
|
||||
@Param("createdAts") List<String> createdAts);
|
||||
|
||||
/**
|
||||
* 根据ID列表批量查询非标日志
|
||||
* @param ids ID列表
|
||||
* @return 非标日志列表
|
||||
*/
|
||||
List<SyslogNonNormalMessage> getMessagesByIds(@Param("ids") List<String> ids);
|
||||
|
||||
/**
|
||||
* 批量更新del_flag字段
|
||||
* @param messages 需要更新的非标日志列表
|
||||
* @return 更新记录数
|
||||
*/
|
||||
int updateBatchDelFlag(@Param("messages") List<SyslogNonNormalMessage> messages);
|
||||
|
||||
/**
|
||||
* 批量更新记录
|
||||
* @param messages 需要更新的非标日志列表
|
||||
* @return 更新记录数
|
||||
*/
|
||||
int updateBatch(@Param("messages") List<SyslogNonNormalMessage> messages);
|
||||
}
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.GroupedSyslogData;
|
||||
import com.common.entity.SyslogNormalData;
|
||||
import com.common.entity.SyslogNormalAlarm;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface SyslogNormalAlarmMapper {
|
||||
|
||||
/**
|
||||
* 动态插入数据 - 使用 Map
|
||||
*/
|
||||
int insertDynamic(@Param("dataMap") Map<String, Object> dataMap);
|
||||
|
||||
/**
|
||||
* 动态插入数据 - 使用实体类
|
||||
*/
|
||||
int insertByEntity(SyslogNormalAlarm entity);
|
||||
|
||||
/**
|
||||
* 批量插入数据
|
||||
*/
|
||||
int batchInsert(@Param("dataList") List<Map<String, Object>> dataList);
|
||||
|
||||
|
||||
/**
|
||||
* 统计24小时内分组数据量
|
||||
*/
|
||||
@Select("SELECT count(1) as group_count from ( select " +
|
||||
"to_char(log_time, 'YYYYMMDD') || '_' || " +
|
||||
"dest_ip || '_' || " +
|
||||
"origin_event_name " +
|
||||
"FROM syslog_normal_alarm " +
|
||||
"WHERE log_time >= #{startTime} AND log_time < #{endTime} " +
|
||||
"AND event_level >= 1 AND src_ip NOT IN ('127.0.0.1', '127.0.0.2') " +
|
||||
"GROUP BY to_char(log_time, 'YYYYMMDD'),src_ip, dest_ip, origin_event_name )" )
|
||||
Long count24HoursGroupedData(@Param("startTime") LocalDateTime startTime,
|
||||
@Param("endTime") LocalDateTime endTime);
|
||||
|
||||
/**
|
||||
* 分页查询分组数据
|
||||
*/
|
||||
@Select("SELECT " +
|
||||
"to_char(log_time, 'YYYYMMDD') as log_date, " +
|
||||
"ARRAY_AGG(DISTINCT host(src_ip)::text) as attack_ips, " +
|
||||
"origin_event_name, " +
|
||||
"MAX(attack_result) as attack_result, " +
|
||||
"MIN(log_time) as min_log_time, " +
|
||||
"MAX(log_time) as max_log_time, " +
|
||||
"COUNT(1) as log_count, " +
|
||||
"ARRAY_AGG(DISTINCT host(dest_ip)::text) as victim_ips, " +
|
||||
"ARRAY_AGG(DISTINCT http_url) as victim_web_urls, " +
|
||||
"ARRAY_AGG(DISTINCT device_id) as device_ids, " +
|
||||
"ARRAY_AGG(DISTINCT id) as origin_log_ids, " +
|
||||
"MAX(event_level) as max_event_level, " +
|
||||
"MIN(origin_event_type) AS first_event_type, " +
|
||||
"MAX(origin_event_type) as event_type, " +
|
||||
"MIN(event_type) as min_event_type, " +
|
||||
"ARRAY_AGG(DISTINCT src_port::int4) as attack_ports, " +
|
||||
"ARRAY_AGG(DISTINCT dest_port::int4) as victim_ports, " +
|
||||
"ARRAY_AGG(DISTINCT http_resp_codes::text) as http_status_codes, " +
|
||||
"ARRAY_AGG(DISTINCT payload::BYTEA) as payload_samples, " +
|
||||
"ARRAY_AGG(DISTINCT http_req_header) as httpReqHeaders, " +
|
||||
"ARRAY_AGG(DISTINCT http_req_body) as httpReqBodys, " +
|
||||
"ARRAY_AGG(DISTINCT http_resp_header) as httpRespHeaders, " +
|
||||
"ARRAY_AGG(DISTINCT http_resp_body) as httpRespBodys, " +
|
||||
"MODE() WITHIN GROUP (ORDER BY dest_domain) as dns_info, " +
|
||||
"STRING_AGG(DISTINCT COALESCE(host(dest_ip)::text, ''), ',') as victim_ips_str " +
|
||||
"FROM syslog_normal_alarm " +
|
||||
"WHERE log_time >= #{startTime} AND log_time < #{endTime} " +
|
||||
"AND event_level >= 1 AND src_ip NOT IN ('127.0.0.1', '127.0.0.2') " +
|
||||
"GROUP BY to_char(log_time, 'YYYYMMDD'), src_ip, dest_ip, origin_event_name " +
|
||||
"ORDER BY log_date, dest_ip, origin_event_name " +
|
||||
"LIMIT #{pageSize} OFFSET #{offset}")
|
||||
List<GroupedSyslogData> select24HoursGroupedDataByPage(
|
||||
@Param("startTime") LocalDateTime startTime,
|
||||
@Param("endTime") LocalDateTime endTime,
|
||||
@Param("offset") int offset,
|
||||
@Param("pageSize") int pageSize);
|
||||
}
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.GroupedSyslogData;
|
||||
import com.common.entity.SyslogNormalData;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import java.util.Map;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
@Mapper
|
||||
public interface SyslogNormalDataMapper {
|
||||
|
||||
/**
|
||||
* 动态插入数据 - 使用 Map
|
||||
*/
|
||||
int insertDynamic(@Param("dataMap") Map<String, Object> dataMap);
|
||||
|
||||
/**
|
||||
* 动态插入数据 - 使用实体类
|
||||
*/
|
||||
int insertByEntity(SyslogNormalData entity);
|
||||
|
||||
/**
|
||||
* 批量插入数据
|
||||
*/
|
||||
int batchInsert(@Param("dataList") java.util.List<Map<String, Object>> dataList);
|
||||
|
||||
|
||||
/**
|
||||
* 统计24小时内分组数据量
|
||||
*/
|
||||
@Select("SELECT count(1) as group_count from ( select " +
|
||||
"to_char(log_time, 'YYYYMMDD') || '_' || " +
|
||||
"dest_ip || '_' || " +
|
||||
"origin_event_name " +
|
||||
"FROM syslog_normal_data " +
|
||||
"WHERE log_time >= #{startTime} AND log_time < #{endTime} " +
|
||||
"AND http_resp_codes =200 and origin_event_type <> '' and origin_event_name='访问日志' AND src_ip NOT IN ('127.0.0.1', '127.0.0.2') " +
|
||||
"GROUP BY to_char(log_time, 'YYYYMMDD'),src_ip, dest_ip, origin_event_name )" )
|
||||
Long count24HoursGroupedData(@Param("startTime") LocalDateTime startTime,
|
||||
@Param("endTime") LocalDateTime endTime);
|
||||
|
||||
/**
|
||||
* 分页查询分组数据
|
||||
*/
|
||||
@Select("SELECT " +
|
||||
"to_char(log_time, 'YYYYMMDD') as log_date, " +
|
||||
"ARRAY_AGG(DISTINCT host(src_ip)::text) as attack_ips, " +
|
||||
"origin_event_name, " +
|
||||
"MAX(attack_result) as attack_result, " +
|
||||
"MIN(log_time) as min_log_time, " +
|
||||
"MAX(log_time) as max_log_time, " +
|
||||
"COUNT(1) as log_count, " +
|
||||
"ARRAY_AGG(DISTINCT host(dest_ip)::text) as victim_ips, " +
|
||||
"ARRAY_AGG(DISTINCT http_url) as victim_web_urls, " +
|
||||
"ARRAY_AGG(DISTINCT device_id) as device_ids, " +
|
||||
"ARRAY_AGG(DISTINCT id) as origin_log_ids, " +
|
||||
"MAX(event_level) as max_event_level, " +
|
||||
"MIN(origin_event_type) AS first_event_type, " +
|
||||
"MAX(origin_event_type) as event_type, " +
|
||||
"MIN(event_type) as min_event_type, " +
|
||||
"ARRAY_AGG(DISTINCT src_port::int4) as attack_ports, " +
|
||||
"ARRAY_AGG(DISTINCT dest_port::int4) as victim_ports, " +
|
||||
"ARRAY_AGG(DISTINCT http_resp_codes::text) as http_status_codes, " +
|
||||
"ARRAY_AGG(DISTINCT payload::BYTEA) as payload_samples, " +
|
||||
"ARRAY_AGG(DISTINCT http_req_header) as httpReqHeaders, " +
|
||||
"ARRAY_AGG(DISTINCT http_req_body) as httpReqBodys, " +
|
||||
"ARRAY_AGG(DISTINCT http_resp_header) as httpRespHeaders, " +
|
||||
"ARRAY_AGG(DISTINCT http_resp_body) as httpRespBodys, " +
|
||||
"MODE() WITHIN GROUP (ORDER BY dest_domain) as dns_info, " +
|
||||
"STRING_AGG(DISTINCT COALESCE(host(dest_ip)::text, ''), ',') as victim_ips_str " +
|
||||
"FROM syslog_normal_data " +
|
||||
"WHERE log_time >= #{startTime} AND log_time < #{endTime} " +
|
||||
"AND http_resp_codes =200 and origin_event_type <> '' and origin_event_name='访问日志' AND src_ip NOT IN ('127.0.0.1', '127.0.0.2') " +
|
||||
"GROUP BY to_char(log_time, 'YYYYMMDD'), src_ip, dest_ip, origin_event_name " +
|
||||
"ORDER BY log_date, dest_ip, origin_event_name " +
|
||||
"LIMIT #{pageSize} OFFSET #{offset}")
|
||||
List<GroupedSyslogData> select24HoursGroupedDataByPage(
|
||||
@Param("startTime") LocalDateTime startTime,
|
||||
@Param("endTime") LocalDateTime endTime,
|
||||
@Param("offset") int offset,
|
||||
@Param("pageSize") int pageSize);
|
||||
|
||||
/**
|
||||
* 查询指定时间后的所需字段(使用XML映射)
|
||||
* 注意:参数类型保持为LocalDateTime,但实际映射时使用类型处理器转换
|
||||
*/
|
||||
List<SyslogNormalData> findRequiredFieldsAfterTime(@Param("startTime") LocalDateTime startTime);
|
||||
|
||||
/**
|
||||
* 分页查询所需字段
|
||||
*/
|
||||
List<SyslogNormalData> findRequiredFieldsByPage(
|
||||
@Param("startTime") LocalDateTime startTime,
|
||||
@Param("limit") int limit,
|
||||
@Param("offset") int offset
|
||||
);
|
||||
@Select("SELECT * FROM syslog_normal_data WHERE created_at >= #{startTime, jdbcType=TIMESTAMP} ORDER BY created_at ASC")
|
||||
List<SyslogNormalData> findAfterTime(@Param("startTime") LocalDateTime startTime);
|
||||
|
||||
@Select("SELECT * FROM syslog_normal_data WHERE id = #{id}")
|
||||
SyslogNormalData findById(@Param("id") String id);
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.WecomNotification;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
/**
|
||||
* 微信通知 Mapper 接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface WecomNotificationMapper {
|
||||
|
||||
/**
|
||||
* 插入单条记录(使用序列生成ID)
|
||||
*/
|
||||
@Insert("INSERT INTO wecom_notification (" +
|
||||
"wecom_notification_id, user_id, wecom_notification_name, wecom_notification_ip, " +
|
||||
"wecom_notification_type, wecom_notification_level, wecom_notification_content, " +
|
||||
"wecom_notification_time, tenant_id, create_dept, create_by, create_time, " +
|
||||
"update_by, update_time, remark, wecom_notification_status" +
|
||||
") VALUES (" +
|
||||
"nextval('seq_wecom_notification'), #{userId}, #{wecomNotificationName}, #{wecomNotificationIp}, " +
|
||||
"#{wecomNotificationType}, #{wecomNotificationLevel}, #{wecomNotificationContent}, " +
|
||||
"#{wecomNotificationTime}, #{tenantId}, #{createDept}, #{createBy}, #{createTime}, " +
|
||||
"#{updateBy}, #{updateTime}, #{remark}, #{wecomNotificationStatus}" +
|
||||
")")
|
||||
@SelectKey(statement = "SELECT currval('seq_wecom_notification')", keyProperty = "wecomNotificationId", resultType = Long.class, before = false)
|
||||
int insert(WecomNotification notification);
|
||||
|
||||
/**
|
||||
* 根据通知ID查询
|
||||
*/
|
||||
@Select("SELECT * FROM wecom_notification WHERE wecom_notification_id = #{wecomNotificationId}")
|
||||
WecomNotification selectById(@Param("wecomNotificationId") Long wecomNotificationId);
|
||||
|
||||
/**
|
||||
* 查询未发送的通知列表
|
||||
*/
|
||||
@Select("SELECT * FROM wecom_notification WHERE wecom_notification_status = '1' ORDER BY create_time DESC")
|
||||
java.util.List<WecomNotification> selectUnsentNotifications();
|
||||
|
||||
/**
|
||||
* 更新通知状态
|
||||
*/
|
||||
@Update("UPDATE wecom_notification SET wecom_notification_status = #{status}, update_time = NOW() " +
|
||||
"WHERE wecom_notification_id = #{wecomNotificationId}")
|
||||
int updateStatus(@Param("wecomNotificationId") Long wecomNotificationId, @Param("status") String status);
|
||||
}
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.XdrHoneypot;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* XDR Honeypot Mapper 接口
|
||||
*/
|
||||
public interface XdrHoneypotMapper {
|
||||
|
||||
/**
|
||||
* 插入单条记录
|
||||
*/
|
||||
@Insert("INSERT INTO xdr_honeypot (vcsource, dstart_time, dtime, risk_level, vcconnection, " +
|
||||
"file_info, extra, vctype, agent_sn, agent_name, honeypot_id, honeypot_name, " +
|
||||
"src_ip, src_port, src_mac, dest_ip, dest_port, proxy_ip, node) " +
|
||||
"VALUES (#{vcsource}, #{dstartTime}, #{dtime}, #{riskLevel}, #{vcconnection}, " +
|
||||
"#{fileInfo}, #{extra}, #{vctype}, #{agentSn}, #{agentName}, #{honeypotId}, #{honeypotName}, " +
|
||||
"#{srcIp}, #{srcPort}, #{srcMac}, #{destIp}, #{destPort}, #{proxyIp}, #{node})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
int insert(XdrHoneypot xdrHoneypot);
|
||||
|
||||
/**
|
||||
* 批量插入记录
|
||||
*/
|
||||
int batchInsert(List<XdrHoneypot> xdrHoneypotList);
|
||||
|
||||
/**
|
||||
* 根据ID查询记录
|
||||
*/
|
||||
@Select("SELECT * FROM xdr_honeypot WHERE id = #{id}")
|
||||
@Results({
|
||||
@Result(property = "id", column = "id"),
|
||||
@Result(property = "vcsource", column = "vcsource"),
|
||||
@Result(property = "dstartTime", column = "dstart_time"),
|
||||
@Result(property = "dtime", column = "dtime"),
|
||||
@Result(property = "riskLevel", column = "risk_level"),
|
||||
@Result(property = "vcconnection", column = "vcconnection"),
|
||||
@Result(property = "fileInfo", column = "file_info"),
|
||||
@Result(property = "extra", column = "extra"),
|
||||
@Result(property = "vctype", column = "vctype"),
|
||||
@Result(property = "agentSn", column = "agent_sn"),
|
||||
@Result(property = "agentName", column = "agent_name"),
|
||||
@Result(property = "honeypotId", column = "honeypot_id"),
|
||||
@Result(property = "honeypotName", column = "honeypot_name"),
|
||||
@Result(property = "srcIp", column = "src_ip"),
|
||||
@Result(property = "srcPort", column = "src_port"),
|
||||
@Result(property = "srcMac", column = "src_mac"),
|
||||
@Result(property = "destIp", column = "dest_ip"),
|
||||
@Result(property = "destPort", column = "dest_port"),
|
||||
@Result(property = "proxyIp", column = "proxy_ip"),
|
||||
@Result(property = "node", column = "node")
|
||||
})
|
||||
XdrHoneypot selectById(Long id);
|
||||
|
||||
/**
|
||||
* 查询所有记录
|
||||
*/
|
||||
@Select("SELECT * FROM xdr_honeypot ORDER BY id DESC")
|
||||
@Results({
|
||||
@Result(property = "dstartTime", column = "dstart_time"),
|
||||
@Result(property = "riskLevel", column = "risk_level"),
|
||||
@Result(property = "fileInfo", column = "file_info"),
|
||||
@Result(property = "agentSn", column = "agent_sn"),
|
||||
@Result(property = "agentName", column = "agent_name"),
|
||||
@Result(property = "honeypotId", column = "honeypot_id"),
|
||||
@Result(property = "honeypotName", column = "honeypot_name"),
|
||||
@Result(property = "srcIp", column = "src_ip"),
|
||||
@Result(property = "srcPort", column = "src_port"),
|
||||
@Result(property = "srcMac", column = "src_mac"),
|
||||
@Result(property = "destIp", column = "dest_ip"),
|
||||
@Result(property = "destPort", column = "dest_port"),
|
||||
@Result(property = "proxyIp", column = "proxy_ip")
|
||||
})
|
||||
List<XdrHoneypot> selectAll();
|
||||
|
||||
/**
|
||||
* 根据源IP查询记录
|
||||
*/
|
||||
@Select("SELECT * FROM xdr_honeypot WHERE src_ip = #{srcIp} ORDER BY dtime DESC")
|
||||
List<XdrHoneypot> selectBySrcIp(String srcIp);
|
||||
|
||||
/**
|
||||
* 根据风险等级查询记录
|
||||
*/
|
||||
@Select("SELECT * FROM xdr_honeypot WHERE risk_level = #{riskLevel} ORDER BY dtime DESC")
|
||||
List<XdrHoneypot> selectByRiskLevel(String riskLevel);
|
||||
|
||||
/**
|
||||
* 更新记录
|
||||
*/
|
||||
@Update("UPDATE xdr_honeypot SET risk_level = #{riskLevel}, extra = #{extra} WHERE id = #{id}")
|
||||
int update(XdrHoneypot xdrHoneypot);
|
||||
|
||||
/**
|
||||
* 根据ID删除记录
|
||||
*/
|
||||
@Delete("DELETE FROM xdr_honeypot WHERE id = #{id}")
|
||||
int delete(Long id);
|
||||
|
||||
/**
|
||||
* 统计总记录数
|
||||
*/
|
||||
@Select("SELECT COUNT(*) FROM xdr_honeypot")
|
||||
long count();
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package com.common.service;
|
||||
|
||||
import com.common.entity.AnalysisAnalysisRule;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 分析引擎接口
|
||||
*/
|
||||
public interface AnalysisEngine {
|
||||
|
||||
/**
|
||||
* 执行分析规则
|
||||
*
|
||||
* @param rule 规则
|
||||
* @return 处理结果
|
||||
*/
|
||||
Map<String, Object> executeRule(AnalysisAnalysisRule rule);
|
||||
|
||||
/**
|
||||
* 批量执行规则
|
||||
*
|
||||
* @param rules 规则列表
|
||||
* @return 处理结果列表
|
||||
*/
|
||||
List<Map<String, Object>> executeRules(List<AnalysisAnalysisRule> rules);
|
||||
|
||||
/**
|
||||
* 停止指定规则
|
||||
*
|
||||
* @param ruleId 规则ID
|
||||
*/
|
||||
void stopRule(String ruleId);
|
||||
|
||||
/**
|
||||
* 获取引擎运行模式
|
||||
*
|
||||
* @return 运行模式
|
||||
*/
|
||||
String getRunMode();
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
package com.common.service;
|
||||
|
||||
import com.common.entity.AnalysisAnalysisRule;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 分析规则服务接口
|
||||
*/
|
||||
public interface AnalysisRuleService {
|
||||
|
||||
/**
|
||||
* 执行实时分析
|
||||
*
|
||||
* @return 执行结果
|
||||
*/
|
||||
List<Map<String, Object>> executeRealtimeAnalysis();
|
||||
|
||||
/**
|
||||
* 执行离线分析
|
||||
*
|
||||
* @return 执行结果
|
||||
*/
|
||||
List<Map<String, Object>> executeOfflineAnalysis();
|
||||
|
||||
/**
|
||||
* 查询活动规则
|
||||
*
|
||||
* @param runMode 运行模式
|
||||
* @return 规则列表
|
||||
*/
|
||||
List<AnalysisAnalysisRule> getActiveRules(String runMode);
|
||||
|
||||
/**
|
||||
* 停止规则
|
||||
*
|
||||
* @param ruleId 规则ID
|
||||
*/
|
||||
void stopRule(String ruleId);
|
||||
|
||||
|
||||
/**
|
||||
* 执行单个实时分析规则
|
||||
*
|
||||
* @param ruleId 规则ID
|
||||
* @return 执行结果
|
||||
*/
|
||||
Map<String, Object> executeRealtimeRule(String ruleId);
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.common.service;
|
||||
|
||||
|
||||
import com.common.entity.AppLog;
|
||||
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
//@Repository
|
||||
public interface AppLogRepository extends ElasticsearchRepository<AppLog, String> {
|
||||
|
||||
/**
|
||||
* 根据应用名称和日志级别查询
|
||||
*/
|
||||
List<AppLog> findByAppNameAndLogLevel(String appName, String logLevel);
|
||||
|
||||
/**
|
||||
* 根据时间范围查询
|
||||
*/
|
||||
List<AppLog> findByDtTimeBetween(Long startTime, Long endTime);
|
||||
|
||||
/**
|
||||
* 根据索引名称查询
|
||||
*/
|
||||
List<AppLog> findByIndex(String index);
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
package com.common.service;
|
||||
|
||||
|
||||
import com.common.entity.AppLogEntity;
|
||||
import com.common.mapper.AppLogMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ApplogService {
|
||||
|
||||
@Autowired
|
||||
private AppLogMapper appLogMapper;
|
||||
|
||||
/**
|
||||
* 保存日志到数据库(去重)
|
||||
*/
|
||||
@Transactional
|
||||
public void saveAppLogWithDeduplication(AppLogEntity appLog) {
|
||||
// 检查是否已存在
|
||||
boolean exists = appLogMapper.existsByEsIdAndIndex(appLog.getEsId(), appLog.getEsIndex());
|
||||
|
||||
if (!exists) {
|
||||
appLog.setCreatedAt(LocalDateTime.now());
|
||||
appLog.setUpdatedAt(LocalDateTime.now());
|
||||
appLogMapper.insert(appLog);
|
||||
log.info("保存日志到数据库, ES ID: {}", appLog.getEsId());
|
||||
} else {
|
||||
log.debug("日志已存在,跳过保存, ES ID: {}", appLog.getEsId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量保存日志到数据库(去重)
|
||||
*/
|
||||
@Transactional
|
||||
public int batchSaveAppLogsWithDeduplication(List<AppLogEntity> appLogs) {
|
||||
if (appLogs == null || appLogs.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 过滤已存在的记录
|
||||
List<AppLogEntity> newLogs = appLogs.stream()
|
||||
.filter(log -> !appLogMapper.existsByEsIdAndIndex(log.getEsId(), log.getEsIndex()))
|
||||
.peek(log -> {
|
||||
log.setCreatedAt(LocalDateTime.now());
|
||||
log.setUpdatedAt(LocalDateTime.now());
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
|
||||
if (!newLogs.isEmpty()) {
|
||||
appLogMapper.batchInsert(newLogs);
|
||||
log.info("批量保存 {} 条日志到数据库,跳过 {} 条重复数据",
|
||||
newLogs.size(), appLogs.size() - newLogs.size());
|
||||
} else {
|
||||
log.info("所有 {} 条日志均已存在,跳过保存", appLogs.size());
|
||||
}
|
||||
|
||||
return newLogs.size();
|
||||
}
|
||||
}
|
||||
+210
@@ -0,0 +1,210 @@
|
||||
package com.common.service;
|
||||
|
||||
|
||||
|
||||
import com.common.entity.AlarmVisit;
|
||||
import com.common.entity.GroupedSyslogData;
|
||||
import com.common.mapper.SyslogNormalDataMapper;
|
||||
import com.common.mapper.SyslogNormalAlarmMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.catalina.mapper.Mapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.common.entity.Alarm;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DataExtractor {
|
||||
|
||||
@Autowired
|
||||
private SyslogNormalDataMapper syslogNormalDataMapper;
|
||||
@Autowired
|
||||
private SyslogNormalAlarmMapper syslogNormalAlarmMapper;
|
||||
@Autowired
|
||||
private DataTransformer dataTransformer;
|
||||
|
||||
@Autowired
|
||||
private DataLoader dataLoader;
|
||||
|
||||
@Value("${etl.batch.page-size:1000}")
|
||||
private int pageSize;
|
||||
|
||||
|
||||
/**
|
||||
* 抽取并处理指定时间范围内的分组访问日志数据
|
||||
*/
|
||||
public void extractAndProcessQueryHoursGroupedData( String strStartTime ,String strEndTime ) {
|
||||
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
LocalDateTime endTime = LocalDateTime.parse(strEndTime, formatter);
|
||||
LocalDateTime startTime = LocalDateTime.parse(strStartTime, formatter);
|
||||
|
||||
log.info("开始处理指定时间范围内访问日志数据,时间范围: {} - {}", startTime, endTime);
|
||||
|
||||
try {
|
||||
// 获取分组数据总量
|
||||
Long totalGroups = syslogNormalDataMapper.count24HoursGroupedData(startTime, endTime);
|
||||
log.info("指定时间范围分组数据量: {} 组", totalGroups);
|
||||
|
||||
if (totalGroups == 0) {
|
||||
log.info("没有需要处理的数据");
|
||||
return;
|
||||
}
|
||||
|
||||
int totalPages = (int) Math.ceil((double) totalGroups / pageSize);
|
||||
long totalProcessed = 0;
|
||||
|
||||
for (int page = 1; page <= totalPages; page++) {
|
||||
int offset = (page - 1) * pageSize;
|
||||
syslogNormalDataMapper.select24HoursGroupedDataByPage(
|
||||
startTime, endTime, offset, pageSize);
|
||||
// 分页查询分组数据
|
||||
List<GroupedSyslogData> groupedDataList =
|
||||
syslogNormalDataMapper.select24HoursGroupedDataByPage(
|
||||
startTime, endTime, offset, pageSize);
|
||||
|
||||
if (!groupedDataList.isEmpty()) {
|
||||
// 转换并加载数据
|
||||
List<AlarmVisit> alarmList = dataTransformer.transformGroupedDataVisit(groupedDataList);
|
||||
//dataLoader.batchInsertAlarms(alarmList);
|
||||
dataLoader.batchInsertAlarmVisits(alarmList);
|
||||
totalProcessed += groupedDataList.size();
|
||||
double progress = (double) totalProcessed / totalGroups * 100;
|
||||
log.info("分组数据处理进度: {}/{} ({}%)",
|
||||
totalProcessed, totalGroups, String.format("%.2f", progress));
|
||||
}
|
||||
|
||||
// 内存管理
|
||||
if (page % 50 == 0) {
|
||||
System.gc();
|
||||
log.debug("执行GC清理内存");
|
||||
}
|
||||
}
|
||||
|
||||
log.info("分组数据处理完成,共处理 {} 组数据", totalProcessed);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("访问日志数据抽取处理失败", e);
|
||||
throw new RuntimeException("ETL处理失败", e);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 抽取并处理指定时间范围内的分组告警类型数据
|
||||
*/
|
||||
public void extractAndProcessQueryHoursAlarm( String strStartTime ,String strEndTime ) {
|
||||
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
LocalDateTime endTime = LocalDateTime.parse(strEndTime, formatter);
|
||||
LocalDateTime startTime = LocalDateTime.parse(strStartTime, formatter);
|
||||
|
||||
log.info("开始处理告警类型指定时间范围内数据,时间范围: {} - {}", startTime, endTime);
|
||||
|
||||
try {
|
||||
// 获取分组数据总量
|
||||
Long totalGroups = syslogNormalAlarmMapper.count24HoursGroupedData(startTime, endTime);
|
||||
log.info("指定时间范围分组数据量: {} 组", totalGroups);
|
||||
if (totalGroups == 0) {
|
||||
log.info("没有需要处理的数据");
|
||||
return;
|
||||
}
|
||||
|
||||
int totalPages = (int) Math.ceil((double) totalGroups / pageSize);
|
||||
long totalProcessed = 0;
|
||||
|
||||
for (int page = 1; page <= totalPages; page++) {
|
||||
int offset = (page - 1) * pageSize;
|
||||
syslogNormalAlarmMapper.select24HoursGroupedDataByPage(
|
||||
startTime, endTime, offset, pageSize);
|
||||
// 分页查询分组数据
|
||||
List<GroupedSyslogData> groupedDataList =
|
||||
syslogNormalAlarmMapper.select24HoursGroupedDataByPage(
|
||||
startTime, endTime, offset, pageSize);
|
||||
|
||||
if (!groupedDataList.isEmpty()) {
|
||||
// 转换并加载数据
|
||||
List<Alarm> alarmList = dataTransformer.transformGroupedData(groupedDataList);
|
||||
dataLoader.batchInsertAlarms(alarmList);
|
||||
|
||||
totalProcessed += groupedDataList.size();
|
||||
double progress = (double) totalProcessed / totalGroups * 100;
|
||||
log.info("分组数据处理进度: {}/{} ({}%)",
|
||||
totalProcessed, totalGroups, String.format("%.2f", progress));
|
||||
}
|
||||
|
||||
// 内存管理
|
||||
if (page % 50 == 0) {
|
||||
System.gc();
|
||||
log.debug("执行GC清理内存");
|
||||
}
|
||||
}
|
||||
|
||||
log.info("分组数据处理完成,共处理 {} 组数据", totalProcessed);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("告警日志数据抽取处理失败", e);
|
||||
throw new RuntimeException("ETL处理失败", e);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 抽取并处理24小时内分组数据
|
||||
*/
|
||||
public void extractAndProcess24HoursGroupedData() {
|
||||
|
||||
LocalDateTime endTime = LocalDateTime.now();
|
||||
LocalDateTime startTime = endTime.minusHours(24);
|
||||
|
||||
log.info("开始处理24小时内数据,时间范围: {} - {}", startTime, endTime);
|
||||
|
||||
try {
|
||||
// 获取分组数据总量
|
||||
Long totalGroups = syslogNormalDataMapper.count24HoursGroupedData(startTime, endTime);
|
||||
log.info("24小时内分组数据量: {} 组", totalGroups);
|
||||
|
||||
if (totalGroups == 0) {
|
||||
log.info("没有需要处理的数据");
|
||||
return;
|
||||
}
|
||||
|
||||
int totalPages = (int) Math.ceil((double) totalGroups / pageSize);
|
||||
long totalProcessed = 0;
|
||||
|
||||
for (int page = 1; page <= totalPages; page++) {
|
||||
int offset = (page - 1) * pageSize;
|
||||
|
||||
// 分页查询分组数据
|
||||
List<GroupedSyslogData> groupedDataList =
|
||||
syslogNormalDataMapper.select24HoursGroupedDataByPage(
|
||||
startTime, endTime, offset, pageSize);
|
||||
|
||||
if (!groupedDataList.isEmpty()) {
|
||||
// 转换并加载数据
|
||||
List<Alarm> alarmList = dataTransformer.transformGroupedData(groupedDataList);
|
||||
dataLoader.batchInsertAlarms(alarmList);
|
||||
|
||||
totalProcessed += groupedDataList.size();
|
||||
double progress = (double) totalProcessed / totalGroups * 100;
|
||||
log.info("分组数据处理进度: {}/{} ({:.2f}%)",
|
||||
totalProcessed, totalGroups, progress);
|
||||
}
|
||||
|
||||
// 内存管理
|
||||
if (page % 50 == 0) {
|
||||
System.gc();
|
||||
log.debug("执行GC清理内存");
|
||||
}
|
||||
}
|
||||
|
||||
log.info("分组数据处理完成,共处理 {} 组数据", totalProcessed);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("数据抽取处理失败", e);
|
||||
throw new RuntimeException("ETL处理失败", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
package com.common.service;
|
||||
|
||||
|
||||
|
||||
import com.common.entity.Alarm;
|
||||
import com.common.entity.AlarmVisit;
|
||||
import com.common.mapper.AlarmMapper;
|
||||
import com.common.mapper.AlarmVisitMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DataLoader {
|
||||
|
||||
@Autowired
|
||||
private AlarmMapper alarmMapper;
|
||||
@Autowired
|
||||
private AlarmVisitMapper alarmVisitMapper;
|
||||
/**
|
||||
* 批量入库告警数据
|
||||
*/
|
||||
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
||||
public void batchInsertAlarms(List<Alarm> alarmList) {
|
||||
if (alarmList == null || alarmList.isEmpty()) {
|
||||
log.info("没有需要入库的告警类型数据");
|
||||
return;
|
||||
}
|
||||
|
||||
int batchSize = 500; // 每批500条
|
||||
List<List<Alarm>> batches = partitionList(alarmList, batchSize);
|
||||
int totalSuccess = 0;
|
||||
|
||||
for (int i = 0; i < batches.size(); i++) {
|
||||
List<Alarm> batch = batches.get(i);
|
||||
try {
|
||||
alarmMapper.batchInsert(batch);
|
||||
totalSuccess += batch.size();
|
||||
log.debug("第 {} 批数据入库成功,本批 {} 条", i + 1, batch.size());
|
||||
} catch (Exception e) {
|
||||
log.error("第 {} 批数据批量入库失败,尝试单条插入", i + 1, e);
|
||||
int singleSuccess = insertOneByOne(batch);
|
||||
totalSuccess += singleSuccess;
|
||||
}
|
||||
}
|
||||
|
||||
log.info("告警数据入库完成,成功: {} 条,总数: {} 条", totalSuccess, alarmList.size());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量入库访问日志告警数据
|
||||
*/
|
||||
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
||||
public void batchInsertAlarmVisits(List<AlarmVisit> alarmList) {
|
||||
if (alarmList == null || alarmList.isEmpty()) {
|
||||
log.info("没有需要入库的访问日志数据");
|
||||
return;
|
||||
}
|
||||
|
||||
int batchSize = 500; // 每批500条
|
||||
List<List<AlarmVisit>> batches = partitionList(alarmList, batchSize);
|
||||
int totalSuccess = 0;
|
||||
|
||||
for (int i = 0; i < batches.size(); i++) {
|
||||
List<AlarmVisit> batch = batches.get(i);
|
||||
try {
|
||||
alarmVisitMapper.batchInsert(batch);
|
||||
totalSuccess += batch.size();
|
||||
log.debug("第 {} 批数据入库成功,本批 {} 条", i + 1, batch.size());
|
||||
} catch (Exception e) {
|
||||
log.error("第 {} 批数据批量入库失败,尝试单条插入", i + 1, e);
|
||||
int singleSuccess = insertVisitOneByOne(batch);
|
||||
totalSuccess += singleSuccess;
|
||||
}
|
||||
}
|
||||
|
||||
log.info("访问日志告警数据入库完成,成功: {} 条,总数: {} 条", totalSuccess, alarmList.size());
|
||||
}
|
||||
|
||||
|
||||
private int insertOneByOne(List<Alarm> alarmList) {
|
||||
int successCount = 0;
|
||||
for (Alarm alarm : alarmList) {
|
||||
try {
|
||||
alarmMapper.insert(alarm);
|
||||
successCount++;
|
||||
} catch (Exception e) {
|
||||
log.error("单条插入告警失败: {}", alarm.getId(), e);
|
||||
}
|
||||
}
|
||||
return successCount;
|
||||
}
|
||||
|
||||
private int insertVisitOneByOne(List<AlarmVisit> alarmList) {
|
||||
int successCount = 0;
|
||||
for (AlarmVisit alarm : alarmList) {
|
||||
try {
|
||||
alarmVisitMapper.insert(alarm);
|
||||
successCount++;
|
||||
} catch (Exception e) {
|
||||
log.error("单条插入告警失败: {}", alarm.getId(), e);
|
||||
}
|
||||
}
|
||||
return successCount;
|
||||
}
|
||||
private <T> List<List<T>> partitionList(List<T> list, int size) {
|
||||
return IntStream.range(0, (list.size() + size - 1) / size)
|
||||
.mapToObj(i -> list.subList(i * size, Math.min((i + 1) * size, list.size())))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+302
@@ -0,0 +1,302 @@
|
||||
package com.common.service;
|
||||
|
||||
|
||||
|
||||
import com.common.entity.Alarm;
|
||||
import com.common.entity.AlarmVisit;
|
||||
import com.common.entity.GroupedSyslogData;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DataTransformer {
|
||||
|
||||
/**
|
||||
* 转换分组数据为告警记录
|
||||
*/
|
||||
public List<Alarm> transformGroupedData(List<GroupedSyslogData> groupedDataList) {
|
||||
List<Alarm> alarmList = new ArrayList<>(groupedDataList.size());
|
||||
|
||||
for (GroupedSyslogData groupedData : groupedDataList) {
|
||||
Alarm alarm = transformSingleGroupedData(groupedData);
|
||||
if (alarm != null) {
|
||||
alarmList.add(alarm);
|
||||
}
|
||||
}
|
||||
|
||||
return alarmList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换分组数据为告警记录
|
||||
*/
|
||||
public List<AlarmVisit> transformGroupedDataVisit(List<GroupedSyslogData> groupedDataList) {
|
||||
List<AlarmVisit> alarmList = new ArrayList<>(groupedDataList.size());
|
||||
|
||||
for (GroupedSyslogData groupedData : groupedDataList) {
|
||||
AlarmVisit alarm = transformSingleGroupedDataVisit(groupedData);
|
||||
if (alarm != null) {
|
||||
alarmList.add(alarm);
|
||||
}
|
||||
}
|
||||
|
||||
return alarmList;
|
||||
}
|
||||
|
||||
private Alarm transformSingleGroupedData(GroupedSyslogData groupedData) {
|
||||
try {
|
||||
return Alarm.builder()
|
||||
.id(UUID.randomUUID().toString())
|
||||
.createdAt(LocalDateTime.now())
|
||||
.alarmName( groupedData.getOriginEventName())
|
||||
.alarmLevel(convertAlarmLevel(groupedData.getMaxEventLevel()))
|
||||
.alarmType(getAlarmType(groupedData.getFirstEventType(),groupedData.getMinEventType()))
|
||||
.alarmMajorType(groupedData.getEventType())
|
||||
.alarmMinorType(groupedData.getMinEventType())
|
||||
.alarmAreaId(0)
|
||||
.attackIp(groupedData.getAttackIps())
|
||||
.victimIp(groupedData.getVictimIps())
|
||||
.victimWebUrl(groupedData.getVictimWebUrls())
|
||||
.attackChainPhase(new Integer[]{-1})
|
||||
.deviceId(groupedData.getDeviceIds())
|
||||
.tag(null)
|
||||
.comment(buildComment(groupedData))
|
||||
.originLogIds(groupedData.getOriginLogIds())
|
||||
.queryId(null)
|
||||
.judgedState(0)
|
||||
.disposedState(0)
|
||||
.dispositionAdvice("研判后处置")
|
||||
.attackResult(determineAttackResult(groupedData))
|
||||
.fall(0)
|
||||
.payload(extractPayloadSample(groupedData.getPayloadSamples()))
|
||||
.operateEvent(null)
|
||||
.attackPort(groupedData.getAttackPorts())
|
||||
.victimPort(groupedData.getVictimPorts())
|
||||
.attackMethod(groupedData.getOriginEventName())
|
||||
.businessExt(null)
|
||||
.logStartAt(groupedData.getMinLogTime())
|
||||
.logEndAt(groupedData.getMaxLogTime())
|
||||
.httpStatus(convertHttpStatus(groupedData.getHttpStatusCodes()))
|
||||
.dnsInfo(groupedData.getDnsInfo())
|
||||
.accountInfo(null)
|
||||
.attackerInfo(null)
|
||||
.victimInfo(null)
|
||||
.suspiciousAction(null)
|
||||
.vulnInfo(null)
|
||||
.weakPwd(null)
|
||||
.complianceBaseline(null)
|
||||
.fileInfo(null)
|
||||
.fileTags(null)
|
||||
.endpointInfo(null)
|
||||
.endpointProtection(null)
|
||||
.originInfo(null)
|
||||
.protocolInfo(null)
|
||||
.emailInfo(null)
|
||||
.sensitiveData(null)
|
||||
.hitIntelligence(0)
|
||||
.windowTime(null)
|
||||
.updatedAt(LocalDateTime.now())
|
||||
.engineType(null)
|
||||
.attackIpPic(null)
|
||||
.victimIpPic(null)
|
||||
.operationAt(null)
|
||||
.attackDirection("other")
|
||||
.etlTime(LocalDateTime.now())
|
||||
.logCount(groupedData.getLogCount().intValue())
|
||||
.isAssetHit(0)
|
||||
.focused(false)
|
||||
.baseFocused(false)
|
||||
.isUpdated(false)
|
||||
.httpReqHeader(groupedData.getHttpReqHeaders())
|
||||
.httpReqBody(groupedData.getHttpReqBodys())
|
||||
.httpRespHeader(groupedData.getHttpRespHeaders())
|
||||
.httpRespBody(groupedData.getHttpRespBodys())
|
||||
.build();
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("转换分组数据失败: {}", groupedData, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private AlarmVisit transformSingleGroupedDataVisit(GroupedSyslogData groupedData) {
|
||||
try {
|
||||
return AlarmVisit.builder()
|
||||
.id(UUID.randomUUID().toString())
|
||||
.createdAt(LocalDateTime.now())
|
||||
.alarmName( groupedData.getOriginEventName())
|
||||
.alarmLevel(convertAlarmLevel(groupedData.getMaxEventLevel()))
|
||||
.alarmType(getAlarmType(groupedData.getFirstEventType(),groupedData.getEventType()))
|
||||
.alarmMajorType(groupedData.getEventType())
|
||||
.alarmMinorType(groupedData.getMinEventType())
|
||||
.alarmAreaId(0)
|
||||
.attackIp(groupedData.getAttackIps())
|
||||
.victimIp(groupedData.getVictimIps())
|
||||
.victimWebUrl(groupedData.getVictimWebUrls())
|
||||
.attackChainPhase(new Integer[]{-1})
|
||||
.deviceId(groupedData.getDeviceIds())
|
||||
.tag(null)
|
||||
.comment(buildComment(groupedData))
|
||||
.originLogIds(groupedData.getOriginLogIds())
|
||||
.queryId(null)
|
||||
.judgedState(0)
|
||||
.disposedState(0)
|
||||
.dispositionAdvice("研判后处置")
|
||||
.attackResult(determineAttackResult(groupedData))
|
||||
.fall(0)
|
||||
.payload(extractPayloadSample(groupedData.getPayloadSamples()))
|
||||
.operateEvent(null)
|
||||
.attackPort(groupedData.getAttackPorts())
|
||||
.victimPort(groupedData.getVictimPorts())
|
||||
.attackMethod(groupedData.getOriginEventName())
|
||||
.businessExt(null)
|
||||
.logStartAt(groupedData.getMinLogTime())
|
||||
.logEndAt(groupedData.getMaxLogTime())
|
||||
.httpStatus(convertHttpStatus(groupedData.getHttpStatusCodes()))
|
||||
.dnsInfo(groupedData.getDnsInfo())
|
||||
.accountInfo(null)
|
||||
.attackerInfo(null)
|
||||
.victimInfo(null)
|
||||
.suspiciousAction(null)
|
||||
.vulnInfo(null)
|
||||
.weakPwd(null)
|
||||
.complianceBaseline(null)
|
||||
.fileInfo(null)
|
||||
.fileTags(null)
|
||||
.endpointInfo(null)
|
||||
.endpointProtection(null)
|
||||
.originInfo(null)
|
||||
.protocolInfo(null)
|
||||
.emailInfo(null)
|
||||
.sensitiveData(null)
|
||||
.hitIntelligence(0)
|
||||
.windowTime(null)
|
||||
.updatedAt(LocalDateTime.now())
|
||||
.engineType(null)
|
||||
.attackIpPic(null)
|
||||
.victimIpPic(null)
|
||||
.operationAt(null)
|
||||
.attackDirection("other")
|
||||
.etlTime(LocalDateTime.now())
|
||||
.logCount(groupedData.getLogCount().intValue())
|
||||
.isAssetHit(0)
|
||||
.focused(false)
|
||||
.baseFocused(false)
|
||||
.isUpdated(false)
|
||||
.httpReqHeader(groupedData.getHttpReqHeaders())
|
||||
.httpReqBody(groupedData.getHttpReqBodys())
|
||||
.httpRespHeader(groupedData.getHttpRespHeaders())
|
||||
.httpRespBody(groupedData.getHttpRespBodys())
|
||||
.build();
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("转换分组数据失败: {}", groupedData, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private String getAlarmType(String firstEventType,String eventType) {
|
||||
// 如果 firstEventType 有效则使用它
|
||||
if (firstEventType != null && !firstEventType.isEmpty()) {
|
||||
return firstEventType;
|
||||
}
|
||||
|
||||
// 否则使用 eventType(如果也为 null 则返回空字符串)
|
||||
return eventType != null ? eventType : "";
|
||||
}
|
||||
/**
|
||||
* 确定attack_result的值
|
||||
*/
|
||||
private Integer determineAttackResult(GroupedSyslogData groupedData) {
|
||||
// 优先使用单个attack_result值
|
||||
if (groupedData.getAttackResult() != null) {
|
||||
return groupedData.getAttackResult();
|
||||
}
|
||||
|
||||
// 如果没有单个值,使用最常见的值
|
||||
if (groupedData.getMostCommonAttackResult() != null) {
|
||||
return groupedData.getMostCommonAttackResult();
|
||||
}
|
||||
|
||||
// 如果有多值,取第一个非空值
|
||||
if (groupedData.getAllAttackResults() != null && groupedData.getAllAttackResults().length > 0) {
|
||||
for (Integer result : groupedData.getAllAttackResults()) {
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 默认值
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 提取payload样本
|
||||
*/
|
||||
private byte[] extractPayloadSample(byte[][] payloadSamples) {
|
||||
if (payloadSamples == null || payloadSamples.length == 0) {
|
||||
return null;
|
||||
}
|
||||
// 返回第一个样本
|
||||
return payloadSamples[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建comment字段
|
||||
*/
|
||||
private String buildComment(GroupedSyslogData groupedData) {
|
||||
String victimIpsStr;
|
||||
if (StringUtils.isNotBlank(groupedData.getVictimIpsStr())) {
|
||||
victimIpsStr = groupedData.getVictimIpsStr();
|
||||
} else if (groupedData.getVictimIps() != null && groupedData.getVictimIps().length > 0) {
|
||||
victimIpsStr = String.join(",", groupedData.getVictimIps());
|
||||
} else {
|
||||
victimIpsStr = "未知";
|
||||
}
|
||||
|
||||
return String.format(
|
||||
"24小时内,检测到%s上产生%s告警:\n告警名称:%s\n攻击IP:%s\n攻击结果:%d",
|
||||
victimIpsStr,
|
||||
convertAlarmLevel(groupedData.getMaxEventLevel()),
|
||||
groupedData.getOriginEventName(),
|
||||
convertAttackIps(groupedData.getAttackIps()),
|
||||
determineAttackResult(groupedData)
|
||||
);
|
||||
}
|
||||
|
||||
private String convertAlarmLevel(Integer eventLevel) {
|
||||
if (eventLevel == null) return "未知";
|
||||
switch (eventLevel) {
|
||||
case 0: return "安全(无威胁)";
|
||||
case 1: return "低危";
|
||||
case 2: return "中危";
|
||||
case 3: return "高危";
|
||||
case 4: return "超危";
|
||||
default: return "未知";
|
||||
}
|
||||
}
|
||||
|
||||
private String convertHttpStatus(String[] httpStatusCodes) {
|
||||
if (httpStatusCodes == null || httpStatusCodes.length == 0) {
|
||||
return null;
|
||||
}
|
||||
return String.join(",", httpStatusCodes);
|
||||
}
|
||||
|
||||
private String convertAttackIps(String[] attackIps) {
|
||||
if (attackIps == null || attackIps.length == 0) {
|
||||
return null;
|
||||
}
|
||||
return String.join(",", attackIps);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+136
@@ -0,0 +1,136 @@
|
||||
package com.common.service;
|
||||
|
||||
import com.common.entity.DeviceCollectTask;
|
||||
import com.common.mapper.DeviceCollectTaskMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.cache.annotation.CachePut;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "collectTask")
|
||||
public class DeviceCollectTaskService {
|
||||
|
||||
@Autowired
|
||||
private DeviceCollectTaskMapper deviceCollectTaskMapper;
|
||||
|
||||
/**
|
||||
* 根据ID查询采集任务 - 缓存
|
||||
*/
|
||||
@Cacheable(key = "'id:' + #id")
|
||||
public DeviceCollectTask getById(Integer id) {
|
||||
return deviceCollectTaskMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有采集任务 - 缓存
|
||||
*/
|
||||
@Cacheable(key = "'all'")
|
||||
public List<DeviceCollectTask> getAll() {
|
||||
return deviceCollectTaskMapper.selectAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据设备ID查询采集任务 - 缓存
|
||||
*/
|
||||
@Cacheable(key = "'device:' + #deviceId")
|
||||
public List<DeviceCollectTask> getByDeviceId(Integer deviceId) {
|
||||
return deviceCollectTaskMapper.selectByDeviceId(deviceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据方法类型查询采集任务
|
||||
*/
|
||||
public List<DeviceCollectTask> getByMethod(Integer method) {
|
||||
return deviceCollectTaskMapper.selectByMethod(method);
|
||||
}
|
||||
|
||||
/**
|
||||
* 多条件组合查询
|
||||
*/
|
||||
public List<DeviceCollectTask> getByCondition(DeviceCollectTask condition) {
|
||||
return deviceCollectTaskMapper.selectByCondition(condition);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增采集任务 - 清除相关缓存
|
||||
*/
|
||||
@CacheEvict(allEntries = true)
|
||||
public int create(DeviceCollectTask task) {
|
||||
return deviceCollectTaskMapper.insert(task);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新采集任务 - 更新缓存
|
||||
*/
|
||||
@CachePut(key = "'id:' + #task.id")
|
||||
@CacheEvict(key = "'device:' + #task.deviceId")
|
||||
public DeviceCollectTask update(DeviceCollectTask task) {
|
||||
deviceCollectTaskMapper.update(task);
|
||||
return deviceCollectTaskMapper.selectById(task.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除采集任务 - 清除缓存
|
||||
*/
|
||||
@CacheEvict(key = "'id:' + #id")
|
||||
public int delete(Integer id) {
|
||||
return deviceCollectTaskMapper.deleteById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 标记任务成功 - 更新缓存
|
||||
*/
|
||||
@CacheEvict(key = "'id:' + #id")
|
||||
public int markSuccess(Integer id) {
|
||||
return deviceCollectTaskMapper.updateSuccessStatus(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 标记任务失败 - 更新缓存
|
||||
*/
|
||||
@CacheEvict(key = "'id:' + #id")
|
||||
public int markFailed(Integer id) {
|
||||
return deviceCollectTaskMapper.updateFailedStatus(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新EPM指标 - 更新缓存
|
||||
*/
|
||||
@CacheEvict(key = "'id:' + #id")
|
||||
public int updateEpm(Integer id, Integer epm) {
|
||||
return deviceCollectTaskMapper.updateEpm(id, epm);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询成功的任务
|
||||
*/
|
||||
public List<DeviceCollectTask> getSuccessTasks() {
|
||||
return deviceCollectTaskMapper.selectSuccessTasks();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询失败的任务
|
||||
*/
|
||||
public List<DeviceCollectTask> getFailedTasks() {
|
||||
return deviceCollectTaskMapper.selectFailedTasks();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备的最新采集任务
|
||||
*/
|
||||
@Cacheable(key = "'latest:device:' + #deviceId")
|
||||
public DeviceCollectTask getLatestByDeviceId(Integer deviceId) {
|
||||
return deviceCollectTaskMapper.selectLatestByDeviceId(deviceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计设备任务数量
|
||||
*/
|
||||
public int countByDeviceId(Integer deviceId) {
|
||||
return deviceCollectTaskMapper.countByDeviceId(deviceId);
|
||||
}
|
||||
}
|
||||
+251
@@ -0,0 +1,251 @@
|
||||
package com.common.service;
|
||||
|
||||
|
||||
import com.common.entity.*;
|
||||
import com.common.mapper.DeviceCollectTaskMapper;
|
||||
import com.common.mapper.DeviceReceiveLogMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.time.ZoneOffset;
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DeviceCollectTaskUpdateService {
|
||||
|
||||
private final DeviceReceiveLogMapper deviceReceiveLogMapper;
|
||||
private final DeviceCollectTaskMapper deviceCollectTaskMapper;
|
||||
|
||||
/**
|
||||
* 主处理方法:更新所有设备任务的时间信息
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateAllDeviceTaskTimes() {
|
||||
log.info("开始更新设备采集任务时间,当前时间: {}", LocalDateTime.now());
|
||||
|
||||
// 1. 查询所有设备任务
|
||||
List<DeviceCollectTask> allTasks = deviceCollectTaskMapper.selectAllTasks();
|
||||
if (CollectionUtils.isEmpty(allTasks)) {
|
||||
log.info("没有找到设备采集任务");
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. 查询设备接收日志的时间信息
|
||||
Map<String, DeviceCollectTaskTime> successTimes = getDeviceSuccessTimes();
|
||||
Map<String, DeviceCollectTaskTime> failTimes = getDeviceFailTimes();
|
||||
|
||||
// 3. 更新任务时间
|
||||
LocalDateTime updateTime = LocalDateTime.now();
|
||||
int updatedCount = 0;
|
||||
|
||||
for (DeviceCollectTask task : allTasks) {
|
||||
String deviceCollectId = task.getId().toString();
|
||||
|
||||
// 获取成功时间
|
||||
DeviceCollectTaskTime successTime = successTimes.get(deviceCollectId);
|
||||
DeviceCollectTaskTime failTime = failTimes.get(deviceCollectId);
|
||||
|
||||
// 准备更新时间
|
||||
LocalDateTime firstTime = task.getFirstTime().toLocalDateTime();
|
||||
LocalDateTime lastSuccessTime = null;
|
||||
LocalDateTime lastFailTime = null;
|
||||
|
||||
// 设置最后成功时间
|
||||
if (successTime != null && successTime.getLastSuccessTime() != null) {
|
||||
lastSuccessTime = successTime.getLastSuccessTime();
|
||||
|
||||
// 如果first_time为空,且这是首次成功,则设置first_time
|
||||
if (firstTime == null && successTime.getFirstTime() != null) {
|
||||
firstTime = successTime.getFirstTime();
|
||||
}
|
||||
}
|
||||
|
||||
// 设置最后失败时间
|
||||
if (failTime != null && failTime.getLastFailTime() != null) {
|
||||
lastFailTime = failTime.getLastFailTime();
|
||||
}
|
||||
|
||||
// 如果有更新,则执行更新
|
||||
if (lastSuccessTime != null || lastFailTime != null) {
|
||||
int result = deviceCollectTaskMapper.updateTaskTime(
|
||||
deviceCollectId,
|
||||
firstTime,
|
||||
lastSuccessTime,
|
||||
lastFailTime,
|
||||
updateTime
|
||||
);
|
||||
|
||||
if (result > 0) {
|
||||
updatedCount++;
|
||||
log.debug("更新设备任务时间成功,设备ID: {}, 首次时间: {}, 最后成功: {}, 最后失败: {}",
|
||||
deviceCollectId, firstTime, lastSuccessTime, lastFailTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.info("设备采集任务时间更新完成,总计: {},已更新: {}", allTasks.size(), updatedCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量更新版本(性能更好)
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void batchUpdateDeviceTaskTimes() {
|
||||
log.info("开始批量更新设备采集任务时间,当前时间: {}", LocalDateTime.now());
|
||||
|
||||
// 1. 查询所有设备任务
|
||||
List<DeviceCollectTask> allTasks = deviceCollectTaskMapper.selectAllTasks();
|
||||
if (CollectionUtils.isEmpty(allTasks)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. 查询时间信息
|
||||
Map<String, DeviceCollectTaskTime> successTimes = getDeviceSuccessTimes();
|
||||
Map<String, DeviceCollectTaskTime> failTimes = getDeviceFailTimes();
|
||||
|
||||
// 3. 批量更新
|
||||
LocalDateTime updateTime = LocalDateTime.now();
|
||||
|
||||
for (DeviceCollectTask task : allTasks) {
|
||||
String deviceCollectId = task.getId().toString();
|
||||
|
||||
// 获取成功和失败时间
|
||||
DeviceCollectTaskTime successTime = successTimes.get(deviceCollectId);
|
||||
DeviceCollectTaskTime failTime = failTimes.get(deviceCollectId);
|
||||
|
||||
// 更新成功时间
|
||||
if (successTime != null) {
|
||||
// 如果first_time为空,则设置首次成功时间
|
||||
if (task.getFirstTime() == null && successTime.getFirstTime() != null) {
|
||||
task.setFirstTime(successTime.getFirstTime().atOffset(ZoneOffset.UTC));
|
||||
}
|
||||
|
||||
// 设置最后成功时间
|
||||
if (successTime.getLastSuccessTime() != null) {
|
||||
task.setLastSuccessTime(successTime.getLastSuccessTime().atOffset(ZoneOffset.UTC));
|
||||
}
|
||||
}
|
||||
|
||||
// 更新失败时间
|
||||
if (failTime != null && failTime.getLastFailTime() != null) {
|
||||
task.setLastFailedTime(failTime.getLastFailTime().atOffset(ZoneOffset.UTC));
|
||||
}
|
||||
|
||||
task.setUpdatedAt(updateTime.atOffset(ZoneOffset.UTC));
|
||||
}
|
||||
|
||||
// 4. 批量更新到数据库
|
||||
int updatedCount = deviceCollectTaskMapper.batchUpdateTimes(allTasks);
|
||||
log.info("批量更新完成,总计: {},已更新: {}", allTasks.size(), updatedCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备的成功时间信息
|
||||
*/
|
||||
private Map<String, DeviceCollectTaskTime> getDeviceSuccessTimes() {
|
||||
// 查询当天的最新成功时间
|
||||
List<DeviceCollectTaskTime> dailySuccess = deviceReceiveLogMapper.selectDailySuccessTimes();
|
||||
|
||||
// 查询首次成功时间(历史)
|
||||
List<DeviceCollectTaskTime> firstSuccess = deviceReceiveLogMapper.selectFirstSuccessTimes();
|
||||
|
||||
// 合并结果
|
||||
Map<String, DeviceCollectTaskTime> result = new HashMap<>();
|
||||
|
||||
// 处理首次成功时间
|
||||
for (DeviceCollectTaskTime first : firstSuccess) {
|
||||
DeviceCollectTaskTime time = new DeviceCollectTaskTime();
|
||||
time.setDeviceCollectId(first.getDeviceCollectId());
|
||||
time.setFirstTime(first.getFirstTime());
|
||||
result.put(first.getDeviceCollectId(), time);
|
||||
}
|
||||
|
||||
// 处理当天成功时间
|
||||
for (DeviceCollectTaskTime daily : dailySuccess) {
|
||||
String deviceId = daily.getDeviceCollectId();
|
||||
DeviceCollectTaskTime time = result.getOrDefault(deviceId, new DeviceCollectTaskTime());
|
||||
time.setDeviceCollectId(deviceId);
|
||||
time.setLastSuccessTime(daily.getLastSuccessTime());
|
||||
result.put(deviceId, time);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备的失败时间信息
|
||||
*/
|
||||
private Map<String, DeviceCollectTaskTime> getDeviceFailTimes() {
|
||||
List<DeviceCollectTaskTime> failTimes = deviceReceiveLogMapper.selectDailyFailTimes();
|
||||
return failTimes.stream()
|
||||
.collect(Collectors.toMap(
|
||||
DeviceCollectTaskTime::getDeviceCollectId,
|
||||
ft -> ft,
|
||||
(existing, replacement) -> {
|
||||
// 如果存在重复,取更晚的时间
|
||||
if (existing.getLastFailTime() != null &&
|
||||
replacement.getLastFailTime() != null &&
|
||||
replacement.getLastFailTime().isAfter(existing.getLastFailTime())) {
|
||||
return replacement;
|
||||
}
|
||||
return existing;
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* 增量更新:只处理最近一段时间的数据
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void incrementalUpdate(int hours) {
|
||||
LocalDateTime endTime = LocalDateTime.now();
|
||||
LocalDateTime startTime = endTime.minusHours(hours);
|
||||
|
||||
log.info("开始增量更新设备采集任务时间,时间范围: {} 到 {}", startTime, endTime);
|
||||
|
||||
// 查询指定时间范围内的成功记录
|
||||
List<DeviceCollectTaskTime> successTimes = deviceReceiveLogMapper.selectSuccessTimesByRange(startTime, endTime);
|
||||
|
||||
if (CollectionUtils.isEmpty(successTimes)) {
|
||||
log.info("没有找到增量数据");
|
||||
return;
|
||||
}
|
||||
|
||||
LocalDateTime updateTime = LocalDateTime.now();
|
||||
int updatedCount = 0;
|
||||
|
||||
for (DeviceCollectTaskTime successTime : successTimes) {
|
||||
// 查询现有任务
|
||||
DeviceCollectTask task = deviceCollectTaskMapper.selectOne(
|
||||
new com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<DeviceCollectTask>()
|
||||
.eq("id", successTime.getDeviceCollectId())
|
||||
);
|
||||
|
||||
if (task != null) {
|
||||
// 更新任务时间
|
||||
int result = deviceCollectTaskMapper.updateTaskTime(
|
||||
successTime.getDeviceCollectId(),
|
||||
task.getFirstTime() == null ? successTime.getFirstTime() : null,
|
||||
successTime.getLastSuccessTime(),
|
||||
null, // 失败时间需要单独查询
|
||||
updateTime
|
||||
);
|
||||
|
||||
if (result > 0) {
|
||||
updatedCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.info("增量更新完成,处理记录: {},更新任务: {}", successTimes.size(), updatedCount);
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.common.service;
|
||||
|
||||
import com.common.entity.DeviceDevice;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface DeviceDeviceService {
|
||||
|
||||
DeviceDevice getByIdSafely(Integer id);
|
||||
|
||||
|
||||
|
||||
List<DeviceDevice> getByIpSafely(String ip);
|
||||
|
||||
DeviceDevice getById(Integer id);
|
||||
|
||||
List<DeviceDevice> getAll();
|
||||
|
||||
List<DeviceDevice> getByIp(String ip);
|
||||
|
||||
List<DeviceDevice> getByNameLike(String name);
|
||||
|
||||
List<DeviceDevice> getByCondition(DeviceDevice condition);
|
||||
|
||||
List<DeviceDevice> getByMap(Map<String, Object> params);
|
||||
|
||||
List<DeviceDevice> getByPage(int pageNum, int pageSize);
|
||||
|
||||
Long getCount();
|
||||
|
||||
List<DeviceDevice> getMonitoringDevices();
|
||||
|
||||
List<DeviceDevice> getActiveDevices();
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
package com.common.service;
|
||||
|
||||
import com.common.entity.DeviceInterlockingCmd;
|
||||
import com.common.mapper.DeviceInterlockingCmdMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class DeviceInterlockingCmdService {
|
||||
|
||||
@Autowired
|
||||
private DeviceInterlockingCmdMapper cmdMapper;
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
public DeviceInterlockingCmd selectById(Long id) {
|
||||
return cmdMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询待执行的指令
|
||||
*/
|
||||
public List<DeviceInterlockingCmd> selectPendingCommands(Long probeId) {
|
||||
return cmdMapper.selectPendingCommands(probeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据探针ID和状态查询
|
||||
*/
|
||||
public List<DeviceInterlockingCmd> selectByProbeIdAndStatus(Long probeId, String cmdStatus) {
|
||||
return cmdMapper.selectByProbeIdAndStatus(probeId, cmdStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入指令
|
||||
*/
|
||||
public int insert(DeviceInterlockingCmd cmd) {
|
||||
return cmdMapper.insert(cmd);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新指令状态
|
||||
*/
|
||||
public int updateStatus(Long id, String cmdStatus) {
|
||||
return cmdMapper.updateStatus(id, cmdStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新指令状态为执行中
|
||||
*/
|
||||
public int updateStatusToExecuting(Long id) {
|
||||
return cmdMapper.updateStatusToExecuting(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新指令状态为执行完成
|
||||
*/
|
||||
public int updateStatusToCompleted(Long id) {
|
||||
return cmdMapper.updateStatusToCompleted(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新指令状态为执行失败
|
||||
*/
|
||||
public int updateStatusToFailed(Long id) {
|
||||
return cmdMapper.updateStatusToFailed(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有指令
|
||||
*/
|
||||
public List<DeviceInterlockingCmd> selectAll() {
|
||||
return cmdMapper.selectAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据多个ID查询
|
||||
*/
|
||||
public List<DeviceInterlockingCmd> selectByIds(List<Long> ids) {
|
||||
return cmdMapper.selectByIds(ids);
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
package com.common.service;
|
||||
|
||||
import com.common.entity.DeviceInterlockingLog;
|
||||
import com.common.mapper.DeviceInterlockingLogMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class DeviceInterlockingLogService {
|
||||
|
||||
@Autowired
|
||||
private DeviceInterlockingLogMapper logMapper;
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
public DeviceInterlockingLog selectById(Long id) {
|
||||
return logMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据指令ID查询
|
||||
*/
|
||||
public List<DeviceInterlockingLog> selectByCmdId(Long cmdId) {
|
||||
return logMapper.selectByCmdId(cmdId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入记录
|
||||
*/
|
||||
public int insert(DeviceInterlockingLog log) {
|
||||
if (log.getBanTime() == null) {
|
||||
log.setBanTime(OffsetDateTime.now());
|
||||
}
|
||||
return logMapper.insert(log);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量插入记录
|
||||
*/
|
||||
public int batchInsert(List<DeviceInterlockingLog> logs) {
|
||||
if (logs != null && !logs.isEmpty()) {
|
||||
for (DeviceInterlockingLog log : logs) {
|
||||
if (log.getBanTime() == null) {
|
||||
log.setBanTime(OffsetDateTime.now());
|
||||
}
|
||||
}
|
||||
}
|
||||
return logMapper.batchInsert(logs);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有记录
|
||||
*/
|
||||
public List<DeviceInterlockingLog> selectAll() {
|
||||
return logMapper.selectAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计某指令的成功/失败数量
|
||||
*/
|
||||
public List<java.util.Map<String, Object>> countByCmdId(Long cmdId) {
|
||||
return logMapper.countByCmdId(cmdId);
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
package com.common.service;
|
||||
|
||||
import com.common.entity.DeviceInterlocking;
|
||||
import com.common.mapper.DeviceInterlockingMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class DeviceInterlockingService {
|
||||
|
||||
@Autowired
|
||||
private DeviceInterlockingMapper interlockingMapper;
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
public DeviceInterlocking selectById(Long id) {
|
||||
return interlockingMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据部门ID查询联动设备
|
||||
*/
|
||||
public List<DeviceInterlocking> selectByDeptId(String deptId) {
|
||||
return interlockingMapper.selectByDeptId(deptId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据厂商查询
|
||||
*/
|
||||
public List<DeviceInterlocking> selectByVendor(String vendor) {
|
||||
return interlockingMapper.selectByVendor(vendor);
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入记录
|
||||
*/
|
||||
public int insert(DeviceInterlocking device) {
|
||||
return interlockingMapper.insert(device);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新记录
|
||||
*/
|
||||
public int update(DeviceInterlocking device) {
|
||||
return interlockingMapper.update(device);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有记录
|
||||
*/
|
||||
public List<DeviceInterlocking> selectAll() {
|
||||
return interlockingMapper.selectAll();
|
||||
}
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.common.service;
|
||||
|
||||
|
||||
|
||||
import com.common.entity.DeviceReceiveLog;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface DeviceReceiveLogService {
|
||||
|
||||
// 插入操作
|
||||
Long insertLog(DeviceReceiveLog log);
|
||||
int batchInsertLogs(List<DeviceReceiveLog> logs);
|
||||
|
||||
// 查询操作
|
||||
DeviceReceiveLog getById(Long id);
|
||||
List<DeviceReceiveLog> getByDeviceId(Integer deviceId);
|
||||
List<DeviceReceiveLog> getByCollectId(Integer collectId);
|
||||
List<DeviceReceiveLog> getByTimeRange(LocalDateTime startTime, LocalDateTime endTime);
|
||||
List<DeviceReceiveLog> getByCondition(DeviceReceiveLog condition);
|
||||
PageInfo<DeviceReceiveLog> getByConditionPage(DeviceReceiveLog condition, Integer pageNum, Integer pageSize);
|
||||
|
||||
// 统计操作
|
||||
Long countByCondition(DeviceReceiveLog condition);
|
||||
List<Map<String, Object>> getDeviceLogStatistics();
|
||||
|
||||
// 删除操作
|
||||
int deleteOldLogs(LocalDateTime beforeTime);
|
||||
|
||||
// 获取最近日志
|
||||
List<DeviceReceiveLog> getRecentLogs(Integer limit);
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.common.service;
|
||||
|
||||
import com.common.entity.DmColumn;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface DmColumnService {
|
||||
|
||||
List<DmColumn> findAll();
|
||||
|
||||
DmColumn findById(Long id);
|
||||
|
||||
DmColumn findByDmColumnId(Long id);
|
||||
|
||||
DmColumn findByName(String name);
|
||||
|
||||
List<DmColumn> findByDisplayName(String displayName);
|
||||
|
||||
List<DmColumn> findByIsBuiltIn(Boolean isBuiltIn);
|
||||
|
||||
int insert(DmColumn dmColumn);
|
||||
|
||||
int batchInsert(List<DmColumn> dmColumns);
|
||||
|
||||
List<DmColumn> findByCondition(DmColumn condition);
|
||||
Long count();
|
||||
|
||||
List<Map<String, Object>> selectAllNormal();
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
package com.common.service;
|
||||
|
||||
import com.common.entity.XdrHoneypot;
|
||||
import com.common.mapper.XdrHoneypotMapper;
|
||||
import com.common.util.MyBatisUtil;
|
||||
import com.influx.SyslogToInfluxApp;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.common.mapper.DmNormalizeRuleMapper;
|
||||
import com.common.entity.DmNormalizeRule;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "normalizeRule")
|
||||
public class DmNormalizeRuleService {
|
||||
|
||||
@Autowired
|
||||
private DmNormalizeRuleMapper dmNormalizeRuleMapper;
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DmNormalizeRuleService.class);
|
||||
|
||||
|
||||
/**
|
||||
* 根据ID查询规则
|
||||
*/
|
||||
@Cacheable(key = "'id:' + #id")
|
||||
public DmNormalizeRule getById(Long id) {
|
||||
return dmNormalizeRuleMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID和租户查询规则
|
||||
*/
|
||||
public DmNormalizeRule getByIdAndTenant(Long id, String tenantId) {
|
||||
return dmNormalizeRuleMapper.selectByIdAndTenant(id, tenantId);
|
||||
}
|
||||
/**
|
||||
* 根据ID更新规则
|
||||
*/
|
||||
public boolean updateById(DmNormalizeRule rule) {
|
||||
// 设置更新时间
|
||||
rule.setUpdatedAt(java.time.LocalDateTime.now());
|
||||
rule.setUpdateTime(java.time.LocalDateTime.now());
|
||||
int result = dmNormalizeRuleMapper.updateById(rule);
|
||||
return result > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID和租户更新规则
|
||||
*/
|
||||
public boolean updateByIdAndTenant(DmNormalizeRule rule) {
|
||||
// 设置更新时间
|
||||
rule.setUpdatedAt(java.time.LocalDateTime.now());
|
||||
rule.setUpdateTime(java.time.LocalDateTime.now());
|
||||
int result = dmNormalizeRuleMapper.updateByIdAndTenant(rule);
|
||||
return result > 0;
|
||||
}
|
||||
/**
|
||||
* 根据device ID 获取normal rule 信息
|
||||
*/
|
||||
@Cacheable(key = "'deviceId:' + #id")
|
||||
public List<Map<String, Object>> selectByDeviceId( Long id)
|
||||
{
|
||||
try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) {
|
||||
dmNormalizeRuleMapper = sqlSession.getMapper(DmNormalizeRuleMapper.class);
|
||||
|
||||
List<Map<String, Object>> ruleMap=dmNormalizeRuleMapper.selectByDeviceId(id);
|
||||
sqlSession.commit();
|
||||
return ruleMap;
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("DmNormalizeRuleService MyBatisUtil getSqlSession 异常", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据device ID 获取关联的Normalize Rule 信息
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Cacheable(key = "'deviceId:' + #id")
|
||||
public List<Map<String, Object>> selectByDeviceIdAuto( Long id)
|
||||
{
|
||||
System.out.println("调用selectByDeviceIdAuto 方法,id:"+id);
|
||||
List<Map<String, Object>> ruleMap=dmNormalizeRuleMapper.selectByDeviceId(id);
|
||||
return ruleMap;
|
||||
}
|
||||
|
||||
}
|
||||
+165
@@ -0,0 +1,165 @@
|
||||
package com.common.service;
|
||||
|
||||
|
||||
|
||||
import com.common.entity.AppLog;
|
||||
import com.common.service.AppLogRepository;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
|
||||
import org.springframework.data.elasticsearch.core.IndexOperations;
|
||||
import org.springframework.data.elasticsearch.core.document.Document;
|
||||
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.Collections;
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ElasticsearchService {
|
||||
|
||||
@Autowired
|
||||
private AppLogRepository appLogRepository;
|
||||
|
||||
@Autowired
|
||||
private ElasticsearchRestTemplate elasticsearchRestTemplate;
|
||||
|
||||
private static final DateTimeFormatter INDEX_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||
|
||||
/**
|
||||
* 保存日志到ES
|
||||
*/
|
||||
public void saveAppLog(AppLog appLog) {
|
||||
try {
|
||||
// 设置索引名为当天的日期
|
||||
String indexName = "applog-" + LocalDate.now().format(INDEX_FORMATTER);
|
||||
appLog.setIndex(indexName);
|
||||
|
||||
// 检查索引是否存在,不存在则创建
|
||||
IndexOperations indexOps = elasticsearchRestTemplate.indexOps(IndexCoordinates.of(indexName));
|
||||
if (!indexOps.exists()) {
|
||||
indexOps.create();
|
||||
Document mapping = indexOps.createMapping(AppLog.class);
|
||||
indexOps.putMapping(mapping);
|
||||
log.info("创建ES索引: {}", indexName);
|
||||
}
|
||||
|
||||
// 保存数据
|
||||
appLogRepository.save(appLog);
|
||||
log.info("成功保存日志到ES, ID: {}, Index: {}", appLog.getId(), indexName);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("保存日志到ES失败", e);
|
||||
throw new RuntimeException("保存ES日志失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量保存日志
|
||||
*/
|
||||
public void saveAppLogs(List<AppLog> appLogs) {
|
||||
try {
|
||||
String indexName = "applog-" + LocalDate.now().format(INDEX_FORMATTER);
|
||||
|
||||
// 设置所有日志的索引
|
||||
appLogs.forEach(log -> log.setIndex(indexName));
|
||||
|
||||
// 检查索引是否存在,不存在则创建
|
||||
IndexOperations indexOps = elasticsearchRestTemplate.indexOps(IndexCoordinates.of(indexName));
|
||||
if (!indexOps.exists()) {
|
||||
indexOps.create();
|
||||
Document mapping = indexOps.createMapping(AppLog.class);
|
||||
indexOps.putMapping(mapping);
|
||||
log.info("创建ES索引: {}", indexName);
|
||||
}
|
||||
|
||||
appLogRepository.saveAll(appLogs);
|
||||
log.info("批量保存 {} 条日志到ES索引: {}", appLogs.size(), indexName);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("批量保存日志到ES失败", e);
|
||||
throw new RuntimeException("批量保存ES日志失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据日期获取索引中的日志
|
||||
*/
|
||||
public List<AppLog> getLogsByDate(LocalDate date) {
|
||||
String indexName = "applog-" + date.format(INDEX_FORMATTER);
|
||||
IndexCoordinates indexCoordinates = IndexCoordinates.of(indexName);
|
||||
|
||||
try {
|
||||
// 检查索引是否存在
|
||||
IndexOperations indexOps = elasticsearchRestTemplate.indexOps(indexCoordinates);
|
||||
if (!indexOps.exists()) {
|
||||
log.info("索引 {} 不存在", indexName);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// 使用ElasticsearchRestTemplate查询指定索引
|
||||
return elasticsearchRestTemplate.search(
|
||||
org.springframework.data.elasticsearch.core.query.Query.findAll(),
|
||||
AppLog.class,
|
||||
indexCoordinates
|
||||
).get().map(result -> {
|
||||
AppLog appLog = result.getContent();
|
||||
appLog.setIndex(indexName); // 设置索引名称
|
||||
appLog.setScore(result.getScore()); // 设置评分
|
||||
return appLog;
|
||||
}).collect(Collectors.toList());
|
||||
} catch (Exception e) {
|
||||
log.warn("查询ES索引 {} 失败", indexName, e);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID检查日志是否存在
|
||||
*/
|
||||
public boolean existsById(String id, LocalDate date) {
|
||||
String indexName = "applog-" + date.format(INDEX_FORMATTER);
|
||||
IndexCoordinates indexCoordinates = IndexCoordinates.of(indexName);
|
||||
|
||||
try {
|
||||
//return elasticsearchRestTemplate.exists(id, AppLog.class, indexCoordinates);
|
||||
return elasticsearchRestTemplate.exists(id, indexCoordinates);
|
||||
} catch (Exception e) {
|
||||
log.warn("检查日志存在性失败, ID: {}, Index: {}", id, indexName);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据索引名称获取日志
|
||||
*/
|
||||
public List<AppLog> getLogsByIndex(String indexName) {
|
||||
IndexCoordinates indexCoordinates = IndexCoordinates.of(indexName);
|
||||
|
||||
try {
|
||||
// 检查索引是否存在
|
||||
IndexOperations indexOps = elasticsearchRestTemplate.indexOps(indexCoordinates);
|
||||
if (!indexOps.exists()) {
|
||||
log.info("索引 {} 不存在", indexName);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return elasticsearchRestTemplate.search(
|
||||
org.springframework.data.elasticsearch.core.query.Query.findAll(),
|
||||
AppLog.class,
|
||||
indexCoordinates
|
||||
).get().map(result -> {
|
||||
AppLog appLog = result.getContent();
|
||||
appLog.setIndex(indexName);
|
||||
appLog.setScore(result.getScore());
|
||||
return appLog;
|
||||
}).collect(Collectors.toList());
|
||||
} catch (Exception e) {
|
||||
log.warn("查询ES索引 {} 失败", indexName, e);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
package com.common.service;
|
||||
|
||||
import com.common.entity.AppLog;
|
||||
import com.common.entity.AppLogEntity;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class EsToDbSyncService {
|
||||
|
||||
@Autowired
|
||||
private ElasticsearchService elasticsearchService;
|
||||
|
||||
@Autowired
|
||||
private ApplogService ApplogService;
|
||||
|
||||
/**
|
||||
* 同步指定日期的ES日志到数据库
|
||||
*/
|
||||
public void syncEsLogsToDatabase(LocalDate date) {
|
||||
log.info("开始同步ES日志到数据库,日期: {}", date);
|
||||
|
||||
try {
|
||||
// 从ES获取指定日期的日志
|
||||
List<AppLog> esLogs = elasticsearchService.getLogsByDate(date);
|
||||
|
||||
if (esLogs.isEmpty()) {
|
||||
log.info("ES中未找到 {} 的日志数据", date);
|
||||
return;
|
||||
}
|
||||
|
||||
log.info("从ES索引 applog-{} 获取到 {} 条日志",
|
||||
date.format(java.time.format.DateTimeFormatter.ofPattern("yyyyMMdd")),
|
||||
esLogs.size());
|
||||
|
||||
// 转换为数据库实体
|
||||
List<AppLogEntity> dbLogs = esLogs.stream()
|
||||
.map(this::convertToEntity)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 批量保存到数据库(自动去重)
|
||||
int savedCount = ApplogService.batchSaveAppLogsWithDeduplication(dbLogs);
|
||||
|
||||
log.info("同步完成,成功保存 {} 条日志到数据库", savedCount);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("同步ES日志到数据库失败,日期: {}", date, e);
|
||||
throw new RuntimeException("同步失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步指定索引的ES日志到数据库
|
||||
*/
|
||||
public void syncEsLogsByIndexToDatabase(String indexName) {
|
||||
log.info("开始同步ES索引 {} 的日志到数据库", indexName);
|
||||
|
||||
try {
|
||||
// 从ES获取指定索引的日志
|
||||
List<AppLog> esLogs = elasticsearchService.getLogsByIndex(indexName);
|
||||
|
||||
if (esLogs.isEmpty()) {
|
||||
log.info("ES索引 {} 中未找到日志数据", indexName);
|
||||
return;
|
||||
}
|
||||
|
||||
log.info("从ES索引 {} 获取到 {} 条日志", indexName, esLogs.size());
|
||||
|
||||
// 转换为数据库实体
|
||||
List<AppLogEntity> dbLogs = esLogs.stream()
|
||||
.map(this::convertToEntity)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 批量保存到数据库(自动去重)
|
||||
int savedCount = ApplogService.batchSaveAppLogsWithDeduplication(dbLogs);
|
||||
|
||||
log.info("同步完成,成功保存 {} 条日志到数据库", savedCount);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("同步ES索引 {} 的日志到数据库失败", indexName, e);
|
||||
throw new RuntimeException("同步失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将ES实体转换为数据库实体
|
||||
*/
|
||||
private AppLogEntity convertToEntity(AppLog esLog) {
|
||||
AppLogEntity entity = new AppLogEntity();
|
||||
|
||||
// 复制ES元数据字段
|
||||
entity.setEsId(esLog.getId());
|
||||
entity.setEsIndex(esLog.getIndex());
|
||||
entity.setEsType(esLog.getType());
|
||||
entity.setEsScore(esLog.getScore());
|
||||
|
||||
// 复制日志内容字段
|
||||
entity.setDtTime(esLog.getDtTime());
|
||||
entity.setCollectTime(esLog.getCollectTime());
|
||||
entity.setLogType(esLog.getLogType());
|
||||
entity.setTraceId(esLog.getTraceId());
|
||||
entity.setMethod(esLog.getMethod());
|
||||
entity.setAppName(esLog.getAppName());
|
||||
entity.setIp(esLog.getIp());
|
||||
entity.setClassName(esLog.getClassName());
|
||||
entity.setEnv(esLog.getEnv());
|
||||
entity.setContent(esLog.getContent());
|
||||
entity.setThreadName(esLog.getThreadName());
|
||||
entity.setLogLevel(esLog.getLogLevel());
|
||||
entity.setSeq(esLog.getSeq());
|
||||
entity.setIndexedAt(esLog.getIndexedAt());
|
||||
|
||||
// 转换时间字段
|
||||
if (esLog.getDtTime() != null) {
|
||||
entity.setLogDate(Instant.ofEpochMilli(esLog.getDtTime())
|
||||
.atZone(ZoneId.systemDefault())
|
||||
.toLocalDateTime());
|
||||
}
|
||||
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
+212
@@ -0,0 +1,212 @@
|
||||
package com.common.service;
|
||||
|
||||
import com.influx.InfluxDBClient;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ArrayList;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class InfluxSyslogService {
|
||||
|
||||
//@Autowired
|
||||
//private InfluxDBClient influxDBClient;
|
||||
// 初始化 InfluxDB 客户端
|
||||
//@Autowired
|
||||
private final com.influx.InfluxDBClient influxDBClient = new InfluxDBClient();
|
||||
|
||||
private static final DateTimeFormatter TABLE_DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||
private static final DateTimeFormatter INPUT_DATE_FORMATTER = DateTimeFormatter.ISO_DATE_TIME;
|
||||
|
||||
/**
|
||||
* 接口1:按时间范围查询(最长一天)
|
||||
*/
|
||||
public List<Map<String, Object>> queryByTimeRange(String startTime, String endTime) {
|
||||
try {
|
||||
Instant start = parseInstant(startTime);
|
||||
Instant end = parseInstant(endTime);
|
||||
|
||||
validateTimeRange(start, end);
|
||||
|
||||
// 生成需要查询的表名(处理跨天情况)
|
||||
List<String> measurementNames = generateMeasurementNames(start, end);
|
||||
List<Map<String, Object>> allResults = new ArrayList<>();
|
||||
|
||||
for (String measurement : measurementNames) {
|
||||
List<Map<String, Object>> results = influxDBClient.queryByTimeRange(measurement, start, end);
|
||||
allResults.addAll(results);
|
||||
}
|
||||
|
||||
log.info("按时间范围查询成功,查询表: {}, 返回记录数: {}", measurementNames, allResults.size());
|
||||
return allResults;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("按时间范围查询失败: {}", e.getMessage());
|
||||
throw new RuntimeException("查询失败: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 接口2:按UUID查询详细日志
|
||||
*/
|
||||
public List<Map<String, Object>> queryByUuid(String uuid) {
|
||||
try {
|
||||
// 从UUID中提取日期部分
|
||||
String datePart = extractDateFromUuid(uuid);
|
||||
String measurement = "syslog_security_" + datePart;
|
||||
|
||||
List<Map<String, Object>> results = influxDBClient.queryByUuid(measurement, uuid);
|
||||
|
||||
log.info("按UUID查询成功,表: {}, UUID: {}, 返回记录数: {}", measurement, uuid, results.size());
|
||||
return results;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("按UUID查询失败: {}", e.getMessage());
|
||||
throw new RuntimeException("查询失败: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 接口3:按设备ID和时间范围查询
|
||||
*/
|
||||
public List<Map<String, Object>> queryByDeviceIdAndTime(String deviceId, String startTime, String endTime) {
|
||||
try {
|
||||
Instant start = parseInstant(startTime);
|
||||
Instant end = parseInstant(endTime);
|
||||
|
||||
validateTimeRange(start, end);
|
||||
|
||||
List<String> measurementNames = generateMeasurementNames(start, end);
|
||||
List<Map<String, Object>> allResults = new ArrayList<>();
|
||||
|
||||
for (String measurement : measurementNames) {
|
||||
List<Map<String, Object>> results = influxDBClient.queryByDeviceIdAndTime(measurement, deviceId, start, end);
|
||||
allResults.addAll(results);
|
||||
}
|
||||
|
||||
log.info("按设备ID查询成功,设备: {}, 返回记录数: {}", deviceId, allResults.size());
|
||||
return allResults;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("按设备ID查询失败: {}", e.getMessage());
|
||||
throw new RuntimeException("查询失败: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 接口4:模糊查询message内容
|
||||
*/
|
||||
public List<Map<String, Object>> queryByMessageContent(String startTime, String endTime, String keyword) {
|
||||
try {
|
||||
Instant start = parseInstant(startTime);
|
||||
Instant end = parseInstant(endTime);
|
||||
|
||||
validateTimeRange(start, end);
|
||||
validateKeyword(keyword);
|
||||
|
||||
List<String> measurementNames = generateMeasurementNames(start, end);
|
||||
List<Map<String, Object>> allResults = new ArrayList<>();
|
||||
|
||||
for (String measurement : measurementNames) {
|
||||
List<Map<String, Object>> results = influxDBClient.queryByMessageContent(measurement, start, end, keyword);
|
||||
allResults.addAll(results);
|
||||
}
|
||||
|
||||
log.info("模糊查询成功,关键字: {}, 返回记录数: {}", keyword, allResults.size());
|
||||
return allResults;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("模糊查询失败: {}", e.getMessage());
|
||||
throw new RuntimeException("查询失败: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
public Map<String, List<Map<String, Object>>> queryByUuids(List<String> uuids) {
|
||||
if (CollectionUtils.isEmpty(uuids)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
Map<String, List<Map<String, Object>>> resultMap = new HashMap<>();
|
||||
for (String uuid : uuids) {
|
||||
// 查询单个UUID的日志
|
||||
List<Map<String, Object>> logList = queryByUuid(uuid);
|
||||
resultMap.put(uuid, logList);
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
/**
|
||||
* 从UUID中提取日期部分
|
||||
*/
|
||||
private String extractDateFromUuid(String uuid) {
|
||||
if (uuid == null || uuid.length() < 8) {
|
||||
throw new IllegalArgumentException("UUID格式不正确,无法提取日期");
|
||||
}
|
||||
return uuid.substring(0, 8);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析时间字符串为Instant
|
||||
*/
|
||||
private Instant parseInstant(String timeString) {
|
||||
try {
|
||||
return Instant.parse(timeString);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException("时间格式不正确,请使用ISO格式,例如: 2023-11-20T00:00:00Z");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证时间范围(最长一天)
|
||||
*/
|
||||
private void validateTimeRange(Instant start, Instant end) {
|
||||
long hours = ChronoUnit.HOURS.between(start, end);
|
||||
if (hours > 24) {
|
||||
throw new IllegalArgumentException("查询时间范围不能超过24小时");
|
||||
}
|
||||
if (start.isAfter(end)) {
|
||||
throw new IllegalArgumentException("开始时间不能晚于结束时间");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证搜索关键字
|
||||
*/
|
||||
private void validateKeyword(String keyword) {
|
||||
if (keyword == null || keyword.trim().isEmpty()) {
|
||||
throw new IllegalArgumentException("搜索关键字不能为空");
|
||||
}
|
||||
if (keyword.length() > 32) {
|
||||
throw new IllegalArgumentException("搜索关键字长度不能超过32个字符");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成需要查询的表名列表(处理跨天情况)
|
||||
*/
|
||||
private List<String> generateMeasurementNames(Instant start, Instant end) {
|
||||
List<String> measurements = new ArrayList<>();
|
||||
|
||||
LocalDateTime startDate = LocalDateTime.ofInstant(start, ZoneId.of("UTC"));
|
||||
LocalDateTime endDate = LocalDateTime.ofInstant(end, ZoneId.of("UTC"));
|
||||
|
||||
LocalDateTime currentDate = startDate;
|
||||
while (!currentDate.toLocalDate().isAfter(endDate.toLocalDate())) {
|
||||
String dateStr = currentDate.format(TABLE_DATE_FORMATTER);
|
||||
measurements.add("syslog_security_" + dateStr);
|
||||
currentDate = currentDate.plusDays(1);
|
||||
}
|
||||
|
||||
return measurements;
|
||||
}
|
||||
}
|
||||
+258
@@ -0,0 +1,258 @@
|
||||
package com.common.service;
|
||||
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class LogDataCompleteService {
|
||||
|
||||
|
||||
/**
|
||||
* 处理日志数据补全
|
||||
*/
|
||||
public boolean processDataCompletion(String ruleContent,Map<String, Object> destMap) {
|
||||
try {
|
||||
boolean hasCompleted = false;
|
||||
if (executeCompleteRule(ruleContent, destMap)) {
|
||||
hasCompleted = true;
|
||||
}
|
||||
if (hasCompleted) {
|
||||
log.debug("数据补全完成: {}", destMap.get("id"));
|
||||
} else {
|
||||
log.debug("数据无需补全: {}", destMap.get("id"));
|
||||
}
|
||||
return hasCompleted;
|
||||
} catch (Exception e) {
|
||||
log.error("处理数据补全时发生错误: {}", e.getMessage(), e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行补全规则
|
||||
*/
|
||||
private boolean executeCompleteRule(String ruleContent, Map<String, Object> destMap) {
|
||||
try {
|
||||
JSONObject ruleJson = JSON.parseObject(ruleContent);
|
||||
JSONArray completeColumns = ruleJson.getJSONArray("complete_columns");
|
||||
|
||||
if (completeColumns == null || completeColumns.isEmpty()) {
|
||||
log.warn("补全规则为空");
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean hasCompleted = false;
|
||||
|
||||
// 遍历所有补全配置
|
||||
for (int i = 0; i < completeColumns.size(); i++) {
|
||||
JSONObject completeConfig = completeColumns.getJSONObject(i);
|
||||
if (executeCompleteConfig(completeConfig, destMap)) {
|
||||
hasCompleted = true;
|
||||
}
|
||||
}
|
||||
|
||||
return hasCompleted;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("解析补全规则失败: {}", e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行单个补全配置
|
||||
*/
|
||||
private boolean executeCompleteConfig(JSONObject completeConfig, Map<String, Object> destMap) {
|
||||
try {
|
||||
String columnName = completeConfig.getString("column_name");
|
||||
Object value = completeConfig.get("value");
|
||||
JSONArray conditions = completeConfig.getJSONArray("conditions");
|
||||
String relation = completeConfig.getString("filters_relation");
|
||||
|
||||
// 检查目标字段是否已存在
|
||||
if (destMap.containsKey(columnName) && destMap.get(columnName) != null) {
|
||||
log.debug("字段 {} 已存在,跳过补全", columnName);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 检查条件是否满足
|
||||
boolean conditionsMet = evaluateConditions(conditions, relation, destMap);
|
||||
|
||||
if (conditionsMet) {
|
||||
// 执行补全操作
|
||||
destMap.put(columnName, value);
|
||||
log.debug("字段 {} 补全完成,值: {}", columnName, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("执行补全配置失败: {}", e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 评估条件
|
||||
*/
|
||||
private boolean evaluateConditions(JSONArray conditions, String relation, Map<String, Object> destMap) {
|
||||
if (conditions == null || conditions.isEmpty()) {
|
||||
return true; // 无条件,直接通过
|
||||
}
|
||||
|
||||
// 根据关系类型评估
|
||||
if ("or".equalsIgnoreCase(relation)) {
|
||||
return evaluateOrConditions(conditions, destMap);
|
||||
} else {
|
||||
// 默认使用 AND 关系
|
||||
return evaluateAndConditions(conditions, destMap);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 评估 AND 关系的条件
|
||||
*/
|
||||
private boolean evaluateAndConditions(JSONArray conditions, Map<String, Object> destMap) {
|
||||
for (int i = 0; i < conditions.size(); i++) {
|
||||
JSONObject condition = conditions.getJSONObject(i);
|
||||
if (!evaluateCondition(condition, destMap)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 评估 OR 关系的条件
|
||||
*/
|
||||
private boolean evaluateOrConditions(JSONArray conditions, Map<String, Object> destMap) {
|
||||
for (int i = 0; i < conditions.size(); i++) {
|
||||
JSONObject condition = conditions.getJSONObject(i);
|
||||
if (evaluateCondition(condition, destMap)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 评估单个条件
|
||||
*/
|
||||
private boolean evaluateCondition(JSONObject condition, Map<String, Object> destMap) {
|
||||
String columnName = condition.getString("column_name");
|
||||
String op = condition.getString("op");
|
||||
Object value = condition.get("value");
|
||||
|
||||
// 从目标Map中获取字段值
|
||||
Object fieldValue = destMap.get(columnName);
|
||||
if (fieldValue == null) {
|
||||
fieldValue = ""; // 处理null值
|
||||
}
|
||||
|
||||
String fieldValueStr = fieldValue.toString();
|
||||
|
||||
try {
|
||||
switch (op) {
|
||||
case "=":
|
||||
return equals(fieldValueStr, value);
|
||||
case "!=":
|
||||
return notEquals(fieldValueStr, value);
|
||||
case "in":
|
||||
return in(fieldValueStr, value);
|
||||
case "zero_len":
|
||||
return zeroLen(fieldValueStr, value);
|
||||
case "contain":
|
||||
return contain(fieldValueStr, value);
|
||||
case "regexp":
|
||||
return regexp(fieldValueStr, value);
|
||||
default:
|
||||
log.warn("未知的操作符: {}", op);
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("评估条件失败: {}{}{}, 错误: {}", columnName, op, value, e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 等于操作
|
||||
*/
|
||||
private boolean equals(String fieldValue, Object value) {
|
||||
if (value == null) return false;
|
||||
return fieldValue.equals(value.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 不等于操作
|
||||
*/
|
||||
private boolean notEquals(String fieldValue, Object value) {
|
||||
if (value == null) return true;
|
||||
return !fieldValue.equals(value.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* IN 操作
|
||||
*/
|
||||
private boolean in(String fieldValue, Object value) {
|
||||
if (value instanceof JSONArray) {
|
||||
JSONArray array = (JSONArray) value;
|
||||
for (Object item : array) {
|
||||
if (fieldValue.equals(item.toString())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 非空检查操作
|
||||
*/
|
||||
private boolean zeroLen(String fieldValue, Object value) {
|
||||
boolean isEmpty = !StringUtils.hasText(fieldValue);
|
||||
boolean expected = Boolean.parseBoolean(value.toString());
|
||||
return isEmpty == expected;
|
||||
}
|
||||
|
||||
/**
|
||||
* 包含操作
|
||||
*/
|
||||
private boolean contain(String fieldValue, Object value) {
|
||||
if (value == null) return false;
|
||||
return fieldValue.contains(value.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 正则表达式匹配
|
||||
*/
|
||||
private boolean regexp(String fieldValue, Object value) {
|
||||
if (value == null) return false;
|
||||
try {
|
||||
Pattern pattern = Pattern.compile(value.toString());
|
||||
return pattern.matcher(fieldValue).matches();
|
||||
} catch (Exception e) {
|
||||
log.error("正则表达式编译失败: {}, 错误: {}", value, e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+204
@@ -0,0 +1,204 @@
|
||||
package com.common.service;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.common.mapper.SyslogNormalDataMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class LogDataFilterService {
|
||||
|
||||
/**
|
||||
* 评估过滤规则
|
||||
*/
|
||||
public boolean evaluateFilterRule(String ruleContent, Map<String, Object> destMap) {
|
||||
try {
|
||||
JSONObject ruleJson = JSON.parseObject(ruleContent);
|
||||
if (ruleJson.containsKey("filters_params") ) {
|
||||
JSONObject filtersParamsObj = ruleJson.getJSONObject("filters_params");
|
||||
JSONArray filtersParams = filtersParamsObj.getJSONArray("expressions");
|
||||
|
||||
if (filtersParams == null || filtersParams.isEmpty()) {
|
||||
log.warn("泛化规则-数据过滤规则为空,默认不处理!");
|
||||
return false;
|
||||
}
|
||||
// 遍历所有过滤组,只要满足任一过滤组即可
|
||||
for (int i = 0; i < filtersParams.size(); i++) {
|
||||
JSONObject filterGroup = filtersParams.getJSONObject(i);
|
||||
if (evaluateFilterGroup(filterGroup, destMap)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("解析过滤规则失败或filters_params为空: {}", e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 评估过滤组
|
||||
*/
|
||||
private boolean evaluateFilterGroup(JSONObject filterGroup, Map<String, Object> destMap) {
|
||||
try {
|
||||
//JSONObject expressions_obj = filterGroup.getJSONObject("expressions");
|
||||
JSONArray expressions = filterGroup.getJSONArray("expressions");
|
||||
String relation = filterGroup.getString("filters_relation");
|
||||
|
||||
if (expressions == null || expressions.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 根据关系类型评估
|
||||
if ("or".equalsIgnoreCase(relation)) {
|
||||
return evaluateOrExpressions(expressions, destMap);
|
||||
} else {
|
||||
// 默认使用 AND 关系
|
||||
return evaluateAndExpressions(expressions, destMap);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("评估过滤组evaluateFilterGroup解析json失败: {}", e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 评估 AND 关系的表达式
|
||||
*/
|
||||
private boolean evaluateAndExpressions(JSONArray expressions, Map<String, Object> destMap) {
|
||||
for (int i = 0; i < expressions.size(); i++) {
|
||||
JSONObject expression = expressions.getJSONObject(i);
|
||||
if (!evaluateExpression(expression, destMap)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 评估 OR 关系的表达式
|
||||
*/
|
||||
private boolean evaluateOrExpressions(JSONArray expressions, Map<String, Object> destMap) {
|
||||
for (int i = 0; i < expressions.size(); i++) {
|
||||
JSONObject expression = expressions.getJSONObject(i);
|
||||
if (evaluateExpression(expression, destMap)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 评估单个表达式
|
||||
*/
|
||||
private boolean evaluateExpression(JSONObject expression, Map<String, Object> destMap) {
|
||||
String columnName = expression.getString("column_name");
|
||||
String op = expression.getString("op");
|
||||
Object value = expression.get("value");
|
||||
|
||||
// 从目标Map中获取字段值
|
||||
Object fieldValue = destMap.get(columnName);
|
||||
if (fieldValue == null) {
|
||||
fieldValue = ""; // 处理null值
|
||||
}
|
||||
|
||||
String fieldValueStr = fieldValue.toString();
|
||||
|
||||
try {
|
||||
switch (op) {
|
||||
case "=":
|
||||
return equals(fieldValueStr, value);
|
||||
case "!=":
|
||||
return notEquals(fieldValueStr, value);
|
||||
case "in":
|
||||
return in(fieldValueStr, value);
|
||||
case "zero_len":
|
||||
return zeroLen(fieldValueStr, value);
|
||||
case "contain":
|
||||
return contain(fieldValueStr, value);
|
||||
case "regexp":
|
||||
return regexp(fieldValueStr, value);
|
||||
default:
|
||||
log.warn("未知的操作符: {}", op);
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("评估表达式失败: {}{}{}, 错误: {}", columnName, op, value, e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 等于操作
|
||||
*/
|
||||
private boolean equals(String fieldValue, Object value) {
|
||||
return fieldValue.equals(value.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 不等于操作
|
||||
*/
|
||||
private boolean notEquals(String fieldValue, Object value) {
|
||||
return !fieldValue.equals(value.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* IN 操作
|
||||
*/
|
||||
private boolean in(String fieldValue, Object value) {
|
||||
if (value instanceof JSONArray) {
|
||||
JSONArray array = (JSONArray) value;
|
||||
for (Object item : array) {
|
||||
if (fieldValue.equals(item.toString())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 长度检查操作
|
||||
*/
|
||||
private boolean zeroLen(String fieldValue, Object value) {
|
||||
boolean isEmpty = !StringUtils.hasText(fieldValue);
|
||||
boolean expected = Boolean.parseBoolean(value.toString());
|
||||
return isEmpty == expected;
|
||||
}
|
||||
|
||||
/**
|
||||
* 包含操作
|
||||
*/
|
||||
private boolean contain(String fieldValue, Object value) {
|
||||
return fieldValue.contains(value.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 正则表达式匹配
|
||||
*/
|
||||
private boolean regexp(String fieldValue, Object value) {
|
||||
try {
|
||||
Pattern pattern = Pattern.compile(value.toString());
|
||||
return pattern.matcher(fieldValue).matches();
|
||||
} catch (Exception e) {
|
||||
log.error("正则表达式编译失败: {}, 错误: {}", value, e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+248
@@ -0,0 +1,248 @@
|
||||
package com.common.service;
|
||||
|
||||
import com.common.entity.RuleHitTimeDTO;
|
||||
import com.common.mapper.NormalizeRuleStatsMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class NormalizeRuleHitTimeService {
|
||||
|
||||
@Autowired
|
||||
private NormalizeRuleStatsMapper normalizeRuleStatsMapper;
|
||||
|
||||
// 用于缓存最新的命中时间,避免重复查询
|
||||
private final Map<Long, LocalDateTime> ruleLatestHitCache = new ConcurrentHashMap<>();
|
||||
|
||||
// 记录上次执行时间
|
||||
private LocalDateTime lastExecutionTime;
|
||||
|
||||
|
||||
public void updateRuleHitTimeTask() {
|
||||
long startTime = System.currentTimeMillis();
|
||||
log.info("开始执行泛化规则命中时间更新任务,时间:{}", LocalDateTime.now());
|
||||
|
||||
try {
|
||||
// 执行更新逻辑
|
||||
int updatedCount = updateNormalizeRuleHitTime();
|
||||
|
||||
long endTime = System.currentTimeMillis();
|
||||
log.info("泛化规则命中时间更新任务完成,更新规则数:{},耗时:{}ms",
|
||||
updatedCount, (endTime - startTime));
|
||||
|
||||
// 更新上次执行时间
|
||||
lastExecutionTime = LocalDateTime.now();
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("泛化规则命中时间更新任务执行失败", e);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新泛化规则命中时间
|
||||
* @return 更新的规则数量
|
||||
*/
|
||||
public int updateNormalizeRuleHitTime() {
|
||||
// 1. 获取当天开始时间(用于过滤当天数据)
|
||||
LocalDateTime todayStart = LocalDateTime.of(LocalDate.now(), LocalTime.MIN);
|
||||
|
||||
// 2. 从两个标准化表中统计最新命中时间
|
||||
List<RuleHitTimeDTO> normalDataStats = normalizeRuleStatsMapper
|
||||
.selectMaxHitTimeFromNormalData(todayStart);
|
||||
List<RuleHitTimeDTO> alarmDataStats = normalizeRuleStatsMapper
|
||||
.selectMaxHitTimeFromNormalAlarm(todayStart);
|
||||
|
||||
log.info("从 syslog_normal_data 表统计到 {} 条规则命中记录",
|
||||
normalDataStats.size());
|
||||
log.info("从 syslog_normal_alarm 表统计到 {} 条规则命中记录",
|
||||
alarmDataStats.size());
|
||||
|
||||
// 3. 合并两个统计结果,取每个规则的最新命中时间
|
||||
Map<Long, LocalDateTime> ruleMaxHitTimeMap = mergeRuleHitTimes(
|
||||
normalDataStats, alarmDataStats
|
||||
);
|
||||
|
||||
// 4. 获取所有启用状态的规则ID
|
||||
List<Long> activeRuleIds = normalizeRuleStatsMapper.selectActiveRuleIds();
|
||||
log.info("当前启用状态的规则数量:{}", activeRuleIds.size());
|
||||
|
||||
// 5. 批量更新规则的最新命中时间
|
||||
int updatedCount = batchUpdateRuleHitTime(activeRuleIds, ruleMaxHitTimeMap);
|
||||
|
||||
// 6. 更新缓存
|
||||
updateRuleHitCache(ruleMaxHitTimeMap);
|
||||
|
||||
return updatedCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 合并两个表的统计结果,取每个规则的最新命中时间
|
||||
*/
|
||||
private Map<Long, LocalDateTime> mergeRuleHitTimes(
|
||||
List<RuleHitTimeDTO> normalDataStats,
|
||||
List<RuleHitTimeDTO> alarmDataStats
|
||||
) {
|
||||
Map<Long, LocalDateTime> resultMap = new HashMap<>();
|
||||
|
||||
// 处理 syslog_normal_data 表统计结果
|
||||
if (!CollectionUtils.isEmpty(normalDataStats)) {
|
||||
for (RuleHitTimeDTO dto : normalDataStats) {
|
||||
if (dto.getNormalizeRuleId() != null && dto.getMaxLogTime() != null) {
|
||||
LocalDateTime currentMax = resultMap.get(dto.getNormalizeRuleId());
|
||||
if (currentMax == null || dto.getMaxLogTime().isAfter(currentMax)) {
|
||||
resultMap.put(dto.getNormalizeRuleId(), dto.getMaxLogTime());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 处理 syslog_normal_alarm 表统计结果
|
||||
if (!CollectionUtils.isEmpty(alarmDataStats)) {
|
||||
for (RuleHitTimeDTO dto : alarmDataStats) {
|
||||
if (dto.getNormalizeRuleId() != null && dto.getMaxLogTime() != null) {
|
||||
LocalDateTime currentMax = resultMap.get(dto.getNormalizeRuleId());
|
||||
if (currentMax == null || dto.getMaxLogTime().isAfter(currentMax)) {
|
||||
resultMap.put(dto.getNormalizeRuleId(), dto.getMaxLogTime());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.info("合并后需要更新的规则数量:{}", resultMap.size());
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量更新规则命中时间
|
||||
*/
|
||||
private int batchUpdateRuleHitTime(
|
||||
List<Long> activeRuleIds,
|
||||
Map<Long, LocalDateTime> ruleMaxHitTimeMap
|
||||
) {
|
||||
if (CollectionUtils.isEmpty(activeRuleIds)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int updatedCount = 0;
|
||||
int batchSize = 1000; // 每批处理1000条
|
||||
int totalBatches = (activeRuleIds.size() + batchSize - 1) / batchSize;
|
||||
|
||||
log.info("开始批量更新,规则总数:{},分批数:{}", activeRuleIds.size(), totalBatches);
|
||||
|
||||
for (int i = 0; i < totalBatches; i++) {
|
||||
int fromIndex = i * batchSize;
|
||||
int toIndex = Math.min(fromIndex + batchSize, activeRuleIds.size());
|
||||
List<Long> batchRuleIds = activeRuleIds.subList(fromIndex, toIndex);
|
||||
|
||||
// 处理当前批次
|
||||
int batchUpdated = processBatchUpdate(batchRuleIds, ruleMaxHitTimeMap);
|
||||
updatedCount += batchUpdated;
|
||||
|
||||
log.debug("第 {} 批处理完成,更新 {} 条规则", i + 1, batchUpdated);
|
||||
|
||||
// 每处理完一批,稍作停顿,避免数据库压力过大
|
||||
if (i < totalBatches - 1) {
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
log.warn("批量更新任务被中断");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return updatedCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理单个批次的更新
|
||||
*/
|
||||
private int processBatchUpdate(
|
||||
List<Long> batchRuleIds,
|
||||
Map<Long, LocalDateTime> ruleMaxHitTimeMap
|
||||
) {
|
||||
int batchUpdated = 0;
|
||||
|
||||
for (Long ruleId : batchRuleIds) {
|
||||
LocalDateTime maxHitTime = ruleMaxHitTimeMap.get(ruleId);
|
||||
if (maxHitTime != null) {
|
||||
// 检查缓存中是否有更晚的时间
|
||||
LocalDateTime cachedTime = ruleLatestHitCache.get(ruleId);
|
||||
if (cachedTime == null || maxHitTime.isAfter(cachedTime)) {
|
||||
// 执行更新
|
||||
int updated = normalizeRuleStatsMapper.updateRuleHitTime(ruleId, maxHitTime);
|
||||
if (updated > 0) {
|
||||
batchUpdated++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return batchUpdated;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新命中时间缓存
|
||||
*/
|
||||
private void updateRuleHitCache(Map<Long, LocalDateTime> ruleMaxHitTimeMap) {
|
||||
ruleMaxHitTimeMap.forEach((ruleId, hitTime) -> {
|
||||
LocalDateTime cachedTime = ruleLatestHitCache.get(ruleId);
|
||||
if (cachedTime == null || hitTime.isAfter(cachedTime)) {
|
||||
ruleLatestHitCache.put(ruleId, hitTime);
|
||||
}
|
||||
});
|
||||
|
||||
// 清理过期的缓存(超过1天)
|
||||
cleanupExpiredCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理过期缓存
|
||||
*/
|
||||
private void cleanupExpiredCache() {
|
||||
LocalDateTime oneDayAgo = LocalDateTime.now().minusDays(1);
|
||||
Iterator<Map.Entry<Long, LocalDateTime>> iterator = ruleLatestHitCache.entrySet().iterator();
|
||||
|
||||
int removedCount = 0;
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<Long, LocalDateTime> entry = iterator.next();
|
||||
if (entry.getValue().isBefore(oneDayAgo)) {
|
||||
iterator.remove();
|
||||
removedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (removedCount > 0) {
|
||||
log.debug("清理了 {} 条过期缓存记录", removedCount);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取规则最新命中时间(缓存中)
|
||||
*/
|
||||
public LocalDateTime getLatestHitTime(Long ruleId) {
|
||||
return ruleLatestHitCache.get(ruleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动触发更新(可用于测试或紧急更新)
|
||||
*/
|
||||
public int triggerManualUpdate() {
|
||||
log.info("手动触发泛化规则命中时间更新");
|
||||
return updateNormalizeRuleHitTime();
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user