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
62a576e8
Commit
62a576e8
authored
May 07, 2023
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加告警统计信息
parent
d579e2c6
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
106 additions
and
12 deletions
+106
-12
device-manager/src/main/java/com/mortals/xhx/common/code/DaySelectEnum.java
.../main/java/com/mortals/xhx/common/code/DaySelectEnum.java
+63
-0
device-manager/src/main/java/com/mortals/xhx/module/device/model/vo/DeviceStatVo.java
.../com/mortals/xhx/module/device/model/vo/DeviceStatVo.java
+2
-0
device-manager/src/main/java/com/mortals/xhx/module/device/model/vo/DeviceVo.java
...java/com/mortals/xhx/module/device/model/vo/DeviceVo.java
+4
-4
device-manager/src/main/java/com/mortals/xhx/module/device/web/DeviceStatController.java
...m/mortals/xhx/module/device/web/DeviceStatController.java
+37
-8
No files found.
device-manager/src/main/java/com/mortals/xhx/common/code/DaySelectEnum.java
0 → 100644
View file @
62a576e8
package
com.mortals.xhx.common.code
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
public
enum
DaySelectEnum
{
今天
(
0
,
"今天"
),
近七天
(
1
,
"近七天"
),
近三十天
(
2
,
"近三十天"
),
今年
(
3
,
"今年"
);
private
Integer
value
;
private
String
desc
;
DaySelectEnum
(
Integer
value
,
String
desc
)
{
this
.
value
=
value
;
this
.
desc
=
desc
;
}
public
Integer
getValue
()
{
return
this
.
value
;
}
public
String
getDesc
()
{
return
this
.
desc
;
}
public
static
DaySelectEnum
getByValue
(
Integer
value
)
{
for
(
DaySelectEnum
alarmLevelEnum
:
DaySelectEnum
.
values
())
{
if
(
alarmLevelEnum
.
getValue
()
==
value
)
{
return
alarmLevelEnum
;
}
}
return
null
;
}
/**
* 获取Map集合
*
* @param eItem 不包含项
* @return
*/
public
static
Map
<
String
,
String
>
getEnumMap
(
Integer
...
eItem
)
{
Map
<
String
,
String
>
resultMap
=
new
LinkedHashMap
<>();
for
(
DaySelectEnum
item
:
DaySelectEnum
.
values
())
{
try
{
boolean
hasE
=
false
;
for
(
Integer
e
:
eItem
)
{
if
(
item
.
getValue
()
==
e
)
{
hasE
=
true
;
break
;
}
}
if
(!
hasE
)
{
resultMap
.
put
(
item
.
getValue
()
+
""
,
item
.
getDesc
());
}
}
catch
(
Exception
ex
)
{
}
}
return
resultMap
;
}
}
\ No newline at end of file
device-manager/src/main/java/com/mortals/xhx/module/device/model/vo/DeviceStatVo.java
View file @
62a576e8
...
...
@@ -45,4 +45,6 @@ public class DeviceStatVo extends BaseEntityLong {
/** 结束 创建时间 */
private
String
createTimeEnd
;
private
Integer
selected
;
}
\ No newline at end of file
device-manager/src/main/java/com/mortals/xhx/module/device/model/vo/DeviceVo.java
View file @
62a576e8
package
com.mortals.xhx.module.device.model.vo
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.databind.annotation.JsonSerialize
;
import
com.mortals.framework.annotation.Excel
;
import
com.mortals.framework.model.BaseEntityLong
;
import
com.mortals.xhx.module.device.model.DeviceEntity
;
import
lombok.Data
;
import
org.apache.poi.ss.usermodel.PictureData
;
import
java.io.ByteArrayOutputStream
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* 设备视图对象
...
...
@@ -61,4 +58,7 @@ public class DeviceVo extends BaseEntityLong {
private
List
<
Integer
>
deviceStatusList
;
}
\ No newline at end of file
device-manager/src/main/java/com/mortals/xhx/module/device/web/DeviceStatController.java
View file @
62a576e8
package
com.mortals.xhx.module.device.web
;
import
cn.hutool.core.date.DateUtil
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.util.DateUtils
;
import
com.mortals.framework.web.BaseCRUDJsonBodyMappingController
;
import
com.mortals.xhx.common.code.DaySelectEnum
;
import
com.mortals.xhx.module.device.model.DeviceQuery
;
import
com.mortals.xhx.module.device.model.DeviceStatEntity
;
import
com.mortals.xhx.module.device.model.DeviceStatQuery
;
...
...
@@ -18,6 +20,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.Map
;
/**
...
...
@@ -34,7 +37,6 @@ public class DeviceStatController extends BaseCRUDJsonBodyMappingController<Devi
private
DeviceService
deviceService
;
public
DeviceStatController
()
{
super
.
setModuleDesc
(
"设备统计"
);
}
...
...
@@ -45,19 +47,46 @@ public class DeviceStatController extends BaseCRUDJsonBodyMappingController<Devi
}
@Override
protected
void
doListBefore
(
DeviceStatEntity
query
,
Map
<
String
,
Object
>
model
,
Context
context
)
throws
AppException
{
super
.
doListBefore
(
query
,
model
,
context
);
if
(!
ObjectUtils
.
isEmpty
(
query
.
getSelected
()))
{
//转换日期
switch
(
DaySelectEnum
.
getByValue
(
query
.
getSelected
()))
{
case
今天:
query
.
setCreateTimeStart
(
DateUtil
.
today
());
break
;
case
近七天:
query
.
setCreateTimeStart
(
DateUtil
.
offsetDay
(
new
Date
(),-
7
).
toDateStr
());
break
;
case
近三十天:
query
.
setCreateTimeStart
(
DateUtil
.
offsetDay
(
new
Date
(),-
30
).
toDateStr
());
break
;
case
今年:
query
.
setCreateTimeStart
(
DateUtil
.
beginOfYear
(
new
Date
()).
toDateStr
());
break
;
default
:
break
;
}
}
}
/**
* 同步当前站点
*/
@PostMapping
(
value
=
"syncDeviceStat"
)
public
Rest
<
Object
>
syncDeviceStat
(
@RequestBody
DeviceQuery
deviceQuery
)
throws
Exception
{
try
{
if
(
ObjectUtils
.
isEmpty
(
deviceQuery
)||
ObjectUtils
.
isEmpty
(
deviceQuery
.
getSiteId
()))
throw
new
AppException
(
"请求站点Id不能为空!"
);
if
(
ObjectUtils
.
isEmpty
(
deviceQuery
)
||
ObjectUtils
.
isEmpty
(
deviceQuery
.
getSiteId
()))
throw
new
AppException
(
"请求站点Id不能为空!"
);
//刷新成功,返回列
//deviceService.deviceStat(deviceQuery.getSiteId(),getContext());
DeviceStatQuery
deviceStatQuery
=
new
DeviceStatQuery
();
Calendar
calendar
=
Calendar
.
getInstance
();
deviceStatQuery
.
setYear
(
calendar
.
get
(
Calendar
.
YEAR
));
deviceStatQuery
.
setMonth
(
calendar
.
get
(
Calendar
.
MONTH
)
+
1
);
deviceStatQuery
.
setMonth
(
calendar
.
get
(
Calendar
.
MONTH
)
+
1
);
deviceStatQuery
.
setDay
(
calendar
.
get
(
Calendar
.
DAY_OF_MONTH
));
deviceStatQuery
.
setSiteId
(
deviceQuery
.
getSiteId
());
Rest
<
Object
>
resp
=
this
.
list
(
deviceStatQuery
);
...
...
@@ -70,12 +99,12 @@ public class DeviceStatController extends BaseCRUDJsonBodyMappingController<Devi
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
DateUtils
.
getThisYear
());
System
.
out
.
println
(
DateUtils
.
getCurrMonth
());
System
.
out
.
println
(
DateUtils
.
getCurrMonth
());
System
.
out
.
println
(
DateUtils
.
getThisYear
());
System
.
out
.
println
(
DateUtils
.
getCurrMonth
());
System
.
out
.
println
(
DateUtils
.
getCurrMonth
());
Calendar
calendar
=
Calendar
.
getInstance
();
System
.
out
.
println
(
calendar
.
get
(
Calendar
.
MONTH
));
System
.
out
.
println
(
calendar
.
get
(
Calendar
.
DAY_OF_MONTH
));
System
.
out
.
println
(
calendar
.
get
(
Calendar
.
MONTH
));
System
.
out
.
println
(
calendar
.
get
(
Calendar
.
DAY_OF_MONTH
));
}
}
\ 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