Commit 4f08c6c2 by HlQ

[add]

1.添加广场进出客流差异异常指标
2.同步 agent 上 mall 的设备数量
1 parent 644cce09
......@@ -60,6 +60,9 @@ public class MqttClientMessageListener {
break;
// endregion
// region mall 事件
case MALL_INOUT_DIFF:
handleMallInoutDiff(jsonObj.toString());
break;
// endregion
default:
log.info("未定义的消息类型:{}, payload:{}", type, jsonObj);
......@@ -125,6 +128,7 @@ public class MqttClientMessageListener {
recordService.save(eventRecord);
}
// region store 事件
/**
* 门店人数波动异常
*
......@@ -134,5 +138,18 @@ public class MqttClientMessageListener {
EventRecord eventRecord = JsonUtil.parseObject(payloadStr, EventRecord.class);
recordService.save(eventRecord);
}
// endregion
// region mall 事件
/**
* 广场进出客流差异异常
*
* @param payloadStr 事件记录
*/
private void handleMallInoutDiff(String payloadStr) {
EventRecord eventRecord = JsonUtil.parseObject(payloadStr, EventRecord.class);
recordService.save(eventRecord);
}
// endregion
}
......@@ -32,7 +32,7 @@ public class MAccount extends BaseDTO {
/**
* 集团uid
*/
@TableField(value = "\"uid\"")
@TableField(value = "uid")
private String uid;
/**
......
......@@ -73,6 +73,12 @@ public class Mall {
private String timeZone;
/**
* 设备数量
*/
@TableField(value = "device_num")
private Integer deviceNum;
/**
* 备注
*/
@TableField(value = "remark")
......
......@@ -34,6 +34,7 @@ import vion.vo.monitor.AgentVO;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
......@@ -50,7 +51,6 @@ public class AgentServiceImpl extends MPJBaseServiceImpl<AgentMapper, Agent> imp
private final IServiceInfoService serviceInfoService;
private final IServiceRecordService serviceRecordService;
private final IRAgentServiceService rAgentServiceService;
private final IRAgentEventService irAgentEventService;
private final IUpgradeService upgradeService;
private final Converter converter;
private final MqttClientTemplate client;
......@@ -65,9 +65,9 @@ public class AgentServiceImpl extends MPJBaseServiceImpl<AgentMapper, Agent> imp
.selectAll(Agent.class)
.orderByAsc(Agent::getCreateTime);
var agentVOPage = this.selectJoinListPage(Page.of(dto.getPageNum(), dto.getPageSize()), AgentVO.class, wrapper);
Opt.ofEmptyAble(agentVOPage.getRecords())
.ifPresent(r -> {
var agentUidList = r.stream().map(AgentVO::getUid).toList();
if (CollUtil.isNotEmpty(agentVOPage.getRecords())) {
var records = agentVOPage.getRecords();
var agentUidList = records.stream().map(AgentVO::getUid).toList();
// 查询服务器信息
var agentRecWrapper = Wrappers.<AgentRecord>query()
.select("DISTINCT on (agent_uid) *")
......@@ -75,7 +75,7 @@ public class AgentServiceImpl extends MPJBaseServiceImpl<AgentMapper, Agent> imp
.orderByDesc("agent_uid", "create_time");
var agentRecordList = agentRecordService.list(agentRecWrapper);
var uid2AgentRecMap = agentRecordList.stream().collect(Collectors.toMap(AgentRecord::getAgentUid, Function.identity()));
r.forEach(a -> a.setAgentRecord(uid2AgentRecMap.get(a.getUid())));
records.forEach(a -> a.setAgentRecord(uid2AgentRecMap.get(a.getUid())));
// 查询异常服务的名称
var serviceRecordWrapper = new MPJLambdaWrapper<ServiceRecord>()
......@@ -85,9 +85,20 @@ public class AgentServiceImpl extends MPJBaseServiceImpl<AgentMapper, Agent> imp
.in(ServiceRecord::getAgentUid, agentUidList)
.orderByDesc(ServiceRecord::getAgentUid, ServiceRecord::getServiceUid, ServiceRecord::getMonitorTime);
var serviceRecordList = serviceRecordService.selectJoinList(ServiceRecord.class, serviceRecordWrapper);
var serviceNameMap = serviceRecordList.stream().collect(Collectors.groupingBy(ServiceRecord::getAgentUid, Collectors.mapping(ServiceRecord::getName, Collectors.joining(","))));
r.forEach(a -> a.setServiceName(serviceNameMap.get(a.getUid())));
});
var agentUid2ServiceRecMap = serviceRecordList.stream().collect(Collectors.groupingBy(ServiceRecord::getAgentUid));
var errorNameMap = agentUid2ServiceRecMap
.entrySet()
.stream()
.collect(Collectors.toMap(
Map.Entry::getKey,
entry -> entry.getValue().stream()
.map(rec -> (rec.getStatus() != 200 || rec.getBodyStatus() != 200 || rec.getResponseTime() > 1000L) ? rec.getName() : "")
.filter(StrUtil::isNotBlank)
.collect(Collectors.joining(","))
));
records.forEach(a -> a.setServiceName(errorNameMap.get(a.getUid())));
}
return agentVOPage;
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!