Commit 4f08c6c2 by HlQ

[add]

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