|
|
|
|
@ -77,9 +77,17 @@ public class CarInfoTask { |
|
|
|
|
public void parseCarInfo() { |
|
|
|
|
//从redis获取数据
|
|
|
|
|
CarInfoVO info = null; |
|
|
|
|
WebSocketMessage message = new WebSocketMessage(); |
|
|
|
|
String allCarData = CarInfoCache.getAllCarData(); |
|
|
|
|
JSONObject json = JSON.parseObject(allCarData); |
|
|
|
|
String carNo = CarInfoCache.getPushCarNo(); |
|
|
|
|
HashMap<String, Object> statusMap = new HashMap<>(); |
|
|
|
|
if (Func.isEmpty(carNo)) { |
|
|
|
|
statusMap.put("status","offline"); |
|
|
|
|
message.setContent(JSON.toJSONString(statusMap)); |
|
|
|
|
websocketService.broadcast(message); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
JSONArray carInfoList = json.getJSONArray("bus"); |
|
|
|
|
for (Object o : carInfoList) { |
|
|
|
|
JSONObject carInfo = (JSONObject) o; |
|
|
|
|
@ -88,6 +96,12 @@ public class CarInfoTask { |
|
|
|
|
info = BeanUtil.copy(carInfo, CarInfoVO.class); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (Func.isEmpty(info)) { |
|
|
|
|
statusMap.put("status","offline"); |
|
|
|
|
message.setContent(JSON.toJSONString(statusMap)); |
|
|
|
|
websocketService.broadcast(message); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<SiteInfoVO> siteList = SiteListCache.getSiteList(info.getLinename(), info.getUpordown()); |
|
|
|
|
int nextSiteIdx = Integer.parseInt(info.getInorder()); |
|
|
|
|
@ -209,7 +223,6 @@ public class CarInfoTask { |
|
|
|
|
map.put("data", resultMap); |
|
|
|
|
String messageJson = JSON.toJSONString(map); |
|
|
|
|
|
|
|
|
|
WebSocketMessage message = new WebSocketMessage(); |
|
|
|
|
message.setTitle(WEB); |
|
|
|
|
message.setCode(200); |
|
|
|
|
message.setContent(messageJson); |
|
|
|
|
@ -224,8 +237,13 @@ public class CarInfoTask { |
|
|
|
|
public void getCarSpeed() { |
|
|
|
|
String carNo = CarInfoCache.getPushCarNo(); |
|
|
|
|
CarInfoVO info = carInfoService.getCarInfo(carNo); |
|
|
|
|
WebSocketMessage message = new WebSocketMessage(); |
|
|
|
|
HashMap<String, Object> statusMap = new HashMap<>(); |
|
|
|
|
if (Func.isEmpty(info)) { |
|
|
|
|
throw new RuntimeException("未获取到车辆信息, 请检查车是否已掉线"); |
|
|
|
|
statusMap.put("status","offline"); |
|
|
|
|
message.setContent(JSON.toJSONString(statusMap)); |
|
|
|
|
websocketService.broadcast(message); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Map<String, String> speedMap = new HashMap<>(); |
|
|
|
|
@ -236,7 +254,6 @@ public class CarInfoTask { |
|
|
|
|
dataMap.put("msgType", SPEED); |
|
|
|
|
dataMap.put("data", speedMap); |
|
|
|
|
|
|
|
|
|
WebSocketMessage message = new WebSocketMessage(); |
|
|
|
|
message.setTitle(WEB); |
|
|
|
|
message.setCode(200); |
|
|
|
|
message.setContent(JSON.toJSONString(dataMap)); |
|
|
|
|
|