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
28d4c2f8
Commit
28d4c2f8
authored
Jun 19, 2023
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加设备上线和下线的业务日志记录
parent
6606f2b6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
12 deletions
+30
-12
device-manager/src/main/java/com/mortals/xhx/daemon/task/DeviceTotalStatTaskImpl.java
.../com/mortals/xhx/daemon/task/DeviceTotalStatTaskImpl.java
+4
-8
device-manager/src/main/java/com/mortals/xhx/module/device/service/DeviceStatService.java
.../mortals/xhx/module/device/service/DeviceStatService.java
+6
-0
device-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceStatServiceImpl.java
...xhx/module/device/service/impl/DeviceStatServiceImpl.java
+20
-4
No files found.
device-manager/src/main/java/com/mortals/xhx/daemon/task/DeviceTotalStatTaskImpl.java
View file @
28d4c2f8
...
...
@@ -6,7 +6,6 @@ import com.mortals.framework.service.ITaskExcuteService;
import
com.mortals.xhx.common.code.PlatformTypeEnum
;
import
com.mortals.xhx.common.pdu.site.SitePdu
;
import
com.mortals.xhx.feign.site.ISiteFeign
;
import
com.mortals.xhx.module.device.service.DeviceService
;
import
com.mortals.xhx.module.device.service.DeviceStatService
;
import
com.mortals.xhx.module.site.model.SiteEntity
;
import
com.mortals.xhx.module.site.model.SiteQuery
;
...
...
@@ -28,8 +27,6 @@ import java.util.List;
@Service
(
"DeviceTotalStatTask"
)
public
class
DeviceTotalStatTaskImpl
implements
ITaskExcuteService
{
@Autowired
private
DeviceService
deviceService
;
@Autowired
private
DeviceStatService
deviceStatService
;
...
...
@@ -48,14 +45,13 @@ public class DeviceTotalStatTaskImpl implements ITaskExcuteService {
//统计所有站点
SitePdu
sitePdu
=
new
SitePdu
();
sitePdu
.
setSize
(-
1
);
siteFeign
.
list
(
sitePdu
).
getData
().
getData
().
parallelStream
().
forEach
(
item
->
{
//deviceService.deviceStat(item.getId(), null);
});
List
<
SitePdu
>
siteList
=
siteFeign
.
list
(
sitePdu
).
getData
().
getData
();
for
(
SitePdu
item
:
siteList
)
{
deviceStatService
.
deviceStat
(
item
.
getId
(),
null
);
}
}
else
if
(
platFormType
.
equalsIgnoreCase
(
PlatformTypeEnum
.
STANDALONE
.
getValue
()))
{
List
<
SiteEntity
>
siteEntities
=
siteService
.
find
(
new
SiteQuery
());
for
(
SiteEntity
siteEntity
:
siteEntities
)
{
//判断如果当前节点无设备 则不统计
deviceStatService
.
deviceStat
(
siteEntity
.
getId
(),
null
);
}
...
...
device-manager/src/main/java/com/mortals/xhx/module/device/service/DeviceStatService.java
View file @
28d4c2f8
...
...
@@ -23,6 +23,12 @@ public interface DeviceStatService extends ICRUDService<DeviceStatEntity, Long>
*/
void
deviceStat
(
Long
siteId
,
Context
context
);
/**
* 统计指定天的所有站点报表
* @param context
*/
void
deviceStatByDay
(
String
dateStr
,
Context
context
);
List
<
DeviceStatEntity
>
getBillInfos
(
Long
siteId
,
String
createTimeStart
,
Integer
datePattern
,
PageInfo
pageInfo
,
Context
context
);
}
\ No newline at end of file
device-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceStatServiceImpl.java
View file @
28d4c2f8
package
com.mortals.xhx.module.device.service.impl
;
import
cn.hutool.core.date.DateTime
;
import
cn.hutool.core.date.DateUtil
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.model.Context
;
...
...
@@ -166,21 +168,22 @@ public class DeviceStatServiceImpl extends AbstractCRUDServiceImpl<DeviceStatDao
//获取昨天统计数据
DeviceStatEntity
yesterdayDeviceStat
=
this
.
selectOne
(
new
DeviceStatQuery
()
.
siteId
(
siteId
)
.
year
(
calendar
.
get
(
Calendar
.
YEAR
))
.
month
(
calendar
.
get
(
Calendar
.
MONTH
)
+
1
)
.
day
(
calendar
.
get
(
Calendar
.
DAY_OF_MONTH
)));
.
year
(
DateUtil
.
year
(
new
Date
()
))
.
month
(
DateUtil
.
month
(
new
Date
()
)
+
1
)
.
day
(
DateUtil
.
dayOfMonth
(
new
Date
()
)));
if
(
ObjectUtils
.
isEmpty
(
yesterdayDeviceStat
))
{
yesterdayDeviceStat
=
new
DeviceStatEntity
();
yesterdayDeviceStat
.
initAttrValue
();
yesterdayDeviceStat
.
setSiteId
(
siteId
);
// yesterdayDeviceStat.setYear(DateUtil.year(DateUtil.yesterday()));
yesterdayDeviceStat
.
setYear
(
calendar
.
get
(
Calendar
.
YEAR
));
yesterdayDeviceStat
.
setYear
(
DateUtil
.
year
(
new
Date
()
));
}
try
{
//获取设备总数
List
<
DeviceEntity
>
deviceList
=
deviceService
.
find
(
new
DeviceQuery
().
siteId
(
siteId
));
Integer
deviceTotalCount
=
deviceList
.
size
();
if
(
deviceTotalCount
>
0
)
{
log
.
info
(
"设备总数大于0,可统计"
);
//未激活数量
Long
deviceUnActiveCount
=
deviceList
.
parallelStream
()
.
filter
(
f
->
f
.
getDeviceStatus
()
==
DeviceStatusEnum
.
未激活
.
getValue
())
...
...
@@ -286,6 +289,19 @@ public class DeviceStatServiceImpl extends AbstractCRUDServiceImpl<DeviceStatDao
log
.
error
(
"统计异常"
,
e
);
throw
new
AppException
(
"统计异常!"
);
}
}
@Override
public
void
deviceStatByDay
(
String
dateStr
,
Context
context
)
{
DateTime
dateTime
=
DateUtil
.
parseDate
(
dateStr
);
int
day
=
dateTime
.
dayOfMonth
();
int
month
=
dateTime
.
month
()+
1
;
int
year
=
dateTime
.
year
();
}
}
\ 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