暂降原因

This commit is contained in:
hzj
2025-08-01 10:48:04 +08:00
parent 7c1b07feba
commit 0a6b4e9aca
8 changed files with 165 additions and 13 deletions

View File

@@ -0,0 +1,24 @@
package com.njcn.advance.api;
import com.njcn.advance.api.fallback.EventCauseFeignClientFallbackFactory;
import com.njcn.advance.pojo.dto.EventAnalysisDTO;
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.RequestBody;
/**
* Description:
* Date: 2025/08/01 上午 8:54【需求编号】
*
* @author clam
* @version V1.0.0
*/
@FeignClient(value = ServerInfo.ADVANCE_BOOT,path = "/eventAdvance",
fallbackFactory = EventCauseFeignClientFallbackFactory.class,
contextId = "eventAdvance" )
public interface EventCauseFeignClient {
@PostMapping(value = "/analysisCauseAndType")
HttpResult<EventAnalysisDTO> analysisCauseAndType(@RequestBody EventAnalysisDTO eventAnalysis);
}

View File

@@ -0,0 +1,41 @@
package com.njcn.advance.api.fallback;
import com.njcn.advance.api.EventCauseFeignClient;
import com.njcn.advance.api.EventWaveAnalysisFeignClient;
import com.njcn.advance.pojo.dto.EventAnalysisDTO;
import com.njcn.advance.pojo.dto.waveAnalysis.EntityAdvancedData;
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.utils.EventlEnumUtil;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* @author wr
*/
@Slf4j
@Component
public class EventCauseFeignClientFallbackFactory implements FallbackFactory<EventCauseFeignClient> {
@Override
public EventCauseFeignClient 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 EventCauseFeignClient() {
@Override
public HttpResult<EventAnalysisDTO> analysisCauseAndType(EventAnalysisDTO eventAnalysis) {
log.error("{}异常,降级处理,异常为:{}", "暂降原因分析", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -1,4 +1,4 @@
package com.njcn.advance.event.pojo;
package com.njcn.advance.pojo.dto;
import lombok.Data;

View File

@@ -1,6 +1,6 @@
package com.njcn.advance.event.controller;
import com.njcn.advance.event.pojo.EventAnalysisDTO;
import com.njcn.advance.pojo.dto.EventAnalysisDTO;
import com.njcn.advance.event.service.IEventAdvanceService;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
@@ -13,11 +13,10 @@ import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author hongawen
* @version 1.0
@@ -35,7 +34,7 @@ public class EventCauseController extends BaseController {
@PostMapping(value = "/analysisCauseAndType")
@ApiOperation("分析暂降事件的原因和类型")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
public HttpResult<EventAnalysisDTO> analysisCauseAndType(EventAnalysisDTO eventAnalysis) {
public HttpResult<EventAnalysisDTO> analysisCauseAndType(@RequestBody EventAnalysisDTO eventAnalysis) {
String methodDescribe = getMethodDescribe("analysisCauseAndType");
eventAnalysis = eventAdvanceService.analysisCauseAndType(eventAnalysis);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, eventAnalysis, methodDescribe);

View File

@@ -1,6 +1,6 @@
package com.njcn.advance.event.service;
import com.njcn.advance.event.pojo.EventAnalysisDTO;
import com.njcn.advance.pojo.dto.EventAnalysisDTO;
/**
* @author hongawen

View File

@@ -5,7 +5,7 @@ import com.njcn.advance.event.cause.core.VoltageSagAnalyzer;
import com.njcn.advance.event.cause.model.AnalysisResult;
import com.njcn.advance.event.cause.model.DataFeature;
import com.njcn.advance.event.cause.model.QvvrDataStruct;
import com.njcn.advance.event.pojo.EventAnalysisDTO;
import com.njcn.advance.pojo.dto.EventAnalysisDTO;
import com.njcn.advance.event.service.IEventAdvanceService;
import com.njcn.advance.event.type.jna.QvvrDLL;
import com.njcn.common.config.GeneralInfo;