Commit e4a86f92 authored by 冯超鹏's avatar 冯超鹏

提交用户监测问题

parent 9fa83d93
Pipeline #99 canceled with stages
......@@ -67,7 +67,7 @@ class alarm extends Command
));
$this->ws->on('open', function ($ws, $request) {
// //链接成功
$userdata = new SwooleCommandController();
// $userdata = new SwooleCommandController();
// $this->ws->push($request->fd,'11',1);
});
......
......@@ -67,17 +67,12 @@ class chemicalswb extends Command
));
$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消息事件
$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) {
......
......@@ -67,17 +67,12 @@ class firewb extends Command
));
$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消息事件
$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) {
......
......@@ -26,39 +26,75 @@ class SwooleCommandController extends Controller
return $this->jsonSuccessData($countdata);
}
public function chemicals()
public function chemicals($id)
{
$uid = $this->isadmin($id);
$databadevice = DB::table('device');
$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')
->select('dy.tname', 'g.gas', 'device.*', 'p.status_name', 'dw.danwei')
->orderBy('device.id', 'desc')
->get()->toArray();
$count = $databadevice
->whereIn('dtype', [1, 5, 10])
->count();
if($uid == 1){
$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')
->select('dy.tname', 'g.gas', 'device.*', 'p.status_name', 'dw.danwei')
->orderBy('device.id', 'desc')
->get()->toArray();
$count = $databadevice
->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]);
}
public function fire()
public function fire($id)
{
$uid = $this->isadmin($id);
$databadevice = DB::table('device');
$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')
->select('dy.tname', 'g.gas', 'device.*', 'p.status_name', 'dw.danwei')
->orderBy('device.id', 'desc')
->get()->toArray();
$count = $databadevice
->whereIn('dtype', [2, 4, 6, 7, 8, 9, 11])
->count();
if($uid == 1){
$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')
->select('dy.tname', 'g.gas', 'device.*', 'p.status_name', 'dw.danwei')
->orderBy('device.id', 'desc')
->get()->toArray();
$count = $databadevice
->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]);
}
......@@ -66,8 +102,8 @@ class SwooleCommandController extends Controller
//监测是否设备报警
public function alarm($id)
{
$isadmin = DB::table('users')->where('id','=',$id)->value('isadmin');
if ($isadmin == 1) {
$uid = $this->isadmin($id);
if ($uid == 1) {
$isalarm = DB::table('reportpolice')
->where('status', '=', '1')
->where('police', '=', '1')
......@@ -79,7 +115,7 @@ class SwooleCommandController extends Controller
->join('device as d','reportpolice.devicenumber','=','d.devicenum')
->where('reportpolice.status', '=', '1')
->where('reportpolice.police', '=', '1')
->where('d.uid', '=', $isadmin)
->where('d.uid', '=', $id)
->groupBy('reportpolice.id')
->select('reportpolice.devicenumber')
->get()->toArray();
......@@ -90,4 +126,9 @@ class SwooleCommandController extends Controller
return $this->jsonErrorData(105, '当前无报警');
}
}
public function isadmin($id)
{
$isadmin = DB::table('users')->where('id','=',$id)->value('isadmin');
return $isadmin;
}
}
......@@ -175,7 +175,6 @@ export default {
this.websock.onclose = this.websocketclose;
},
websocketonopen(){ // 连接建立之后执行send方法发送数据
console.log('连接成功');
this.timer = setInterval(() => {
this.websocketsend();
}, 5000);
......
......@@ -82,6 +82,7 @@ export default {
type: 2,
total: 0,
paper: undefined,
timer: '',
};
},
created() {
......@@ -117,7 +118,9 @@ export default {
this.websock.onclose = this.websocketclose;
},
websocketonopen(){ // 连接建立之后执行send方法发送数据
console.log('连接成功');
this.timer = setInterval(() => {
this.websocketsend();
}, 5000);
},
websocketonerror(){ // 连接建立失败重连
this.$notify({
......@@ -133,7 +136,7 @@ export default {
this.total = redata.data.count;
},
websocketsend(){ // 数据发送
this.websock.send(JSON.stringify(this.type));
this.websock.send(localStorage.getItem('userinfoid'));
},
websocketclose(e){ // 关闭
console.log('断开连接', e);
......@@ -142,6 +145,7 @@ export default {
message: '危化监测长连接已断开',
type: 'warning',
});
clearInterval(this.timer);
},
handleClick(tab) {
this.type = tab.$attrs.tid;
......
......@@ -82,6 +82,7 @@ export default {
type: 1,
total: 0,
paper: undefined,
timer: '',
};
},
created() {
......@@ -117,7 +118,9 @@ export default {
this.websock.onclose = this.websocketclose;
},
websocketonopen(){ // 连接建立之后执行send方法发送数据
console.log('连接成功');
this.timer = setInterval(() => {
this.websocketsend();
}, 5000);
},
websocketonerror(){ // 连接建立失败重连
this.$notify({
......@@ -133,7 +136,7 @@ export default {
this.total = redata.data.count;
},
websocketsend(){ // 数据发送
this.websock.send(JSON.stringify(this.type));
this.websock.send(localStorage.getItem('userinfoid'));
},
websocketclose(e){ // 关闭
console.log('断开连接', e);
......@@ -142,6 +145,7 @@ export default {
message: '消防监测长连接已断开',
type: 'warning',
});
clearInterval(this.timer);
},
handleClick(tab) {
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