Commit dd12f5e1 authored by Administrator's avatar Administrator
parents 10c28a6b 1c904c2a
Pipeline #103 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;
}
}
......@@ -379,10 +379,19 @@ class DevicesController extends Controller
//返回设备当前报警
public function police()
{
$data = DB::table('reportpolice as r')
->join('status as s', 'r.policestatus', '=', 's.id')
->select('r.*', 's.status_name')
->get();
if (!is_null($this->isadmin())) {
$data = DB::table('reportpolice as r')
->join('status as s', 'r.policestatus', '=', 's.id')
->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);
}
......@@ -486,20 +495,39 @@ class DevicesController extends Controller
$wherein = [1, 5, 10];
}
$databadevice = DB::table('device');
$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')
->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)
->count();
if (!is_null($this->isadmin())) {
$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')
->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)
->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]);
}
public function devicepolice(Request $request)
......
......@@ -82,7 +82,6 @@ class HomepageController extends Controller
public function userdevicemonthcount(Request $request)
{
\Session::put(['loginuid' => Auth::id()]);
dd(\Session::get('loginuid'));
$year_start = strtotime(date("Y") . "-01-01"); // 获取当前的1月份的时间戳
$endThismonth = mktime(23, 59, 59, date('m'), date('t'), date('Y')); //获取当月的时间戳
$devicedata = Device::where('uid','=',Auth::id())->whereBetween('deviceaddtime', [$year_start, $endThismonth])
......
......@@ -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