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
7ed4003b
Commit
7ed4003b
authored
4 years ago
by
Administrator
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
ssh://111.61.77.35:15/fengchaopeng/laravelzh
parents
aafdbced
38d9dacc
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
146 additions
and
24 deletions
+146
-24
alarm.php
app/Console/Commands/alarm.php
+3
-6
SwooleCommandController.php
app/Http/Controllers/Auth/SwooleCommandController.php
+5
-7
AuthController.php
app/Http/Controllers/AuthController.php
+1
-2
DevicesController.php
app/Http/Controllers/DevicesController.php
+28
-1
HomepageController.php
app/Http/Controllers/HomepageController.php
+2
-5
device.js
resources/js/api/device.js
+14
-0
Navbar.vue
resources/js/layout/components/Navbar.vue
+1
-0
index.vue
resources/js/layout/components/TagsView/index.vue
+88
-2
user.js
resources/js/store/modules/user.js
+1
-0
index.vue
resources/js/views/login/index.vue
+1
-0
api.php
routes/api.php
+2
-1
No files found.
app/Console/Commands/alarm.php
View file @
7ed4003b
...
...
@@ -68,16 +68,13 @@ class alarm extends Command
$this
->
ws
->
on
(
'open'
,
function
(
$ws
,
$request
)
{
// //链接成功
$userdata
=
new
SwooleCommandController
();
$this
->
ws
->
push
(
$request
->
fd
,
$userdata
->
alarm
(),
1
);
swoole_timer_tick
(
6000
,
function
(
$timerId
)
use
(
$ws
,
$request
)
{
$userdata
=
new
SwooleCommandController
();
$this
->
ws
->
push
(
$request
->
fd
,
$userdata
->
alarm
(),
1
);
});
// $this->ws->push($request->fd,'11',1);
});
//监听WebSocket消息事件
$this
->
ws
->
on
(
'message'
,
function
(
$ws
,
$frame
)
{
$userdata
=
new
SwooleCommandController
();
$this
->
ws
->
push
(
$frame
->
fd
,
$userdata
->
alarm
(
$frame
->
data
),
1
);
});
$this
->
ws
->
on
(
'request'
,
function
(
$request
,
$response
,
$from_id
,
$fd
)
{
...
...
This diff is collapsed.
Click to expand it.
app/Http/Controllers/Auth/SwooleCommandController.php
View file @
7ed4003b
...
...
@@ -62,10 +62,10 @@ class SwooleCommandController extends Controller
//监测是否设备报警
public
function
alarm
()
public
function
alarm
(
$id
)
{
$isadmin
=
DB
::
table
(
'
config'
)
->
first
(
);
if
(
is_null
(
$isadmin
)
)
{
$isadmin
=
DB
::
table
(
'
users'
)
->
where
(
'id'
,
'='
,
$id
)
->
value
(
'isadmin'
);
if
(
$isadmin
==
1
)
{
$isalarm
=
DB
::
table
(
'reportpolice'
)
->
where
(
'status'
,
'='
,
'1'
)
->
where
(
'police'
,
'='
,
'1'
)
...
...
@@ -73,21 +73,19 @@ class SwooleCommandController extends Controller
->
select
(
'devicenumber'
)
->
get
()
->
toArray
();
}
else
{
$uid
=
get_object_vars
(
$isadmin
)[
'uid'
];
$isalarm
=
DB
::
table
(
'reportpolice'
)
->
join
(
'device as d'
,
'reportpolice.devicenumber'
,
'='
,
'd.devicenum'
)
->
where
(
'reportpolice.status'
,
'='
,
'1'
)
->
where
(
'reportpolice.police'
,
'='
,
'1'
)
->
where
(
'd.uid'
,
'='
,
$
uid
)
->
where
(
'd.uid'
,
'='
,
$
isadmin
)
->
groupBy
(
'reportpolice.id'
)
->
select
(
'reportpolice.devicenumber'
)
->
get
()
->
toArray
();
}
if
(
$isalarm
)
{
return
$this
->
jsonSuccessData
(
$isalarm
);
return
$this
->
jsonSuccessData
(
$isalarm
);
}
else
{
return
$this
->
jsonErrorData
(
105
,
'当前无报警'
);
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
app/Http/Controllers/AuthController.php
View file @
7ed4003b
...
...
@@ -73,8 +73,7 @@ class AuthController extends Controller
}
public
function
logout
(
Request
$request
)
{
$config
=
DB
::
table
(
'config'
);
$delectuser
=
$config
->
where
(
'uid'
,
'='
,
Auth
::
id
())
->
delete
();
$delectuser
=
\Session
::
forget
(
'loginuid'
);
if
(
$delectuser
){
$request
->
user
()
->
token
()
->
revoke
();
return
response
()
->
json
((
new
JsonResponse
())
->
success
([]),
Response
::
HTTP_OK
);
...
...
This diff is collapsed.
Click to expand it.
app/Http/Controllers/DevicesController.php
View file @
7ed4003b
...
...
@@ -488,7 +488,34 @@ class DevicesController extends Controller
->
count
();
return
$this
->
jsonSuccessData
([
'devicelist'
=>
$devicelist
,
'count'
=>
$count
]);
}
public
function
devicepolice
(
Request
$request
)
{
$devicenum
=
$request
->
input
(
'devicenum'
);
if
(
$devicenum
)
{
$police
=
DB
::
table
(
'reportpolice'
)
->
where
(
'devicenumber'
,
'='
,
$devicenum
)
->
update
([
'police'
=>
2
]);
$this
->
jsonSuccessData
(
$police
);
}
else
{
return
$this
->
jsonErrorData
(
105
,
'设备编号不能为空'
);
}
}
public
function
devicepoliceinfo
(
Request
$request
){
$devicenum
=
$request
->
input
(
'devicenum'
);
if
(
$devicenum
)
{
$data
=
DB
::
table
(
'device as d'
)
->
join
(
'device_type as t'
,
'd.dtype'
,
'='
,
't.tid'
)
->
join
(
'gas as g'
,
'd.status'
,
'='
,
'g.id'
)
->
join
(
'status as s'
,
'd.devicepolice'
,
'='
,
's.id'
)
->
join
(
'danwei as w'
,
'd.devicemonad'
,
'='
,
'w.id'
)
->
join
(
'users as u'
,
'd.uid'
,
'='
,
'u.id'
)
->
join
(
'reportpolice as r'
,
'd.devicenum'
,
'='
,
'r.devicenumber'
)
->
where
(
'd.devicenum'
,
'='
,
$devicenum
)
->
select
(
'd.devicenum'
,
'd.username'
,
'd.nd'
,
'd.deviceremark'
,
'd.devicecoord'
,
'd.deviceaddtime'
,
'd.devicestatus'
,
't.tname'
,
'g.gas'
,
's.status_name'
,
'w.danwei'
,
'u.name'
,
'u.email'
,
'r.location'
,
'r.concentration'
,
'r.starttime'
)
->
first
();
return
$this
->
jsonSuccessData
(
$data
);
}
else
{
return
$this
->
jsonErrorData
(
105
,
'设备编号不能为空'
);
}
}
/**
* @param bool $isNew
* @return array
...
...
This diff is collapsed.
Click to expand it.
app/Http/Controllers/HomepageController.php
View file @
7ed4003b
...
...
@@ -81,11 +81,8 @@ class HomepageController extends Controller
//返回一年当前月份
public
function
userdevicemonthcount
(
Request
$request
)
{
$config
=
DB
::
table
(
'config'
);
$user
=
$config
->
where
(
'uid'
,
'='
,
Auth
::
id
())
->
first
();
if
(
!
$user
){
$config
->
insertGetId
([
'uid'
=>
Auth
::
id
(),
'userinfo'
=>
Auth
::
user
(),
'upde_time'
=>
time
()]);
}
\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
])
...
...
This diff is collapsed.
Click to expand it.
resources/js/api/device.js
View file @
7ed4003b
...
...
@@ -151,3 +151,17 @@ export function updedata(data) {
data
,
});
}
export
function
devicepolice
(
devicenum
)
{
return
request
({
url
:
'/devices/devicepolice?devicenum='
+
devicenum
,
method
:
'get'
,
});
}
export
function
devicepoliceinfo
(
devicenum
)
{
return
request
({
url
:
'/devices/devicepoliceinfo?devicenum='
+
devicenum
,
method
:
'get'
,
});
}
This diff is collapsed.
Click to expand it.
resources/js/layout/components/Navbar.vue
View file @
7ed4003b
...
...
@@ -80,6 +80,7 @@ export default {
},
async
logout
()
{
await
this
.
$store
.
dispatch
(
'user/logout'
);
localStorage
.
removeItem
(
'userinfoid'
);
this
.
$notify
.
closeAll
();
this
.
$router
.
go
(
0
);
this
.
$router
.
push
(
`/login?redirect=
${
this
.
$route
.
fullPath
}
`
);
...
...
This diff is collapsed.
Click to expand it.
resources/js/layout/components/TagsView/index.vue
View file @
7ed4003b
...
...
@@ -31,6 +31,46 @@
{{
$t
(
'tagsView.closeAll'
)
}}
</li>
</ul>
<el-dialog
title=
"报警详情"
:visible
.
sync=
"dialogTableVisible"
>
<el-form
ref=
"form"
label-width=
"80px"
>
<el-form-item
label=
"设备编号"
>
<span>
{{
gridData
.
devicenum
}}
</span>
</el-form-item>
<el-form-item
label=
"设备名称"
>
<span>
{{
gridData
.
username
}}
</span>
</el-form-item>
<el-form-item
label=
"用户名称"
>
<span>
{{
gridData
.
name
}}
</span>
</el-form-item>
<el-form-item
label=
"用户邮箱"
>
<span>
{{
gridData
.
email
}}
</span>
</el-form-item>
<el-form-item
label=
"设备类型"
>
<span>
{{
gridData
.
tname
}}
</span>
</el-form-item>
<el-form-item
label=
"设备单位浓度"
label-width=
"100px"
>
<span>
{{
gridData
.
gas
}}
/
{{
gridData
.
concentration
}}{{
gridData
.
danwei
}}
</span>
</el-form-item>
<el-form-item
label=
"设备报警开始时间"
label-width=
"130px"
>
<span>
{{
gridData
.
starttime
|
parseTime
(
'{y
}
-{m
}
-{d
}
{h
}
:{i
}
:{s
}
'
)
}}
<
/span
>
<
/el-form-item
>
<
el
-
form
-
item
label
=
"报警位置"
>
<
span
>
{{
gridData
.
location
}}
<
/span
>
<
/el-form-item
>
<
el
-
form
-
item
label
=
"设备坐标"
>
<
span
>
{{
gridData
.
devicecoord
}}
<
/span
>
<
/el-form-item
>
<
el
-
form
-
item
label
=
"设备备注"
>
<
span
>
{{
gridData
.
deviceremark
}}
<
/span
>
<
/el-form-item
>
<
el
-
form
-
item
label
=
"添加时间"
>
<
span
>
{{
gridData
.
deviceaddtime
|
parseTime
(
'{y
}
-{m
}
-{d
}
{h
}
:{i
}
'
)
}}
<
/span
>
<
/el-form-item
>
<
el
-
form
-
item
label
=
"设备报警状态"
label
-
width
=
"100px"
>
<
span
>
{{
gridData
.
status_name
}}
<
/span
>
<
/el-form-item
>
<
/el-form
>
<
/el-dialog
>
<
/div
>
<
/template
>
...
...
@@ -39,14 +79,19 @@ import ScrollPane from './ScrollPane';
import
{
generateTitle
}
from
'@/utils/i18n'
;
import
path
from
'path'
;
import
websocketurl
from
'@/api/configurl'
;
import
{
devicepolice
,
devicepoliceinfo
}
from
'@/api/device'
;
export
default
{
components
:
{
ScrollPane
}
,
data
()
{
return
{
visible
:
false
,
top
:
0
,
tableKey
:
0
,
dialogTableVisible
:
false
,
left
:
0
,
timer
:
''
,
selectedTag
:
{
}
,
gridData
:
[],
affixTags
:
[],
}
;
}
,
...
...
@@ -131,6 +176,9 @@ export default {
}
,
websocketonopen
(){
// 连接建立之后执行send方法发送数据
console
.
log
(
'连接成功'
);
this
.
timer
=
setInterval
(()
=>
{
this
.
websocketsend
();
}
,
5000
);
}
,
websocketonerror
(){
// 连接建立失败重连
this
.
$notify
({
...
...
@@ -141,6 +189,7 @@ export default {
this
.
initWebSocket
();
}
,
websocketonmessage
(
e
){
// 数据接收
const
that
=
this
;
const
redata
=
JSON
.
parse
(
e
.
data
);
if
(
redata
.
code
===
200
)
{
if
(
localStorage
.
getItem
(
'isalam'
)
===
null
||
localStorage
.
getItem
(
'isalam'
)
===
undefined
)
{
// 第一次没有的话
...
...
@@ -153,6 +202,23 @@ export default {
duration
:
0
,
message
:
redata
.
data
[
i
].
devicenumber
+
'正在报警请尽快处理'
,
onClose
:
function
(){
devicepolice
(
redata
.
data
[
i
].
devicenumber
)
.
then
(
response
=>
{
localStorage
.
removeItem
(
'isalam'
);
}
)
.
catch
(
err
=>
{
console
.
log
(
err
);
}
);
}
,
onClick
:
function
(){
devicepoliceinfo
(
redata
.
data
[
i
].
devicenumber
)
.
then
(
response
=>
{
that
.
gridData
=
response
.
data
;
that
.
dialogTableVisible
=
true
;
}
)
.
catch
(
err
=>
{
console
.
log
(
err
);
}
);
}
,
}
);
}
,
3
);
...
...
@@ -167,7 +233,23 @@ export default {
duration
:
0
,
message
:
redata
.
data
[
j
].
devicenumber
+
'正在报警请尽快处理'
,
onClose
:
function
(){
console
.
log
(
redata
.
data
[
j
].
devicenumber
);
devicepolice
(
redata
.
data
[
j
].
devicenumber
)
.
then
(
response
=>
{
localStorage
.
removeItem
(
'isalam'
);
}
)
.
catch
(
err
=>
{
console
.
log
(
err
);
}
);
}
,
onClick
:
function
(){
devicepoliceinfo
(
redata
.
data
[
j
].
devicenumber
)
.
then
(
response
=>
{
that
.
gridData
=
response
.
data
;
that
.
dialogTableVisible
=
true
;
}
)
.
catch
(
err
=>
{
console
.
log
(
err
);
}
);
}
,
}
);
}
,
3
);
...
...
@@ -180,8 +262,11 @@ export default {
beforeun
(
e
)
{
localStorage
.
removeItem
(
'isalam'
);
}
,
closeAlls
()
{
this
.
$notify
.
closeAll
();
}
,
websocketsend
(){
// 数据发送
this
.
websock
.
send
(
JSON
.
stringify
(
this
.
type
));
this
.
websock
.
send
(
localStorage
.
getItem
(
'userinfoid'
));
}
,
websocketclose
(
e
){
// 关闭
console
.
log
(
'断开连接'
,
e
);
...
...
@@ -190,6 +275,7 @@ export default {
message
:
'监测报警长连接已断开'
,
type
:
'warning'
,
}
);
clearInterval
(
this
.
timer
);
}
,
isarray
(
needle
,
arr
)
{
// data长连接返回 adata本地储
var
has
=
false
;
...
...
This diff is collapsed.
Click to expand it.
resources/js/store/modules/user.js
View file @
7ed4003b
...
...
@@ -45,6 +45,7 @@ const actions = {
return
new
Promise
((
resolve
,
reject
)
=>
{
login
({
email
:
email
.
trim
(),
password
:
password
,
userOrAdmin
:
userOrAdmin
})
.
then
(
response
=>
{
localStorage
.
setItem
(
'userinfoid'
,
response
.
id
);
commit
(
'SET_TOKEN'
,
response
.
token
);
setToken
(
response
.
token
);
resolve
();
...
...
This diff is collapsed.
Click to expand it.
resources/js/views/login/index.vue
View file @
7ed4003b
...
...
@@ -210,6 +210,7 @@ export default {
this
.
$store
.
dispatch
(
'user/login'
,
this
.
userloginForm
)
.
then
(()
=>
{
this
.
$router
.
push
({
path
:
'/'
});
localStorage
.
removeItem
(
'isalam'
);
this
.
loading
=
false
;
})
.
catch
(()
=>
{
...
...
This diff is collapsed.
Click to expand it.
routes/api.php
View file @
7ed4003b
...
...
@@ -100,7 +100,8 @@ Route::group(['middleware'=>'auth:api'],function (){
Route
::
get
(
'devices/control'
,
'DevicesController@control'
);
//返回消防监测
Route
::
get
(
'devices/deviceLocation'
,
'DevicesController@deviceLocation'
);
//返回设备安装位置
Route
::
get
(
'devices/device_info/{id}'
,
'DevicesController@device_info'
);
//返回设备地图详情信息
Route
::
get
(
'devices/UseridOrdeviceInfo'
,
'DevicesController@UseridOrdeviceInfo'
);
//用户测试接口
Route
::
get
(
'devices/devicepolice'
,
'DevicesController@devicepolice'
);
//设备消警
Route
::
get
(
'devices/devicepoliceinfo'
,
'DevicesController@devicepoliceinfo'
);
//设备报警弹窗详情
});
//装维中心
...
...
This diff is collapsed.
Click to expand it.
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