From 941c6c06850c287e2e99ac1cb2e0536906884d6a Mon Sep 17 00:00:00 2001 From: qiaoqinzheng Date: Wed, 10 Jan 2024 15:32:16 +0800 Subject: [PATCH] =?UTF-8?q?ftp=E8=B7=AF=E5=BE=84=E5=89=8D=E5=A4=9A?= =?UTF-8?q?=E6=8B=BC=E6=8E=A5=E4=BA=86/=E5=AF=BC=E8=87=B4=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E6=89=BE=E4=B8=8D=E5=88=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jeecg/common/util/GammaFileUtil.java | 2 +- .../jeecg/common/util/SelfStationUtil.java | 4 ++++ .../service/impl/GammaServiceImpl.java | 4 ++-- .../service/impl/SelfStationServiceImpl.java | 2 +- .../impl/SpectrumAnalysisServiceImpl.java | 22 +++++++++---------- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/GammaFileUtil.java b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/GammaFileUtil.java index d709ca18..3e30373b 100644 --- a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/GammaFileUtil.java +++ b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/GammaFileUtil.java @@ -3208,7 +3208,7 @@ public class GammaFileUtil extends AbstractLogOrReport { try { sampleTmp = new File(fileAnlyse.getTmpFilePath()); if (Objects.nonNull(sampleTmp)) { - bRet = ftpUtil.saveFile(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + middleData.analyses_save_filePath.substring(0, middleData.analyses_save_filePath.lastIndexOf(StringPool.SLASH)), middleData.analyses_save_filePath.substring(middleData.analyses_save_filePath.lastIndexOf(StringPool.SLASH)+1), new FileInputStream(sampleTmp)); + bRet = ftpUtil.saveFile(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + middleData.analyses_save_filePath.substring(0, middleData.analyses_save_filePath.lastIndexOf(StringPool.SLASH)), middleData.analyses_save_filePath.substring(middleData.analyses_save_filePath.lastIndexOf(StringPool.SLASH)+1), new FileInputStream(sampleTmp)); } } catch (FileNotFoundException e) { throw new RuntimeException(e); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/SelfStationUtil.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/SelfStationUtil.java index f01270a1..69b17c32 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/SelfStationUtil.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/SelfStationUtil.java @@ -257,6 +257,10 @@ public class SelfStationUtil extends AbstractLogOrReport { } } catch (Exception e) { e.printStackTrace(); + } finally { + if (Objects.nonNull(file)) { + file.delete(); + } } return struct; } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java index 55a945d6..b4567d48 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java @@ -1002,7 +1002,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi result.error500("The comparison file path does not exist"); return result; } - compareFilePath = StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + compareFilePath; + compareFilePath = ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + compareFilePath; File compareFile = ftpUtil.downloadFile(compareFilePath, "betaGamma"); if (Objects.isNull(compareFile)) { result.error500("The comparison file path does not exist"); @@ -1086,7 +1086,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi result.error500("The comparison file path does not exist"); return result; } - stripFilePath = StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + stripFilePath; + stripFilePath = ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + stripFilePath; File stripFile = ftpUtil.downloadFile(stripFilePath, "betaGamma"); if (Objects.isNull(stripFile)) { result.error500("The comparison file path does not exist"); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SelfStationServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SelfStationServiceImpl.java index 2e701ad5..fe000bbd 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SelfStationServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SelfStationServiceImpl.java @@ -49,7 +49,7 @@ public class SelfStationServiceImpl implements ISelfStationService { String userName = JwtUtil.getUserNameByToken(request); //解析文件 //上传文件路径 - String path = StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; + String path = ftpUtil.getFtpRootPath() + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; //获取自建台站缓存信息 Cache selfCache = selfStationCache.getSelfCache(); SelfStationData selfStationData = selfCache.getIfPresent(sampleFileName + StringPool.DASH + userName); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java index dced9e2f..3297a466 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java @@ -431,7 +431,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements List filePaths = new LinkedList<>(); //判断sample信息是否存在 if (Objects.nonNull(sample)) { - betaDataFile.setSampleFilePathName(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH +dbSpectrumFilePath.getSampleFilePath()); + betaDataFile.setSampleFilePathName(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH +dbSpectrumFilePath.getSampleFilePath()); betaDataFile.setSampleFileName(sampleFileName); sampleTmp = ftpUtil.downloadFile(betaDataFile.getSampleFilePathName(), "betaGamma"); if (Objects.nonNull(sampleTmp)) { @@ -445,7 +445,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements } //判断gas信息是否存在 if (Objects.nonNull(gasBg)) { - betaDataFile.setGasFilePathName(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH +dbSpectrumFilePath.getGasBgFilePath()); + betaDataFile.setGasFilePathName(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH +dbSpectrumFilePath.getGasBgFilePath()); betaDataFile.setGasFileName(gasFileName); gasTmp = ftpUtil.downloadFile(betaDataFile.getGasFilePathName(), "betaGamma"); if (Objects.nonNull(gasTmp)) { @@ -459,7 +459,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements } //判断det信息是否存在 if (Objects.nonNull(detBg)) { - betaDataFile.setDetFilePathName(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH +dbSpectrumFilePath.getDetBgFilePath()); + betaDataFile.setDetFilePathName(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH +dbSpectrumFilePath.getDetBgFilePath()); betaDataFile.setDetFileName(detFileName); detTmp = ftpUtil.downloadFile(betaDataFile.getDetFilePathName(), "betaGamma"); if (Objects.nonNull(detTmp)) { @@ -473,7 +473,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements } //判断qc信息是否存在 if (Objects.nonNull(qc)) { - betaDataFile.setQcFilePathName(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH +dbQcFilePath); + betaDataFile.setQcFilePathName(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH +dbQcFilePath); betaDataFile.setQcFileName(qcFileName); qcTmp = ftpUtil.downloadFile(betaDataFile.getQcFilePathName(), "betaGamma"); if (Objects.nonNull(qcTmp)) { @@ -552,7 +552,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements //获取用户名 String userName = JwtUtil.getUserNameByToken(request); //上传文件路径 - String path = StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; + String path = ftpUtil.getFtpRootPath() + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; Map resultMap = new HashMap<>(); Map sampleMap = new HashMap<>(); Map gasBgMap = new HashMap<>(); @@ -832,7 +832,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements InputStream inputStream = null; ServletOutputStream outputStream = null; try { - inputStream = ftpUtil.downloadFileStream(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + reportPath + ".txt"); + inputStream = ftpUtil.downloadFileStream(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + reportPath + ".txt"); if (Objects.nonNull(inputStream)){ outputStream = response.getOutputStream(); byte[] buffer = new byte[1024]; @@ -3676,7 +3676,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements InputStream inputStream = null; ServletOutputStream outputStream = null; try { - inputStream = ftpUtil.downloadFileStream(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getLogPath() + StringPool.SLASH + logPath); + inputStream = ftpUtil.downloadFileStream(ftpUtil.getFtpRootPath() + spectrumPathProperties.getLogPath() + StringPool.SLASH + logPath); if (Objects.nonNull(inputStream)){ outputStream = response.getOutputStream(); byte[] buffer = new byte[1024]; @@ -3964,19 +3964,19 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements try { if (StringUtils.isNotBlank(betaDataFile.getSampleTmpPath())) { File sampleTmp = new File(betaDataFile.getSampleTmpPath()); - ftpUtil.saveFile(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + sampleFilePathName.substring(0, sampleFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getSampleFileName(), new FileInputStream(sampleTmp)); + ftpUtil.saveFile(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + sampleFilePathName.substring(0, sampleFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getSampleFileName(), new FileInputStream(sampleTmp)); } if (StringUtils.isNotBlank(betaDataFile.getGasTmpPath())) { File gasTmp = new File(betaDataFile.getGasTmpPath()); - ftpUtil.saveFile(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + gasFilePathName.substring(0, gasFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getGasFileName(), new FileInputStream(gasTmp)); + ftpUtil.saveFile(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + gasFilePathName.substring(0, gasFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getGasFileName(), new FileInputStream(gasTmp)); } if (StringUtils.isNotBlank(betaDataFile.getDetTmpPath())) { File detTmp = new File(betaDataFile.getDetTmpPath()); - ftpUtil.saveFile(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + detFilePathName.substring(0, detFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getDetFileName(), new FileInputStream(detTmp)); + ftpUtil.saveFile(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + detFilePathName.substring(0, detFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getDetFileName(), new FileInputStream(detTmp)); } if (StringUtils.isNotBlank(betaDataFile.getQcTmpPath())) { File qcTmp = new File(betaDataFile.getQcTmpPath()); - ftpUtil.saveFile(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + qcFilePathName.substring(0, qcFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getQcFileName(), new FileInputStream(qcTmp)); + ftpUtil.saveFile(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + qcFilePathName.substring(0, qcFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getQcFileName(), new FileInputStream(qcTmp)); } } catch (FileNotFoundException e) { throw new RuntimeException(e);