服务器配置管理查询历史报警信息
This commit is contained in:
parent
e594618d50
commit
a9682bf4dc
|
@ -0,0 +1,22 @@
|
|||
package org.jeecg.modules.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class AlarmHistory {
|
||||
|
||||
private String name;
|
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date alarmStartDate;
|
||||
|
||||
private String alarmInfo;
|
||||
|
||||
private String operator;
|
||||
|
||||
}
|
|
@ -1,7 +1,15 @@
|
|||
package org.jeecg.modules.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.jeecg.modules.entity.AlarmHistory;
|
||||
import org.jeecg.modules.entity.SysServer;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface SysServerMapper extends BaseMapper<SysServer> {
|
||||
|
||||
List<AlarmHistory> findAlarmHistory(@Param("serverId")String serverId, @Param("startDate") Date startDate, @Param("endDate") Date endDate);
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.jeecg.modules.mapper.SysServerMapper">
|
||||
|
||||
<select id="findAlarmHistory" resultType="org.jeecg.modules.entity.AlarmHistory">
|
||||
SELECT
|
||||
se.name,
|
||||
l.alarm_start_date,
|
||||
l.alarm_info,
|
||||
r.operator
|
||||
FROM
|
||||
sys_server se
|
||||
inner join alarm_rule r on r.source_id = se.id
|
||||
inner join alarm_log l on l.rule_id = r.id
|
||||
<where>
|
||||
l.alarm_start_date between #{startDate} and #{endDate}
|
||||
<if test=" serverId != null and serverId != '' ">
|
||||
and se.id = #{serverId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -8,7 +8,9 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.jeecg.common.api.QueryRequest;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.util.JwtUtil;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import org.jeecg.modules.entity.AlarmHistory;
|
||||
import org.jeecg.modules.entity.SysServer;
|
||||
import org.jeecg.modules.mapper.SysServerMapper;
|
||||
import org.jeecg.modules.service.ISysServerService;
|
||||
|
@ -16,7 +18,9 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Service("sysServerService")
|
||||
|
@ -108,8 +112,25 @@ public class SysServerServiceImpl extends ServiceImpl<SysServerMapper, SysServer
|
|||
|
||||
@Override
|
||||
public Result findAlarmHistory(String serverId, Date startTime, Date endTime) {
|
||||
|
||||
return null;
|
||||
Result result = new Result();
|
||||
try {
|
||||
if (Objects.isNull(startTime)){
|
||||
result.error500("开始时间不能为空");
|
||||
return result;
|
||||
}
|
||||
if (Objects.isNull(endTime)){
|
||||
result.error500("结束时间不能为空");
|
||||
return result;
|
||||
}
|
||||
Date startDate = DateUtils.parseDate(DateUtils.formatDate(startTime, "yyyy-MM-dd") + " 00:00:00", "yyyy-MM-dd HH:mm:ss");
|
||||
Date endDate = DateUtils.parseDate(DateUtils.formatDate(endTime, "yyyy-MM-dd") + " 23:59:59", "yyyy-MM-dd HH:mm:ss");
|
||||
List<AlarmHistory> alarmHistory = this.baseMapper.findAlarmHistory(serverId, startDate, endDate);
|
||||
result.setSuccess(true);
|
||||
result.setResult(alarmHistory);
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user