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

地图用户统计

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