CMXX - Cronjob

This commit is contained in:
“VeLiTi”
2024-10-04 09:14:48 +02:00
parent 0f87a9b762
commit bc1c5147e9
2 changed files with 41 additions and 3 deletions

View File

@@ -2544,7 +2544,7 @@ function storeMeasurementEquipment($serialnumber){
$stmt = $pdo->prepare($sql);
$stmt->execute([$identification[0],$identification[1]]);
$product_measurements = $stmt->fetchAll(PDO::FETCH_ASSOC);
$product_measurements = $product_measurements[0]['measurement'];
$product_measurements = $product_measurements[0]['measurement']?? '';
if (!empty($product_measurements)){
//Only run when there is a product version found
@@ -2628,13 +2628,13 @@ function storeMeasurementEquipment($serialnumber){
}
else {
//EXIST INSERT
$sql = 'INSERT INTO equipment_data (measurement, , healthindex, equipmentid, historyid) VALUES (?,?,?,?)';
$sql = 'INSERT INTO equipment_data (measurement, healthindex, equipmentid, historyid) VALUES (?,?,?,?)';
}
//EXECUTE QUERY
$stmt = $pdo->prepare($sql);
$stmt->execute([$data, $healthindex, $identification[2],$identification[3]]);
$equipment_data = $stmt->fetchAll(PDO::FETCH_ASSOC);
//$equipment_data = $stmt->fetchAll(PDO::FETCH_ASSOC);
}
}
}

View File

@@ -50,8 +50,46 @@ foreach ($communications as $communication){
// END FIRMWARE COMMUNICATION TO END-USER ++++++++++++++
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
// getUserkey ++++++++++++++
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
$token ='';
$data = json_encode(array("username" => interface_user, "password" => interface_pw), JSON_UNESCAPED_UNICODE);
//Secure data
$payload = generate_payload($data);
//API call
$responses = ioServer('/v1/authorization', $payload);
//Decode Payload
if (!empty($responses)){$responses = decode_payload($responses);}else{$responses = '400';}
if ($responses === 'NOK' || $responses === '400'){
//Not allowed
http_response_code(403);
exit;
}
else {
// Store data in session
$token = $responses->userkey;
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
// close Contracts ++++++++++++++
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
closeContract();
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Machine learning ++++++++++++++
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
$total_measurement = traintotalMeasurement();
$total_results = statisticalAnalyses($total_measurement);
storeMeasurementProduct($total_results, $token);
storeMeasurementEquipment('');
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
// GeoUpdate ++++++++++++++
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
geolocationUpdate($token);
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
// EXIT ++++++++++++++