Commit dd12f5e1 authored by Administrator's avatar Administrator
parents 10c28a6b 1c904c2a
Pipeline #103 canceled with stages
...@@ -67,7 +67,7 @@ class alarm extends Command ...@@ -67,7 +67,7 @@ class alarm extends Command
)); ));
$this->ws->on('open', function ($ws, $request) { $this->ws->on('open', function ($ws, $request) {
// //链接成功 // //链接成功
$userdata = new SwooleCommandController(); // $userdata = new SwooleCommandController();
// $this->ws->push($request->fd,'11',1); // $this->ws->push($request->fd,'11',1);
}); });
......
...@@ -67,17 +67,12 @@ class chemicalswb extends Command ...@@ -67,17 +67,12 @@ class chemicalswb extends Command
)); ));
$this->ws->on('open', function ($ws, $request) { $this->ws->on('open', function ($ws, $request) {
// //链接成功 // //链接成功
$userdata = new SwooleCommandController();
$this->ws->push($request->fd,$userdata->chemicals(),1);
swoole_timer_tick(6000, function($timerId) use ($ws, $request) {
$userdata = new SwooleCommandController();
$this->ws->push($request->fd,$userdata->chemicals(),1);
});
}); });
//监听WebSocket消息事件 //监听WebSocket消息事件
$this->ws->on('message', function ($ws, $frame) { $this->ws->on('message', function ($ws, $frame) {
$userdata = new SwooleCommandController();
$this->ws->push($frame->fd,$userdata->chemicals($frame->data),1);
}); });
$this->ws->on('request', function ($request, $response,$from_id,$fd) { $this->ws->on('request', function ($request, $response,$from_id,$fd) {
......
...@@ -67,17 +67,12 @@ class firewb extends Command ...@@ -67,17 +67,12 @@ class firewb extends Command
)); ));
$this->ws->on('open', function ($ws, $request) { $this->ws->on('open', function ($ws, $request) {
// //链接成功 // //链接成功
$userdata = new SwooleCommandController();
$this->ws->push($request->fd,$userdata->fire(),1);
swoole_timer_tick(6000, function($timerId) use ($ws, $request) {
$userdata = new SwooleCommandController();
$this->ws->push($request->fd,$userdata->fire(),1);
});
}); });
//监听WebSocket消息事件 //监听WebSocket消息事件
$this->ws->on('message', function ($ws, $frame) { $this->ws->on('message', function ($ws, $frame) {
$userdata = new SwooleCommandController();
$this->ws->push($frame->fd,$userdata->fire($frame->data),1);
}); });
$this->ws->on('request', function ($request, $response,$from_id,$fd) { $this->ws->on('request', function ($request, $response,$from_id,$fd) {
......
...@@ -26,39 +26,75 @@ class SwooleCommandController extends Controller ...@@ -26,39 +26,75 @@ class SwooleCommandController extends Controller
return $this->jsonSuccessData($countdata); return $this->jsonSuccessData($countdata);
} }
public function chemicals() public function chemicals($id)
{ {
$uid = $this->isadmin($id);
$databadevice = DB::table('device'); $databadevice = DB::table('device');
$devicelist = $databadevice if($uid == 1){
->whereIn('dtype', [1, 5, 10]) $devicelist = $databadevice
->leftjoin('device_type as dy', "device.dtype", '=', 'dy.tid') ->whereIn('dtype', [1, 5, 10])
->leftjoin('gas as g', "device.status", '=', 'g.id') ->leftjoin('device_type as dy', "device.dtype", '=', 'dy.tid')
->leftjoin('status as p', "device.devicepolice", '=', 'p.id') ->leftjoin('gas as g', "device.status", '=', 'g.id')
->leftjoin('danwei as dw', 'device.devicemonad', '=', 'dw.id') ->leftjoin('status as p', "device.devicepolice", '=', 'p.id')
->select('dy.tname', 'g.gas', 'device.*', 'p.status_name', 'dw.danwei') ->leftjoin('danwei as dw', 'device.devicemonad', '=', 'dw.id')
->orderBy('device.id', 'desc') ->select('dy.tname', 'g.gas', 'device.*', 'p.status_name', 'dw.danwei')
->get()->toArray(); ->orderBy('device.id', 'desc')
$count = $databadevice ->get()->toArray();
->whereIn('dtype', [1, 5, 10]) $count = $databadevice
->count(); ->whereIn('dtype', [1, 5, 10])
->count();
}else{
$devicelist = $databadevice
->whereIn('dtype', [1, 5, 10])
->leftjoin('device_type as dy', "device.dtype", '=', 'dy.tid')
->leftjoin('gas as g', "device.status", '=', 'g.id')
->leftjoin('status as p', "device.devicepolice", '=', 'p.id')
->leftjoin('danwei as dw', 'device.devicemonad', '=', 'dw.id')
->where('device.uid','=',$id)
->select('dy.tname', 'g.gas', 'device.*', 'p.status_name', 'dw.danwei')
->orderBy('device.id', 'desc')
->get()->toArray();
$count = $databadevice
->where('device.uid','=',$id)
->whereIn('dtype', [1, 5, 10])
->count();
}
return $this->jsonSuccessData(['devicelist' => $devicelist, 'count' => $count]); return $this->jsonSuccessData(['devicelist' => $devicelist, 'count' => $count]);
} }
public function fire() public function fire($id)
{ {
$uid = $this->isadmin($id);
$databadevice = DB::table('device'); $databadevice = DB::table('device');
$devicelist = $databadevice if($uid == 1){
->whereIn('dtype', [2, 4, 6, 7, 8, 9, 11]) $devicelist = $databadevice
->leftjoin('device_type as dy', "device.dtype", '=', 'dy.tid') ->whereIn('dtype', [2, 4, 6, 7, 8, 9, 11])
->leftjoin('gas as g', "device.status", '=', 'g.id') ->leftjoin('device_type as dy', "device.dtype", '=', 'dy.tid')
->leftjoin('status as p', "device.devicepolice", '=', 'p.id') ->leftjoin('gas as g', "device.status", '=', 'g.id')
->leftjoin('danwei as dw', 'device.devicemonad', '=', 'dw.id') ->leftjoin('status as p', "device.devicepolice", '=', 'p.id')
->select('dy.tname', 'g.gas', 'device.*', 'p.status_name', 'dw.danwei') ->leftjoin('danwei as dw', 'device.devicemonad', '=', 'dw.id')
->orderBy('device.id', 'desc') ->select('dy.tname', 'g.gas', 'device.*', 'p.status_name', 'dw.danwei')
->get()->toArray(); ->orderBy('device.id', 'desc')
$count = $databadevice ->get()->toArray();
->whereIn('dtype', [2, 4, 6, 7, 8, 9, 11]) $count = $databadevice
->count(); ->whereIn('dtype', [2, 4, 6, 7, 8, 9, 11])
->count();
}else{
$devicelist = $databadevice
->whereIn('dtype', [2, 4, 6, 7, 8, 9, 11])
->leftjoin('device_type as dy', "device.dtype", '=', 'dy.tid')
->leftjoin('gas as g', "device.status", '=', 'g.id')
->leftjoin('status as p', "device.devicepolice", '=', 'p.id')
->leftjoin('danwei as dw', 'device.devicemonad', '=', 'dw.id')
->where('device.uid','=',$id)
->select('dy.tname', 'g.gas', 'device.*', 'p.status_name', 'dw.danwei')
->orderBy('device.id', 'desc')
->get()->toArray();
$count = $databadevice
->where('device.uid','=',$id)
->whereIn('dtype', [2, 4, 6, 7, 8, 9, 11])
->count();
}
return $this->jsonSuccessData(['devicelist' => $devicelist, 'count' => $count]); return $this->jsonSuccessData(['devicelist' => $devicelist, 'count' => $count]);
} }
...@@ -66,8 +102,8 @@ class SwooleCommandController extends Controller ...@@ -66,8 +102,8 @@ class SwooleCommandController extends Controller
//监测是否设备报警 //监测是否设备报警
public function alarm($id) public function alarm($id)
{ {
$isadmin = DB::table('users')->where('id','=',$id)->value('isadmin'); $uid = $this->isadmin($id);
if ($isadmin == 1) { if ($uid == 1) {
$isalarm = DB::table('reportpolice') $isalarm = DB::table('reportpolice')
->where('status', '=', '1') ->where('status', '=', '1')
->where('police', '=', '1') ->where('police', '=', '1')
...@@ -79,7 +115,7 @@ class SwooleCommandController extends Controller ...@@ -79,7 +115,7 @@ class SwooleCommandController extends Controller
->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', '=', $isadmin) ->where('d.uid', '=', $id)
->groupBy('reportpolice.id') ->groupBy('reportpolice.id')
->select('reportpolice.devicenumber') ->select('reportpolice.devicenumber')
->get()->toArray(); ->get()->toArray();
...@@ -90,4 +126,9 @@ class SwooleCommandController extends Controller ...@@ -90,4 +126,9 @@ class SwooleCommandController extends Controller
return $this->jsonErrorData(105, '当前无报警'); return $this->jsonErrorData(105, '当前无报警');
} }
} }
public function isadmin($id)
{
$isadmin = DB::table('users')->where('id','=',$id)->value('isadmin');
return $isadmin;
}
} }
...@@ -379,10 +379,19 @@ class DevicesController extends Controller ...@@ -379,10 +379,19 @@ class DevicesController extends Controller
//返回设备当前报警 //返回设备当前报警
public function police() public function police()
{ {
$data = DB::table('reportpolice as r') if (!is_null($this->isadmin())) {
->join('status as s', 'r.policestatus', '=', 's.id') $data = DB::table('reportpolice as r')
->select('r.*', 's.status_name') ->join('status as s', 'r.policestatus', '=', 's.id')
->get(); ->select('r.*', 's.status_name')
->get();
}else{
$data = DB::table('reportpolice as r')
->join('status as s', 'r.policestatus', '=', 's.id')
->join('device as d' , 'r.devicenumber','=','d.devicenum')
->where('d.uid','=',Auth::id())
->select('r.*', 's.status_name')
->get();
}
return $this->jsonSuccessData($data); return $this->jsonSuccessData($data);
} }
...@@ -486,20 +495,39 @@ class DevicesController extends Controller ...@@ -486,20 +495,39 @@ class DevicesController extends Controller
$wherein = [1, 5, 10]; $wherein = [1, 5, 10];
} }
$databadevice = DB::table('device'); $databadevice = DB::table('device');
$devicelist = $databadevice if (!is_null($this->isadmin())) {
->whereIn('dtype', $wherein) $devicelist = $databadevice
->leftjoin('device_type as dy', "device.dtype", '=', 'dy.tid') ->whereIn('dtype', $wherein)
->leftjoin('gas as g', "device.status", '=', 'g.id') ->leftjoin('device_type as dy', "device.dtype", '=', 'dy.tid')
->leftjoin('status as p', "device.devicepolice", '=', 'p.id') ->leftjoin('gas as g', "device.status", '=', 'g.id')
->leftjoin('danwei as dw', 'device.devicemonad', '=', 'dw.id') ->leftjoin('status as p', "device.devicepolice", '=', 'p.id')
->select('dy.tname', 'g.gas', 'device.*', 'p.status_name', 'dw.danwei') ->leftjoin('danwei as dw', 'device.devicemonad', '=', 'dw.id')
->orderBy('device.id', 'desc') ->select('dy.tname', 'g.gas', 'device.*', 'p.status_name', 'dw.danwei')
->offset($pagenNum) ->orderBy('device.id', 'desc')
->limit($limit) ->offset($pagenNum)
->get()->toArray(); ->limit($limit)
$count = $databadevice ->get()->toArray();
->whereIn('dtype', $wherein) $count = $databadevice
->count(); ->whereIn('dtype', $wherein)
->count();
}else{
$devicelist = $databadevice
->whereIn('dtype', $wherein)
->leftjoin('device_type as dy', "device.dtype", '=', 'dy.tid')
->leftjoin('gas as g', "device.status", '=', 'g.id')
->leftjoin('status as p', "device.devicepolice", '=', 'p.id')
->leftjoin('danwei as dw', 'device.devicemonad', '=', 'dw.id')
->where('device.uid','=',Auth::id())
->select('dy.tname', 'g.gas', 'device.*', 'p.status_name', 'dw.danwei')
->orderBy('device.id', 'desc')
->offset($pagenNum)
->limit($limit)
->get()->toArray();
$count = $databadevice
->whereIn('dtype', $wherein)
->where('uid','=',Auth::id())
->count();
}
return $this->jsonSuccessData(['devicelist' => $devicelist, 'count' => $count]); return $this->jsonSuccessData(['devicelist' => $devicelist, 'count' => $count]);
} }
public function devicepolice(Request $request) public function devicepolice(Request $request)
......
...@@ -82,7 +82,6 @@ class HomepageController extends Controller ...@@ -82,7 +82,6 @@ class HomepageController extends Controller
public function userdevicemonthcount(Request $request) public function userdevicemonthcount(Request $request)
{ {
\Session::put(['loginuid' => Auth::id()]); \Session::put(['loginuid' => Auth::id()]);
dd(\Session::get('loginuid'));
$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])
......
...@@ -175,7 +175,6 @@ export default { ...@@ -175,7 +175,6 @@ export default {
this.websock.onclose = this.websocketclose; this.websock.onclose = this.websocketclose;
}, },
websocketonopen(){ // 连接建立之后执行send方法发送数据 websocketonopen(){ // 连接建立之后执行send方法发送数据
console.log('连接成功');
this.timer = setInterval(() => { this.timer = setInterval(() => {
this.websocketsend(); this.websocketsend();
}, 5000); }, 5000);
......
...@@ -82,6 +82,7 @@ export default { ...@@ -82,6 +82,7 @@ export default {
type: 2, type: 2,
total: 0, total: 0,
paper: undefined, paper: undefined,
timer: '',
}; };
}, },
created() { created() {
...@@ -117,7 +118,9 @@ export default { ...@@ -117,7 +118,9 @@ export default {
this.websock.onclose = this.websocketclose; this.websock.onclose = this.websocketclose;
}, },
websocketonopen(){ // 连接建立之后执行send方法发送数据 websocketonopen(){ // 连接建立之后执行send方法发送数据
console.log('连接成功'); this.timer = setInterval(() => {
this.websocketsend();
}, 5000);
}, },
websocketonerror(){ // 连接建立失败重连 websocketonerror(){ // 连接建立失败重连
this.$notify({ this.$notify({
...@@ -133,7 +136,7 @@ export default { ...@@ -133,7 +136,7 @@ export default {
this.total = redata.data.count; this.total = redata.data.count;
}, },
websocketsend(){ // 数据发送 websocketsend(){ // 数据发送
this.websock.send(JSON.stringify(this.type)); this.websock.send(localStorage.getItem('userinfoid'));
}, },
websocketclose(e){ // 关闭 websocketclose(e){ // 关闭
console.log('断开连接', e); console.log('断开连接', e);
...@@ -142,6 +145,7 @@ export default { ...@@ -142,6 +145,7 @@ export default {
message: '危化监测长连接已断开', message: '危化监测长连接已断开',
type: 'warning', type: 'warning',
}); });
clearInterval(this.timer);
}, },
handleClick(tab) { handleClick(tab) {
this.type = tab.$attrs.tid; this.type = tab.$attrs.tid;
......
...@@ -82,6 +82,7 @@ export default { ...@@ -82,6 +82,7 @@ export default {
type: 1, type: 1,
total: 0, total: 0,
paper: undefined, paper: undefined,
timer: '',
}; };
}, },
created() { created() {
...@@ -117,7 +118,9 @@ export default { ...@@ -117,7 +118,9 @@ export default {
this.websock.onclose = this.websocketclose; this.websock.onclose = this.websocketclose;
}, },
websocketonopen(){ // 连接建立之后执行send方法发送数据 websocketonopen(){ // 连接建立之后执行send方法发送数据
console.log('连接成功'); this.timer = setInterval(() => {
this.websocketsend();
}, 5000);
}, },
websocketonerror(){ // 连接建立失败重连 websocketonerror(){ // 连接建立失败重连
this.$notify({ this.$notify({
...@@ -133,7 +136,7 @@ export default { ...@@ -133,7 +136,7 @@ export default {
this.total = redata.data.count; this.total = redata.data.count;
}, },
websocketsend(){ // 数据发送 websocketsend(){ // 数据发送
this.websock.send(JSON.stringify(this.type)); this.websock.send(localStorage.getItem('userinfoid'));
}, },
websocketclose(e){ // 关闭 websocketclose(e){ // 关闭
console.log('断开连接', e); console.log('断开连接', e);
...@@ -142,6 +145,7 @@ export default { ...@@ -142,6 +145,7 @@ export default {
message: '消防监测长连接已断开', message: '消防监测长连接已断开',
type: 'warning', type: 'warning',
}); });
clearInterval(this.timer);
}, },
handleClick(tab) { handleClick(tab) {
this.type = tab.$attrs.tid; this.type = tab.$attrs.tid;
......
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