|
@@ -1,11 +1,12 @@
|
|
|
package com.persagy.filemove.app;
|
|
|
|
|
|
import com.persagy.filemove.dto.SagaFileMoveDTO;
|
|
|
-import com.persagy.filemove.dto.WorkerValidParam;
|
|
|
import com.persagy.filemove.service.SagaFileMoveService;
|
|
|
import com.persagy.filemove.util.StringTools;
|
|
|
import javafx.application.Application;
|
|
|
+import javafx.application.Platform;
|
|
|
import javafx.collections.FXCollections;
|
|
|
+import javafx.concurrent.Task;
|
|
|
import javafx.geometry.Insets;
|
|
|
import javafx.geometry.Pos;
|
|
|
import javafx.scene.Node;
|
|
@@ -96,7 +97,6 @@ public class SagaFileMoveApp extends Application {
|
|
|
/** 进度指示器 */
|
|
|
private ProgressBar progressBar = new ProgressBar(0);
|
|
|
|
|
|
-
|
|
|
public static void main(String[] args) {
|
|
|
launch(args);
|
|
|
}
|
|
@@ -138,13 +138,20 @@ public class SagaFileMoveApp extends Application {
|
|
|
progressBar.setPrefSize(appWidth * .65, 25);
|
|
|
|
|
|
btnValid.setOnAction(e -> {
|
|
|
- progressBar.setProgress(-1);
|
|
|
- validParam();
|
|
|
- progressBar.setProgress(1);
|
|
|
+ progressBar.progressProperty().unbind();
|
|
|
+ progressBar.setProgress(0);
|
|
|
+ Task<Boolean> worker = paramValidWorker();
|
|
|
+ progressBar.progressProperty().bind(worker.progressProperty());
|
|
|
+ worker.messageProperty().addListener((obv, ov, nv)->{
|
|
|
+ System.out.println(nv);
|
|
|
+ });
|
|
|
+ new Thread(worker).start();
|
|
|
});
|
|
|
|
|
|
+
|
|
|
btnExecute.setOnAction(e -> {
|
|
|
- if(validParam()) {
|
|
|
+ String errorMsg = getParamValidResult();
|
|
|
+ if(errorMsg != null && errorMsg.startsWith("success")) {
|
|
|
// 记录当前参数
|
|
|
writeInfoToLogFile("执行参数:" + dto.toString());
|
|
|
|
|
@@ -168,7 +175,30 @@ public class SagaFileMoveApp extends Application {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ public Task<Boolean> paramValidWorker() {
|
|
|
+ return new Task<Boolean>() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected Boolean call() throws Exception {
|
|
|
+ updateProgress(-1, 1);
|
|
|
+ String result = getParamValidResult();
|
|
|
+ updateProgress(1, 1);
|
|
|
+
|
|
|
+ Platform.runLater(() -> {
|
|
|
+ if(result.startsWith("success")) {
|
|
|
+ if(result.contains("warning")) {
|
|
|
+ showTipsWarn(result);
|
|
|
+ }else {
|
|
|
+ showTipsSuccess(result);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ showTipsError(result);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -191,44 +221,39 @@ public class SagaFileMoveApp extends Application {
|
|
|
|
|
|
/**
|
|
|
* 校验参数
|
|
|
- * @return
|
|
|
+ * @return 参数无误,返回"success-信息";
|
|
|
*/
|
|
|
- private boolean validParam() {
|
|
|
- showTipsInfo("");
|
|
|
- boolean result = true;
|
|
|
- WorkerValidParam worker = new WorkerValidParam(this);
|
|
|
- worker.start();
|
|
|
+ private String getParamValidResult() {
|
|
|
+ String errorMsg = null;
|
|
|
|
|
|
if(StringTools.isBlank(dto.dpf.getValue()) || StringTools.isBlank(dto.pjId.getValue()) ||
|
|
|
StringTools.isBlank(dto.imgFromUrl.getValue()) || StringTools.isBlank(dto.imgFromSysId.getValue()) ||
|
|
|
StringTools.isBlank(dto.imgFromSecret.getValue()) || StringTools.isBlank(dto.imgToUrl.getValue()) ||
|
|
|
StringTools.isBlank(dto.imgToSysId.getValue()) || StringTools.isBlank(dto.imgToSecret.getValue())) {
|
|
|
- showTipsError("必填参数不能为空!");
|
|
|
- result = false;
|
|
|
+ errorMsg = "必填参数不能为空!";
|
|
|
}
|
|
|
|
|
|
- if(result && !service.validParamDpfAndPj(this)) {
|
|
|
- showTipsError("获取不到项目信息!请确保数据平台地址和项目id参数正确。");
|
|
|
- result = false;
|
|
|
+ if(errorMsg == null && !service.validParamDpfAndPj(this)) {
|
|
|
+ errorMsg = "获取不到项目信息!请确保数据平台地址和项目id参数正确。";
|
|
|
}
|
|
|
|
|
|
- if(result && !service.validParamImgFromUrl()) {
|
|
|
- showTipsError("[文件服务-From]访问不通!请确保URL正确。");
|
|
|
- result = false;
|
|
|
+ if(errorMsg == null && !service.validParamImgFromUrl()) {
|
|
|
+ errorMsg = "[文件服务-From]访问不通!请确保URL正确。";
|
|
|
}
|
|
|
|
|
|
- if(result && !service.validParamImgToUrl()) {
|
|
|
- showTipsError("[文件服务-To]访问不通!请确保URL正确。");
|
|
|
- result = false;
|
|
|
+ if(errorMsg == null && !service.validParamImgToUrl()) {
|
|
|
+ errorMsg = "[文件服务-To]访问不通!请确保URL正确。";
|
|
|
}
|
|
|
|
|
|
- if(result && dto.imgFromUrl.getValue().equals(dto.imgToUrl.getValue())) {
|
|
|
- showTipsWarn("参数校验通过。警告:两个文件服务的URL相同!");
|
|
|
- }else {
|
|
|
- showTipsSuccess("校验通过");
|
|
|
+ if(errorMsg == null) {
|
|
|
+ if(dto.imgFromUrl.getValue().equals(dto.imgToUrl.getValue())) {
|
|
|
+ errorMsg = "success-校验通过。warning-两个文件服务的URL相同!";
|
|
|
+ }else {
|
|
|
+ errorMsg = "success-校验通过";
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- return result;
|
|
|
+ return errorMsg;
|
|
|
}
|
|
|
|
|
|
public void showTipsSuccess(String info) {
|