Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
self-service
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
廖旭伟
self-service
Commits
cb2a1770
Commit
cb2a1770
authored
Jan 09, 2023
by
廖旭伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
设备列表接口返回值增加设备状态统计数
parent
50ef48a5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
0 deletions
+63
-0
sst-manager/src/main/java/com/mortals/xhx/module/device/web/DeviceController.java
...a/com/mortals/xhx/module/device/web/DeviceController.java
+63
-0
No files found.
sst-manager/src/main/java/com/mortals/xhx/module/device/web/DeviceController.java
View file @
cb2a1770
package
com.mortals.xhx.module.device.web
;
package
com.mortals.xhx.module.device.web
;
import
com.mortals.framework.annotation.UnAuth
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.model.PageInfo
;
import
com.mortals.framework.model.Result
;
import
com.mortals.framework.web.BaseCRUDJsonBodyMappingController
;
import
com.mortals.framework.web.BaseCRUDJsonBodyMappingController
;
import
com.mortals.xhx.module.device.model.DeviceEntity
;
import
com.mortals.xhx.module.device.model.DeviceEntity
;
import
com.mortals.xhx.module.device.service.DeviceService
;
import
com.mortals.xhx.module.device.service.DeviceService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
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
java.util.HashMap
;
import
java.util.Map
;
/**
/**
* 设备
* 设备
*
*
...
@@ -18,5 +28,58 @@ import org.springframework.web.bind.annotation.RestController;
...
@@ -18,5 +28,58 @@ import org.springframework.web.bind.annotation.RestController;
@Slf4j
@Slf4j
public
class
DeviceController
extends
BaseCRUDJsonBodyMappingController
<
DeviceService
,
DeviceEntity
,
Long
>
{
public
class
DeviceController
extends
BaseCRUDJsonBodyMappingController
<
DeviceService
,
DeviceEntity
,
Long
>
{
@Override
@PostMapping
({
"list"
})
@UnAuth
public
Rest
<
Object
>
list
(
@RequestBody
DeviceEntity
query
)
{
Rest
<
Object
>
ret
=
new
Rest
();
Map
<
String
,
Object
>
model
=
new
HashMap
();
Context
context
=
this
.
getContext
();
String
busiDesc
=
"查询"
+
this
.
getModuleDesc
();
int
code
;
try
{
PageInfo
pageInfo
=
this
.
buildPageInfo
(
query
);
this
.
doListBefore
(
query
,
model
,
context
);
Result
<
DeviceEntity
>
result
=
this
.
getService
().
find
(
query
,
pageInfo
,
context
);
model
.
put
(
"data"
,
result
.
getList
());
int
onlineTotal
=
0
;
int
offlineTotal
=
0
;
int
not_active
=
0
;
int
stop_using
=
0
;
for
(
DeviceEntity
deviceEntity:
result
.
getList
()){
if
(
deviceEntity
.
getDeviceStatus
()==
0
){
not_active
++;
}
if
(
deviceEntity
.
getDeviceStatus
()==
1
){
offlineTotal
++;
}
if
(
deviceEntity
.
getDeviceStatus
()==
2
){
onlineTotal
++;
}
if
(
deviceEntity
.
getEnabled
()==
0
){
stop_using
++;
}
}
model
.
put
(
"online"
,
onlineTotal
);
model
.
put
(
"offline"
,
offlineTotal
);
model
.
put
(
"notActive"
,
not_active
);
model
.
put
(
"stopUsing"
,
stop_using
);
model
.
put
(
"pageInfo"
,
result
.
getPageInfo
());
this
.
parsePageInfo
(
model
,
result
.
getPageInfo
());
code
=
this
.
doListAfter
(
query
,
model
,
context
);
model
.
put
(
"message_info"
,
busiDesc
+
"成功"
);
this
.
recordSysLog
(
this
.
request
,
busiDesc
+
" 【成功】"
);
}
catch
(
Exception
var9
)
{
code
=
-
1
;
this
.
doException
(
this
.
request
,
busiDesc
,
model
,
var9
);
}
this
.
init
(
model
,
context
);
ret
.
setCode
(
code
);
ret
.
setData
(
model
);
ret
.
setDict
(
model
.
get
(
"dict"
));
ret
.
setMsg
(
model
.
get
(
"message_info"
)
==
null
?
""
:
model
.
remove
(
"message_info"
).
toString
());
return
ret
;
}
}
}
\ 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