1、新增功能探针联动处置、心跳在线检测
2、syslog-consumer模块拆分 syslog-consumer-rule模块实现日志数据消费、解析、泛化入库。
This commit is contained in:
+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();
|
||||
}
|
||||
Reference in New Issue
Block a user