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"; }