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 9629b77d..9d78a781 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 @@ -1983,9 +1983,9 @@ public class ResultServiceImpl implements IResultService { if (isZeroFiltered) { zeroFilteredPoints++; // 统计双零点 // 双零情况,记录但不加入结果判定 - zeroFilteredPhases.add(phase.toUpperCase() + "相"); - // 将结果改为特殊标记,不参与整体结论判定 - singlePhaseData.put(ItemReportKeyEnum.RESULT.getKey(), "双零过滤"); + zeroFilteredPhases.add(phase.toUpperCase() + "相"); + // 将结果改为特殊标记,不参与整体结论判定 + singlePhaseData.put(ItemReportKeyEnum.RESULT.getKey(), "/"); } else { // 有非双零数据 hasNonZeroData = true; diff --git a/system/src/main/java/com/njcn/gather/system/config/handler/GlobalBusinessExceptionHandler.java b/system/src/main/java/com/njcn/gather/system/config/handler/GlobalBusinessExceptionHandler.java index 8b419feb..71d1e095 100644 --- a/system/src/main/java/com/njcn/gather/system/config/handler/GlobalBusinessExceptionHandler.java +++ b/system/src/main/java/com/njcn/gather/system/config/handler/GlobalBusinessExceptionHandler.java @@ -7,6 +7,7 @@ import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.utils.LogUtil; import com.njcn.gather.system.log.service.ISysLogAuditService; +import com.njcn.gather.system.pojo.enums.SystemResponseEnum; import com.njcn.web.utils.HttpResultUtil; import com.njcn.web.utils.HttpServletUtil; import com.njcn.web.utils.ReflectCommonUtil; @@ -24,6 +25,8 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.validation.ConstraintViolation; import javax.validation.ConstraintViolationException; +import java.io.IOException; +import java.nio.file.NoSuchFileException; import java.util.ArrayList; import java.util.List; import java.util.concurrent.*; @@ -115,6 +118,41 @@ public class GlobalBusinessExceptionHandler { return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.INDEX_OUT_OF_BOUNDS_EXCEPTION, null, ReflectCommonUtil.getMethodDescribeByException(indexOutOfBoundsException)); } + /** + * 文件未找到异常捕捉 + * + * @param noSuchFileException 文件未找到异常 + */ + @ExceptionHandler(NoSuchFileException.class) + public HttpResult handleNoSuchFileException(NoSuchFileException noSuchFileException) { + String filePath = noSuchFileException.getFile(); + // 日志记录详细路径,用于后端排查 + log.warn("文件未找到异常 - 文件路径: {}", filePath, noSuchFileException); + recodeBusinessExceptionLog(noSuchFileException, SystemResponseEnum.FILE_NOT_FOUND.getMessage()); + return HttpResultUtil.assembleResult(SystemResponseEnum.FILE_NOT_FOUND.getCode(), null, + StrFormatter.format("{}{}{}", ReflectCommonUtil.getMethodDescribeByException(noSuchFileException), + StrUtil.C_COMMA, SystemResponseEnum.FILE_NOT_FOUND.getMessage())); + } + + /** + * 文件IO异常捕捉(通用IOException,排除NoSuchFileException) + * + * @param ioException IO异常 + */ + @ExceptionHandler(IOException.class) + public HttpResult handleIOException(IOException ioException) { + // 排除 NoSuchFileException,已由专门的处理器处理 + if (ioException instanceof NoSuchFileException) { + return handleNoSuchFileException((NoSuchFileException) ioException); + } + // 日志记录详细异常信息,用于后端排查 + LogUtil.logExceptionStackInfo(SystemResponseEnum.FILE_IO_ERROR.getMessage(), ioException); + recodeBusinessExceptionLog(ioException, SystemResponseEnum.FILE_IO_ERROR.getMessage()); + return HttpResultUtil.assembleResult(SystemResponseEnum.FILE_IO_ERROR.getCode(), null, + StrFormatter.format("{}{}{}", ReflectCommonUtil.getMethodDescribeByException(ioException), + StrUtil.C_COMMA, SystemResponseEnum.FILE_IO_ERROR.getMessage())); + } + /** * 前端请求后端,请求中参数的媒体方式不支持异常 *