From ff27f42ae2602855274096864fbf19416460eceb Mon Sep 17 00:00:00 2001
From: xuyang <748613696@qq.com>
Date: Mon, 10 Apr 2023 15:19:45 +0800
Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=B2=BB=E7=90=86=E5=AF=B9?=
=?UTF-8?q?=E5=A4=96=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pqs-algorithm/algorithm-api/pom.xml | 5 ++
.../algorithm/api/EquipmentFeignClient.java | 21 +++++
.../EquipmentFeignClientFallbackFactory.java | 36 +++++++++
pqs-algorithm/algorithm-boot/pom.xml | 76 +++++++++----------
.../EquipmentDeliveryController.java | 2 +-
.../njcn/common/pojo/constant/ServerInfo.java | 1 +
6 files changed, 102 insertions(+), 39 deletions(-)
create mode 100644 pqs-algorithm/algorithm-api/src/main/java/com/njcn/algorithm/api/EquipmentFeignClient.java
create mode 100644 pqs-algorithm/algorithm-api/src/main/java/com/njcn/algorithm/api/fallback/EquipmentFeignClientFallbackFactory.java
diff --git a/pqs-algorithm/algorithm-api/pom.xml b/pqs-algorithm/algorithm-api/pom.xml
index ea461c39d..2a9f51a6a 100644
--- a/pqs-algorithm/algorithm-api/pom.xml
+++ b/pqs-algorithm/algorithm-api/pom.xml
@@ -38,6 +38,11 @@
org.projectlombok
lombok
+
+ com.njcn
+ common-microservice
+ ${project.version}
+
diff --git a/pqs-algorithm/algorithm-api/src/main/java/com/njcn/algorithm/api/EquipmentFeignClient.java b/pqs-algorithm/algorithm-api/src/main/java/com/njcn/algorithm/api/EquipmentFeignClient.java
new file mode 100644
index 000000000..61f192864
--- /dev/null
+++ b/pqs-algorithm/algorithm-api/src/main/java/com/njcn/algorithm/api/EquipmentFeignClient.java
@@ -0,0 +1,21 @@
+package com.njcn.algorithm.api;
+
+import com.njcn.algorithm.api.fallback.EquipmentFeignClientFallbackFactory;
+import com.njcn.algorithm.pojo.vo.CsEquipmentDeliveryVO;
+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.ALGORITHM_BOOT, path = "/EquipmentDelivery", fallbackFactory = EquipmentFeignClientFallbackFactory.class,contextId = "EquipmentDelivery")
+public interface EquipmentFeignClient {
+
+ @PostMapping("/queryEquipmentByndid")
+ HttpResult queryEquipmentByndid(@RequestParam("ndid") String ndid);
+
+}
diff --git a/pqs-algorithm/algorithm-api/src/main/java/com/njcn/algorithm/api/fallback/EquipmentFeignClientFallbackFactory.java b/pqs-algorithm/algorithm-api/src/main/java/com/njcn/algorithm/api/fallback/EquipmentFeignClientFallbackFactory.java
new file mode 100644
index 000000000..d204e56fc
--- /dev/null
+++ b/pqs-algorithm/algorithm-api/src/main/java/com/njcn/algorithm/api/fallback/EquipmentFeignClientFallbackFactory.java
@@ -0,0 +1,36 @@
+package com.njcn.algorithm.api.fallback;
+
+import com.njcn.algorithm.api.EquipmentFeignClient;
+import com.njcn.algorithm.pojo.vo.CsEquipmentDeliveryVO;
+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 EquipmentFeignClientFallbackFactory implements FallbackFactory {
+ @Override
+ public EquipmentFeignClient create(Throwable cause) {
+ //判断抛出异常是否为解码器抛出的业务异常
+ Enum> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
+ if (cause.getCause() instanceof BusinessException) {
+ BusinessException businessException = (BusinessException) cause.getCause();
+// exceptionEnum = UserEnumUtil.getExceptionEnum(businessException.getResult());
+ }
+ Enum> finalExceptionEnum = exceptionEnum;
+ return new EquipmentFeignClient() {
+
+ @Override
+ public HttpResult queryEquipmentByndid(String ndid) {
+ log.error("{}异常,降级处理,异常为:{}","通过ndid查询出厂设备异常",cause.toString());
+ throw new BusinessException(finalExceptionEnum);
+ }
+ };
+ }
+}
diff --git a/pqs-algorithm/algorithm-boot/pom.xml b/pqs-algorithm/algorithm-boot/pom.xml
index 7070ec2bc..2fe984f3b 100644
--- a/pqs-algorithm/algorithm-boot/pom.xml
+++ b/pqs-algorithm/algorithm-boot/pom.xml
@@ -101,44 +101,44 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ com.spotify
+ docker-maven-plugin
+ 1.0.0
+
+
+
+ build-image
+ ${docker.operate}
+
+ build
+
+
+
+
+
+ http://${docker.repostory}
+
+ ${docker.repostory}/${docker.registry.name}/${project.artifactId}
+
+
+ latest
+
+
+ ${docker.url}
+ ${basedir}/
+
+
+
+ /ROOT
+
+ ${project.build.directory}
+
+ ${project.build.finalName}.jar
+
+
+
+
diff --git a/pqs-algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/controller/Equipment/EquipmentDeliveryController.java b/pqs-algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/controller/Equipment/EquipmentDeliveryController.java
index 9021a65e1..629dfcfd1 100644
--- a/pqs-algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/controller/Equipment/EquipmentDeliveryController.java
+++ b/pqs-algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/controller/Equipment/EquipmentDeliveryController.java
@@ -62,7 +62,7 @@ public class EquipmentDeliveryController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
- @PostMapping("/queryEquipmentByndid")
+ @PostMapping("/queryEquipmentByndid")
@ApiOperation("通过ndid查询出厂设备")
@ApiImplicitParam(name = "ndid", value = "网关识别码", required = true)
public HttpResult queryEquipmentByndid(@RequestParam("ndid")String ndid){
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 71a6315db..70b1641ea 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
@@ -25,6 +25,7 @@ public interface ServerInfo {
String QUALITY = "quality-boot";
String PROCESS = "process-boot";
String PREPARE_BOOT = "prepare-boot";
+ String ALGORITHM_BOOT = "algorithm-boot";
}