|
|
|
@ -3,10 +3,7 @@ package com.docus.sw.souyin;
|
|
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
|
|
import com.alibaba.excel.util.FileUtils;
|
|
|
|
|
import com.docus.sw.Config;
|
|
|
|
|
import com.docus.sw.fenpan.Document;
|
|
|
|
|
import com.docus.sw.fenpan.FileTypeEnum;
|
|
|
|
|
import com.docus.sw.fenpan.Pieces;
|
|
|
|
|
import com.docus.sw.fenpan.Roll;
|
|
|
|
|
import com.docus.sw.fenpan.*;
|
|
|
|
|
import com.docus.sw.word.GetPicsDocx;
|
|
|
|
|
import com.docus.sw.word.PdfBoxUtils;
|
|
|
|
|
import com.docus.sw.word.ReadImgDoc;
|
|
|
|
@ -38,7 +35,7 @@ public class CheckService {
|
|
|
|
|
// new CheckService().index(path);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void index(String path,String savepath) throws IOException {
|
|
|
|
|
public void index(String path,String savepath, LevelType levelType) throws IOException {
|
|
|
|
|
Map<String, IndexPlate> map = new HashMap<>();
|
|
|
|
|
findAllDir(path, map);
|
|
|
|
|
|
|
|
|
@ -61,7 +58,7 @@ public class CheckService {
|
|
|
|
|
Roll roll = new Roll(rollFile.getName(), rollFile.getAbsolutePath());
|
|
|
|
|
List<Pieces> pieceList = new ArrayList<>();
|
|
|
|
|
File[] piecesFile = rollFile.listFiles();
|
|
|
|
|
Pieces pieces = new Pieces(FileTypeEnum.JPG, roll.getAbsolutePath(), roll.getName());
|
|
|
|
|
Pieces pieces = new Pieces(FileTypeEnum.JPG, roll.getAbsolutePath(), roll.getName(), LevelType.THREE);
|
|
|
|
|
genPieces(pieces, piecesFile, FileTypeEnum.JPG);
|
|
|
|
|
pieceList.add(pieces);
|
|
|
|
|
roll.putAll(pieceList);
|
|
|
|
@ -71,7 +68,7 @@ public class CheckService {
|
|
|
|
|
Roll roll = new Roll(rollFile.getName(), rollFile.getAbsolutePath());
|
|
|
|
|
List<Pieces> pieceList = new ArrayList<>();
|
|
|
|
|
File[] piecesFile = rollFile.listFiles();
|
|
|
|
|
Pieces pieces = new Pieces(FileTypeEnum.JPG, roll.getAbsolutePath(), roll.getName());
|
|
|
|
|
Pieces pieces = new Pieces(FileTypeEnum.JPG, roll.getAbsolutePath(), roll.getName(), LevelType.THREE);
|
|
|
|
|
genPieces(pieces, piecesFile, FileTypeEnum.JPG);
|
|
|
|
|
pieceList.add(pieces);
|
|
|
|
|
roll.putAll(pieceList);
|
|
|
|
@ -86,7 +83,7 @@ public class CheckService {
|
|
|
|
|
|
|
|
|
|
//区分word和pdf
|
|
|
|
|
if (piece.getName().endsWith(".doc")) {
|
|
|
|
|
Pieces pieces = new Pieces(FileTypeEnum.DOC, piece.getAbsolutePath(), piece.getName());
|
|
|
|
|
Pieces pieces = new Pieces(FileTypeEnum.DOC, piece.getAbsolutePath(), piece.getName(), LevelType.THREE);
|
|
|
|
|
|
|
|
|
|
String teamName = "tempIndex/" + UUID.randomUUID();
|
|
|
|
|
File temp = new File(teamName);
|
|
|
|
@ -102,7 +99,7 @@ public class CheckService {
|
|
|
|
|
//删除对应的temp 文件
|
|
|
|
|
FileUtils.delete(temp);
|
|
|
|
|
} else if (piece.getName().endsWith(".docx")) {
|
|
|
|
|
Pieces pieces = new Pieces(FileTypeEnum.DOCX, piece.getAbsolutePath(), piece.getName());
|
|
|
|
|
Pieces pieces = new Pieces(FileTypeEnum.DOCX, piece.getAbsolutePath(), piece.getName(), LevelType.THREE);
|
|
|
|
|
|
|
|
|
|
String teamName = "tempIndex/" + UUID.randomUUID();
|
|
|
|
|
File temp = new File(teamName);
|
|
|
|
@ -117,7 +114,7 @@ public class CheckService {
|
|
|
|
|
//删除对应的temp 文件
|
|
|
|
|
FileUtils.delete(temp);
|
|
|
|
|
} else if (piece.getName().endsWith(".pdf")) {
|
|
|
|
|
Pieces pieces = new Pieces(FileTypeEnum.DOC, piece.getAbsolutePath(), piece.getName());
|
|
|
|
|
Pieces pieces = new Pieces(FileTypeEnum.DOC, piece.getAbsolutePath(), piece.getName(), LevelType.THREE);
|
|
|
|
|
|
|
|
|
|
String teamName = "tempIndex/" + UUID.randomUUID();
|
|
|
|
|
File temp = new File(teamName);
|
|
|
|
@ -138,10 +135,19 @@ public class CheckService {
|
|
|
|
|
// temp.delete();
|
|
|
|
|
FileUtils.delete(temp);
|
|
|
|
|
} else {
|
|
|
|
|
Pieces pieces = new Pieces(FileTypeEnum.JPG, piece.getAbsolutePath(), piece.getName());
|
|
|
|
|
File[] listFiles = piece.listFiles();
|
|
|
|
|
genPieces(pieces, listFiles, FileTypeEnum.JPG);
|
|
|
|
|
pieceList.add(pieces);
|
|
|
|
|
|
|
|
|
|
if(levelType==LevelType.THREE){
|
|
|
|
|
Pieces pieces = new Pieces(FileTypeEnum.JPG, piece.getAbsolutePath(), piece.getName(),LevelType.THREE);
|
|
|
|
|
File[] listFiles = piece.getParentFile().listFiles(); //就是自己本身
|
|
|
|
|
genPieces(pieces, listFiles, FileTypeEnum.JPG);
|
|
|
|
|
pieceList.add(pieces);
|
|
|
|
|
}else{
|
|
|
|
|
Pieces pieces = new Pieces(FileTypeEnum.JPG, piece.getAbsolutePath(), piece.getName(),LevelType.FOUR);
|
|
|
|
|
File[] listFiles = piece.listFiles();
|
|
|
|
|
genPieces(pieces, listFiles, FileTypeEnum.JPG);
|
|
|
|
|
pieceList.add(pieces);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -187,16 +193,16 @@ public class CheckService {
|
|
|
|
|
@Override
|
|
|
|
|
public int compare(CheckPageRow file1, CheckPageRow file2) {
|
|
|
|
|
// 使用正则表达式提取数字部分
|
|
|
|
|
int num1 = extractNumber(file1.getPhNum());
|
|
|
|
|
int num2 = extractNumber(file2.getPhNum());
|
|
|
|
|
long num1 = extractNumber(file1.getPhNum());
|
|
|
|
|
long num2 = extractNumber(file2.getPhNum());
|
|
|
|
|
|
|
|
|
|
// 比较提取的数字部分
|
|
|
|
|
return Integer.compare(num1, num2);
|
|
|
|
|
return Long.compare(num1, num2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int extractNumber(String fileName) {
|
|
|
|
|
private long extractNumber(String fileName) {
|
|
|
|
|
String numberPart = fileName.replaceAll("[^0-9]", "");
|
|
|
|
|
return numberPart.isEmpty() ? 0 : Integer.parseInt(numberPart);
|
|
|
|
|
return numberPart.isEmpty() ? 0 : Long.parseLong(numberPart);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
Collections.sort(checkPageRows,fileComparator);
|
|
|
|
|