@@ -230,7 +230,12 @@ public function getListV2($line, $refresh = false)
230
230
if ($ refresh ) {
231
231
Cache::forget ('line_name: ' .$ line );
232
232
}
233
- return Cache::remember ('line_name: ' .$ line , 3600 * 24 * 30 , function () use ($ line ) {
233
+
234
+ $ return = Cache::get ('line_name: ' .$ line );
235
+ if ($ return ) {
236
+ return $ return ;
237
+ }
238
+ try {
234
239
// 新版本直接调用接口
235
240
$ url = 'http://www.szjt.gov.cn/BusQu/APTSLine.aspx/GetData ' ;
236
241
$ param = '{"num":" ' .$ line .'"} ' ;
@@ -252,13 +257,13 @@ public function getListV2($line, $refresh = false)
252
257
if ($ arr ['Document ' ]) {
253
258
foreach ($ arr ['Document ' ]['LineInfo ' ] as $ item ) {
254
259
// "Guid": "921f91ad-757e-49d6-86ae-8e5f205117be",
255
- // "LName": "快线1号",
256
- // "LDirection": "星塘公交中心首末站",
257
- // "LFStdFTime": "06:00:00",
258
- // "LFStdETime": "21:00:00",
259
- // "LFStdName": "木渎公交换乘枢纽站",
260
- // "LEStdName": "星塘公交中心",
261
- // "LineType": ""
260
+ // "LName": "快线1号",
261
+ // "LDirection": "星塘公交中心首末站",
262
+ // "LFStdFTime": "06:00:00",
263
+ // "LFStdETime": "21:00:00",
264
+ // "LFStdName": "木渎公交换乘枢纽站",
265
+ // "LEStdName": "星塘公交中心",
266
+ // "LineType": ""
262
267
$ fromTo = $ item ['LDirection ' ] ?? '' ;
263
268
$ bus = $ item ['LName ' ] ?? '' ;
264
269
$ Guid = $ item ['Guid ' ] ?? '' ;
@@ -272,10 +277,17 @@ public function getListV2($line, $refresh = false)
272
277
'line_type ' => $ item ['LineType ' ] ?? '' ,
273
278
];
274
279
}
280
+ cache (['line_name: ' .$ line => $ return ], 3600 * 24 * 30 );
275
281
return $ return ;
276
282
}
277
283
}
278
284
}
285
+ } catch (\Exception $ e ) {
286
+ return [];
287
+ }
288
+ return Cache::remember ('line_name: ' .$ line , 3600 * 24 * 30 , function () use ($ line ) {
289
+
290
+ return [];
279
291
});
280
292
}
281
293
0 commit comments