Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gassafety
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
耿迪迪
gassafety
Commits
e4063260
Commit
e4063260
authored
Aug 05, 2021
by
耿迪迪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
异常问题修改 gengdidi
parent
c0ee0f4c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
12 deletions
+18
-12
WebSocketController.java
.../zehong/web/controller/websocket/WebSocketController.java
+18
-12
No files found.
gassafety-admin/src/main/java/com/zehong/web/controller/websocket/WebSocketController.java
View file @
e4063260
package
com
.
zehong
.
web
.
controller
.
websocket
;
package
com
.
zehong
.
web
.
controller
.
websocket
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.zehong.system.domain.
TDeviceAlarm
;
import
com.zehong.system.domain.
vo.DeviceAlarmVo
;
import
com.zehong.system.service.ITDeviceAlarmService
;
import
com.zehong.system.service.ITDeviceAlarmService
;
import
com.zehong.system.service.ITDeviceInfoService
;
import
com.zehong.system.service.ITDeviceInfoService
;
import
com.zehong.system.service.ITPipeService
;
import
com.zehong.system.service.ITPipeService
;
import
com.zehong.system.service.WebSocketServer
;
import
com.zehong.system.service.WebSocketServer
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
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.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.List
;
@RestController
@RestController
@RequestMapping
(
"/websocket"
)
@RequestMapping
(
"/websocket"
)
public
class
WebSocketController
{
public
class
WebSocketController
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
WebSocketController
.
class
);
@Autowired
@Autowired
private
WebSocketServer
webSocketServer
;
private
WebSocketServer
webSocketServer
;
...
@@ -34,14 +35,19 @@ public class WebSocketController {
...
@@ -34,14 +35,19 @@ public class WebSocketController {
@GetMapping
(
"/send"
)
@GetMapping
(
"/send"
)
public
void
send
(
int
alarmId
){
public
void
send
(
int
alarmId
){
TDeviceAlarm
alarm
=
itDeviceAlarmService
.
selectTDeviceAlarmById
(
alarmId
);
try
{
JSONObject
json
=
new
JSONObject
();
DeviceAlarmVo
alarm
=
itDeviceAlarmService
.
selectTDeviceAlarmById
(
alarmId
);
json
.
put
(
"alarmInfo"
,
alarm
);
JSONObject
json
=
new
JSONObject
();
if
(
PIPE_TYPE
.
equals
(
alarm
.
getAlarmType
())){
json
.
put
(
"alarmInfo"
,
alarm
);
json
.
put
(
"deviceInfo"
,
itPipeService
.
selectTPipeById
(
alarm
.
getDeviceId
()));
if
(
PIPE_TYPE
.
equals
(
alarm
.
getAlarmType
())){
}
else
{
json
.
put
(
"deviceInfo"
,
itPipeService
.
selectTPipeById
(
alarm
.
getDeviceId
()));
json
.
put
(
"deviceInfo"
,
itDeviceInfoService
.
selectTDeviceInfoById
(
alarm
.
getDeviceId
()));
}
else
{
json
.
put
(
"deviceInfo"
,
itDeviceInfoService
.
selectTDeviceInfoById
(
alarm
.
getDeviceId
()));
}
webSocketServer
.
batchSendMessage
(
alarm
.
toString
());
}
catch
(
Exception
e
)
{
log
.
error
(
"wesocket发送失败!"
);
}
}
webSocketServer
.
batchSendMessage
(
alarm
.
toString
());
}
}
}
}
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