aufpressen.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. header("content-type: application/json");
  3. ini_set('display_errors', 1);
  4. ini_set('display_startup_errors', 1);
  5. error_reporting(E_ALL);
  6. // connect to the mongo database
  7. $m = new MongoDB\Driver\Manager("mongodb://root:oebb@mongo:27017");
  8. $radsatz = $_GET['radsatz'];
  9. #$station = $_GET['station'];
  10. #$radsatz = '098597DL#1';
  11. $station = 510;
  12. $filter = ['overhauls.radsatznummer' => $radsatz];
  13. $options_status = ['projection' => ['_id' => 0, 'overhauls.radsatznummer' => 1, 'overhauls.process.taetigkeiten.pruefungen' => 1, 'overhauls.process.stationsnummer' => 1, 'overhauls.process.taetigkeiten.name' => 1, 'overhauls.process.taetigkeiten.status' => 1 ]];
  14. $query_status = new MongoDB\Driver\Query($filter,$options_status);
  15. $cursor_status = $m->executeQuery('oebb.process_instances',$query_status);
  16. foreach ($cursor_status as $document) {
  17. foreach ($document as $overhauls) {
  18. foreach ($overhauls as $overhaul) {
  19. if($overhaul->radsatznummer == $radsatz) {
  20. foreach($overhaul->process as $process) {
  21. if($process->stationsnummer == $station) {
  22. foreach($process->taetigkeiten as $taetigkeit) {
  23. #$result['status']=$taetigkeit->status;
  24. if(property_exists($taetigkeit, 'name') && strpos($taetigkeit->name, 'AUF') !== false) {
  25. $result['status']=$taetigkeit->pruefungen;
  26. foreach($taetigkeit->pruefungen as $pruefung) {
  27. if($pruefung->name == "presskrafdiagram_min") {
  28. $min = $pruefung->value_int;
  29. } elseif ($pruefung->name == "presskrafdiagram_max") {
  30. $max = $pruefung->value_int;
  31. } elseif ($pruefung->name == "presskrafdiagram_wert") {
  32. $value = $pruefung->value_int;
  33. }
  34. }
  35. if($value < $min || $value > $max) {
  36. $result["presskraftdiagramm"] = "Schlecht";
  37. break;
  38. } else {
  39. $result["presskraftdiagramm"] = "Gut";
  40. }
  41. }
  42. }
  43. }
  44. }
  45. }
  46. }
  47. }
  48. }
  49. echo json_encode($result);