Commit 4a69e7d0 authored by 冯超鹏's avatar 冯超鹏

地图用户统计

parent f43cfe41
Pipeline #53 failed with stages
......@@ -57,7 +57,7 @@ class swoole extends Command
{
$url = config('public.swoolwebsocketurl');
$por = config('public.swoolwebsocketurlpor');
$this->ws = new \swoole_websocket_server($url, $por); //创建一个端口
$this->ws = new \swoole_websocket_server('0.0.0.0', 9502); //创建一个端口
$this->ws->set(array(
'reactor_num' => 2, //reactor线程数
'worker_num' => 4, //worker进程数
......
......@@ -55,7 +55,7 @@ class swooleMeTcp extends Command
public function start()
{
$url = config('public.swooletcpurl');
$this->tcp = new \swoole_server($url, 9503);
$this->tcp = new \swoole_server('127.0.0.1', 9503);
$this->tcp->addlistener($url, 9504, SWOOLE_SOCK_TCP); // 添加 TCP端口监听
$this->tcp->addlistener($url, 9505, SWOOLE_SOCK_TCP); // 添加 TCP端口监听
$this->tcp->addlistener($url, 9506, SWOOLE_SOCK_TCP); // 添加 TCP端口监听
......
......@@ -22,6 +22,7 @@ use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Resources\Json\ResourceCollection;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Env;
use Illuminate\Support\Facades\Hash;
use Validator;
......@@ -507,30 +508,13 @@ class UserController extends Controller
//返回用户的经纬度
public function userLocation()
{
$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]);
$davicenum = DB::table('BackgroundUser as b')
->leftjoin('device as d','b.id','=','d.uid')
->leftjoin('device_type as t','d.dtype','=','t.tid')
->selectRaw('b.nickname,b.id,b.mapcenter,d.devicenum,COUNT(d.id) AS UserDaviceNum,COUNT(IF(d.devicepolice <> 1, true, null)) AS police')
->groupBy('b.id')
->get()->toArray();
return $this->jsonSuccessData($davicenum );
}
/*
......
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