添加缩略,详细索引模式

master
zhanghai 2 years ago
parent 5242c66f7c
commit ef317a67e4

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

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

@ -152,6 +152,7 @@ public class CheckService {
List<CheckPageRow> checkPageRows = new ArrayList<>(); List<CheckPageRow> checkPageRows = new ArrayList<>();
//生成索引目录 //生成索引目录
Double longth = 0d;
for (IndexPlate indexPlate : map.values()) { for (IndexPlate indexPlate : map.values()) {
List<Roll> rollList = indexPlate.getRollList(); List<Roll> rollList = indexPlate.getRollList();
for(Roll roll:rollList){ for(Roll roll:rollList){
@ -159,13 +160,18 @@ public class CheckService {
for(Pieces pieces:piecesList){ for(Pieces pieces:piecesList){
List<Document> documentList = pieces.getDocumentList(); List<Document> documentList = pieces.getDocumentList();
for(Document document:documentList){ 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); 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); 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) { private void findAllDir(String absolutePath, Map<String, IndexPlate> map) {

@ -34,8 +34,7 @@ public class SuoyinService {
//统计出需要使用的 胶片量 //统计出需要使用的 胶片量
public void index(String path, String indexType) throws IOException {
public void index(String path) throws IOException {
Map<String, IndexPlate> map = new HashMap<>(); Map<String, IndexPlate> map = new HashMap<>();
findAllDir(path, map); findAllDir(path, map);
@ -176,7 +175,7 @@ public class SuoyinService {
} }
} }
if (indexType.equals("简略索引")) {
List<IndexPageRow> indexPageRows = indexGen(indexPlate, rollList, pianPageNum, totalSize); List<IndexPageRow> indexPageRows = indexGen(indexPlate, rollList, pianPageNum, totalSize);
//修正数据 //修正数据
System.out.println(new Gson().toJson(indexPageRows)); System.out.println(new Gson().toJson(indexPageRows));
@ -227,9 +226,13 @@ public class SuoyinService {
File xlsParentFile = xls.getParentFile().getParentFile(); File xlsParentFile = xls.getParentFile().getParentFile();
File file2 = new File(xlsParentFile.getAbsolutePath() + "/" + indexPlate.getName() + ".xls"); File file2 = new File(xlsParentFile.getAbsolutePath() + "/" + indexPlate.getName() + ".xls");
Files.move(xls.toPath(), file2.toPath()); Files.move(xls.toPath(), file2.toPath());
}
//计算完整索引 //计算完整索引
if (indexType.equals("详细索引")) {
List<FullIndexPageRow> fullIndexPageRows = new ArrayList<>(); List<FullIndexPageRow> fullIndexPageRows = new ArrayList<>();
int i = 1; int i = 1;
for (Roll roll : rollList) { for (Roll roll : rollList) {
@ -246,6 +249,8 @@ public class SuoyinService {
File file1 = new File(indexPlate.getAbsolutePath()); File file1 = new File(indexPlate.getAbsolutePath());
EasyExcel.write(file1.getParentFile().getAbsolutePath() + "/full-index-" + indexPlate.getName() + ".xls", FullIndexPageRow.class).sheet("test").doWrite(fullIndexPageRows); EasyExcel.write(file1.getParentFile().getAbsolutePath() + "/full-index-" + indexPlate.getName() + ".xls", FullIndexPageRow.class).sheet("test").doWrite(fullIndexPageRows);
}
} }

Loading…
Cancel
Save