use of com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO in project Corgi by kevinYin.
the class DeployHistoryServiceImpl method createDeploymentOrder.
@Override
@Transactional
public void createDeploymentOrder(DeploymentOrder order) {
validateParameterAndModule(order);
// 检查服务器是否存在 & 环境是否为 envId
List<Server> servers = checkServerStatus(order);
checkProjectAuthorization(order);
checkIfDeployingModuleWithEnv(order);
logger.info("创建上线单 | order: " + JSON.toJSONString(order));
ProjectModule module = projectModuleService.getByModuleId(order.getModuleId());
DeployHistoryPO deployHistory = new DeployHistoryPO();
VOUtil.copy(order, deployHistory);
deployHistory.setCreateTime(new Date());
deployHistory.setProjectId(module.getProjectId());
deployHistory.setModuleName(module.getModuleName());
deployHistory.setResult(DeployResult.NONE.getValue());
// 如果模块需要审核,进入审核,否则进入发布阶段
if (needAudit(module, deployHistory)) {
deployHistory.setDeployStatus(DeployStatus.WAITING_FOR_AUDIT.getValue());
} else {
deployHistory.setDeployStatus(DeployStatus.WAITING_FOR_DEPLOYMENT.getValue());
}
deployHistory.setSuccessCount(0);
deployHistory.setDeployServers(order.getServerId().length);
if (!deployHistory.getTagName().startsWith("/")) {
deployHistory.setTagName("/" + deployHistory.getTagName());
}
// 判断是不是回滚的请求
if (deployHistory.getRollbackToDeployId() > 0) {
deployHistory.setIsRollback(Constants.TRUE);
}
deployHistoryDao.insert(deployHistory);
saveDeployServers(deployHistory, order, servers);
}
use of com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO in project Corgi by kevinYin.
the class DeployHistoryServiceImpl method audit.
@Override
public void audit(long accountId, int historyId) {
DeployHistoryPO po = readAndGetPermission(accountId, historyId);
if (po.getDeployStatus() != DeployStatus.WAITING_FOR_AUDIT.getValue()) {
throw new IllegalStateException("项目状态已改变,请先刷新页面");
}
int rows = deployHistoryDao.auditDeploy(historyId, DeployStatus.WAITING_FOR_DEPLOYMENT.getValue(), po.getDeployStatus(), accountId, new Date());
logger.info("审核发布记录成功 | accountId: {}, historyId: {}, rows: {}", accountId, historyId, rows);
}
use of com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO in project Corgi by kevinYin.
the class DeployHistoryServiceImpl method reject.
@Override
public void reject(long accountId, int historyId) {
DeployHistoryPO po = readAndGetPermission(accountId, historyId);
if (po.getDeployStatus() != DeployStatus.WAITING_FOR_AUDIT.getValue()) {
throw new IllegalStateException("项目状态已改变,请先刷新页面");
}
int rows = deployHistoryDao.updateResultAndStatus(historyId, DeployResult.FAILURE.getValue(), 0, 0, DeployStatus.AUDIT_REJECTED.getValue(), po.getDeployStatus());
logger.info("取消发布记录成功 | accountId: {}, historyId: {}, rows: {}", accountId, historyId, rows);
}
use of com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO in project Corgi by kevinYin.
the class DeployHistoryServiceImpl method getByServerDeployHistoryId.
@Override
public DeployHistory getByServerDeployHistoryId(int serverDeployHistoryId) {
ServerDeployHistoryPO po = serverDeployHistoryDao.get(serverDeployHistoryId);
DeployHistory history = null;
if (po != null) {
DeployHistoryPO deployPo = deployHistoryDao.get(po.getHistoryId());
history = new DeployHistory();
VOUtil.copy(deployPo, history);
}
return history;
}
use of com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO in project Corgi by kevinYin.
the class DeployHistoryServiceImpl method systemCancel.
@Override
public void systemCancel(int historyId) {
DeployHistoryPO po = deployHistoryDao.get(historyId);
Date now = new Date();
if (po != null && po.getDeployStatus() == DeployStatus.DEPLOYING.getValue() && (now.getTime() - po.getCreateTime().getTime()) / 1000 > Constants.DEPLOY_TASK_TIMEOUT) {
int rows = deployHistoryDao.auditDeploy(historyId, DeployStatus.CANCELLED.getValue(), po.getDeployStatus(), Constants.SYSTEM_ACCOUNT_ID, now);
logger.info("系统取消发布记录成功 | historyId: {}, rows: {}", historyId, rows);
// 这里要 end ...
moduleStatusManagementService.endModuleDeploy(po.getModuleId(), po.getEnvId());
}
}
Aggregations