53 lines
1.9 KiB
Java
53 lines
1.9 KiB
Java
package com.muyu.analyze.controller;
|
|
|
|
|
|
import com.muyu.analyze.service.impl.RealTimeDataEventImpl;
|
|
import com.muyu.common.event.cache.VehicleEventCache;
|
|
import com.muyu.common.event.constants.VehicleEventConstants;
|
|
import com.muyu.system.common.domain.VehicleData;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
/**
|
|
* @ProjectName: cloud-vehicles
|
|
* @PackageName: com.muyu.analyze.controller
|
|
* @Description TODO
|
|
* @Author XiaoFan
|
|
* @Date 2024/4/5 20:39
|
|
* @Version 1.0
|
|
*/
|
|
@RestController
|
|
public class RealTimeDataController {
|
|
@Autowired
|
|
private VehicleEventCache vehicleEventCache;
|
|
@Autowired
|
|
private RealTimeDataEventImpl realTimeDataEvent;
|
|
// 定义一个接口,用于获取实时数据
|
|
|
|
// @GetMapping("/realTimeData")
|
|
// public ResponseEntity<VehicleData> getRealTimeData() {
|
|
// // 假设这里调用实时数据处理服务的某个方法来获取实时数据
|
|
// VehicleData realTimeData = realTimeDataEvent.getRealTimeData();
|
|
// System.out.println("数据为"+realTimeData);
|
|
// // 实现这个方法需要根据你的具体业务逻辑
|
|
// // 返回实时数据
|
|
// return ResponseEntity.ok().body(realTimeData);
|
|
// }
|
|
|
|
@PostMapping("/realTimeDataTwo/{vin}")
|
|
public ResponseEntity<VehicleData> getRealTimeDataByVin(@PathVariable String vin) {
|
|
vehicleEventCache.addEvent(vin, VehicleEventConstants.SHI_SHI);
|
|
// 根据 VIN 获取实时数据
|
|
VehicleData realTimeData = realTimeDataEvent.getRealTimeDataByVin(vin);
|
|
System.out.println("VIN为" + vin + "的实时数据为:" + realTimeData);
|
|
// 返回实时数据
|
|
return ResponseEntity.ok().body(realTimeData);
|
|
}
|
|
|
|
|
|
|
|
}
|