diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumFileServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumFileServiceImpl.java index fc672da4..692bb221 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumFileServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumFileServiceImpl.java @@ -34,6 +34,7 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.*; +import java.util.regex.Pattern; import java.util.stream.Collectors; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -65,6 +66,10 @@ public class SpectrumFileServiceImpl implements ISpectrumFileService { String tempFilePath = System.getProperty("java.io.tmpdir") + username + slash; List fileNames = new ArrayList<>(); List fileList = new ArrayList<>(); + String sampleRx = "[a-zA-Z]{3}[0-9]{2}_[0-9]{3}-[0-9]{8}_[0-9]{4}_S_(FULL_|PREL_)\\d+\\.PHD"; + Pattern regexPattern = Pattern.compile(sampleRx); + String sampleRx1 = "[a-zA-Z]{3}[0-9]{2}_[0-9]{3}-[0-9]{8}_[0-9]{4}_S_(FULL_|PREL_)\\d+\\.\\d+\\.PHD"; + Pattern regexPattern1 = Pattern.compile(sampleRx1); try{ File tempDir = new File(tempFilePath); if (!tempDir.exists()) tempDir.mkdir(); @@ -92,9 +97,12 @@ public class SpectrumFileServiceImpl implements ISpectrumFileService { if (!created) return Result.error(Prompt.DIR_CREATE_FAIL + filePath); // 上传所有文件 for (File oneFile : fileList) { - EnergySpectrumStruct struct = phdFileUtil.analyzeFileSourceData(oneFile); - String suffix = nameStandUtil.GetSuffix(struct.data_type, struct.spectrum_quantity, String.valueOf(struct.acquisition_live_time)); - String fileName = oneFile.getName().substring(0, 23)+suffix; + String fileName = oneFile.getName(); + if (!regexPattern.matcher(fileName).find() && !regexPattern1.matcher(fileName).find()) { + EnergySpectrumStruct struct = phdFileUtil.analyzeFileSourceData(oneFile); + String suffix = nameStandUtil.GetSuffix(struct.data_type, struct.spectrum_quantity, String.valueOf(struct.acquisition_live_time)); + fileName = oneFile.getName().substring(0, 23)+suffix; + } String fullFilePath = filePath + slash + fileName; FileInputStream local = new FileInputStream(oneFile); ftpClient.storeFile(fullFilePath, local);