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
b8bbed4a
Commit
b8bbed4a
authored
Dec 15, 2020
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
工单模块
parent
44f4648b
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
295 additions
and
106 deletions
+295
-106
AlarmOrderController.php
app/Http/Controllers/AlarmOrderController.php
+116
-0
Controller.php
app/Http/Controllers/Controller.php
+1
-1
AlarmOrder.php
app/Models/AlarmOrder.php
+28
-0
AlarmOrderSchedule.php
app/Models/AlarmOrderSchedule.php
+10
-0
Reportpolice.php
app/Models/Reportpolice.php
+10
-0
app.php
config/app.php
+1
-1
2020_12_12_151042_create_alarm_order_table.php
...migrations/2020_12_12_151042_create_alarm_order_table.php
+39
-0
2020_12_12_155918_create_alarm_order_schedule_table.php
...s/2020_12_12_155918_create_alarm_order_schedule_table.php
+34
-0
2020_12_12_165838_add_shut_off_to_reportpolice_table.php
.../2020_12_12_165838_add_shut_off_to_reportpolice_table.php
+32
-0
alarms.vue
resources/js/views/history/alarms.vue
+17
-0
api.php
routes/api.php
+7
-104
No files found.
app/Http/Controllers/AlarmOrderController.php
0 → 100644
View file @
b8bbed4a
<?php
namespace
App\Http\Controllers
;
use
Illuminate\Http\Request
;
use
App\Models\AlarmOrder
;
use
Illuminate\Support\Facades\DB
;
use
App\Models\AlarmOrderSchedule
;
class
AlarmOrderController
extends
Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public
function
index
(
Request
$request
)
{
if
(
$this
->
isadmin
())
{
$limit
=
20
;
$offset
=
$limit
*
(
$request
->
input
(
'page'
)
-
1
);
$orders
=
AlarmOrder
::
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'
)
->
leftjoin
(
'reportpolice AS r'
,
'r.id'
,
'='
,
'alarm_order.reportpolice_id'
)
->
offset
(
$offset
)
->
limit
(
$limit
)
->
get
()
->
toArray
();
return
$this
->
jsonSuccessData
(
$orders
);
}
else
{
return
$this
->
jsonErrorData
(
500
,
'没有权限,请联系管理员'
);
}
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public
function
store
(
Request
$request
)
{
$reportpolice_id
=
$request
->
input
(
'reportpolice_id'
);
$orderNum
=
date
(
'YmdHis'
)
.
substr
(
$request
->
input
(
'device_num'
),
-
4
)
.
$request
->
input
(
'policestatus'
)
.
$request
->
input
(
'shutoff_status'
);
$order
=
new
AlarmOrder
();
$insertId
=
$order
->
sharedLock
()
->
insertGetId
([
'order_num'
=>
$orderNum
,
'reportpolice_id'
=>
$reportpolice_id
,
]);
// 进度表新增
$orderSchedule
=
new
AlarmOrderSchedule
();
$orderSchedule
->
lockForUpdate
();
$orderSchedule
->
alarm_order_id
=
$insertId
;
$orderSchedule
->
schedule
=
1
;
$orderSchedule
->
save
();
if
(
$insertId
)
{
return
$this
->
jsonSuccessData
(
'已生成工单!'
);
}
else
{
return
$this
->
jsonErrorData
(
'工单创建失败'
);
}
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public
function
show
(
$id
)
{
$order
=
AlarmOrder
::
select
(
'*'
)
->
join
(
'reportpolice AS r'
,
'r.id'
,
'='
,
'alarm_order.reportpolice_id'
)
->
where
(
'alarm_order.id'
,
'='
,
$id
)
->
get
();
$this
->
jsonSuccessData
(
$order
);
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public
function
update
(
Request
$request
,
$id
)
{
$order
=
AlarmOrder
::
where
(
'id'
,
$id
)
->
update
(
$request
->
all
());
if
(
$order
)
{
$this
->
jsonSuccessData
(
'工单更新成功'
);
}
else
{
$this
->
jsonErrorData
(
500
,
'更新订单失败!'
);
}
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public
function
destroy
(
$id
)
{
$state
=
AlarmOrder
::
destroy
(
$id
);
if
(
$state
)
{
$this
->
jsonSuccessData
(
'删除成功'
);
}
else
{
$this
->
jsonErrorData
(
500
,
'删除工单失败!'
);
}
}
}
app/Http/Controllers/Controller.php
View file @
b8bbed4a
...
@@ -28,7 +28,7 @@ class Controller extends BaseController
...
@@ -28,7 +28,7 @@ class Controller extends BaseController
'msg'
=>
$message
,
'msg'
=>
$message
,
'data'
=>
$data
'data'
=>
$data
];
];
return
json_encode
(
$content
);
return
json_encode
(
$content
,
JSON_UNESCAPED_UNICODE
);
}
}
/**
/**
...
...
app/Models/AlarmOrder.php
0 → 100644
View file @
b8bbed4a
<?php
namespace
App\Models
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Support\Carbon
;
class
AlarmOrder
extends
Model
{
protected
$table
=
'alarm_order'
;
// 获取报警记录
public
function
reportpolices
()
{
return
$this
->
hasOne
(
'Reportpolice'
);
}
public
function
getCreatedAtAttribute
(
$value
)
{
return
Carbon
::
parse
(
$value
)
->
toDateTimeString
();
}
public
function
getUpdatedAtAttribute
(
$value
)
{
return
Carbon
::
parse
(
$value
)
->
toDateTimeString
();
}
}
app/Models/AlarmOrderSchedule.php
0 → 100644
View file @
b8bbed4a
<?php
namespace
App\Models
;
use
Illuminate\Database\Eloquent\Model
;
class
AlarmOrderSchedule
extends
Model
{
protected
$table
=
'alarm_order_schedule'
;
}
app/Models/Reportpolice.php
0 → 100644
View file @
b8bbed4a
<?php
namespace
App\Models
;
use
Illuminate\Database\Eloquent\Model
;
class
Reportpolice
extends
Model
{
//
}
config/app.php
View file @
b8bbed4a
...
@@ -67,7 +67,7 @@ return [
...
@@ -67,7 +67,7 @@ return [
|
|
*/
*/
'timezone'
=>
'
PR
C'
,
'timezone'
=>
'
UT
C'
,
/*
/*
|--------------------------------------------------------------------------
|--------------------------------------------------------------------------
...
...
database/migrations/2020_12_12_151042_create_alarm_order_table.php
0 → 100644
View file @
b8bbed4a
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
class
CreateAlarmOrderTable
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
create
(
'alarm_order'
,
function
(
Blueprint
$table
)
{
$table
->
increments
(
'id'
)
->
comment
(
'主键'
);
$table
->
string
(
'order_num'
,
32
)
->
unique
()
->
comment
(
'工单号'
);
$table
->
integer
(
'user_id'
)
->
comment
(
'用户ID'
);
$table
->
integer
(
'device_id'
)
->
comment
(
'设备ID'
);
$table
->
integer
(
'reportpolice_id'
)
->
comment
(
'报警记录id'
);
$table
->
tinyInteger
(
'is_live'
)
->
comment
(
'1到达现场,2未到达现场'
);
$table
->
tinyInteger
(
'is_verified'
)
->
comment
(
'1属实,2不属实'
);
$table
->
string
(
'content'
)
->
comment
(
'反馈内容'
);
$table
->
tinyInteger
(
'state'
)
->
comment
(
'工单状态,0:进行中, 1完成,2,异常终止。'
);
$table
->
timestamps
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'alarm_order'
);
}
}
database/migrations/2020_12_12_155918_create_alarm_order_schedule_table.php
0 → 100644
View file @
b8bbed4a
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
class
CreateAlarmOrderScheduleTable
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
create
(
'alarm_order_schedule'
,
function
(
Blueprint
$table
)
{
$table
->
increments
(
'id'
);
$table
->
integer
(
'alarm_order_id'
)
->
comment
(
'报警工单ID'
);
$table
->
tinyInteger
(
'schedule'
)
->
comment
(
'进度ID'
);
$table
->
string
(
'content'
)
->
comment
(
'进度详情'
);
$table
->
timestamps
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'alarm_order_schedule'
);
}
}
database/migrations/2020_12_12_165838_add_shut_off_to_reportpolice_table.php
0 → 100644
View file @
b8bbed4a
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
class
AddShutOffToReportpoliceTable
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
table
(
'reportpolice'
,
function
(
Blueprint
$table
)
{
$table
->
tinyInteger
(
'shutoff_status'
)
->
comment
(
'切断装置状态,0初始化状态,1开启,2关闭'
);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
table
(
'reportpolice'
,
function
(
Blueprint
$table
)
{
$table
->
dropColumn
(
'shutoff_status'
);
});
}
}
resources/js/views/history/alarms.vue
View file @
b8bbed4a
...
@@ -31,6 +31,11 @@
...
@@ -31,6 +31,11 @@
<
span
>
{{
scope
.
row
.
status_name
}}
<
/span
>
<
span
>
{{
scope
.
row
.
status_name
}}
<
/span
>
<
/template
>
<
/template
>
<
/el-table-column
>
<
/el-table-column
>
<
el
-
table
-
column
label
=
"切断装置状态"
width
=
"150"
>
<
template
slot
-
scope
=
"scope"
>
<
span
>
{{
shutoffStatus
(
scope
.
row
.
shutoff_status
)
}}
<
/span
>
<
/template
>
<
/el-table-column
>
<
el
-
table
-
column
label
=
"设备状态"
width
=
"155"
>
<
el
-
table
-
column
label
=
"设备状态"
width
=
"155"
>
<
template
slot
-
scope
=
"scope"
>
<
template
slot
-
scope
=
"scope"
>
<
el
-
tag
:
type
=
"scope.row.status==1 ? 'danger' : 'success' "
effect
=
"dark"
>
{{
scope
.
row
.
status
==
1
?
'报警'
:
'正常'
}}
<
/el-tag
>
<
el
-
tag
:
type
=
"scope.row.status==1 ? 'danger' : 'success' "
effect
=
"dark"
>
{{
scope
.
row
.
status
==
1
?
'报警'
:
'正常'
}}
<
/el-tag
>
...
@@ -41,6 +46,11 @@
...
@@ -41,6 +46,11 @@
<
el
-
tag
:
type
=
"scope.row.status==1 ? 'danger' : 'success' "
effect
=
"dark"
>
{{
scope
.
row
.
status
==
1
?
'当前正在报警'
:
'已结束报警'
}}
<
/el-tag
>
<
el
-
tag
:
type
=
"scope.row.status==1 ? 'danger' : 'success' "
effect
=
"dark"
>
{{
scope
.
row
.
status
==
1
?
'当前正在报警'
:
'已结束报警'
}}
<
/el-tag
>
<
/template
>
<
/template
>
<
/el-table-column
>
<
/el-table-column
>
<
el
-
table
-
column
label
=
"操作"
>
<
template
>
<
el
-
button
type
=
"primary"
effect
=
"dark"
>
生成工单
<
/el-button
>
<
/template
>
<
/el-table-column
>
<
/el-table
>
<
/el-table
>
<
el
-
tooltip
placement
=
"top"
content
=
"tooltip"
>
<
el
-
tooltip
placement
=
"top"
content
=
"tooltip"
>
<
back
-
to
-
top
:
custom
-
style
=
"myBackToTopStyle"
:
visibility
-
height
=
"300"
:
back
-
position
=
"50"
transition
-
name
=
"fade"
/>
<
back
-
to
-
top
:
custom
-
style
=
"myBackToTopStyle"
:
visibility
-
height
=
"300"
:
back
-
position
=
"50"
transition
-
name
=
"fade"
/>
...
@@ -73,6 +83,13 @@ export default {
...
@@ -73,6 +83,13 @@ export default {
this
.
police
();
// 列表
this
.
police
();
// 列表
}
,
}
,
methods
:
{
methods
:
{
shutoffStatus
(
id
)
{
const
shutoff
=
[];
shutoff
[
0
]
=
'初始化'
;
shutoff
[
1
]
=
'开启'
;
shutoff
[
2
]
=
'关闭'
;
return
shutoff
[
id
];
}
,
police
()
{
police
()
{
police
()
police
()
.
then
(
response
=>
{
.
then
(
response
=>
{
...
...
routes/api.php
View file @
b8bbed4a
...
@@ -47,6 +47,13 @@ Route::group(['middleware' => 'auth:api'], function () {
...
@@ -47,6 +47,13 @@ Route::group(['middleware' => 'auth:api'], function () {
Route
::
get
(
'user/paperBasketList'
,
'UserController@paperBasketList'
);
//返回废纸篓和用户状态
Route
::
get
(
'user/paperBasketList'
,
'UserController@paperBasketList'
);
//返回废纸篓和用户状态
Route
::
get
(
'user/userLocation'
,
'UserController@userLocation'
);
//返回用户安装位置
Route
::
get
(
'user/userLocation'
,
'UserController@userLocation'
);
//返回用户安装位置
Route
::
get
(
'user/textcountuser'
,
'UserController@textcountuser'
);
//用户测试接口
Route
::
get
(
'user/textcountuser'
,
'UserController@textcountuser'
);
//用户测试接口
// 报警工单
Route
::
get
(
'alarm_order'
,
'AlarmOrderController@index'
);
// 工单列表
Route
::
post
(
'alarm_order'
,
'AlarmOrderController@store'
);
// 创建工单
Route
::
patch
(
'alarm_order/{id}'
,
'AlarmOrderController@update'
);
// 修改工单
Route
::
delete
(
'alarm_order/{id}'
,
'AlarmOrderController@destroy'
);
// 删除工单
Route
::
get
(
'alarm_order/show/{id}'
,
'AlarmOrderController@show'
);
// 工单详情
});
});
//上传图片路由
//上传图片路由
...
@@ -130,108 +137,4 @@ Route::group(['middleware'=>'auth:api'],function (){
...
@@ -130,108 +137,4 @@ Route::group(['middleware'=>'auth:api'],function (){
Route
::
post
(
'huinapphome/setseachdata'
,
'UinappHomeController@setseachdata'
);
//指定查询
Route
::
post
(
'huinapphome/setseachdata'
,
'UinappHomeController@setseachdata'
);
//指定查询
Route
::
get
(
'huinapphome/devicetype'
,
'UinappHomeController@devicetype'
);
//测试添加页面选择数组数据
Route
::
get
(
'huinapphome/devicetype'
,
'UinappHomeController@devicetype'
);
//测试添加页面选择数组数据
});
});
// Fake APIs
Route
::
get
(
'/table/list'
,
function
()
{
$rowsNumber
=
mt_rand
(
20
,
30
);
$data
=
[];
for
(
$rowIndex
=
0
;
$rowIndex
<
$rowsNumber
;
$rowIndex
++
)
{
$row
=
[
'author'
=>
Faker
::
randomString
(
mt_rand
(
5
,
10
)),
'display_time'
=>
Faker
::
randomDateTime
()
->
format
(
'Y-m-d H:i:s'
),
'id'
=>
mt_rand
(
100000
,
100000000
),
'pageviews'
=>
mt_rand
(
100
,
10000
),
'status'
=>
Faker
::
randomInArray
([
'deleted'
,
'published'
,
'draft'
]),
'title'
=>
Faker
::
randomString
(
mt_rand
(
20
,
50
)),
];
$data
[]
=
$row
;
}
return
response
()
->
json
(
new
JsonResponse
([
'items'
=>
$data
]));
});
Route
::
get
(
'/orders'
,
function
()
{
$rowsNumber
=
8
;
$data
=
[];
for
(
$rowIndex
=
0
;
$rowIndex
<
$rowsNumber
;
$rowIndex
++
)
{
$row
=
[
'order_no'
=>
'LARAVUE'
.
mt_rand
(
1000000
,
9999999
),
'price'
=>
mt_rand
(
10000
,
999999
),
'status'
=>
Faker
::
randomInArray
([
'success'
,
'pending'
]),
];
$data
[]
=
$row
;
}
return
response
()
->
json
(
new
JsonResponse
([
'items'
=>
$data
]));
});
Route
::
get
(
'/articles'
,
function
()
{
$rowsNumber
=
10
;
$data
=
[];
for
(
$rowIndex
=
0
;
$rowIndex
<
$rowsNumber
;
$rowIndex
++
)
{
$row
=
[
'id'
=>
mt_rand
(
100
,
10000
),
'display_time'
=>
Faker
::
randomDateTime
()
->
format
(
'Y-m-d H:i:s'
),
'title'
=>
Faker
::
randomString
(
mt_rand
(
20
,
50
)),
'author'
=>
Faker
::
randomString
(
mt_rand
(
5
,
10
)),
'comment_disabled'
=>
Faker
::
randomBoolean
(),
'content'
=>
Faker
::
randomString
(
mt_rand
(
100
,
300
)),
'content_short'
=>
Faker
::
randomString
(
mt_rand
(
30
,
50
)),
'status'
=>
Faker
::
randomInArray
([
'deleted'
,
'published'
,
'draft'
]),
'forecast'
=>
mt_rand
(
100
,
9999
)
/
100
,
'image_uri'
=>
'https://via.placeholder.com/400x300'
,
'importance'
=>
mt_rand
(
1
,
3
),
'pageviews'
=>
mt_rand
(
10000
,
999999
),
'reviewer'
=>
Faker
::
randomString
(
mt_rand
(
5
,
10
)),
'timestamp'
=>
Faker
::
randomDateTime
()
->
getTimestamp
(),
'type'
=>
Faker
::
randomInArray
([
'US'
,
'VI'
,
'JA'
]),
];
$data
[]
=
$row
;
}
return
response
()
->
json
(
new
JsonResponse
([
'items'
=>
$data
,
'total'
=>
mt_rand
(
1000
,
10000
)]));
});
Route
::
get
(
'articles/{id}'
,
function
(
$id
)
{
$article
=
[
'id'
=>
$id
,
'display_time'
=>
Faker
::
randomDateTime
()
->
format
(
'Y-m-d H:i:s'
),
'title'
=>
Faker
::
randomString
(
mt_rand
(
20
,
50
)),
'author'
=>
Faker
::
randomString
(
mt_rand
(
5
,
10
)),
'comment_disabled'
=>
Faker
::
randomBoolean
(),
'content'
=>
Faker
::
randomString
(
mt_rand
(
100
,
300
)),
'content_short'
=>
Faker
::
randomString
(
mt_rand
(
30
,
50
)),
'status'
=>
Faker
::
randomInArray
([
'deleted'
,
'published'
,
'draft'
]),
'forecast'
=>
mt_rand
(
100
,
9999
)
/
100
,
'image_uri'
=>
'https://via.placeholder.com/400x300'
,
'importance'
=>
mt_rand
(
1
,
3
),
'pageviews'
=>
mt_rand
(
10000
,
999999
),
'reviewer'
=>
Faker
::
randomString
(
mt_rand
(
5
,
10
)),
'timestamp'
=>
Faker
::
randomDateTime
()
->
getTimestamp
(),
'type'
=>
Faker
::
randomInArray
([
'US'
,
'VI'
,
'JA'
]),
];
return
response
()
->
json
(
new
JsonResponse
(
$article
));
});
Route
::
get
(
'articles/{id}/pageviews'
,
function
(
$id
)
{
$pageviews
=
[
'PC'
=>
mt_rand
(
10000
,
999999
),
'Mobile'
=>
mt_rand
(
10000
,
999999
),
'iOS'
=>
mt_rand
(
10000
,
999999
),
'android'
=>
mt_rand
(
10000
,
999999
),
];
$data
=
[];
foreach
(
$pageviews
as
$device
=>
$pageview
)
{
$data
[]
=
[
'key'
=>
$device
,
'pv'
=>
$pageview
,
];
}
return
response
()
->
json
(
new
JsonResponse
([
'pvData'
=>
$data
]));
});
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