commit 6889df9761556cc31ade26c0ab208737e1eb2990
Author: zhanghai <120228220@qq.com>
Date: Wed Nov 8 17:55:28 2023 +0800
第一次提交
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..ef40b6a
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..aa00ffa
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 0000000..fcaa658
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jpa-buddy.xml b/.idea/jpa-buddy.xml
new file mode 100644
index 0000000..966d5f5
--- /dev/null
+++ b/.idea/jpa-buddy.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/MigLayout.xml b/.idea/libraries/MigLayout.xml
new file mode 100644
index 0000000..ab653df
--- /dev/null
+++ b/.idea/libraries/MigLayout.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..c6eabde
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
new file mode 100644
index 0000000..2b63946
--- /dev/null
+++ b/.idea/uiDesigner.xml
@@ -0,0 +1,124 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/config.ini b/config.ini
new file mode 100644
index 0000000..4c6f77a
--- /dev/null
+++ b/config.ini
@@ -0,0 +1,8 @@
+file.mode=图片
+file.read.url=C:\jiahsi-saomiao\缩微\ddd_0001\
+a3.length=3000
+plate.size=2800
+a3.width=3000
+file.save.url=C:\jiahsi-saomiao\缩微\分盘结果\档案图\
+zong.name.prefix=南方医院
+Split.mode=copy/cut
diff --git a/config2.ini b/config2.ini
new file mode 100644
index 0000000..192e77c
--- /dev/null
+++ b/config2.ini
@@ -0,0 +1,8 @@
+zong.name.prefix=南方医院
+a3.length=3000
+a3.width=3000
+file.mode=pic/pdf/word
+file.save.url=C:\jiahsi-saomiao\缩微\分盘结果\档案图\
+file.read.url=C:\jiahsi-saomiao\缩微\ddd_0001\
+plate.size=2800
+Split.mode=copy/cut
\ No newline at end of file
diff --git a/lib/miglayout-core-javadoc.jar b/lib/miglayout-core-javadoc.jar
new file mode 100644
index 0000000..da68015
Binary files /dev/null and b/lib/miglayout-core-javadoc.jar differ
diff --git a/lib/miglayout-core-sources.jar b/lib/miglayout-core-sources.jar
new file mode 100644
index 0000000..5ce2041
Binary files /dev/null and b/lib/miglayout-core-sources.jar differ
diff --git a/lib/miglayout-core.jar b/lib/miglayout-core.jar
new file mode 100644
index 0000000..303692e
Binary files /dev/null and b/lib/miglayout-core.jar differ
diff --git a/lib/miglayout-swing-javadoc.jar b/lib/miglayout-swing-javadoc.jar
new file mode 100644
index 0000000..fec8806
Binary files /dev/null and b/lib/miglayout-swing-javadoc.jar differ
diff --git a/lib/miglayout-swing-sources.jar b/lib/miglayout-swing-sources.jar
new file mode 100644
index 0000000..f2a48fd
Binary files /dev/null and b/lib/miglayout-swing-sources.jar differ
diff --git a/lib/miglayout-swing.jar b/lib/miglayout-swing.jar
new file mode 100644
index 0000000..0028623
Binary files /dev/null and b/lib/miglayout-swing.jar differ
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..bbc2f02
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,75 @@
+
+
+ 4.0.0
+
+ org.example
+ SwSoft
+ 1.0-SNAPSHOT
+
+
+ 17
+ 17
+ UTF-8
+
+
+
+
+
+ com.alibaba
+ easyexcel
+ 3.2.1
+
+
+ org.projectlombok
+ lombok
+ 1.18.28
+
+
+
+
+ org.apache.commons
+ commons-imaging
+ 1.0-alpha3
+
+
+ com.itextpdf
+ itextpdf
+ 5.5.13.3
+
+
+
+ com.itextpdf
+ itext-asian
+ 5.2.0
+
+
+
+
+ org.apache.commons
+ commons-lang3
+ 3.12.0
+
+
+
+ org.apache.pdfbox
+ pdfbox
+ 2.0.23
+ bundle
+
+
+
+
+
+
+
+
+ org.apache.felix
+ maven-bundle-plugin
+ true
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/com/docus/Main.java b/src/main/java/com/docus/Main.java
new file mode 100644
index 0000000..d01b199
--- /dev/null
+++ b/src/main/java/com/docus/Main.java
@@ -0,0 +1,24 @@
+package com.docus;
+
+import com.alibaba.excel.util.FileUtils;
+import com.docus.sw.*;
+import com.docus.sw.fenpan.*;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.imaging.ImageInfo;
+import org.apache.commons.imaging.ImageReadException;
+import org.apache.commons.imaging.Imaging;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Slf4j
+public class Main {
+
+}
\ No newline at end of file
diff --git a/src/main/java/com/docus/sw/Config.java b/src/main/java/com/docus/sw/Config.java
new file mode 100644
index 0000000..75fbccf
--- /dev/null
+++ b/src/main/java/com/docus/sw/Config.java
@@ -0,0 +1,85 @@
+package com.docus.sw;
+
+
+import java.io.*;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+
+public class Config {
+
+ private static Map stringStringMap = new HashMap<>();
+
+
+ public static String getParam(String key){
+ return stringStringMap.get(key);
+ }
+
+
+ public static void loadConfig() throws IOException {
+ //从classpath 读取配置文件。将日志写入到result中。
+ Map stringStringMaplocal = readParam("config.ini");
+ stringStringMap = stringStringMaplocal;
+ }
+
+
+ private static Map readParam(String file) throws IOException {
+ Map params = new HashMap<>();
+ BufferedReader in = new BufferedReader(new FileReader(file));
+ String str;
+ while ((str = in.readLine()) != null) {
+ String[] split = str.split("=");
+ params.put(split[0],split[1]);
+ }
+ in.close();
+ return params;
+ }
+
+ public static void updateConfig(String key,String value) throws IOException {
+
+ if(stringStringMap==null){
+ throw new RuntimeException("先加载配置文件");
+ }
+
+ stringStringMap.put(key,value);
+ Files.write(Paths.get("config.ini"), new byte[0]);
+
+ try (BufferedWriter writer = new BufferedWriter(new FileWriter("config.ini"))) {
+ // 写入内容到文件
+ for(String keyN: stringStringMap.keySet()){
+ writer.write(keyN+"="+stringStringMap.get(keyN));
+ writer.newLine(); // 换行
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ public static void updateConfig(Map keyvalue) throws IOException {
+
+ if(stringStringMap==null){
+ throw new RuntimeException("先加载配置文件");
+ }
+
+ stringStringMap.putAll(keyvalue);
+ Files.write(Paths.get("config.ini"), new byte[0]);
+
+ try (BufferedWriter writer = new BufferedWriter(new FileWriter("config.ini"))) {
+ // 写入内容到文件
+ for(String keyN: stringStringMap.keySet()){
+ writer.write(keyN+"="+stringStringMap.get(keyN));
+ writer.newLine(); // 换行
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+
+
+
+
+
+}
diff --git a/src/main/java/com/docus/sw/fenpan/A3Attribute.java b/src/main/java/com/docus/sw/fenpan/A3Attribute.java
new file mode 100644
index 0000000..12f8f86
--- /dev/null
+++ b/src/main/java/com/docus/sw/fenpan/A3Attribute.java
@@ -0,0 +1,15 @@
+package com.docus.sw.fenpan;
+
+import lombok.Getter;
+
+/**
+ * 配置读取A3 的属性
+ */
+@Getter
+public class A3Attribute {
+
+ private Integer width;
+
+ private Integer length;
+
+}
diff --git a/src/main/java/com/docus/sw/fenpan/Document.java b/src/main/java/com/docus/sw/fenpan/Document.java
new file mode 100644
index 0000000..fe32358
--- /dev/null
+++ b/src/main/java/com/docus/sw/fenpan/Document.java
@@ -0,0 +1,33 @@
+package com.docus.sw.fenpan;
+
+import com.docus.sw.Config;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@Getter
+@AllArgsConstructor
+public class Document {
+
+ /**
+ * 宽
+ */
+ private Integer width;
+
+ /**
+ * 长
+ */
+ private Integer longTh;
+
+ private Integer dpi;
+
+
+ //写一个方法判断是 A3 还是 A4
+
+ public Boolean isA3() {
+ if (width > Integer.parseInt(Config.getParam("a3.width")) || longTh > Integer.parseInt(Config.getParam("a3.length"))) {
+ return true;
+ }
+ return false;
+ }
+
+}
diff --git a/src/main/java/com/docus/sw/fenpan/FenpanService.java b/src/main/java/com/docus/sw/fenpan/FenpanService.java
new file mode 100644
index 0000000..e12a6d5
--- /dev/null
+++ b/src/main/java/com/docus/sw/fenpan/FenpanService.java
@@ -0,0 +1,220 @@
+package com.docus.sw.fenpan;
+
+import com.alibaba.excel.util.FileUtils;
+import com.docus.sw.Config;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.imaging.ImageInfo;
+import org.apache.commons.imaging.ImageReadException;
+import org.apache.commons.imaging.Imaging;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Slf4j
+public class FenpanService {
+ public void fenpan(String saveUrl,String readUrl){
+ try {
+ FenpanService main = new FenpanService();
+ Map zongMap = main.readFile(readUrl);
+
+ Map> zongListMap = new HashMap<>();
+ //读取需要转宗的文件夹
+ Integer i = 0;
+ for (String key : zongMap.keySet()) {
+ List plateList = new ArrayList<>();
+ Zong zong = zongMap.get(key);
+ List rollList = zong.getRollList();
+ Plate plate = new Plate(Integer.parseInt(Config.getParam("plate.size")), "盘" + i++);
+ for (Roll roll : rollList) {
+ Boolean put = plate.put(roll);
+ if (!put) {
+ //磁盘放不进去了
+ plateList.add(plate);
+ plate = new Plate(Integer.parseInt(Config.getParam("plate.size")), "盘" + i++);
+ }
+ }
+ plateList.add(plate);
+ zongListMap.put(zong, plateList);
+ }
+
+
+ //copy 文件到新的目录
+ for (Zong zong : zongListMap.keySet()) {
+
+ File saveUrlFile = new File(saveUrl + zong.getName());
+ if (!saveUrlFile.exists()) {
+ FileUtils.createDirectory(saveUrlFile);
+ }
+
+ for (Plate plate : zongListMap.get(zong)) {
+ for (Roll roll : plate.getRollList()) {
+ copyFolder(new File(roll.getAbsolutePath()), new File(saveUrlFile + "/" + plate.getName() + "/" + roll.getName()));
+ }
+ }
+ }
+
+ //输出text
+ for (Zong zong : zongListMap.keySet()) {
+ System.out.println(zong.getName());
+ for (Plate plate : zongListMap.get(zong)) {
+ System.out.print(plate.getName() + " --- ");
+ for (Roll roll : plate.getRollList()) {
+ System.out.print(roll.getName() + ",");
+ }
+ System.out.println();
+ }
+ }
+
+ //转换成 宗。卷,件 。
+ //放到 宗,盘 下面
+ //输出目录结构
+ } catch (IOException e) {
+ log.error("读取配置文件失败!", e);
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static void main(String[] args) throws IOException {
+
+ //读取配置文件。
+ Config.loadConfig();
+ String saveUrl = Config.getParam("file.save.url");
+ String readUrl = Config.getParam("file.read.url");
+ new FenpanService().fenpan(saveUrl,readUrl);
+ }
+
+
+ public Map readFile(String readUrl) {
+ //读取文件夹。
+ List pieces = new ArrayList<>();
+ Map rollMap = new HashMap<>();
+ Map zongMap = new HashMap<>();
+ this.findAllDir(readUrl, pieces);
+ //写入文件
+
+ for (Pieces piece : pieces) {
+ //根据文件类型
+ if (piece.getFileTypeEnum() == FileTypeEnum.WORD) {
+ //从word 直接提取图片
+
+ } else if (piece.getFileTypeEnum() == FileTypeEnum.PDF) {
+ // 从pdf 提取图片
+
+ } else {
+ //是图片,直接从图片提取
+ List documentList = new ArrayList<>();
+ File sourceFile = new File(piece.getAbsolutePath());
+ File[] files = sourceFile.listFiles();
+ for (File file : files) {
+ try {
+ ImageInfo imageInfo = Imaging.getImageInfo(file);
+ int height = imageInfo.getHeight();
+ int width = imageInfo.getWidth();
+ int physicalHeightDpi = imageInfo.getPhysicalHeightDpi();
+ Document document = new Document(width, height, physicalHeightDpi);
+ documentList.add(document);
+ } catch (IOException e) {
+ FileUtils.delete(file);
+ throw new RuntimeException("非图片格式", e);
+ } catch (ImageReadException e) {
+ FileUtils.delete(file);
+ throw new RuntimeException(e);
+ } catch (IllegalArgumentException e) {
+ FileUtils.delete(file);
+ }
+ }
+ piece.put(documentList);
+ }
+
+ //填充卷
+ File file = new File(piece.getAbsolutePath());
+ File parentFile = file.getParentFile();
+ String name = parentFile.getName();
+// System.out.println(name);
+ Roll roll = rollMap.get(name);
+ if (roll == null) {
+ roll = new Roll(name, parentFile.getAbsolutePath());
+ }
+ roll.putPieces(piece);
+ rollMap.put(name, roll);
+ }
+
+ //填充宗
+ for (String name : rollMap.keySet()) {
+ Roll roll = rollMap.get(name);
+ File file = new File(roll.getAbsolutePath());
+ String zongName = file.getParentFile().getName();
+ Zong zong = zongMap.get(zongName);
+ if (zong == null) {
+ zong = new Zong(file.getParentFile().getAbsolutePath(), file.getParentFile().getName());
+ }
+ zong.put(rollMap.get(name));
+ zongMap.put(zongName, zong);
+ }
+
+ return zongMap;
+
+
+ }
+
+
+ private void findAllDir(String absolutePath, List allDirectory) {
+ File sourceFile = new File(absolutePath);
+ File[] files = sourceFile.listFiles();
+ for (File o : files) {
+ if (o.isDirectory()) {
+ findAllDir(o.getAbsolutePath(), allDirectory);
+ }
+
+ if (o.isFile()) {
+ //判断是word,pdf,pic
+ if (o.getName().endsWith(".pdf")) {
+ Pieces pieces = new Pieces(FileTypeEnum.PDF, o.getAbsolutePath(), o.getName());
+ allDirectory.add(pieces);
+ } else if (o.getName().endsWith(".docx") || o.getName().endsWith(".doc")) {
+ Pieces pieces = new Pieces(FileTypeEnum.WORD, o.getAbsolutePath(), o.getName());
+ allDirectory.add(pieces);
+ } else if (o.getName().endsWith(".jpg") || o.getName().endsWith(".png")
+ || o.getName().endsWith(".jpeg") || o.getName().endsWith(".tif")
+ || o.getName().endsWith(".tiff")) {
+ Pieces pieces = new Pieces(FileTypeEnum.JPG, o.getParentFile().getAbsolutePath(), o.getParentFile().getName());
+ allDirectory.add(pieces);
+ } else {
+ FileUtils.delete(new File(o.getAbsolutePath()));
+ System.out.println("请删除无效的文件:" + o.getAbsolutePath());
+ throw new RuntimeException("请删除无效的文件:" + o.getAbsolutePath());
+ }
+ break;
+ }
+ }
+ }
+
+
+ public static void copyFolder(File sourceFolder, File destinationFolder) throws IOException {
+ if (!destinationFolder.exists()) {
+ destinationFolder.mkdirs();
+ }
+
+ for (File file : sourceFolder.listFiles()) {
+ if (file.isDirectory()) {
+ copyFolder(file, newFile(destinationFolder, file));
+ } else {
+ Path sourcePath = file.toPath();
+ Path destinationPath = newFile(destinationFolder, file).toPath();
+ Files.copy(sourcePath, destinationPath, StandardCopyOption.REPLACE_EXISTING);
+ }
+ }
+ }
+
+
+ public static File newFile(File parentDir, File childFile) {
+ return new File(parentDir, childFile.getName());
+ }
+}
diff --git a/src/main/java/com/docus/sw/fenpan/FileTypeEnum.java b/src/main/java/com/docus/sw/fenpan/FileTypeEnum.java
new file mode 100644
index 0000000..8c8a59d
--- /dev/null
+++ b/src/main/java/com/docus/sw/fenpan/FileTypeEnum.java
@@ -0,0 +1,7 @@
+package com.docus.sw.fenpan;
+
+public enum FileTypeEnum {
+ WORD,
+ PDF,
+ JPG
+}
diff --git a/src/main/java/com/docus/sw/fenpan/JFrameDemo1.java b/src/main/java/com/docus/sw/fenpan/JFrameDemo1.java
new file mode 100644
index 0000000..6b06d25
--- /dev/null
+++ b/src/main/java/com/docus/sw/fenpan/JFrameDemo1.java
@@ -0,0 +1,45 @@
+package com.docus.sw.fenpan;
+
+import javax.swing.*;
+import java.awt.*;
+/**
+ * @author EdwinD
+ * @create 2020.08.19 上午 08:31
+ * @desc Swing
+ **/
+public class JFrameDemo1 {
+ public static void main(String[] args) {
+ new JFrameDemo1().init();
+ }
+
+ // init()初始化。
+ public void init() {
+ JFrame jFrame = new JFrame("这是我们的JFrame窗口。");
+ jFrame.setVisible(true);
+ jFrame.setBackground(Color.BLUE);
+ jFrame.setBounds(100, 100, 1024, 900);
+ jFrame.setLayout(new FlowLayout());
+
+
+ Panel panel2 = new Panel();
+ panel2.setLayout(new FlowLayout());
+
+ JLabel jl=new JLabel();
+ jl.setBounds(10,50,500,300);
+
+ JTextField jtf =new JTextField();
+ jtf.setBounds(10,10,150,30);
+ panel2.add(jtf);
+
+ JButton jButton2 = new JButton("启动");
+ panel2.add(jButton2);
+
+ jFrame.add(panel2);
+
+
+// 关闭事件
+ jFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+
+ }
+}
+
diff --git a/src/main/java/com/docus/sw/fenpan/MainJFrame.java b/src/main/java/com/docus/sw/fenpan/MainJFrame.java
new file mode 100644
index 0000000..51a797f
--- /dev/null
+++ b/src/main/java/com/docus/sw/fenpan/MainJFrame.java
@@ -0,0 +1,38 @@
+package com.docus.sw.fenpan;
+
+
+
+import net.miginfocom.swing.MigLayout;
+
+import javax.swing.*;
+import java.awt.*;
+
+public class MainJFrame extends JFrame {
+
+
+ public void init(){
+ JFrame jFrame = new JFrame("这是我们的JFrame窗口。");
+ jFrame.setVisible(true);
+ jFrame.setBackground(Color.BLUE);
+ jFrame.setBounds(0, 0, 1324, 900);
+ MigLayout layout = new MigLayout("wrap 2");
+ JPanel panel = new JPanel(layout);
+ panel.setVisible(true);
+ panel.add(new JLabel("Name"));
+ panel.add(new JTextField(""), "growx");
+ panel.add(new JLabel("Age"));
+ panel.add(new JTextField(""), "growx");
+ panel.add(new JLabel("Address"));
+ panel.add(new JTextArea(5, 20), "growx");
+ panel.add(new Button("提交"));
+ panel.add(new Button("关闭"));
+ jFrame.add(panel);
+ // 关闭事件
+ jFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+ }
+
+
+ public static void main(String[] args) {
+ new MainJFrame().init();
+ }
+}
diff --git a/src/main/java/com/docus/sw/fenpan/MyApplication.java b/src/main/java/com/docus/sw/fenpan/MyApplication.java
new file mode 100644
index 0000000..1fe8080
--- /dev/null
+++ b/src/main/java/com/docus/sw/fenpan/MyApplication.java
@@ -0,0 +1,324 @@
+package com.docus.sw.fenpan;
+
+import com.docus.sw.Config;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.File;
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+public class MyApplication {
+ public static void main(String[] args) throws IOException {
+ Config.loadConfig();
+ // 获取系统支持的外观信息
+ UIManager.LookAndFeelInfo[] lookAndFeels = UIManager.getInstalledLookAndFeels();
+
+ // 遍历可用的外观并设置所选外观
+ for (UIManager.LookAndFeelInfo info : lookAndFeels) {
+ if ("Nimbus".equals(info.getName())) { // 选择Nimbus外观
+ try {
+ UIManager.setLookAndFeel(info.getClassName());
+ break;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ SwingUtilities.invokeLater(() -> createAndShowGUI());
+ }
+
+ private static void createAndShowGUI() {
+ JFrame frame = new JFrame("缩微工具");
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.setSize(600, 400);
+
+ JTabbedPane tabbedPane = new JTabbedPane();
+
+ // 参数设置标签页
+ JPanel paramPanel = new JPanel(new GridBagLayout());
+ GridBagConstraints gbc = new GridBagConstraints();
+ gbc.insets = new Insets(5, 5, 5, 5);
+
+ gbc.gridx = 0;
+ gbc.gridy = 0;
+ gbc.anchor = GridBagConstraints.WEST;
+ paramPanel.add(new JLabel("宗前缀名:"), gbc);
+ gbc.gridx = 1;
+ gbc.anchor = GridBagConstraints.CENTER;
+ JTextField zongPreJtf = new JTextField(20);
+ paramPanel.add(zongPreJtf, gbc);
+
+ JPanel sizePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
+ sizePanel.add(new JLabel("A3大小尺寸 长:"));
+ JTextField a3LongJtf = new JTextField(5);
+ sizePanel.add(a3LongJtf);
+ sizePanel.add(new JLabel("宽:"));
+ JTextField a3WidthJtf = new JTextField(5);
+ sizePanel.add(a3WidthJtf);
+
+ gbc.gridx = 0;
+ gbc.gridy = 1;
+ gbc.gridwidth = 2;
+ gbc.anchor = GridBagConstraints.WEST;
+ paramPanel.add(sizePanel, gbc);
+
+ gbc.gridx = 0;
+ gbc.gridy = 2;
+ gbc.gridwidth = 1;
+ gbc.anchor = GridBagConstraints.WEST;
+ paramPanel.add(new JLabel("盘大小:"), gbc);
+ gbc.gridx = 1;
+ gbc.anchor = GridBagConstraints.CENTER;
+ JTextField plateSizeJtf = new JTextField(20);
+ paramPanel.add(plateSizeJtf, gbc);
+
+ JPanel modePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
+ modePanel.add(new JLabel("模式选择:"));
+ String[] modes = {"图片", "word", "pdf"};
+ JComboBox modeComboBox = new JComboBox<>(modes);
+ modePanel.add(modeComboBox);
+
+
+
+
+ gbc.gridx = 0;
+ gbc.gridy = 3;
+ gbc.gridwidth = 2;
+ gbc.anchor = GridBagConstraints.WEST;
+ paramPanel.add(modePanel, gbc);
+
+ gbc.gridx = 0;
+ gbc.gridy = 4;
+ gbc.gridwidth = 2;
+ gbc.anchor = GridBagConstraints.CENTER;
+ JButton jButton = new JButton("保存设置");
+ paramPanel.add(jButton, gbc);
+
+
+ //添加事件
+ jButton.addActionListener(e -> {
+ //宗名
+ System.out.println(zongPreJtf.getText());
+
+ //模式
+ String selectedValue = (String) modeComboBox.getSelectedItem();
+ System.out.println(selectedValue);
+
+ //a3 图片大小
+ System.out.println(a3LongJtf.getText());
+ System.out.println(a3WidthJtf.getText());
+
+ //盘大小
+ String text = plateSizeJtf.getText();
+ System.out.println(text);
+
+
+ Map keyvalue = new HashMap<>();
+ keyvalue.put("zong.name.prefix",zongPreJtf.getText());
+ keyvalue.put("file.mode",selectedValue);
+ keyvalue.put("a3.length",a3LongJtf.getText());
+ keyvalue.put("a3.width",a3WidthJtf.getText());
+ keyvalue.put("plate.size",plateSizeJtf.getText());
+ try {
+ Config.updateConfig(keyvalue);
+ } catch (IOException ex) {
+ throw new RuntimeException(ex);
+ }
+ });
+
+ // 分盘工具标签页
+ JPanel splitPanel = new JPanel(new BorderLayout());
+ JPanel leftPanel = new JPanel(new GridBagLayout());
+ GridBagConstraints leftGbc = new GridBagConstraints();
+ leftGbc.insets = new Insets(5, 5, 5, 5);
+
+ leftGbc.gridx = 0;
+ leftGbc.gridy = 0;
+ leftPanel.add(new JLabel("分盘目录:"), leftGbc);
+ JTextField folderField = new JTextField(20);
+ leftGbc.gridx = 1;
+ leftGbc.gridwidth = 1;
+ leftPanel.add(folderField, leftGbc);
+
+ JButton folderChooserButton = new JButton("选择文件夹");
+ folderChooserButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ JFileChooser fileChooser = new JFileChooser();
+ fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+ int returnValue = fileChooser.showOpenDialog(null);
+ if (returnValue == JFileChooser.APPROVE_OPTION) {
+ File selectedFile = fileChooser.getSelectedFile();
+ folderField.setText(selectedFile.getAbsolutePath());
+ }
+ }
+ });
+
+ leftGbc.gridx = 2;
+ leftPanel.add(folderChooserButton, leftGbc);
+
+ leftGbc.gridx = 0;
+ leftGbc.gridy = 1;
+ leftPanel.add(new JLabel("保存路径:"), leftGbc);
+ JTextField savePathField = new JTextField(20);
+ leftGbc.gridx = 1;
+ leftPanel.add(savePathField, leftGbc);
+
+ JButton savePathChooserButton = new JButton("选择文件夹");
+ savePathChooserButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ JFileChooser fileChooser = new JFileChooser();
+ fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+ int returnValue = fileChooser.showOpenDialog(null);
+ if (returnValue == JFileChooser.APPROVE_OPTION) {
+ File selectedFile = fileChooser.getSelectedFile();
+ savePathField.setText(selectedFile.getAbsolutePath());
+ }
+ }
+ });
+
+ leftGbc.gridx = 2;
+ leftPanel.add(savePathChooserButton, leftGbc);
+
+ leftGbc.gridx = 0;
+ leftGbc.gridy = 2;
+ leftGbc.gridwidth = 2;
+ leftGbc.anchor = GridBagConstraints.CENTER;
+ JButton fenpanJbtn = new JButton("开始分盘");
+
+
+
+ leftPanel.add(fenpanJbtn, leftGbc);
+
+ JTextArea logTextArea = new JTextArea();
+ JScrollPane logScrollPane = new JScrollPane(logTextArea);
+ logScrollPane.setPreferredSize(new Dimension(200, 200));
+ JPanel rightPanel = new JPanel(new BorderLayout());
+ rightPanel.add(logScrollPane, BorderLayout.CENTER);
+
+
+ fenpanJbtn.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ // 在EDT上执行更新操作
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+
+ logTextArea.append(df.format(new Date())+": 开始分盘。。。"+ "\n");
+ }
+ });
+ // 启动一个异步任务
+
+ Thread workerThread = new Thread(() -> {
+ // 执行长时间运行的业务操作
+
+ // 模拟耗时操作
+ String saveUrl = savePathField.getText();
+ String readUrl = folderField.getText();
+ new FenpanService().fenpan(saveUrl,readUrl);
+
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ // 在EDT上更新UI
+ logTextArea.append(df.format(new Date())+": 分盘结束。。。"+ "\n");
+ }
+ });
+ });
+
+ workerThread.start(); // 启动线程
+
+ }
+ });
+
+
+ splitPanel.add(leftPanel, BorderLayout.WEST);
+ splitPanel.add(rightPanel, BorderLayout.CENTER);
+
+ tabbedPane.addTab("参数设置", paramPanel);
+ tabbedPane.addTab("分盘工具", splitPanel);
+ tabbedPane.addTab("索引工具", createIndexPanel());
+
+ frame.add(tabbedPane);
+ frame.setVisible(true);
+
+
+ //加载数据
+ zongPreJtf.setText(Config.getParam("zong.name.prefix"));
+ a3LongJtf.setText(Config.getParam("a3.length"));
+ a3WidthJtf.setText(Config.getParam("a3.width"));
+ plateSizeJtf.setText(Config.getParam("plate.size"));
+ }
+
+ private static JPanel createIndexPanel() {
+ JPanel indexPanel = new JPanel(new BorderLayout());
+ JPanel leftIndexPanel = new JPanel(new GridBagLayout());
+ GridBagConstraints leftIndexGbc = new GridBagConstraints();
+ leftIndexGbc.insets = new Insets(5, 5, 5, 5);
+
+ leftIndexGbc.gridx = 0;
+ leftIndexGbc.gridy = 0;
+ leftIndexGbc.anchor = GridBagConstraints.WEST;
+ leftIndexPanel.add(new JLabel("文件路径选择:"), leftIndexGbc);
+ JTextField filePathField = new JTextField(20);
+ leftIndexGbc.gridx = 1;
+ leftIndexGbc.gridwidth = 1;
+ leftIndexPanel.add(filePathField, leftIndexGbc);
+
+ JButton fileChooserButton = new JButton("选择文件");
+ leftIndexGbc.gridx = 2;
+ leftIndexPanel.add(fileChooserButton, leftIndexGbc);
+
+ // 文件选择按钮的动作监听器,打开文件选择对话框
+ fileChooserButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ JFileChooser fileChooser = new JFileChooser();
+ fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+ int returnValue = fileChooser.showOpenDialog(null);
+ if (returnValue == JFileChooser.APPROVE_OPTION) {
+ File selectedFile = fileChooser.getSelectedFile();
+ filePathField.setText(selectedFile.getAbsolutePath());
+ }
+ }
+ });
+
+ leftIndexGbc.gridx = 0;
+ leftIndexGbc.gridy = 1;
+ leftIndexGbc.anchor = GridBagConstraints.WEST;
+ leftIndexPanel.add(new JLabel("图片dpi:"), leftIndexGbc);
+ leftIndexGbc.gridx = 1;
+ JTextField dpiField = new JTextField(5);
+ leftIndexPanel.add(dpiField, leftIndexGbc);
+
+ // ... 其他标签左对齐,与前面的代码相同 ...
+
+ leftIndexGbc.gridx = 0;
+ leftIndexGbc.gridy = 2;
+ leftIndexGbc.gridwidth = 2;
+ leftIndexGbc.anchor = GridBagConstraints.CENTER;
+ leftIndexPanel.add(new JButton("开始生成索引"), leftIndexGbc);
+
+ JTextArea indexLogTextArea = new JTextArea();
+ JScrollPane indexLogScrollPane = new JScrollPane(indexLogTextArea);
+ indexLogScrollPane.setPreferredSize(new Dimension(200, 200));
+ JPanel rightIndexPanel = new JPanel(new BorderLayout());
+ rightIndexPanel.add(indexLogScrollPane, BorderLayout.CENTER);
+
+ indexPanel.add(leftIndexPanel, BorderLayout.WEST);
+ indexPanel.add(rightIndexPanel, BorderLayout.CENTER);
+
+ return indexPanel;
+ }
+}
diff --git a/src/main/java/com/docus/sw/fenpan/MyJFrame.java b/src/main/java/com/docus/sw/fenpan/MyJFrame.java
new file mode 100644
index 0000000..e0d773d
--- /dev/null
+++ b/src/main/java/com/docus/sw/fenpan/MyJFrame.java
@@ -0,0 +1,48 @@
+package com.docus.sw.fenpan;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.io.IOException;
+
+public class MyJFrame extends JFrame {
+ JPanel center =new JPanel();
+ public MyJFrame()throws IOException {
+ init();
+ this.setVisible(true);
+ }
+ private void init(){
+ this.setSize(800,600);
+ this.setTitle("随机小游戏");
+ this.setLocationRelativeTo(null);
+ this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ this.setLayout(null); //设置为空布局
+ this.setResizable(false);
+ this.setBackground(Color.BLUE);
+
+ JLabel jl=new JLabel();
+ jl.setBounds(10,50,500,300);
+
+ JTextField jtf =new JTextField(); //文本框
+ jtf.setBounds(10,10,150,30);
+
+ JButton jb=new JButton("搜索"); //鼠标单击监听器
+ jb.setBounds(180,10,60,30);
+ jb.addActionListener(
+ (ActionListener) ->{
+ String text =jtf.getText();
+ jl.setText(text+"是个难得的人才");
+ });
+ jtf.addActionListener((ActionEvent e)->{ //常用键enter 用addActionListener
+ jb.doClick();
+ });
+
+ this.add(jl);
+ this.add(jtf);
+ this.add(jb);
+ }
+
+ public static void main(String[] args) throws IOException {
+ new MyJFrame().init();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/docus/sw/fenpan/Pieces.java b/src/main/java/com/docus/sw/fenpan/Pieces.java
new file mode 100644
index 0000000..e809220
--- /dev/null
+++ b/src/main/java/com/docus/sw/fenpan/Pieces.java
@@ -0,0 +1,51 @@
+package com.docus.sw.fenpan;
+
+import lombok.Getter;
+
+import java.util.List;
+
+/**
+ * 件(档)
+ */
+@Getter
+public class Pieces {
+
+ /**
+ * 实际占用篇幅
+ */
+ private Integer size;
+
+ /**
+ * 文件类型
+ */
+ private FileTypeEnum fileTypeEnum;
+
+ private String name;
+
+ private String absolutePath;
+
+ List documentList;
+
+
+ public Pieces(FileTypeEnum fileTypeEnum, String absolutePath, String name) {
+ this.fileTypeEnum = fileTypeEnum;
+ this.absolutePath = absolutePath;
+ this.name = name;
+ }
+
+
+ public void put(List documentList) {
+ this.documentList = documentList;
+
+ int size = 0;
+ for (Document document : documentList) {
+ if (document.isA3()) {
+ size += 2;
+ } else {
+ size += 1;
+ }
+ }
+ this.size = size;
+ }
+
+}
diff --git a/src/main/java/com/docus/sw/fenpan/Plate.java b/src/main/java/com/docus/sw/fenpan/Plate.java
new file mode 100644
index 0000000..7b18377
--- /dev/null
+++ b/src/main/java/com/docus/sw/fenpan/Plate.java
@@ -0,0 +1,48 @@
+package com.docus.sw.fenpan;
+
+import lombok.Getter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 盘
+ */
+@Getter
+public class Plate {
+
+ /**
+ * 这个是可以设置的。默认是2800
+ */
+ private Integer totalLength;
+
+ /**
+ * 已有大小
+ */
+ private Integer already;
+
+ private List rollList;
+
+ private String name;
+
+
+ //是否还可以放下新的卷
+ public Boolean put(Roll roll) {
+ if(already + roll.getSize() - totalLength >= 0){
+ return false;
+ }
+ this.already = already+roll.getSize();
+ rollList.add(roll);
+ return true;
+ }
+
+
+ public Plate(Integer totalLength,String name){
+ this.totalLength = totalLength;
+ this.rollList = new ArrayList<>();
+ this.already = 0;
+ this.name = name;
+ }
+
+
+}
diff --git a/src/main/java/com/docus/sw/fenpan/Roll.java b/src/main/java/com/docus/sw/fenpan/Roll.java
new file mode 100644
index 0000000..2d82660
--- /dev/null
+++ b/src/main/java/com/docus/sw/fenpan/Roll.java
@@ -0,0 +1,43 @@
+package com.docus.sw.fenpan;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 卷
+ */
+@Getter
+@AllArgsConstructor
+public class Roll {
+
+ private String name;
+
+ private List piecesList;
+
+ private String absolutePath;
+
+ public Integer getSize(){
+ Integer size = 0;
+ for(Pieces pieces:piecesList){
+ size+= pieces.getSize();
+ }
+ return size;
+ }
+
+
+ public Roll(String name, String absolutePath) {
+ this.name = name;
+ this.absolutePath = absolutePath;
+ piecesList = new ArrayList<>();
+ }
+
+ public void putPieces(Pieces pieces){
+ piecesList.add(pieces);
+ }
+
+
+
+}
diff --git a/src/main/java/com/docus/sw/fenpan/Zong.java b/src/main/java/com/docus/sw/fenpan/Zong.java
new file mode 100644
index 0000000..b541caa
--- /dev/null
+++ b/src/main/java/com/docus/sw/fenpan/Zong.java
@@ -0,0 +1,28 @@
+package com.docus.sw.fenpan;
+
+import com.docus.sw.Config;
+import lombok.Getter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Getter
+public class Zong {
+
+ private String name;
+
+
+ private List rollList;
+
+ private String absolutePath;
+
+ public Zong(String absolutePath,String name){
+ this.name = Config.getParam("zong.name.prefix")+name;
+ this.absolutePath = absolutePath;
+ rollList = new ArrayList<>();
+ }
+
+ public void put(Roll roll){
+ rollList.add(roll);
+ }
+}
diff --git a/src/main/java/com/docus/sw/souyin/ExcelToPdfDemo.java b/src/main/java/com/docus/sw/souyin/ExcelToPdfDemo.java
new file mode 100644
index 0000000..2b70ef0
--- /dev/null
+++ b/src/main/java/com/docus/sw/souyin/ExcelToPdfDemo.java
@@ -0,0 +1,64 @@
+package com.docus.sw.souyin;
+
+import com.itextpdf.text.Font;
+import com.itextpdf.text.*;
+import com.itextpdf.text.pdf.BaseFont;
+import com.itextpdf.text.pdf.PdfPCell;
+import com.itextpdf.text.pdf.PdfPTable;
+import com.itextpdf.text.pdf.PdfWriter;
+import org.apache.poi.ss.usermodel.*;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+public class ExcelToPdfDemo {
+ public static void main(String[] args) {
+ try (Workbook workbook = WorkbookFactory.create(new File("C:\\jiahsi-saomiao\\缩微\\test\\test.xls"));
+ FileOutputStream fos = new FileOutputStream("C:\\jiahsi-saomiao\\缩微\\test\\example.pdf")) {
+ // 获取第一个工作表
+ Sheet sheet = workbook.getSheetAt(0);
+
+ // 创建PDF文档对象
+ Document document = new Document(PageSize.A4, 50, 50, 50, 50);
+
+ // 创建PDF输出流
+ PdfWriter writer = PdfWriter.getInstance(document, fos);
+
+ // 打开PDF文档
+ document.open();
+
+ // 创建PDF表格对象
+ PdfPTable table = new PdfPTable(sheet.getRow(0).getLastCellNum());
+
+ // 设置表格宽度
+ table.setWidthPercentage(100);
+
+ // 设置表格标题
+ Font font = FontFactory.getFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED,10f, Font.NORMAL, BaseColor.BLACK);
+ Paragraph title = new Paragraph("",font);
+ title.setAlignment(Element.ALIGN_CENTER);
+ document.add(title);
+
+ // 添加表格内容
+ for (Row row : sheet) {
+ for (Cell cell : row) {
+ PdfPCell pdfCell = new PdfPCell(new Paragraph(cell.getStringCellValue(), new Font(BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED), 12)));
+ pdfCell.setBorderWidth(1f);
+ pdfCell.setHorizontalAlignment(Element.ALIGN_CENTER);
+ pdfCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ table.addCell(pdfCell);
+ }
+ }
+
+ // 添加表格到PDF文档
+ document.add(table);
+
+ // 关闭PDF文档
+ document.close();
+ writer.close();
+ } catch (IOException | DocumentException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/src/main/java/com/docus/sw/souyin/ExcelUtil.java b/src/main/java/com/docus/sw/souyin/ExcelUtil.java
new file mode 100644
index 0000000..1bf0f22
--- /dev/null
+++ b/src/main/java/com/docus/sw/souyin/ExcelUtil.java
@@ -0,0 +1,88 @@
+package com.docus.sw.souyin;
+
+
+import com.alibaba.excel.EasyExcel;
+import com.itextpdf.text.pdf.PdfWriter;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author 未来码匠
+ */
+public class ExcelUtil {
+ public static void easyExcelTest() throws Exception {
+
+ String fileName = "C:\\jiahsi-saomiao\\缩微\\test\\test.xls";
+ //查询出导出的数据
+ List mesEasyExcels = getData();
+ try {
+ EasyExcel.write(fileName, MesEasyExcel.class).sheet("test").doWrite(mesEasyExcels);
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ }
+ ;
+
+ try {
+ FileInputStream excelFile = new FileInputStream(new File(fileName));
+ Workbook workbook = new HSSFWorkbook(excelFile);
+
+ // 选择要转换的工作表(这里假设你选择第一个工作表)
+ Sheet sheet = workbook.getSheetAt(0);
+
+ // 创建一个输出流,用于将Excel内容写入PDF文件
+ FileOutputStream pdfOutput = new FileOutputStream("C:\\jiahsi-saomiao\\缩微\\test\\output.pdf");
+
+ // 使用iText库创建一个PDF文档
+ com.itextpdf.text.Document pdfDocument = new com.itextpdf.text.Document();
+ PdfWriter.getInstance(pdfDocument, pdfOutput);
+ pdfDocument.open();
+
+ // 读取Excel单元格内容并将其写入PDF
+ for (Row row : sheet) {
+ for (Cell cell : row) {
+ pdfDocument.add(new com.itextpdf.text.Paragraph(cell.toString()));
+ }
+ }
+
+ pdfDocument.close();
+ pdfOutput.close();
+
+ System.out.println("Excel文件已成功转换为PDF文件。");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private static List getData() throws Exception {
+ List list = new ArrayList();
+
+ for (int i = 0; i < 100; i++) {
+ MesEasyExcel m = new MesEasyExcel();
+ m.setZongName("全宗名" + i);
+ m.setPlateName("盘2");
+ m.setRollName("卷名");
+ m.setPieces("档号");
+ m.setNums("80");
+ m.setStartNum("28");
+ list.add(m);
+ }
+
+
+ return list;
+ }
+
+
+ public static void main(String[] args) throws Exception {
+ ExcelUtil.easyExcelTest();
+ }
+
+}
diff --git a/src/main/java/com/docus/sw/souyin/IndexPageRow.java b/src/main/java/com/docus/sw/souyin/IndexPageRow.java
new file mode 100644
index 0000000..be5b025
--- /dev/null
+++ b/src/main/java/com/docus/sw/souyin/IndexPageRow.java
@@ -0,0 +1,24 @@
+package com.docus.sw.souyin;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+@AllArgsConstructor
+@Data
+public class IndexPageRow {
+
+
+ private String zongName;
+
+ private String phNum;
+
+ private String rollName;
+
+ private String piecesName;
+
+ private String nums;
+
+ private Integer start;
+
+
+}
diff --git a/src/main/java/com/docus/sw/souyin/IndexPlate.java b/src/main/java/com/docus/sw/souyin/IndexPlate.java
new file mode 100644
index 0000000..28e8717
--- /dev/null
+++ b/src/main/java/com/docus/sw/souyin/IndexPlate.java
@@ -0,0 +1,14 @@
+package com.docus.sw.souyin;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+@AllArgsConstructor
+@Data
+public class IndexPlate {
+
+ private String absolutePath;
+
+ private String name;
+
+}
diff --git a/src/main/java/com/docus/sw/souyin/MesEasyExcel.java b/src/main/java/com/docus/sw/souyin/MesEasyExcel.java
new file mode 100644
index 0000000..6ce38d4
--- /dev/null
+++ b/src/main/java/com/docus/sw/souyin/MesEasyExcel.java
@@ -0,0 +1,30 @@
+package com.docus.sw.souyin;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import lombok.Data;
+
+/**
+ * @author 未来码匠
+ */
+@Data
+public class MesEasyExcel {
+
+ @ExcelProperty("全宗名")
+ private String zongName;
+
+ @ExcelProperty("盘号")
+ private String plateName;
+
+ @ExcelProperty("卷名")
+ private String rollName;
+
+ @ExcelProperty("档号")
+ private String pieces;
+
+ @ExcelProperty("数量")
+ private String nums;
+
+ @ExcelProperty("起始缩微号")
+ private String startNum;
+
+}
diff --git a/src/main/java/com/docus/sw/souyin/PdfToPic.java b/src/main/java/com/docus/sw/souyin/PdfToPic.java
new file mode 100644
index 0000000..96154b3
--- /dev/null
+++ b/src/main/java/com/docus/sw/souyin/PdfToPic.java
@@ -0,0 +1,34 @@
+package com.docus.sw.souyin;
+
+import org.apache.commons.lang3.tuple.Pair;
+
+import java.util.List;
+
+public class PdfToPic {
+
+ public static void main(String[] args) {
+ new PdfToPic().pdfDocumentToImage2();
+ }
+
+ /**
+ * 多页PDF文档转为图片
+ * 此处单元测试的注解是采用:org.junit.Test
+ */
+
+ public void pdfDocumentToImage2() {
+ String source = "C:\\jiahsi-saomiao\\缩微\\test\\example.pdf";
+ String desFileName = "example";
+ String desFilePath = "C:\\jiahsi-saomiao\\缩微\\test\\";
+ String imageType = "png";
+ Pair pair = PdfUtil.pdfToImage(source, desFilePath, desFileName, imageType);
+ System.out.println("PDF文档转化为图片结果:" + pair.getLeft());
+ if (!pair.getLeft()) {
+ System.out.println("" + pair.getRight());
+ } else {
+ List fileList = (List) pair.getRight();
+ System.out.println("转化的文件的内容:");
+ fileList.forEach(System.out::println);
+ }
+ }
+
+}
diff --git a/src/main/java/com/docus/sw/souyin/PdfUtil.java b/src/main/java/com/docus/sw/souyin/PdfUtil.java
new file mode 100644
index 0000000..d49c9c6
--- /dev/null
+++ b/src/main/java/com/docus/sw/souyin/PdfUtil.java
@@ -0,0 +1,73 @@
+package com.docus.sw.souyin;
+
+
+import org.apache.commons.lang3.tuple.Pair;
+import org.apache.pdfbox.pdmodel.PDDocument;
+import org.apache.pdfbox.rendering.ImageType;
+import org.apache.pdfbox.rendering.PDFRenderer;
+import javax.imageio.ImageIO;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+public class PdfUtil {
+
+ /**
+ * @param source 原文件
+ * @param desFilePath 生成图片的路径
+ * @param desFileName 生成图片的名称(多页文档时会变成:名称+下划线+从1开始的数字)
+ * @param imageType 图片类型
+ * @return
+ */
+ public static Pair pdfToImage(String source, String desFilePath, String desFileName, String imageType) {
+ //通过给定的源路径名字符串创建一个File实例
+ File file = new File(source);
+ if (!file.exists()) {
+ return Pair.of(false, "文件不存在,无法转化");
+ }
+ //目录不存在则创建目录
+ File destination = new File(desFilePath);
+ if (!destination.exists()) {
+ boolean flag = destination.mkdirs();
+ System.out.println("创建文件夹结果:" + flag);
+ }
+ PDDocument doc = null;
+ try {
+ //加载PDF文件
+ doc = PDDocument.load(file);
+ PDFRenderer renderer = new PDFRenderer(doc);
+ //获取PDF文档的页数
+ int pageCount = doc.getNumberOfPages();
+ System.out.println("文档一共" + pageCount + "页");
+ List