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
75ea2f15
Commit
75ea2f15
authored
Dec 16, 2020
by
冯超鹏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
工单模块 app
parent
90f8e536
Pipeline
#207
failed with stages
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
34 deletions
+46
-34
AlarmOrderController.php
app/Http/Controllers/AlarmOrderController.php
+44
-32
api.php
routes/api.php
+2
-2
No files found.
app/Http/Controllers/AlarmOrderController.php
View file @
75ea2f15
...
...
@@ -19,11 +19,11 @@ class AlarmOrderController extends Controller
*/
public
function
index
(
Request
$request
)
{
if
(
$this
->
isadmin
())
{
$where
=
[];
$limit
=
20
;
$offset
=
$limit
*
(
$request
->
input
(
'page'
)
-
1
);
if
(
$request
->
input
(
'isuser'
)
==
'user'
){
$where
=
[];
$where
[]
=
[
'u.id'
,
'='
,
Auth
::
id
()];
}
$orders
=
AlarmOrder
::
selectRaw
(
'
...
...
@@ -31,7 +31,7 @@ class AlarmOrderController extends Controller
FROM_UNIXTIME(r.endtime) AS end_time,
alarm_order.*,
r.devicenumber, r.concentration, r.location, r.policestatus, r.shutoff_status,
d.devicecoord, d.username,
d.devicecoord, d.username,
t.tname,
u.name, u.phone_number,
s.status_name
'
)
...
...
@@ -39,15 +39,12 @@ class AlarmOrderController extends Controller
->
leftjoin
(
'device AS d'
,
'd.id'
,
'='
,
'alarm_order.device_id'
)
->
leftjoin
(
'users AS u'
,
'alarm_order.user_id'
,
'='
,
'u.id'
)
->
leftjoin
(
'status AS s'
,
's.id'
,
'='
,
'alarm_order.reportpolice_id'
)
->
leftjoin
(
'device_type AS t'
,
'r.policestatus'
,
'='
,
't.tid'
)
->
offset
(
$offset
)
->
where
(
$where
)
->
limit
(
$limit
)
->
get
()
->
toArray
();
return
$this
->
jsonSuccessData
(
$orders
);
}
else
{
return
$this
->
jsonErrorData
(
500
,
'没有权限,请联系管理员'
);
}
}
...
...
@@ -101,13 +98,28 @@ class AlarmOrderController extends Controller
* @param int $id
* @return \Illuminate\Http\Response
*/
public
function
show
(
$id
)
public
function
show
(
Request
$request
)
{
$order
=
AlarmOrder
::
select
(
'*'
)
->
join
(
'reportpolice AS r'
,
'r.id'
,
'='
,
'alarm_order.reportpolice_id'
)
->
where
(
'alarm_order.id'
,
'='
,
$id
)
->
get
();
$this
->
jsonSuccessData
(
$order
);
$order
=
AlarmOrder
::
leftjoin
(
'reportpolice AS r'
,
'r.id'
,
'='
,
'alarm_order.reportpolice_id'
)
->
leftjoin
(
'device AS d'
,
'd.id'
,
'='
,
'alarm_order.device_id'
)
->
leftjoin
(
'users AS u'
,
'alarm_order.user_id'
,
'='
,
'u.id'
)
->
leftjoin
(
'status AS s'
,
's.id'
,
'='
,
'alarm_order.reportpolice_id'
)
->
leftjoin
(
'device_type AS t'
,
'r.policestatus'
,
'='
,
't.tid'
)
->
leftjoin
(
'gas AS g'
,
'd.status'
,
'='
,
'g.id'
)
->
leftjoin
(
'danwei AS w'
,
'd.devicemonad'
,
'='
,
'w.id'
)
->
where
(
'alarm_order.id'
,
'='
,
$request
->
input
(
'id'
))
->
selectRaw
(
'
FROM_UNIXTIME(r.starttime) AS start_time,
FROM_UNIXTIME(r.endtime) AS end_time,
alarm_order.*,
r.devicenumber, r.concentration, r.location, r.policestatus, r.shutoff_status,
d.devicecoord, d.username,t.tname,d.deviceinfo,g.gas,w.danwei,
u.name, u.phone_number,
s.status_name
'
)
->
first
();
return
$this
->
jsonSuccessData
(
$order
);
}
/**
...
...
@@ -117,7 +129,7 @@ class AlarmOrderController extends Controller
* @param int $id
* @return \Illuminate\Http\Response
*/
public
function
update
(
Request
$request
,
$id
)
public
function
update
(
Request
$request
)
{
$data
=
$request
->
all
();
...
...
@@ -126,9 +138,9 @@ class AlarmOrderController extends Controller
try
{
AlarmOrderSchedule
::
insert
(
array_merge
(
$data
[
'schedule'
],
[
'created_at'
=>
Carbon
::
now
(),
'alarm_order_id'
=>
$
id
]));
[
'created_at'
=>
Carbon
::
now
(),
'alarm_order_id'
=>
$
data
[
'id'
]
]));
unset
(
$data
[
'schedule'
]);
$order
=
AlarmOrder
::
where
(
'id'
,
$
id
)
$order
=
AlarmOrder
::
where
(
'id'
,
$
data
[
'id'
]
)
->
update
(
array_merge
(
$data
,
[
'updated_at'
=>
Carbon
::
now
()]));
DB
::
commit
();
}
catch
(
QueryException
$exception
)
{
...
...
@@ -137,7 +149,7 @@ class AlarmOrderController extends Controller
}
}
else
{
$order
=
AlarmOrder
::
where
(
'id'
,
$
id
)
$order
=
AlarmOrder
::
where
(
'id'
,
$
data
[
'id'
]
)
->
update
(
array_merge
(
$data
,
[
'updated_at'
=>
Carbon
::
now
()]));
}
if
(
$order
)
{
...
...
routes/api.php
View file @
75ea2f15
...
...
@@ -51,9 +51,9 @@ Route::group(['middleware' => 'auth:api'], function () {
// 报警工单
Route
::
get
(
'alarm_order'
,
'AlarmOrderController@index'
);
// 工单列表
Route
::
post
(
'alarm_order'
,
'AlarmOrderController@store'
);
// 创建工单
Route
::
p
atch
(
'alarm_order/{id}
'
,
'AlarmOrderController@update'
);
// 修改工单
Route
::
p
ost
(
'alarm_order/order_ok
'
,
'AlarmOrderController@update'
);
// 修改工单
Route
::
delete
(
'alarm_order/{id}'
,
'AlarmOrderController@destroy'
);
// 删除工单
Route
::
get
(
'alarm_order/show
/{id}
'
,
'AlarmOrderController@show'
);
// 工单详情
Route
::
get
(
'alarm_order/show'
,
'AlarmOrderController@show'
);
// 工单详情
});
//上传图片路由
...
...
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