Commit 74daa78f authored by Administrator's avatar Administrator

Merge branch 'master' into map_model

parents a0a019b3 f43cfe41
...@@ -55,7 +55,9 @@ class swoole extends Command ...@@ -55,7 +55,9 @@ class swoole extends Command
//开启WebSocket //开启WebSocket
public function start() public function start()
{ {
$this->ws = new \swoole_websocket_server("0.0.0.0", 9502); //创建一个端口 $url = config('public.swoolwebsocketurl');
$por = config('public.swoolwebsocketurlpor');
$this->ws = new \swoole_websocket_server($url, $por); //创建一个端口
$this->ws->set(array( $this->ws->set(array(
'reactor_num' => 2, //reactor线程数 'reactor_num' => 2, //reactor线程数
'worker_num' => 4, //worker进程数 'worker_num' => 4, //worker进程数
......
...@@ -54,10 +54,11 @@ class swooleMeTcp extends Command ...@@ -54,10 +54,11 @@ class swooleMeTcp extends Command
//开启 //开启
public function start() public function start()
{ {
$this->tcp = new \swoole_server("127.0.0.1", 9503); $url = config('public.swooletcpurl');
$this->tcp->addlistener("127.0.0.1", 9504, SWOOLE_SOCK_TCP); // 添加 TCP端口监听 $this->tcp = new \swoole_server($url, 9503);
$this->tcp->addlistener("127.0.0.1", 9505, SWOOLE_SOCK_TCP); // 添加 TCP端口监听 $this->tcp->addlistener($url, 9504, SWOOLE_SOCK_TCP); // 添加 TCP端口监听
$this->tcp->addlistener("127.0.0.1", 9506, SWOOLE_SOCK_TCP); // 添加 TCP端口监听 $this->tcp->addlistener($url, 9505, SWOOLE_SOCK_TCP); // 添加 TCP端口监听
$this->tcp->addlistener($url, 9506, SWOOLE_SOCK_TCP); // 添加 TCP端口监听
$this->tcp->set([ $this->tcp->set([
'worker_num' => 2,//设置启动的 Worker 进程数 'worker_num' => 2,//设置启动的 Worker 进程数
'max_request' =>30,//最大任务数 'max_request' =>30,//最大任务数
......
...@@ -29,18 +29,35 @@ class AuthController extends Controller ...@@ -29,18 +29,35 @@ class AuthController extends Controller
*/ */
public function login(Request $request , Users $users) public function login(Request $request , Users $users)
{ {
$userOrAdmin= $request->input('userOrAdmin');
$credentials = $request->only('email', 'password'); $credentials = $request->only('email', 'password');
if (!Auth::attempt($credentials)) { if($userOrAdmin == 1 ){ //用户
$BackgroundUser = $users->where([['email','=',$credentials['email']],['password','=',sha1($credentials['password'])],['state','=','2']])->first();
if (Auth::attempt($credentials)) {
return response()->json(new JsonResponse([], 'login_error'), Response::HTTP_UNAUTHORIZED); return response()->json(new JsonResponse([], 'login_error'), Response::HTTP_UNAUTHORIZED);
} }
if($BackgroundUser){
$BackgroundUser = $request->user();
print_r($BackgroundUser);
die();
$tokenResult = $BackgroundUser->createToken('Personal Access Token');
$token = $tokenResult->token;
$token->save();
return response()->json(new UserResource($BackgroundUser), Response::HTTP_OK)->header('Authorization', $tokenResult->accessToken);
}
}else{
if (!Auth::attempt($credentials)) {
return response()->json(new JsonResponse([], 'login_error'), Response::HTTP_UNAUTHORIZED);
}
$user = $request->user(); $user = $request->user();
$tokenResult = $user->createToken('Personal Access Token'); $tokenResult = $user->createToken('Personal Access Token');
$token = $tokenResult->token; $token = $tokenResult->token;
$token->save(); $token->save();
return response()->json(new UserResource($user), Response::HTTP_OK)->header('Authorization', $tokenResult->accessToken); return response()->json(new UserResource($user), Response::HTTP_OK)->header('Authorization', $tokenResult->accessToken);
}
} }
......
...@@ -186,8 +186,9 @@ class DevicesController extends Controller ...@@ -186,8 +186,9 @@ class DevicesController extends Controller
->where('dtype', '=', $type) ->where('dtype', '=', $type)
->leftjoin('device_type as dy', "device.dtype", '=', 'dy.tid') ->leftjoin('device_type as dy', "device.dtype", '=', 'dy.tid')
->leftjoin('gas as g', "device.status", '=', 'g.id') ->leftjoin('gas as g', "device.status", '=', 'g.id')
->leftjoin('BackgroundUser as u', "device.uid", '=', 'u.id')
->leftjoin('status as p', "device.devicepolice", '=', 'p.id') ->leftjoin('status as p', "device.devicepolice", '=', 'p.id')
->select('dy.tname', 'g.gas', 'device.*', 'p.status_name') ->select('dy.tname', 'g.gas', 'device.*', 'p.status_name','u.nickname as usernickname')
->orderBy('device.id', 'desc') ->orderBy('device.id', 'desc')
->offset($pagenNum) ->offset($pagenNum)
->limit($limit) ->limit($limit)
...@@ -227,8 +228,9 @@ class DevicesController extends Controller ...@@ -227,8 +228,9 @@ class DevicesController extends Controller
->where('devicenum', '=', $devicenum) ->where('devicenum', '=', $devicenum)
->leftjoin('device_type as dy', "device.dtype", '=', 'dy.tid') ->leftjoin('device_type as dy', "device.dtype", '=', 'dy.tid')
->leftjoin('gas as g', "device.status", '=', 'g.id') ->leftjoin('gas as g', "device.status", '=', 'g.id')
->leftjoin('BackgroundUser as u', "device.uid", '=', 'u.id')
->leftjoin('status as p', "device.devicepolice", '=', 'p.id') ->leftjoin('status as p', "device.devicepolice", '=', 'p.id')
->select('dy.tname', 'g.gas', 'device.*', 'p.status_name') ->select('dy.tname', 'g.gas', 'device.*', 'p.status_name','u.nickname as usernickname')
->orderBy('device.id', 'desc') ->orderBy('device.id', 'desc')
->offset($pagenNum) ->offset($pagenNum)
->limit($limit) ->limit($limit)
...@@ -256,7 +258,17 @@ class DevicesController extends Controller ...@@ -256,7 +258,17 @@ class DevicesController extends Controller
->get(); ->get();
return $this->jsonSuccessData(['devicedata' => $devicedata, 'devicedatainfo' => $devicedatainfo]); return $this->jsonSuccessData(['devicedata' => $devicedata, 'devicedatainfo' => $devicedatainfo]);
} }
// 返回设备地图详情信息
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')
->first();
return $this->jsonSuccessData($devicedata);
}
//搜索设备账号 //搜索设备账号
public function deviceDataSearch(Request $request) public function deviceDataSearch(Request $request)
{ {
...@@ -272,8 +284,10 @@ class DevicesController extends Controller ...@@ -272,8 +284,10 @@ class DevicesController extends Controller
//推送获取数据监测数据 //推送获取数据监测数据
public function equipment() public function equipment()
{ {
/*
* 将写入文件改为时序数据库!
* */
$dalen = Redis::llen('Devicesdata');//返回队列长度 $dalen = Redis::llen('Devicesdata');//返回队列长度
// $num = round($dalen / 2);
$data = []; $data = [];
if ($dalen > 0) { if ($dalen > 0) {
for ($i = 0; $i < $dalen; $i++) { for ($i = 0; $i < $dalen; $i++) {
...@@ -359,7 +373,7 @@ class DevicesController extends Controller ...@@ -359,7 +373,7 @@ class DevicesController extends Controller
public function deviceLocation() public function deviceLocation()
{ {
//返回用户安装位置 //返回用户安装位置
return $this->jsonSuccessData(DB::table('device')->select('id','devicenum','devicecoord','devicepolice')->get()); return $this->jsonSuccessData(DB::table('device')->select('id','uid','nd','deviceinfo','devicenum','devicecoord','devicepolice','deviceremark','devicelinkman')->get());
} }
//返回消防监测 //返回消防监测
public function control(Request $request) public function control(Request $request)
...@@ -371,10 +385,10 @@ class DevicesController extends Controller ...@@ -371,10 +385,10 @@ class DevicesController extends Controller
return $this->jsonErrorData(105, '页数或limit不能为空'); return $this->jsonErrorData(105, '页数或limit不能为空');
} }
if($type ==1){//返回消防监测 if($type ==1){//返回消防监测
$wherein = [1,2,4,7,8,11]; $wherein = [2,4,6,7,8,9,11];
}else{ }else{
//返回危化 //返回危化
$wherein = [5,6,9,10]; $wherein = [1,5,10];
} }
$databadevice = DB::table('device'); $databadevice = DB::table('device');
$devicelist = $databadevice $devicelist = $databadevice
......
...@@ -507,7 +507,30 @@ class UserController extends Controller ...@@ -507,7 +507,30 @@ class UserController extends Controller
//返回用户的经纬度 //返回用户的经纬度
public function userLocation() public function userLocation()
{ {
return $this->jsonSuccessData(DB::table('BackgroundUser')->select('id','nickname','mapcenter','company')->get()); $davicenum = DB::table('BackgroundUser')
->select('id')
->get()->toArray();
$data = [];
$police = [];
foreach (array_column($davicenum, 'id') as $k=>$value){
$countdevice_type = DB::table('device')
->where('uid','=',$value)
->count();
$usernum['count'] =$countdevice_type;
$usernum['id'] = $value;
array_push($data,$usernum);
}
foreach (array_column($davicenum, 'id') as $k=>$value){
$countdevice_type = DB::table('device')
->where('uid','=',$value)
->where('devicepolice','>','1')
->count();
$usernum['count'] =$countdevice_type;
$usernum['id'] = $value;
array_push($police,$usernum);
}
$userlist = DB::table('BackgroundUser')->select('id','nickname','mapcenter','company')->get();
return $this->jsonSuccessData(['UserDaviceNum'=>$data,'UserList'=>$userlist,'police'=>$police]);
} }
/* /*
......
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
class Userslist extends Middleware
{
}
\ No newline at end of file
...@@ -44,12 +44,12 @@ return [ ...@@ -44,12 +44,12 @@ return [
'api' => [ 'api' => [
'driver' => 'passport', 'driver' => 'passport',
'provider' => 'users', 'provider' => 'users',
'hash' => false, 'hash' => true,
], ],
'admin' => [ 'admin' => [
'driver' => 'passport', 'driver' => 'passport',
'provider' => 'user', 'provider' => 'users',
'hash' => false, 'hash' => true,
], ],
], ],
......
No preview for this file type
[{"devicenum":"ZHGAS000141031","username":"\u4f60\u597d","deviceremark":"1","devicelinkman":"1","devicephone":"1","deviceinfo":"1","tname":"\u5de5\u4e1a\u63a2\u6d4b\u5668","gas":"\u7532\u70f7","danwei":"%LEL","status_name":"\u9519\u8bef"}]
...@@ -28,7 +28,7 @@ const deviceRoutes = { ...@@ -28,7 +28,7 @@ const deviceRoutes = {
path: 'DeviceStutus', path: 'DeviceStutus',
component: () => import('@/views/device/devicedtutus'), component: () => import('@/views/device/devicedtutus'),
name: 'DeviceStutus', name: 'DeviceStutus',
meta: { title: '设备状态列表', icon: 'devicestutus', permissions: ['manage user'] }, meta: { title: '设备废纸篓', icon: 'devicestutus', permissions: ['manage user'] },
}, },
], ],
}; };
......
...@@ -34,7 +34,7 @@ const usersRoutes = { ...@@ -34,7 +34,7 @@ const usersRoutes = {
path: 'userStatus', path: 'userStatus',
component: () => import('@/views/user/userStatus'), component: () => import('@/views/user/userStatus'),
name: 'userStatus', name: 'userStatus',
meta: { title: '用户状态', icon: 'userstutus', permissions: ['manage user'] }, meta: { title: '用户废纸篓', icon: 'userstutus', permissions: ['manage user'] },
}, },
{ {
path: 'userStatistics', path: 'userStatistics',
......
...@@ -41,8 +41,9 @@ const actions = { ...@@ -41,8 +41,9 @@ const actions = {
// user login // user login
login({ commit }, userInfo) { login({ commit }, userInfo) {
const { email, password } = userInfo; const { email, password } = userInfo;
const userOrAdmin = localStorage.getItem('userOrAdmin');
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
login({ email: email.trim(), password: password }) login({ email: email.trim(), password: password, userOrAdmin: userOrAdmin })
.then(response => { .then(response => {
commit('SET_TOKEN', response.token); commit('SET_TOKEN', response.token);
setToken(response.token); setToken(response.token);
...@@ -56,7 +57,7 @@ const actions = { ...@@ -56,7 +57,7 @@ const actions = {
userlogin({ commit }, userInfo) { userlogin({ commit }, userInfo) {
const { email, password } = userInfo; const { email, password } = userInfo;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
userlogin({ email: email.trim(), password: password }) userlogin({ email: email.trim(), password: password, userOrAdmin: 1 })
.then(response => { .then(response => {
commit('SET_TOKEN', response.token); commit('SET_TOKEN', response.token);
setToken(response.token); setToken(response.token);
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
{{ $t('table.export') }} {{ $t('table.export') }}
</el-button> </el-button>
<el-badge v-if="paper > 0" :value="paper" class="item" style="margin-bottom: 8px;"> <el-badge v-if="paper > 0" :value="paper" class="item" style="margin-bottom: 8px;">
<el-button size="small"> <el-button size="small" @click="pucharray">
<svg-icon class-name="custom-class" icon-class="feizhilou" />废纸篓 <svg-icon class-name="custom-class" icon-class="feizhilou" />废纸篓
</el-button> </el-button>
</el-badge> </el-badge>
...@@ -35,6 +35,11 @@ ...@@ -35,6 +35,11 @@
<span>{{ scope.row.tname }}</span> <span>{{ scope.row.tname }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="用户名称" width="150">
<template slot-scope="scope">
<span>{{ scope.row.usernickname }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="介质状态" width="170"> <el-table-column align="center" label="介质状态" width="170">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.gas }}</span> <span>{{ scope.row.gas }}</span>
...@@ -202,6 +207,10 @@ export default { ...@@ -202,6 +207,10 @@ export default {
handleCopy(text, event) { handleCopy(text, event) {
clip(text, event); clip(text, event);
}, },
// 跳转废纸废纸篓
pucharray() {
this.$router.push({ path: '/device/DeviceStutus' });
},
deviceinfo(row) { deviceinfo(row) {
this.dialogPvVisible = true; this.dialogPvVisible = true;
this.deviceData(row); this.deviceData(row);
...@@ -277,7 +286,7 @@ export default { ...@@ -277,7 +286,7 @@ export default {
}); });
}, },
deviceDelete(id, type) { deviceDelete(id, type) {
this.$confirm('是否将用户丢弃', '提示', { this.$confirm('是否将设备丢弃', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning', type: 'warning',
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<span @click="handleCopy(scope.row.concentration,$event)">{{ scope.row.concentration }}</span> <span @click="handleCopy(scope.row.concentration,$event)">{{ scope.row.concentration }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="报警位置" width="150"> <el-table-column label="报警位置">
<template slot-scope="scope"> <template slot-scope="scope">
<span @click="handleCopy(scope.row.location,$event)">{{ scope.row.location }}</span> <span @click="handleCopy(scope.row.location,$event)">{{ scope.row.location }}</span>
</template> </template>
......
...@@ -4,37 +4,37 @@ ...@@ -4,37 +4,37 @@
<el-date-picker v-model="value2" align="right" type="date" placeholder="选择日期" :picker-options="pickerOptions" value-format="yyyy-MM-dd" @change="dataSearch"></el-date-picker> <el-date-picker v-model="value2" align="right" type="date" placeholder="选择日期" :picker-options="pickerOptions" value-format="yyyy-MM-dd" @change="dataSearch"></el-date-picker>
</div> </div>
<el-table :key="tableKey" :data="equipment" border fit highlight-current-rows> <el-table :key="tableKey" :data="equipment" border fit highlight-current-rows>
<el-table-column label="设备编号" width="130"> <el-table-column label="设备编号" width="169">
<template slot-scope="scope"> <template slot-scope="scope">
<span @click="handleCopy(scope.row.devicenum,$event)">{{ scope.row.devicenum }}</span> <span @click="handleCopy(scope.row.devicenum,$event)">{{ scope.row.devicenum }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="用户姓名" width="130"> <el-table-column label="用户姓名" width="140">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.username }}</span> <span>{{ scope.row.username }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="设备备注" width="130"> <el-table-column label="设备备注" width="140">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.deviceremark }}</span> <span>{{ scope.row.deviceremark }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="设备联系人" width="130"> <el-table-column label="设备联系人" width="140">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.devicelinkman }}</span> <span>{{ scope.row.devicelinkman }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="设备手机号" width="130"> <el-table-column label="设备手机号" width="140">
<template slot-scope="scope"> <template slot-scope="scope">
<span @click="handleCopy(scope.row.devicephone,$event)">{{ scope.row.devicephone }}</span> <span @click="handleCopy(scope.row.devicephone,$event)">{{ scope.row.devicephone }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="设备详情" width="130"> <el-table-column label="设备详情">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.deviceinfo }}</span> <span>{{ scope.row.deviceinfo }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="设备分类" width="130"> <el-table-column label="设备分类" width="140">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.tname }}</span> <span>{{ scope.row.tname }}</span>
</template> </template>
......
...@@ -113,10 +113,12 @@ export default { ...@@ -113,10 +113,12 @@ export default {
loginForm: { loginForm: {
email: '', email: '',
password: '', password: '',
userOrAdmin: 2, // 管理员
}, },
userloginForm: { userloginForm: {
email: '', email: '',
password: '', password: '',
userOrAdmin: 1, // 用户
}, },
loginRules: { loginRules: {
email: [{ required: true, trigger: 'blur', validator: validateEmail }], email: [{ required: true, trigger: 'blur', validator: validateEmail }],
...@@ -167,6 +169,7 @@ export default { ...@@ -167,6 +169,7 @@ export default {
} else if (this.loginForm.password === '') { } else if (this.loginForm.password === '') {
this.$message.error('密码不能为空'); this.$message.error('密码不能为空');
} else { } else {
localStorage.setItem('userOrAdmin', '2');
this.$prompt('请输入登入口令', '提示', { this.$prompt('请输入登入口令', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
...@@ -197,28 +200,21 @@ export default { ...@@ -197,28 +200,21 @@ export default {
} }
}, },
userLogin() { userLogin() {
// this.$router.push({ path: '/redirect' + 'user/userslist' }); if (this.userloginForm.email === '') {
// if (this.userloginForm.email === '') { this.$message.error('邮箱不能为空');
// this.$message.error('邮箱不能为空'); } else if (this.userloginForm.password === '') {
// } else if (this.userloginForm.password === '') { this.$message.error('密码不能为空');
// this.$message.error('密码不能为空'); } else {
// } else { localStorage.setItem('userOrAdmin', '1');
// userlogin(this.userloginForm) this.$store.dispatch('user/login', this.userloginForm)
// .then(response => {
// this.$router.push({ path: '/user/userslist' });
// })
// .catch(err => {
// console.log(err);
// });
this.$store.dispatch('user/userlogin', this.userloginForm)
.then(() => { .then(() => {
this.$router.push({ path: '/redirect' + 'user/userslist' }); this.$router.push({ path: '/' });
this.loading = false; this.loading = false;
}) })
.catch(() => { .catch(() => {
this.loading = false; this.loading = false;
}); });
// } }
}, },
}, },
}; };
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
{{ $t('table.export') }} {{ $t('table.export') }}
</el-button> </el-button>
<el-badge v-if="paper > 0" :value="paper" class="item" style="margin-bottom: 8px;"> <el-badge v-if="paper > 0" :value="paper" class="item" style="margin-bottom: 8px;">
<el-button size="small"> <el-button size="small" @click="userpaty">
<svg-icon class-name="custom-class" icon-class="feizhilou" />废纸篓 <svg-icon class-name="custom-class" icon-class="feizhilou" />废纸篓
</el-button> </el-button>
</el-badge> </el-badge>
...@@ -203,6 +203,10 @@ export default { ...@@ -203,6 +203,10 @@ export default {
handleCopy(text, event) { handleCopy(text, event) {
clip(text, event); clip(text, event);
}, },
// 用户废纸篓
userpaty() {
this.$router.push({ path: '/users/userStatus' });
},
// 编辑 // 编辑
userUpdate(id) { userUpdate(id) {
this.dialogPvVisible = true; this.dialogPvVisible = true;
......
...@@ -62,6 +62,11 @@ Route::group(['middleware'=>'auth:api'],function (){ ...@@ -62,6 +62,11 @@ Route::group(['middleware'=>'auth:api'],function (){
Route::post('SwooleCommand/SwooleCommand','SwooleCommandController@index'); Route::post('SwooleCommand/SwooleCommand','SwooleCommandController@index');
}); });
//用户路由
Route::group(['middleware'=>'auth:api'],function (){
});
//首页路由 //首页路由
Route::group(['middleware'=>'auth:api'],function (){ Route::group(['middleware'=>'auth:api'],function (){
Route::get('homepagecount/homepagecount','HomepageController@homepagecount');//删除图片 Route::get('homepagecount/homepagecount','HomepageController@homepagecount');//删除图片
...@@ -90,6 +95,7 @@ Route::group(['middleware'=>'auth:api'],function (){ ...@@ -90,6 +95,7 @@ Route::group(['middleware'=>'auth:api'],function (){
Route::get('devices/detedevice','DevicesController@detedevice');//查看历史数据 Route::get('devices/detedevice','DevicesController@detedevice');//查看历史数据
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');//返回设备地图详情信息
}); });
//装维中心 //装维中心
......
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