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
dd12f5e1
Commit
dd12f5e1
authored
Jul 23, 2020
by
Administrator
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
ssh://111.61.77.35:15/fengchaopeng/laravelzh
parents
10c28a6b
1c904c2a
Pipeline
#103
canceled with stages
Changes
9
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
133 additions
and
68 deletions
+133
-68
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
DevicesController.php
app/Http/Controllers/DevicesController.php
+46
-18
HomepageController.php
app/Http/Controllers/HomepageController.php
+0
-1
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 @
dd12f5e1
...
...
@@ -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 @
dd12f5e1
...
...
@@ -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 @
dd12f5e1
...
...
@@ -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 @
dd12f5e1
...
...
@@ -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
;
}
}
app/Http/Controllers/DevicesController.php
View file @
dd12f5e1
...
...
@@ -379,10 +379,19 @@ class DevicesController extends Controller
//返回设备当前报警
public
function
police
()
{
$data
=
DB
::
table
(
'reportpolice as r'
)
->
join
(
'status as s'
,
'r.policestatus'
,
'='
,
's.id'
)
->
select
(
'r.*'
,
's.status_name'
)
->
get
();
if
(
!
is_null
(
$this
->
isadmin
()))
{
$data
=
DB
::
table
(
'reportpolice as r'
)
->
join
(
'status as s'
,
'r.policestatus'
,
'='
,
's.id'
)
->
select
(
'r.*'
,
's.status_name'
)
->
get
();
}
else
{
$data
=
DB
::
table
(
'reportpolice as r'
)
->
join
(
'status as s'
,
'r.policestatus'
,
'='
,
's.id'
)
->
join
(
'device as d'
,
'r.devicenumber'
,
'='
,
'd.devicenum'
)
->
where
(
'd.uid'
,
'='
,
Auth
::
id
())
->
select
(
'r.*'
,
's.status_name'
)
->
get
();
}
return
$this
->
jsonSuccessData
(
$data
);
}
...
...
@@ -486,20 +495,39 @@ class DevicesController extends Controller
$wherein
=
[
1
,
5
,
10
];
}
$databadevice
=
DB
::
table
(
'device'
);
$devicelist
=
$databadevice
->
whereIn
(
'dtype'
,
$wherein
)
->
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'
)
->
offset
(
$pagenNum
)
->
limit
(
$limit
)
->
get
()
->
toArray
();
$count
=
$databadevice
->
whereIn
(
'dtype'
,
$wherein
)
->
count
();
if
(
!
is_null
(
$this
->
isadmin
()))
{
$devicelist
=
$databadevice
->
whereIn
(
'dtype'
,
$wherein
)
->
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'
)
->
offset
(
$pagenNum
)
->
limit
(
$limit
)
->
get
()
->
toArray
();
$count
=
$databadevice
->
whereIn
(
'dtype'
,
$wherein
)
->
count
();
}
else
{
$devicelist
=
$databadevice
->
whereIn
(
'dtype'
,
$wherein
)
->
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'
,
'='
,
Auth
::
id
())
->
select
(
'dy.tname'
,
'g.gas'
,
'device.*'
,
'p.status_name'
,
'dw.danwei'
)
->
orderBy
(
'device.id'
,
'desc'
)
->
offset
(
$pagenNum
)
->
limit
(
$limit
)
->
get
()
->
toArray
();
$count
=
$databadevice
->
whereIn
(
'dtype'
,
$wherein
)
->
where
(
'uid'
,
'='
,
Auth
::
id
())
->
count
();
}
return
$this
->
jsonSuccessData
([
'devicelist'
=>
$devicelist
,
'count'
=>
$count
]);
}
public
function
devicepolice
(
Request
$request
)
...
...
app/Http/Controllers/HomepageController.php
View file @
dd12f5e1
...
...
@@ -82,7 +82,6 @@ class HomepageController extends Controller
public
function
userdevicemonthcount
(
Request
$request
)
{
\Session
::
put
([
'loginuid'
=>
Auth
::
id
()]);
dd
(
\Session
::
get
(
'loginuid'
));
$year_start
=
strtotime
(
date
(
"Y"
)
.
"-01-01"
);
// 获取当前的1月份的时间戳
$endThismonth
=
mktime
(
23
,
59
,
59
,
date
(
'm'
),
date
(
't'
),
date
(
'Y'
));
//获取当月的时间戳
$devicedata
=
Device
::
where
(
'uid'
,
'='
,
Auth
::
id
())
->
whereBetween
(
'deviceaddtime'
,
[
$year_start
,
$endThismonth
])
...
...
resources/js/layout/components/TagsView/index.vue
View file @
dd12f5e1
...
...
@@ -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 @
dd12f5e1
...
...
@@ -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 @
dd12f5e1
...
...
@@ -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