Compare commits

..

No commits in common. "2186c581221fb568a46e53efccdf6f93db91a2e2" and "e2897c4bb7c3856f85e49acc3aa79f7dbe54be9f" have entirely different histories.

1 changed files with 9 additions and 12 deletions

View File

@ -25,12 +25,6 @@ import org.springframework.web.bind.annotation.RequestParam;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/** /**
* *
* @author liuxinyue * @author liuxinyue
@ -55,6 +49,7 @@ public class MqttConfigure {
@Autowired @Autowired
private MessageTemplateTypeCacheService messageTemplateTypeCacheService; private MessageTemplateTypeCacheService messageTemplateTypeCacheService;
@Autowired @Autowired
private KafkaProducer kafkaProducer; private KafkaProducer kafkaProducer;
@ -129,23 +124,25 @@ public class MqttConfigure {
SysCar carByVin = null; SysCar carByVin = null;
List<SysCarVo> carList = service.get("carList"); List<SysCarVo> carList = service.get("carList");
if(carList==null){ if(carList==null){
throw new RuntimeException("Redis未获取到车辆数据!!!"); log.info("redis未取到数据");
}else{ }else{
// 使用 HashMap 存储车信息,以 VIN 作为键 for (SysCarVo sysCarVo : carList) {
Map<String, SysCarVo> carMap = carList.stream() if(sysCarVo.getCarVin().equals(carVin)){
.collect(Collectors.toMap(SysCarVo::getCarVin, Function.identity())); carByVin = sysCarVo;
carByVin = carMap.get(carVin); }
}
} }
log.info("车辆信息为:" + carByVin); log.info("车辆信息为:" + carByVin);
//对应车辆所对应的报文模版 //对应车辆所对应的报文模版
Integer templateId = carByVin.getTemplateId(); Integer templateId = carByVin.getTemplateId();
List<MessageTemplateType> templateTypeList=null;
List<MessageTemplateType> messageTemplateTypes=null; List<MessageTemplateType> messageTemplateTypes=null;
String redisKey = "messageTemplateTypeList"; String redisKey = "messageTemplateTypeList";
//key存在 //key存在
Boolean b = redisService.hasKey(redisKey); Boolean b = redisService.hasKey(redisKey);
if (b) { if (b) {
messageTemplateTypes = messageTemplateTypeCacheService.get(redisKey); messageTemplateTypes = messageTemplateTypeCacheService.get(redisKey);
}else{ }else{
throw new RuntimeException("请先将配置存入Redis!!!"); throw new RuntimeException("请先将配置存入Redis!!!");
} }