feat(): 新增获取车辆实时数据接口
parent
7b309dc9ac
commit
f34d4acc1f
|
@ -12,7 +12,7 @@ public class WebMvcSaaSConfig implements WebMvcConfigurer {
|
||||||
/**
|
/**
|
||||||
* 不需要拦截的地址
|
* 不需要拦截的地址
|
||||||
*/
|
*/
|
||||||
public static final String[] EXCLUDE_URLS = {"/user/info", "/login", "/logout", "/refresh"};
|
public static final String[] EXCLUDE_URLS = {"/user/info", "/login", "/logout", "/refresh", "/realTime/getCarRealTime"};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addInterceptors (InterceptorRegistry registry) {
|
public void addInterceptors (InterceptorRegistry registry) {
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.muyu.openbusiness.domain;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆详细数据
|
||||||
|
*
|
||||||
|
* @Author: 胡杨
|
||||||
|
* @Name: SysCarData
|
||||||
|
* @Description: 车辆详细数据
|
||||||
|
* @CreatedDate: 2024/10/10 下午7:35
|
||||||
|
* @FilePath: com.muyu.openbusiness.domain
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class SysCarData <T> {
|
||||||
|
|
||||||
|
private String key;
|
||||||
|
private String label;
|
||||||
|
private T value;
|
||||||
|
private String type;
|
||||||
|
}
|
|
@ -53,6 +53,9 @@ public class SysCarMessage implements Serializable {
|
||||||
@Excel(name = "报文分类")
|
@Excel(name = "报文分类")
|
||||||
private String messageType;
|
private String messageType;
|
||||||
|
|
||||||
|
/* 报文数据类型*/
|
||||||
|
private String messageClass;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.muyu.openbusiness.controller;
|
||||||
|
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.openbusiness.domain.SysCarData;
|
||||||
|
import com.muyu.openbusiness.service.SysCarRealTimeService;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆实时信息控制层
|
||||||
|
*
|
||||||
|
* @Author: 胡杨
|
||||||
|
* @Name: SysCarRealTimeController
|
||||||
|
* @Description: 车辆实时信息控制层
|
||||||
|
* @CreatedDate: 2024/10/10 下午7:16
|
||||||
|
* @FilePath: com.muyu.openbusiness.controller
|
||||||
|
*/
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/realTime")
|
||||||
|
public class SysCarRealTimeController {
|
||||||
|
@Resource
|
||||||
|
private SysCarRealTimeService service;
|
||||||
|
|
||||||
|
@GetMapping("/getCarRealTime")
|
||||||
|
public Result<HashMap<String, String>> getCarRealTime(@RequestParam("vin") String vin) {
|
||||||
|
return Result.success(service.getCarRealTime(vin));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.muyu.openbusiness.service;
|
||||||
|
|
||||||
|
|
||||||
|
import com.muyu.openbusiness.domain.SysCarData;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆实时信息业务层
|
||||||
|
*
|
||||||
|
* @Author: 胡杨
|
||||||
|
* @Name: SysCarRealTime
|
||||||
|
* @Description: 车辆实时信息业务层
|
||||||
|
* @CreatedDate: 2024/10/10 下午7:37
|
||||||
|
* @FilePath: com.muyu.openbusiness.service
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface SysCarRealTimeService{
|
||||||
|
HashMap<String, String> getCarRealTime(String vin);
|
||||||
|
}
|
|
@ -0,0 +1,70 @@
|
||||||
|
package com.muyu.openbusiness.service.impl;
|
||||||
|
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import com.muyu.common.redis.service.RedisService;
|
||||||
|
import com.muyu.openbusiness.domain.SysCarData;
|
||||||
|
import com.muyu.openbusiness.service.SysCarRealTimeService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆实时信息实现层
|
||||||
|
*
|
||||||
|
* @Author: 胡杨
|
||||||
|
* @Name: SysCarRealTime
|
||||||
|
* @Description: 车辆实时信息实现层
|
||||||
|
* @CreatedDate: 2024/10/10 下午7:37
|
||||||
|
* @FilePath: com.muyu.openbusiness.service.impl
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class SysCarRealTimeServiceImpl implements SysCarRealTimeService {
|
||||||
|
@Resource
|
||||||
|
private RedisService redisService;
|
||||||
|
|
||||||
|
private static final HashMap<String, Class<?> > typeMap = new HashMap<>();
|
||||||
|
static {
|
||||||
|
typeMap.put("int", Integer.class);
|
||||||
|
typeMap.put("double", Double.class);
|
||||||
|
typeMap.put("long", Long.class);
|
||||||
|
typeMap.put("string", String.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashMap<String, String> getCarRealTime(String vin) {
|
||||||
|
HashMap<String, String> map = new HashMap<>();
|
||||||
|
for (String key : redisService.keys(vin+":*")) {
|
||||||
|
map.put(key.replace(vin + ":",""), classConversion(redisService.getCacheObject(key)));
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 去除无用字符
|
||||||
|
* @param str
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private String classConversion(String str) {
|
||||||
|
try {
|
||||||
|
double d = Double.parseDouble(str);
|
||||||
|
str = Double.toString(d);
|
||||||
|
String[] split = str.split(".");
|
||||||
|
if (split.length>1 && split[1].equals("0")) {
|
||||||
|
str = String.valueOf(Integer.parseInt(str));
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue