|
|
|
|
@ -11,7 +11,6 @@ import org.springblade.common.cache.business.SiteListCache; |
|
|
|
|
import org.springblade.common.constant.BusinessConstant; |
|
|
|
|
import org.springblade.common.utils.CommonUtil; |
|
|
|
|
import org.springblade.common.utils.HttpClientUtils; |
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
import org.springblade.core.tool.utils.BeanUtil; |
|
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
|
import org.springblade.modules.business.entity.BusLine; |
|
|
|
|
@ -23,12 +22,9 @@ import org.springblade.modules.business.vo.imgVo; |
|
|
|
|
import org.springblade.modules.websocket.service.WebsocketService; |
|
|
|
|
import org.springblade.modules.websocket.vo.WebSocketMessage; |
|
|
|
|
import org.springblade.upload.service.IProBusLineImgService; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam; |
|
|
|
|
import springfox.documentation.spring.web.json.Json; |
|
|
|
|
|
|
|
|
|
import java.text.DecimalFormat; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
@ -83,10 +79,9 @@ public class CarInfoTask { |
|
|
|
|
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)); |
|
|
|
|
Map<String, Object> resultMap = new HashMap<>(); |
|
|
|
|
if (Func.isEmpty(info)) { |
|
|
|
|
message.setContent(JSON.toJSONString(initMap(resultMap))); |
|
|
|
|
websocketService.broadcast(message); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
@ -99,8 +94,7 @@ public class CarInfoTask { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (Func.isEmpty(info)) { |
|
|
|
|
statusMap.put("status",OFFLINE); |
|
|
|
|
message.setContent(JSON.toJSONString(statusMap)); |
|
|
|
|
message.setContent(JSON.toJSONString(initMap(resultMap))); |
|
|
|
|
websocketService.broadcast(message); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
@ -191,19 +185,10 @@ public class CarInfoTask { |
|
|
|
|
log.info("================ BusLineCache.getBusLine(" + info.getUpordown() + ", " + nextSite.getSname() + ", " + nextSite.getWeizhi() + ")"); |
|
|
|
|
|
|
|
|
|
// 组织返回数据
|
|
|
|
|
Map<String, Object> resultMap = new HashMap<>(); |
|
|
|
|
resultMap.put("siteData", siteMap); |
|
|
|
|
resultMap.put("catNo", CarInfoCache.getPushCarNo()); |
|
|
|
|
if (Func.isEmpty(busLine)) { |
|
|
|
|
resultMap.put("siteTips", ""); |
|
|
|
|
resultMap.put("articleData", ""); |
|
|
|
|
resultMap.put("activityData", ""); |
|
|
|
|
resultMap.put("scenicData", ""); |
|
|
|
|
resultMap.put("imgData", new ArrayList<>()); |
|
|
|
|
resultMap.put("busNo", ""); |
|
|
|
|
resultMap.put("speed", ""); |
|
|
|
|
resultMap.put("weidu", ""); |
|
|
|
|
resultMap.put("jingdu", ""); |
|
|
|
|
initMap(resultMap); |
|
|
|
|
} else { |
|
|
|
|
resultMap.put("siteTips", busLine.getTips()); |
|
|
|
|
resultMap.put("articleData", busLine.getActicle()); |
|
|
|
|
@ -232,6 +217,19 @@ public class CarInfoTask { |
|
|
|
|
websocketService.broadcast(message); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private Map<String, Object> initMap(Map<String, Object> resultMap) { |
|
|
|
|
resultMap.put("siteTips", ""); |
|
|
|
|
resultMap.put("articleData", ""); |
|
|
|
|
resultMap.put("activityData", ""); |
|
|
|
|
resultMap.put("scenicData", ""); |
|
|
|
|
resultMap.put("imgData", new ArrayList<>()); |
|
|
|
|
resultMap.put("busNo", ""); |
|
|
|
|
resultMap.put("speed", ""); |
|
|
|
|
resultMap.put("weidu", ""); |
|
|
|
|
resultMap.put("jingdu", ""); |
|
|
|
|
return resultMap; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 每秒向web推送当前推流车辆的车速和推流状态信息 |
|
|
|
|
*/ |
|
|
|
|
|