From 1f8f557ea0bffe98bd2cd6980ecd3c05961a8e01 Mon Sep 17 00:00:00 2001 From: wr <1754607820@qq.com> Date: Thu, 2 Nov 2023 10:02:49 +0800 Subject: [PATCH] =?UTF-8?q?1.=E8=B0=90=E6=B3=A2=E9=AB=98=E7=BA=A7=E7=AE=97?= =?UTF-8?q?=E6=B3=95=E8=BF=9C=E7=A8=8B=E8=B0=83=E7=94=A8=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/EventWaveAnalysisFeignClient.java | 25 +++++++++++++ ...aveAnalysisFeignClientFallbackFactory.java | 35 +++++++++++++++++++ .../njcn/common/pojo/constant/ServerInfo.java | 2 ++ .../swagger/config/Knife4jSwaggerConfig.java | 3 +- .../com/njcn/device/pq/api/AlarmClient.java | 4 +-- .../service/impl/SupvPushGwServiceImpl.java | 2 +- 6 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 pqs-advance/advance-api/src/main/java/com/njcn/advance/api/EventWaveAnalysisFeignClient.java create mode 100644 pqs-advance/advance-api/src/main/java/com/njcn/advance/api/fallback/EventWaveAnalysisFeignClientFallbackFactory.java diff --git a/pqs-advance/advance-api/src/main/java/com/njcn/advance/api/EventWaveAnalysisFeignClient.java b/pqs-advance/advance-api/src/main/java/com/njcn/advance/api/EventWaveAnalysisFeignClient.java new file mode 100644 index 000000000..4233d7201 --- /dev/null +++ b/pqs-advance/advance-api/src/main/java/com/njcn/advance/api/EventWaveAnalysisFeignClient.java @@ -0,0 +1,25 @@ +package com.njcn.advance.api; + +import com.njcn.advance.api.fallback.EventWaveAnalysisFeignClientFallbackFactory; +import com.njcn.advance.pojo.dto.waveAnalysis.EntityAdvancedData; +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; + + +@FeignClient(value = ServerInfo.ADVANCE_BOOT,path = "/waveAnalysis",fallbackFactory = EventWaveAnalysisFeignClientFallbackFactory.class,contextId = "waveAnalysis") +public interface EventWaveAnalysisFeignClient { + + + /** + * @Description: 波形高级分析 + * @param eventIndex + * @return: com.njcn.common.pojo.response.HttpResult + * @Author: wr + * @Date: 2023/11/1 14:23 + */ + @PostMapping("analysis") + HttpResult analysis(@RequestParam("eventIndex") String eventIndex); +} diff --git a/pqs-advance/advance-api/src/main/java/com/njcn/advance/api/fallback/EventWaveAnalysisFeignClientFallbackFactory.java b/pqs-advance/advance-api/src/main/java/com/njcn/advance/api/fallback/EventWaveAnalysisFeignClientFallbackFactory.java new file mode 100644 index 000000000..e8020d381 --- /dev/null +++ b/pqs-advance/advance-api/src/main/java/com/njcn/advance/api/fallback/EventWaveAnalysisFeignClientFallbackFactory.java @@ -0,0 +1,35 @@ +package com.njcn.advance.api.fallback; + +import com.njcn.advance.api.EventWaveAnalysisFeignClient; +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; + + +@Slf4j +@Component +public class EventWaveAnalysisFeignClientFallbackFactory implements FallbackFactory { + @Override + public EventWaveAnalysisFeignClient 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 EventWaveAnalysisFeignClient() { + + @Override + public HttpResult analysis(String eventIndex) { + log.error("{}异常,降级处理,异常为:{}", "波形高级分析", throwable.toString()); + throw new BusinessException(finalExceptionEnum); + } + }; + } +} diff --git a/pqs-common/common-core/src/main/java/com/njcn/common/pojo/constant/ServerInfo.java b/pqs-common/common-core/src/main/java/com/njcn/common/pojo/constant/ServerInfo.java index 869964497..4cceecaad 100644 --- a/pqs-common/common-core/src/main/java/com/njcn/common/pojo/constant/ServerInfo.java +++ b/pqs-common/common-core/src/main/java/com/njcn/common/pojo/constant/ServerInfo.java @@ -47,5 +47,7 @@ public interface ServerInfo { String CS_ZL_EVENT_BOOT = "zl-event-boot"; + String ADVANCE_BOOT = "advance-boot"; + } diff --git a/pqs-common/common-swagger/src/main/java/com/njcn/swagger/config/Knife4jSwaggerConfig.java b/pqs-common/common-swagger/src/main/java/com/njcn/swagger/config/Knife4jSwaggerConfig.java index db99e7ab3..e33fdd8bd 100644 --- a/pqs-common/common-swagger/src/main/java/com/njcn/swagger/config/Knife4jSwaggerConfig.java +++ b/pqs-common/common-swagger/src/main/java/com/njcn/swagger/config/Knife4jSwaggerConfig.java @@ -74,7 +74,8 @@ public class Knife4jSwaggerConfig { "com.njcn.advance.controller", "com.njcn.stat.controller", "com.njcn.rt.controller", - "com.njcn.zlevent.controller" + "com.njcn.zlevent.controller", + "com.njcn.cloud.controller" ) .collect(Collectors.toList()); List grantTypes = new ArrayList<>(); diff --git a/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/api/AlarmClient.java b/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/api/AlarmClient.java index 266b2afa0..adfdbff0a 100644 --- a/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/api/AlarmClient.java +++ b/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/api/AlarmClient.java @@ -2,7 +2,7 @@ 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.DeviceTreeClientFallbackFactory; +import com.njcn.device.pq.api.fallback.AlarmClientFallbackFactory; import com.njcn.device.pq.pojo.vo.AlarmStrategyVO; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; @@ -15,7 +15,7 @@ import java.util.List; * @author yzh * @date 2022/9/19 */ -@FeignClient(value = ServerInfo.DEVICE, path = "/Alarm", fallbackFactory = DeviceTreeClientFallbackFactory.class, contextId = "Alarm") +@FeignClient(value = ServerInfo.DEVICE, path = "/Alarm", fallbackFactory = AlarmClientFallbackFactory.class, contextId = "Alarm") public interface AlarmClient { /** diff --git a/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/SupvPushGwServiceImpl.java b/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/SupvPushGwServiceImpl.java index 79f8d210a..e47158d7c 100644 --- a/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/SupvPushGwServiceImpl.java +++ b/pqs-process/process-boot/src/main/java/com/njcn/process/service/impl/SupvPushGwServiceImpl.java @@ -727,7 +727,7 @@ public class SupvPushGwServiceImpl implements SupvPushGwService { if(StrUtil.isNotBlank(str)) { String[] split = str.split("_"); if("succeed".equals(split[0])){ - maps.put("succeed", "000000"); + maps.put("succeed", "1"); }else{ maps.put("error", split[1]); }