Skip to content

Commit f110d35

Browse files
committed
fix: 公交临时维护数据处理完成
1 parent 178a88a commit f110d35

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

laravel/app/Http/Controllers/Bus/IndexController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public function busLine(Request $request)
142142
}
143143
unset($post['href']);
144144

145-
$data = BusRepository::getInstent()->getLine($aspUrl, $post);
145+
$data = BusRepository::getInstent()->getLineData2($aspUrl, $post);
146146
}
147147

148148
return $this->out(200, $data);

laravel/app/Http/Repository/BusRepository.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ public function getLineData2($path, $get)
278278
return false;
279279

280280
$url = 'http://www.szjt.gov.cn/BusQu/APTSLine.aspx/GetData2';
281-
$param = '{"guid":"'. $get['LineGuid']. '"}';
281+
$param = '{"guid":"'.$get['LineGuid'].'"}';
282282
$header = [
283283
'content-type: Application/json',
284284
'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36',
@@ -292,7 +292,25 @@ public function getLineData2($path, $get)
292292
$res = json_decode($data['content'], true);
293293
if (isset($res['d'])) {
294294
$arr = json_decode($res['d'], true);
295-
return $arr['Document'] ?? [];
295+
// 处理数组
296+
$return = [];
297+
if ($arr['Document']) {
298+
$lName = $arr['Document']['LName'] ?? '';
299+
$lDir = $arr['Document']['LDirection'] ?? '';
300+
$return['to'] = $lName.'-'.$lDir;
301+
302+
foreach ($arr['Document']['StandInfo'] as $item) {
303+
$return['line'][] = [
304+
'stationName' => $item['SName'] ?? '',
305+
'stationCode' => $item['SCode'] ?? '',
306+
'carCode' => $item['BusInfo'] ?? '',
307+
'ArrivalTime' => str_replace('/', '-', $item['InTime'] ?? ''),
308+
'OutTime' => str_replace('/', '-', $item['OutTime'] ?? ''),
309+
'SGuid' => $item['SGuid'] ?? '',
310+
];
311+
}
312+
return $return;
313+
}
296314
}
297315
}
298316
return [];

0 commit comments

Comments
 (0)