初始版本提交
This commit is contained in:
@@ -16,5 +16,30 @@
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-microservice</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn.platform</groupId>
|
||||
<artifactId>data-processing-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn.platform</groupId>
|
||||
<artifactId>message-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
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.EventAnalysisFeignClientFallbackFactory;
|
||||
import com.njcn.message.messagedto.MessageDataDTO;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2025/01/15 下午 3:52【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@FeignClient(
|
||||
value = ServerInfo.PLATFORM_STAT_BOOT,
|
||||
path = "/eventAnalysis",
|
||||
fallbackFactory = EventAnalysisFeignClientFallbackFactory.class,
|
||||
contextId = "analysis")
|
||||
public interface EventAnalysisFeignClient {
|
||||
@PostMapping("/analysis")
|
||||
HttpResult<String> analysis(@RequestBody List<MessageDataDTO> messageList);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
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.EventAnalysisFeignClient;
|
||||
import com.njcn.event.utils.EventEnumUtil;
|
||||
import com.njcn.message.messagedto.MessageDataDTO;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2025/01/15 下午 3:55【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class EventAnalysisFeignClientFallbackFactory implements FallbackFactory<EventAnalysisFeignClient> {
|
||||
|
||||
@Override
|
||||
public EventAnalysisFeignClient create(Throwable throwable) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (throwable.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) throwable.getCause();
|
||||
exceptionEnum = EventEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new EventAnalysisFeignClient() {
|
||||
|
||||
@Override
|
||||
public HttpResult<String> analysis(List<MessageDataDTO> messageList) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "暂态消息数据解析", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Description:feign回调函数包
|
||||
* Date: 2025/01/23 下午 1:50【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
package com.njcn.event.api.fallback;
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Description:对外接口包
|
||||
* Date: 2025/01/23 下午 1:48【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
package com.njcn.event.api;
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.njcn.event.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2021年12月20日 09:56
|
||||
*/
|
||||
@Getter
|
||||
public enum EventResponseEnum {
|
||||
STAT_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,47 @@
|
||||
package com.njcn.event.messagedto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2024/11/28 8:41【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Data
|
||||
public class EventDTO {
|
||||
|
||||
/**
|
||||
* MAG : 56.23
|
||||
* DUR : 23
|
||||
* STARTTIME : 1512097260000
|
||||
* ENDTIME : 1512097283000
|
||||
* DISKIND : 01
|
||||
* CFG_FILE : fbb0a92db093e1bca6d9571ad68d9f43
|
||||
* DAT_FILE : 33bbc16993eab29950196b35ef44c93a
|
||||
* PHASIC : unknow
|
||||
*/
|
||||
@JsonProperty("MAG")
|
||||
private double mag;
|
||||
@JsonProperty("DUR")
|
||||
private Double dur;
|
||||
@JsonProperty("STARTTIME")
|
||||
private LocalDateTime starttime;
|
||||
@JsonProperty("ENDTIME")
|
||||
private LocalDateTime endtime;
|
||||
@JsonProperty("DISKIND")
|
||||
private String diskind;
|
||||
@JsonProperty("CFG_FILE")
|
||||
private String cfgFile;
|
||||
@JsonProperty("DAT_FILE")
|
||||
private String datFile;
|
||||
@JsonProperty("PHASIC")
|
||||
private String phasic;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.njcn.event.messagedto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2024/11/8 14:11【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Data
|
||||
public class MessageEventDataSet implements Serializable {
|
||||
private Integer FLAG;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
|
||||
@JsonSerialize(using = LocalDateTimeSerializer.class)
|
||||
private LocalDateTime TIME;
|
||||
@JsonProperty("VOLTAGE")
|
||||
private EventDTO volTage;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user