eigen.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 = '004277AA#1';
  11. #$station = 140;
  12. $filter = ['overhauls.radsatznummer' => $radsatz];
  13. $options_status = ['projection' => ['_id' => 0, 'overhauls.radsatznummer' => 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. }
  25. }
  26. }
  27. }
  28. }
  29. }
  30. }
  31. echo json_encode($result);