1、服务器路径上传

2023-10-30 14:40:47 浏览数 (2)

0、策略常量类

代码语言:javascript复制
/**
 * @author Eliauk
 */
public interface PathUploadType {

    String PDF = "PDF文件";

    String TIF = "TIF文件";

    String IMAGE_TO_PDF = "合并图片文件";

    String VOLUME = "案卷合并";

    String OFD = "OFD文件";

}

1、合并图片为PDF

这里的逻辑是将当前根目录下所有的包含PDF目录的文件夹里边所有的【jpg", “jpeg”, “png”, “tif”, "tiff】文件都合并成一个PDF文件

代码语言:javascript复制
logger.info("接受到图片合并处理任务…………");
List<File> fileFolders = new ArrayList<>();
List<String> legalSuffix = Arrays.asList("jpg", "jpeg", "png", "tif", "tiff"
File rootFolder = FileUtil.file(upload   localPath);
DirectoryScanner.getFileFoldersWithImages(rootFolder, fileFolders, legalSuffix);
logger.info("列出包含文件的文件夹成功,一共包含{}个文件夹", fileFolders.size()
for (File uploadFileFolder : fileFolders) {
    pathUpLoadProducer.syncSendPathUpload(tenantId,Convert.toStr(taskId),null,Convert.toStr(uploadFileFolder),Convert.toStr(overWrite),PathUploadType.IMAGE_TO_PDF);
}

2、OFD转PDF

代码语言:javascript复制
List<File> fileFolders = new ArrayList<>();
List<String> legalSuffix = List.of("ofd"
getFoldersWithPDFFiles(upload   localPath, fileFolders, legalSuffix);
logger.info("成功列出包含PDF的文件夹,总共包含{}个文件夹", fileFolders.size());

for (int folderIndex = 0; folderIndex < fileFolders.size(); folderIndex  ) {
    File uploadFileFolder = fileFolders.get(folderIndex);
    pathUpLoadProducer.syncSendPathUpload(tenantId,Convert.toStr(taskId),null,Convert.toStr(uploadFileFolder),Convert.toStr(overWrite),PathUploadType.OFD);
}

3、案卷合并

:::warning 这个逻辑与合并图片为PDF不同的是,这个会根据全宗去合并 举个例子: A001-004-021-0001.jpg A001-004-021-0002.jpg A001-004-022-0001.jpg A001-004-022-0002.jpg A001-004-022-0003.jpg A001-004-023-0001.jpg 最终合并成的文件就是【 A001-004-021-0001, A001-004-022-0001, A001-004-023-0001 】 :::

代码语言:javascript复制
logger.info("接受到案卷合并处理任务…………");
List<File> fileFolders = new ArrayList<>();
List<String> legalSuffix = Arrays.asList("jpg", "jpeg", "png", "tif", "tiff");

File rootFolder = FileUtil.file(upload   localPath);
DirectoryScanner.getFileFoldersWithImages(rootFolder, fileFolders, legalSuffix);
logger.info("列出包含文件的文件夹成功,一共包含{}个文件夹", fileFolders.size());

for (int folderIndex = 0; folderIndex < fileFolders.size(); folderIndex  ) {
    File uploadFileFolder = fileFolders.get(folderIndex);
    pathUpLoadProducer.syncSendPathUpload(tenantId,Convert.toStr(taskId),null,Convert.toStr(uploadFileFolder),Convert.toStr(overWrite),PathUploadType.VOLUME);
}

0 人点赞