初始化
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
package com.njcn.event.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.event.api.fallback.EventDetailFeignClientFallbackFactory;
|
||||
import com.njcn.event.pojo.po.EventDetail;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author denghuajun
|
||||
* @version 1.0.0
|
||||
* @date 2022/3/16
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.EVENT,path = "/event",fallbackFactory = EventDetailFeignClientFallbackFactory.class)
|
||||
public interface EventDetailFeignClient {
|
||||
|
||||
/**
|
||||
* 根据监测点id获取暂降事件
|
||||
* @param id 监测点id
|
||||
* @return 暂降事件信息
|
||||
*/
|
||||
@PostMapping("/getEventDetailData")
|
||||
HttpResult<List<EventDetail>> getEventDetailData(@RequestParam("id")String id, @RequestParam("startTime")String startTime, @RequestParam("endTime")String endTime);
|
||||
|
||||
/**
|
||||
* 根据监测点集合获取暂降事件
|
||||
* @return 暂降事件信息
|
||||
*/
|
||||
@PostMapping("/getEventDetail")
|
||||
HttpResult<List<EventDetail>> getEventDetail(@RequestBody List<String> lineIndexes, @RequestParam("startTime")String startTime, @RequestParam("endTime")String endTime);
|
||||
|
||||
/**
|
||||
* 根据监测点集合分页获取暂降事件
|
||||
* @return 暂降事件信息
|
||||
*/
|
||||
@PostMapping("/getEventDetailLimit")
|
||||
HttpResult<List<EventDetail>> getEventDetailLimit(@RequestBody List<String> lineIndexes, @RequestParam("startTime")String startTime, @RequestParam("endTime")String endTime,@RequestParam("pageSize") Integer pageSize,@RequestParam("pageNum") Integer pageNum);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.njcn.event.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.event.api.EventDetailFeignClient;
|
||||
import com.njcn.event.pojo.po.EventDetail;
|
||||
import com.njcn.event.utils.EventlEnumUtil;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author denghuajun
|
||||
* @version 1.0.0
|
||||
* @date 2022/3/16
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class EventDetailFeignClientFallbackFactory implements FallbackFactory<EventDetailFeignClient> {
|
||||
@Override
|
||||
public EventDetailFeignClient create(Throwable throwable) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (throwable.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) throwable.getCause();
|
||||
exceptionEnum = EventlEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new EventDetailFeignClient() {
|
||||
@Override
|
||||
public HttpResult<List<EventDetail>> getEventDetailData(String id, String startTime, String endTime) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "根据监测点Id获取暂降事件信息", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<EventDetail>> getEventDetail(List<String> lineIndexes, String startTime, String endTime) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "根据监测点集合获取暂降事件", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<EventDetail>> getEventDetailLimit(List<String> lineIndexes, String startTime, String endTime, Integer pageSize, Integer pageNum) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "根据监测点集合获取暂降事件", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.njcn.event.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2021年12月20日 09:56
|
||||
*/
|
||||
@Getter
|
||||
public enum EventResponseEnum {
|
||||
|
||||
/**
|
||||
* 谐波模块异常响应码的范围:
|
||||
* A00650 ~ A00749
|
||||
*/
|
||||
HARMONIC_COMMON_ERROR("A00550","谐波模块异常")
|
||||
;
|
||||
|
||||
private final String code;
|
||||
|
||||
private final String message;
|
||||
|
||||
EventResponseEnum(String code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.njcn.event.pojo.param;
|
||||
|
||||
import com.njcn.device.pojo.param.DeviceInfoParam;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @version 1.0.0
|
||||
* @author: chenchao
|
||||
* @date: 2022/06/06 14:07
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class TransientParam extends DeviceInfoParam.BusinessParam {
|
||||
|
||||
@ApiModelProperty("页码")
|
||||
@NotNull(message = "页码不可为空")
|
||||
@Range(min = 1,message = "页码必须大于0")
|
||||
private Integer pageNum;
|
||||
|
||||
@ApiModelProperty("条数")
|
||||
@NotNull(message = "条数不可为空")
|
||||
@Range(min = 1,message = "条数必须大于0")
|
||||
private Integer pageSize;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.njcn.event.pojo.po;
|
||||
|
||||
import lombok.Data;
|
||||
import org.influxdb.annotation.Column;
|
||||
import org.influxdb.annotation.Measurement;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
/**
|
||||
* @author denghuajun
|
||||
* @version 1.0.0
|
||||
* @date 2022年04月07日 08:59
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Measurement(name = "pqs_eventdetail")
|
||||
public class EventDetail {
|
||||
|
||||
@Column(name = "id")
|
||||
private String id;
|
||||
|
||||
@Column(name = "line_id")
|
||||
private String lineId;
|
||||
|
||||
@Column(name = "time")
|
||||
private Instant timeId;
|
||||
|
||||
@Column(name = "event_describe")
|
||||
private String eventDescribe;
|
||||
|
||||
@Column(name = "wave_type")
|
||||
private Integer waveType;
|
||||
|
||||
@Column(name = "persist_time")
|
||||
private Double persistTime;
|
||||
|
||||
@Column(name = "event_value")
|
||||
private Double eventValue;
|
||||
|
||||
@Column(name = "event_reason")
|
||||
private String eventReason;
|
||||
|
||||
@Column(name = "event_type")
|
||||
private String eventType;
|
||||
|
||||
@Column(name = "eventass_index")
|
||||
private String eventassIndex;
|
||||
|
||||
@Column(name = "dq_time")
|
||||
private Integer dqTime;
|
||||
|
||||
@Column(name = "deal_time")
|
||||
private String dealTime;
|
||||
|
||||
@Column(name = "deal_flag")
|
||||
private Integer dealFlag;
|
||||
|
||||
@Column(name = "num")
|
||||
private Integer num;
|
||||
|
||||
@Column(name = "file_flag")
|
||||
private Integer fileFlag;
|
||||
|
||||
@Column(name = "first_time")
|
||||
private String firstTime;
|
||||
|
||||
@Column(name = "first_type")
|
||||
private String firstType;
|
||||
|
||||
@Column(name = "first_ms")
|
||||
private Integer firstMs;
|
||||
|
||||
@Column(name = "wave_name")
|
||||
private String waveName;
|
||||
|
||||
@Column(name = "energy")
|
||||
private Double energy;
|
||||
|
||||
@Column(name = "severity")
|
||||
private Double severity;
|
||||
|
||||
@Column(name = "sagsource")
|
||||
private String sagSource;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.njcn.event.pojo.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 区域暂降监测点分布
|
||||
* @author denghuajun
|
||||
* @version 1.0.0
|
||||
* @date 2022/4/6
|
||||
*/
|
||||
@Data
|
||||
public class AreaEventDetailVO implements Serializable {
|
||||
|
||||
@ApiModelProperty(name = "lineId",value = "监测点id")
|
||||
private String lineId;
|
||||
|
||||
@ApiModelProperty(name = "lineName",value = "监测点名称")
|
||||
private String lineName;
|
||||
|
||||
@ApiModelProperty(name ="lng",value = "经度")
|
||||
private Double lng;
|
||||
|
||||
@ApiModelProperty(name ="scale",value = "纬度")
|
||||
private Double lat;
|
||||
|
||||
@ApiModelProperty(name = "state",value = "状态")
|
||||
private Integer state;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.njcn.event.pojo.vo;
|
||||
|
||||
import com.njcn.device.pojo.vo.SubstationDetailVO;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author denghuajun
|
||||
* @version 1.0.0
|
||||
* @date 2022年04月07日 08:59
|
||||
*/
|
||||
@Data
|
||||
public class AreaLineVO implements Serializable {
|
||||
@ApiModelProperty(name = "areaEventDetailVOList",value = "监测点分布")
|
||||
private List<SubstationDetailVO> substationDetailVOList;
|
||||
|
||||
@ApiModelProperty(name = "areaValue",value = "数值")
|
||||
private List<List<Object>> areaValue;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.njcn.event.pojo.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author denghuajun
|
||||
* @version 1.0.0
|
||||
* @date 2022年05月07日 14:50
|
||||
*/
|
||||
@Data
|
||||
public class EventAssessmentVO implements Serializable {
|
||||
@ApiModelProperty(name = "areaValue",value = "数值")
|
||||
private List<List<Object>> areaValue;
|
||||
|
||||
@ApiModelProperty(name = "eventHeatMapValue",value = "暂降评估数值")
|
||||
private List<EventAssessmentValueVO> assessmentValueList;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.njcn.event.pojo.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author denghuajun
|
||||
* @version 1.0.0
|
||||
* @date 2022年05月07日 15:51
|
||||
*/
|
||||
@Data
|
||||
public class EventAssessmentValueVO implements Serializable {
|
||||
@ApiModelProperty("区域名称")
|
||||
private String areaName;
|
||||
|
||||
@ApiModelProperty("区域暂降评估数值")
|
||||
private Float eventAssessmentValue;
|
||||
|
||||
@ApiModelProperty("评估等级")
|
||||
private Integer level;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.njcn.event.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import org.influxdb.annotation.Column;
|
||||
import org.influxdb.annotation.Measurement;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author denghuajun
|
||||
* @version 1.0.0
|
||||
* @date 2022年05月06日 17:24
|
||||
*/
|
||||
@Data
|
||||
@Measurement(name = "pqs_eventdetail")
|
||||
public class EventHeatDeatilVO implements Serializable {
|
||||
|
||||
@Column(name = "line_id")
|
||||
private String lineId;
|
||||
|
||||
@Column(name = "time")
|
||||
private String timeId;
|
||||
|
||||
@Column(name = "count")
|
||||
private Integer count;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.njcn.event.pojo.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author denghuajun
|
||||
* @version 1.0.0
|
||||
* @date 2022年05月06日 11:41
|
||||
*/
|
||||
@Data
|
||||
public class EventHeatMapDetailVO implements Serializable {
|
||||
|
||||
@ApiModelProperty("供电公司名称")
|
||||
private String gdName;
|
||||
|
||||
@ApiModelProperty("变电站名称")
|
||||
private String subName;
|
||||
|
||||
@ApiModelProperty("监测点名称")
|
||||
private String lineName;
|
||||
|
||||
@ApiModelProperty("暂降次数")
|
||||
private Integer eventNum;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.njcn.event.pojo.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author denghuajun
|
||||
* @version 1.0.0
|
||||
* @date 2022年05月05日 15:42
|
||||
*/
|
||||
@Data
|
||||
public class EventHeatMapVO implements Serializable {
|
||||
|
||||
@ApiModelProperty(name = "areaValue",value = "数值")
|
||||
private List<List<Object>> areaValue;
|
||||
|
||||
@ApiModelProperty(name = "eventHeatMapValue",value = "热力图数值")
|
||||
private List<EventHeatMapDetailVO> eventHeatMapValue;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.njcn.event.pojo.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 暂降严重度
|
||||
* @author denghuajun
|
||||
* @version 1.0.0
|
||||
* @date 2022年05月07日 09:03
|
||||
*/
|
||||
@Data
|
||||
public class EventSeverityVO implements Serializable {
|
||||
@ApiModelProperty(name = "areaValue",value = "数值")
|
||||
private List<List<Object>> areaValue;
|
||||
|
||||
@ApiModelProperty(name = "eventSeverityValue",value = "暂降严重度数值")
|
||||
private List<EventSeverityValueVO> eventSeverityValue;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.njcn.event.pojo.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author denghuajun
|
||||
* @version 1.0.0
|
||||
* @date 2022年05月07日 09:05
|
||||
*/
|
||||
@Data
|
||||
public class EventSeverityValueVO implements Serializable {
|
||||
@ApiModelProperty("区域名称")
|
||||
private String areaName;
|
||||
|
||||
@ApiModelProperty("监测点个数")
|
||||
private Integer lineNum;
|
||||
|
||||
@ApiModelProperty("暂降事件次数")
|
||||
private Integer eventNum;
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.njcn.event.pojo.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author: chenchao
|
||||
* @date: 2022/03/29 11:54
|
||||
* @Description: <描述>
|
||||
*/
|
||||
@Data
|
||||
public class TransientVO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@ApiModelProperty("id")
|
||||
private String id;
|
||||
/**
|
||||
* 暂态发生时刻
|
||||
*/
|
||||
@ApiModelProperty("暂态发生时刻")
|
||||
private String time;
|
||||
/**
|
||||
* 监测点名称
|
||||
*/
|
||||
@ApiModelProperty("监测点名称")
|
||||
private String name;
|
||||
/**
|
||||
* 供电公司
|
||||
*/
|
||||
@ApiModelProperty("供电公司")
|
||||
private String powerCompany;
|
||||
/**
|
||||
* 变电站
|
||||
*/
|
||||
@ApiModelProperty("变电站")
|
||||
private String substation;
|
||||
/**
|
||||
* 网络参数
|
||||
*/
|
||||
@ApiModelProperty("网络参数")
|
||||
private String networkParam;
|
||||
/**
|
||||
* 电压等级
|
||||
*/
|
||||
@ApiModelProperty("电压等级")
|
||||
private String voltageLevel;
|
||||
/**
|
||||
* 触发类型
|
||||
*/
|
||||
@ApiModelProperty("触发类型")
|
||||
private String trigType;
|
||||
/**
|
||||
* 暂态幅值
|
||||
*/
|
||||
@ApiModelProperty("暂态幅值")
|
||||
private Double eventValue;
|
||||
/**
|
||||
* 暂态深度
|
||||
*/
|
||||
@ApiModelProperty("暂态深度")
|
||||
private Double eventValues;
|
||||
/**
|
||||
* 暂态持续时间
|
||||
*/
|
||||
@ApiModelProperty("暂态持续时间")
|
||||
private Float persistTime;
|
||||
/**
|
||||
* 暂态严重度
|
||||
*/
|
||||
@ApiModelProperty("暂态严重度")
|
||||
private String yZD;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.njcn.event.utils;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
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.common.utils.EnumUtils;
|
||||
import com.njcn.event.enums.EventResponseEnum;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2021年12月20日 10:03
|
||||
*/
|
||||
public class EventlEnumUtil {
|
||||
|
||||
/**
|
||||
* 获取EventResponseEnum实例
|
||||
*/
|
||||
public static EventResponseEnum getEventEnumResponseEnumByMessage(@NotNull Object value) {
|
||||
EventResponseEnum eventDetailResponseEnum;
|
||||
try {
|
||||
String message = value.toString();
|
||||
if(message.indexOf(StrUtil.C_COMMA)>0){
|
||||
value = message.substring(message.indexOf(StrUtil.C_COMMA)+1);
|
||||
}
|
||||
eventDetailResponseEnum = EnumUtils.valueOf(EventResponseEnum.class, value, EventResponseEnum.class.getMethod(BusinessException.GET_MESSAGE_METHOD));
|
||||
return Objects.isNull(eventDetailResponseEnum) ? EventResponseEnum.HARMONIC_COMMON_ERROR : eventDetailResponseEnum;
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new BusinessException(CommonResponseEnum.INTERNAL_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
public static Enum<?> getExceptionEnum(HttpResult<Object> result){
|
||||
//如果返回错误,且为内部错误,则直接抛出异常
|
||||
CommonResponseEnum commonResponseEnum = EnumUtils.getCommonResponseEnumByCode(result.getCode());
|
||||
if (commonResponseEnum == CommonResponseEnum.DEVICE_RESPONSE_ENUM) {
|
||||
return getEventEnumResponseEnumByMessage(result.getMessage());
|
||||
}
|
||||
return commonResponseEnum;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user