添加缩略,详细索引模式

master
zhanghai 2 years ago
parent 5242c66f7c
commit ef317a67e4

@ -317,8 +317,8 @@ public class MyApplication {
tabbedPane.addTab("参数设置", paramPanel);
tabbedPane.addTab("分盘工具", splitPanel);
tabbedPane.addTab("索引工具", createIndexPanel());
tabbedPane.addTab("检查工具", checkPanel());
tabbedPane.addTab("索引工具", createIndexPanel());
frame.add(tabbedPane);
frame.setVisible(true);
@ -344,6 +344,8 @@ public class MyApplication {
leftGbc.insets = new Insets(5, 5, 5, 5);
leftGbc.gridx = 0;
leftGbc.gridy = 0;
leftGbc.anchor = GridBagConstraints.WEST;
@ -470,8 +472,18 @@ public class MyApplication {
GridBagConstraints leftIndexGbc = new GridBagConstraints();
leftIndexGbc.insets = new Insets(5, 5, 5, 5);
leftIndexGbc.gridx = 0;
leftIndexGbc.gridy = 0;
leftIndexPanel.add(new JLabel("索引模式:"));
String[] rollmodes = {"详细索引", "简略索引"};
JComboBox<String> rollmodeComboBox = new JComboBox<>(rollmodes);
leftIndexGbc.gridx = 1;
leftIndexGbc.gridwidth = 1;
leftIndexPanel.add(rollmodeComboBox);
leftIndexGbc.gridx = 0;
leftIndexGbc.gridy = 1;
leftIndexGbc.anchor = GridBagConstraints.WEST;
leftIndexPanel.add(new JLabel("文件路径选择:"), leftIndexGbc);
JTextField filePathField = new JTextField(20);
@ -508,7 +520,7 @@ public class MyApplication {
// ... 其他标签左对齐,与前面的代码相同 ...
leftIndexGbc.gridx = 0;
leftIndexGbc.gridy = 2;
leftIndexGbc.gridy = 3;
leftIndexGbc.gridwidth = 2;
leftIndexGbc.anchor = GridBagConstraints.CENTER;
JButton jButton = new JButton("开始生成索引");
@ -529,6 +541,7 @@ public class MyApplication {
jButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// 在EDT上执行更新操作
SwingUtilities.invokeLater(new Runnable() {
@ -546,7 +559,7 @@ public class MyApplication {
// 模拟耗时操作
try {
new SuoyinService().index(filePathField.getText());
new SuoyinService().index(filePathField.getText(),rollmodeComboBox.getSelectedItem().toString());
} catch (IOException ex) {
throw new RuntimeException(ex);
}

@ -21,5 +21,6 @@ public class CheckPageRow {
@ExcelProperty("胶片用量(厘米)")
private Double useStore;
@ExcelProperty("画幅幅面")
private String sizeString;
}

@ -152,6 +152,7 @@ public class CheckService {
List<CheckPageRow> checkPageRows = new ArrayList<>();
//生成索引目录
Double longth = 0d;
for (IndexPlate indexPlate : map.values()) {
List<Roll> rollList = indexPlate.getRollList();
for(Roll roll:rollList){
@ -159,13 +160,18 @@ public class CheckService {
for(Pieces pieces:piecesList){
List<Document> documentList = pieces.getDocumentList();
for(Document document:documentList){
CheckPageRow checkPageRow = new CheckPageRow(indexPlate.getName(), document.getName(), document.getDpi(), document.useStore());
CheckPageRow checkPageRow = new CheckPageRow(indexPlate.getName(), document.getName(), document.getDpi(), document.useStore(),document.toSize());
checkPageRows.add(checkPageRow);
longth+=checkPageRow.getUseStore();
}
}
}
}
//加上统计
CheckPageRow checkPageRow = new CheckPageRow("", "总计长度:", null, longth,"");
checkPageRows.add(checkPageRow);
EasyExcel.write(savepath+"/check" + ".xls", CheckPageRow.class).sheet("test").doWrite(checkPageRows);
}
@ -216,66 +222,6 @@ public class CheckService {
}
private List<IndexPageRow> indexGen(IndexPlate indexPlate, List<Roll> rollList, Integer pianPageNum, Integer totalSize) {
List<IndexPageRow> indexPageRows = new ArrayList<>();
int start = 1;
//添加片头
for (Roll roll : rollList) {
//跳过片头
if (roll.getName().equals("片头")) {
File file = new File(roll.getAbsolutePath());
int fileasize = file.listFiles().length;
fileasize += pianPageNum;
IndexPageRow indexPageRow = new IndexPageRow(indexPlate.getZongName(), indexPlate.getName(), roll.getName(), "", fileasize, start);
start += fileasize;
indexPageRows.add(indexPageRow);
start += 1;
}
}
//处理偏中
for (Roll roll : rollList) {
//跳过片头
if (roll.getName().equals("片头")) {
continue;
}
//跳过片尾
if (roll.getName().equals("片尾")) {
continue;
}
List<Pieces> piecesList = roll.getPiecesList();
for (Pieces pieces : piecesList) {
IndexPageRow indexPageRow = new IndexPageRow(indexPlate.getZongName(), indexPlate.getName(), roll.getName(), pieces.getName(), pieces.getDocumentList().size(), start);
start += pieces.getDocumentList().size();
indexPageRows.add(indexPageRow);
}
start += 1;
}
//添加片尾
for (Roll roll : rollList) {
//跳过片头
if (roll.getName().equals("片尾")) {
File file = new File(roll.getAbsolutePath());
int fileasize = file.listFiles().length;
fileasize += pianPageNum;
IndexPageRow indexPageRow = new IndexPageRow(indexPlate.getZongName(), indexPlate.getName(), roll.getName(), "", fileasize, start);
start += fileasize;
indexPageRows.add(indexPageRow);
start += 1;
}
}
//加上统计
IndexPageRow indexPageRow = new IndexPageRow("", "", "", "有效画幅数", totalSize, null);
indexPageRows.add(indexPageRow);
return indexPageRows;
}
private void findAllDir(String absolutePath, Map<String, IndexPlate> map) {

@ -34,8 +34,7 @@ public class SuoyinService {
//统计出需要使用的 胶片量
public void index(String path) throws IOException {
public void index(String path, String indexType) throws IOException {
Map<String, IndexPlate> map = new HashMap<>();
findAllDir(path, map);
@ -176,76 +175,82 @@ public class SuoyinService {
}
}
if (indexType.equals("简略索引")) {
List<IndexPageRow> indexPageRows = indexGen(indexPlate, rollList, pianPageNum, totalSize);
//修正数据
System.out.println(new Gson().toJson(indexPageRows));
List<IndexPageRow> indexPageRows = indexGen(indexPlate, rollList, pianPageNum, totalSize);
//修正数据
System.out.println(new Gson().toJson(indexPageRows));
//生成excel
List<MesEasyExcel> mesEasyExcels = new ArrayList<>();
for (IndexPageRow indexPageRowTemp : indexPageRows) {
mesEasyExcels.add(MesEasyExcel.create(indexPageRowTemp));
}
//生成excel
List<MesEasyExcel> mesEasyExcels = new ArrayList<>();
for (IndexPageRow indexPageRowTemp : indexPageRows) {
mesEasyExcels.add(MesEasyExcel.create(indexPageRowTemp));
}
EasyExcel.write(indexPlate.getAbsolutePath() + "/" + indexPlate.getName() + ".xls", MesEasyExcel.class).sheet("test").doWrite(mesEasyExcels);
EasyExcel.write(indexPlate.getAbsolutePath() + "/" + indexPlate.getName() + ".xls", MesEasyExcel.class).sheet("test").doWrite(mesEasyExcels);
ExcelUtil.toPdf(indexPlate.getAbsolutePath() + "/" + indexPlate.getName() + ".xls", indexPlate.getAbsolutePath() + "/" + indexPlate.getName() + ".pdf");
ExcelUtil.toPdf(indexPlate.getAbsolutePath() + "/" + indexPlate.getName() + ".xls", indexPlate.getAbsolutePath() + "/" + indexPlate.getName() + ".pdf");
Integer page = PdfUtil.getPage(indexPlate.getAbsolutePath() + "/" + indexPlate.getName() + ".pdf");
Integer page = PdfUtil.getPage(indexPlate.getAbsolutePath() + "/" + indexPlate.getName() + ".pdf");
indexPageRows = indexGen(indexPlate, rollList, page, totalSize);
//修正数据
System.out.println(new Gson().toJson(indexPageRows));
indexPageRows = indexGen(indexPlate, rollList, page, totalSize);
//修正数据
System.out.println(new Gson().toJson(indexPageRows));
//生成excel
mesEasyExcels = new ArrayList<>();
for (IndexPageRow indexPageRowTemp : indexPageRows) {
mesEasyExcels.add(MesEasyExcel.create(indexPageRowTemp));
}
//生成excel
mesEasyExcels = new ArrayList<>();
for (IndexPageRow indexPageRowTemp : indexPageRows) {
mesEasyExcels.add(MesEasyExcel.create(indexPageRowTemp));
}
EasyExcel.write(indexPlate.getAbsolutePath() + "/" + indexPlate.getName() + ".xls", MesEasyExcel.class).sheet("test").doWrite(mesEasyExcels);
ExcelUtil.toPdf(indexPlate.getAbsolutePath() + "/" + indexPlate.getName() + ".xls", indexPlate.getAbsolutePath() + "/" + indexPlate.getName() + ".pdf");
EasyExcel.write(indexPlate.getAbsolutePath() + "/" + indexPlate.getName() + ".xls", MesEasyExcel.class).sheet("test").doWrite(mesEasyExcels);
//写入文件夹。
PdfToPic.toPic(indexPlate.getAbsolutePath() + "/" + indexPlate.getName() + ".pdf", indexPlate.getAbsolutePath() + "/片头", "01", "jpg");
ExcelUtil.toPdf(indexPlate.getAbsolutePath() + "/" + indexPlate.getName() + ".xls", indexPlate.getAbsolutePath() + "/" + indexPlate.getName() + ".pdf");
//写入文件夹。
PdfToPic.toPic(indexPlate.getAbsolutePath() + "/" + indexPlate.getName() + ".pdf", indexPlate.getAbsolutePath() + "/片头", "01", "jpg");
PdfToPic.toPicDesc(indexPlate.getAbsolutePath() + "/" + indexPlate.getName() + ".pdf", indexPlate.getAbsolutePath() + "/片尾", "00", "jpg");
File pdf = new File(indexPlate.getAbsolutePath() + "/" + indexPlate.getName() + ".pdf");
//再重算一次索引,以及将文件进行替换。
File parentFile = pdf.getParentFile().getParentFile();
File file = new File(parentFile.getAbsolutePath() + "/" + indexPlate.getName() + ".pdf");
Files.move(pdf.toPath(), file.toPath(), StandardCopyOption.ATOMIC_MOVE);
PdfToPic.toPicDesc(indexPlate.getAbsolutePath() + "/" + indexPlate.getName() + ".pdf", indexPlate.getAbsolutePath() + "/片尾", "00", "jpg");
File xls = new File(indexPlate.getAbsolutePath() + "/" + indexPlate.getName() + ".xls");
//再重算一次索引,以及将文件进行替换。
File xlsParentFile = xls.getParentFile().getParentFile();
File file2 = new File(xlsParentFile.getAbsolutePath() + "/" + indexPlate.getName() + ".xls");
Files.move(xls.toPath(), file2.toPath());
}
File pdf = new File(indexPlate.getAbsolutePath() + "/" + indexPlate.getName() + ".pdf");
//再重算一次索引,以及将文件进行替换。
File parentFile = pdf.getParentFile().getParentFile();
File file = new File(parentFile.getAbsolutePath() + "/" + indexPlate.getName() + ".pdf");
Files.move(pdf.toPath(), file.toPath(), StandardCopyOption.ATOMIC_MOVE);
File xls = new File(indexPlate.getAbsolutePath() + "/" + indexPlate.getName() + ".xls");
//再重算一次索引,以及将文件进行替换。
File xlsParentFile = xls.getParentFile().getParentFile();
File file2 = new File(xlsParentFile.getAbsolutePath() + "/" + indexPlate.getName() + ".xls");
Files.move(xls.toPath(), file2.toPath());
//计算完整索引
List<FullIndexPageRow> fullIndexPageRows = new ArrayList<>();
int i = 1;
for (Roll roll : rollList) {
List<Pieces> piecesList = roll.getPiecesList();
for (Pieces pieces : piecesList) {
List<Document> documentList = pieces.getDocumentList();
for (Document document : documentList) {
FullIndexPageRow fullIndexPageRow = new FullIndexPageRow(indexPlate.getZongName(), indexPlate.getName(), roll.getName(), pieces.getName(), document.getName(), document.isA3() ? "A3" : "A4", i);
fullIndexPageRows.add(fullIndexPageRow);
i++;
if (indexType.equals("详细索引")) {
List<FullIndexPageRow> fullIndexPageRows = new ArrayList<>();
int i = 1;
for (Roll roll : rollList) {
List<Pieces> piecesList = roll.getPiecesList();
for (Pieces pieces : piecesList) {
List<Document> documentList = pieces.getDocumentList();
for (Document document : documentList) {
FullIndexPageRow fullIndexPageRow = new FullIndexPageRow(indexPlate.getZongName(), indexPlate.getName(), roll.getName(), pieces.getName(), document.getName(), document.isA3() ? "A3" : "A4", i);
fullIndexPageRows.add(fullIndexPageRow);
i++;
}
}
}
File file1 = new File(indexPlate.getAbsolutePath());
EasyExcel.write(file1.getParentFile().getAbsolutePath() + "/full-index-" + indexPlate.getName() + ".xls", FullIndexPageRow.class).sheet("test").doWrite(fullIndexPageRows);
}
File file1 = new File(indexPlate.getAbsolutePath());
EasyExcel.write(file1.getParentFile().getAbsolutePath() + "/full-index-" + indexPlate.getName() + ".xls", FullIndexPageRow.class).sheet("test").doWrite(fullIndexPageRows);
}
@ -274,7 +279,7 @@ public class SuoyinService {
BufferedImage image = ImageIO.read(docfile);
int height = image.getHeight();
int width = image.getWidth();
Document document = new Document(width, height, 300, docfile.getName(),null);
Document document = new Document(width, height, 300, docfile.getName(), null);
documentList.add(document);
} catch (IOException e) {
throw new RuntimeException(e);
@ -286,7 +291,7 @@ public class SuoyinService {
int height = imageInfo.getHeight();
int width = imageInfo.getWidth();
int physicalHeightDpi = imageInfo.getPhysicalHeightDpi();
Document document = new Document(width, height, physicalHeightDpi, docfile.getName(),null);
Document document = new Document(width, height, physicalHeightDpi, docfile.getName(), null);
documentList.add(document);
} catch (IOException e) {
throw new RuntimeException("非图片格式", e);

Loading…
Cancel
Save