Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
L
laravelzh
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
冯超鹏
laravelzh
Commits
e4a86f92
Commit
e4a86f92
authored
Jul 23, 2020
by
冯超鹏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交用户监测问题
parent
9fa83d93
Pipeline
#99
canceled with stages
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
87 additions
and
49 deletions
+87
-49
alarm.php
app/Console/Commands/alarm.php
+1
-1
chemicalswb.php
app/Console/Commands/chemicalswb.php
+2
-7
firewb.php
app/Console/Commands/firewb.php
+2
-7
SwooleCommandController.php
app/Http/Controllers/Auth/SwooleCommandController.php
+70
-29
index.vue
resources/js/layout/components/TagsView/index.vue
+0
-1
chemicals.vue
resources/js/views/monitor/chemicals.vue
+6
-2
fire.vue
resources/js/views/monitor/fire.vue
+6
-2
No files found.
app/Console/Commands/alarm.php
View file @
e4a86f92
...
...
@@ -67,7 +67,7 @@ class alarm extends Command
));
$this
->
ws
->
on
(
'open'
,
function
(
$ws
,
$request
)
{
// //链接成功
$userdata
=
new
SwooleCommandController
();
//
$userdata = new SwooleCommandController();
// $this->ws->push($request->fd,'11',1);
});
...
...
app/Console/Commands/chemicalswb.php
View file @
e4a86f92
...
...
@@ -67,17 +67,12 @@ class chemicalswb extends Command
));
$this
->
ws
->
on
(
'open'
,
function
(
$ws
,
$request
)
{
// //链接成功
$userdata
=
new
SwooleCommandController
();
$this
->
ws
->
push
(
$request
->
fd
,
$userdata
->
chemicals
(),
1
);
swoole_timer_tick
(
6000
,
function
(
$timerId
)
use
(
$ws
,
$request
)
{
$userdata
=
new
SwooleCommandController
();
$this
->
ws
->
push
(
$request
->
fd
,
$userdata
->
chemicals
(),
1
);
});
});
//监听WebSocket消息事件
$this
->
ws
->
on
(
'message'
,
function
(
$ws
,
$frame
)
{
$userdata
=
new
SwooleCommandController
();
$this
->
ws
->
push
(
$frame
->
fd
,
$userdata
->
chemicals
(
$frame
->
data
),
1
);
});
$this
->
ws
->
on
(
'request'
,
function
(
$request
,
$response
,
$from_id
,
$fd
)
{
...
...
app/Console/Commands/firewb.php
View file @
e4a86f92
...
...
@@ -67,17 +67,12 @@ class firewb extends Command
));
$this
->
ws
->
on
(
'open'
,
function
(
$ws
,
$request
)
{
// //链接成功
$userdata
=
new
SwooleCommandController
();
$this
->
ws
->
push
(
$request
->
fd
,
$userdata
->
fire
(),
1
);
swoole_timer_tick
(
6000
,
function
(
$timerId
)
use
(
$ws
,
$request
)
{
$userdata
=
new
SwooleCommandController
();
$this
->
ws
->
push
(
$request
->
fd
,
$userdata
->
fire
(),
1
);
});
});
//监听WebSocket消息事件
$this
->
ws
->
on
(
'message'
,
function
(
$ws
,
$frame
)
{
$userdata
=
new
SwooleCommandController
();
$this
->
ws
->
push
(
$frame
->
fd
,
$userdata
->
fire
(
$frame
->
data
),
1
);
});
$this
->
ws
->
on
(
'request'
,
function
(
$request
,
$response
,
$from_id
,
$fd
)
{
...
...
app/Http/Controllers/Auth/SwooleCommandController.php
View file @
e4a86f92
...
...
@@ -26,39 +26,75 @@ class SwooleCommandController extends Controller
return
$this
->
jsonSuccessData
(
$countdata
);
}
public
function
chemicals
()
public
function
chemicals
(
$id
)
{
$uid
=
$this
->
isadmin
(
$id
);
$databadevice
=
DB
::
table
(
'device'
);
$devicelist
=
$databadevice
->
whereIn
(
'dtype'
,
[
1
,
5
,
10
])
->
leftjoin
(
'device_type as dy'
,
"device.dtype"
,
'='
,
'dy.tid'
)
->
leftjoin
(
'gas as g'
,
"device.status"
,
'='
,
'g.id'
)
->
leftjoin
(
'status as p'
,
"device.devicepolice"
,
'='
,
'p.id'
)
->
leftjoin
(
'danwei as dw'
,
'device.devicemonad'
,
'='
,
'dw.id'
)
->
select
(
'dy.tname'
,
'g.gas'
,
'device.*'
,
'p.status_name'
,
'dw.danwei'
)
->
orderBy
(
'device.id'
,
'desc'
)
->
get
()
->
toArray
();
$count
=
$databadevice
->
whereIn
(
'dtype'
,
[
1
,
5
,
10
])
->
count
();
if
(
$uid
==
1
){
$devicelist
=
$databadevice
->
whereIn
(
'dtype'
,
[
1
,
5
,
10
])
->
leftjoin
(
'device_type as dy'
,
"device.dtype"
,
'='
,
'dy.tid'
)
->
leftjoin
(
'gas as g'
,
"device.status"
,
'='
,
'g.id'
)
->
leftjoin
(
'status as p'
,
"device.devicepolice"
,
'='
,
'p.id'
)
->
leftjoin
(
'danwei as dw'
,
'device.devicemonad'
,
'='
,
'dw.id'
)
->
select
(
'dy.tname'
,
'g.gas'
,
'device.*'
,
'p.status_name'
,
'dw.danwei'
)
->
orderBy
(
'device.id'
,
'desc'
)
->
get
()
->
toArray
();
$count
=
$databadevice
->
whereIn
(
'dtype'
,
[
1
,
5
,
10
])
->
count
();
}
else
{
$devicelist
=
$databadevice
->
whereIn
(
'dtype'
,
[
1
,
5
,
10
])
->
leftjoin
(
'device_type as dy'
,
"device.dtype"
,
'='
,
'dy.tid'
)
->
leftjoin
(
'gas as g'
,
"device.status"
,
'='
,
'g.id'
)
->
leftjoin
(
'status as p'
,
"device.devicepolice"
,
'='
,
'p.id'
)
->
leftjoin
(
'danwei as dw'
,
'device.devicemonad'
,
'='
,
'dw.id'
)
->
where
(
'device.uid'
,
'='
,
$id
)
->
select
(
'dy.tname'
,
'g.gas'
,
'device.*'
,
'p.status_name'
,
'dw.danwei'
)
->
orderBy
(
'device.id'
,
'desc'
)
->
get
()
->
toArray
();
$count
=
$databadevice
->
where
(
'device.uid'
,
'='
,
$id
)
->
whereIn
(
'dtype'
,
[
1
,
5
,
10
])
->
count
();
}
return
$this
->
jsonSuccessData
([
'devicelist'
=>
$devicelist
,
'count'
=>
$count
]);
}
public
function
fire
()
public
function
fire
(
$id
)
{
$uid
=
$this
->
isadmin
(
$id
);
$databadevice
=
DB
::
table
(
'device'
);
$devicelist
=
$databadevice
->
whereIn
(
'dtype'
,
[
2
,
4
,
6
,
7
,
8
,
9
,
11
])
->
leftjoin
(
'device_type as dy'
,
"device.dtype"
,
'='
,
'dy.tid'
)
->
leftjoin
(
'gas as g'
,
"device.status"
,
'='
,
'g.id'
)
->
leftjoin
(
'status as p'
,
"device.devicepolice"
,
'='
,
'p.id'
)
->
leftjoin
(
'danwei as dw'
,
'device.devicemonad'
,
'='
,
'dw.id'
)
->
select
(
'dy.tname'
,
'g.gas'
,
'device.*'
,
'p.status_name'
,
'dw.danwei'
)
->
orderBy
(
'device.id'
,
'desc'
)
->
get
()
->
toArray
();
$count
=
$databadevice
->
whereIn
(
'dtype'
,
[
2
,
4
,
6
,
7
,
8
,
9
,
11
])
->
count
();
if
(
$uid
==
1
){
$devicelist
=
$databadevice
->
whereIn
(
'dtype'
,
[
2
,
4
,
6
,
7
,
8
,
9
,
11
])
->
leftjoin
(
'device_type as dy'
,
"device.dtype"
,
'='
,
'dy.tid'
)
->
leftjoin
(
'gas as g'
,
"device.status"
,
'='
,
'g.id'
)
->
leftjoin
(
'status as p'
,
"device.devicepolice"
,
'='
,
'p.id'
)
->
leftjoin
(
'danwei as dw'
,
'device.devicemonad'
,
'='
,
'dw.id'
)
->
select
(
'dy.tname'
,
'g.gas'
,
'device.*'
,
'p.status_name'
,
'dw.danwei'
)
->
orderBy
(
'device.id'
,
'desc'
)
->
get
()
->
toArray
();
$count
=
$databadevice
->
whereIn
(
'dtype'
,
[
2
,
4
,
6
,
7
,
8
,
9
,
11
])
->
count
();
}
else
{
$devicelist
=
$databadevice
->
whereIn
(
'dtype'
,
[
2
,
4
,
6
,
7
,
8
,
9
,
11
])
->
leftjoin
(
'device_type as dy'
,
"device.dtype"
,
'='
,
'dy.tid'
)
->
leftjoin
(
'gas as g'
,
"device.status"
,
'='
,
'g.id'
)
->
leftjoin
(
'status as p'
,
"device.devicepolice"
,
'='
,
'p.id'
)
->
leftjoin
(
'danwei as dw'
,
'device.devicemonad'
,
'='
,
'dw.id'
)
->
where
(
'device.uid'
,
'='
,
$id
)
->
select
(
'dy.tname'
,
'g.gas'
,
'device.*'
,
'p.status_name'
,
'dw.danwei'
)
->
orderBy
(
'device.id'
,
'desc'
)
->
get
()
->
toArray
();
$count
=
$databadevice
->
where
(
'device.uid'
,
'='
,
$id
)
->
whereIn
(
'dtype'
,
[
2
,
4
,
6
,
7
,
8
,
9
,
11
])
->
count
();
}
return
$this
->
jsonSuccessData
([
'devicelist'
=>
$devicelist
,
'count'
=>
$count
]);
}
...
...
@@ -66,8 +102,8 @@ class SwooleCommandController extends Controller
//监测是否设备报警
public
function
alarm
(
$id
)
{
$
isadmin
=
DB
::
table
(
'users'
)
->
where
(
'id'
,
'='
,
$id
)
->
value
(
'isadmin'
);
if
(
$
isadmin
==
1
)
{
$
uid
=
$this
->
isadmin
(
$id
);
if
(
$
uid
==
1
)
{
$isalarm
=
DB
::
table
(
'reportpolice'
)
->
where
(
'status'
,
'='
,
'1'
)
->
where
(
'police'
,
'='
,
'1'
)
...
...
@@ -79,7 +115,7 @@ class SwooleCommandController extends Controller
->
join
(
'device as d'
,
'reportpolice.devicenumber'
,
'='
,
'd.devicenum'
)
->
where
(
'reportpolice.status'
,
'='
,
'1'
)
->
where
(
'reportpolice.police'
,
'='
,
'1'
)
->
where
(
'd.uid'
,
'='
,
$i
sadmin
)
->
where
(
'd.uid'
,
'='
,
$i
d
)
->
groupBy
(
'reportpolice.id'
)
->
select
(
'reportpolice.devicenumber'
)
->
get
()
->
toArray
();
...
...
@@ -90,4 +126,9 @@ class SwooleCommandController extends Controller
return
$this
->
jsonErrorData
(
105
,
'当前无报警'
);
}
}
public
function
isadmin
(
$id
)
{
$isadmin
=
DB
::
table
(
'users'
)
->
where
(
'id'
,
'='
,
$id
)
->
value
(
'isadmin'
);
return
$isadmin
;
}
}
resources/js/layout/components/TagsView/index.vue
View file @
e4a86f92
...
...
@@ -175,7 +175,6 @@ export default {
this
.
websock
.
onclose
=
this
.
websocketclose
;
}
,
websocketonopen
(){
// 连接建立之后执行send方法发送数据
console
.
log
(
'连接成功'
);
this
.
timer
=
setInterval
(()
=>
{
this
.
websocketsend
();
}
,
5000
);
...
...
resources/js/views/monitor/chemicals.vue
View file @
e4a86f92
...
...
@@ -82,6 +82,7 @@ export default {
type
:
2
,
total
:
0
,
paper
:
undefined
,
timer
:
''
,
}
;
}
,
created
()
{
...
...
@@ -117,7 +118,9 @@ export default {
this
.
websock
.
onclose
=
this
.
websocketclose
;
}
,
websocketonopen
(){
// 连接建立之后执行send方法发送数据
console
.
log
(
'连接成功'
);
this
.
timer
=
setInterval
(()
=>
{
this
.
websocketsend
();
}
,
5000
);
}
,
websocketonerror
(){
// 连接建立失败重连
this
.
$notify
({
...
...
@@ -133,7 +136,7 @@ export default {
this
.
total
=
redata
.
data
.
count
;
}
,
websocketsend
(){
// 数据发送
this
.
websock
.
send
(
JSON
.
stringify
(
this
.
type
));
this
.
websock
.
send
(
localStorage
.
getItem
(
'userinfoid'
));
}
,
websocketclose
(
e
){
// 关闭
console
.
log
(
'断开连接'
,
e
);
...
...
@@ -142,6 +145,7 @@ export default {
message
:
'危化监测长连接已断开'
,
type
:
'warning'
,
}
);
clearInterval
(
this
.
timer
);
}
,
handleClick
(
tab
)
{
this
.
type
=
tab
.
$attrs
.
tid
;
...
...
resources/js/views/monitor/fire.vue
View file @
e4a86f92
...
...
@@ -82,6 +82,7 @@ export default {
type
:
1
,
total
:
0
,
paper
:
undefined
,
timer
:
''
,
}
;
}
,
created
()
{
...
...
@@ -117,7 +118,9 @@ export default {
this
.
websock
.
onclose
=
this
.
websocketclose
;
}
,
websocketonopen
(){
// 连接建立之后执行send方法发送数据
console
.
log
(
'连接成功'
);
this
.
timer
=
setInterval
(()
=>
{
this
.
websocketsend
();
}
,
5000
);
}
,
websocketonerror
(){
// 连接建立失败重连
this
.
$notify
({
...
...
@@ -133,7 +136,7 @@ export default {
this
.
total
=
redata
.
data
.
count
;
}
,
websocketsend
(){
// 数据发送
this
.
websock
.
send
(
JSON
.
stringify
(
this
.
type
));
this
.
websock
.
send
(
localStorage
.
getItem
(
'userinfoid'
));
}
,
websocketclose
(
e
){
// 关闭
console
.
log
(
'断开连接'
,
e
);
...
...
@@ -142,6 +145,7 @@ export default {
message
:
'消防监测长连接已断开'
,
type
:
'warning'
,
}
);
clearInterval
(
this
.
timer
);
}
,
handleClick
(
tab
)
{
this
.
type
=
tab
.
$attrs
.
tid
;
...
...
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