Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
李苗
/
Vion-DevOps
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 4f08c6c2
authored
Nov 06, 2024
by
HlQ
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[add]
1.添加广场进出客流差异异常指标 2.同步 agent 上 mall 的设备数量
1 parent
644cce09
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
24 deletions
src/main/java/vion/event/mqtt/MqttClientMessageListener.java
src/main/java/vion/model/monitor/MAccount.java
src/main/java/vion/model/monitor/Mall.java
src/main/java/vion/service/impl/monitor/AgentServiceImpl.java
src/main/java/vion/event/mqtt/MqttClientMessageListener.java
View file @
4f08c6c
...
...
@@ -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
}
src/main/java/vion/model/monitor/MAccount.java
View file @
4f08c6c
...
...
@@ -32,7 +32,7 @@ public class MAccount extends BaseDTO {
/**
* 集团uid
*/
@TableField
(
value
=
"
\"uid\"
"
)
@TableField
(
value
=
"
uid
"
)
private
String
uid
;
/**
...
...
src/main/java/vion/model/monitor/Mall.java
View file @
4f08c6c
...
...
@@ -73,6 +73,12 @@ public class Mall {
private
String
timeZone
;
/**
* 设备数量
*/
@TableField
(
value
=
"device_num"
)
private
Integer
deviceNum
;
/**
* 备注
*/
@TableField
(
value
=
"remark"
)
...
...
src/main/java/vion/service/impl/monitor/AgentServiceImpl.java
View file @
4f08c6c
...
...
@@ -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,29 +65,40 @@ 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
();
// 查询服务器信息
var
agentRecWrapper
=
Wrappers
.<
AgentRecord
>
query
()
.
select
(
"DISTINCT on (agent_uid) *"
)
.
in
(
"agent_uid"
,
agentUidList
)
.
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
())));
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) *"
)
.
in
(
"agent_uid"
,
agentUidList
)
.
orderByDesc
(
"agent_uid"
,
"create_time"
);
var
agentRecordList
=
agentRecordService
.
list
(
agentRecWrapper
);
var
uid2AgentRecMap
=
agentRecordList
.
stream
().
collect
(
Collectors
.
toMap
(
AgentRecord:
:
getAgentUid
,
Function
.
identity
()));
records
.
forEach
(
a
->
a
.
setAgentRecord
(
uid2AgentRecMap
.
get
(
a
.
getUid
())));
// 查询异常服务的名称
var
serviceRecordWrapper
=
new
MPJLambdaWrapper
<
ServiceRecord
>()
.
select
(
"DISTINCT on (agent_uid, service_uid) t.*"
)
.
selectAs
(
"si"
,
ServiceInfo:
:
getName
,
ServiceRecord:
:
getName
)
.
leftJoin
(
ServiceInfo
.
class
,
"si"
,
ServiceInfo:
:
getUid
,
"t"
,
ServiceRecord:
:
getServiceUid
)
.
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
serviceRecordWrapper
=
new
MPJLambdaWrapper
<
ServiceRecord
>()
.
select
(
"DISTINCT on (agent_uid, service_uid) t.*"
)
.
selectAs
(
"si"
,
ServiceInfo:
:
getName
,
ServiceRecord:
:
getName
)
.
leftJoin
(
ServiceInfo
.
class
,
"si"
,
ServiceInfo:
:
getUid
,
"t"
,
ServiceRecord:
:
getServiceUid
)
.
in
(
ServiceRecord:
:
getAgentUid
,
agentUidList
)
.
orderByDesc
(
ServiceRecord:
:
getAgentUid
,
ServiceRecord:
:
getServiceUid
,
ServiceRecord:
:
getMonitorTime
);
var
serviceRecordList
=
serviceRecordService
.
selectJoinList
(
ServiceRecord
.
class
,
serviceRecordWrapper
);
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
;
}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment