Commit 165fe2b3 authored by 冯超鹏's avatar 冯超鹏

用户设备报警提示窗

parent f3246426
Pipeline #73 canceled with stages
...@@ -7,6 +7,7 @@ use App\Laravue\Models\Users; ...@@ -7,6 +7,7 @@ use App\Laravue\Models\Users;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use App\Http\Controllers\DevicesController;
class SwooleCommandController extends Controller class SwooleCommandController extends Controller
{ {
//返回用户列表 //返回用户列表
...@@ -63,9 +64,8 @@ class SwooleCommandController extends Controller ...@@ -63,9 +64,8 @@ class SwooleCommandController extends Controller
//监测是否设备报警 //监测是否设备报警
public function alarm() public function alarm()
{ {
$user = Auth::user();//获取当前用户信息 $isadmin = DB::table('config')->first();
$isadmin = DB::table('users')->where([['name', '=', $user['name']], ['email', '=', $user['email']]])->first(); if (is_null($isadmin)) {
if (!is_null($isadmin)) {
$isalarm = DB::table('reportpolice') $isalarm = DB::table('reportpolice')
->where('status', '=', '1') ->where('status', '=', '1')
->where('police', '=', '1') ->where('police', '=', '1')
...@@ -73,11 +73,12 @@ class SwooleCommandController extends Controller ...@@ -73,11 +73,12 @@ class SwooleCommandController extends Controller
->select('devicenumber') ->select('devicenumber')
->get()->toArray(); ->get()->toArray();
} else { } else {
$uid = get_object_vars($isadmin)['uid'];
$isalarm = DB::table('reportpolice') $isalarm = DB::table('reportpolice')
->join('device as d','reportpolice.devicenumber','=','d.devicenum') ->join('device as d','reportpolice.devicenumber','=','d.devicenum')
->where('reportpolice.status', '=', '1') ->where('reportpolice.status', '=', '1')
->where('reportpolice.police', '=', '1') ->where('reportpolice.police', '=', '1')
->where('d.uid', '=', Auth::id()) ->where('d.uid', '=', $uid)
->groupBy('reportpolice.id') ->groupBy('reportpolice.id')
->select('reportpolice.devicenumber') ->select('reportpolice.devicenumber')
->get()->toArray(); ->get()->toArray();
......
...@@ -73,8 +73,14 @@ class AuthController extends Controller ...@@ -73,8 +73,14 @@ class AuthController extends Controller
} }
public function logout(Request $request) public function logout(Request $request)
{ {
$request->user()->token()->revoke(); $config = DB::table('config');
return response()->json((new JsonResponse())->success([]), Response::HTTP_OK); $delectuser = $config->where('uid','=',Auth::id())->delete();
if($delectuser){
$request->user()->token()->revoke();
return response()->json((new JsonResponse())->success([]), Response::HTTP_OK);
}else{
return 500;
}
} }
public function user() public function user()
......
...@@ -79,8 +79,13 @@ class HomepageController extends Controller ...@@ -79,8 +79,13 @@ class HomepageController extends Controller
} }
//返回一年当前月份 //返回一年当前月份
public function userdevicemonthcount() 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()]);
}
$year_start = strtotime(date("Y") . "-01-01"); // 获取当前的1月份的时间戳 $year_start = strtotime(date("Y") . "-01-01"); // 获取当前的1月份的时间戳
$endThismonth = mktime(23, 59, 59, date('m'), date('t'), date('Y')); //获取当月的时间戳 $endThismonth = mktime(23, 59, 59, date('m'), date('t'), date('Y')); //获取当月的时间戳
$devicedata = Device::where('uid','=',Auth::id())->whereBetween('deviceaddtime', [$year_start, $endThismonth]) $devicedata = Device::where('uid','=',Auth::id())->whereBetween('deviceaddtime', [$year_start, $endThismonth])
......
...@@ -552,6 +552,6 @@ class UserController extends Controller ...@@ -552,6 +552,6 @@ class UserController extends Controller
public function textcountuser() public function textcountuser()
{ {
var_dump(exec("ifconfig", $res)); print_r(Auth::id());
} }
} }
\ No newline at end of file
...@@ -44,8 +44,6 @@ Route::group(['middleware' => 'auth:api'], function () { ...@@ -44,8 +44,6 @@ 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');//用户测试接口
}); });
//上传图片路由 //上传图片路由
...@@ -102,6 +100,7 @@ Route::group(['middleware'=>'auth:api'],function (){ ...@@ -102,6 +100,7 @@ Route::group(['middleware'=>'auth:api'],function (){
Route::get('devices/control','DevicesController@control');//返回消防监测 Route::get('devices/control','DevicesController@control');//返回消防监测
Route::get('devices/deviceLocation','DevicesController@deviceLocation');//返回设备安装位置 Route::get('devices/deviceLocation','DevicesController@deviceLocation');//返回设备安装位置
Route::get('devices/device_info/{id}','DevicesController@device_info');//返回设备地图详情信息 Route::get('devices/device_info/{id}','DevicesController@device_info');//返回设备地图详情信息
Route::get('devices/UseridOrdeviceInfo','DevicesController@UseridOrdeviceInfo');//用户测试接口
}); });
//装维中心 //装维中心
......
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