master
chents 3 years ago
parent acb82e7a8d
commit 221e416007
  1. 7
      src/main/java/org/springblade/modules/business/controller/CommonApiController.java
  2. 2
      src/main/java/org/springblade/modules/business/service/impl/StationHintServiceImpl.java
  3. 9
      src/main/java/org/springblade/modules/business/vo/CurrentCarInfoVo.java
  4. 2
      src/main/java/org/springblade/modules/job/CarInfoTask.java

@ -435,8 +435,6 @@ public class CommonApiController extends BladeController {
resultMap.put("activityData", busLine.getActivity()); resultMap.put("activityData", busLine.getActivity());
resultMap.put("scenicData", busLine.getScenic()); resultMap.put("scenicData", busLine.getScenic());
resultMap.put("speed",info.getSpeed()); resultMap.put("speed",info.getSpeed());
List<imgVo> imgListR = (List<imgVo>) redisTemplate.opsForValue().get("imgList-info");
if (CollectionUtils.isEmpty(imgListR)){
List<BusLine> busLineList = stationHintService.getBusLineByName(nextSite.getSname()); List<BusLine> busLineList = stationHintService.getBusLineByName(nextSite.getSname());
QueryWrapper<PocBusLineImg> queryWrapper = new QueryWrapper<>(); QueryWrapper<PocBusLineImg> queryWrapper = new QueryWrapper<>();
queryWrapper.select("img_url","img_type"); queryWrapper.select("img_url","img_type");
@ -444,12 +442,7 @@ public class CommonApiController extends BladeController {
ArrayList<imgVo> imgList = getImgVos(queryWrapper); ArrayList<imgVo> imgList = getImgVos(queryWrapper);
redisTemplate.opsForValue().set("imgList-info", imgList); redisTemplate.opsForValue().set("imgList-info", imgList);
resultMap.put("imgData", imgList); resultMap.put("imgData", imgList);
//定时任务缓存
carInfoTask.setCarInfo(resultMap);
return R.data(resultMap);
} }
resultMap.put("imgData", imgListR);
}
//定时任务缓存 //定时任务缓存
carInfoTask.setCarInfo(resultMap); carInfoTask.setCarInfo(resultMap);
return R.data(resultMap); return R.data(resultMap);

@ -163,8 +163,6 @@ public class StationHintServiceImpl extends BaseServiceImpl<BusLineMapper,BusLin
QueryWrapper<PocBusLineImg> wrapper = new QueryWrapper<>(); QueryWrapper<PocBusLineImg> wrapper = new QueryWrapper<>();
wrapper.eq("bus_line_id", busLine.getId()); wrapper.eq("bus_line_id", busLine.getId());
proBusLineImgMapper.delete(wrapper); proBusLineImgMapper.delete(wrapper);
//刪除缓存
redisTemplate.delete("imgList-info");
// 插入新的图片列表 // 插入新的图片列表
if (imgList != null && !imgList.isEmpty()) { if (imgList != null && !imgList.isEmpty()) {
for (PocBusLineImg img : imgList) { for (PocBusLineImg img : imgList) {

@ -3,6 +3,8 @@ package org.springblade.modules.business.vo;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.util.List;
import java.util.Map;
/** /**
* @Author: Chents * @Author: Chents
@ -25,5 +27,10 @@ public class CurrentCarInfoVo implements Serializable {
//下一站 //下一站
private String downStation; private String downStation;
//当前车辆距离上一站点百分比 //当前车辆距离上一站点百分比
private double percentage; private double percentage;
//景点信息
private Map<String,Object> infoMap;
private List<String> imgList;
} }

@ -41,7 +41,7 @@ public class CarInfoTask {
System.out.println("======存入实时车辆信息到redis成功========="); System.out.println("======存入实时车辆信息到redis成功=========");
} }
//@Scheduled(cron = "0/1 * * * * ?") @Scheduled(cron = "0/1 * * * * ?")
public void parseCarInfo() { public void parseCarInfo() {
//从redis获取数据 //从redis获取数据
Map<String,Object> carInfoMap = (Map<String,Object> ) redisTemplate.opsForValue().get("current_car_info"); Map<String,Object> carInfoMap = (Map<String,Object> ) redisTemplate.opsForValue().get("current_car_info");

Loading…
Cancel
Save