Merge remote-tracking branch 'origin/dev' into dev
commit
fbb7322d11
|
@ -16,8 +16,8 @@ import javafx.stage.Stage;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
|
|
||||||
public class BuilderPackageEcology extends Application {
|
public class BuilderPackageEcology extends Application {
|
||||||
|
|
||||||
|
@ -68,17 +68,33 @@ public class BuilderPackageEcology extends Application {
|
||||||
buttonBox.setSpacing(10);
|
buttonBox.setSpacing(10);
|
||||||
buttonBox.setPadding(new Insets(10));
|
buttonBox.setPadding(new Insets(10));
|
||||||
buttonBox.setAlignment(Pos.CENTER_RIGHT);
|
buttonBox.setAlignment(Pos.CENTER_RIGHT);
|
||||||
|
Map<String, String> param = new HashMap<>(8);
|
||||||
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
|
||||||
|
Date date = new Date();
|
||||||
|
param.put("date", simpleDateFormat.format(date));
|
||||||
Button button = new Button("生成升级包");
|
Button button = new Button("生成升级包");
|
||||||
button.setOnAction(event -> {
|
button.setOnAction(event -> {
|
||||||
|
// 输出包编号和功能名称的值
|
||||||
|
String packageNumber = packageNumberTextField.getText();
|
||||||
|
String functionName = functionNameTextField.getText();
|
||||||
FileChooser fileChooser = new FileChooser();
|
FileChooser fileChooser = new FileChooser();
|
||||||
String defaultName = FileTreeBuilder.zipDefaultName;
|
String defaultName = FileTreeBuilder.zipDefaultName;
|
||||||
if (StrUtil.isBlank(defaultName)) {
|
if (StrUtil.isBlank(defaultName)) {
|
||||||
defaultName = "sh_ebu_dev_1_ecology.zip";
|
defaultName = "sh_ebu_dev_1_ecology.zip";
|
||||||
}
|
}
|
||||||
|
param.put("name", functionName);
|
||||||
|
param.put("no", packageNumber);
|
||||||
|
defaultName = replacePlaceholders(defaultName, param);
|
||||||
|
replacePlaceholders(defaultName, param);
|
||||||
|
String defaultDir = FileTreeBuilder.defaultDir;
|
||||||
|
if (StrUtil.isNotBlank(defaultDir)) {
|
||||||
|
try {
|
||||||
|
fileChooser.setInitialDirectory(new File(defaultDir));
|
||||||
|
} catch (Exception ignore) {
|
||||||
|
System.out.println(defaultDir);
|
||||||
|
}
|
||||||
|
}
|
||||||
fileChooser.setInitialFileName(defaultName);
|
fileChooser.setInitialFileName(defaultName);
|
||||||
// fileChooser.setInitialDirectory();
|
|
||||||
File outputFile = fileChooser.showSaveDialog(primaryStage);
|
File outputFile = fileChooser.showSaveDialog(primaryStage);
|
||||||
if (outputFile != null) {
|
if (outputFile != null) {
|
||||||
try {
|
try {
|
||||||
|
@ -97,14 +113,11 @@ public class BuilderPackageEcology extends Application {
|
||||||
});
|
});
|
||||||
clearSelections();
|
clearSelections();
|
||||||
updateTreeView();
|
updateTreeView();
|
||||||
|
packageNumberTextField.setText("");
|
||||||
|
functionNameTextField.setText("");
|
||||||
showSuccessAlert("升级包制作成功!");
|
showSuccessAlert("升级包制作成功!");
|
||||||
System.out.println("压缩包位置: " + outputFile.getPath());
|
System.out.println("压缩包位置: " + outputFile.getPath());
|
||||||
|
|
||||||
// 输出包编号和功能名称的值
|
|
||||||
String packageNumber = packageNumberTextField.getText();
|
|
||||||
String functionName = functionNameTextField.getText();
|
|
||||||
System.out.println("包编号: " + packageNumber);
|
|
||||||
System.out.println("功能名称: " + functionName);
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
@ -154,6 +167,7 @@ public class BuilderPackageEcology extends Application {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
filePaths.clear();
|
filePaths.clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateTreeView() {
|
private void updateTreeView() {
|
||||||
|
@ -217,6 +231,25 @@ public class BuilderPackageEcology extends Application {
|
||||||
alert.showAndWait();
|
alert.showAndWait();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String replacePlaceholders(String inputString, Map<String, String> placeholderMap) {
|
||||||
|
StringBuilder outputString = new StringBuilder(inputString);
|
||||||
|
|
||||||
|
for (Map.Entry<String, String> entry : placeholderMap.entrySet()) {
|
||||||
|
String placeholder = "${" + entry.getKey() + "}";
|
||||||
|
String value = entry.getValue();
|
||||||
|
|
||||||
|
// 检查占位符是否存在于字符串中
|
||||||
|
if (outputString.indexOf(placeholder) != -1) {
|
||||||
|
// 使用 String 类的 replace 方法进行占位符的替换
|
||||||
|
outputString.replace(outputString.indexOf(placeholder),
|
||||||
|
outputString.indexOf(placeholder) + placeholder.length(),
|
||||||
|
value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return outputString.toString();
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
launch(args);
|
launch(args);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package builderpackage;
|
package builderpackage;
|
||||||
|
|
||||||
|
import aiyh.utils.excention.CustomerException;
|
||||||
import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
|
import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.*;
|
||||||
import java.io.IOException;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class FileTreeBuilder {
|
public class FileTreeBuilder {
|
||||||
|
@ -27,7 +27,11 @@ public class FileTreeBuilder {
|
||||||
|
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
try (InputStream inputStream = FileTreeBuilder.class.getClassLoader().getResourceAsStream("application.properties")) {
|
try (InputStream inputStream = FileTreeBuilder.class.getClassLoader().getResourceAsStream("application.properties")) {
|
||||||
properties.load(inputStream);
|
if (inputStream == null) {
|
||||||
|
throw new CustomerException("测试包的resources中不存在application.properties!");
|
||||||
|
}
|
||||||
|
BufferedReader bf = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
|
||||||
|
properties.load(bf);
|
||||||
// 通过键获取属性值
|
// 通过键获取属性值
|
||||||
String value = properties.getProperty("packageBlackPaths");
|
String value = properties.getProperty("packageBlackPaths");
|
||||||
if (StrUtil.isNotBlank(value)) {
|
if (StrUtil.isNotBlank(value)) {
|
||||||
|
@ -65,6 +69,7 @@ public class FileTreeBuilder {
|
||||||
System.out.println("Invalid directory path: " + directoryPath);
|
System.out.println("Invalid directory path: " + directoryPath);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
System.out.println(blackList);
|
||||||
return buildFileTreeRecursively(root, blackList);
|
return buildFileTreeRecursively(root, blackList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +97,7 @@ public class FileTreeBuilder {
|
||||||
if (files != null) {
|
if (files != null) {
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
if (file.isDirectory()) {
|
if (file.isDirectory()) {
|
||||||
if (!isBlacklisted(file.getAbsolutePath(), blacklistPrefixes)) {
|
if (!isBlacklisted(file.getPath(), blacklistPrefixes)) {
|
||||||
FileInfo child = buildFileTreeRecursively(file, blacklistPrefixes);
|
FileInfo child = buildFileTreeRecursively(file, blacklistPrefixes);
|
||||||
fileInfo.addChild(child);
|
fileInfo.addChild(child);
|
||||||
}
|
}
|
||||||
|
@ -121,10 +126,11 @@ public class FileTreeBuilder {
|
||||||
if (filePath.endsWith(".DS_Store") || filePath.endsWith(".DSStore")) {
|
if (filePath.endsWith(".DS_Store") || filePath.endsWith(".DSStore")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
System.out.println("黑名单过滤文件:" + filePath);
|
||||||
for (String prefix : blacklistPrefixes) {
|
for (String prefix : blacklistPrefixes) {
|
||||||
String path = FileTreeBuilder.class.getResource("").getPath();
|
// // String path = FileTreeBuilder.class.getResource("").getPath();
|
||||||
String prefixPath = path.substring(0, path.indexOf(File.separator + "target" + File.separator)) + File.separator;
|
// String prefixPath = path.substring(0, path.indexOf(File.separator + "target" + File.separator)) + File.separator;
|
||||||
if (filePath.startsWith(prefixPath + prefix)) {
|
if (filePath.startsWith(prefix)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue