From e2ac5380423d24d1ebdf267fefe409dcca867b1a Mon Sep 17 00:00:00 2001 From: qiaoqinzheng Date: Thu, 19 Oct 2023 18:55:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E5=8C=96=E6=96=87=E4=BB=B6=E5=90=8D=E7=A7=B0=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=BF=AE=E6=94=B9=E5=A2=9E=E5=8A=A0=E6=AD=A3=E5=88=99?= =?UTF-8?q?=E8=A1=A8=E8=BE=BE=E5=BC=8F=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/SpectrumFileServiceImpl.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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);