reghao 1 год назад
Родитель
Сommit
05493528b1

+ 0 - 30
web/src/main/java/cn/reghao/bnt/web/admin/model/constant/DeployStatus.java

@@ -1,30 +0,0 @@
-package cn.reghao.bnt.web.admin.model.constant;
-
-/**
- * 部署状态
- *
- * @author reghao
- * @date 2021-11-08 16:35:42
- */
-public enum DeployStatus {
-    neverDeploy(1, "尚未部署"),
-    onDeploying(2, "正在部署"),
-    deploySuccess(3, "部署成功"),
-    deployFail(4, "部署失败");
-
-    private final Integer code;
-    private final String desc;
-
-    DeployStatus(Integer code, String desc) {
-        this.code = code;
-        this.desc = desc;
-    }
-
-    public Integer getCode() {
-        return code;
-    }
-
-    public String getDesc() {
-        return desc;
-    }
-}

+ 0 - 30
web/src/main/java/cn/reghao/bnt/web/console/model/constant/DeployStatus.java

@@ -1,30 +0,0 @@
-package cn.reghao.bnt.web.console.model.constant;
-
-/**
- * 部署状态
- *
- * @author reghao
- * @date 2021-11-08 16:35:42
- */
-public enum DeployStatus {
-    neverDeploy(1, "尚未部署"),
-    onDeploying(2, "正在部署"),
-    deploySuccess(3, "部署成功"),
-    deployFail(4, "部署失败");
-
-    private final Integer code;
-    private final String desc;
-
-    DeployStatus(Integer code, String desc) {
-        this.code = code;
-        this.desc = desc;
-    }
-
-    public Integer getCode() {
-        return code;
-    }
-
-    public String getDesc() {
-        return desc;
-    }
-}

+ 3 - 3
web/src/main/java/cn/reghao/bnt/web/devops/app/db/repository/AppDeployingRepository.java

@@ -1,6 +1,7 @@
 package cn.reghao.bnt.web.devops.app.db.repository;
 
 import cn.reghao.bnt.web.devops.app.model.po.AppDeploying;
+import cn.reghao.bnt.web.devops.app.model.po.config.AppConfig;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 import org.springframework.data.jpa.repository.JpaRepository;
@@ -12,7 +13,6 @@ import java.util.List;
  * @date 2023-11-15 21:24:50
  */
 public interface AppDeployingRepository extends JpaRepository<AppDeploying, Integer> {
-    List<AppDeploying> findAllByAppDeployConfig_AppConfig_AppId(String appId);
-    AppDeploying findAllByAppDeployConfig_AppConfig_AppIdAndAppDeployConfig_MachineHost_MachineId(String appId, String machineId);
-    Page<AppDeploying> findAllByAppDeployConfig_AppConfig_EnvAndAppDeployConfig_AppConfig_AppType(String env, String appType, Pageable pageable);
+    AppDeploying findByAppConfig(AppConfig appConfig);
+    AppDeploying findByAppConfig_AppId(String appId);
 }

+ 35 - 78
web/src/main/java/cn/reghao/bnt/web/devops/app/model/po/AppDeploying.java

@@ -1,20 +1,21 @@
 package cn.reghao.bnt.web.devops.app.model.po;
 
+import cn.reghao.bnt.common.msg.event.EvtAppStatResult;
 import cn.reghao.bnt.web.devops.app.model.constant.DeployStatus;
+import cn.reghao.bnt.web.devops.app.model.po.config.AppConfig;
 import cn.reghao.bnt.web.devops.app.model.po.config.AppDeployConfig;
 import cn.reghao.bnt.web.devops.app.model.po.log.BuildLog;
-import cn.reghao.bnt.web.devops.app.model.po.log.DeployLog;
-import cn.reghao.bnt.common.msg.event.EvtAppStatResult;
-import cn.reghao.bnt.common.util.NotAvailable;
 import cn.reghao.bnt.web.util.db.BaseEntity;
 import cn.reghao.jutil.jdk.converter.DateTimeConverter;
 import cn.reghao.jutil.jdk.result.ResultStatus;
 import lombok.*;
+import org.hibernate.annotations.LazyCollection;
+import org.hibernate.annotations.LazyCollectionOption;
 
-import javax.persistence.Entity;
-import javax.persistence.OneToOne;
-import javax.persistence.Table;
-import java.time.LocalDateTime;
+import javax.persistence.*;
+import javax.validation.constraints.NotNull;
+import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * 应用最新一次构建的部署状态
@@ -29,88 +30,44 @@ import java.time.LocalDateTime;
 @Table(name = "devops_app_deploying")
 public class AppDeploying extends BaseEntity {
     @OneToOne
-    private AppDeployConfig appDeployConfig;
+    private AppConfig appConfig;
     @OneToOne
     private BuildLog buildLog;
-    private LocalDateTime deployTime;
-    private String deployResult;
-    private String deployBy;
-    private boolean onDeploying;
-    private boolean deployed;
 
-    // AppRunning
-    private String status;
-    private LocalDateTime startTime;
-    private Integer pid;
-    private LocalDateTime lastCheck;
+    @NotNull
+    @ElementCollection(targetClass = AppDeployingNode.class)
+    @LazyCollection(LazyCollectionOption.FALSE)
+    @CollectionTable(name = "devops_app_deploying_nodes")
+    private List<AppDeployingNode> deployingNodes;
 
     public AppDeploying(AppDeployConfig appDeployConfig) {
-        this.appDeployConfig = appDeployConfig;
-        this.deployResult = DeployStatus.neverDeploy.getDesc();
-        this.deployTime = DateTimeConverter.localDateTime(0);
-        this.deployBy = NotAvailable.na.getDesc();
-        this.onDeploying = false;
-        this.deployed = false;
-
-        this.status = NotAvailable.na.getDesc();
-        this.startTime = DateTimeConverter.localDateTime(0);
-        this.pid = -1;
-        this.lastCheck = DateTimeConverter.localDateTime(0);
-    }
-
-    public AppDeploying(AppDeployConfig appDeployConfig, AppBuilding appBuilding) {
-        this.appDeployConfig = appDeployConfig;
-        this.buildLog = appBuilding.getBuildLog();
-        this.deployResult = DeployStatus.neverDeploy.getDesc();
-        this.deployTime = LocalDateTime.now();
-        this.deployBy = appBuilding.getBuildBy();
-        this.onDeploying = false;
-        this.deployed = false;
-
-        this.status = NotAvailable.na.getDesc();
-        this.startTime = DateTimeConverter.localDateTime(0);
-        this.pid = -1;
-        this.lastCheck = DateTimeConverter.localDateTime(0);
-    }
-
-    public AppDeploying(AppDeployConfig appDeployConfig, AppBuilding appBuilding, DeployLog deployLog) {
-        this.appDeployConfig = appDeployConfig;
-        this.buildLog = appBuilding.getBuildLog();
-        this.deployResult = deployLog.getMsg();
-        this.deployTime = deployLog.getDeployTime();
-        this.deployBy = deployLog.getDeployBy();
-        this.onDeploying = false;
-        this.deployed = true;
-
-        this.status = NotAvailable.na.getDesc();
-        this.startTime = DateTimeConverter.localDateTime(0);
-        this.pid = -1;
-        this.lastCheck = DateTimeConverter.localDateTime(0);
+        this.appConfig = appDeployConfig.getAppConfig();
+        this.deployingNodes = List.of(new AppDeployingNode(appDeployConfig));
     }
 
     public void afterBuild(AppBuilding appBuilding) {
         this.buildLog = appBuilding.getBuildLog();
-        this.deployResult = DeployStatus.neverDeploy.getDesc();
-        this.onDeploying = false;
-        this.deployed = false;
-    }
-
-    public void beforeDeploy(AppBuilding appBuilding, String deployBy) {
-        this.buildLog = appBuilding.getBuildLog();
-        this.deployBy = deployBy;
-        this.deployResult = DeployStatus.onDeploying.getDesc();
-        this.onDeploying = true;
-        this.deployed = false;
+        deployingNodes.forEach(deployNode -> {
+            deployNode.setDeployResult(DeployStatus.neverDeploy.getDesc());
+            deployNode.setOnDeploying(false);
+            deployNode.setDeployed(false);
+        });
     }
 
     public void afterDeploy(EvtAppStatResult deployResult) {
-        this.onDeploying = false;
-        this.deployed = true;
-        this.deployTime = DateTimeConverter.localDateTime(deployResult.getResult().getTimestamp());
-        if (deployResult.getResult().getCode() == ResultStatus.SUCCESS.getCode()) {
-            this.deployResult = DeployStatus.deploySuccess.getDesc();
-        } else {
-            this.deployResult = DeployStatus.deployFail.getDesc();
-        }
+        String machineId = deployResult.getMachineId();
+        deployingNodes.forEach(deployNode -> {
+            deployNode.setOnDeploying(false);
+            deployNode.setDeployed(true);
+            deployNode.setDeployTime(DateTimeConverter.localDateTime(deployResult.getResult().getTimestamp()));
+            if (deployResult.getResult().getCode() == ResultStatus.SUCCESS.getCode()) {
+                deployNode.setDeployResult(DeployStatus.deploySuccess.getDesc());
+            } else {
+                deployNode.setDeployResult(DeployStatus.deployFail.getDesc());
+            }
+
+            deployNode.setDeployResult(DeployStatus.onDeploying.getDesc());
+
+        });
     }
 }

+ 52 - 0
web/src/main/java/cn/reghao/bnt/web/devops/app/model/po/AppDeployingNode.java

@@ -0,0 +1,52 @@
+package cn.reghao.bnt.web.devops.app.model.po;
+
+import cn.reghao.bnt.common.util.NotAvailable;
+import cn.reghao.bnt.web.devops.app.model.constant.DeployStatus;
+import cn.reghao.bnt.web.devops.app.model.po.config.AppDeployConfig;
+import cn.reghao.jutil.jdk.converter.DateTimeConverter;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.persistence.Embeddable;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * @author reghao
+ * @date 2024-07-27 09:20:37
+ */
+@NoArgsConstructor
+@Data
+@Embeddable
+public class AppDeployingNode implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    //private Integer deployConfigId;
+    private AppDeployConfig deployConfig;
+    private LocalDateTime deployTime;
+    private String deployResult;
+    private String deployBy;
+    private boolean onDeploying;
+    private boolean deployed;
+
+    // AppRunning
+    private String status;
+    private LocalDateTime startTime;
+    private Integer pid;
+    private LocalDateTime lastCheck;
+
+    public AppDeployingNode(AppDeployConfig deployConfig) {
+        //this.deployConfigId = deployConfigId;
+        this.deployConfig = deployConfig;
+        this.deployResult = DeployStatus.neverDeploy.getDesc();
+        this.deployTime = DateTimeConverter.localDateTime(0);
+        this.deployBy = NotAvailable.na.getDesc();
+        this.onDeploying = false;
+        this.deployed = false;
+
+        this.status = NotAvailable.na.getDesc();
+        this.startTime = DateTimeConverter.localDateTime(0);
+        this.pid = -1;
+        this.lastCheck = DateTimeConverter.localDateTime(0);
+    }
+}

+ 14 - 11
web/src/main/java/cn/reghao/bnt/web/devops/app/model/vo/AppDeployingVO.java

@@ -2,6 +2,7 @@ package cn.reghao.bnt.web.devops.app.model.vo;
 
 import cn.reghao.bnt.common.util.NotAvailable;
 import cn.reghao.bnt.web.devops.app.model.po.AppDeploying;
+import cn.reghao.bnt.web.devops.app.model.po.AppDeployingNode;
 import cn.reghao.bnt.web.devops.app.model.po.log.BuildLog;
 import cn.reghao.bnt.web.devops.machine.model.po.MachineHost;
 import cn.reghao.jutil.jdk.converter.DateTimeConverter;
@@ -23,7 +24,8 @@ public class AppDeployingVO {
     private String deployResult;
 
     public AppDeployingVO(AppDeploying appDeploying, String machineStatus, String deployResult) {
-        MachineHost machineHost = appDeploying.getAppDeployConfig().getMachineHost();
+        AppDeployingNode deployingNode = appDeploying.getDeployingNodes().get(0);
+        MachineHost machineHost = deployingNode.getDeployConfig().getMachineHost();
         this.machineId = machineHost.getMachineId();
         this.machineIpv4 = machineHost.getMachineIpv4();
         this.machineStatus = machineStatus;
@@ -37,15 +39,16 @@ public class AppDeployingVO {
             this.packagePath = NotAvailable.na.getDesc();
         }
 
-        this.deployBy = appDeploying.getDeployBy() != null ?
-                appDeploying.getDeployBy() : NotAvailable.na.getDesc();
-        this.deployTime = appDeploying.getDeployTime() != null ?
-                DateTimeConverter.format(appDeploying.getDeployTime()) : NotAvailable.na.getDesc();
+        this.deployBy = deployingNode.getDeployBy() != null ?
+                deployingNode.getDeployBy() : NotAvailable.na.getDesc();
+        this.deployTime = deployingNode.getDeployTime() != null ?
+                DateTimeConverter.format(deployingNode.getDeployTime()) : NotAvailable.na.getDesc();
         this.deployResult = deployResult;
     }
 
     public AppDeployingVO(AppDeploying appDeploying, String machineStatus) {
-        MachineHost machineHost = appDeploying.getAppDeployConfig().getMachineHost();
+        AppDeployingNode deployingNode = appDeploying.getDeployingNodes().get(0);
+        MachineHost machineHost = deployingNode.getDeployConfig().getMachineHost();
         this.machineId = machineHost.getMachineId();
         this.machineIpv4 = machineHost.getMachineIpv4();
         this.machineStatus = machineStatus;
@@ -59,10 +62,10 @@ public class AppDeployingVO {
             this.packagePath = NotAvailable.na.getDesc();
         }
 
-        this.deployBy = appDeploying.getDeployBy() != null ?
-                appDeploying.getDeployBy() : NotAvailable.na.getDesc();
-        this.deployTime = appDeploying.getDeployTime() != null ?
-                DateTimeConverter.format(appDeploying.getDeployTime()) : NotAvailable.na.getDesc();
-        this.deployResult = appDeploying.getDeployResult();
+        this.deployBy = deployingNode.getDeployBy() != null ?
+                deployingNode.getDeployBy() : NotAvailable.na.getDesc();
+        this.deployTime = deployingNode.getDeployTime() != null ?
+                DateTimeConverter.format(deployingNode.getDeployTime()) : NotAvailable.na.getDesc();
+        this.deployResult = deployingNode.getDeployResult();
     }
 }

+ 8 - 6
web/src/main/java/cn/reghao/bnt/web/devops/app/model/vo/AppRunning.java

@@ -1,6 +1,7 @@
 package cn.reghao.bnt.web.devops.app.model.vo;
 
 import cn.reghao.bnt.web.devops.app.model.po.AppDeploying;
+import cn.reghao.bnt.web.devops.app.model.po.AppDeployingNode;
 import cn.reghao.bnt.web.devops.app.model.po.config.AppConfig;
 import cn.reghao.bnt.web.devops.app.model.po.log.BuildLog;
 import cn.reghao.bnt.web.devops.machine.model.po.MachineHost;
@@ -27,8 +28,9 @@ public class AppRunning {
     private String lastCheck;
 
     public AppRunning(AppDeploying appDeploying) {
-        AppConfig appConfig = appDeploying.getAppDeployConfig().getAppConfig();
-        MachineHost machineHost = appDeploying.getAppDeployConfig().getMachineHost();
+        AppDeployingNode deployingNode = appDeploying.getDeployingNodes().get(0);
+        AppConfig appConfig = deployingNode.getDeployConfig().getAppConfig();
+        MachineHost machineHost = deployingNode.getDeployConfig().getMachineHost();
         this.appId = appConfig.getAppId();
         this.appName = appConfig.getAppName();
         this.machineId = machineHost.getMachineId();
@@ -39,10 +41,10 @@ public class AppRunning {
         BuildLog buildLog = appDeploying.getBuildLog();
         if (buildLog != null) {
             this.packagePath = buildLog.getPackagePath();
-            this.status = appDeploying.getStatus();
-            this.startTime = DateTimeConverter.format(appDeploying.getStartTime());
-            this.pid = appDeploying.getPid();
-            this.lastCheck = DateTimeConverter.format(appDeploying.getLastCheck());
+            this.status = deployingNode.getStatus();
+            this.startTime = DateTimeConverter.format(deployingNode.getStartTime());
+            this.pid = deployingNode.getPid();
+            this.lastCheck = DateTimeConverter.format(deployingNode.getLastCheck());
         } else {
             this.packagePath = NotAvailable.na.getDesc();
             this.status = NotAvailable.na.getDesc();

+ 92 - 57
web/src/main/java/cn/reghao/bnt/web/devops/app/service/bd/impl/DeployStatImpl.java

@@ -5,6 +5,7 @@ import cn.reghao.bnt.web.devops.app.db.repository.log.DeployLogRepository;
 import cn.reghao.bnt.web.devops.app.model.constant.DeployStatus;
 import cn.reghao.bnt.web.devops.app.model.po.AppBuilding;
 import cn.reghao.bnt.web.devops.app.model.po.AppDeploying;
+import cn.reghao.bnt.web.devops.app.model.po.AppDeployingNode;
 import cn.reghao.bnt.web.devops.app.model.po.config.AppConfig;
 import cn.reghao.bnt.web.devops.app.model.po.config.AppDeployConfig;
 import cn.reghao.bnt.web.devops.app.model.po.log.BuildLog;
@@ -61,76 +62,98 @@ public class DeployStatImpl implements DeployStat {
     public void update(AppDeployConfig appDeployConfig) {
         String appId = appDeployConfig.getAppConfig().getAppId();
         String machineId = appDeployConfig.getMachineHost().getMachineId();
-        AppDeploying appDeploying = deployingRepository.findAllByAppDeployConfig_AppConfig_AppIdAndAppDeployConfig_MachineHost_MachineId(appId, machineId);
-        appDeploying.setAppDeployConfig(appDeployConfig);
-        deployingRepository.save(appDeploying);
+        /*AppDeploying appDeploying = deployingRepository.findAllByAppDeployConfig_AppConfig_AppIdAndAppDeployConfig_MachineHost_MachineId(appId, machineId);
+        appDeploying.getDeployingNodes().add(new AppDeployingNode(appDeployConfig));
+        deployingRepository.save(appDeploying);*/
     }
 
     @Override
     public boolean delete(AppDeployConfig appDeployConfig) {
         String appId = appDeployConfig.getAppConfig().getAppId();
         String machineId = appDeployConfig.getMachineHost().getMachineId();
-        AppDeploying appDeploying = deployingRepository.findAllByAppDeployConfig_AppConfig_AppIdAndAppDeployConfig_MachineHost_MachineId(appId, machineId);
+        /*AppDeploying appDeploying = deployingRepository.findAllByAppDeployConfig_AppConfig_AppIdAndAppDeployConfig_MachineHost_MachineId(appId, machineId);
         if (appDeploying == null) {
             return true;
         }
 
-        int pid = appDeploying.getPid();
-        if (pid == -1) {
-            deployingRepository.delete(appDeploying);
-            return true;
-        }
+        for (AppDeployingNode appDeployingNode : appDeploying.getDeployingNodes()) {
+            AppDeployConfig deployConfig = appDeployingNode.getDeployConfig();
+            if (deployConfig.equals(appDeployConfig)) {
+                int pid = appDeployingNode.getPid();
+                if (pid == -1) {
+                    deployingRepository.delete(appDeploying);
+                    return true;
+                }
+            }
+        }*/
 
         return false;
     }
 
     public void delete(String appId, String machineId) {
-        AppDeploying appDeploying = deployingRepository.findAllByAppDeployConfig_AppConfig_AppIdAndAppDeployConfig_MachineHost_MachineId(appId, machineId);
+        AppDeploying appDeploying = deployingRepository.findByAppConfig_AppId(appId);
         if (appDeploying != null) {
-            deployingRepository.delete(appDeploying);
+            List<AppDeployingNode> deployingNodes = appDeploying.getDeployingNodes();
+
+            int idx = -1;
+            for (int i = 0; i < deployingNodes.size(); i++) {
+                String machineId1 = deployingNodes.get(i).getDeployConfig().getMachineHost().getMachineId();
+                if (machineId.equals(machineId1)) {
+                    idx = i;
+                }
+            }
+
+            if (idx != -1) {
+                deployingNodes.remove(idx);
+                deployingRepository.delete(appDeploying);
+            }
         }
     }
 
     @Override
     public void afterBuild(AppBuilding appBuilding) {
         String appId = appBuilding.getAppConfig().getAppId();
-        List<AppDeploying> list = deployingRepository.findAllByAppDeployConfig_AppConfig_AppId(appId);
+        /*List<AppDeploying> list = deployingRepository.findAllByAppDeployConfig_AppConfig_AppId(appId);
         list.forEach(appDeploying -> {
             appDeploying.afterBuild(appBuilding);
         });
-        deployingRepository.saveAll(list);
+        deployingRepository.saveAll(list);*/
     }
 
     @Override
     public void beforeDeploy(AppBuilding appBuilding, String machineId, String deployBy) {
-        String appId = appBuilding.getAppConfig().getAppId();
-        List<AppDeploying> list = deployingRepository.findAllByAppDeployConfig_AppConfig_AppId(appId);
-        for (AppDeploying appDeploying : list) {
-            String machineId1 = appDeploying.getAppDeployConfig().getMachineHost().getMachineId();
+        AppDeploying appDeploying = deployingRepository.findByAppConfig(appBuilding.getAppConfig());
+        appDeploying.setBuildLog(appBuilding.getBuildLog());
+        for (AppDeployingNode deployNode : appDeploying.getDeployingNodes()) {
+            String machineId1 = deployNode.getDeployConfig().getMachineHost().getMachineId();
             if (machineId1.equals(machineId)) {
-                appDeploying.beforeDeploy(appBuilding, deployBy);
-                deployingRepository.save(appDeploying);
+                deployNode.setDeployResult(DeployStatus.onDeploying.getDesc());
+                deployNode.setDeployBy(deployBy);
+                deployNode.setOnDeploying(true);
+                deployNode.setDeployed(false);
             }
         }
+        deployingRepository.save(appDeploying);
     }
 
     @Override
     public void afterDeploy(EvtAppStatResult deployResult) {
         log.info("执行 {} 部署后的操作", deployResult.getAppId());
-
-        String appId = deployResult.getAppId();
         String machineId = deployResult.getMachineId();
-        List<AppDeploying> list = deployingRepository.findAllByAppDeployConfig_AppConfig_AppId(appId);
-        for (AppDeploying appDeploying : list) {
-            String machineId1 = appDeploying.getAppDeployConfig().getMachineHost().getMachineId();
+        String appId = deployResult.getAppId();
+        AppDeploying appDeploying = deployingRepository.findByAppConfig_AppId(appId);
+        for (AppDeployingNode deployNode : appDeploying.getDeployingNodes()) {
+            String machineId1 = deployNode.getDeployConfig().getMachineHost().getMachineId();
             if (machineId1.equals(machineId)) {
                 appDeploying.afterDeploy(deployResult);
                 if (deployResult.getResult().getCode() == ResultStatus.SUCCESS.getCode()) {
-                    setAppStatus(appDeploying, deployResult);
+                    deployNode.setStatus(deployResult.getStatus());
+                    deployNode.setStartTime(deployResult.getStartTime());
+                    deployNode.setPid(deployResult.getPid());
+                    deployNode.setLastCheck(DateTimeConverter.localDateTime(deployResult.getResult().getTimestamp()));
                 }
-                deployingRepository.save(appDeploying);
 
-                MachineHost machineHost = appDeploying.getAppDeployConfig().getMachineHost();
+                MachineHost machineHost = deployNode.getDeployConfig().getMachineHost();
                 // BuildLog buildLog = buildLogRepository.findByBuildLogId(appDeploying.getAppBuilding().getBuildLogId());
                 BuildLog buildLog = appDeploying.getBuildLog();
                 DeployLog deployLog = new DeployLog(buildLog, machineHost, deployResult);
@@ -140,36 +163,32 @@ public class DeployStatImpl implements DeployStat {
                 log.info("{} 的通知已发送", deployResult.getAppId());
             }
         }
-    }
 
-    private void setAppStatus(AppDeploying appDeploying, EvtAppStatResult deployResult) {
-        appDeploying.setStatus(deployResult.getStatus());
-        appDeploying.setStartTime(deployResult.getStartTime());
-        appDeploying.setPid(deployResult.getPid());
-        appDeploying.setLastCheck(DateTimeConverter.localDateTime(deployResult.getResult().getTimestamp()));
+        deployingRepository.save(appDeploying);
     }
 
     @Override
     public void refresh(EvtAppStatResult statResult) {
-        String appId = statResult.getAppId();
-        String machineId = statResult.getMachineId();
-        List<AppDeploying> list = deployingRepository.findAllByAppDeployConfig_AppConfig_AppId(appId);
-        for (AppDeploying appDeploying : list) {
-            String machineId1 = appDeploying.getAppDeployConfig().getMachineHost().getMachineId();
-            if (machineId1.equals(machineId)) {
-                setAppStatus(appDeploying, statResult);
-                deployingRepository.save(appDeploying);
-            }
+    }
+
+    private void getApp(String appId) {
+        AppDeploying appDeploying = deployingRepository.findByAppConfig_AppId(appId);
+        for (AppDeployingNode deployNode : appDeploying.getDeployingNodes()) {
+
         }
     }
 
     @Override
     public List<AppInfo> getAppsByMachineId(String machineId) {
         return deployingRepository.findAll().stream()
-                .filter(appDeploying -> appDeploying.getAppDeployConfig().getMachineHost().getMachineId().equals(machineId))
+                .filter(appDeploying -> {
+                    MachineHost machineHost = appDeploying.getDeployingNodes().get(0).getDeployConfig().getMachineHost();
+                    return machineHost.getMachineId().equals(machineId);
+                })
                 .map(appDeploying -> {
-                    String packType = appDeploying.getAppDeployConfig().getAppConfig().getPackerConfig().getType();
-                    String appId = appDeploying.getAppDeployConfig().getAppConfig().getAppId();
+                    AppDeployConfig deployConfig = appDeploying.getDeployingNodes().get(0).getDeployConfig();
+                    String packType = deployConfig.getAppConfig().getPackerConfig().getType();
+                    String appId = deployConfig.getAppConfig().getAppId();
                     return new AppInfo(packType, appId);
                 })
                 .collect(Collectors.toList());
@@ -177,13 +196,13 @@ public class DeployStatImpl implements DeployStat {
 
     @Override
     public List<AppDeployingVO> get(String appId, AppBuilding appBuilding) {
-        List<AppDeploying> list = deployingRepository.findAllByAppDeployConfig_AppConfig_AppId(appId);
+        List<AppDeploying> list = Collections.emptyList();
         if (list.isEmpty()) {
             return Collections.emptyList();
         }
 
         return list.stream().map(appDeploying -> {
-                    MachineHost machineHost = appDeploying.getAppDeployConfig().getMachineHost();
+                    MachineHost machineHost = appDeploying.getDeployingNodes().get(0).getDeployConfig().getMachineHost();
                     String machineStatus = machineService.isAgentOnline(machineHost.getMachineId())
                             ? NodeStatus.Online.name() : NodeStatus.Offline.name();
 
@@ -208,9 +227,10 @@ public class DeployStatImpl implements DeployStat {
     @Override
     public PageList<AppRunningVO> getByPage(String env, String appType, int pageNumber, int pageSize) {
         PageRequest pageRequest = PageRequest.of(pageNumber-1, pageSize);
-        Page<AppDeploying> page = deployingRepository.findAllByAppDeployConfig_AppConfig_EnvAndAppDeployConfig_AppConfig_AppType(env, appType, pageRequest);
+        Page<AppDeploying> page = Page.empty();
         List<AppRunningVO> list2 = page.getContent().stream().map(appDeploying -> {
-            AppConfig appConfig = appDeploying.getAppDeployConfig().getAppConfig();
+            AppConfig appConfig = appDeploying.getDeployingNodes().get(0).getDeployConfig().getAppConfig();
+
             String appId = appConfig.getAppId();
             String appName = appConfig.getAppName();
             String bindPorts = appConfig.getBindPorts();
@@ -228,31 +248,46 @@ public class DeployStatImpl implements DeployStat {
 
     @Override
     public List<AppRunning> getAppRunning(String appId) {
-        return deployingRepository.findAllByAppDeployConfig_AppConfig_AppId(appId).stream()
+        return Collections.emptyList();
+        /*return deployingRepository.findAllByAppDeployConfig_AppConfig_AppId(appId).stream()
                 //.filter(AppDeploying::isDeployed)
                 //.sorted(Comparator.comparing(AppDeploying::getDeployTime).reversed())
                 .map(AppRunning::new)
-                .collect(Collectors.toList());
+                .collect(Collectors.toList());*/
     }
 
     @Override
     public boolean isDeploying(String appId, String machineId) {
-        AppDeploying appDeploying = deployingRepository.findAllByAppDeployConfig_AppConfig_AppIdAndAppDeployConfig_MachineHost_MachineId(appId, machineId);
-        return appDeploying.isOnDeploying();
+        AppDeploying appDeploying = deployingRepository.findByAppConfig_AppId(appId);
+        if (appDeploying != null) {
+            for (AppDeployingNode deployingNode : appDeploying.getDeployingNodes()) {
+                String machineId1 = deployingNode.getDeployConfig().getMachineHost().getMachineId();
+                if (machineId.equals(machineId1)) {
+                    return deployingNode.isOnDeploying();
+                }
+            }
+        }
+
+        return false;
     }
 
     @Override
     public boolean isRunning(String appId) {
-        List<AppDeploying> list = deployingRepository.findAllByAppDeployConfig_AppConfig_AppId(appId);
+        List<AppDeploying> list = Collections.emptyList();
         return !list.isEmpty();
     }
 
     @Override
     public boolean isRunning(String appId, String machineId) {
-        AppDeploying appDeploying = deployingRepository.findAllByAppDeployConfig_AppConfig_AppIdAndAppDeployConfig_MachineHost_MachineId(appId, machineId);
+        AppDeploying appDeploying = deployingRepository.findByAppConfig_AppId(appId);
         if (appDeploying != null) {
-            int pid = appDeploying.getPid();
-            return pid != -1;
+            for (AppDeployingNode deployingNode : appDeploying.getDeployingNodes()) {
+                String machineId1 = deployingNode.getDeployConfig().getMachineHost().getMachineId();
+                if (machineId.equals(machineId1)) {
+                    int pid = deployingNode.getPid();
+                    return pid != -1;
+                }
+            }
         }
 
         return false;