|
|
@@ -112,12 +112,12 @@ public class DeployStatImpl implements DeployStat {
|
|
|
|
|
|
@Override
|
|
|
public void afterBuild(AppBuilding appBuilding) {
|
|
|
- String appId = appBuilding.getAppConfig().getAppId();
|
|
|
- /*List<AppDeploying> list = deployingRepository.findAllByAppDeployConfig_AppConfig_AppId(appId);
|
|
|
- list.forEach(appDeploying -> {
|
|
|
- appDeploying.afterBuild(appBuilding);
|
|
|
- });
|
|
|
- deployingRepository.saveAll(list);*/
|
|
|
+ AppConfig appConfig = appBuilding.getAppConfig();
|
|
|
+ AppDeploying appDeploying = deployingRepository.findByAppConfig(appConfig);
|
|
|
+ if (appDeploying != null) {
|
|
|
+ appDeploying.setBuildLog(appBuilding.getBuildLog());
|
|
|
+ deployingRepository.save(appDeploying);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -196,32 +196,23 @@ public class DeployStatImpl implements DeployStat {
|
|
|
|
|
|
@Override
|
|
|
public List<AppDeployingVO> get(String appId, AppBuilding appBuilding) {
|
|
|
- List<AppDeploying> list = Collections.emptyList();
|
|
|
- if (list.isEmpty()) {
|
|
|
+ AppDeploying appDeploying = deployingRepository.findByAppConfig_AppId(appId);
|
|
|
+ if (appDeploying == null) {
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
|
|
|
|
- return list.stream().map(appDeploying -> {
|
|
|
- MachineHost machineHost = appDeploying.getDeployingNodes().get(0).getDeployConfig().getMachineHost();
|
|
|
- String machineStatus = machineService.isAgentOnline(machineHost.getMachineId())
|
|
|
- ? NodeStatus.Online.name() : NodeStatus.Offline.name();
|
|
|
-
|
|
|
- if (appBuilding == null || appBuilding.getBuildCode() != ResultStatus.SUCCESS.getCode()) {
|
|
|
- return new AppDeployingVO(appDeploying, machineStatus);
|
|
|
- }
|
|
|
-
|
|
|
- AppDeployingVO appDeployingVO;
|
|
|
- String buildLogId1 = appDeploying.getBuildLog().getBuildLogId();
|
|
|
- if (buildLogId1.equals(appBuilding.getBuildLog().getBuildLogId())) {
|
|
|
- appDeployingVO = new AppDeployingVO(appDeploying, machineStatus);
|
|
|
- } else {
|
|
|
- appDeployingVO = new AppDeployingVO(appDeploying, machineStatus, DeployStatus.neverDeploy.getDesc());
|
|
|
- }
|
|
|
- return appDeployingVO;
|
|
|
- })
|
|
|
- // 降序
|
|
|
- .sorted(Comparator.comparing(AppDeployingVO::getDeployTime).reversed())
|
|
|
- .collect(Collectors.toList());
|
|
|
+ BuildLog buildLog = appDeploying.getBuildLog();
|
|
|
+ return appDeploying.getDeployingNodes().stream().map(appDeployingNode -> {
|
|
|
+ MachineHost machineHost = appDeployingNode.getDeployConfig().getMachineHost();
|
|
|
+ String machineStatus = machineService.isAgentOnline(machineHost.getMachineId())
|
|
|
+ ? NodeStatus.Online.name() : NodeStatus.Offline.name();
|
|
|
+
|
|
|
+ if (buildLog == null || buildLog.getCode() != ResultStatus.SUCCESS.getCode()) {
|
|
|
+ return new AppDeployingVO(appDeployingNode, null, machineStatus);
|
|
|
+ }
|
|
|
+
|
|
|
+ return new AppDeployingVO(appDeployingNode, buildLog, machineStatus, DeployStatus.neverDeploy.getDesc());
|
|
|
+ }).sorted(Comparator.comparing(AppDeployingVO::getDeployTime).reversed()).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
@Override
|