pull/1/head
李建辉 1 year ago
parent 7703cba46b
commit f78cbe4c4a

3
.gitignore vendored

@ -3,4 +3,5 @@
/.metadata/ /.metadata/
/com.connor.chint.sap2/bin/ /com.connor.chint.sap2/bin/
/com.connor.chint.sap2/.settings /com.connor.chint.sap2/.settings
RemoteSystemsTempFiles/* RemoteSystemsTempFiles/*
/build/

@ -50,6 +50,7 @@ public class SpecStatementDialog2 extends AbstractAIFDialog {
private JButton b_path; // 文件保存路径 private JButton b_path; // 文件保存路径
protected JTextField jtf_path; // 文件路径 protected JTextField jtf_path; // 文件路径
private String name;//报表类型 private String name;//报表类型
private String nameEnglish;//报表类型
public static final String[] HEADER = new String[] { "", "序号", "方案名称", "物料编码" }; public static final String[] HEADER = new String[] { "", "序号", "方案名称", "物料编码" };
public static final int[] HEADERWIDTH = new int[] { 50, 60, 180, 180 }; public static final int[] HEADERWIDTH = new int[] { 50, 60, 180, 180 };
@ -98,10 +99,12 @@ public class SpecStatementDialog2 extends AbstractAIFDialog {
case "001": case "001":
this.setTitle("一次规范书汇总报表导出"); // 中压 this.setTitle("一次规范书汇总报表导出"); // 中压
name = "中压一次规范书汇总报表"; name = "中压一次规范书汇总报表";
nameEnglish = "a";
break; break;
case "002": case "002":
this.setTitle("二次规范书汇总报表导出"); // 中压 this.setTitle("二次规范书汇总报表导出"); // 中压
name = "中压二次规范书汇总报表"; name = "中压二次规范书汇总报表";
nameEnglish = "b";
break; break;
case "003": case "003":
@ -225,18 +228,31 @@ public class SpecStatementDialog2 extends AbstractAIFDialog {
JPanel panel = new JPanel(new PropertyLayout()); JPanel panel = new JPanel(new PropertyLayout());
jtf_path = new JTextField(30); jtf_path = new JTextField(30);
//2022/11/14新增记录保存路径 //2022/11/14新增记录保存路径
String tempPath = System.getProperty("java.io.tmpdir"); //2022/11/14新增记录保存路径
String tempFilePath = tempPath + File.separator + name + "功能导出路径.txt"; System.out.println("System.getenv(\"Temp\")==========="+System.getenv("Temp"));
File exportFileTxt = new File(tempFilePath); Path configFilePath = Paths.get(System.getenv("Temp")+"//export_dir.config");
if(exportFileTxt.exists()) { // 检查文件是否存在,不存在则创建
String[] openTextFile = openTextFile(tempFilePath); if (!Files.exists(configFilePath)) {
System.out.println("上次保存路径:"+openTextFile[0]); Files.createFile(configFilePath);
jtf_path.setText(openTextFile[0]); }
}else {
File desktopDir = FileSystemView.getFileSystemView().getHomeDirectory(); Properties properties = new Properties();
String desktopPath = desktopDir.getAbsolutePath(); try (InputStream in = new FileInputStream(System.getenv("Temp")+"//export_dir.config")) {
jtf_path.setText(desktopPath); properties.load(in);
} }
System.out.println("properties==="+properties.toString());
System.out.println("size==="+properties.size());
System.out.println("nameEnglish======="+nameEnglish);
String property = properties.getProperty(nameEnglish);
if(property != null && !property.isEmpty()) {
jtf_path.setText(property);
}else {
File desktopDir = FileSystemView.getFileSystemView().getHomeDirectory();
String desktopPath = desktopDir.getAbsolutePath();
jtf_path.setText(desktopPath);
}
b_path = new JButton("浏览"); b_path = new JButton("浏览");
panel.add("1.1.left.top", new JLabel("报表保存路径: ")); panel.add("1.1.left.top", new JLabel("报表保存路径: "));
@ -250,16 +266,13 @@ public class SpecStatementDialog2 extends AbstractAIFDialog {
JFileChooser jfc = new JFileChooser(); JFileChooser jfc = new JFileChooser();
FileSystemView fsv = FileSystemView.getFileSystemView(); FileSystemView fsv = FileSystemView.getFileSystemView();
//2022/11/14新增记录保存路径 //2022/11/14新增记录保存路径
String tempPath = System.getProperty("java.io.tmpdir"); String property = properties.getProperty(nameEnglish);
String tempFilePath = tempPath + File.separator + name + "功能导出路径.txt"; if(property != null && !property.isEmpty()) {
File exportFileTxt = new File(tempFilePath); jfc.setCurrentDirectory(new File(property));
if(exportFileTxt.exists()) {
String[] openTextFile = openTextFile(tempFilePath);
System.out.println("上次保存路径:"+openTextFile[0]);
jfc.setCurrentDirectory(new File(openTextFile[0]));
}else { }else {
jfc.setCurrentDirectory(fsv.getHomeDirectory()); jfc.setCurrentDirectory(fsv.getHomeDirectory());
} }
System.out.println("111111111111111111111111111111111111111111111111");
jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
jfc.showOpenDialog(SpecStatementDialog2.this); jfc.showOpenDialog(SpecStatementDialog2.this);
@ -268,12 +281,15 @@ public class SpecStatementDialog2 extends AbstractAIFDialog {
System.out.println("->" + f.getAbsolutePath()); System.out.println("->" + f.getAbsolutePath());
jtf_path.setText(f.getAbsolutePath()); jtf_path.setText(f.getAbsolutePath());
//2022/11/14新增记录保存路径 //2022/11/14新增记录保存路径
try { properties.setProperty(nameEnglish, f.getAbsolutePath());
writeFile(tempFilePath,f.getAbsolutePath()); System.out.println("f.getAbsolutePath()=========="+f.getAbsolutePath());
} catch (IOException e1) { }
// TODO Auto-generated catch block // 保存修改后的配置
e1.printStackTrace(); try (OutputStream out = Files.newOutputStream(configFilePath)) {
} properties.store(out, null);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} }
} }
}); });

Loading…
Cancel
Save