123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- header("content-type: application/json");
- ini_set('display_errors', 1);
- ini_set('display_startup_errors', 1);
- error_reporting(E_ALL);
- // connect to the mongo database
- $m = new MongoDB\Driver\Manager("mongodb://root:oebb@mongo:27017");
- $radsatz = $_GET['radsatz'];
- $station = $_GET['station'];
- #$radsatz = '098597DL#1';
- #$station = 410;
- $filter = ['overhauls.radsatznummer' => $radsatz];
- $options_status = ['projection' => ['_id' => 0, 'overhauls.radsatznummer' => 1, 'overhauls.process.stationsnummer' => 1, 'overhauls.process.schadcodes.code' => 1]];
- $query_status = new MongoDB\Driver\Query($filter,$options_status);
- $cursor_status = $m->executeQuery('oebb.process_instances',$query_status);
- $codes = array();
- foreach ($cursor_status as $document) {
- foreach ($document as $overhauls) {
- foreach ($overhauls as $overhaul) {
- if($overhaul->radsatznummer == $radsatz) {
- foreach($overhaul->process as $process) {
- if($process->stationsnummer == $station && !empty($process->schadcodes)) {
- foreach($process->schadcodes as $schadcode) {
- array_push($codes, $schadcode->code);
- }
- }
- }
- }
- }
- }
- }
- if(!empty($codes) && in_array("INR", $codes)) {
- $result['innenring_status'] = 'Schlecht';
- } else {
- $result['innenring_status'] = 'Gut';
- }
- echo json_encode($result);
|