mirror of
https://gitee.com/dromara/Jpom.git
synced 2024-12-01 19:38:09 +08:00
fix 逻辑节点中项目数和脚本数仅显示当前工作空间数量
This commit is contained in:
parent
ffe43958c8
commit
e90de9cf76
@ -1,5 +1,17 @@
|
||||
# 🚀 版本日志
|
||||
|
||||
### 2.11.0.1-beta
|
||||
|
||||
### 🐣 新增功能
|
||||
|
||||
|
||||
### 🐞 解决BUG、优化功能
|
||||
|
||||
1. 【server】修复 新版页面漏掉项目复制按钮
|
||||
2. 【server】优化 逻辑节点中项目数和脚本数仅显示当前工作空间数量
|
||||
|
||||
------
|
||||
|
||||
### 2.11.0.0-beta (2023-12-29)
|
||||
|
||||
### 🐣 新增功能
|
||||
|
@ -50,7 +50,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -125,9 +127,33 @@ public class IndexController extends BaseAgentController {
|
||||
jsonObject.put("totalMemory", SystemUtil.getTotalMemory());
|
||||
//
|
||||
jsonObject.put("freeMemory", SystemUtil.getFreeMemory());
|
||||
Map<String, JSONObject> workspaceMap = new HashMap<>(4);
|
||||
//
|
||||
jsonObject.put("projectCount", CollUtil.size(nodeProjectInfoModels));
|
||||
jsonObject.put("scriptCount", CollUtil.size(list));
|
||||
{
|
||||
for (NodeProjectInfoModel model : nodeProjectInfoModels) {
|
||||
JSONObject jsonObject1 = workspaceMap.computeIfAbsent(model.getWorkspaceId(), s -> {
|
||||
JSONObject jsonObject11 = new JSONObject();
|
||||
jsonObject11.put("projectCount", 0);
|
||||
jsonObject11.put("scriptCount", 0);
|
||||
return jsonObject11;
|
||||
});
|
||||
jsonObject1.merge("projectCount", 1, (v1, v2) -> Integer.sum((Integer) v1, (Integer) v2));
|
||||
}
|
||||
jsonObject.put("projectCount", CollUtil.size(nodeProjectInfoModels));
|
||||
}
|
||||
{
|
||||
for (NodeScriptModel model : list) {
|
||||
JSONObject jsonObject1 = workspaceMap.computeIfAbsent(model.getWorkspaceId(), s -> {
|
||||
JSONObject jsonObject11 = new JSONObject();
|
||||
jsonObject11.put("projectCount", 0);
|
||||
jsonObject11.put("scriptCount", 0);
|
||||
return jsonObject11;
|
||||
});
|
||||
jsonObject1.merge("scriptCount", 1, (v1, v2) -> Integer.sum((Integer) v1, (Integer) v2));
|
||||
}
|
||||
jsonObject.put("scriptCount", CollUtil.size(list));
|
||||
}
|
||||
jsonObject.put("workspaceStat", workspaceMap);
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,6 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -283,9 +282,9 @@ public class MachineNodeServer extends BaseDbService<MachineNodeModel> implement
|
||||
networkDelay = networkDelay - systemSleep;
|
||||
machineNodeModel.setNetworkDelay(networkDelay);
|
||||
// jpom 相关信息
|
||||
Optional.ofNullable(data.getJSONObject("jpomInfo")).ifPresent(jsonObject -> {
|
||||
JSONObject jpomManifest = jsonObject.getJSONObject("jpomManifest");
|
||||
Optional.ofNullable(jpomManifest)
|
||||
JSONObject jpomInfo = data.getJSONObject("jpomInfo");
|
||||
Optional.ofNullable(jpomInfo).ifPresent(jsonObject -> {
|
||||
Optional.ofNullable(jsonObject.getJSONObject("jpomManifest"))
|
||||
.ifPresent(jsonObject1 -> {
|
||||
machineNodeModel.setJpomVersion(jsonObject1.getString("version"));
|
||||
machineNodeModel.setJpomBuildTime(jsonObject1.getString("timeStamp"));
|
||||
@ -342,6 +341,26 @@ public class MachineNodeServer extends BaseDbService<MachineNodeModel> implement
|
||||
});
|
||||
this.updateById(machineNodeModel);
|
||||
machineNodeStatLogServer.insert(machineNodeStatLogModel);
|
||||
//
|
||||
Optional.ofNullable(jpomInfo).ifPresent(jsonObject -> {
|
||||
JSONObject workspaceStat = jsonObject.getJSONObject("workspaceStat");
|
||||
if (workspaceStat == null) {
|
||||
return;
|
||||
}
|
||||
for (Map.Entry<String, Object> entry : workspaceStat.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
JSONObject value = (JSONObject) entry.getValue();
|
||||
int projectCount = value.getIntValue("projectCount", 0);
|
||||
int scriptCount = value.getIntValue("scriptCount", 0);
|
||||
Entity entity = Entity.create();
|
||||
entity.set("jpomProjectCount", projectCount);
|
||||
entity.set("jpomScriptCount", scriptCount);
|
||||
Entity where = Entity.create();
|
||||
where.set("machineId", machineNodeModel.getId());
|
||||
where.set("workspaceId", key);
|
||||
nodeService.update(entity, where);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -34,8 +34,8 @@ import org.dromara.jpom.model.BaseMachineModel;
|
||||
* 节点实体
|
||||
*
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/16
|
||||
* @see MachineNodeModel
|
||||
* @since 2019/4/16
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName(value = "NODE_INFO", name = "节点信息")
|
||||
@ -90,6 +90,14 @@ public class NodeModel extends BaseMachineModel {
|
||||
|
||||
@PropIgnore
|
||||
private WorkspaceModel workspace;
|
||||
/**
|
||||
* jpom 项目数
|
||||
*/
|
||||
private Integer jpomProjectCount;
|
||||
/**
|
||||
* jpom 脚本数据
|
||||
*/
|
||||
private Integer jpomScriptCount;
|
||||
|
||||
public boolean isOpenStatus() {
|
||||
return openStatus != null && openStatus == 1;
|
||||
|
@ -163,29 +163,28 @@ public abstract class BaseNodeService<T extends BaseNodeModel> extends BaseGloba
|
||||
.collect(Collectors.toSet());
|
||||
// 转换数据修改时间
|
||||
List<T> projectInfoModels = jsonArray.stream().map(o -> {
|
||||
// modifyTime,createTime
|
||||
JSONObject jsonObject = (JSONObject) o;
|
||||
T t = jsonObject.to(tClass);
|
||||
Opt.ofBlankAble(jsonObject.getString("createTime")).map(s -> {
|
||||
try {
|
||||
return DateUtil.parse(s);
|
||||
} catch (Exception e) {
|
||||
log.warn("数据创建时间格式不正确 {} {}", s, jsonObject);
|
||||
return null;
|
||||
}
|
||||
}).ifPresent(s -> t.setCreateTimeMillis(s.getTime()));
|
||||
//
|
||||
Opt.ofBlankAble(jsonObject.getString("modifyTime")).map(s -> {
|
||||
try {
|
||||
return DateUtil.parse(s);
|
||||
} catch (Exception e) {
|
||||
log.warn("数据修改时间格式不正确 {} {}", s, jsonObject);
|
||||
return null;
|
||||
}
|
||||
}).ifPresent(s -> t.setModifyTimeMillis(s.getTime()));
|
||||
return t;
|
||||
}).collect(Collectors.toList());
|
||||
List<T> models = projectInfoModels.stream()
|
||||
// modifyTime,createTime
|
||||
JSONObject jsonObject = (JSONObject) o;
|
||||
T t = jsonObject.to(tClass);
|
||||
Opt.ofBlankAble(jsonObject.getString("createTime")).map(s -> {
|
||||
try {
|
||||
return DateUtil.parse(s);
|
||||
} catch (Exception e) {
|
||||
log.warn("数据创建时间格式不正确 {} {}", s, jsonObject);
|
||||
return null;
|
||||
}
|
||||
}).ifPresent(s -> t.setCreateTimeMillis(s.getTime()));
|
||||
//
|
||||
Opt.ofBlankAble(jsonObject.getString("modifyTime")).map(s -> {
|
||||
try {
|
||||
return DateUtil.parse(s);
|
||||
} catch (Exception e) {
|
||||
log.warn("数据修改时间格式不正确 {} {}", s, jsonObject);
|
||||
return null;
|
||||
}
|
||||
}).ifPresent(s -> t.setModifyTimeMillis(s.getTime()));
|
||||
return t;
|
||||
})
|
||||
.peek(item -> this.fullData(item, nodeModel))
|
||||
// 只保留自己节点的数据
|
||||
.filter(t -> StrUtil.equals(t.getNodeId(), nodeModel.getId()))
|
||||
@ -219,7 +218,7 @@ public abstract class BaseNodeService<T extends BaseNodeModel> extends BaseGloba
|
||||
// 设置 临时缓存,便于放行检查
|
||||
BaseServerController.resetInfo(UserModel.EMPTY);
|
||||
//
|
||||
models.forEach(BaseNodeService.super::upsert);
|
||||
projectInfoModels.forEach(BaseNodeService.super::upsert);
|
||||
// 删除项目
|
||||
int delCount = 0;
|
||||
Set<String> strings = cacheIds.stream()
|
||||
@ -232,12 +231,14 @@ public abstract class BaseNodeService<T extends BaseNodeModel> extends BaseGloba
|
||||
if (CollUtil.isNotEmpty(needDelete)) {
|
||||
delCount = super.delByKey(needDelete, null);
|
||||
}
|
||||
int size = CollUtil.size(projectInfoModels);
|
||||
String format = StrUtil.format(
|
||||
"{} 节点拉取到 {} 个{},已经缓存 {} 个{},更新 {} 个{},删除 {} 个缓存",
|
||||
nodeModelName, CollUtil.size(jsonArray), dataName,
|
||||
CollUtil.size(cacheAll), dataName,
|
||||
CollUtil.size(models), dataName,
|
||||
size, dataName,
|
||||
delCount);
|
||||
this.refreshCacheStat(nodeModel.getId(), size);
|
||||
log.debug(format);
|
||||
return format;
|
||||
} catch (Exception e) {
|
||||
@ -247,6 +248,16 @@ public abstract class BaseNodeService<T extends BaseNodeModel> extends BaseGloba
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新缓存统计
|
||||
*
|
||||
* @param nodeId 节点id
|
||||
* @param dataCount 数据总数
|
||||
*/
|
||||
protected void refreshCacheStat(String nodeId, int dataCount) {
|
||||
|
||||
}
|
||||
|
||||
protected String checkException(Exception e, String nodeModelName) {
|
||||
if (e instanceof AgentException) {
|
||||
AgentException agentException = (AgentException) e;
|
||||
|
@ -112,4 +112,12 @@ public class ProjectInfoCacheService extends BaseNodeService<ProjectInfoCacheMod
|
||||
public String typeName() {
|
||||
return getTableName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void refreshCacheStat(String nodeId, int dataCount) {
|
||||
NodeModel nodeModel = new NodeModel();
|
||||
nodeModel.setId(nodeId);
|
||||
nodeModel.setJpomProjectCount(dataCount);
|
||||
nodeService.updateById(nodeModel);
|
||||
}
|
||||
}
|
||||
|
@ -79,4 +79,12 @@ public class NodeScriptServer extends BaseNodeService<NodeScriptCacheModel> impl
|
||||
public String typeName() {
|
||||
return getTableName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void refreshCacheStat(String nodeId, int dataCount) {
|
||||
NodeModel nodeModel = new NodeModel();
|
||||
nodeModel.setId(nodeId);
|
||||
nodeModel.setJpomScriptCount(dataCount);
|
||||
nodeService.updateById(nodeModel);
|
||||
}
|
||||
}
|
||||
|
@ -8,3 +8,5 @@ ADD,OUTGIVINGLOG,modeData,String,500,,分发方式数据
|
||||
ADD,OUT_GIVING,mode,String,50,,分发方式
|
||||
ADD,OUT_GIVING,modeData,String,500,,分发方式数据
|
||||
ADD,FILE_RELEASE_TASK_LOG,fileType,TINYINT,,,文件类型
|
||||
ADD,NODE_INFO,jpomProjectCount,Integer,,,jpom项目数,
|
||||
ADD,NODE_INFO,jpomScriptCount,Integer,,,jpom脚本数,
|
||||
|
|
@ -137,19 +137,19 @@
|
||||
<a-tooltip slot="runTime" slot-scope="text, item" placement="topLeft" :title="formatDuration(item.machineNodeData && item.machineNodeData.jpomUptime)">
|
||||
<span>{{ formatDuration(item.machineNodeData && item.machineNodeData.jpomUptime, "", 2) }}</span>
|
||||
</a-tooltip>
|
||||
<template slot="projectCount" slot-scope="text, item">
|
||||
<template slot="jpomProjectCount" slot-scope="text, item">
|
||||
<div v-if="item.machineNodeData && item.machineNodeData.status === 1" @click="syncNode(item)">
|
||||
<a-tooltip placement="topLeft" title="节点中的所有项目数量,点击重新同步节点项目信息">
|
||||
<a-tag>{{ item.machineNodeData.jpomProjectCount }} </a-tag>
|
||||
<a-tooltip placement="topLeft" :title="`节点中的项目数量:${text || 0}/${item.machineNodeData.jpomProjectCount},点击重新同步节点项目信息`">
|
||||
<a-tag>{{ text || 0 }} </a-tag>
|
||||
<a-icon type="sync" />
|
||||
</a-tooltip>
|
||||
</div>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
<template slot="scriptCount" slot-scope="text, item">
|
||||
<template slot="jpomScriptCount" slot-scope="text, item">
|
||||
<div v-if="item.machineNodeData && item.machineNodeData.status === 1" @click="syncNodeScript(item)">
|
||||
<a-tooltip placement="topLeft" title="节点中的所有脚本模版数量,点击重新同步脚本模版信息">
|
||||
<a-tag>{{ item.machineNodeData.jpomScriptCount }} </a-tag>
|
||||
<a-tooltip placement="topLeft" :title="`节点中脚本模版数量:${text || 0}/${item.machineNodeData.jpomScriptCount},点击重新同步脚本模版信息`">
|
||||
<a-tag>{{ text || 0 }} </a-tag>
|
||||
<a-icon type="sync" />
|
||||
</a-tooltip>
|
||||
</div>
|
||||
@ -519,8 +519,8 @@ export default {
|
||||
{ title: "JVM 信息", dataIndex: "jvmInfo", width: 100, ellipsis: true, scopedSlots: { customRender: "jvmInfo" } },
|
||||
// { title: "JVM 剩余内存", dataIndex: "machineNodeData.jvmFreeMemory", ellipsis: true, scopedSlots: { customRender: "freeMemory" } },
|
||||
|
||||
{ title: "项目数", dataIndex: "count", key: "count", width: "90px", scopedSlots: { customRender: "projectCount" } },
|
||||
{ title: "脚本数", dataIndex: "scriptCount", key: "scriptCount", width: "90px", scopedSlots: { customRender: "scriptCount" } },
|
||||
{ title: "项目数", dataIndex: "jpomProjectCount", width: "90px", scopedSlots: { customRender: "jpomProjectCount" } },
|
||||
{ title: "脚本数", dataIndex: "jpomScriptCount", width: "90px", scopedSlots: { customRender: "jpomScriptCount" } },
|
||||
|
||||
{ title: "插件运行", dataIndex: "runTime", width: "100px", key: "runTime", ellipsis: true, scopedSlots: { customRender: "runTime" } },
|
||||
{
|
||||
|
@ -269,10 +269,11 @@ export default {
|
||||
...res.data,
|
||||
type: "edit",
|
||||
};
|
||||
}
|
||||
if (this.data) {
|
||||
// 复制项目
|
||||
this.temp = { ...this.temp, ...this.data, type: "add" };
|
||||
} else {
|
||||
if (this.data) {
|
||||
// 复制项目
|
||||
this.temp = { ...this.temp, ...this.data, type: "add" };
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
@ -159,6 +159,9 @@
|
||||
<a-menu-item v-if="noFileModes.includes(record.runMode)">
|
||||
<a-button size="small" type="primary" @click="handleLogBack(record)">项目日志 </a-button>
|
||||
</a-menu-item>
|
||||
<a-menu-item>
|
||||
<a-button size="small" type="primary" @click="copyItem(record)">复制</a-button>
|
||||
</a-menu-item>
|
||||
<a-menu-item>
|
||||
<a-button size="small" type="danger" @click="handleDelete(record)">逻辑删除</a-button>
|
||||
</a-menu-item>
|
||||
@ -310,6 +313,7 @@
|
||||
this.loadGroupList();
|
||||
}
|
||||
"
|
||||
:data="temp"
|
||||
:nodeId="temp.nodeId"
|
||||
:projectId="temp.id"
|
||||
/>
|
||||
@ -914,6 +918,16 @@ export default {
|
||||
|
||||
this.editProjectVisible = true;
|
||||
},
|
||||
// 复制
|
||||
copyItem(record) {
|
||||
const temp = Object.assign({}, record);
|
||||
delete temp.id;
|
||||
delete temp.createTimeMillis;
|
||||
delete temp.outGivingProject;
|
||||
this.temp = { ...temp, name: temp.name + "副本", id: temp.projectId + "_copy", lib: temp.lib + "_copy" };
|
||||
|
||||
this.editProjectVisible = true;
|
||||
},
|
||||
// 打开编辑
|
||||
openAdd() {
|
||||
this.temp = {
|
||||
|
Loading…
Reference in New Issue
Block a user