🔨 修改标签查询逻辑.

This commit is contained in:
lijiahangmax
2025-10-07 16:06:00 +08:00
parent 1d5c579e64
commit 963cd0b227
15 changed files with 97 additions and 112 deletions

View File

@@ -48,10 +48,10 @@ public interface HostAgentApi {
/**
* 获取缓存名称
*
* @param agentKeyList agentKeyList
* @param agentKeys agentKeys
* @return nameMap
*/
Map<String, String> getNameCacheByAgentKey(List<String> agentKeyList);
Map<String, String> getNameCacheByAgentKey(List<String> agentKeys);
/**
* 获取缓存名称

View File

@@ -103,11 +103,11 @@ public class HostAgentApiImpl implements HostAgentApi {
}
@Override
public Map<String, String> getNameCacheByAgentKey(List<String> agentKeyList) {
public Map<String, String> getNameCacheByAgentKey(List<String> agentKeys) {
Map<String, String> result = new HashMap<>();
List<String> queryList = new ArrayList<>();
// 查询缓存
for (String agentKey : agentKeyList) {
for (String agentKey : agentKeys) {
HostBaseDTO host = AGENT_HOST_CACHE.get(agentKey);
if (host != null) {
result.put(agentKey, host.getName());

View File

@@ -92,14 +92,14 @@ public interface HostDAO extends IMapper<HostDO> {
/**
* 更新探针信息
*
* @param keys agentKeyList
* @param update update
* @param agentKeys agentKeys
* @param update update
* @return effect
*/
default int updateByAgentKeys(List<String> keys, HostDO update) {
default int updateByAgentKeys(List<String> agentKeys, HostDO update) {
update.setUpdateTime(new Date());
// 更新
return this.update(update, Conditions.in(HostDO::getAgentKey, keys));
return this.update(update, Conditions.in(HostDO::getAgentKey, agentKeys));
}
}

View File

@@ -212,25 +212,25 @@ public class HostAgentEndpointServiceImpl implements HostAgentEndpointService {
/**
* 标记在线状态
*
* @param agentKeyList agentKeyList
* @param status status
* @param agentKeys agentKeys
* @param status status
*/
private void markOnlineStatus(List<String> agentKeyList, AgentOnlineStatusEnum status) {
if (Lists.isEmpty(agentKeyList)) {
private void markOnlineStatus(List<String> agentKeys, AgentOnlineStatusEnum status) {
if (Lists.isEmpty(agentKeys)) {
return;
}
log.info("HostAgentEndpointService mark {}. count: {}, keys: {}", status, agentKeyList.size(), agentKeyList);
log.info("HostAgentEndpointService mark {}. count: {}, keys: {}", status, agentKeys.size(), agentKeys);
// 更新数据
HostDO update = HostDO.builder()
.agentOnlineStatus(status.getValue())
.agentOnlineChangeTime(new Date())
.build();
int effect = hostDAO.updateByAgentKeys(agentKeyList, update);
int effect = hostDAO.updateByAgentKeys(agentKeys, update);
// 更新缓存
agentKeyList.forEach(s -> ONLINE_STATUS_CACHE.put(s, status.getValue()));
agentKeys.forEach(s -> ONLINE_STATUS_CACHE.put(s, status.getValue()));
log.info("HostAgentEndpointService mark {}. effect: {}", status, effect);
// 插入日志
List<HostAgentLogDO> logList = hostDAO.selectIdByAgentKeys(agentKeyList)
List<HostAgentLogDO> logList = hostDAO.selectIdByAgentKeys(agentKeys)
.stream()
.map(s -> {
HostAgentLogDO agentLog = HostAgentLogDO.builder()
@@ -250,7 +250,7 @@ public class HostAgentEndpointServiceImpl implements HostAgentEndpointService {
}
// 发送已下线事件
if (AgentOnlineStatusEnum.OFFLINE.equals(status)) {
SpringHolder.publishEvent(new AgentOfflineEvent(agentKeyList));
SpringHolder.publishEvent(new AgentOfflineEvent(agentKeys));
}
}