增加取消告警闪烁功能
This commit is contained in:
+10
@@ -159,6 +159,7 @@ public class RmResourceRegistrationController extends BaseController
|
||||
{
|
||||
List<RmResourceRegistration> list = rmResourceRegistrationService.selectRmResourceRegistrationList(new RmResourceRegistration());
|
||||
for (RmResourceRegistration item : list) {
|
||||
|
||||
boolean isAlarm = (item.getCpuUtil() != null && item.getCpuUtil().compareTo(BigDecimal.valueOf(80)) >= 0) ||
|
||||
(item.getMemUtil() != null && item.getMemUtil().compareTo(BigDecimal.valueOf(60)) >= 0);
|
||||
|
||||
@@ -262,5 +263,14 @@ public class RmResourceRegistrationController extends BaseController
|
||||
{
|
||||
return toAjax(rmResourceRegistrationService.addReportedBandwidth(rmResourceRegistration));
|
||||
}
|
||||
/**
|
||||
* 取消闪烁
|
||||
*/
|
||||
@Log(title = "取消闪烁", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/removeAlarmFlag")
|
||||
public AjaxResult removeAlarmFlag(@RequestBody RmResourceRegistration rmResourceRegistration)
|
||||
{
|
||||
return toAjax(rmResourceRegistrationService.removeAlarmFlag(rmResourceRegistration));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
@@ -263,4 +263,7 @@ public class RmResourceRegistration extends BaseEntity
|
||||
private BigDecimal memUtil;
|
||||
/** 是否告警 */
|
||||
private boolean alarmFlag;
|
||||
/** 取消告警时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date delAlarmTime;
|
||||
}
|
||||
+2
@@ -126,4 +126,6 @@ public interface RmResourceRegistrationMapper
|
||||
List<RmResourceRegistration> getCpuUtil(@Param("clientIdsStr") String clientIdsStr);
|
||||
|
||||
List<RmResourceRegistration> getMemUtil(@Param("clientIdsStr") String clientIdsStr);
|
||||
|
||||
int removeAlarmFlag(RmResourceRegistration rmResourceRegistration);
|
||||
}
|
||||
|
||||
+7
@@ -139,4 +139,11 @@ public interface IRmResourceRegistrationService
|
||||
* @return
|
||||
*/
|
||||
int addReportedBandwidth(RmResourceRegistration rmResourceRegistration);
|
||||
|
||||
/**
|
||||
* 取消告警闪烁
|
||||
* @param rmResourceRegistration
|
||||
* @return
|
||||
*/
|
||||
int removeAlarmFlag(RmResourceRegistration rmResourceRegistration);
|
||||
}
|
||||
|
||||
+26
-2
@@ -24,6 +24,8 @@ import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -286,8 +288,21 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
}
|
||||
}
|
||||
private boolean isAlarm(RmResourceRegistration item) {
|
||||
return (item.getCpuUtil() != null && item.getCpuUtil().compareTo(BigDecimal.valueOf(80)) >= 0) ||
|
||||
(item.getMemUtil() != null && item.getMemUtil().compareTo(BigDecimal.valueOf(60)) >= 0);
|
||||
Date delAlarmTime = item.getDelAlarmTime();
|
||||
boolean alarmFlag = true;
|
||||
|
||||
if (delAlarmTime != null) {
|
||||
// 将Date转换为Instant
|
||||
Instant delAlarmInstant = delAlarmTime.toInstant();
|
||||
Instant now = Instant.now();
|
||||
|
||||
// 如果当前时间-delAlarmTime<24小时,设置alarmFlag=false
|
||||
if (Duration.between(delAlarmInstant, now).toHours() < 24) {
|
||||
alarmFlag = false;
|
||||
}
|
||||
}
|
||||
return alarmFlag && ((item.getCpuUtil() != null && item.getCpuUtil().compareTo(BigDecimal.valueOf(80)) >= 0) ||
|
||||
(item.getMemUtil() != null && item.getMemUtil().compareTo(BigDecimal.valueOf(60)) >= 0));
|
||||
}
|
||||
|
||||
private BigDecimal getMaxUtilization(RmResourceRegistration item) {
|
||||
@@ -1232,4 +1247,13 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
return rows;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int removeAlarmFlag(RmResourceRegistration rmResourceRegistration) {
|
||||
if(rmResourceRegistration.getId() == null){
|
||||
throw new RuntimeException("id不可为null");
|
||||
}
|
||||
int rows = rmResourceRegistrationMapper.removeAlarmFlag(rmResourceRegistration);
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+11
-1
@@ -24,10 +24,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="reportedBandwidth" column="reported_bandwidth" />
|
||||
<result property="delAarmTime" column="del_alarm_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectRmResourceRegistrationVo">
|
||||
select id, client_id, hardware_sn, business_name, logical_node_id, multi_public_ip_status, registration_status, online_status, resource_type, agent_version, create_time, update_time, heartbeat_count, heartbeat_interval, onboard_time, remark, create_by, update_by, reported_bandwidth from rm_resource_registration
|
||||
select id, client_id, hardware_sn, business_name, logical_node_id, multi_public_ip_status, registration_status, online_status, resource_type, agent_version, create_time, update_time, heartbeat_count, heartbeat_interval, onboard_time, remark, create_by, update_by, reported_bandwidth, del_alarm_time from rm_resource_registration
|
||||
</sql>
|
||||
|
||||
<select id="selectRmResourceRegistrationList" parameterType="RmResourceRegistration" resultMap="RmResourceRegistrationResult">
|
||||
@@ -67,6 +68,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
a.onboard_time as onboardTime,
|
||||
a.remark as remark,
|
||||
a.reported_bandwidth as reportedBandwidth,
|
||||
a.del_alarm_time as delAlarmTime,
|
||||
b.machine_code as machineCode,
|
||||
(select bandwidth_result from eps_node_bandwidth
|
||||
where client_id=a.client_id and calculation_mode='1000' and bandwidth_type=1
|
||||
@@ -97,6 +99,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="reportedBandwidth != null">reported_bandwidth,</if>
|
||||
<if test="delAlarmTime != null">del_alarm_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="clientId != null">#{clientId},</if>
|
||||
@@ -117,6 +120,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="reportedBandwidth != null">#{reportedBandwidth},</if>
|
||||
<if test="delAlarmTime != null">#{delAlarmTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@@ -141,6 +145,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="reportedBandwidth != null">reported_bandwidth = #{reportedBandwidth},</if>
|
||||
<if test="delAlarmTime != null">del_alarm_time = #{delAlarmTime},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
@@ -232,6 +237,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
a.onboard_time as onboardTime,
|
||||
a.remark as remark,
|
||||
a.reported_bandwidth as reportedBandwidth,
|
||||
a.del_alarm_time as delAlarmTime,
|
||||
b.machine_code as machineCode,
|
||||
(select bandwidth_result from eps_node_bandwidth
|
||||
where client_id=a.client_id and calculation_mode='1000' and bandwidth_type='1'
|
||||
@@ -317,4 +323,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
AND d.create_time = latest.max_time
|
||||
AND d.collect_type='memoryUtilizationCollect'
|
||||
</select>
|
||||
<update id="removeAlarmFlag" parameterType="RmResourceRegistration">
|
||||
update rm_resource_registration set del_alarm_time = now()
|
||||
where id =#{id}
|
||||
</update>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user