ftp路径前多拼接了/导致文件找不到

This commit is contained in:
qiaoqinzheng 2024-01-10 15:32:16 +08:00
parent cadbdb3ba9
commit 941c6c0685
5 changed files with 19 additions and 15 deletions

View File

@ -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);

View File

@ -257,6 +257,10 @@ public class SelfStationUtil extends AbstractLogOrReport {
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (Objects.nonNull(file)) {
file.delete();
}
}
return struct;
}

View File

@ -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");

View File

@ -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<String, SelfStationData> selfCache = selfStationCache.getSelfCache();
SelfStationData selfStationData = selfCache.getIfPresent(sampleFileName + StringPool.DASH + userName);

View File

@ -431,7 +431,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
List<String> 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<String, Object> resultMap = new HashMap<>();
Map<String, Object> sampleMap = new HashMap<>();
Map<String, Object> 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);