From c7b6d4022cd5f28afa45c2696a597a2435c0ef34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=A8=E6=9C=A8c?= <857448963@qq.com> Date: Wed, 17 May 2023 17:17:15 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=90=E5=80=BC=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pqs-device/common-device-biz/pom.xml | 7 +++ .../biz/commApi/CommLedgerDeptClient.java | 41 ++++++++++++ .../CommLedgerDeptClientFallbackFactory.java | 44 +++++++++++++ ...mTerminalGeneralClientFallbackFactory.java | 4 +- .../njcn/device/biz/pojo/po/Overlimit.java | 54 ++++++++++++++++ .../njcn/device/biz/utils/COverlimitUtil.java | 62 +++---------------- pqs-device/pms-device/pms-device-boot/pom.xml | 8 +-- pqs-device/pq-device/pq-device-boot/pom.xml | 8 +-- 8 files changed, 160 insertions(+), 68 deletions(-) create mode 100644 pqs-device/common-device-biz/src/main/java/com/njcn/device/biz/commApi/CommLedgerDeptClient.java create mode 100644 pqs-device/common-device-biz/src/main/java/com/njcn/device/biz/commApi/fallback/CommLedgerDeptClientFallbackFactory.java diff --git a/pqs-device/common-device-biz/pom.xml b/pqs-device/common-device-biz/pom.xml index 526b99636..e663ab869 100644 --- a/pqs-device/common-device-biz/pom.xml +++ b/pqs-device/common-device-biz/pom.xml @@ -43,11 +43,18 @@ org.influxdb influxdb-java + com.njcn system-api ${project.version} + + + com.njcn + user-api + ${project.version} + diff --git a/pqs-device/common-device-biz/src/main/java/com/njcn/device/biz/commApi/CommLedgerDeptClient.java b/pqs-device/common-device-biz/src/main/java/com/njcn/device/biz/commApi/CommLedgerDeptClient.java new file mode 100644 index 000000000..7394c7d1b --- /dev/null +++ b/pqs-device/common-device-biz/src/main/java/com/njcn/device/biz/commApi/CommLedgerDeptClient.java @@ -0,0 +1,41 @@ +package com.njcn.device.biz.commApi; + +import com.njcn.common.pojo.constant.ServerInfo; +import com.njcn.common.pojo.response.HttpResult; +import com.njcn.device.biz.commApi.fallback.CommLedgerDeptClientFallbackFactory; +import com.njcn.device.biz.commApi.fallback.CommTerminalGeneralClientFallbackFactory; +import com.njcn.device.biz.pojo.dto.*; +import com.njcn.device.biz.pojo.param.DeptGetLineParam; +import com.njcn.user.pojo.po.Dept; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.List; + +/** + * + * @author cdf + * @date 2023/4/24 + */ +@FeignClient( + value = ServerInfo.DEVICE, + path = "pmsLedger", + fallbackFactory = CommLedgerDeptClientFallbackFactory.class) +public interface CommLedgerDeptClient { + + + /** + * + * @author cdf + * @date 2023/5/15 + */ + @PostMapping("update") + HttpResult update(@RequestBody Dept dept); + + + + +} diff --git a/pqs-device/common-device-biz/src/main/java/com/njcn/device/biz/commApi/fallback/CommLedgerDeptClientFallbackFactory.java b/pqs-device/common-device-biz/src/main/java/com/njcn/device/biz/commApi/fallback/CommLedgerDeptClientFallbackFactory.java new file mode 100644 index 000000000..141ca1bbe --- /dev/null +++ b/pqs-device/common-device-biz/src/main/java/com/njcn/device/biz/commApi/fallback/CommLedgerDeptClientFallbackFactory.java @@ -0,0 +1,44 @@ +package com.njcn.device.biz.commApi.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.device.biz.commApi.CommLedgerDeptClient; +import com.njcn.device.biz.utils.DeviceEnumUtil; +import com.njcn.user.pojo.po.Dept; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * 公共 + * @author cdf + * @date 2023/5/17 + */ +@Slf4j +@Component +public class CommLedgerDeptClientFallbackFactory implements FallbackFactory { + @Override + public CommLedgerDeptClient create(Throwable throwable) { + //判断抛出异常是否为解码器抛出的业务异常 + Enum exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK; + if (throwable.getCause() instanceof BusinessException) { + BusinessException businessException = (BusinessException) throwable.getCause(); + exceptionEnum = DeviceEnumUtil.getExceptionEnum(businessException.getResult()); + } + Enum finalExceptionEnum = exceptionEnum; + + return new CommLedgerDeptClient() { + @Override + public HttpResult update(Dept dept) { + log.error("{}异常,降级处理,异常为:{}", "通过部门获取所有子级部门详情", throwable.toString()); + throw new BusinessException(finalExceptionEnum); + } + + + }; + } +} + diff --git a/pqs-device/common-device-biz/src/main/java/com/njcn/device/biz/commApi/fallback/CommTerminalGeneralClientFallbackFactory.java b/pqs-device/common-device-biz/src/main/java/com/njcn/device/biz/commApi/fallback/CommTerminalGeneralClientFallbackFactory.java index ce8ec7bba..c67370b33 100644 --- a/pqs-device/common-device-biz/src/main/java/com/njcn/device/biz/commApi/fallback/CommTerminalGeneralClientFallbackFactory.java +++ b/pqs-device/common-device-biz/src/main/java/com/njcn/device/biz/commApi/fallback/CommTerminalGeneralClientFallbackFactory.java @@ -14,8 +14,8 @@ import org.springframework.stereotype.Component; import java.util.List; /** - * 告警管理熔断降级 - * @author yzh + * 公共台账 + * @author cdf * @date 2022/9/19 */ @Slf4j diff --git a/pqs-device/common-device-biz/src/main/java/com/njcn/device/biz/pojo/po/Overlimit.java b/pqs-device/common-device-biz/src/main/java/com/njcn/device/biz/pojo/po/Overlimit.java index 9c6945f2c..06757bdc5 100644 --- a/pqs-device/common-device-biz/src/main/java/com/njcn/device/biz/pojo/po/Overlimit.java +++ b/pqs-device/common-device-biz/src/main/java/com/njcn/device/biz/pojo/po/Overlimit.java @@ -893,4 +893,58 @@ public class Overlimit implements Serializable { this.iharm49= iHarmTem[47]; } + public void buildUharm(Float resultEven,Float resultOdd){ + this.uharm2=resultEven; + this.uharm4=resultEven; + this.uharm6=resultEven; + this.uharm8=resultEven; + this.uharm10=resultEven; + this.uharm12=resultEven; + this.uharm14=resultEven; + this.uharm16=resultEven; + this.uharm18=resultEven; + this.uharm20=resultEven; + this.uharm22=resultEven; + this.uharm24=resultEven; + this.uharm26=resultEven; + this.uharm28=resultEven; + this.uharm30=resultEven; + this.uharm32=resultEven; + this.uharm34=resultEven; + this.uharm36=resultEven; + this.uharm38=resultEven; + this.uharm40=resultEven; + this.uharm42=resultEven; + this.uharm44=resultEven; + this.uharm46=resultEven; + this.uharm48=resultEven; + this.uharm50=resultEven; + + + this.uharm3=resultOdd; + this.uharm5=resultOdd; + this.uharm7=resultOdd; + this.uharm9=resultOdd; + this.uharm11=resultOdd; + this.uharm13=resultOdd; + this.uharm15=resultOdd; + this.uharm17=resultOdd; + this.uharm19=resultOdd; + this.uharm21=resultOdd; + this.uharm23=resultOdd; + this.uharm25=resultOdd; + this.uharm27=resultOdd; + this.uharm29=resultOdd; + this.uharm31=resultOdd; + this.uharm33=resultOdd; + this.uharm35=resultOdd; + this.uharm37=resultOdd; + this.uharm39=resultOdd; + this.uharm41=resultOdd; + this.uharm43=resultOdd; + this.uharm45=resultOdd; + this.uharm47=resultOdd; + this.uharm49=resultOdd; + } + } diff --git a/pqs-device/common-device-biz/src/main/java/com/njcn/device/biz/utils/COverlimitUtil.java b/pqs-device/common-device-biz/src/main/java/com/njcn/device/biz/utils/COverlimitUtil.java index f11879aa1..d01247fd9 100644 --- a/pqs-device/common-device-biz/src/main/java/com/njcn/device/biz/utils/COverlimitUtil.java +++ b/pqs-device/common-device-biz/src/main/java/com/njcn/device/biz/utils/COverlimitUtil.java @@ -32,8 +32,14 @@ public class COverlimitUtil { /** * 计算监测点限值 + * @param voltageLevel 电压等级(10kV = 10 220kV = 220 ) + * @param protocolCapacity 协议容量 + * @param devCapacity 设备容量 + * @param shortCapacity 短路容量 + * @param powerFlag 0.用户侧 1.电网侧 + * @param lineType 0.主网 1.配网 */ - public static Overlimit globalAssemble(Float voltageLevel,Float protocolCapacity,Float devCapacity,Float shortCapacity) { + public static Overlimit globalAssemble(Float voltageLevel,Float protocolCapacity,Float devCapacity,Float shortCapacity,Integer powerFlag,Integer lineType) { Overlimit overlimit = new Overlimit(); voltageDeviation(overlimit,voltageLevel); frequency(overlimit); @@ -160,59 +166,7 @@ public class COverlimitUtil { resultOdd = 1.6f; resultEven = 0.8f; } - overlimit.setUharm2(resultEven); - overlimit.setUharm4(resultEven); - overlimit.setUharm6(resultEven); - overlimit.setUharm8(resultEven); - overlimit.setUharm10(resultEven); - overlimit.setUharm12(resultEven); - overlimit.setUharm14(resultEven); - overlimit.setUharm16(resultEven); - overlimit.setUharm18(resultEven); - overlimit.setUharm20(resultEven); - overlimit.setUharm22(resultEven); - overlimit.setUharm24(resultEven); - overlimit.setUharm26(resultEven); - overlimit.setUharm28(resultEven); - overlimit.setUharm30(resultEven); - overlimit.setUharm32(resultEven); - overlimit.setUharm34(resultEven); - overlimit.setUharm36(resultEven); - overlimit.setUharm38(resultEven); - overlimit.setUharm40(resultEven); - overlimit.setUharm42(resultEven); - overlimit.setUharm44(resultEven); - overlimit.setUharm46(resultEven); - overlimit.setUharm48(resultEven); - overlimit.setUharm50(resultEven); - - - - overlimit.setUharm3(resultOdd); - overlimit.setUharm5(resultOdd); - overlimit.setUharm7(resultOdd); - overlimit.setUharm9(resultOdd); - overlimit.setUharm11(resultOdd); - overlimit.setUharm13(resultOdd); - overlimit.setUharm15(resultOdd); - overlimit.setUharm17(resultOdd); - overlimit.setUharm19(resultOdd); - overlimit.setUharm21(resultOdd); - overlimit.setUharm23(resultOdd); - overlimit.setUharm25(resultOdd); - overlimit.setUharm27(resultOdd); - overlimit.setUharm29(resultOdd); - overlimit.setUharm31(resultOdd); - overlimit.setUharm33(resultOdd); - overlimit.setUharm35(resultOdd); - overlimit.setUharm37(resultOdd); - overlimit.setUharm39(resultOdd); - overlimit.setUharm41(resultOdd); - overlimit.setUharm43(resultOdd); - overlimit.setUharm45(resultOdd); - overlimit.setUharm47(resultOdd); - overlimit.setUharm49(resultOdd); - + overlimit.buildUharm(resultEven,resultOdd); } diff --git a/pqs-device/pms-device/pms-device-boot/pom.xml b/pqs-device/pms-device/pms-device-boot/pom.xml index d18e83f10..dde0351fa 100644 --- a/pqs-device/pms-device/pms-device-boot/pom.xml +++ b/pqs-device/pms-device/pms-device-boot/pom.xml @@ -24,11 +24,7 @@ pms-device-api ${project.version} - - com.njcn - user-api - ${project.version} - + com.njcn system-api @@ -62,4 +58,4 @@ - \ No newline at end of file + diff --git a/pqs-device/pq-device/pq-device-boot/pom.xml b/pqs-device/pq-device/pq-device-boot/pom.xml index 930868d69..3fad2704d 100644 --- a/pqs-device/pq-device/pq-device-boot/pom.xml +++ b/pqs-device/pq-device/pq-device-boot/pom.xml @@ -23,11 +23,7 @@ pq-device-api ${project.version} - - com.njcn - user-api - ${project.version} - + com.njcn system-api @@ -61,4 +57,4 @@ - \ No newline at end of file +