From e81413eaa9944d69ba230ed69e37a69c1f4b5b32 Mon Sep 17 00:00:00 2001 From: hongawen <83944980@qq.com> Date: Mon, 20 Oct 2025 13:37:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8A=A5=E5=91=8A=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E5=8F=8B=E5=A5=BD=E6=8F=90=E7=A4=BA=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/PqReportServiceImpl.java | 23 +++++++++++++++++++ .../system/pojo/enums/SystemResponseEnum.java | 4 +++- .../service/impl/CompareWaveServiceImpl.java | 1 + 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/detection/src/main/java/com/njcn/gather/report/service/impl/PqReportServiceImpl.java b/detection/src/main/java/com/njcn/gather/report/service/impl/PqReportServiceImpl.java index b8abd88c..a1bce574 100644 --- a/detection/src/main/java/com/njcn/gather/report/service/impl/PqReportServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/report/service/impl/PqReportServiceImpl.java @@ -67,6 +67,7 @@ import com.njcn.gather.system.cfg.pojo.enums.SceneEnum; import com.njcn.gather.system.cfg.service.ISysTestConfigService; import com.njcn.gather.system.dictionary.pojo.po.DictData; import com.njcn.gather.system.dictionary.service.IDictDataService; +import com.njcn.gather.system.pojo.enums.SystemResponseEnum; import com.njcn.gather.tools.report.model.constant.ReportConstant; import com.njcn.gather.tools.report.service.IWordReportService; import com.njcn.gather.tools.report.util.BookmarkUtil; @@ -108,6 +109,7 @@ import java.math.BigInteger; import java.math.RoundingMode; import java.net.URLEncoder; import java.nio.file.Files; +import java.nio.file.NoSuchFileException; import java.nio.file.Path; import java.nio.file.Paths; import java.time.LocalDateTime; @@ -639,6 +641,13 @@ public class PqReportServiceImpl extends ServiceImpl i } } }); + } catch (NoSuchFileException e) { + String filePath = e.getFile() != null ? e.getFile().replaceAll("\\\\", "/") : "未知文件"; + log.error("报告模板文件不存在 - 文件路径: {}", filePath, e); + throw new BusinessException(SystemResponseEnum.FILE_NOT_FOUND); + } catch (IOException e) { + log.error("报告文件读写异常", e); + throw new BusinessException(SystemResponseEnum.FILE_IO_ERROR); } catch (Exception e) { log.error(ReportResponseEnum.GENERATE_REPORT_ERROR.getMessage(), e); throw new BusinessException(ReportResponseEnum.GENERATE_REPORT_ERROR); @@ -814,6 +823,13 @@ public class PqReportServiceImpl extends ServiceImpl i Docx4jUtil.cleanBlankPagesAndRedundantPageBreaks(baseModelDocument); baseModelDocument.save(new File(dirPath.concat(File.separator).concat(fileName))); this.updateDevAndPlanState(devId, devReportParam.getPlanId()); + } catch (NoSuchFileException e) { + String filePath = e.getFile() != null ? e.getFile().replaceAll("\\\\", "/") : "未知文件"; + log.error("报告模板文件不存在 - 文件路径: {}", filePath, e); + throw new BusinessException(SystemResponseEnum.FILE_NOT_FOUND); + } catch (IOException e) { + log.error("报告文件读写异常", e); + throw new BusinessException(SystemResponseEnum.FILE_IO_ERROR); } catch (Exception e) { log.error(ReportResponseEnum.GENERATE_REPORT_ERROR.getMessage(), e); throw new BusinessException(ReportResponseEnum.GENERATE_REPORT_ERROR); @@ -869,6 +885,13 @@ public class PqReportServiceImpl extends ServiceImpl i ensureDirectoryExists(dirPath); baseModelDocument.save(new File(dirPath.concat(File.separator).concat(pqDevVO.getCreateId()).concat(ReportConstant.DOCX))); this.updateDevAndPlanState(devId, devReportParam.getPlanId()); + } catch (NoSuchFileException e) { + String filePath = e.getFile() != null ? e.getFile().replaceAll("\\\\", "/") : "未知文件"; + log.error("报告模板文件不存在 - 文件路径: {}", filePath, e); + throw new BusinessException(SystemResponseEnum.FILE_NOT_FOUND); + } catch (IOException e) { + log.error("报告文件读写异常", e); + throw new BusinessException(SystemResponseEnum.FILE_IO_ERROR); } catch (Exception e) { log.error(ReportResponseEnum.GENERATE_REPORT_ERROR.getMessage(), e); throw new BusinessException(ReportResponseEnum.GENERATE_REPORT_ERROR); diff --git a/system/src/main/java/com/njcn/gather/system/pojo/enums/SystemResponseEnum.java b/system/src/main/java/com/njcn/gather/system/pojo/enums/SystemResponseEnum.java index 6d471b58..5570429b 100644 --- a/system/src/main/java/com/njcn/gather/system/pojo/enums/SystemResponseEnum.java +++ b/system/src/main/java/com/njcn/gather/system/pojo/enums/SystemResponseEnum.java @@ -27,7 +27,9 @@ public enum SystemResponseEnum { GET_MAC_ADDRESS_FAILED("A01040", "获取本机MAC地址失败"), REGISTRATION_CODE_FORMAT_ERROR("A01041", "注册码格式错误"), MAC_ADDRESS_NOT_MATCH("A01042","注册码中的MAC地址与本机MAC地址不匹配"), - REGISTRATION_CODE_EXPIRED("A01043","注册码已过期"),; + REGISTRATION_CODE_EXPIRED("A01043","注册码已过期"), + FILE_NOT_FOUND("A01050", "模板文件不存在"), + FILE_IO_ERROR("A01051", "文件读写异常"),; private final String code; diff --git a/tools/wave-comtrade/src/main/java/com/njcn/gather/tools/comtrade/comparewave/service/impl/CompareWaveServiceImpl.java b/tools/wave-comtrade/src/main/java/com/njcn/gather/tools/comtrade/comparewave/service/impl/CompareWaveServiceImpl.java index e398f7da..d2b55510 100644 --- a/tools/wave-comtrade/src/main/java/com/njcn/gather/tools/comtrade/comparewave/service/impl/CompareWaveServiceImpl.java +++ b/tools/wave-comtrade/src/main/java/com/njcn/gather/tools/comtrade/comparewave/service/impl/CompareWaveServiceImpl.java @@ -427,6 +427,7 @@ public class CompareWaveServiceImpl implements ICompareWaveService { if (sourceLowSampleRate || targetLowSampleRate) { log.warn("窗口 {} - 采样率过低(源文件: {}点/周波, 目标文件: {}点/周波, 最小要求128),该窗口被丢弃", window, sourceSampleRate, targetSampleRate); + // 推进位置到下一个窗口 sourceCurrentPos = sourceWindowEnd;