From eb068b76a487dcede0dcd6610d7178d12fdaf213 Mon Sep 17 00:00:00 2001 From: caozehui <2427765068@qq.com> Date: Tue, 9 Dec 2025 16:18:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=A5=E5=91=8A=E6=A8=A1=E6=9D=BF=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SocketContrastResponseService.java | 41 ++-------------- .../service/impl/PreDetectionServiceImpl.java | 4 +- .../service/impl/PqReportServiceImpl.java | 47 ++++++++++--------- 3 files changed, 30 insertions(+), 62 deletions(-) diff --git a/detection/src/main/java/com/njcn/gather/detection/handler/SocketContrastResponseService.java b/detection/src/main/java/com/njcn/gather/detection/handler/SocketContrastResponseService.java index 9fd87441..76ae946e 100644 --- a/detection/src/main/java/com/njcn/gather/detection/handler/SocketContrastResponseService.java +++ b/detection/src/main/java/com/njcn/gather/detection/handler/SocketContrastResponseService.java @@ -120,7 +120,7 @@ public class SocketContrastResponseService { // private SysRegRes contrastRegRes = null; - @Value("${log.homeDir}") + @Value("${report.reportDir}") private String alignDataFilePath; public static final Map> testItemCodeMap = new HashMap() {{ @@ -182,8 +182,8 @@ public class SocketContrastResponseService { FormalTestManager.pstDataType = null; FormalTestManager.isPstData = false; FormalTestManager.isWaveCheck = false; -// FormalTestManager.isXu = param.getPhaseCheck() == 1 ? true : false; - FormalTestManager.isXu = true; + FormalTestManager.isXu = param.getPhaseCheck() == 1 ? true : false; +// FormalTestManager.isXu = true; FormalTestManager.nonWaveDataSourceEnum = null; String[] datasourceIds = FormalTestManager.currentTestPlan.getDatasourceId().split(","); @@ -1230,39 +1230,6 @@ public class SocketContrastResponseService { } } this.setScheduler(targetCount, param.getUserPageId(), requestOperateCode, quitOperateCode); -// if (Objects.isNull(FormalTestManager.scheduler)) { -// FormalTestManager.scheduler = Executors.newScheduledThreadPool(1); -// long delay = this.getDelay(targetCount); -// FormalTestManager.scheduledFuture = FormalTestManager.scheduler.schedule(() -> { -// if (!checkResult) { -// System.out.println("正式检测-" + delay + "s内收集数据不完整!"); -// // 断开与设备的连接,但是不要将Socket移除 -// if (FormalTestManager.statisticsProtocol && quitOperateCode == SourceOperateCodeEnum.QUIT_INIT_02) { -// CnSocketUtil.contrastSendquit(param.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_01, false); -// } -// if (FormalTestManager.voltageProtocol) { -// CnSocketUtil.contrastSendquit(param.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_03, false); -// } -// CnSocketUtil.contrastSendquit(param.getUserPageId(), quitOperateCode, false); -// FormalTestManager.isTesting = false; -// -// this.clearData(); -// -// Collection disjunction = CollectionUtil.disjunction(FormalTestManager.pairsIpMap.keySet(), successPair.keySet()); -// // 向前端推送收集数据不完整的配对项 -// for (String key : disjunction) { -// webSend.setCode(SourceResponseCodeEnum.FAIL.getCode()); -// webSend.setData(MsgUtil.getPairStr(key, FormalTestManager.pairsIpMap.inverse().get(key), FormalTestManager.devNameMapComm) + " 数据收集不完整!"); -// WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(webSend)); -// } -// // 推送最终失败结果 -// webSend.setCode(SourceResponseCodeEnum.ALL_FAIL.getCode());//最终错误推送 -// WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(webSend)); -// } -// FormalTestManager.scheduler.shutdown(); -// FormalTestManager.scheduler = null; -// }, delay, TimeUnit.SECONDS); -// } String monitorId1 = devData.getId(); String devMonitorId = monitorId1; @@ -2149,7 +2116,7 @@ public class SocketContrastResponseService { }); }); - ExcelUtil.saveExcel(alignDataFilePath, "实时数据.xlsx", sheetsList); + ExcelUtil.saveExcel(alignDataFilePath, "对齐数据.xlsx", sheetsList); } /** diff --git a/detection/src/main/java/com/njcn/gather/detection/service/impl/PreDetectionServiceImpl.java b/detection/src/main/java/com/njcn/gather/detection/service/impl/PreDetectionServiceImpl.java index f1e2b1bf..a523787b 100644 --- a/detection/src/main/java/com/njcn/gather/detection/service/impl/PreDetectionServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/detection/service/impl/PreDetectionServiceImpl.java @@ -76,7 +76,7 @@ public class PreDetectionServiceImpl implements PreDetectionService { private final IPqScriptCheckDataService iPqScriptCheckDataService; private final SocketManager socketManager; - @Value("${log.homeDir}") + @Value("${report.reportDir}") private String alignDataFilePath; @@ -337,7 +337,7 @@ public class PreDetectionServiceImpl implements PreDetectionService { @Override public void exportAlignData() { - String fileName = "实时数据.xlsx"; + String fileName = "对齐数据.xlsx"; HttpServletResponse response = HttpServletUtil.getResponse(); response.reset(); response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\""); 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 c1e8196f..972f11e1 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 @@ -310,7 +310,8 @@ public class PqReportServiceImpl extends ServiceImpl i private void uploadFile(ReportParam reportParam, PqReport pqReport, boolean isAdd) { MultipartFile baseFile = reportParam.getBaseFile(); MultipartFile detailFile = reportParam.getDetailFile(); - String newDir = templatePath + File.separator + reportParam.getName() + File.separator + reportParam.getVersion() + File.separator; + String relativePath = File.separator + reportParam.getName() + File.separator + reportParam.getVersion() + File.separator; + String newDir = templatePath + relativePath; long FILE_SIZE_LIMIT = 5 * 1024 * 1024; if (isAdd) { @@ -329,13 +330,13 @@ public class PqReportServiceImpl extends ServiceImpl i throw new BusinessException(ReportResponseEnum.FILE_SIZE_ERROR); } - pqReport.setBasePath(newDir + baseOriginalFilename); - pqReport.setDetailPath(newDir + detailOriginalFilename); + pqReport.setBasePath(relativePath + baseOriginalFilename); + pqReport.setDetailPath(relativePath + detailOriginalFilename); this.createDirectory(newDir); this.clearDirectory(newDir); - this.uploadFile(baseFile, pqReport.getBasePath()); - this.uploadFile(detailFile, pqReport.getDetailPath()); + this.uploadFile(baseFile, newDir + baseOriginalFilename); + this.uploadFile(detailFile, newDir + detailOriginalFilename); } else { throw new BusinessException(ReportResponseEnum.FILE_NOT_NULL); } @@ -383,34 +384,34 @@ public class PqReportServiceImpl extends ServiceImpl i //若修改了文件名称、版本号,则需要重命名文件 this.createDirectory(newDir); - if (!oldDir.equals(newDir)) { + if (!oldDir.equals(relativePath)) { // 文件夹重命名 String oldBasePathStr = oldPqReport.getBasePath(); String baseName = oldBasePathStr.substring(oldBasePathStr.lastIndexOf(File.separator) + 1); - Path oldBasePath = Paths.get(oldBasePathStr); + Path oldBasePath = Paths.get(templatePath + oldBasePathStr); Path newBasePath = Paths.get(newDir + baseName); - pqReport.setBasePath(newDir + baseName); + pqReport.setBasePath(relativePath + baseName); String oldDetailPathStr = oldPqReport.getDetailPath(); String detailName = oldDetailPathStr.substring(oldDetailPathStr.lastIndexOf(File.separator) + 1); - Path oldDetailPath = Paths.get(oldDetailPathStr); + Path oldDetailPath = Paths.get(templatePath + oldDetailPathStr); Path newDetailPath = Paths.get(newDir + detailName); - pqReport.setDetailPath(newDir + detailName); + pqReport.setDetailPath(relativePath + detailName); try { // windows下文件夹名称不区分大小写 - if (!oldDir.equalsIgnoreCase(newDir)) { + if (!oldDir.equalsIgnoreCase(relativePath)) { this.clearDirectory(newDir); Files.move(oldBasePath, newBasePath); Files.move(oldDetailPath, newDetailPath); if (!oldPqReport.getName().equals(reportParam.getName()) && !this.existSameName(pqReport.getId(), oldPqReport.getName())) { this.recursionDeleteDirectory(templatePath + File.separator + oldPqReport.getName()); } else { - Paths.get(oldDir).toFile().delete(); + Paths.get(templatePath + oldDir).toFile().delete(); } } else { // 文件夹重命名 - Paths.get(oldDir).toFile().renameTo(Paths.get(newDir).toFile()); + Paths.get(templatePath + oldDir).toFile().renameTo(Paths.get(newDir).toFile()); } } catch (IOException e) { throw new BusinessException(ReportResponseEnum.FILE_RENAME_FAILED); @@ -418,16 +419,16 @@ public class PqReportServiceImpl extends ServiceImpl i } if (!baseFileOriginalFilename.isEmpty()) { - pqReport.setBasePath(newDir + baseFileOriginalFilename); - Paths.get(oldPqReport.getBasePath()).toFile().delete(); + pqReport.setBasePath(relativePath + baseFileOriginalFilename); + Paths.get(templatePath + oldPqReport.getBasePath()).toFile().delete(); Paths.get(newDir + oldPqReport.getBasePath().substring(oldPqReport.getBasePath().lastIndexOf(File.separator) + 1)).toFile().delete(); - this.uploadFile(baseFile, pqReport.getBasePath()); + this.uploadFile(baseFile, newDir + baseFileOriginalFilename); } if (!detailFileOriginalFilename.isEmpty()) { - pqReport.setDetailPath(newDir + detailFileOriginalFilename); - Paths.get(oldPqReport.getDetailPath()).toFile().delete(); + pqReport.setDetailPath(relativePath + detailFileOriginalFilename); + Paths.get(templatePath + oldPqReport.getDetailPath()).toFile().delete(); Paths.get(newDir + oldPqReport.getDetailPath().substring(oldPqReport.getDetailPath().lastIndexOf(File.separator) + 1)).toFile().delete(); - this.uploadFile(detailFile, pqReport.getDetailPath()); + this.uploadFile(detailFile, newDir + detailFileOriginalFilename); } } } @@ -800,8 +801,8 @@ public class PqReportServiceImpl extends ServiceImpl i if (Objects.isNull(report)) { throw new BusinessException(ReportResponseEnum.REPORT_TEMPLATE_NOT_EXIST); } - Path basePath = Paths.get(report.getBasePath()); - Path detailPath = Paths.get(report.getDetailPath()); + Path basePath = Paths.get(templatePath + report.getBasePath()); + Path detailPath = Paths.get(templatePath + report.getDetailPath()); try (InputStream baseInputStream = Files.newInputStream(basePath); InputStream detailInputStream = Files.newInputStream(detailPath)) { WordprocessingMLPackage detailModelDocument = WordprocessingMLPackage.load(detailInputStream); @@ -877,8 +878,8 @@ public class PqReportServiceImpl extends ServiceImpl i if (Objects.isNull(report)) { throw new BusinessException(ReportResponseEnum.REPORT_TEMPLATE_NOT_EXIST); } - Path basePath = Paths.get(report.getBasePath()); - Path detailPath = Paths.get(report.getDetailPath()); + Path basePath = Paths.get(templatePath + report.getBasePath()); + Path detailPath = Paths.get(templatePath + report.getDetailPath()); try (InputStream baseInputStream = Files.newInputStream(basePath); InputStream detailInputStream = Files.newInputStream(detailPath)) { WordprocessingMLPackage detailModelDocument = WordprocessingMLPackage.load(detailInputStream);