Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
device-new-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
device-new-platform
Commits
2418c3c5
Commit
2418c3c5
authored
Jul 22, 2022
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加手动刷新
parent
842a2233
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
305 additions
and
66 deletions
+305
-66
device-manager-ui/admin/src/views/Home.vue
device-manager-ui/admin/src/views/Home.vue
+118
-44
device-manager/src/main/java/com/mortals/xhx/daemon/task/DeviceTotalStatTaskImpl.java
.../com/mortals/xhx/daemon/task/DeviceTotalStatTaskImpl.java
+2
-1
device-manager/src/main/java/com/mortals/xhx/module/device/service/DeviceService.java
.../com/mortals/xhx/module/device/service/DeviceService.java
+6
-0
device-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java
...als/xhx/module/device/service/impl/DeviceServiceImpl.java
+128
-7
device-manager/src/main/java/com/mortals/xhx/module/device/web/DeviceStatController.java
...m/mortals/xhx/module/device/web/DeviceStatController.java
+43
-14
device-manager/src/main/java/com/mortals/xhx/module/sitestat/web/SitestatController.java
...m/mortals/xhx/module/sitestat/web/SitestatController.java
+8
-0
No files found.
device-manager-ui/admin/src/views/Home.vue
View file @
2418c3c5
...
@@ -10,11 +10,20 @@
...
@@ -10,11 +10,20 @@
<el-button
type=
"text"
size=
"mini"
<el-button
type=
"text"
size=
"mini"
>
数据更新:
{{
formatterDate
(
statData
.
updateTime
)
}}
</el-button
>
数据更新:
{{
formatterDate
(
statData
.
updateTime
)
}}
</el-button
>
>
<el-button
icon=
"el-icon-refresh"
size=
"mini"
type=
"text"
>
手动刷新
</el-button>
<el-button
icon=
"el-icon-refresh"
size=
"mini"
@
click=
"syncDeviceStat"
type=
"text"
>
手动刷新
</el-button
>
</el-row>
</el-row>
<el-card
style=
"margin-left: 50px; margin-right: 50px; margin-top: 10px"
>
<el-card
style=
"margin-left: 50px; margin-right: 50px; margin-top: 10px"
>
<el-row
:gutter=
"20"
style=
"height:80px;align-items: center;margin-top:10px"
>
<el-row
:gutter=
"20"
style=
"height: 80px; align-items: center; margin-top: 10px"
>
<el-col
:span=
"3"
>
<el-col
:span=
"3"
>
<el-row
type=
"flex"
justify=
"center"
>
<el-row
type=
"flex"
justify=
"center"
>
<span
style=
"font-size: 20px"
<span
style=
"font-size: 20px"
...
@@ -22,8 +31,19 @@
...
@@ -22,8 +31,19 @@
></el-row
></el-row
>
>
<el-row
type=
"flex"
justify=
"center"
>
<el-row
type=
"flex"
justify=
"center"
>
<span
style=
"font-size: 12px;"
<span
style=
"font-size: 12px"
><span
style=
"color:#6182f6"
>
昨日
</span
><span
v-bind:class=
"
{success: statData.deviceAddCount>=0, warn: statData.deviceAddCount
<0
}"
>
{{
statData
.
deviceAddCount
>=
0
?
'
+
'
+
statData
.
deviceAddCount
:
"
-
"
+
statData
.
deviceAddCount
}}
</span></span
><span
style=
"color: #6182f6"
>
昨日
</span
><span
v-bind:class=
"
{
success: statData.deviceAddCount >= 0,
warn: statData.deviceAddCount
<
0
,
}"
>
{{
statData
.
deviceAddCount
>=
0
?
"
+
"
+
statData
.
deviceAddCount
:
"
-
"
+
statData
.
deviceAddCount
}}
</span
></span
></el-row
></el-row
>
>
<el-row
type=
"flex"
justify=
"center"
>
<el-row
type=
"flex"
justify=
"center"
>
...
@@ -39,8 +59,19 @@
...
@@ -39,8 +59,19 @@
></el-row
></el-row
>
>
<el-row
type=
"flex"
justify=
"center"
>
<el-row
type=
"flex"
justify=
"center"
>
<span
style=
"font-size: 12px;"
<span
style=
"font-size: 12px"
><span
style=
"color:#6182f6"
>
昨日
</span
><span
v-bind:class=
"
{success: statData.siteAddCount>=0, warn: statData.siteAddCount
<0
}"
>
{{
statData
.
siteAddCount
>=
0
?
'
+
'
+
statData
.
siteAddCount
:
"
-
"
+
statData
.
siteAddCount
}}
</span></span
><span
style=
"color: #6182f6"
>
昨日
</span
><span
v-bind:class=
"
{
success: statData.siteAddCount >= 0,
warn: statData.siteAddCount
<
0
,
}"
>
{{
statData
.
siteAddCount
>=
0
?
"
+
"
+
statData
.
siteAddCount
:
"
-
"
+
statData
.
siteAddCount
}}
</span
></span
></el-row
></el-row
>
>
<el-row
type=
"flex"
justify=
"center"
>
<el-row
type=
"flex"
justify=
"center"
>
...
@@ -56,9 +87,13 @@
...
@@ -56,9 +87,13 @@
></el-row
></el-row
>
>
<el-row
type=
"flex"
justify=
"center"
>
<el-row
type=
"flex"
justify=
"center"
>
<span
style=
"font-size: 12px;"
<span
style=
"font-size: 12px"
><span
style=
"color:#6182f6"
>
上线率
</span
><span
v-bind:class=
"
{success: statData.deviceOnlineRatio>=0}">
{{
statData
.
deviceOnlineRatio
*
100
}}
%
</span></span
><span
style=
"color: #6182f6"
>
上线率
</span
><span
v-bind:class=
"
{ success: statData.deviceOnlineRatio >= 0 }"
>
{{
statData
.
deviceOnlineRatio
*
100
}}
%
</span
></span
></el-row
></el-row
>
>
<el-row
type=
"flex"
justify=
"center"
>
<el-row
type=
"flex"
justify=
"center"
>
...
@@ -74,8 +109,11 @@
...
@@ -74,8 +109,11 @@
></el-row
></el-row
>
>
<el-row
type=
"flex"
justify=
"center"
>
<el-row
type=
"flex"
justify=
"center"
>
<span
style=
"font-size: 12px;"
<span
style=
"font-size: 12px"
><span
style=
"color:#6182f6"
>
离线率
</span
><span
v-bind:class=
"
{warn: statData.deviceOfflineRatio>=0}">
{{
statData
.
deviceOfflineRatio
*
100
}}
%
</span></span
><span
style=
"color: #6182f6"
>
离线率
</span
><span
v-bind:class=
"
{ warn: statData.deviceOfflineRatio >= 0 }"
>
{{
statData
.
deviceOfflineRatio
*
100
}}
%
</span
></span
></el-row
></el-row
>
>
<el-row
type=
"flex"
justify=
"center"
>
<el-row
type=
"flex"
justify=
"center"
>
...
@@ -90,9 +128,12 @@
...
@@ -90,9 +128,12 @@
><b>
{{
statData
.
deviceStopRatio
}}
</b></span
><b>
{{
statData
.
deviceStopRatio
}}
</b></span
></el-row
></el-row
>
>
<el-row
type=
"flex"
justify=
"center"
>
<el-row
type=
"flex"
justify=
"center"
>
<span
style=
"font-size: 12px;"
<span
style=
"font-size: 12px"
><span
style=
"color:#6182f6"
>
停用率
</span
><span
v-bind:class=
"
{warn: statData.deviceStopRatio>=0}">
{{
statData
.
deviceStopRatio
*
100
}}
%
</span></span
><span
style=
"color: #6182f6"
>
停用率
</span
><span
v-bind:class=
"
{ warn: statData.deviceStopRatio >= 0 }"
>
{{
statData
.
deviceStopRatio
*
100
}}
%
</span
></span
></el-row
></el-row
>
>
<el-row
type=
"flex"
justify=
"center"
>
<el-row
type=
"flex"
justify=
"center"
>
...
@@ -108,8 +149,19 @@
...
@@ -108,8 +149,19 @@
></el-row
></el-row
>
>
<el-row
type=
"flex"
justify=
"center"
>
<el-row
type=
"flex"
justify=
"center"
>
<span
style=
"font-size: 12px;"
<span
style=
"font-size: 12px"
><span
style=
"color:#6182f6"
>
昨日
</span
><span
v-bind:class=
"
{success: statData.alarmAddCount>=0, warn: statData.alarmAddCount
<0
}"
>
{{
statData
.
alarmAddCount
>=
0
?
'
+
'
+
statData
.
alarmAddCount
:
"
-
"
+
statData
.
alarmAddCount
}}
</span></span
><span
style=
"color: #6182f6"
>
昨日
</span
><span
v-bind:class=
"
{
success: statData.alarmAddCount >= 0,
warn: statData.alarmAddCount
<
0
,
}"
>
{{
statData
.
alarmAddCount
>=
0
?
"
+
"
+
statData
.
alarmAddCount
:
"
-
"
+
statData
.
alarmAddCount
}}
</span
></span
></el-row
></el-row
>
>
<el-row
type=
"flex"
justify=
"center"
>
<el-row
type=
"flex"
justify=
"center"
>
...
@@ -118,35 +170,46 @@
...
@@ -118,35 +170,46 @@
>
>
</el-row>
</el-row>
</el-col>
</el-col>
<el-col
:span=
"3"
>
<el-col
:span=
"3"
>
<el-row
type=
"flex"
justify=
"center"
<el-row
type=
"flex"
justify=
"center"
><span
style=
"font-size: 20px"
><span
style=
"font-size: 20px"
><b>
{{
statData
.
pushTotalCount
}}
</b></span
><b>
{{
statData
.
pushTotalCount
}}
</b></span
></el-row
></el-row
>
>
<el-row
type=
"flex"
justify=
"center"
>
<el-row
type=
"flex"
justify=
"center"
>
<span
style=
"font-size: 12px;"
<span
style=
"font-size: 12px"
><span
style=
"color:#6182f6"
>
昨日
</span
><span
v-bind:class=
"
{success: statData.pushAddCount>=0, warn: statData.pushAddCount
<0
}"
>
{{
statData
.
pushAddCount
>=
0
?
'
+
'
+
statData
.
pushAddCount
:
"
-
"
+
statData
.
pushAddCount
}}
</span></span
><span
style=
"color: #6182f6"
>
昨日
</span
><span
v-bind:class=
"
{
success: statData.pushAddCount >= 0,
warn: statData.pushAddCount
<
0
,
}"
>
{{
statData
.
pushAddCount
>=
0
?
"
+
"
+
statData
.
pushAddCount
:
"
-
"
+
statData
.
pushAddCount
}}
</span
></span
></el-row
></el-row
>
>
<el-row
type=
"flex"
justify=
"center"
>
<el-row
type=
"flex"
justify=
"center"
>
<el-button
icon=
"el-icon-data-board"
size=
"mini"
type=
"text"
<el-button
icon=
"el-icon-data-board"
size=
"mini"
type=
"text"
>
今日消息推送
</el-button
>
今日消息推送
</el-button
>
>
</el-row>
</el-row>
</el-col>
</el-col>
<el-col
:span=
"3"
type=
"flex"
style=
"height:
100%"
>
<el-col
:span=
"3"
type=
"flex"
style=
"height:
100%"
>
<el-row
type=
"flex"
style=
"margin-top:6px"
justify=
"center"
<el-row
type=
"flex"
style=
"margin-top: 6px"
justify=
"center"
><span
style=
"font-size: 13px"
><span
style=
"font-size: 13px"
><span
style=
"color:#6182f6"
>
今日下发命令
</span>
><span
style=
"color:
#6182f6"
>
今日下发命令
</span>
<b>
{{
statData
.
uploadMessageTotalCount
}}
</b></span
<b>
{{
statData
.
uploadMessageTotalCount
}}
</b></span
></el-row
></el-row
>
>
<el-row
type=
"flex"
style=
"margin-top:
6px"
justify=
"center"
<el-row
type=
"flex"
style=
"margin-top:
6px"
justify=
"center"
><span
style=
"font-size: 13px"
><span
style=
"font-size: 13px"
><span
style=
"color:#6182f6"
>
今日下发命令
</span>
><span
style=
"color:
#6182f6"
>
今日下发命令
</span>
<b>
{{
statData
.
downloadMessageTotalCount
}}
</b></span
<b>
{{
statData
.
downloadMessageTotalCount
}}
</b></span
></el-row
></el-row
>
>
...
@@ -213,9 +276,7 @@ export default {
...
@@ -213,9 +276,7 @@ export default {
this
.
$post
(
"
/device/stat/list
"
,
query
)
this
.
$post
(
"
/device/stat/list
"
,
query
)
.
then
((
res
)
=>
{
.
then
((
res
)
=>
{
if
(
res
.
code
==
1
)
{
if
(
res
.
code
==
1
)
{
console
.
log
(
"
res
"
,
res
);
this
.
statData
=
res
.
data
.
data
[
0
];
this
.
statData
=
res
.
data
.
data
[
0
];
console
.
log
(
"
statData
"
,
this
.
statData
);
}
}
this
.
loading
=
false
;
this
.
loading
=
false
;
})
})
...
@@ -237,6 +298,20 @@ export default {
...
@@ -237,6 +298,20 @@ export default {
console
.
log
(
"
process
"
,
process
.
env
);
console
.
log
(
"
process
"
,
process
.
env
);
},
},
methods
:
{
methods
:
{
syncDeviceStat
()
{
this
.
$post
(
"
/device/stat/syncDeviceStat
"
,
{})
.
then
((
res
)
=>
{
if
(
res
.
code
==
1
)
{
this
.
statData
=
res
.
data
.
data
[
0
];
}
else
{
this
.
$message
.
error
(
res
.
msg
);
}
})
.
catch
((
error
)
=>
{
this
.
$message
.
error
(
error
.
message
);
});
},
findDeviceTotalStat
(
beforeday
)
{
findDeviceTotalStat
(
beforeday
)
{
let
query
=
{
createTimeStart
:
this
.
formatterDate
(
beforeday
)
};
let
query
=
{
createTimeStart
:
this
.
formatterDate
(
beforeday
)
};
this
.
$post
(
"
/device/stat/list
"
,
query
)
this
.
$post
(
"
/device/stat/list
"
,
query
)
...
@@ -709,26 +784,25 @@ export default {
...
@@ -709,26 +784,25 @@ export default {
</
script
>
</
script
>
<
style
scoped
>
<
style
scoped
>
.success
{
.success
{
color
:
green
color
:
green
;
}
}
.warn
{
.warn
{
color
:
rgb
(
215
,
25
,
25
);
color
:
rgb
(
215
,
25
,
25
);
}
}
.homeIndex
{
.homeIndex
{
display
:
inline-block
;
display
:
inline-block
;
position
:
relative
;
position
:
relative
;
}
}
.homeIndex
::before
{
.homeIndex
::before
{
content
:
''
;
content
:
""
;
position
:
absolute
;
position
:
absolute
;
top
:
0
;
top
:
0
;
left
:
0
;
left
:
0
;
width
:
100%
;
width
:
100%
;
height
:
35%
;
height
:
35%
;
background
:
#1848c8
;
background
:
#1848c8
;
}
}
</
style
>
</
style
>
device-manager/src/main/java/com/mortals/xhx/daemon/task/DeviceTotalStatTaskImpl.java
View file @
2418c3c5
...
@@ -62,7 +62,8 @@ public class DeviceTotalStatTaskImpl implements ITaskExcuteService {
...
@@ -62,7 +62,8 @@ public class DeviceTotalStatTaskImpl implements ITaskExcuteService {
@Override
@Override
public
void
excuteTask
(
ITask
task
)
throws
AppException
{
public
void
excuteTask
(
ITask
task
)
throws
AppException
{
doDeviceStat
();
deviceService
.
deviceStat
(
null
);
//doDeviceStat();
}
}
...
...
device-manager/src/main/java/com/mortals/xhx/module/device/service/DeviceService.java
View file @
2418c3c5
...
@@ -53,6 +53,12 @@ public interface DeviceService extends ICRUDCacheService<DeviceEntity,Long>{
...
@@ -53,6 +53,12 @@ public interface DeviceService extends ICRUDCacheService<DeviceEntity,Long>{
DeviceDao
getDeviceDao
();
DeviceDao
getDeviceDao
();
/**
* 设备统计当天情况
* @param context
*/
void
deviceStat
(
Context
context
);
...
...
device-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java
View file @
2418c3c5
package
com.mortals.xhx.module.device.service.impl
;
package
com.mortals.xhx.module.device.service.impl
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.lang.PatternPool
;
import
cn.hutool.core.lang.PatternPool
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.URLUtil
;
import
cn.hutool.core.util.URLUtil
;
...
@@ -9,18 +10,25 @@ import com.mortals.framework.exception.AppException;
...
@@ -9,18 +10,25 @@ import com.mortals.framework.exception.AppException;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.service.ICacheService
;
import
com.mortals.framework.service.ICacheService
;
import
com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl
;
import
com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl
;
import
com.mortals.framework.util.DateUtils
;
import
com.mortals.xhx.base.system.message.MessageService
;
import
com.mortals.xhx.base.system.message.MessageService
;
import
com.mortals.xhx.busiz.req.DeviceReq
;
import
com.mortals.xhx.busiz.req.DeviceReq
;
import
com.mortals.xhx.busiz.rsp.ApiResp
;
import
com.mortals.xhx.busiz.rsp.ApiResp
;
import
com.mortals.xhx.common.code.*
;
import
com.mortals.xhx.common.code.*
;
import
com.mortals.xhx.common.key.Constant
;
import
com.mortals.xhx.common.key.Constant
;
import
com.mortals.xhx.common.pdu.RespData
;
import
com.mortals.xhx.common.pdu.site.SitePdu
;
import
com.mortals.xhx.common.pdu.site.SitePdu
;
import
com.mortals.xhx.common.utils.BeanUtil
;
import
com.mortals.xhx.common.utils.BeanUtil
;
import
com.mortals.xhx.feign.site.ISiteFeign
;
import
com.mortals.xhx.feign.site.ISiteFeign
;
import
com.mortals.xhx.module.alarm.model.AlarmSmsSendEntity
;
import
com.mortals.xhx.module.alarm.model.AlarmSmsSendQuery
;
import
com.mortals.xhx.module.alarm.service.AlarmSmsSendService
;
import
com.mortals.xhx.module.device.dao.DeviceDao
;
import
com.mortals.xhx.module.device.dao.DeviceDao
;
import
com.mortals.xhx.module.device.model.DeviceEntity
;
import
com.mortals.xhx.module.device.model.*
;
import
com.mortals.xhx.module.device.model.DeviceQuery
;
import
com.mortals.xhx.module.device.service.DeviceAlarmInfoService
;
import
com.mortals.xhx.module.device.service.DeviceLogService
;
import
com.mortals.xhx.module.device.service.DeviceService
;
import
com.mortals.xhx.module.device.service.DeviceService
;
import
com.mortals.xhx.module.device.service.DeviceStatService
;
import
com.mortals.xhx.module.platform.model.PlatformEntity
;
import
com.mortals.xhx.module.platform.model.PlatformEntity
;
import
com.mortals.xhx.module.platform.model.PlatformQuery
;
import
com.mortals.xhx.module.platform.model.PlatformQuery
;
import
com.mortals.xhx.module.platform.service.PlatformService
;
import
com.mortals.xhx.module.platform.service.PlatformService
;
...
@@ -35,7 +43,12 @@ import org.springframework.beans.factory.annotation.Value;
...
@@ -35,7 +43,12 @@ import org.springframework.beans.factory.annotation.Value;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
java.math.BigDecimal
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
static
java
.
math
.
BigDecimal
.
ROUND_HALF_DOWN
;
import
static
java
.
util
.
stream
.
Collectors
.
counting
;
/**
/**
* DeviceService
* DeviceService
...
@@ -56,6 +69,14 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
...
@@ -56,6 +69,14 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
private
DefaultTbCoreConsumerService
consumerService
;
private
DefaultTbCoreConsumerService
consumerService
;
@Autowired
@Autowired
private
ISiteFeign
siteFeign
;
private
ISiteFeign
siteFeign
;
@Autowired
private
DeviceLogService
deviceLogService
;
@Autowired
private
DeviceStatService
deviceStatService
;
@Autowired
private
DeviceAlarmInfoService
deviceAlarmInfoService
;
@Autowired
private
AlarmSmsSendService
alarmSmsSendService
;
@Override
@Override
protected
String
getExtKey
(
DeviceEntity
data
)
{
protected
String
getExtKey
(
DeviceEntity
data
)
{
...
@@ -130,7 +151,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
...
@@ -130,7 +151,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
}
}
@Override
@Override
public
ApiResp
<
String
>
sendDeviceMessage
(
DeviceEntity
deviceEntity
,
TopicPartitionInfo
info
,
TbQueueMsgHeaders
header
,
String
message
,
TbQueueCallback
callback
,
Context
context
)
{
public
ApiResp
<
String
>
sendDeviceMessage
(
DeviceEntity
deviceEntity
,
TopicPartitionInfo
info
,
TbQueueMsgHeaders
header
,
String
message
,
TbQueueCallback
callback
,
Context
context
)
{
ApiResp
<
String
>
resp
=
new
ApiResp
<>();
ApiResp
<
String
>
resp
=
new
ApiResp
<>();
resp
.
setCode
(
ApiRespCodeEnum
.
SUCCESS
.
getValue
());
resp
.
setCode
(
ApiRespCodeEnum
.
SUCCESS
.
getValue
());
resp
.
setMsg
(
ApiRespCodeEnum
.
SUCCESS
.
getLabel
());
resp
.
setMsg
(
ApiRespCodeEnum
.
SUCCESS
.
getLabel
());
...
@@ -145,7 +166,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
...
@@ -145,7 +166,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
deviceQuery
.
setIdList
(
deviceIds
);
deviceQuery
.
setIdList
(
deviceIds
);
List
<
DeviceEntity
>
deviceEntityList
=
this
.
find
(
deviceQuery
);
List
<
DeviceEntity
>
deviceEntityList
=
this
.
find
(
deviceQuery
);
for
(
DeviceEntity
deviceEntity
:
deviceEntityList
)
{
for
(
DeviceEntity
deviceEntity
:
deviceEntityList
)
{
resp
=
sendDeviceMessage
(
deviceEntity
,
info
,
header
,
message
,
null
,
context
);
resp
=
sendDeviceMessage
(
deviceEntity
,
info
,
header
,
message
,
null
,
context
);
}
}
return
resp
;
return
resp
;
}
}
...
@@ -206,10 +227,10 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
...
@@ -206,10 +227,10 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
Set
<
TopicPartitionInfo
>
set
=
new
HashSet
<>();
Set
<
TopicPartitionInfo
>
set
=
new
HashSet
<>();
set
.
add
(
topicPartitionInfo
);
set
.
add
(
topicPartitionInfo
);
if
(
status
==
YesNoEnum
.
YES
.
getValue
())
{
if
(
status
==
YesNoEnum
.
YES
.
getValue
())
{
//开启
//开启
consumerService
.
getMainConsumer
().
subscribe
(
set
);
consumerService
.
getMainConsumer
().
subscribe
(
set
);
}
else
{
}
else
{
//关闭
//关闭
consumerService
.
getMainConsumer
().
unsubscribe
(
set
);
consumerService
.
getMainConsumer
().
unsubscribe
(
set
);
}
}
...
@@ -303,6 +324,106 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
...
@@ -303,6 +324,106 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
return
this
.
getDao
();
return
this
.
getDao
();
}
}
@Override
public
void
deviceStat
(
Context
context
)
{
//查询当天统计,如果有 则更新统计结果,否则新增
DeviceStatEntity
deviceStatEntity
=
deviceStatService
.
selectOne
(
new
DeviceStatQuery
()
.
year
(
DateUtil
.
year
(
new
Date
()))
.
month
(
DateUtil
.
month
(
new
Date
())
+
1
)
.
day
(
DateUtil
.
dayOfMonth
(
new
Date
())));
if
(
ObjectUtils
.
isEmpty
(
deviceStatEntity
))
{
deviceStatEntity
=
new
DeviceStatEntity
();
deviceStatEntity
.
initAttrValue
();
deviceStatEntity
.
setCreateTime
(
new
Date
());
deviceStatEntity
.
setYear
(
DateUtil
.
year
(
new
Date
()));
deviceStatEntity
.
setMonth
(
DateUtil
.
month
(
new
Date
())
+
1
);
deviceStatEntity
.
setDay
(
DateUtil
.
dayOfMonth
(
new
Date
()));
}
//获取昨天统计数据
DeviceStatEntity
yesterdayDeviceStat
=
deviceStatService
.
selectOne
(
new
DeviceStatQuery
()
.
year
(
DateUtil
.
year
(
DateUtil
.
yesterday
()))
.
month
(
DateUtil
.
month
(
DateUtil
.
yesterday
())
+
1
)
.
day
(
DateUtil
.
dayOfMonth
(
DateUtil
.
yesterday
())));
if
(
ObjectUtils
.
isEmpty
(
yesterdayDeviceStat
))
{
yesterdayDeviceStat
=
new
DeviceStatEntity
();
yesterdayDeviceStat
.
initAttrValue
();
}
try
{
//获取设备总数
List
<
DeviceEntity
>
deviceList
=
this
.
find
(
new
DeviceQuery
());
Integer
deviceTotalCount
=
deviceList
.
size
();
deviceStatEntity
.
setDeviceTotalCount
(
deviceTotalCount
);
deviceStatEntity
.
setDeviceAddCount
(
deviceTotalCount
-
yesterdayDeviceStat
.
getDeviceTotalCount
());
//站点数量
SitePdu
sitePdu
=
new
SitePdu
();
sitePdu
.
setSize
(-
1
);
Rest
<
RespData
<
List
<
SitePdu
>>>
resp
=
siteFeign
.
list
(
sitePdu
);
if
(
resp
.
getCode
()
==
1
)
{
List
<
SitePdu
>
sitePduList
=
resp
.
getData
().
getData
();
deviceStatEntity
.
setSiteTotalCount
(
sitePduList
.
size
());
deviceStatEntity
.
setSiteAddCount
(
sitePduList
.
size
()
-
yesterdayDeviceStat
.
getSiteTotalCount
());
}
//在线数量
Long
deviceOnlineCount
=
deviceList
.
parallelStream
().
filter
(
f
->
f
.
getDeviceStatus
()
==
DeviceStatusEnum
.
在线
.
getValue
()).
count
();
deviceStatEntity
.
setDeviceOnlineCount
(
deviceOnlineCount
.
intValue
());
deviceStatEntity
.
setDeviceOnlineRatio
(
new
BigDecimal
(
deviceOnlineCount
).
divide
(
new
BigDecimal
(
deviceList
.
size
()),
ROUND_HALF_DOWN
).
setScale
(
2
));
//离线数量
Long
deviceOfflineCount
=
deviceList
.
parallelStream
().
filter
(
f
->
f
.
getDeviceStatus
()
==
DeviceStatusEnum
.
离线
.
getValue
()).
count
();
deviceStatEntity
.
setDeviceOfflineCount
(
deviceOfflineCount
.
intValue
());
deviceStatEntity
.
setDeviceOfflineRatio
(
new
BigDecimal
(
deviceOfflineCount
).
divide
(
new
BigDecimal
(
deviceList
.
size
()),
ROUND_HALF_DOWN
).
setScale
(
2
));
//停用数量
Long
deviceStopCount
=
deviceList
.
parallelStream
().
filter
(
f
->
f
.
getEnabled
()
==
YesNoEnum
.
NO
.
getValue
()).
count
();
deviceStatEntity
.
setDeviceStopCount
(
deviceStopCount
.
intValue
());
deviceStatEntity
.
setDeviceStopRatio
(
new
BigDecimal
(
deviceStopCount
).
divide
(
new
BigDecimal
(
deviceList
.
size
()),
ROUND_HALF_DOWN
).
setScale
(
2
));
//今日告警数量
DeviceAlarmInfoQuery
deviceAlarmInfoQuery
=
new
DeviceAlarmInfoQuery
();
deviceAlarmInfoQuery
.
setCreateTimeStart
(
DateUtils
.
getCurrStrDate
());
deviceAlarmInfoQuery
.
setCreateTimeEnd
(
DateUtils
.
getCurrStrDate
());
List
<
DeviceAlarmInfoEntity
>
deviceAlarmInfoList
=
deviceAlarmInfoService
.
find
(
deviceAlarmInfoQuery
);
deviceStatEntity
.
setAlarmTotalCount
(
deviceAlarmInfoList
.
size
());
deviceStatEntity
.
setAlarmAddCount
(
deviceAlarmInfoList
.
size
()
-
yesterdayDeviceStat
.
getAlarmTotalCount
());
//推送数量
AlarmSmsSendQuery
alarmSmsSendQuery
=
new
AlarmSmsSendQuery
();
alarmSmsSendQuery
.
setSendTimeStart
(
DateUtils
.
getCurrStrDate
());
alarmSmsSendQuery
.
setSendTimeEnd
(
DateUtils
.
getCurrStrDate
());
alarmSmsSendQuery
.
setSendStatus
(
SendStatusEnum
.
发送成功
.
getValue
());
List
<
AlarmSmsSendEntity
>
alarmSmsSendEntities
=
alarmSmsSendService
.
find
(
alarmSmsSendQuery
);
deviceStatEntity
.
setPushTotalCount
(
alarmSmsSendEntities
.
size
());
deviceStatEntity
.
setPushAddCount
(
alarmSmsSendEntities
.
size
()
-
yesterdayDeviceStat
.
getPushTotalCount
());
//上行下行数量
DeviceLogQuery
deviceLogQuery
=
new
DeviceLogQuery
();
deviceLogQuery
.
setCreateTimeStart
(
DateUtils
.
getCurrStrDate
());
deviceLogQuery
.
setCreateTimeEnd
(
DateUtils
.
getCurrStrDate
());
Map
<
Boolean
,
Long
>
collect
=
deviceLogService
.
find
(
deviceLogQuery
).
parallelStream
().
collect
(
Collectors
.
partitioningBy
(
x
->
x
.
getLogType
()
==
LogTypeEnum
.
上报事件
.
getValue
(),
counting
()));
deviceStatEntity
.
setUploadMessageTotalCount
(
collect
.
getOrDefault
(
true
,
0L
).
intValue
());
deviceStatEntity
.
setDownloadMessageTotalCount
(
collect
.
getOrDefault
(
false
,
0L
).
intValue
());
if
(
deviceStatEntity
.
newEntity
())
{
deviceStatEntity
.
setCreateTime
(
new
Date
());
deviceStatService
.
save
(
deviceStatEntity
);
}
else
{
deviceStatEntity
.
setUpdateTime
(
new
Date
());
deviceStatService
.
update
(
deviceStatEntity
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
"统计异常"
,
e
);
throw
new
AppException
(
"统计异常!"
);
}
}
@Override
@Override
protected
void
removeBefore
(
Long
[]
ids
,
Context
context
)
throws
AppException
{
protected
void
removeBefore
(
Long
[]
ids
,
Context
context
)
throws
AppException
{
Arrays
.
asList
(
ids
).
stream
().
forEach
(
id
->
{
Arrays
.
asList
(
ids
).
stream
().
forEach
(
id
->
{
...
@@ -366,7 +487,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
...
@@ -366,7 +487,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
DeviceEntity
deviceEntity
=
this
.
selectOne
(
new
DeviceQuery
().
deviceCode
(
entity
.
getDeviceCode
()));
DeviceEntity
deviceEntity
=
this
.
selectOne
(
new
DeviceQuery
().
deviceCode
(
entity
.
getDeviceCode
()));
if
(!
ObjectUtils
.
isEmpty
(
deviceEntity
))
{
if
(!
ObjectUtils
.
isEmpty
(
deviceEntity
))
{
//如果原始的域当前的站点不一致,做更新处理,否则提示编码重复
//如果原始的域当前的站点不一致,做更新处理,否则提示编码重复
if
(!
ObjectUtils
.
isEmpty
(
entity
.
getSiteId
())
&&
entity
.
getSiteId
()
!=
deviceEntity
.
getSiteId
())
{
if
(!
ObjectUtils
.
isEmpty
(
entity
.
getSiteId
())
&&
entity
.
getSiteId
()
!=
deviceEntity
.
getSiteId
())
{
entity
.
setId
(
deviceEntity
.
getId
());
entity
.
setId
(
deviceEntity
.
getId
());
entity
.
setUpdateTime
(
new
Date
());
entity
.
setUpdateTime
(
new
Date
());
entity
.
setUpdateUserId
(
getContextUserId
(
context
));
entity
.
setUpdateUserId
(
getContextUserId
(
context
));
...
...
device-manager/src/main/java/com/mortals/xhx/module/device/web/DeviceStatController.java
View file @
2418c3c5
package
com.mortals.xhx.module.device.web
;
package
com.mortals.xhx.module.device.web
;
import
cn.hutool.core.date.DateUtil
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.web.BaseCRUDJsonBodyMappingController
;
import
com.mortals.framework.web.BaseCRUDJsonBodyMappingController
;
import
com.mortals.xhx.base.system.param.service.ParamService
;
import
com.mortals.xhx.base.system.param.service.ParamService
;
import
com.mortals.xhx.module.device.model.DeviceStatQuery
;
import
com.mortals.xhx.module.device.service.DeviceService
;
import
com.mortals.xhx.module.sitestat.model.SitestatQuery
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.model.Context
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
com.mortals.framework.web.BaseCRUDJsonBodyMappingController
;
import
com.mortals.framework.web.BaseCRUDJsonBodyMappingController
;
import
com.mortals.xhx.module.device.model.DeviceStatEntity
;
import
com.mortals.xhx.module.device.model.DeviceStatEntity
;
import
com.mortals.xhx.module.device.service.DeviceStatService
;
import
com.mortals.xhx.module.device.service.DeviceStatService
;
import
org.apache.commons.lang3.ArrayUtils
;
import
org.apache.commons.lang3.ArrayUtils
;
import
com.mortals.framework.util.StringUtils
;
import
com.mortals.framework.util.StringUtils
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.*
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
java.util.Arrays
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
static
com
.
mortals
.
framework
.
ap
.
SysConstains
.*;
import
static
com
.
mortals
.
framework
.
ap
.
SysConstains
.*;
/**
/**
*
* 设备统计
* 设备统计
*
*
* @author zxfei
* @author zxfei
* @date 2022-07-05
* @date 2022-07-05
*/
*/
@RestController
@RestController
@RequestMapping
(
"device/stat"
)
@RequestMapping
(
"device/stat"
)
public
class
DeviceStatController
extends
BaseCRUDJsonBodyMappingController
<
DeviceStatService
,
DeviceStatEntity
,
Long
>
{
public
class
DeviceStatController
extends
BaseCRUDJsonBodyMappingController
<
DeviceStatService
,
DeviceStatEntity
,
Long
>
{
@Autowired
@Autowired
private
ParamService
param
Service
;
private
DeviceService
device
Service
;
public
DeviceStatController
(){
public
DeviceStatController
()
{
super
.
setModuleDesc
(
"设备统计"
);
super
.
setModuleDesc
(
"设备统计"
);
}
}
@Override
@Override
...
@@ -46,4 +55,24 @@ public class DeviceStatController extends BaseCRUDJsonBodyMappingController<Devi
...
@@ -46,4 +55,24 @@ public class DeviceStatController extends BaseCRUDJsonBodyMappingController<Devi
}
}
/**
* 站点信息
*/
@PostMapping
(
value
=
"syncDeviceStat"
)
public
Rest
<
Object
>
syncDeviceStat
()
{
try
{
//刷新成功,返回列表
deviceService
.
deviceStat
(
getContext
());
DeviceStatQuery
deviceStatQuery
=
new
DeviceStatQuery
();
deviceStatQuery
.
setYear
(
DateUtil
.
year
(
new
Date
()));
deviceStatQuery
.
setMonth
(
DateUtil
.
month
(
new
Date
())
+
1
);
deviceStatQuery
.
setDay
(
DateUtil
.
dayOfMonth
(
new
Date
()));
Rest
<
Object
>
resp
=
this
.
list
(
deviceStatQuery
);
return
resp
;
}
catch
(
Exception
e
)
{
log
.
error
(
"刷新异常"
,
e
);
return
Rest
.
fail
(
KEY_RESULT_CODE
,
super
.
convertException
(
e
));
}
}
}
}
\ No newline at end of file
device-manager/src/main/java/com/mortals/xhx/module/sitestat/web/SitestatController.java
View file @
2418c3c5
...
@@ -14,11 +14,14 @@ import com.mortals.xhx.common.pdu.site.SitePdu;
...
@@ -14,11 +14,14 @@ import com.mortals.xhx.common.pdu.site.SitePdu;
import
com.mortals.xhx.common.pdu.user.UserPdu
;
import
com.mortals.xhx.common.pdu.user.UserPdu
;
import
com.mortals.xhx.feign.site.ISiteFeign
;
import
com.mortals.xhx.feign.site.ISiteFeign
;
import
com.mortals.xhx.feign.user.IUserFeign
;
import
com.mortals.xhx.feign.user.IUserFeign
;
import
com.mortals.xhx.module.device.service.DeviceService
;
import
com.mortals.xhx.module.sitestat.model.SitestatEntity
;
import
com.mortals.xhx.module.sitestat.model.SitestatEntity
;
import
com.mortals.xhx.module.sitestat.model.SitestatQuery
;
import
com.mortals.xhx.module.sitestat.service.SitestatService
;
import
com.mortals.xhx.module.sitestat.service.SitestatService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
...
@@ -39,6 +42,8 @@ public class SitestatController extends BaseCRUDJsonBodyMappingController<Sitest
...
@@ -39,6 +42,8 @@ public class SitestatController extends BaseCRUDJsonBodyMappingController<Sitest
@Autowired
@Autowired
private
IAuthTokenService
authTokenService
;
private
IAuthTokenService
authTokenService
;
@Autowired
private
DeviceService
deviceService
;
@Autowired
@Autowired
...
@@ -148,4 +153,7 @@ public class SitestatController extends BaseCRUDJsonBodyMappingController<Sitest
...
@@ -148,4 +153,7 @@ public class SitestatController extends BaseCRUDJsonBodyMappingController<Sitest
return
jsonObject
.
toJSONString
();
return
jsonObject
.
toJSONString
();
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment