构建历史查询问题,构建历史新增构建名称字段,下拉框新增不选择选项

This commit is contained in:
bwcx_jzy 2021-09-16 11:57:25 +08:00
parent 837ba46377
commit 050e32027e
9 changed files with 117 additions and 98 deletions

View File

@ -173,6 +173,7 @@ public class BuildInfoManage extends BaseBuild implements Runnable {
buildHistoryLog.setStatus(BuildStatus.Ing.getCode());
buildHistoryLog.setStartTime(System.currentTimeMillis());
buildHistoryLog.setBuildNumberId(buildInfoModel.getBuildId());
buildHistoryLog.setBuildName(buildInfoModel.getName());
buildHistoryLog.setBuildUser(optUserName);
DbBuildHistoryLogService dbBuildHistoryLogService = SpringUtil.getBean(DbBuildHistoryLogService.class);

View File

@ -74,6 +74,9 @@ public class BuildUtil {
* @return file
*/
public static File getHistoryPackageFile(String buildModelId, int buildId, String resultFile) {
if (StrUtil.isEmpty(buildModelId) || StrUtil.isEmpty(resultFile)) {
return null;
}
return FileUtil.file(getBuildDataFile(buildModelId),
"history",
BuildInfoModel.getBuildIdStr(buildId),
@ -110,6 +113,9 @@ public class BuildUtil {
* @return file
*/
public static File getLogFile(String buildModelId, int buildId) {
if (StrUtil.isEmpty(buildModelId)) {
return null;
}
return FileUtil.file(getBuildDataFile(buildModelId),
"history",
BuildInfoModel.getBuildIdStr(buildId),

View File

@ -3,6 +3,7 @@ package io.jpom.controller.build;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.db.Entity;
import cn.hutool.db.Page;
@ -38,6 +39,8 @@ import javax.annotation.Resource;
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
@ -72,7 +75,7 @@ public class BuildInfoHistoryController extends BaseServerController {
return;
}
File logFile = BuildUtil.getHistoryPackageFile(item.getId(), buildHistoryLog.getBuildNumberId(), buildHistoryLog.getResultDirFile());
if (!logFile.exists()) {
if (!FileUtil.exist(logFile)) {
return;
}
if (logFile.isFile()) {
@ -94,7 +97,7 @@ public class BuildInfoHistoryController extends BaseServerController {
BuildInfoModel item = buildInfoService.getByKey(buildHistoryLog.getBuildDataId());
Objects.requireNonNull(item);
File logFile = BuildUtil.getLogFile(item.getId(), buildHistoryLog.getBuildNumberId());
if (!logFile.exists()) {
if (!FileUtil.exist(logFile)) {
return;
}
if (logFile.isFile()) {
@ -146,18 +149,20 @@ public class BuildInfoHistoryController extends BaseServerController {
}
}
PageResult<BuildHistoryLog> pageResult = dbBuildHistoryLogService.listPage(entity, pageObj);
List<BuildHistoryLogVo> buildHistoryLogVos = new ArrayList<>();
pageResult.forEach(buildHistoryLog -> {
BuildHistoryLogVo historyLogVo = new BuildHistoryLogVo();
BeanUtil.copyProperties(buildHistoryLog, historyLogVo);
String dataId = buildHistoryLog.getBuildDataId();
BuildInfoModel item = buildInfoService.getByKey(dataId);
if (item != null) {
historyLogVo.setBuildName(item.getName());
List<BuildHistoryLogVo> collect = pageResult.stream().map(buildHistoryLog -> {
BuildHistoryLogVo buildHistoryLogVo = new BuildHistoryLogVo();
BeanUtil.copyProperties(buildHistoryLog, buildHistoryLogVo);
//
if (StrUtil.isEmpty(buildHistoryLog.getBuildName())) {
String dataId = buildHistoryLog.getBuildDataId();
BuildInfoModel item = buildInfoService.getByKey(dataId);
if (item != null) {
buildHistoryLogVo.setBuildName(item.getName());
}
}
buildHistoryLogVos.add(historyLogVo);
});
JSONObject jsonObject = JsonMessage.toJson(200, "获取成功", buildHistoryLogVos);
return buildHistoryLogVo;
}).collect(Collectors.toList());
JSONObject jsonObject = JsonMessage.toJson(200, "获取成功", collect);
jsonObject.put("total", pageResult.getTotal());
return jsonObject.toString();
}

View File

@ -23,6 +23,10 @@ public class BuildHistoryLog extends BaseBuildModule {
* @see BuildInfoModel#getId()
*/
private String buildDataId;
/**
* 构建名称
*/
private String buildName;
/**
* 构建编号
*
@ -97,4 +101,12 @@ public class BuildHistoryLog extends BaseBuildModule {
public void setEndTime(long endTime) {
this.endTime = endTime;
}
public String getBuildName() {
return buildName;
}
public void setBuildName(String buildName) {
this.buildName = buildName;
}
}

View File

@ -1,13 +1,9 @@
package io.jpom.model.vo;
import cn.jiangzeyin.common.spring.SpringUtil;
import cn.hutool.core.io.FileUtil;
import io.jpom.build.BuildUtil;
import io.jpom.model.BaseEnum;
import io.jpom.model.data.BuildInfoModel;
import io.jpom.model.data.OutGivingModel;
import io.jpom.model.enums.BuildReleaseMethod;
import io.jpom.model.log.BuildHistoryLog;
import io.jpom.service.node.OutGivingServer;
import java.io.File;
@ -18,85 +14,77 @@ import java.io.File;
* @date 2019/7/17
*/
public class BuildHistoryLogVo extends BuildHistoryLog {
private String buildName;
private String releaseDesc;
/**
* 是否存在构建产物
*/
private boolean hashFile;
/**
* 是否存在日志
*/
private boolean hasLog;
public boolean isHasLog() {
File file = BuildUtil.getLogFile(getBuildDataId(), getBuildNumberId());
hasLog = file.exists();
return hasLog;
}
private String releaseDesc;
/**
* 是否存在构建产物
*/
private boolean hashFile;
/**
* 是否存在日志
*/
private boolean hasLog;
public void setHasLog(boolean hasLog) {
this.hasLog = hasLog;
}
public boolean isHasLog() {
File file = BuildUtil.getLogFile(getBuildDataId(), getBuildNumberId());
hasLog = FileUtil.exist(file);
return hasLog;
}
public String getBuildName() {
return buildName;
}
public void setHasLog(boolean hasLog) {
this.hasLog = hasLog;
}
public void setBuildName(String buildName) {
this.buildName = buildName;
}
public boolean isHashFile() {
File file = BuildUtil.getHistoryPackageFile(getBuildDataId(), getBuildNumberId(), getResultDirFile());
hashFile = FileUtil.exist(file);
return hashFile;
}
public boolean isHashFile() {
File file = BuildUtil.getHistoryPackageFile(getBuildDataId(), getBuildNumberId(), getResultDirFile());
hashFile = file.exists();
return hashFile;
}
public void setHashFile(boolean hashFile) {
this.hashFile = hashFile;
}
public void setHashFile(boolean hashFile) {
this.hashFile = hashFile;
}
public String getBuildIdStr() {
return BuildInfoModel.getBuildIdStr(getBuildNumberId());
}
public String getBuildIdStr() {
return BuildInfoModel.getBuildIdStr(getBuildNumberId());
}
public void setReleaseDesc(String releaseDesc) {
this.releaseDesc = releaseDesc;
}
public void setReleaseDesc(String releaseDesc) {
this.releaseDesc = releaseDesc;
}
/**
* 发布描述
*
* @return 描述
*/
public String getReleaseDesc() {
if (releaseDesc == null) {
int releaseMethod = getReleaseMethod();
BuildReleaseMethod releaseMethod1 = BaseEnum.getEnum(BuildReleaseMethod.class, releaseMethod);
if (releaseMethod1 == null) {
return BuildReleaseMethod.No.getDesc();
}
String releaseMethodDataId = getReleaseMethodDataId();
switch (releaseMethod1) {
case Project: {
String[] datas = releaseMethodDataId.split(":");
return String.format("【%s】节点【%s】项目", datas[0], datas[1]);
}
case Outgiving: {
OutGivingServer outGivingServer = SpringUtil.getBean(OutGivingServer.class);
OutGivingModel item = outGivingServer.getItem(releaseMethodDataId);
if (item == null) {
return "-";
}
return "" + item.getName() + "】分发";
}
case No:
default:
return releaseMethod1.getDesc();
}
}
return releaseDesc;
}
// /**
// * 发布描述
// *
// * @return 描述
// */
// public String getReleaseDesc() {
// if (releaseDesc == null) {
// int releaseMethod = getReleaseMethod();
// BuildReleaseMethod releaseMethod1 = BaseEnum.getEnum(BuildReleaseMethod.class, releaseMethod);
// if (releaseMethod1 == null) {
// return BuildReleaseMethod.No.getDesc();
// }
// String releaseMethodDataId = getReleaseMethodDataId();
// switch (releaseMethod1) {
// case Project: {
// String[] datas = releaseMethodDataId.split(":");
// return String.format("【%s】节点【%s】项目", datas[0], datas[1]);
// }
// case Outgiving: {
// OutGivingServer outGivingServer = SpringUtil.getBean(OutGivingServer.class);
// OutGivingModel item = outGivingServer.getItem(releaseMethodDataId);
// if (item == null) {
// return "-";
// }
// return "" + item.getName() + "】分发";
// }
// case No:
// default:
// return releaseMethod1.getDesc();
// }
// }
// return releaseDesc;
// }
}

View File

@ -128,3 +128,7 @@ ALTER TABLE SSHTERMINALEXECUTELOG
ADD IF NOT EXISTS CREATETIMEMILLIS BIGINT COMMENT '数据创建时间';
ALTER TABLE SSHTERMINALEXECUTELOG
ADD IF NOT EXISTS MODIFYTIMEMILLIS BIGINT COMMENT '数据修改时间';
-- @author jzy
ALTER TABLE BUILDHISTORYLOG
ADD IF NOT EXISTS BUILDNAME VARCHAR(100) COMMENT '构建名称';

View File

@ -25,6 +25,7 @@
<a-divider style="margin: 4px 0" />
<v-nodes :vnodes="menu" />
</div>
<a-select-option value="">{{selectPlaceholder}}</a-select-option>
<a-select-option v-for="item in optionList" :key="item">{{ item }} </a-select-option>
</Select>
</div>

View File

@ -20,9 +20,8 @@
<a-tooltip slot="buildName" slot-scope="text" placement="topLeft" :title="text">
<span>{{ text }}</span>
</a-tooltip>
<a-tooltip slot="buildIdStr" slot-scope="text, record" placement="topLeft" :title="text + ' ( 点击查看日志 ) '">
<span v-if="record.buildId <= 0"></span>
<a-tag v-else color="#108ee9" @click="handleBuildLog(record)">{{ text }}</a-tag>
<a-tooltip slot="buildNumberId" slot-scope="text, record" placement="topLeft" :title="text + ' ( 点击查看日志 ) '">
<a-tag color="#108ee9" @click="handleBuildLog(record)">#{{ text }}</a-tag>
</a-tooltip>
<template slot="status" slot-scope="text" placement="topleft" :title="text">
<span>{{ statusMap[text] }}</span>
@ -34,7 +33,7 @@
<span>{{ text }}</span>
</a-tooltip>
<template slot="operation" slot-scope="text, record">
<a-button type="primary" @click="handleDownload(record)">下载日志</a-button>
<a-button type="primary" :disabled="!record.hasLog" @click="handleDownload(record)">下载日志</a-button>
<a-button type="primary" :disabled="!record.hashFile" @click="handleFile(record)">下载产物</a-button>
<a-dropdown>
<a class="ant-dropdown-link" @click="e => e.preventDefault()">
@ -93,7 +92,7 @@ export default {
buildLogVisible: false,
columns: [
{title: '构建名称', dataIndex: 'buildName', /*width: 120,*/ ellipsis: true, scopedSlots: {customRender: 'buildName'}},
{title: '构建 ID', dataIndex: 'buildIdStr', width: 100, ellipsis: true, scopedSlots: {customRender: 'buildIdStr'}},
{title: '构建 ID', dataIndex: 'buildNumberId', width: 100, ellipsis: true, scopedSlots: {customRender: 'buildNumberId'}},
{title: '状态', dataIndex: 'status', width: 120, ellipsis: true, scopedSlots: {customRender: 'status'}},
{title: '开始时间', dataIndex: 'startTime', customRender: (text) => {
return parseTime(text);

View File

@ -43,7 +43,7 @@
</template>
<a-tooltip slot="buildId" slot-scope="text, record" placement="topLeft" :title="text + ' ( 点击查看日志 ) '">
<span v-if="record.buildId <= 0"></span>
<a-tag v-else color="#108ee9" @click="handleBuildLog(record)">{{ text }}</a-tag>
<a-tag v-else color="#108ee9" @click="handleBuildLog(record)">#{{ text }}</a-tag>
</a-tooltip>
<a-tooltip slot="modifyUser" slot-scope="text" placement="topLeft" :title="text">
<span>{{ text }}</span>
@ -268,7 +268,7 @@ export default {
],
columns: [
{ title: "名称", dataIndex: "name", width: 150, ellipsis: true, scopedSlots: { customRender: "name" } },
{ title: "分组", dataIndex: "group", width: 150, ellipsis: true, scopedSlots: { customRender: "group" } },
{ title: "分组", dataIndex: "group", width: 100, ellipsis: true, scopedSlots: { customRender: "group" } },
{
title: "分支",
dataIndex: "branchName",
@ -313,9 +313,10 @@ export default {
title: "产物目录",
dataIndex: "resultDirFile",
ellipsis: true,
width: 100,
scopedSlots: { customRender: "resultDirFile" },
},
{ title: "构建命令", dataIndex: "script", ellipsis: true, scopedSlots: { customRender: "script" } },
{ title: "构建命令", width: 100, dataIndex: "script", ellipsis: true, scopedSlots: { customRender: "script" } },
{
title: "操作",
dataIndex: "operation",
@ -543,6 +544,8 @@ export default {
if (res.code === 200) {
this.branchList = res.data[0];
this.branchTagList = res.data[1];
this.temp.branchName = "";
this.temp.branchTagName = "";
}
loading.close();
});