治理暂态事件、文件解析功能

This commit is contained in:
2023-09-07 20:37:25 +08:00
parent 58feaf2aa0
commit d537021ffd
37 changed files with 1466 additions and 179 deletions

View File

@@ -0,0 +1,18 @@
package com.njcn.access.api;
import com.njcn.access.api.fallback.CsTopicClientFallbackFactory;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
* @author xy
*/
@FeignClient(value = ServerInfo.ACCESS_BOOT, path = "/topic", fallbackFactory = CsTopicClientFallbackFactory.class,contextId = "topic")
public interface CsTopicFeignClient {
@PostMapping("/find")
HttpResult<String> find(@RequestParam("nDid") String nDid);
}

View File

@@ -0,0 +1,34 @@
package com.njcn.access.api.fallback;
import com.njcn.access.api.CsTopicFeignClient;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* @author xy
*/
@Slf4j
@Component
public class CsTopicClientFallbackFactory implements FallbackFactory<CsTopicFeignClient> {
@Override
public CsTopicFeignClient create(Throwable cause) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (cause.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) cause.getCause();
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new CsTopicFeignClient() {
@Override
public HttpResult<String> find(String nDid) {
log.error("{}异常,降级处理,异常为:{}","获取设备支持的主题版本",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -51,6 +51,7 @@ public enum AccessResponseEnum {
SET_DICT_MISSING("A0307","Set字典数据缺失!"),
INSET_DICT_MISSING("A0307","InSet字典数据缺失!"),
CTRL_DICT_MISSING("A0307","Ctrl字典数据缺失!"),
WAVE_INFO_MISSING("A0307","波形参数缺失!"),
MODEL_MISS("A0308","模板信息缺失!"),
MODEL_VERSION_ERROR("A0308","询问装置模板信息错误"),

View File

@@ -0,0 +1,74 @@
package com.njcn.access.pojo.dto.file;
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2023/9/6 8:51
*/
@Data
public class FileDto implements Serializable {
@SerializedName("Mid")
private Integer mid;
@SerializedName("Did")
@ApiModelProperty("逻辑设备 治理逻辑设备为1 电能质量设备为2")
private Integer did;
@SerializedName("Pri")
private Integer pri;
@SerializedName("Type")
private Integer type;
@SerializedName("Code")
private Integer code;
@SerializedName("Msg")
private FileDto.Msg msg;
@Data
public static class Msg{
@SerializedName("Type")
private String type;
@SerializedName("FileInfo")
private FileDto.FileInfo fileInfo;
@SerializedName("Data")
private String data;
@SerializedName("Name")
private String name;
}
@Data
public static class FileInfo{
@SerializedName("Name")
private String name;
@SerializedName("FileTime")
private Long fileTime;
@SerializedName("FileSize")
private Integer fileSize;
@SerializedName("FileCheck")
private String fileCheck;
@SerializedName("FileChkType")
private String fileChkType;
}
}