Merge branch 'feature/ProvinceReport' into 'develop'
Feature/province report See merge request witel-back-end/crm!16
This commit is contained in:
32
app/Console/Commands/SendCallStatsReportCommand.php
Normal file
32
app/Console/Commands/SendCallStatsReportCommand.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Services\Commands\SendCallStatsReportService;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class SendCallStatsReportCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'report:send-call-stats';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'gather all call stats report and send them to the center';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(SendCallStatsReportService $service): void
|
||||
{
|
||||
$service->execute();
|
||||
$this->info('Done!');
|
||||
}
|
||||
}
|
||||
32
app/Console/Commands/SendKeypressStatsCommand.php
Normal file
32
app/Console/Commands/SendKeypressStatsCommand.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Services\Commands\SendKeypressStatsService;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class SendKeypressStatsCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'report:send-keypress-stats';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'gather all keypress stats report and send them to the center';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(SendKeypressStatsService $service)
|
||||
{
|
||||
$service->execute();
|
||||
$this->info('Done!');
|
||||
}
|
||||
}
|
||||
32
app/Console/Commands/SendPeopleMessageStatsCommand.php
Normal file
32
app/Console/Commands/SendPeopleMessageStatsCommand.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Services\Commands\SendPeopleMessageStatsService;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class SendPeopleMessageStatsCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'report:send-people-message-stats';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'gather all people message stats report and send them to the center';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(SendPeopleMessageStatsService $service): void
|
||||
{
|
||||
$service->execute();
|
||||
$this->info('Done!');
|
||||
}
|
||||
}
|
||||
32
app/Console/Commands/SendSystemMessageStatsCommand.php
Normal file
32
app/Console/Commands/SendSystemMessageStatsCommand.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Services\Commands\SendSystemMessageStatsService;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class SendSystemMessageStatsCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'report:send-system-message-stats';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'gather all system message stats report and send them to the center';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(SendSystemMessageStatsService $service): void
|
||||
{
|
||||
$service->execute();
|
||||
$this->info('Done!');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\ProvinceDashboard\OperatorDialogues;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Dashboard\Province\OperatorDialogues\DataTableService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class OperatorController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index(Request $request, DataTableService $dataTableService): JsonResponse
|
||||
{
|
||||
return response()->json($dataTableService->index($request));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function download(Request $request, string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function excel(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,8 @@
|
||||
namespace App\Http\Controllers\ProvinceDashboard\PeopleMessages;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Dashboard\Province\PeopleMessages\DataTableService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class SupervisorController extends Controller
|
||||
@@ -10,17 +12,14 @@ class SupervisorController extends Controller
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
public function index(Request $request, DataTableService $dataTableService): JsonResponse
|
||||
{
|
||||
//
|
||||
return response()->json($dataTableService->index($request));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
public function excel()
|
||||
{
|
||||
//
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -30,28 +29,4 @@ class SupervisorController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
36
app/Http/Controllers/ProvinceDashboard/ReportController.php
Normal file
36
app/Http/Controllers/ProvinceDashboard/ReportController.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\ProvinceDashboard;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Dashboard\Province\ReportService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ReportController extends Controller
|
||||
{
|
||||
public function cumulative(Request $request, ReportService $reportService): JsonResponse
|
||||
{
|
||||
return response()->json($reportService->cumulative($request));
|
||||
}
|
||||
|
||||
public function peopleMessages(Request $request, ReportService $reportService): JsonResponse
|
||||
{
|
||||
return response()->json($reportService->peopleMessages($request));
|
||||
}
|
||||
|
||||
public function detailedLogs(Request $request, ReportService $reportService): JsonResponse
|
||||
{
|
||||
return response()->json($reportService->detailedLogs($request));
|
||||
}
|
||||
|
||||
public function operatorPerformanceDaily(Request $request, ReportService $reportService): JsonResponse
|
||||
{
|
||||
return response()->json($reportService->operatorPerformanceDaily($request));
|
||||
}
|
||||
|
||||
public function operatorPerformanceTotal(Request $request, ReportService $reportService): JsonResponse
|
||||
{
|
||||
return response()->json($reportService->operatorPerformanceTotal($request));
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\OperatorDialogueRatingFactory;
|
||||
use Database\Factories\OperatorDialogueFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class OperatorDialogueRating extends Model
|
||||
class OperatorDialogue extends Model
|
||||
{
|
||||
/** @use HasFactory<OperatorDialogueRatingFactory> */
|
||||
/** @use HasFactory<OperatorDialogueFactory> */
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = [];
|
||||
91
app/Services/Commands/SendCallStatsReportService.php
Normal file
91
app/Services/Commands/SendCallStatsReportService.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Commands;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Http\Client\ConnectionException;
|
||||
use Illuminate\Http\Client\RequestException;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class SendCallStatsReportService
|
||||
{
|
||||
private string $url;
|
||||
private string $channelName;
|
||||
private string $provinceId;
|
||||
private string $provinceName;
|
||||
public function __construct()
|
||||
{
|
||||
$this->url = config('ProvinceInfo.center_ip');
|
||||
$this->channelName = 'send_call_stats_report';
|
||||
$this->provinceId = config('ProvinceInfo.id');
|
||||
$this->provinceName = config('ProvinceInfo.name');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ConnectionException
|
||||
* @throws RequestException
|
||||
*/
|
||||
public function execute(): void
|
||||
{
|
||||
try
|
||||
{
|
||||
$data = $this->prepare();
|
||||
Http::post($this->url, $data)->throw();
|
||||
Log::channel($this->channelName)->info(SendCallStatsReportService::class, [$this->provinceName, array_sum($data), 'successful']);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
Log::channel($this->channelName)->error(SendCallStatsReportService::class, [$e->getMessage()]);
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
private function prepare(): array
|
||||
{
|
||||
$query = "SELECT
|
||||
{$this->provinceId} AS province_id,
|
||||
'{$this->provinceName}' AS province_name,
|
||||
date,
|
||||
total,
|
||||
route_to_teh4,
|
||||
route_to_teh5,
|
||||
route_to_os4,
|
||||
route_to_os5,
|
||||
answered,
|
||||
missed,
|
||||
answered_over10,
|
||||
dnd,
|
||||
transferred,
|
||||
talked_to_operator,
|
||||
c_agency,
|
||||
c_agency_driver,
|
||||
average_calls_time,
|
||||
(talked_to_operator - (answered + missed) + c_agency + c_agency_driver) AS fails
|
||||
FROM (
|
||||
SELECT
|
||||
DATE(calldate) AS date,
|
||||
COUNT(CASE WHEN recordingfile = '' OR recordingfile LIKE 'q-%' THEN 1 END) AS total,
|
||||
COUNT(CASE WHEN lastdata = 'IAX2/serverpeer/100' THEN 1 END) AS route_to_teh4,
|
||||
COUNT(CASE WHEN lastdata = 'IAX2/serverpeer/200' THEN 1 END) AS route_to_teh5,
|
||||
COUNT(CASE WHEN dst = '500' THEN 1 END) AS route_to_os4,
|
||||
COUNT(CASE WHEN dst = '600' THEN 1 END) AS route_to_os5,
|
||||
COUNT(CASE WHEN dcontext = 'from-internal' AND disposition = 'ANSWERED' AND dst BETWEEN 101 AND 104 THEN 1 END) AS answered,
|
||||
COUNT(CASE WHEN dcontext = 'from-internal' AND disposition = 'NO ANSWER' AND dst BETWEEN 101 AND 104 AND duration > 14 THEN 1 END) AS missed,
|
||||
COUNT(CASE WHEN dcontext = 'from-internal' AND disposition = 'ANSWERED' AND dst BETWEEN 101 AND 104 AND billsec > 9 THEN 1 END) AS answered_over10,
|
||||
COUNT(CASE WHEN lastapp = 'Busy' THEN 1 END) AS dnd,
|
||||
COUNT(CASE WHEN dst BETWEEN 502 AND 599 THEN 1 END) AS transferred,
|
||||
COUNT(CASE WHEN disposition <> 'BUSY' AND dst BETWEEN 101 AND 105 THEN 1 END) AS talked_to_operator,
|
||||
COUNT(CASE WHEN lastdata LIKE '%custom/agency%' THEN 1 END) AS c_agency,
|
||||
COUNT(CASE WHEN lastdata LIKE '%custom/agency-driver%' THEN 1 END) AS c_agency_driver,
|
||||
AVG(CASE WHEN dcontext = 'from-internal' AND disposition = 'ANSWERED' THEN billsec END) AS average_calls_time
|
||||
FROM asteriskcdrdb.cdr
|
||||
WHERE calldate >= NOW() - INTERVAL 3 DAY
|
||||
GROUP BY date
|
||||
)
|
||||
WHERE date >= DATE(NOW() - INTERVAL 3 DAY)";
|
||||
|
||||
return DB::select($query);
|
||||
}
|
||||
}
|
||||
70
app/Services/Commands/SendKeypressStatsService.php
Normal file
70
app/Services/Commands/SendKeypressStatsService.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Commands;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Http\Client\ConnectionException;
|
||||
use Illuminate\Http\Client\RequestException;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class SendKeypressStatsService
|
||||
{
|
||||
private string $url;
|
||||
private string $channelName;
|
||||
private string $provinceId;
|
||||
private string $provinceName;
|
||||
public function __construct()
|
||||
{
|
||||
$this->url = config('ProvinceInfo.center_ip');
|
||||
$this->channelName = 'send_keypress_stats_report';
|
||||
$this->provinceId = config('ProvinceInfo.id');
|
||||
$this->provinceName = config('ProvinceInfo.name');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ConnectionException
|
||||
* @throws RequestException
|
||||
*/
|
||||
public function execute(): void
|
||||
{
|
||||
try
|
||||
{
|
||||
$data = $this->prepare();
|
||||
Http::post($this->url, $data)->throw();
|
||||
Log::channel($this->channelName)->info(SendKeypressStatsService::class, [$this->provinceName, array_sum($data), 'successful']);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
Log::channel($this->channelName)->error(SendKeypressStatsService::class, [$e->getMessage()]);
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
private function prepare(): array
|
||||
{
|
||||
$query = "SELECT
|
||||
{$this->provinceId} AS province_id,
|
||||
'{$this->provinceName}' AS province_name,
|
||||
DATE(cdate) AS date,
|
||||
COUNT(CASE WHEN (ctype=-1 AND channel=0) THEN 1 END) AS total,
|
||||
COUNT(CASE WHEN (ctype=1 AND channel=0) THEN 1 END) AS key1,
|
||||
COUNT(CASE WHEN (ctype=2 AND channel=0) THEN 1 END) AS key2,
|
||||
COUNT(CASE WHEN (ctype=3 AND channel=0) THEN 1 END) AS key3,
|
||||
COUNT(CASE WHEN (ctype=4 AND channel=0) THEN 1 END) AS key4,
|
||||
COUNT(CASE WHEN (ctype=5 AND channel=0) THEN 1 END) AS key5,
|
||||
COUNT(CASE WHEN (ctype=6 AND channel=0) THEN 1 END) AS key6,
|
||||
COUNT(CASE WHEN (ctype=9 AND channel=0) THEN 1 END) AS key9,
|
||||
COUNT(CASE WHEN (ctype=1 AND channel=4) THEN 1 END) AS key4_1,
|
||||
COUNT(CASE WHEN (ctype=2 AND channel=4) THEN 1 END) AS key4_2,
|
||||
COUNT(CASE WHEN (ctype=1 AND channel=5) THEN 1 END) AS key5_1,
|
||||
COUNT(CASE WHEN (ctype=2 AND channel=5) THEN 1 END) AS key5_2,
|
||||
COUNT(CASE WHEN (ctype=1 AND channel=2) THEN 1 END) AS key2_1,
|
||||
COUNT(CASE WHEN (ctype=2 AND channel=2) THEN 1 END) AS key2_2,
|
||||
COUNT(CASE WHEN (ctype=3 AND channel=2) THEN 1 END) AS key2_3
|
||||
FROM report WHERE DATE(cdate)> DATE(NOW()- INTERVAL 3 day) GROUP BY date ORDER BY date DESC";
|
||||
|
||||
return DB::select($query);
|
||||
}
|
||||
}
|
||||
64
app/Services/Commands/SendPeopleMessageStatsService.php
Normal file
64
app/Services/Commands/SendPeopleMessageStatsService.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Commands;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Http\Client\ConnectionException;
|
||||
use Illuminate\Http\Client\RequestException;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class SendPeopleMessageStatsService
|
||||
{
|
||||
private string $url;
|
||||
private string $channelName;
|
||||
private string $provinceId;
|
||||
private string $provinceName;
|
||||
public function __construct()
|
||||
{
|
||||
$this->url = config('ProvinceInfo.center_ip');
|
||||
$this->channelName = 'send_people_message_stats_report';
|
||||
$this->provinceId = config('ProvinceInfo.id');
|
||||
$this->provinceName = config('ProvinceInfo.name');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ConnectionException
|
||||
* @throws RequestException
|
||||
*/
|
||||
public function execute(): void
|
||||
{
|
||||
try
|
||||
{
|
||||
$data = $this->prepare();
|
||||
Http::post($this->url, $data)->throw();
|
||||
Log::channel($this->channelName)->info(SendPeopleMessageStatsService::class, [$this->provinceName, array_sum($data), 'successful']);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
Log::channel($this->channelName)->error(SendPeopleMessageStatsService::class, [$e->getMessage()]);
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
private function prepare(): array
|
||||
{
|
||||
$query = "SELECT
|
||||
{$this->provinceId} AS province_id,
|
||||
'{$this->provinceName}' AS province_name,
|
||||
date,
|
||||
COUNT(CASE WHEN action_id=1 THEN 1 END) AS action1,
|
||||
COUNT(CASE WHEN action_id=2 THEN 1 END) AS action2,
|
||||
COUNT(CASE WHEN action_id=3 THEN 1 END) AS action3,
|
||||
COUNT(CASE WHEN action_id=4 THEN 1 END) AS action4,
|
||||
COUNT(CASE WHEN action_id=5 THEN 1 END) AS action5,
|
||||
COUNT(CASE WHEN is_listen=1 THEN 1 END) AS listens,
|
||||
COUNT(CASE WHEN is_listen=0 THEN 1 END) AS not_listens,
|
||||
COUNT(*) AS total,
|
||||
AVG(review_duration) as review_average
|
||||
FROM system_messages GROUP BY date ORDER BY date DESC LIMIT 3";
|
||||
|
||||
return DB::select($query);
|
||||
}
|
||||
}
|
||||
59
app/Services/Commands/SendSystemMessageStatsService.php
Normal file
59
app/Services/Commands/SendSystemMessageStatsService.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Commands;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Http\Client\ConnectionException;
|
||||
use Illuminate\Http\Client\RequestException;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class SendSystemMessageStatsService
|
||||
{
|
||||
private string $url;
|
||||
private string $channelName;
|
||||
private string $provinceId;
|
||||
private string $provinceName;
|
||||
public function __construct()
|
||||
{
|
||||
$this->url = config('ProvinceInfo.center_ip');
|
||||
$this->channelName = 'send_system_message_stats_report';
|
||||
$this->provinceId = config('ProvinceInfo.id');
|
||||
$this->provinceName = config('ProvinceInfo.name');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ConnectionException
|
||||
* @throws RequestException
|
||||
*/
|
||||
public function execute(): void
|
||||
{
|
||||
try
|
||||
{
|
||||
$data = $this->prepare();
|
||||
Http::post($this->url, $data)->throw();
|
||||
Log::channel($this->channelName)->info(SendSystemMessageStatsService::class, [$this->provinceName, array_sum($data), 'successful']);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
Log::channel($this->channelName)->error(SendSystemMessageStatsService::class, [$e->getMessage()]);
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
private function prepare(): array
|
||||
{
|
||||
$query = "SELECT
|
||||
{$this->provinceId} AS province_id,
|
||||
'{$this->provinceName}' AS province_name,
|
||||
date,
|
||||
COUNT(CASE WHEN message_quality=1 THEN 1 END) AS message_quality_ok,
|
||||
COUNT(CASE WHEN message_quality=0 THEN 1 END) AS message_quality_nok,
|
||||
COUNT(CASE WHEN format_quality=1 THEN 1 END) AS message_format_ok,
|
||||
COUNT(CASE WHEN format_quality=0 THEN 1 END) AS message_format_nok,
|
||||
FROM system_messages GROUP BY date ORDER BY date DESC LIMIT 5";
|
||||
|
||||
return DB::select($query);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Dashboard\Province\OperatorDialogues;
|
||||
|
||||
use App\Facades\DataTable\DataTableFacade;
|
||||
use App\Models\OperatorDialogue;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class DataTableService
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$query = DB::table('asteriskcdrdb.cdr')
|
||||
->leftJoin('crm_db.voice_experts', 'asteriskcdrdb.cdr.uniqueid', '=', 'crm_db.operator_dialogues.cdr_unique_id')
|
||||
->where('dst', '<>', '')
|
||||
->where('lastapp', '=', 'Dial')
|
||||
->where('duration', '>', 0)
|
||||
->where('recordingfile', '<>', '')
|
||||
->select('*');
|
||||
|
||||
return DataTableFacade::run(
|
||||
$query,
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
);
|
||||
}
|
||||
}
|
||||
157
app/Services/Dashboard/Province/ReportService.php
Normal file
157
app/Services/Dashboard/Province/ReportService.php
Normal file
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Dashboard\Province;
|
||||
|
||||
use App\Facades\DataTable\DataTableFacade;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ReportService
|
||||
{
|
||||
public function cumulative(Request $request)
|
||||
{
|
||||
$query = DB::table('asteriskcdrdb.cdr')
|
||||
->selectRaw("
|
||||
DATE(calldate) AS d,
|
||||
COUNT(CASE WHEN (recordingfile = '' OR recordingfile LIKE 'q-%') THEN 1 END) AS c_all,
|
||||
COUNT(CASE WHEN lastdata = 'IAX2/serverpeer/100' THEN 1 END) AS c_teh4,
|
||||
COUNT(CASE WHEN lastdata = 'IAX2/242serverpeer/200' THEN 1 END) AS c_teh5,
|
||||
COUNT(CASE WHEN dst = '500' THEN 1 END) AS c_os4,
|
||||
COUNT(CASE WHEN dst = '600' THEN 1 END) AS c_os5,
|
||||
COUNT(CASE WHEN dcontext = 'from-internal' AND disposition = 'ANSWERED' AND dst BETWEEN 101 AND 104 THEN 1 END) AS c_ok,
|
||||
COUNT(CASE WHEN dcontext = 'from-internal' AND disposition = 'NO ANSWER' AND dst BETWEEN 101 AND 104 AND duration > 14 THEN 1 END) AS c_nok,
|
||||
COUNT(CASE WHEN dcontext = 'from-internal' AND disposition = 'ANSWERED' AND dst BETWEEN 101 AND 104 AND billsec > 9 THEN 1 END) AS c_b10,
|
||||
COUNT(CASE WHEN lastapp = 'Busy' THEN 1 END) AS c_dnd,
|
||||
COUNT(CASE WHEN dst BETWEEN 502 AND 599 THEN 1 END) AS c_trans,
|
||||
COUNT(CASE WHEN disposition <> 'BUSY' AND dst BETWEEN 101 AND 105 THEN 1 END) AS ch_all,
|
||||
AVG(CASE WHEN dcontext = 'from-internal' AND disposition = 'ANSWERED' THEN billsec END) AS c_avg
|
||||
");
|
||||
// ->whereBetween('calldate', [$from, $to]) // use Carbon or date strings
|
||||
// ->groupBy(DB::raw('DATE(calldate)'))
|
||||
// ->orderByDesc(DB::raw('DATE(calldate)'))
|
||||
// ->get();
|
||||
|
||||
return DataTableFacade::run(
|
||||
$query,
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
allowedGroupBy: ['d']
|
||||
);
|
||||
}
|
||||
|
||||
public function peopleMessages(Request $request)
|
||||
{
|
||||
$query = DB::table('people_messages')
|
||||
->selectRaw('
|
||||
COUNT(CASE WHEN is_listen = 1 THEN 1 END) AS c_l,
|
||||
COUNT(CASE WHEN is_listen = 0 THEN 1 END) AS c_nl
|
||||
');
|
||||
// ->whereBetween('date', [$date_from, $date_to])
|
||||
// ->first();
|
||||
|
||||
return DataTableFacade::run(
|
||||
$query,
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
);
|
||||
}
|
||||
|
||||
public function detailedLogs(Request $request)
|
||||
{
|
||||
$query = DB::table('asteriskcdrdb.cdr')
|
||||
->where('recordingfile', '<>', '');
|
||||
// ->whereBetween('calldate', ["$date_from $time_from", "$date_to $time_to"])
|
||||
// ->when($cid, function ($query, $cid) {
|
||||
// return $query->where('src', 'like', "%{$cid}%");
|
||||
// })
|
||||
// ->when($c_op, function ($query, $c_op) {
|
||||
// return $query->where('dst', $c_op);
|
||||
// }, function ($query) {
|
||||
// return $query->whereBetween('dst', [100, 110]);
|
||||
// })
|
||||
// ->orderByDesc('calldate');
|
||||
|
||||
return DataTableFacade::run(
|
||||
$query,
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
);
|
||||
}
|
||||
|
||||
public function operatorPerformanceDaily(Request $request)
|
||||
{
|
||||
$query = DB::table('asteriskcdrdb.cdr')
|
||||
->selectRaw("
|
||||
SELECT
|
||||
*
|
||||
(ch_all - (c_ok + c_nok)) AS c_fail
|
||||
FROM (
|
||||
SELECT
|
||||
DATE(calldate) AS d,
|
||||
dst,
|
||||
COUNT(CASE WHEN dcontext = 'from-internal' AND disposition = 'ANSWERED' AND dst BETWEEN 101 AND 104 THEN 1 END) AS c_ok,
|
||||
COUNT(CASE WHEN dcontext = 'from-internal' AND disposition = 'NO ANSWER' AND dst BETWEEN 101 AND 104 AND duration > 14 THEN 1 END) AS c_nok,
|
||||
COUNT(CASE WHEN dcontext = 'from-internal' AND disposition = 'ANSWERED' AND dst BETWEEN 101 AND 104 AND billsec > 9 THEN 1 END) AS c_b10,
|
||||
COUNT(CASE WHEN lastapp = 'Busy' THEN 1 END) AS c_dnd,
|
||||
COUNT(CASE WHEN dst BETWEEN 502 AND 599 THEN 1 END) AS c_trans,
|
||||
COUNT(CASE WHEN disposition <> 'BUSY' AND dst BETWEEN 101 AND 105 THEN 1 END) AS ch_all
|
||||
FROM asteriskcdrdb.cdr
|
||||
WHERE dst BETWEEN 101 AND 105 AND calldate BETWEEN ? AND ?
|
||||
GROUP BY d, dst
|
||||
ORDER BY d, dst
|
||||
);
|
||||
");
|
||||
// ->whereBetween('calldate', ["$date_from $time_from", "$date_to $time_to"])
|
||||
// ->when($cid, function ($query, $cid) {
|
||||
// return $query->where('src', 'like', "%{$cid}%");
|
||||
// })
|
||||
// ->when($c_op, function ($query, $c_op) {
|
||||
// return $query->where('dst', $c_op);
|
||||
// }, function ($query) {
|
||||
// return $query->whereBetween('dst', [100, 110]);
|
||||
// })
|
||||
// ->orderByDesc('calldate');
|
||||
|
||||
return DataTableFacade::run(
|
||||
$query,
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
);
|
||||
}
|
||||
|
||||
public function operatorPerformanceTotal(Request $request)
|
||||
{
|
||||
$query = DB::table('asteriskcdrdb.cdr')
|
||||
->selectRaw("
|
||||
SELECT
|
||||
*
|
||||
(ch_all - (c_ok + c_nok)) AS c_fail
|
||||
FROM (
|
||||
SELECT
|
||||
DATE(calldate) AS d,
|
||||
dst,
|
||||
COUNT(CASE WHEN dcontext = 'from-internal' AND disposition = 'ANSWERED' AND dst BETWEEN 101 AND 104 THEN 1 END) AS c_ok,
|
||||
COUNT(CASE WHEN dcontext = 'from-internal' AND disposition = 'NO ANSWER' AND dst BETWEEN 101 AND 104 AND duration > 14 THEN 1 END) AS c_nok,
|
||||
COUNT(CASE WHEN dcontext = 'from-internal' AND disposition = 'ANSWERED' AND dst BETWEEN 101 AND 104 AND billsec > 9 THEN 1 END) AS c_b10,
|
||||
COUNT(CASE WHEN lastapp = 'Busy' THEN 1 END) AS c_dnd,
|
||||
COUNT(CASE WHEN dst BETWEEN 502 AND 599 THEN 1 END) AS c_trans,
|
||||
COUNT(CASE WHEN disposition <> 'BUSY' AND dst BETWEEN 101 AND 105 THEN 1 END) AS ch_all
|
||||
FROM asteriskcdrdb.cdr
|
||||
WHERE dst BETWEEN 101 AND 105 AND calldate BETWEEN ? AND ?
|
||||
GROUP dst
|
||||
ORDER dst
|
||||
);
|
||||
");
|
||||
|
||||
return DataTableFacade::run(
|
||||
$query,
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
);
|
||||
}
|
||||
}
|
||||
8
config/ProvinceInfo.php
Normal file
8
config/ProvinceInfo.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'ip' => env('PROVINCE_INFO_IP'),
|
||||
'name' => env('PROVINCE_INFO_NAME'),
|
||||
'id' => env('PROVINCE_INFO_ID'),
|
||||
'center_ip' => env('PROVINCE_INFO_CENTER_IP'),
|
||||
];
|
||||
@@ -127,6 +127,29 @@ return [
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
],
|
||||
|
||||
'send_call_stats_report' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/send_call_stats_report.log'),
|
||||
'level' => 'debug',
|
||||
],
|
||||
|
||||
'send_keypress_stats_report' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/send_keypress_stats_report.log'),
|
||||
'level' => 'debug',
|
||||
],
|
||||
|
||||
'send_people_message_stats_report' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/send_people_message_stats_report.log'),
|
||||
'level' => 'debug',
|
||||
],
|
||||
|
||||
'send_system_message_stats_report' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/send_system_message_stats_report.log'),
|
||||
'level' => 'debug',
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
@@ -5,9 +5,9 @@ namespace Database\Factories;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\OperatorDialogueRating>
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\OperatorDialogue>
|
||||
*/
|
||||
class OperatorDialogueRatingFactory extends Factory
|
||||
class OperatorDialogueFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
@@ -11,11 +11,11 @@ return new class extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('operator_dialogue_ratings', function (Blueprint $table) {
|
||||
Schema::create('operator_dialogues', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('cdr_unique_id');
|
||||
$table->dateTime('date');
|
||||
$table->foreignId('expert_id')->constrained('users');
|
||||
$table->foreignId('supervisor_id')->constrained('users');
|
||||
$table->boolean('is_listen')->default(false);
|
||||
$table->boolean('is_good');
|
||||
$table->string('description')->nullable();
|
||||
@@ -28,6 +28,6 @@ return new class extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('operator_dialogue_ratings');
|
||||
Schema::dropIfExists('operator_dialogues');
|
||||
}
|
||||
};
|
||||
@@ -5,7 +5,7 @@ namespace Database\Seeders;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class OperatorDialogueRatingSeeder extends Seeder
|
||||
class OperatorDialogueSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
@@ -6,3 +6,8 @@ use Illuminate\Support\Facades\Artisan;
|
||||
Artisan::command('inspire', function () {
|
||||
$this->comment(Inspiring::quote());
|
||||
})->purpose('Display an inspiring quote');
|
||||
|
||||
Schedule::command('report:send-call-stats')->everyTwoMinutes();
|
||||
Schedule::command('report:send-system-message-stats')->everyThreeMinutes();
|
||||
Schedule::command('report:send-keypress-stats')->everyFourMinutes();
|
||||
Schedule::command('report:send-people-message-stats')->everyFiveMinutes();
|
||||
|
||||
Reference in New Issue
Block a user