CMXX - Asset Health

This commit is contained in:
“VeLiTi”
2024-10-01 12:27:40 +02:00
parent 00f7d4f6ba
commit 17df4c7bc1
5 changed files with 115 additions and 0 deletions

View File

@@ -2619,4 +2619,33 @@ function storeMeasurementEquipment($serialnumber){
$equipment_data = $stmt->fetchAll(PDO::FETCH_ASSOC);
}
}
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
// calculatehealthindex of asset ++++++++++
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
function assetHealthIndex($prof,$pem,$healthdata){
$healthindex = 100;
//Allowed check
if (isAllowed('equipment_data',$prof,$pem,'R') === 1 && !empty($healthdata)){
//GET last data
$last_data_measurement = end($healthdata);
foreach (json_decode($last_data_measurement->measurement,true) as $data_measure){
switch ($data_measure['deviation']) {
case 1:
$healthindex = $healthindex - $data_measure['deviation'];
break;
case 2:
$healthindex = $healthindex - ($data_measure['deviation']*2);
break;
case 3:
$healthindex = $healthindex - ($data_measure['deviation']*3);
break;
}
}
}
//Not allowed or no data return 100% health
return $healthindex;
}