Commit 75ea2f15 authored by 冯超鹏's avatar 冯超鹏

工单模块 app

parent 90f8e536
Pipeline #207 failed with stages
......@@ -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) {
......
......@@ -51,9 +51,9 @@ Route::group(['middleware' => 'auth:api'], function () {
// 报警工单
Route::get('alarm_order', 'AlarmOrderController@index'); // 工单列表
Route::post('alarm_order', 'AlarmOrderController@store'); // 创建工单
Route::patch('alarm_order/{id}', 'AlarmOrderController@update'); // 修改工单
Route::post('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'); // 工单详情
});
//上传图片路由
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment