合并代码
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package com.njcn.device.pq.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.device.pq.api.fallback.SubstationFeignClientFallbackFactory;
|
||||
import com.njcn.device.pq.pojo.dto.SubstationDTO;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2022年10月13日 19:54
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.DEVICE, path = "/substation", fallbackFactory = SubstationFeignClientFallbackFactory.class)
|
||||
public interface SubstationFeignClient {
|
||||
|
||||
|
||||
/**
|
||||
* 根据变电站ID获取变电站信息
|
||||
*
|
||||
* @param subId 变电站ID集合
|
||||
* @return 变电站信息
|
||||
*/
|
||||
@PostMapping("getSubstationById")
|
||||
HttpResult<List<SubstationDTO>> getSubstationById(@RequestParam("subId") List<String> subId);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.njcn.device.pq.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.device.pq.api.SubstationFeignClient;
|
||||
import com.njcn.device.pq.pojo.dto.SubstationDTO;
|
||||
import com.njcn.device.pq.pojo.po.Substation;
|
||||
import com.njcn.device.pq.utils.DeviceEnumUtil;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2022年10月13日 19:55
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class SubstationFeignClientFallbackFactory implements FallbackFactory<SubstationFeignClient> {
|
||||
@Override
|
||||
public SubstationFeignClient create(Throwable throwable) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (throwable.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) throwable.getCause();
|
||||
exceptionEnum = DeviceEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new SubstationFeignClient(){
|
||||
@Override
|
||||
public HttpResult<List<SubstationDTO>> getSubstationById(List<String> id) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "根据变电站ID获取变电站信息", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.njcn.device.pq.pojo.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2022年10月13日 20:03
|
||||
*/
|
||||
@Data
|
||||
public class SubstationDTO implements Serializable {
|
||||
|
||||
/**
|
||||
* 索引
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 电压等级Id,字典表
|
||||
*/
|
||||
private String scale;
|
||||
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
private BigDecimal lng;
|
||||
|
||||
/**
|
||||
* 纬度
|
||||
*/
|
||||
private BigDecimal lat;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.njcn.device.pq.pojo.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* 接口文档访问地址:http://serverIP:port/swagger-ui.html
|
||||
* Date: 2022/10/9 15:59【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ApiModel(value = "DeptLineCountVO" ,description = "部门监测点统计信息")
|
||||
public class DeptLineCountVO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("部门索引")
|
||||
private String index;
|
||||
|
||||
@ApiModelProperty("部门名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("监测点数量")
|
||||
private Integer number=0;
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.njcn.device.pq.pojo.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* Description:通讯异常设备
|
||||
* 接口文档访问地址:http://serverIP:port/swagger-ui.html
|
||||
* Date: 2022/10/14 10:45【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ApiModel(value = "ExceptionDeviceInfoVO" ,description = "通讯异常设备")
|
||||
public class ExceptionDeviceInfoVO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(name ="subIndex",value = "变电站索引")
|
||||
private String subIndex;
|
||||
|
||||
|
||||
|
||||
@ApiModelProperty(name ="subName",value = "变电站名称")
|
||||
private String subName;
|
||||
|
||||
@ApiModelProperty("设备索引")
|
||||
private String devIndex;
|
||||
|
||||
|
||||
@ApiModelProperty("设备名称")
|
||||
private String devName;
|
||||
|
||||
|
||||
@ApiModelProperty("网络参数")
|
||||
private String ip;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty("发生时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@ApiModelProperty("警告类型id")
|
||||
private String warningId;
|
||||
|
||||
@ApiModelProperty("警告类型")
|
||||
private String warningType;
|
||||
|
||||
@ApiModelProperty("异常描述")
|
||||
private String exceptionDescription;
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user