From 563eb80b653ebaa9e7182fb4b57f62ddabeac29e Mon Sep 17 00:00:00 2001 From: hongawen <83944980@qq.com> Date: Tue, 4 Nov 2025 10:34:08 +0800 Subject: [PATCH] =?UTF-8?q?swagger=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ResultServiceImpl.java | 35 +++++++++++-------- .../user/user/filter/AuthGlobalFilter.java | 5 +-- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/detection/src/main/java/com/njcn/gather/result/service/impl/ResultServiceImpl.java b/detection/src/main/java/com/njcn/gather/result/service/impl/ResultServiceImpl.java index dd175992..47b6767b 100644 --- a/detection/src/main/java/com/njcn/gather/result/service/impl/ResultServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/result/service/impl/ResultServiceImpl.java @@ -2034,8 +2034,10 @@ public class ResultServiceImpl implements IResultService { int totalDataPoints = 0; // 统计总的数据点数 int zeroFilteredPoints = 0; // 统计双零过滤的数据点数 - // 遍历 2~50 次谐波 - for (int harmNum = 2; harmNum <= 50; harmNum++) { + // 间谐波从1开始,普通谐波从2开始 + int startHarmNum = isInterHarmonic ? 1 : 2; + // 遍历谐波次数 + for (int harmNum = startHarmNum; harmNum <= 50; harmNum++) { String harmKey = String.valueOf(harmNum); Map>> checkResultHarmonic = new LinkedHashMap<>(); List zeroFilteredPhases = new ArrayList<>(); // 当前次数被过滤的相别 @@ -2380,10 +2382,8 @@ public class ResultServiceImpl implements IResultService { contrastTestResult.setHarmonic(false); List allResult = new ArrayList<>(); Map> checkResultNonHarmonic = new LinkedHashMap<>(); - // 根据指标代码确定小数位数 Integer decimalPlaces = getDecimalPlacesByScriptCode(dictTree.getCode()); - try { // 非谐波的需要注意是否为T相还是ABC三相的 if (PowerConstant.T_PHASE.contains(dictTree.getCode())) { @@ -2509,27 +2509,22 @@ public class ResultServiceImpl implements IResultService { Map dataMap = new LinkedHashMap<>(); if (CollUtil.isNotEmpty(dataList)) { DetectionData detectionData = dataList.get(0); - // 相别 dataMap.put(ItemReportKeyEnum.PHASE.getKey(), phase); // 有效组数 todo... 目前是对齐组数 dataMap.put(ItemReportKeyEnum.NUM_OF_DATA.getKey(), String.valueOf(numOfData)); - // 标准值 - 根据参数决定是否格式化 String standardValue = String.valueOf(detectionData.getResultData()); if (decimalPlaces != null && detectionData.getResultData() != null) { standardValue = formatSignificantDigits(detectionData.getResultData(), decimalPlaces); } dataMap.put(ItemReportKeyEnum.STANDARD.getKey(), standardValue); - // 被检值 - 根据参数决定是否格式化 String testValue = String.valueOf(detectionData.getData()); if (decimalPlaces != null && detectionData.getData() != null) { testValue = formatSignificantDigits(detectionData.getData(), decimalPlaces); } dataMap.put(ItemReportKeyEnum.TEST.getKey(), testValue); - - // 误差 - 根据参数决定是否格式化 String errorValue = String.valueOf(detectionData.getErrorData()); if (decimalPlaces != null && detectionData.getErrorData() != null) { @@ -2538,7 +2533,6 @@ public class ResultServiceImpl implements IResultService { errorValue = "/"; } dataMap.put(ItemReportKeyEnum.ERROR.getKey(), errorValue); - // 误差范围 - 根据参数决定是否格式化 String errorScope = String.valueOf(detectionData.getRadius()); if (decimalPlaces != null && detectionData.getRadius() != null) { @@ -2547,7 +2541,6 @@ public class ResultServiceImpl implements IResultService { errorScope = "/"; } dataMap.put(ItemReportKeyEnum.A_ERROR_SCOPE.getKey(), errorScope); - // 结论 dataMap.put(ItemReportKeyEnum.RESULT.getKey(), getTestResult(detectionData.getIsData())); } else { @@ -2642,8 +2635,20 @@ public class ResultServiceImpl implements IResultService { Map dataMap = new LinkedHashMap<>(); if (CollUtil.isNotEmpty(dataList)) { DetectionData detectionData = dataList.get(0); - // 次数 - dataMap.put(ItemReportKeyEnum.TIME.getKey(), String.valueOf(harmNum)); + // 次数 - 从数据对象中获取实际次数(间谐波为1.5、2.5等) + String timeValue; + if (detectionData.getNum() != null) { + double numValue = detectionData.getNum(); + // 如果是整数,则只显示整数部分(如2.0显示为2) + if (numValue == Math.floor(numValue)) { + timeValue = String.valueOf((int) numValue); + } else { + timeValue = String.valueOf(numValue); + } + } else { + timeValue = String.valueOf(harmNum); + } + dataMap.put(ItemReportKeyEnum.TIME.getKey(), timeValue); // 相别 dataMap.put(ItemReportKeyEnum.PHASE.getKey(), phase); // 有效组数 todo... 目前是对齐组数 @@ -2684,7 +2689,7 @@ public class ResultServiceImpl implements IResultService { // 结论 dataMap.put(ItemReportKeyEnum.RESULT.getKey(), getTestResult(detectionData.getIsData())); } else { - // 次数 + // 次数 - 数据为空时用循环变量作为兜底 dataMap.put(ItemReportKeyEnum.TIME.getKey(), String.valueOf(harmNum)); // 相别 dataMap.put(ItemReportKeyEnum.PHASE.getKey(), phase); @@ -3596,7 +3601,7 @@ public class ResultServiceImpl implements IResultService { switch (scriptCode) { // 保留2位小数 case "FREQ": // 频率 - return 2; + return 4; // 保留3位小数 case "I": // 电流 return 3; diff --git a/user/src/main/java/com/njcn/gather/user/user/filter/AuthGlobalFilter.java b/user/src/main/java/com/njcn/gather/user/user/filter/AuthGlobalFilter.java index ea9ea77c..591803ad 100644 --- a/user/src/main/java/com/njcn/gather/user/user/filter/AuthGlobalFilter.java +++ b/user/src/main/java/com/njcn/gather/user/user/filter/AuthGlobalFilter.java @@ -6,6 +6,7 @@ import com.njcn.common.pojo.constant.SecurityConstants; import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.utils.JwtUtil; +import com.njcn.web.utils.HttpResultUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.core.Ordered; import org.springframework.stereotype.Component; @@ -24,7 +25,7 @@ import java.util.List; @Slf4j @Component public class AuthGlobalFilter implements Filter, Ordered { - private final static List IGNORE_URI = Arrays.asList("/doc.html", "/admin/login", "/admin/getPublicKey", "/report/generateReport"); + private final static List IGNORE_URI = Arrays.asList("/doc.html","/v3/api-docs","/admin/login","/admin/getPublicKey", "/report/generateReport"); @Override public int getOrder() { @@ -41,7 +42,7 @@ public class AuthGlobalFilter implements Filter, Ordered { res.setContentType("application/json; charset=utf-8"); String requestURI = req.getRequestURI(); - if (IGNORE_URI.contains(requestURI)) { + if (IGNORE_URI.contains(requestURI) || requestURI.startsWith("/webjars") || requestURI.startsWith("/swagger-resources")) { filterChain.doFilter(req, res); } else { String accessTokenStr = req.getHeader(SecurityConstants.AUTHORIZATION_KEY);