From 0e7555a9322d385ec4412bacd666bf47def6d45b Mon Sep 17 00:00:00 2001 From: zhanghai <120228220@qq.com> Date: Mon, 1 Jan 2024 09:43:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=BC=A9=E7=95=A5=EF=BC=8C?= =?UTF-8?q?=E8=AF=A6=E7=BB=86=E7=B4=A2=E5=BC=95=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/docus/sw/fenpan/FenpanService.java | 21 ++++++++++++++----- .../com/docus/sw/souyin/CheckService.java | 14 ++++++++----- .../com/docus/sw/souyin/SuoyinService.java | 12 ++++++++--- 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/docus/sw/fenpan/FenpanService.java b/src/main/java/com/docus/sw/fenpan/FenpanService.java index 37e8d73..339e71b 100644 --- a/src/main/java/com/docus/sw/fenpan/FenpanService.java +++ b/src/main/java/com/docus/sw/fenpan/FenpanService.java @@ -16,6 +16,8 @@ import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; +import java.math.BigDecimal; +import java.math.BigInteger; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardCopyOption; @@ -198,7 +200,11 @@ public class FenpanService { //是图片,直接从图片提取 List documentList = new ArrayList<>(); + File sourceFile = new File(piece.getAbsolutePath()); + if(piece.getLevelType()==LevelType.THREE&&piece.getFileTypeEnum()==FileTypeEnum.JPG){ + sourceFile = new File(piece.getAbsolutePath()).getParentFile(); + } File[] files = sourceFile.listFiles(); ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()); @@ -245,6 +251,11 @@ public class FenpanService { for (Pieces piece : pieces) { //根据文件类型 //填充卷 + +// String picesPath = piece.getAbsolutePath(); +// if((piece.getLevelType()==LevelType.THREE&&piece.getFileTypeEnum()==FileTypeEnum.JPG)){ +// picesPath = +// } File file = new File(piece.getAbsolutePath()); File parentFile = file.getParentFile(); String name = parentFile.getName(); @@ -276,16 +287,16 @@ public class FenpanService { @Override public int compare(File file1, File file2) { // 使用正则表达式提取数字部分 - long num1 = extractNumber(file1.getName()); - long num2 = extractNumber(file2.getName()); + BigInteger num1 = extractNumber(file1.getName()); + BigInteger num2 = extractNumber(file2.getName()); // 比较提取的数字部分 - return Long.compare(num1, num2); + return num1.compareTo(num2); } - private long extractNumber(String fileName) { + private BigInteger extractNumber(String fileName) { String numberPart = fileName.replaceAll("[^0-9]", ""); - return numberPart.isEmpty() ? 0 : Long.parseLong(numberPart); + return numberPart.isEmpty() ? new BigInteger("0") : new BigInteger(numberPart); } }; diff --git a/src/main/java/com/docus/sw/souyin/CheckService.java b/src/main/java/com/docus/sw/souyin/CheckService.java index 82e67ef..0dffcb5 100644 --- a/src/main/java/com/docus/sw/souyin/CheckService.java +++ b/src/main/java/com/docus/sw/souyin/CheckService.java @@ -37,7 +37,7 @@ public class CheckService { public void index(String path,String savepath, LevelType levelType) throws IOException { Map map = new HashMap<>(); - findAllDir(path, map); + findAllDir(path, map,levelType); //计算出宗 @@ -262,14 +262,14 @@ public class CheckService { } - private void findAllDir(String absolutePath, Map map) { + private void findAllDir(String absolutePath, Map map, LevelType levelType) { File sourceFile = new File(absolutePath); File[] files = sourceFile.listFiles(); for (File o : files) { if (o.isDirectory()) { - findAllDir(o.getAbsolutePath(), map); + findAllDir(o.getAbsolutePath(), map,levelType); } if (o.isFile()) { @@ -297,8 +297,6 @@ public class CheckService { if (o.getParentFile().getName().equals("片头") || o.getParentFile().getName().equals("片尾")) { continue; } - - //件 File parentFile = o.getParentFile() //卷 @@ -306,6 +304,12 @@ public class CheckService { //盘 .getParentFile(); + if(levelType==LevelType.THREE){ + parentFile = o.getParentFile() + //卷 + .getParentFile(); + } + if (map.get(parentFile.getAbsolutePath()) == null) { IndexPlate indexPlate = new IndexPlate(parentFile.getAbsolutePath(), parentFile.getName(), parentFile.getParentFile().getName()); map.put(parentFile.getAbsolutePath(), indexPlate); diff --git a/src/main/java/com/docus/sw/souyin/SuoyinService.java b/src/main/java/com/docus/sw/souyin/SuoyinService.java index ffe65b7..6ae33b8 100644 --- a/src/main/java/com/docus/sw/souyin/SuoyinService.java +++ b/src/main/java/com/docus/sw/souyin/SuoyinService.java @@ -33,7 +33,7 @@ public class SuoyinService { public void index(String path, String indexType,LevelType levelType) throws IOException { Map map = new HashMap<>(); - findAllDir(path, map); + findAllDir(path, map,levelType); //计算出宗 @@ -457,14 +457,14 @@ public class SuoyinService { } - private void findAllDir(String absolutePath, Map map) { + private void findAllDir(String absolutePath, Map map, LevelType levelType) { File sourceFile = new File(absolutePath); File[] files = sourceFile.listFiles(); for (File o : files) { if (o.isDirectory()) { - findAllDir(o.getAbsolutePath(), map); + findAllDir(o.getAbsolutePath(), map,levelType); } if (o.isFile()) { @@ -501,6 +501,12 @@ public class SuoyinService { //盘 .getParentFile(); + if(levelType==LevelType.THREE){ + parentFile = o.getParentFile() + //卷 + .getParentFile(); + } + if (map.get(parentFile.getAbsolutePath()) == null) { IndexPlate indexPlate = new IndexPlate(parentFile.getAbsolutePath(), parentFile.getName(), parentFile.getParentFile().getName()); map.put(parentFile.getAbsolutePath(), indexPlate);