|
|
package com.monitor.other.projectRestart.ctrl;
|
|
|
package com.monitor.switchs.projectRestart.ctrl;
|
|
|
|
|
|
import com.model.JavaApiInfo;
|
|
|
import com.monitor.influxdb.mapper.JavaProjectMapper;
|
|
|
import com.monitor.model.domain.JavaProjectStatus;
|
|
|
import com.monitor.model.domain.PageBean;
|
|
|
import com.monitor.model.domain.*;
|
|
|
import com.monitor.model.page.PageRequest;
|
|
|
import com.monitor.model.request.JavaApiInfoReq;
|
|
|
import com.monitor.model.response.BaseResponse;
|
|
|
import com.monitor.model.response.PageResponse;
|
|
|
import com.monitor.other.projectRestart.common.Project;
|
|
|
import com.monitor.other.projectRestart.common.ProjectOnline;
|
|
|
import com.monitor.switchs.projectRestart.common.ProjectOnline;
|
|
|
import com.monitor.switchs.projectRestart.common.RestartProcessStore;
|
|
|
import com.monitor.switchs.projectRestart.service.RestartService;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -30,12 +28,12 @@ public class JavaRestartCtrl { |
|
|
Logger log = LoggerFactory.getLogger(JavaRestartCtrl.class);
|
|
|
|
|
|
@Autowired
|
|
|
private JavaProjectMapper javaProjectMapper;
|
|
|
private RestartService restartService;
|
|
|
|
|
|
@RequestMapping("/query")
|
|
|
@ResponseBody
|
|
|
public BaseResponse<PageResponse<Project>> getProjectInfos(@RequestBody PageRequest req) throws Exception {
|
|
|
PageResponse<Project> response = new PageResponse<Project>();
|
|
|
PageResponse<Project> response = new PageResponse<>();
|
|
|
try {
|
|
|
// 组装分页对象
|
|
|
PageBean page = PageBean.initPageInfo(req.getCurrentPage(),
|
...
|
...
|
@@ -61,7 +59,7 @@ public class JavaRestartCtrl { |
|
|
@ResponseBody
|
|
|
public BaseResponse<List<JavaProjectStatus>> getStatusInfos(String project) {
|
|
|
try {
|
|
|
List<JavaProjectStatus> list = javaProjectMapper.getByProject(project);
|
|
|
List<JavaProjectStatus> list = restartService.getStatusInfos(project);
|
|
|
return new BaseResponse<>(list);
|
|
|
} catch (Exception e) {
|
|
|
log.error("getStatusInfos ~", e);
|
...
|
...
|
@@ -70,4 +68,60 @@ public class JavaRestartCtrl { |
|
|
|
|
|
}
|
|
|
|
|
|
@RequestMapping("/stopOrRestart")
|
|
|
public BaseResponse<List<RestartModel>> stopOrRestart(@RequestBody RestartModel restartModel) {
|
|
|
try {
|
|
|
List<RestartModel> integerList = new ArrayList<>();
|
|
|
if ("all".equals(restartModel.getProject())) {
|
|
|
RestartModel model;
|
|
|
for (Project project : ProjectOnline.getJavaList()) {
|
|
|
model = new RestartModel();
|
|
|
model.setProject(project.getName());
|
|
|
model.setIp(restartModel.getIp());
|
|
|
model.setCloud(restartModel.getCloud());
|
|
|
model.setExe(restartModel.getExe());
|
|
|
RestartProcess restartProcess = new RestartProcess();
|
|
|
restartProcess.setRestartModel(restartModel);
|
|
|
Integer id = RestartProcessStore.put(restartProcess);
|
|
|
model.setId(id);
|
|
|
integerList.add(model);
|
|
|
restartService.stopOrRestart(id);
|
|
|
}
|
|
|
} else {
|
|
|
RestartProcess restartProcess = new RestartProcess();
|
|
|
restartProcess.setRestartModel(restartModel);
|
|
|
Integer id = RestartProcessStore.put(restartProcess);
|
|
|
|
|
|
restartModel.setId(id);
|
|
|
integerList.add(restartModel);
|
|
|
restartService.stopOrRestart(id);
|
|
|
}
|
|
|
return new BaseResponse<>(integerList);
|
|
|
} catch (Exception e) {
|
|
|
log.error("stopOrRestart ~", e);
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
@RequestMapping("/getMessage")
|
|
|
@ResponseBody
|
|
|
public BaseResponse<RestartProcessResult> getMessage(Integer id) {
|
|
|
RestartProcess restartProcess = RestartProcessStore.get(id);
|
|
|
if (restartProcess == null){
|
|
|
BaseResponse baseResponse = new BaseResponse<>();
|
|
|
baseResponse.setCode(300);
|
|
|
return baseResponse;
|
|
|
}
|
|
|
RestartProcessResult restartProcessResult = new RestartProcessResult();
|
|
|
restartProcessResult.setToDoList(restartProcess.getToDoList().toString());
|
|
|
restartProcessResult.setDoneList(restartProcess.getDoneList().toString());
|
|
|
restartProcessResult.setDonePersent(restartProcess.getDonePersent());
|
|
|
|
|
|
if (restartProcess.getStatus() == 2) {
|
|
|
RestartProcessStore.remove(id);
|
|
|
}
|
|
|
return new BaseResponse<>(restartProcessResult);
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|