CMXX - Asset Health
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user