添加检查工作

master
zhanghai 2 years ago
parent b5d3a7a526
commit 605e4159e9

@ -27,11 +27,37 @@ public class Document {
//写一个方法判断是 A3 还是 A4
public Boolean isA3() {
if (width / dpi > Integer.parseInt(Config.getParam("a3.width"))
|| longTh / dpi > Integer.parseInt(Config.getParam("a3.length"))) {
if (width / dpi > Integer.parseInt(Config.getParam("a4.width"))
|| longTh / dpi > Integer.parseInt(Config.getParam("a4.length"))) {
return true;
}
return false;
}
public String toSize(){
if(width / dpi > Integer.parseInt(Config.getParam("a4.width"))
|| longTh / dpi > Integer.parseInt(Config.getParam("a4.length"))){
return "A3";
}else if(width / dpi > Integer.parseInt(Config.getParam("a3.width"))
|| longTh / dpi > Integer.parseInt(Config.getParam("a3.length"))){
return "A3以上";
}else {
return "A4";
}
}
public Double useStore(){
if(width / dpi > Integer.parseInt(Config.getParam("a4.width"))
|| longTh / dpi > Integer.parseInt(Config.getParam("a4.length"))){
return 2d;
}else if(width / dpi > Integer.parseInt(Config.getParam("a3.width"))
|| longTh / dpi > Integer.parseInt(Config.getParam("a3.length"))){
return 4.2d;
}else {
return 1d;
}
}
}

@ -1,6 +1,7 @@
package com.docus.sw.fenpan;
import com.docus.sw.Config;
import com.docus.sw.souyin.CheckService;
import com.docus.sw.souyin.SuoyinService;
import javax.swing.*;
@ -277,9 +278,13 @@ public class MyApplication {
splitPanel.add(leftPanel, BorderLayout.WEST);
splitPanel.add(rightPanel, BorderLayout.CENTER);
tabbedPane.addTab("参数设置", paramPanel);
tabbedPane.addTab("分盘工具", splitPanel);
tabbedPane.addTab("索引工具", createIndexPanel());
tabbedPane.addTab("检查工具", checkPanel());
frame.add(tabbedPane);
frame.setVisible(true);
@ -294,6 +299,132 @@ public class MyApplication {
plateSizeJtf.setText(Config.getParam("plate.size"));
}
public static JPanel checkPanel(){
// 分盘工具标签页
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;
leftGbc.anchor = GridBagConstraints.WEST;
leftPanel.add(new JLabel("文件路径选择:"), leftGbc);
JTextField filePathField = new JTextField(20);
leftGbc.gridx = 1;
leftGbc.gridwidth = 1;
leftPanel.add(filePathField, leftGbc);
JButton fileChooserButton = new JButton("选择文件");
leftGbc.gridx = 2;
leftPanel.add(fileChooserButton, leftGbc);
// 文件选择按钮的动作监听器,打开文件选择对话框
fileChooserButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFileChooser fileChooser = new JFileChooser();
int returnValue = fileChooser.showOpenDialog(null);
if (returnValue == JFileChooser.APPROVE_OPTION) {
File selectedFile = fileChooser.getSelectedFile();
filePathField.setText(selectedFile.getAbsolutePath());
}
}
});
// leftGbc.gridx = 0;
// leftGbc.gridy = 1;
// leftGbc.anchor = GridBagConstraints.WEST;
// leftPanel.add(new JLabel("dpi:"), leftGbc);
// JTextField dpiField = new JTextField(20);
// leftGbc.gridx = 1;
// leftPanel.add(dpiField, leftGbc);
//
// leftGbc.gridx = 0;
// leftGbc.gridy = 2;
// leftPanel.add(new JLabel("胶片长度:"), leftGbc);
// JTextField filmLengthField = new JTextField(20);
// leftGbc.gridx = 1;
// leftPanel.add(filmLengthField, leftGbc);
//
// leftGbc.gridx = 0;
// leftGbc.gridy = 3;
// leftPanel.add(new JLabel("图像格式:"), leftGbc);
// String[] imageFormats = {"图片", "pdf", "word"};
// JComboBox<String> formatComboBox = new JComboBox<>(imageFormats);
// leftGbc.gridx = 1;
// leftPanel.add(formatComboBox, leftGbc);
//
// // 添加图像格式选择框的监听器,可以根据选择的格式执行相应操作
// formatComboBox.addActionListener(new ActionListener() {
// @Override
// public void actionPerformed(ActionEvent e) {
// String selectedFormat = (String) formatComboBox.getSelectedItem();
// // 在这里执行根据选择的格式的操作
// System.out.println("选择的图像格式: " + selectedFormat);
// }
// });
leftGbc.gridx = 1;
leftGbc.gridy = 4;
JButton jButton = new JButton("开始检查");
leftPanel.add(jButton, leftGbc);
// ... 其他左边的功能选项,与前面的代码相同 ...
// 添加到左右布局
splitPanel.add(leftPanel, BorderLayout.WEST);
JTextArea logTextArea = new JTextArea();
JScrollPane logScrollPane = new JScrollPane(logTextArea);
logScrollPane.setPreferredSize(new Dimension(200, 200));
splitPanel.add(logScrollPane, BorderLayout.CENTER);
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() {
@Override
public void run() {
logTextArea.append(df.format(new Date())+": 检查开始。。。"+ "\n");
}
});
// 启动一个异步任务
Thread workerThread = new Thread(() -> {
// 执行长时间运行的业务操作
// 模拟耗时操作
try {
new CheckService().index(filePathField.getText());
} catch (IOException ex) {
throw new RuntimeException(ex);
}
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
// 在EDT上更新UI
logTextArea.append(df.format(new Date())+": 检查结束。。。"+ "\n");
}
});
});
workerThread.start(); // 启动线程
}
});
return splitPanel;
}
private static JPanel createIndexPanel() {
JPanel indexPanel = new JPanel(new BorderLayout());
JPanel leftIndexPanel = new JPanel(new GridBagLayout());

@ -0,0 +1,25 @@
package com.docus.sw.souyin;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
@AllArgsConstructor
@Data
public class CheckPageRow {
@ExcelProperty("盘号")
private String phNum;
@ExcelProperty("文件名")
private String documentName;
@ExcelProperty("dpi")
private Integer dpi;
@ExcelProperty("胶片用量(厘米)")
private Double useStore;
}

@ -46,6 +46,9 @@ public class CheckService {
//计算出每个盘的目录。
for (IndexPlate indexPlate : map.values()) {
//计算每盘是否有 图片dpi 不足,或者格式不正确的情况。
String absolutePath = indexPlate.getAbsolutePath();
File file = new File(absolutePath);
File[] files = file.listFiles();
@ -145,6 +148,9 @@ public class CheckService {
FileUtils.delete(new File("tempIndex"));
List<CheckPageRow> checkPageRows = new ArrayList<>();
//生成索引目录
for (IndexPlate indexPlate : map.values()) {
List<Roll> rollList = indexPlate.getRollList();
@ -153,12 +159,14 @@ 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());
checkPageRows.add(checkPageRow);
}
}
}
}
EasyExcel.write("check" + ".xls", CheckPageRow.class).sheet("test").doWrite(checkPageRows);
}

Loading…
Cancel
Save