added new fcp statistics

This commit is contained in:
2025-09-12 09:18:15 +02:00
parent 900b9232b4
commit 8e6ab15fef
5 changed files with 218 additions and 16 deletions
@@ -136,14 +136,10 @@ class ADBRimoFcpController extends TTCrud {
public function getAllFCPsAction() {
$input = json_decode(file_get_contents('php://input'), true);
$fcpList = ADBRimoFcp::getAll();
$fcpData = array_map(function ($fcp) {
return [
'id' => $fcp->id,
// 'rimo_ex_state' => $fcp->rimo_ex_state,
// 'rimo_op_state' => $fcp->rimo_op_state,
'gps_lat' => $fcp->gps_lat,
'gps_long' => $fcp->gps_long
];
@@ -151,4 +147,20 @@ class ADBRimoFcpController extends TTCrud {
self::returnJson(['success' => true, 'data' => $fcpData]);
}
public function getRimoFcpStatsAction() {
$stats = ADBRimoFcp::getRimoFcpStatistics();
if (!empty($this->postData->fcp_ids)) {
$fcpIds = (array) $this->postData->fcp_ids;
$stats = array_filter($stats, fn($item) => in_array($item['fcp_id'], $fcpIds));
}
foreach ($stats as &$item)
if (isset($item['counts_by_rimo_type']) && is_string($item['counts_by_rimo_type']))
$item['counts_by_rimo_type'] = json_decode($item['counts_by_rimo_type']);
unset($item);
self::returnJson(array_values($stats));
}
}