feat(alarm): 添加告警统计功能并优化设备管理
- 在AlarmVO中新增interruptCounts和warnCounts字段用于统计通信中断和终端告警次数 - 在CsAlarmServiceImpl中实现告警次数统计逻辑,解析告警事件数据并计算各类告警数量 - 重构CsEventUserPOServiceImpl中的查询逻辑,优化暂态事件详细信息查询接口 - 在CsEquipmentDeliveryServiceImpl中集成事件查询功能,实时获取设备告警状态 - 优化数据库查询语句,改进事件查询的排序和过滤逻辑
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package com.njcn.csharmonic.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csharmonic.api.fallback.CsHarmonicPlanFeignClientFallbackFactory;
|
||||
import com.njcn.csharmonic.pojo.po.CsHarmonicPlan;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_HARMONIC_BOOT, path = "/csHarmonicPlan", fallbackFactory = CsHarmonicPlanFeignClientFallbackFactory.class,contextId = "csHarmonicPlan")
|
||||
public interface CsHarmonicPlanFeignClient {
|
||||
|
||||
@GetMapping("/getById")
|
||||
@ApiOperation("根据ID查询稳态指标方案")
|
||||
HttpResult<CsHarmonicPlan> getById(@RequestParam("id") String id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.njcn.csharmonic.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csharmonic.api.fallback.CsHarmonicPlanLineFeignClientFallbackFactory;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_HARMONIC_BOOT, path = "/csHarmonicPlanLine", fallbackFactory = CsHarmonicPlanLineFeignClientFallbackFactory.class,contextId = "csHarmonicPlanLine")
|
||||
public interface CsHarmonicPlanLineFeignClient {
|
||||
|
||||
@GetMapping("/getPlanIdByLineId")
|
||||
@ApiOperation("根据监测点ID查询方案ID")
|
||||
HttpResult<String> getPlanIdByLineId(@RequestParam("lineId") String lineId);
|
||||
|
||||
}
|
||||
@@ -1,11 +1,17 @@
|
||||
package com.njcn.csharmonic.api;
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.csharmonic.api.fallback.EventUserFeignClientFallbackFactory;
|
||||
import com.njcn.csharmonic.param.CsEventUserQueryParam;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
|
||||
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -33,6 +39,10 @@ public interface EventUserFeignClient {
|
||||
@ApiOperation("查询暂态事件(未读)")
|
||||
HttpResult<List<String>> queryTempEvent(@RequestBody CsEventUserQueryParam param);
|
||||
|
||||
@PostMapping("/queryTempEventDetail")
|
||||
@ApiOperation("查询暂态事件详细信息(未读)")
|
||||
HttpResult<List<CsEventPO>> queryTempEventDetail(@RequestBody CsEventUserQueryParam param);
|
||||
|
||||
@PostMapping("/queryTempHarmonic")
|
||||
@ApiOperation("查询稳态事件(未读)")
|
||||
HttpResult<List<String>> queryTempHarmonic(@RequestBody CsEventUserQueryParam param);
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.njcn.csharmonic.api.fallback;
|
||||
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csharmonic.api.CsHarmonicFeignClient;
|
||||
import com.njcn.csharmonic.api.CsHarmonicPlanFeignClient;
|
||||
import com.njcn.csharmonic.pojo.po.CsHarmonic;
|
||||
import com.njcn.csharmonic.pojo.po.CsHarmonicPlan;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CsHarmonicPlanFeignClientFallbackFactory implements FallbackFactory<CsHarmonicPlanFeignClient> {
|
||||
@Override
|
||||
public CsHarmonicPlanFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new CsHarmonicPlanFeignClient() {
|
||||
|
||||
@Override
|
||||
public HttpResult<CsHarmonicPlan> getById(String id) {
|
||||
log.error("{}异常,降级处理,异常为:{}","根据ID查询稳态指标方案异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.njcn.csharmonic.api.fallback;
|
||||
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csharmonic.api.CsHarmonicPlanLineFeignClient;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CsHarmonicPlanLineFeignClientFallbackFactory implements FallbackFactory<CsHarmonicPlanLineFeignClient> {
|
||||
@Override
|
||||
public CsHarmonicPlanLineFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new CsHarmonicPlanLineFeignClient() {
|
||||
@Override
|
||||
public HttpResult<String> getPlanIdByLineId(String lineId) {
|
||||
log.error("{}异常,降级处理,异常为:{}","根据监测点ID查询方案ID异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csharmonic.api.EventUserFeignClient;
|
||||
import com.njcn.csharmonic.param.CsEventUserQueryParam;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
|
||||
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
@@ -52,6 +53,12 @@ public class EventUserFeignClientFallbackFactory implements FallbackFactory<Even
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<CsEventPO>> queryTempEventDetail(CsEventUserQueryParam param) {
|
||||
log.error("{}异常,降级处理,异常为:{}","查询暂态事件详细信息(未读)异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<String>> queryTempHarmonic(CsEventUserQueryParam param) {
|
||||
log.error("{}异常,降级处理,异常为:{}","查询稳态事件(未读)异常",cause.toString());
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.njcn.csharmonic.param;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 稳态指标方案与测点关系参数类
|
||||
*
|
||||
* @author xy
|
||||
* @since 2026-04-15
|
||||
*/
|
||||
@Data
|
||||
public class CsHarmonicPlanLineParam {
|
||||
|
||||
/**
|
||||
* 方案ID
|
||||
*/
|
||||
@ApiModelProperty(value = "方案ID")
|
||||
@NotBlank(message = "方案ID不能为空")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 监测点ID集合
|
||||
*/
|
||||
@ApiModelProperty(value = "监测点ID集合")
|
||||
@NotEmpty(message = "监测点ID集合不能为空")
|
||||
private List<String> lineIds;
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.njcn.csharmonic.param;
|
||||
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 稳态指标方案参数类
|
||||
*
|
||||
* @author xy
|
||||
* @since 2026-04-15
|
||||
*/
|
||||
@Data
|
||||
public class CsHarmonicPlanParam {
|
||||
|
||||
/**
|
||||
* 稳态方案名称
|
||||
*/
|
||||
@ApiModelProperty(value = "稳态方案名称")
|
||||
@NotBlank(message = "稳态方案名称不能为空")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 稳态指标集合
|
||||
*/
|
||||
@ApiModelProperty(value = "稳态指标集合")
|
||||
private String harmonicTarget;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 监测点id集合
|
||||
*/
|
||||
@ApiModelProperty(value = "监测点id集合")
|
||||
private List<String> lineList;
|
||||
|
||||
/**
|
||||
* 修改参数类
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class UpdateCsHarmonicPlanParam extends CsHarmonicPlanParam {
|
||||
@ApiModelProperty("ID")
|
||||
@NotBlank(message = "ID不能为空")
|
||||
private String id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询参数类
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class QueryParam extends BaseParam {
|
||||
@ApiModelProperty(value = "稳态方案名称")
|
||||
private String name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.njcn.csharmonic.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2026-04-15
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("cs_harmonic_plan")
|
||||
public class CsHarmonicPlan extends BaseEntity implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 稳态方案名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 稳态指标集合
|
||||
*/
|
||||
private String harmonicTarget;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 监测点ID集合(非数据库字段)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private List<String> lineList;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.njcn.csharmonic.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import java.io.Serializable;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2026-04-15
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("cs_harmonic_plan_line")
|
||||
public class CsHarmonicPlanLine implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 监测点id
|
||||
*/
|
||||
private String lineId;
|
||||
|
||||
|
||||
}
|
||||
@@ -24,6 +24,12 @@ public class AlarmVO implements Serializable {
|
||||
@ApiModelProperty(value = "告警设备台数")
|
||||
private Integer warnNums;
|
||||
|
||||
@ApiModelProperty(value = "通讯中断告警次数")
|
||||
private Integer interruptCounts;
|
||||
|
||||
@ApiModelProperty(value = "终端告警次数")
|
||||
private Integer warnCounts;
|
||||
|
||||
@ApiModelProperty(value = "告警设备id集合")
|
||||
private List<String> devIds;
|
||||
|
||||
@@ -42,6 +48,9 @@ public class AlarmVO implements Serializable {
|
||||
@ApiModelProperty(value = "设备名称")
|
||||
private String devName;
|
||||
|
||||
@ApiModelProperty(value = "设备类型")
|
||||
private String devType;
|
||||
|
||||
@ApiModelProperty(value = "告警次数")
|
||||
private Integer warnCounts = 0;
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -47,6 +46,8 @@ public class EventDetailVO {
|
||||
*/
|
||||
private String deviceId;
|
||||
|
||||
@ApiModelProperty(value = "设备类型")
|
||||
private String devType;
|
||||
|
||||
@ApiModelProperty(value = "设备名称")
|
||||
private String equipmentName;
|
||||
|
||||
Reference in New Issue
Block a user