innenring.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 = 410;
  12. $filter = ['overhauls.radsatznummer' => $radsatz];
  13. $options_status = ['projection' => ['_id' => 0, 'overhauls.radsatznummer' => 1, 'overhauls.process.stationsnummer' => 1, 'overhauls.process.schadcodes.code' => 1]];
  14. $query_status = new MongoDB\Driver\Query($filter,$options_status);
  15. $cursor_status = $m->executeQuery('oebb.process_instances',$query_status);
  16. $codes = array();
  17. foreach ($cursor_status as $document) {
  18. foreach ($document as $overhauls) {
  19. foreach ($overhauls as $overhaul) {
  20. if($overhaul->radsatznummer == $radsatz) {
  21. foreach($overhaul->process as $process) {
  22. if($process->stationsnummer == $station && !empty($process->schadcodes)) {
  23. foreach($process->schadcodes as $schadcode) {
  24. array_push($codes, $schadcode->code);
  25. }
  26. }
  27. }
  28. }
  29. }
  30. }
  31. }
  32. if(!empty($codes) && in_array("INR", $codes)) {
  33. $result['innenring_status'] = 'Schlecht';
  34. } else {
  35. $result['innenring_status'] = 'Gut';
  36. }
  37. echo json_encode($result);