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
3781ff76
Commit
3781ff76
authored
May 30, 2020
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
回滚
parent
ac06c1dd
Pipeline
#57
failed with stages
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
46 deletions
+65
-46
DevicesController.php
app/Http/Controllers/DevicesController.php
+65
-46
No files found.
app/Http/Controllers/DevicesController.php
View file @
3781ff76
...
...
@@ -125,12 +125,19 @@ class DevicesController extends Controller
public
function
adddevice
(
Request
$request
)
{
//验证用户提交表单
$validator
=
Validator
::
make
(
$request
->
all
(),
$this
->
getValidationRulesdevice
(
false
));
$addDeviceData
=
$request
->
all
();
$validator
=
Validator
::
make
(
$addDeviceData
,
$this
->
getValidationRulesdevice
(
false
));
if
(
$validator
->
fails
())
{
return
response
()
->
json
([
'errors'
=>
$validator
->
errors
()],
403
);
}
foreach
(
$addDeviceData
as
$k
=>
$v
)
{
if
(
$k
==
'isadmin'
)
{
unset
(
$addDeviceData
[
$k
]);
}
}
$type
=
new
Device
();
return
$this
->
jsonSuccessData
(
$type
->
adddevice
(
$request
->
all
()));
return
$this
->
jsonSuccessData
(
$type
->
adddevice
(
$addDeviceData
,
$request
->
input
(
'isadmin'
)
==
1
?
1
:
2
));
}
...
...
@@ -188,7 +195,7 @@ class DevicesController extends Controller
->
leftjoin
(
'gas as g'
,
"device.status"
,
'='
,
'g.id'
)
->
leftjoin
(
'BackgroundUser as u'
,
"device.uid"
,
'='
,
'u.id'
)
->
leftjoin
(
'status as p'
,
"device.devicepolice"
,
'='
,
'p.id'
)
->
select
(
'dy.tname'
,
'g.gas'
,
'device.*'
,
'p.status_name'
,
'u.nickname as usernickname'
)
->
select
(
'dy.tname'
,
'g.gas'
,
'device.*'
,
'p.status_name'
,
'u.nickname as usernickname'
)
->
orderBy
(
'device.id'
,
'desc'
)
->
offset
(
$pagenNum
)
->
limit
(
$limit
)
...
...
@@ -230,7 +237,7 @@ class DevicesController extends Controller
->
leftjoin
(
'gas as g'
,
"device.status"
,
'='
,
'g.id'
)
->
leftjoin
(
'BackgroundUser as u'
,
"device.uid"
,
'='
,
'u.id'
)
->
leftjoin
(
'status as p'
,
"device.devicepolice"
,
'='
,
'p.id'
)
->
select
(
'dy.tname'
,
'g.gas'
,
'device.*'
,
'p.status_name'
,
'u.nickname as usernickname'
)
->
select
(
'dy.tname'
,
'g.gas'
,
'device.*'
,
'p.status_name'
,
'u.nickname as usernickname'
)
->
orderBy
(
'device.id'
,
'desc'
)
->
offset
(
$pagenNum
)
->
limit
(
$limit
)
...
...
@@ -250,7 +257,7 @@ class DevicesController extends Controller
public
function
deviceDataInfo
(
$id
)
{
$devicedata
=
Device
::
where
(
'device.id'
,
'='
,
$id
)
->
leftjoin
(
'contactsuser as c'
,
'c.contactsid'
,
'='
,
'device.
contacts
id'
)
->
leftjoin
(
'contactsuser as c'
,
'c.contactsid'
,
'='
,
'device.id'
)
->
select
(
'c.*'
,
'device.deviceuuid'
,
'device.devicelinkman'
,
'device.devicephone'
,
'device.devicecoord'
)
->
get
();
$devicedatainfo
=
Device
::
where
(
'id'
,
'='
,
$id
)
...
...
@@ -258,17 +265,20 @@ class DevicesController extends Controller
->
get
();
return
$this
->
jsonSuccessData
([
'devicedata'
=>
$devicedata
,
'devicedatainfo'
=>
$devicedatainfo
]);
}
// 返回设备地图详情信息
public
function
device_info
(
$id
){
public
function
device_info
(
$id
)
{
$devicedata
=
Device
::
where
(
'device.id'
,
'='
,
$id
)
->
leftjoin
(
'device_type as dy'
,
"device.dtype"
,
'='
,
'dy.tid'
)
->
leftjoin
(
'gas as g'
,
"device.status"
,
'='
,
'g.id'
)
->
leftjoin
(
'BackgroundUser as u'
,
"device.uid"
,
'='
,
'u.id'
)
->
leftjoin
(
'status as p'
,
"device.devicepolice"
,
'='
,
'p.id'
)
->
select
(
'dy.tname'
,
'g.gas'
,
'device.*'
,
'p.status_name'
,
'u.nickname as usernickname'
)
->
select
(
'dy.tname'
,
'g.gas'
,
'device.*'
,
'p.status_name'
,
'u.nickname as usernickname'
)
->
first
();
return
$this
->
jsonSuccessData
(
$devicedata
);
}
//搜索设备账号
public
function
deviceDataSearch
(
Request
$request
)
{
...
...
@@ -298,21 +308,23 @@ class DevicesController extends Controller
$this
->
devicemkdir
(
$data
);
//写入文件
}
$devicelistopen
=
$this
->
devicelistopen
();
if
(
$devicelistopen
!=
105
)
{
if
(
$devicelistopen
!=
105
)
{
return
$this
->
jsonSuccessData
(
$devicelistopen
);
}
else
{
return
$this
->
jsonErrorData
(
105
,
'暂无数据'
);
}
else
{
return
$this
->
jsonErrorData
(
105
,
'暂无数据'
);
}
}
//历史数据查询
public
function
detedevice
(
Request
$request
){
public
function
detedevice
(
Request
$request
)
{
$dete
=
$request
->
input
(
'dete'
);
$devicetime
=
$this
->
devicetime
(
$dete
);
if
(
$devicetime
!=
105
)
{
if
(
$devicetime
!=
105
)
{
return
$this
->
jsonSuccessData
(
$devicetime
);
}
else
{
return
$this
->
jsonErrorData
(
105
,
'暂无数据'
);
}
else
{
return
$this
->
jsonErrorData
(
105
,
'暂无数据'
);
}
}
...
...
@@ -334,6 +346,11 @@ class DevicesController extends Controller
return
$this
->
jsonSuccessData
(
DB
::
table
(
'device'
)
->
where
(
'delete'
,
'='
,
'1'
)
->
count
());
}
public
function
addUserDevice
()
{
return
$this
->
jsonSuccessData
(
DB
::
table
(
'BackgroundUser'
)
->
where
(
'state'
,
'='
,
'2'
)
->
select
(
'nickname'
,
'id'
)
->
get
());
}
//返回设备废纸篓和禁用设备
public
function
deviceBasketList
()
{
...
...
@@ -384,6 +401,7 @@ class DevicesController extends Controller
//返回用户安装位置
return
$this
->
jsonSuccessData
(
$data
);
}
//返回消防监测
public
function
control
(
Request
$request
)
{
...
...
@@ -393,11 +411,11 @@ class DevicesController extends Controller
if
(
$pagenNum
===
''
||
$limit
==
''
||
$type
===
''
)
{
return
$this
->
jsonErrorData
(
105
,
'页数或limit不能为空'
);
}
if
(
$type
==
1
)
{
//返回消防监测
$wherein
=
[
2
,
4
,
6
,
7
,
8
,
9
,
11
];
}
else
{
if
(
$type
==
1
)
{
//返回消防监测
$wherein
=
[
2
,
4
,
6
,
7
,
8
,
9
,
11
];
}
else
{
//返回危化
$wherein
=
[
1
,
5
,
10
];
$wherein
=
[
1
,
5
,
10
];
}
$databadevice
=
DB
::
table
(
'device'
);
$devicelist
=
$databadevice
...
...
@@ -411,7 +429,7 @@ class DevicesController extends Controller
->
limit
(
$limit
)
->
get
()
->
toArray
();
$count
=
$databadevice
->
whereIn
(
'dtype'
,
$wherein
)
->
whereIn
(
'dtype'
,
$wherein
)
->
count
();
return
$this
->
jsonSuccessData
([
'devicelist'
=>
$devicelist
,
'count'
=>
$count
]);
}
...
...
@@ -435,7 +453,7 @@ class DevicesController extends Controller
'devicecoord'
=>
'sometimes|required'
,
'contactsid'
=>
'sometimes|required'
,
//绑定联系人id
'deviceinfo'
=>
'sometimes|required'
,
'devicenumber'
=>
'required|unique:device,devicenumber|max:40'
'devicenumber'
=>
'
sometimes|
required|unique:device,devicenumber|max:40'
];
}
...
...
@@ -459,8 +477,8 @@ class DevicesController extends Controller
private
function
devicemkdir
(
$data
)
{
$path
=
public_path
()
.
'/device/'
.
date
(
'Y-m-d'
.
'/'
);
if
(
!
is_dir
(
$path
)){
$path
=
public_path
()
.
'/device/'
.
date
(
'Y-m-d'
.
'/'
);
if
(
!
is_dir
(
$path
))
{
mkdir
(
$path
);
}
file_put_contents
(
$path
.
"devicelistdata.text"
,
json_encode
(
$data
)
.
PHP_EOL
,
FILE_APPEND
);
...
...
@@ -468,10 +486,10 @@ class DevicesController extends Controller
$this
->
devicelistopen
(
$path
);
}
private
function
devicelistopen
()
:
array
private
function
devicelistopen
()
:
array
{
$path
=
public_path
()
.
'/device/'
.
date
(
'Y-m-d'
.
'/'
);
if
(
is_file
(
$path
.
'devicelistdata.text'
))
{
$path
=
public_path
()
.
'/device/'
.
date
(
'Y-m-d'
.
'/'
);
if
(
is_file
(
$path
.
'devicelistdata.text'
))
{
$myfile
=
file_get_contents
(
$path
.
'devicelistdata.text'
);
$exp
=
explode
(
"
\n
"
,
$myfile
);
$datadevice
=
[];
...
...
@@ -481,14 +499,15 @@ class DevicesController extends Controller
array_push
(
$datadevice
,
json_decode
(
$newstring1
,
true
));
}
return
$datadevice
;
}
else
{
}
else
{
return
105
;
}
}
private
function
devicetime
(
$dete
)
{
$path
=
public_path
()
.
'/device/'
.
$dete
.
'/'
;
if
(
is_file
(
$path
.
'devicelistdata.text'
))
{
private
function
devicetime
(
$dete
)
{
$path
=
public_path
()
.
'/device/'
.
$dete
.
'/'
;
if
(
is_file
(
$path
.
'devicelistdata.text'
))
{
$myfile
=
file_get_contents
(
$path
.
'devicelistdata.text'
);
$exp
=
explode
(
"
\n
"
,
$myfile
);
$datadevice
=
[];
...
...
@@ -498,7 +517,7 @@ class DevicesController extends Controller
array_push
(
$datadevice
,
json_decode
(
$newstring1
,
true
));
}
return
$datadevice
;
}
else
{
}
else
{
return
105
;
}
}
...
...
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