Просмотр исходного кода

实现应用部署后的操作,包括更新 DeployLog, 更新 AppDeploying, 更新 AppRunning 以及发送部署通知

reghao 4 лет назад
Родитель
Сommit
59aa3de1e8
32 измененных файлов с 340 добавлено и 227 удалено
  1. 2 1
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/query/AppDeployingQuery.java
  2. 5 0
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/query/AppDeployingQueryImpl.java
  3. 2 1
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/query/AppRunningQuery.java
  4. 3 2
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/query/log/DeployLogQuery.java
  5. 11 5
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/query/log/DeployLogQueryImpl.java
  6. 1 0
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/repository/log/DeployLogRepository.java
  7. 11 6
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/model/po/log/DeployLog.java
  8. 1 3
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/BuildDeployDispatcher.java
  9. 0 3
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/BuildDeployService.java
  10. 1 1
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/AppBuildingService.java
  11. 2 2
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/AppBuildingServiceImpl.java
  12. 29 12
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/AppDeployer.java
  13. 5 2
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/AppDeployingService.java
  14. 111 0
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/AppDeployingServiceImpl.java
  15. 1 1
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/AppRunningService.java
  16. 2 2
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/AppRunningServiceImpl.java
  17. 4 4
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/impl/AppConfigServiceImpl.java
  18. 1 1
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/impl/AppDeployConfigServiceImpl.java
  19. 0 60
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/impl/AppDeployingServiceImpl.java
  20. 7 7
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/impl/BuildConfigChecker.java
  21. 0 1
      dmaster/src/main/java/cn/reghao/autodop/dmaster/monitor/db/query/AppMonitorQuery.java
  22. 0 15
      dmaster/src/main/java/cn/reghao/autodop/dmaster/monitor/db/query/AppMonitorQueryImpl.java
  23. 14 27
      dmaster/src/main/java/cn/reghao/autodop/dmaster/mqttsub/impl/rpcresult/AppRpcClazzResultImpl.java
  24. 11 0
      dmaster/src/main/java/cn/reghao/autodop/dmaster/notification/db/crud/DingAccountCrud.java
  25. 11 0
      dmaster/src/main/java/cn/reghao/autodop/dmaster/notification/db/crud/NotifyGroupCrud.java
  26. 12 0
      dmaster/src/main/java/cn/reghao/autodop/dmaster/notification/db/query/DingAccountQuery.java
  27. 24 0
      dmaster/src/main/java/cn/reghao/autodop/dmaster/notification/db/query/DingAccountQueryImpl.java
  28. 1 1
      dmaster/src/main/java/cn/reghao/autodop/dmaster/notification/db/repository/DingAccountRepository.java
  29. 1 1
      dmaster/src/main/java/cn/reghao/autodop/dmaster/notification/model/vo/BuildNotifyMsg.java
  30. 13 12
      dmaster/src/main/java/cn/reghao/autodop/dmaster/notification/model/vo/DeployNotifyMsg.java
  31. 22 56
      dmaster/src/main/java/cn/reghao/autodop/dmaster/notification/service/NotifyService.java
  32. 32 1
      dmaster/src/test/java/cn/reghao/autodop/dmaster/app/service/impl/BuildDeployConfigServiceImplTest.java

+ 2 - 1
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/query/AppDeployingQuery.java

@@ -2,6 +2,7 @@ package cn.reghao.autodop.dmaster.app.db.query;
 
 import cn.reghao.autodop.dmaster.app.model.po.AppDeploying;
 import cn.reghao.autodop.dmaster.app.model.po.config.AppDeployConfig;
+import cn.reghao.jdkutil.db.BaseQuery;
 
 import java.util.List;
 import java.util.Map;
@@ -10,7 +11,7 @@ import java.util.Map;
  * @author reghao
  * @date 2021-06-02 15:01:18
  */
-public interface AppDeployingQuery {
+public interface AppDeployingQuery extends BaseQuery<AppDeploying> {
     List<AppDeploying> findByAppId(String appId);
     AppDeploying findByAppIdAndMachineId(String appId, String machineId);
     AppDeploying findByAppDeployConfig(AppDeployConfig appDeployConfig);

+ 5 - 0
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/query/AppDeployingQueryImpl.java

@@ -26,6 +26,11 @@ public class AppDeployingQueryImpl implements AppDeployingQuery {
         this.deployingRepository = deployingRepository;
     }
 
+    @Override
+    public List<AppDeploying> findAll() {
+        return deployingRepository.findAll();
+    }
+
     @Override
     public List<AppDeploying> findByAppId(String appId) {
         return Collections.emptyList();

+ 2 - 1
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/query/AppRunningQuery.java

@@ -2,6 +2,7 @@ package cn.reghao.autodop.dmaster.app.db.query;
 
 import cn.reghao.autodop.dmaster.app.model.po.AppDeploying;
 import cn.reghao.autodop.dmaster.app.model.po.AppRunning;
+import cn.reghao.jdkutil.db.BaseQuery;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 
@@ -12,7 +13,7 @@ import java.util.Map;
  * @author reghao
  * @date 2021-06-02 15:01:18
  */
-public interface AppRunningQuery {
+public interface AppRunningQuery extends BaseQuery<AppRunning> {
     AppRunning findByAppIdAndMachineId(String appId, String machineId);
     AppRunning findByAppDeploying(AppDeploying appDeploying);
     List<AppRunning> queryAll(Map<String, String> kv);

+ 3 - 2
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/query/log/DeployLogQuery.java

@@ -11,6 +11,7 @@ import java.util.List;
  * @date 2021-06-17 15:50:46
  */
 public interface DeployLogQuery {
-    List<DeployLog> findDeployLogByBuildLogId(String buildLogId);
-    Page<DeployLog> deployLogs(String appId, Pageable pageable);
+    List<DeployLog> findByBuildLogId(String buildLogId);
+    DeployLog findByBuildLogIdAndMachineId(String buildLogId, String machineId);
+    Page<DeployLog> findByAppId(String appId, Pageable pageable);
 }

+ 11 - 5
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/query/log/DeployLogQueryImpl.java

@@ -3,9 +3,11 @@ package cn.reghao.autodop.dmaster.app.db.query.log;
 import cn.reghao.autodop.dmaster.app.db.repository.log.DeployLogRepository;
 import cn.reghao.autodop.dmaster.app.model.po.log.DeployLog;
 import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageImpl;
 import org.springframework.data.domain.Pageable;
 import org.springframework.stereotype.Service;
 
+import java.util.Collections;
 import java.util.List;
 
 /**
@@ -14,20 +16,24 @@ import java.util.List;
  */
 @Service
 public class DeployLogQueryImpl implements DeployLogQuery {
-    private DeployLogRepository deployLogRepository;
+    private final DeployLogRepository deployLogRepository;
 
     public DeployLogQueryImpl(DeployLogRepository deployLogRepository) {
         this.deployLogRepository = deployLogRepository;
     }
 
     @Override
-    public List<DeployLog> findDeployLogByBuildLogId(String buildLogId) {
-        return null;
+    public List<DeployLog> findByBuildLogId(String buildLogId) {
+        return deployLogRepository.findByBuildLogId(buildLogId);
     }
 
     @Override
-    public Page<DeployLog> deployLogs(String appId, Pageable pageable) {
+    public DeployLog findByBuildLogIdAndMachineId(String buildLogId, String machineId) {
+        return deployLogRepository.findByBuildLogIdAndMachineId(buildLogId, machineId);
+    }
 
-        return null;
+    @Override
+    public Page<DeployLog> findByAppId(String appId, Pageable pageable) {
+        return new PageImpl<>(Collections.emptyList());
     }
 }

+ 1 - 0
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/repository/log/DeployLogRepository.java

@@ -12,4 +12,5 @@ import java.util.List;
  */
 public interface DeployLogRepository extends MongoRepository<DeployLog, String> {
     List<DeployLog> findByBuildLogId(String buildLogId);
+    DeployLog findByBuildLogIdAndMachineId(String buildLogId, String machineId);
 }

+ 11 - 6
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/model/po/log/DeployLog.java

@@ -1,6 +1,5 @@
 package cn.reghao.autodop.dmaster.app.model.po.log;
 
-import cn.reghao.autodop.common.msg.rpc.dto.app.StatusResult;
 import cn.reghao.autodop.common.msg.rpc.dto.app.DeployResult;
 import cn.reghao.jdkutil.result.Result;
 import cn.reghao.autodop.dmaster.util.db.BaseDocument;
@@ -23,13 +22,19 @@ public class DeployLog extends BaseDocument {
     private String buildLogId;
     private String machineId;
     private String machineIpv4;
+    private String deployBy;
     private LocalDateTime deployTime;
     private Result result;
-    private String deployBy;
 
-    public static DeployLog from(DeployResult deployResult) {
-        DeployLog deployLog = new DeployLog();
-        // TODO
-        return deployLog;
+    public DeployLog(String buildLogId, String machineId, String machineIpv4, String deployBy) {
+        this.buildLogId = buildLogId;
+        this.machineId = machineId;
+        this.machineIpv4 = machineIpv4;
+        this.deployBy = deployBy;
+    }
+
+    public void update(DeployResult deployResult) {
+        this.deployTime = deployResult.getDeployTime();
+        this.result = deployResult.getResult();
     }
 }

+ 1 - 3
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/BuildDeployDispatcher.java

@@ -10,13 +10,11 @@ import cn.reghao.autodop.dmaster.app.model.po.AppBuilding;
 import cn.reghao.autodop.dmaster.app.model.po.AppDeploying;
 import cn.reghao.autodop.dmaster.app.model.po.log.*;
 import cn.reghao.autodop.dmaster.spring.interceptor.AppIntegrateReinitInterceptor;
-import cn.reghao.autodop.dmaster.app.db.repository.AppBuildingRepository;
-import cn.reghao.autodop.dmaster.app.db.repository.AppDeployingRepository;
 import cn.reghao.autodop.dmaster.app.db.repository.log.BuildLogRepository;
 import cn.reghao.autodop.dmaster.app.service.bd.AppIntegrate;
 import cn.reghao.autodop.dmaster.app.service.bd.AppDeployer;
 import cn.reghao.autodop.dmaster.app.model.po.config.AppConfig;
-import cn.reghao.autodop.dmaster.app.service.bd.BuildNotifyMsg;
+import cn.reghao.autodop.dmaster.notification.model.vo.BuildNotifyMsg;
 import cn.reghao.autodop.dmaster.notification.model.po.NotifyGroup;
 import cn.reghao.autodop.dmaster.notification.model.po.NotifyType;
 import cn.reghao.autodop.dmaster.notification.service.NotifyService;

+ 0 - 3
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/BuildDeployService.java

@@ -1,13 +1,10 @@
 package cn.reghao.autodop.dmaster.app.service;
 
-import cn.reghao.autodop.dmaster.app.model.po.config.AppConfig;
-
 /**
  * @author reghao
  * @date 2021-09-17 11:30:16
  */
 public interface BuildDeployService {
-    //void addApp(AppConfig appConfig);
     String buildAndDeploy(String appId);
     String build(String appId);
     String build(String appId, String commitId);

+ 1 - 1
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/AppBuildingService.java → dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/AppBuildingService.java

@@ -1,4 +1,4 @@
-package cn.reghao.autodop.dmaster.app.service.config;
+package cn.reghao.autodop.dmaster.app.service.bd;
 
 import cn.reghao.autodop.dmaster.app.model.po.config.AppConfig;
 import cn.reghao.autodop.dmaster.app.model.po.log.BuildLog;

+ 2 - 2
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/impl/AppBuildingServiceImpl.java → dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/AppBuildingServiceImpl.java

@@ -1,11 +1,11 @@
-package cn.reghao.autodop.dmaster.app.service.config.impl;
+package cn.reghao.autodop.dmaster.app.service.bd;
 
 import cn.reghao.autodop.dmaster.app.db.crud.AppBuildingCrud;
 import cn.reghao.autodop.dmaster.app.db.query.AppBuildingQuery;
 import cn.reghao.autodop.dmaster.app.model.po.AppBuilding;
 import cn.reghao.autodop.dmaster.app.model.po.config.AppConfig;
 import cn.reghao.autodop.dmaster.app.model.po.log.BuildLog;
-import cn.reghao.autodop.dmaster.app.service.config.AppBuildingService;
+import cn.reghao.autodop.dmaster.app.service.bd.AppBuildingService;
 import org.springframework.stereotype.Service;
 
 /**

+ 29 - 12
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/AppDeployer.java

@@ -1,14 +1,15 @@
 package cn.reghao.autodop.dmaster.app.service.bd;
 
-import cn.reghao.autodop.common.machine.Machine;
 import cn.reghao.autodop.common.msg.Message;
 import cn.reghao.autodop.common.msg.MsgQueue;
 import cn.reghao.autodop.common.msg.rpc.RpcMsg;
 import cn.reghao.autodop.common.msg.rpc.constant.AppRpcClazz;
 import cn.reghao.autodop.common.msg.rpc.dto.app.DeployParam;
 import cn.reghao.autodop.common.mqtt.DefaultMqttClient;
+import cn.reghao.autodop.dmaster.app.db.crud.log.DeployLogCrud;
 import cn.reghao.autodop.dmaster.app.db.query.config.AppDeployConfigQuery;
 import cn.reghao.autodop.dmaster.app.model.po.config.AppDeployConfig;
+import cn.reghao.autodop.dmaster.app.model.po.log.DeployLog;
 import cn.reghao.jdkutil.serializer.JsonConverter;
 import cn.reghao.autodop.dmaster.app.model.po.log.BuildLog;
 import lombok.extern.slf4j.Slf4j;
@@ -28,33 +29,49 @@ import java.util.*;
 public class AppDeployer {
     private final DefaultMqttClient mqttClient;
     private final AppDeployConfigQuery deployConfigQuery;
+    private final DeployLogCrud logCrud;
 
-    public AppDeployer(DefaultMqttClient mqttClient, AppDeployConfigQuery deployConfigQuery) {
+    public AppDeployer(DefaultMqttClient mqttClient, AppDeployConfigQuery deployConfigQuery, DeployLogCrud logCrud) {
         this.mqttClient = mqttClient;
         this.deployConfigQuery = deployConfigQuery;
+        this.logCrud = logCrud;
     }
 
     public void deploy(BuildLog buildLog) throws MqttException {
-        List<AppDeployConfig> deployConfigs = deployConfigQuery.findByAppId(buildLog.getAppId());
+        List<DeployLog> deployLogs = new ArrayList<>();
+        String buildLogId = buildLog.getId();
+        String appId = buildLog.getAppId();
+        String packagePath = buildLog.getPackagePath();
+        String deployBy = buildLog.getBuildBy();
+
+        List<AppDeployConfig> deployConfigs = deployConfigQuery.findByAppId(appId);
         for (AppDeployConfig deployConfig : deployConfigs) {
-            DeployParam deployParam = new DeployParam();
-            deployParam.setBuildLogId(buildLog.getId());
-            deployParam.setAppId(buildLog.getAppId());
-            deployParam.setPackagePath(buildLog.getPackagePath());
-            deployParam.setPackType(deployConfig.getPackType());
-            deployParam.setStartHome(deployConfig.getStartHome());
-            deployParam.setStartScript(deployConfig.getStartScript());
+            String machineId = deployConfig.getMachineHost().getMachineId();
+            String machineIpv4 = deployConfig.getMachineHost().getMachineIpv4();
+            String packType = deployConfig.getPackType();
             String startScript = deployConfig.getStartScript();
+            String startHome = deployConfig.getStartHome();
+            String unpackScript = deployConfig.getUnpackScript();
+
+            DeployParam deployParam = new DeployParam();
+            deployParam.setBuildLogId(buildLogId);
+            deployParam.setAppId(appId);
+            deployParam.setPackagePath(packagePath);
+            deployParam.setPackType(packType);
             deployParam.setStartScript(startScript);
+            //deployParam.setStartHome(startHome);
 
             RpcMsg rpcMsg = RpcMsg.paramMsg(AppRpcClazz.class.getSimpleName(), AppRpcClazz.deploy.name(),
                     JsonConverter.objectToJson(deployParam));
             Message message = Message.rpcParamMsg(rpcMsg);
-
             // TODO 对于需要返回值的 pub,需要做一个记录,pub 和 sub 一一对应
-            String topic = MsgQueue.dagentTopic(Machine.ID);
+            String topic = MsgQueue.dagentTopic(machineId);
             mqttClient.pubWithResult(topic, 1, message);
+
+            deployLogs.add(new DeployLog(buildLogId, machineId, machineIpv4, deployBy));
         }
+
+        logCrud.saveAll(deployLogs);
     }
 
     /**

+ 5 - 2
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/AppDeployingService.java → dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/AppDeployingService.java

@@ -1,7 +1,8 @@
-package cn.reghao.autodop.dmaster.app.service.config;
+package cn.reghao.autodop.dmaster.app.service.bd;
 
 import cn.reghao.autodop.common.msg.rpc.dto.app.DeployResult;
 import cn.reghao.autodop.dmaster.app.model.po.config.AppDeployConfig;
+import cn.reghao.autodop.dmaster.app.model.po.log.DeployLog;
 
 /**
  * @author reghao
@@ -9,6 +10,8 @@ import cn.reghao.autodop.dmaster.app.model.po.config.AppDeployConfig;
  */
 public interface AppDeployingService {
     void add(AppDeployConfig appDeployConfig);
-    void refresh(String appId, DeployResult deployResult);
+    void refresh(DeployResult deployResult);
     void delete(AppDeployConfig appDeployConfig);
+    DeployLog updateDeployLog(DeployResult deployResult);
+    void sendDeployNotify(DeployLog deployLog);
 }

+ 111 - 0
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/AppDeployingServiceImpl.java

@@ -0,0 +1,111 @@
+package cn.reghao.autodop.dmaster.app.service.bd;
+
+import cn.reghao.autodop.common.msg.rpc.dto.app.DeployResult;
+import cn.reghao.autodop.dmaster.app.db.crud.AppDeployingCrud;
+import cn.reghao.autodop.dmaster.app.db.crud.log.DeployLogCrud;
+import cn.reghao.autodop.dmaster.app.db.query.AppDeployingQuery;
+import cn.reghao.autodop.dmaster.app.db.query.log.BuildLogQuery;
+import cn.reghao.autodop.dmaster.app.db.query.log.DeployLogQuery;
+import cn.reghao.autodop.dmaster.app.model.po.AppDeploying;
+import cn.reghao.autodop.dmaster.app.model.po.config.AppDeployConfig;
+import cn.reghao.autodop.dmaster.app.model.po.log.BuildLog;
+import cn.reghao.autodop.dmaster.app.model.po.log.DeployLog;
+import cn.reghao.autodop.dmaster.app.service.bd.AppDeployingService;
+import cn.reghao.autodop.dmaster.app.service.bd.AppRunningService;
+import cn.reghao.autodop.dmaster.machine.db.query.MachineHostQuery;
+import cn.reghao.autodop.dmaster.monitor.db.query.AppMonitorQuery;
+import cn.reghao.autodop.dmaster.monitor.model.po.AppMonitor;
+import cn.reghao.autodop.dmaster.notification.model.po.NotifyGroup;
+import cn.reghao.autodop.dmaster.notification.model.vo.DeployNotifyMsg;
+import cn.reghao.autodop.dmaster.notification.service.NotifyService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author reghao
+ * @date 2021-10-22 14:45:22
+ */
+@Slf4j
+@Service
+public class AppDeployingServiceImpl implements AppDeployingService {
+    private final AppDeployingQuery deployingQuery;
+    private final AppDeployingCrud deployingCrud;
+    private final AppRunningService runningService;
+    private final BuildLogQuery buildLogQuery;
+    private final DeployLogQuery deployLogQuery;
+    private final DeployLogCrud deployLogCrud;
+    private final MachineHostQuery hostQuery;
+    private final AppMonitorQuery appMonitorQuery;
+    private final NotifyService notifyService;
+
+    public AppDeployingServiceImpl(AppDeployingQuery deployingQuery, AppDeployingCrud deployingCrud,
+                                   AppRunningService runningService, BuildLogQuery buildLogQuery,
+                                   DeployLogQuery deployLogQuery, DeployLogCrud deployLogCrud,
+                                   MachineHostQuery hostQuery, AppMonitorQuery appMonitorQuery,
+                                   NotifyService notifyService) {
+        this.deployingQuery = deployingQuery;
+        this.deployingCrud = deployingCrud;
+        this.runningService = runningService;
+        this.buildLogQuery = buildLogQuery;
+        this.deployLogQuery = deployLogQuery;
+        this.deployLogCrud = deployLogCrud;
+        this.hostQuery = hostQuery;
+        this.appMonitorQuery = appMonitorQuery;
+        this.notifyService = notifyService;
+    }
+
+    @Override
+    public void add(AppDeployConfig appDeployConfig) {
+        AppDeploying appDeploying = new AppDeploying(appDeployConfig);
+        deployingCrud.save(appDeploying);
+        runningService.add(appDeploying);
+    }
+
+    @Override
+    public void refresh(DeployResult deployResult) {
+        String buildLogId = deployResult.getBuildLogId();
+        String machineId = deployResult.getMachineId();
+        BuildLog buildLog = buildLogQuery.findById(buildLogId);
+        String appId = buildLog.getAppId();
+        AppDeploying appDeploying = deployingQuery.findByAppIdAndMachineId(appId, machineId);
+        if (appDeploying != null) {
+            appDeploying.update(buildLog, deployResult);
+            deployingCrud.update(appDeploying);
+        }
+    }
+
+    @Override
+    public void delete(AppDeployConfig appDeployConfig) {
+        AppDeploying appDeploying = deployingQuery.findByAppDeployConfig(appDeployConfig);
+        if (appDeploying != null) {
+            deployingCrud.delete(appDeploying);
+            runningService.delete(appDeploying);
+        }
+    }
+
+    @Override
+    public DeployLog updateDeployLog(DeployResult deployResult) {
+        String buildLogId = deployResult.getBuildLogId();
+        String machineId = deployResult.getMachineId();
+        DeployLog deployLog = deployLogQuery.findByBuildLogIdAndMachineId(buildLogId, machineId);
+        deployLog.update(deployResult);
+        deployLogCrud.update(deployLog);
+        return deployLog;
+    }
+
+    @Override
+    public void sendDeployNotify(DeployLog deployLog) {
+        String buildLogId = deployLog.getBuildLogId();
+        BuildLog buildLog = buildLogQuery.findById(buildLogId);
+        String appId = buildLog.getAppId();
+        AppMonitor appMonitor = appMonitorQuery.findByAppId(appId);
+        if (appMonitor == null || appMonitor.getAppDeploy() == null) {
+            log.error("{} 没有部署通知配置", appId);
+            return;
+        }
+
+        NotifyGroup notifyGroup = appMonitor.getAppDeploy();
+        DeployNotifyMsg deployNotifyMsg = new DeployNotifyMsg(buildLog, deployLog);
+        notifyService.notify(notifyGroup, deployNotifyMsg.dingMsg());
+    }
+}

+ 1 - 1
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/AppRunningService.java → dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/AppRunningService.java

@@ -1,4 +1,4 @@
-package cn.reghao.autodop.dmaster.app.service.config;
+package cn.reghao.autodop.dmaster.app.service.bd;
 
 import cn.reghao.autodop.common.msg.rpc.dto.app.StatusResult;
 import cn.reghao.autodop.dmaster.app.model.po.AppDeploying;

+ 2 - 2
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/impl/AppRunningServiceImpl.java → dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/AppRunningServiceImpl.java

@@ -1,11 +1,11 @@
-package cn.reghao.autodop.dmaster.app.service.config.impl;
+package cn.reghao.autodop.dmaster.app.service.bd;
 
 import cn.reghao.autodop.common.msg.rpc.dto.app.StatusResult;
 import cn.reghao.autodop.dmaster.app.db.crud.AppRunningCrud;
 import cn.reghao.autodop.dmaster.app.db.query.AppRunningQuery;
 import cn.reghao.autodop.dmaster.app.model.po.AppDeploying;
 import cn.reghao.autodop.dmaster.app.model.po.AppRunning;
-import cn.reghao.autodop.dmaster.app.service.config.AppRunningService;
+import cn.reghao.autodop.dmaster.app.service.bd.AppRunningService;
 import org.springframework.stereotype.Service;
 
 /**

+ 4 - 4
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/impl/AppConfigServiceImpl.java

@@ -24,20 +24,20 @@ public class AppConfigServiceImpl implements AppConfigService {
     private final AppConfigQuery appConfigQuery;
     private final AppConfigCrud appConfigCrud;
     private final MachineHostQuery machineHostQuery;
-    private final SharedEntityChecker sharedEntityChecker;
+    private final BuildConfigChecker buildConfigChecker;
     private final BuildDeployConfigServiceImpl appBuildService;
     private final AppRunningRepository runningRepository;
     private AppDeployingQuery appDeployingQuery;
     private AppDeployingCrud appDeployingCrud;
 
     public AppConfigServiceImpl(AppConfigQuery appConfigQuery, AppConfigCrud appConfigCrud,
-                                MachineHostQuery machineHostQuery, SharedEntityChecker sharedEntityChecker,
+                                MachineHostQuery machineHostQuery, BuildConfigChecker buildConfigChecker,
                                 BuildDeployConfigServiceImpl appBuildService, AppRunningRepository runningRepository,
                                 AppDeployingQuery appDeployingQuery, AppDeployingCrud appDeployingCrud) {
         this.appConfigQuery = appConfigQuery;
         this.appConfigCrud = appConfigCrud;
         this.machineHostQuery = machineHostQuery;
-        this.sharedEntityChecker = sharedEntityChecker;
+        this.buildConfigChecker = buildConfigChecker;
         this.appBuildService = appBuildService;
         this.runningRepository = runningRepository;
         this.appDeployingQuery = appDeployingQuery;
@@ -63,7 +63,7 @@ public class AppConfigServiceImpl implements AppConfigService {
     }
 
     private void checkSharedEntity(AppConfig app) throws Exception {
-        sharedEntityChecker.checkAndSetBuildConfig(app);
+        buildConfigChecker.checkAndSetBuildConfig(app);
     }
 
     @Override

+ 1 - 1
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/impl/AppDeployConfigServiceImpl.java

@@ -9,7 +9,7 @@ import cn.reghao.autodop.dmaster.app.model.dto.AppDeployConfigDto;
 import cn.reghao.autodop.dmaster.app.model.po.config.AppConfig;
 import cn.reghao.autodop.dmaster.app.model.po.config.AppDeployConfig;
 import cn.reghao.autodop.dmaster.app.service.config.AppDeployConfigService;
-import cn.reghao.autodop.dmaster.app.service.config.AppDeployingService;
+import cn.reghao.autodop.dmaster.app.service.bd.AppDeployingService;
 import cn.reghao.autodop.dmaster.machine.db.query.MachineHostQuery;
 import cn.reghao.autodop.dmaster.machine.model.po.MachineHost;
 import cn.reghao.jdkutil.result.Result;

+ 0 - 60
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/impl/AppDeployingServiceImpl.java

@@ -1,60 +0,0 @@
-package cn.reghao.autodop.dmaster.app.service.config.impl;
-
-import cn.reghao.autodop.common.msg.rpc.dto.app.DeployResult;
-import cn.reghao.autodop.dmaster.app.db.crud.AppDeployingCrud;
-import cn.reghao.autodop.dmaster.app.db.query.AppDeployingQuery;
-import cn.reghao.autodop.dmaster.app.db.query.log.BuildLogQuery;
-import cn.reghao.autodop.dmaster.app.model.po.AppDeploying;
-import cn.reghao.autodop.dmaster.app.model.po.config.AppDeployConfig;
-import cn.reghao.autodop.dmaster.app.model.po.log.BuildLog;
-import cn.reghao.autodop.dmaster.app.service.config.AppDeployingService;
-import cn.reghao.autodop.dmaster.app.service.config.AppRunningService;
-import org.springframework.stereotype.Service;
-
-/**
- * @author reghao
- * @date 2021-10-22 14:45:22
- */
-@Service
-public class AppDeployingServiceImpl implements AppDeployingService {
-    private final AppDeployingQuery deployingQuery;
-    private final AppDeployingCrud deployingCrud;
-    private final AppRunningService runningService;
-    private final BuildLogQuery buildLogQuery;
-
-    public AppDeployingServiceImpl(AppDeployingQuery deployingQuery, AppDeployingCrud deployingCrud,
-                                   AppRunningService runningService, BuildLogQuery buildLogQuery) {
-        this.deployingQuery = deployingQuery;
-        this.deployingCrud = deployingCrud;
-        this.runningService = runningService;
-        this.buildLogQuery = buildLogQuery;
-    }
-
-    @Override
-    public void add(AppDeployConfig appDeployConfig) {
-        AppDeploying appDeploying = new AppDeploying(appDeployConfig);
-        deployingCrud.save(appDeploying);
-        runningService.add(appDeploying);
-    }
-
-    @Override
-    public void refresh(String appId, DeployResult deployResult) {
-        String machineId = deployResult.getMachineId();
-        String buildLogId = deployResult.getBuildLogId();
-        BuildLog buildLog = buildLogQuery.findById(buildLogId);
-        AppDeploying appDeploying = deployingQuery.findByAppIdAndMachineId(appId, machineId);
-        if (appDeploying != null) {
-            appDeploying.update(buildLog, deployResult);
-            deployingCrud.update(appDeploying);
-        }
-    }
-
-    @Override
-    public void delete(AppDeployConfig appDeployConfig) {
-        AppDeploying appDeploying = deployingQuery.findByAppDeployConfig(appDeployConfig);
-        if (appDeploying != null) {
-            deployingCrud.delete(appDeploying);
-            runningService.delete(appDeploying);
-        }
-    }
-}

+ 7 - 7
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/impl/SharedEntityChecker.java → dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/impl/BuildConfigChecker.java

@@ -11,19 +11,19 @@ import cn.reghao.autodop.dmaster.app.model.vo.BuildConfig;
 import org.springframework.stereotype.Service;
 
 /**
- * 检查并设置共享实体
+ * 检查并设置构建配置
  *
  * @author reghao
  * @date 2020-11-13 17:58:27
  */
 @Service
-public class SharedEntityChecker {
-    private RepoAuthConfigQuery repoAuthConfigQuery;
-    private CompilerConfigQuery compilerConfigQuery;
-    private PackerConfigQuery packerConfigQuery;
+public class BuildConfigChecker {
+    private final RepoAuthConfigQuery repoAuthConfigQuery;
+    private final CompilerConfigQuery compilerConfigQuery;
+    private final PackerConfigQuery packerConfigQuery;
 
-    public SharedEntityChecker(RepoAuthConfigQuery repoAuthConfigQuery, CompilerConfigQuery compilerConfigQuery,
-                               PackerConfigQuery packerConfigQuery) {
+    public BuildConfigChecker(RepoAuthConfigQuery repoAuthConfigQuery, CompilerConfigQuery compilerConfigQuery,
+                              PackerConfigQuery packerConfigQuery) {
         this.repoAuthConfigQuery = repoAuthConfigQuery;
         this.compilerConfigQuery = compilerConfigQuery;
         this.packerConfigQuery = packerConfigQuery;

+ 0 - 1
dmaster/src/main/java/cn/reghao/autodop/dmaster/monitor/db/query/AppMonitorQuery.java

@@ -14,7 +14,6 @@ import java.util.List;
  */
 public interface AppMonitorQuery extends BaseQuery<AppMonitor> {
     Page<AppMonitorDto> findByEnv(String env, Pageable pageable);
-    AppMonitor findByAppIdAndMonitorType(String appId, String monitorType);
     AppMonitor findByAppId(String appId);
     List<AppMonitor> findByEnvAndAppType(String env, String appType);
 }

+ 0 - 15
dmaster/src/main/java/cn/reghao/autodop/dmaster/monitor/db/query/AppMonitorQueryImpl.java

@@ -37,21 +37,6 @@ public class AppMonitorQueryImpl implements AppMonitorQuery {
         return appMonitorRepository.findAll(specification, pageable).map(AppMonitorDto::new);
     }
 
-    @Override
-    public AppMonitor findByAppIdAndMonitorType(String appId, String monitorType) {
-        Map<String, String> query = new HashMap<>();
-        query.put("appId", appId);
-        query.put("monitorType", monitorType);
-
-        Specification<AppMonitor> specification = innerJoin(appId, monitorType);
-        List<AppMonitor> list =  appMonitorRepository.findAll(specification);
-        if (list.size() == 1) {
-            return list.get(0);
-        } else {
-            return null;
-        }
-    }
-
     @Override
     public AppMonitor findByAppId(String appId) {
         Map<String, String> query = new HashMap<>();

+ 14 - 27
dmaster/src/main/java/cn/reghao/autodop/dmaster/mqttsub/impl/rpcresult/AppRpcClazzResultImpl.java

@@ -2,13 +2,9 @@ package cn.reghao.autodop.dmaster.mqttsub.impl.rpcresult;
 
 import cn.reghao.autodop.common.msg.rpc.dto.app.StatusResult;
 import cn.reghao.autodop.common.msg.rpc.dto.app.DeployResult;
-import cn.reghao.autodop.dmaster.app.db.crud.log.DeployLogCrud;
-import cn.reghao.autodop.dmaster.app.service.config.AppDeployingService;
-import cn.reghao.autodop.dmaster.app.service.config.AppRunningService;
-import cn.reghao.autodop.dmaster.monitor.db.query.AppMonitorQuery;
-import cn.reghao.autodop.dmaster.monitor.model.constant.MonitorType;
-import cn.reghao.autodop.dmaster.monitor.model.po.AppMonitor;
-import cn.reghao.autodop.dmaster.notification.model.po.NotifyGroup;
+import cn.reghao.autodop.dmaster.app.model.po.log.DeployLog;
+import cn.reghao.autodop.dmaster.app.service.bd.AppDeployingService;
+import cn.reghao.autodop.dmaster.app.service.bd.AppRunningService;
 import cn.reghao.jdkutil.result.Result;
 import cn.reghao.jdkutil.result.ResultStatus;
 import cn.reghao.jdkutil.serializer.JsonConverter;
@@ -22,41 +18,32 @@ import org.springframework.stereotype.Service;
 @Slf4j
 @Service
 public class AppRpcClazzResultImpl {
-    private DeployLogCrud deployLogCrud;
-    private AppDeployingService deployingService;
+    private final AppDeployingService deployingService;
     private final AppRunningService runningService;
-    private AppMonitorQuery appMonitorQuery;
 
-    public AppRpcClazzResultImpl(AppDeployingService deployingService, AppRunningService runningService,
-                                 AppMonitorQuery appMonitorQuery) {
+    public AppRpcClazzResultImpl(AppDeployingService deployingService, AppRunningService runningService) {
         this.deployingService = deployingService;
         this.runningService = runningService;
-        this.appMonitorQuery = appMonitorQuery;
     }
 
     public void deployResult(DeployResult deployResult) {
+        // 1.更新 DeployLog
+        DeployLog deployLog = deployingService.updateDeployLog(deployResult);
+        // 2.更新 AppDeploying
+        deployingService.refresh(deployResult);
+        // 3.更新 AppRunning
         Result result = deployResult.getResult();
         int code = result.getCode();
         String msg = result.getMsg();
         if (code != ResultStatus.SUCCESS.getCode()) {
             log.error("msg -> {}", msg);
-            return;
+        } else {
+            StatusResult statusResult = JsonConverter.jsonToObject(msg, StatusResult.class);
+            runningService.refresh(statusResult);
         }
 
-        // 1.添加 DeployLog
-        // 2.更新 AppDeploying
-        // 3.更新 AppRunning
         // 4.发送部署通知
-        StatusResult statusResult = JsonConverter.jsonToObject(msg, StatusResult.class);
-        String appId = statusResult.getAppId();
-        AppMonitor appMonitor = appMonitorQuery.findByAppIdAndMonitorType(appId, MonitorType.appDeploy.name());
-        if (appMonitor == null) {
-            log.error("{} 没有部署通知配置", appId);
-            return;
-        }
-
-        NotifyGroup notifyGroup = appMonitor.getAppDeploy();
-        System.out.println();
+        deployingService.sendDeployNotify(deployLog);
     }
 
     public void statusResult(StatusResult statusResult) {

+ 11 - 0
dmaster/src/main/java/cn/reghao/autodop/dmaster/notification/db/crud/DingAccountCrud.java

@@ -0,0 +1,11 @@
+package cn.reghao.autodop.dmaster.notification.db.crud;
+
+import cn.reghao.autodop.dmaster.notification.model.po.DingAccount;
+import cn.reghao.jdkutil.db.BaseCrud;
+
+/**
+ * @author reghao
+ * @date 2021-10-25 19:20:39
+ */
+public interface DingAccountCrud extends BaseCrud<DingAccount> {
+}

+ 11 - 0
dmaster/src/main/java/cn/reghao/autodop/dmaster/notification/db/crud/NotifyGroupCrud.java

@@ -0,0 +1,11 @@
+package cn.reghao.autodop.dmaster.notification.db.crud;
+
+import cn.reghao.autodop.dmaster.notification.model.po.NotifyGroup;
+import cn.reghao.jdkutil.db.BaseCrud;
+
+/**
+ * @author reghao
+ * @date 2021-10-25 19:20:53
+ */
+public interface NotifyGroupCrud extends BaseCrud<NotifyGroup> {
+}

+ 12 - 0
dmaster/src/main/java/cn/reghao/autodop/dmaster/notification/db/query/DingAccountQuery.java

@@ -0,0 +1,12 @@
+package cn.reghao.autodop.dmaster.notification.db.query;
+
+import cn.reghao.autodop.dmaster.notification.model.po.DingAccount;
+import cn.reghao.jdkutil.db.BaseQuery;
+
+/**
+ * @author reghao
+ * @date 2021-10-25 19:20:21
+ */
+public interface DingAccountQuery extends BaseQuery<DingAccount> {
+    DingAccount findByNotifyAccountId(String notifyAccountId);
+}

+ 24 - 0
dmaster/src/main/java/cn/reghao/autodop/dmaster/notification/db/query/DingAccountQueryImpl.java

@@ -0,0 +1,24 @@
+package cn.reghao.autodop.dmaster.notification.db.query;
+
+import cn.reghao.autodop.dmaster.notification.db.repository.DingAccountRepository;
+import cn.reghao.autodop.dmaster.notification.model.po.DingAccount;
+import cn.reghao.jdkutil.db.BaseQuery;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author reghao
+ * @date 2021-10-25 19:20:21
+ */
+@Service
+public class DingAccountQueryImpl implements DingAccountQuery {
+    private final DingAccountRepository dingAccountRepository;
+
+    public DingAccountQueryImpl(DingAccountRepository dingAccountRepository) {
+        this.dingAccountRepository = dingAccountRepository;
+    }
+
+    @Override
+    public DingAccount findByNotifyAccountId(String notifyAccountId) {
+        return dingAccountRepository.findByNotifyAccountId(notifyAccountId);
+    }
+}

+ 1 - 1
dmaster/src/main/java/cn/reghao/autodop/dmaster/notification/db/repository/DingAccountRepository.java

@@ -8,5 +8,5 @@ import org.springframework.data.jpa.repository.JpaRepository;
  * @date 2021-05-24 15:20:24
  */
 public interface DingAccountRepository extends JpaRepository<DingAccount, Integer> {
-    DingAccount findDingAccountByNotifyAccountId(String notifyAccountId);
+    DingAccount findByNotifyAccountId(String notifyAccountId);
 }

+ 1 - 1
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/BuildNotifyMsg.java → dmaster/src/main/java/cn/reghao/autodop/dmaster/notification/model/vo/BuildNotifyMsg.java

@@ -1,4 +1,4 @@
-package cn.reghao.autodop.dmaster.app.service.bd;
+package cn.reghao.autodop.dmaster.notification.model.vo;
 
 import cn.reghao.autodop.dmaster.app.model.po.log.BuildLog;
 import cn.reghao.autodop.dmaster.notification.service.notifier.ding.DingMsg;

+ 13 - 12
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/DeployNotifyMsg.java → dmaster/src/main/java/cn/reghao/autodop/dmaster/notification/model/vo/DeployNotifyMsg.java

@@ -1,10 +1,11 @@
-package cn.reghao.autodop.dmaster.app.service.bd;
+package cn.reghao.autodop.dmaster.notification.model.vo;
 
-import cn.reghao.autodop.common.msg.rpc.dto.app.StatusResult;
-import cn.reghao.autodop.common.msg.rpc.dto.app.DeployResult;
 import cn.reghao.autodop.dmaster.app.model.po.log.BuildLog;
+import cn.reghao.autodop.dmaster.app.model.po.log.DeployLog;
 import cn.reghao.autodop.dmaster.notification.service.notifier.ding.DingMsg;
 import cn.reghao.jdkutil.converter.DateTimeConverter;
+import cn.reghao.jdkutil.result.Result;
+import cn.reghao.jdkutil.result.ResultStatus;
 import lombok.Data;
 
 /**
@@ -26,22 +27,22 @@ public class DeployNotifyMsg {
     private String deployTime;
     private String deployBy;
 
-    public DeployNotifyMsg(BuildLog buildLog, DeployResult deployResult) {
+    public DeployNotifyMsg(BuildLog buildLog, DeployLog deployLog) {
         this.buildId = buildLog.getId();
         this.appId = buildLog.getAppId();
         this.env = buildLog.getEnv();
         this.repoBranch = buildLog.getRepoBranch();
         this.commitId = buildLog.getCommitInfo().getCommitId();
         this.commitTime = DateTimeConverter.format(buildLog.getCommitInfo().getMsCommitTime());
-        /*this.machineIpv4 = deployResult.getMachineIpv4();
-        this.deployResult = deployResult.getResult().getMsg();
-        StatusResult appStatus = deployResult.getAppStatus();
-        if (appStatus != null) {
-            this.deployTime = DateTimeConverter.format(appStatus.getStartTime());
+        this.machineIpv4 = deployLog.getMachineIpv4();
+        Result result = deployLog.getResult();
+        if (result.getCode() == ResultStatus.SUCCESS.getCode()) {
+            this.deployResult = ResultStatus.SUCCESS.getMsg();
         } else {
-            this.deployTime = DateTimeConverter.format(0);
-        }*/
-        this.deployBy = "某人";
+            this.deployResult = deployLog.getResult().getMsg();
+        }
+        this.deployTime = DateTimeConverter.format(deployLog.getDeployTime());
+        this.deployBy = deployLog.getDeployBy();
     }
 
     public DingMsg dingMsg() {

+ 22 - 56
dmaster/src/main/java/cn/reghao/autodop/dmaster/notification/service/NotifyService.java

@@ -2,12 +2,10 @@ package cn.reghao.autodop.dmaster.notification.service;
 
 import cn.reghao.autodop.common.http.DefaultWebRequest;
 import cn.reghao.autodop.common.http.WebRequest;
+import cn.reghao.autodop.dmaster.notification.db.query.DingAccountQuery;
+import cn.reghao.autodop.dmaster.notification.db.query.NotifyGroupQuery;
 import cn.reghao.autodop.dmaster.notification.model.po.*;
 import cn.reghao.autodop.common.util.thread.ThreadPoolWrapper;
-import cn.reghao.autodop.dmaster.notification.db.repository.DingAccountRepository;
-import cn.reghao.autodop.dmaster.notification.db.repository.EmailAccountRepository;
-import cn.reghao.autodop.dmaster.notification.db.repository.NotifyGroupRepository;
-import cn.reghao.autodop.dmaster.notification.db.repository.SmsAccountRepository;
 import cn.reghao.autodop.dmaster.notification.service.notifier.Notify;
 import cn.reghao.autodop.dmaster.notification.service.notifier.ding.DingMsg;
 import cn.reghao.autodop.dmaster.notification.service.notifier.ding.DingNotify;
@@ -32,23 +30,16 @@ import java.util.concurrent.ExecutorService;
 @Slf4j
 @Service
 public class NotifyService {
-    private ExecutorService threadPool = ThreadPoolWrapper.threadPool("notify-service");
-    private Map<NotifyGroup, Notify> notifierMap = new HashMap<>();
-    private WebRequest webRequest;
-    private NotifyGroupRepository groupRepository;
-    private DingAccountRepository dingRepository;
-    private EmailAccountRepository emailRepository;
-    private SmsAccountRepository smsRepository;
+    private final ExecutorService threadPool = ThreadPoolWrapper.threadPool("notify-service");
+    private final Map<NotifyGroup, Notify> notifierMap = new HashMap<>();
+    private final WebRequest webRequest;
+    private final NotifyGroupQuery notifyGroupQuery;
+    private final DingAccountQuery dingAccountQuery;
 
-    public NotifyService(NotifyGroupRepository groupRepository,
-                         DingAccountRepository dingRepository,
-                         EmailAccountRepository emailRepository,
-                         SmsAccountRepository smsRepository) {
+    public NotifyService(NotifyGroupQuery notifyGroupQuery, DingAccountQuery dingAccountQuery) {
         this.webRequest = new DefaultWebRequest();
-        this.groupRepository = groupRepository;
-        this.dingRepository = dingRepository;
-        this.emailRepository = emailRepository;
-        this.smsRepository = smsRepository;
+        this.notifyGroupQuery = notifyGroupQuery;
+        this.dingAccountQuery = dingAccountQuery;
     }
 
     /**
@@ -60,7 +51,7 @@ public class NotifyService {
      */
     @PostConstruct
     private void initNotifier() throws UnsupportedEncodingException {
-        for (NotifyGroup group : groupRepository.findAll()) {
+        for (NotifyGroup group : notifyGroupQuery.findAll()) {
             addNotifier(group);
         }
     }
@@ -75,23 +66,11 @@ public class NotifyService {
         String notifyAccountId = notifyGroup.getNotifyAccountId();
         switch (NotifyType.valueOf(notifyType)) {
             case ding:
-                DingAccount dingAccount = dingRepository.findDingAccountByNotifyAccountId(notifyAccountId);
+                DingAccount dingAccount = dingAccountQuery.findByNotifyAccountId(notifyAccountId);
                 notifierMap.put(notifyGroup, new DingNotify(webRequest, dingAccount));
                 break;
-            case email:
-                EmailAccount emailAccount = emailRepository.findEmailAccountByNotifyAccountId(notifyAccountId);
-                if (emailAccount != null) {
-                    notifierMap.put(notifyGroup, new EmailNotify(emailAccount));
-                }
-                break;
-            case sms:
-                SmsAccount smsAccount = smsRepository.findSmsAccountByNotifyAccountId(notifyAccountId);
-                if (smsAccount != null) {
-                    notifierMap.put(notifyGroup, new SmsNotify(webRequest, smsAccount));
-                }
-                break;
             default:
-                log.error("通知类型不存在");
+                log.error("{} 通知类型暂未实现", notifyType);
         }
     }
 
@@ -104,31 +83,18 @@ public class NotifyService {
         }
 
         String notifyType = notifyGroup.getNotifyType();
-        /*switch (NotifyType.valueOf(notifyType)) {
+        switch (NotifyType.valueOf(notifyType)) {
             case ding:
                 if (!(msg instanceof DingMsg)) {
                     log.error("{} 消息格式不正确, 不是 DingMsg", msg);
                 }
-                notifyGroup.getReceivers()
-                        .forEach(receiver -> threadPool.execute(new NotifyTask(notify, receiver, msg)));
-                break;
-            case email:
-                if (!(msg instanceof EmailMsg)) {
-                    log.error("{} 消息格式不正确, 不是 EmailMsg", msg);
-                }
-                notifyGroup.getReceivers()
-                        .forEach(receiver -> threadPool.execute(new NotifyTask(notify, receiver, msg)));
-                break;
-            case sms:
-                if (!(msg instanceof String)) {
-                    log.error("{} 消息格式不正确, 不是 SMS 消息", msg);
-                }
-                notifyGroup.getReceivers()
-                        .forEach(receiver -> threadPool.execute(new NotifyTask(notify, receiver, msg)));
+                DingMsg dingMsg = (DingMsg) msg;
+                String receiver = notifyGroup.getReceiver();
+                threadPool.execute(new NotifyTask<DingMsg>(notify, receiver, dingMsg));
                 break;
             default:
-                log.error("通知类型不存在");
-        }*/
+                log.error("{} 通知类型暂未实现", notifyType);
+        }
     }
 
     /**
@@ -139,9 +105,9 @@ public class NotifyService {
      * @date 2021-06-23 上午9:29
      */
     static class NotifyTask<T> implements Runnable {
-        private Notify<T> notify;
-        private String receiver;
-        private T msg;
+        private final Notify<T> notify;
+        private final String receiver;
+        private final T msg;
 
         public NotifyTask(Notify<T> notify, String receiver, T msg) {
             this.notify = notify;

+ 32 - 1
dmaster/src/test/java/cn/reghao/autodop/dmaster/app/service/impl/BuildDeployConfigServiceImplTest.java

@@ -1,10 +1,14 @@
 package cn.reghao.autodop.dmaster.app.service.impl;
 
 import cn.reghao.autodop.dmaster.DmasterApplication;
+import cn.reghao.autodop.dmaster.app.db.query.AppDeployingQuery;
 import cn.reghao.autodop.dmaster.app.db.query.config.AppConfigQuery;
+import cn.reghao.autodop.dmaster.app.db.query.config.AppDeployConfigQuery;
 import cn.reghao.autodop.dmaster.app.model.constant.EnvList;
 import cn.reghao.autodop.dmaster.app.model.po.config.AppConfig;
-import cn.reghao.autodop.dmaster.app.service.config.AppBuildingService;
+import cn.reghao.autodop.dmaster.app.service.bd.AppBuildingService;
+import cn.reghao.autodop.dmaster.app.service.bd.AppDeployingService;
+import cn.reghao.autodop.dmaster.app.service.bd.AppRunningService;
 import cn.reghao.autodop.dmaster.monitor.db.crud.AppMonitorCrud;
 import cn.reghao.autodop.dmaster.monitor.model.po.AppMonitor;
 import org.junit.Test;
@@ -26,6 +30,14 @@ public class BuildDeployConfigServiceImplTest {
     @Autowired
     private AppBuildingService buildingService;
     @Autowired
+    private AppDeployingService deployingService;
+    @Autowired
+    private AppDeployingQuery deployingQuery;
+    @Autowired
+    private AppRunningService runningService;
+    @Autowired
+    private AppDeployConfigQuery deployConfigQuery;
+    @Autowired
     private AppMonitorCrud appMonitorCrud;
 
     @Test
@@ -41,6 +53,25 @@ public class BuildDeployConfigServiceImplTest {
         System.out.println();
     }
 
+    @Test
+    public void generateAppDeploying() {
+        List<AppConfig> list = appConfigQuery.findAll().stream()
+                .filter(appConfig -> appConfig.getEnv().equals(EnvList.dev.getName()))
+                .collect(Collectors.toList());
+        list.forEach(appConfig -> {
+            deployConfigQuery.findByAppId(appConfig.getAppId()).forEach(appDeployConfig -> {
+                deployingService.add(appDeployConfig);
+            });
+        });
+    }
+
+    @Test
+    public void generateAppRunning() {
+        deployingQuery.findAll().forEach(appDeploying -> {
+            runningService.add(appDeploying);
+        });
+    }
+
     @Test
     public void generateAppMonitor() {
         List<AppMonitor> list = appConfigQuery.findAll().stream()