SimulationService/src/main/java/com/simulationservice/controller/InferenceController.java

38 lines
1.4 KiB
Java
Raw Normal View History

2025-09-14 12:49:22 +08:00
package com.simulationservice.controller;
import com.simulationservice.common.R;
import com.simulationservice.service.InferenceTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
/**
* 想定控制与前端进行交互的接口
* 想定控制包括想定的加载开始暂停停止加速减速
*/
@RestController
public class InferenceController {
@Autowired
private InferenceTaskService inferenceTaskService;
@GetMapping("/api/loadScenario")
public R<Map<String, Object>> loadScenario(@RequestParam(value = "roomId") String roomId, @RequestParam(value = "scenarioId") String scenarioId) {
// 服务端加载想定
Map<String, Object> retMap = new HashMap<>();
boolean ret = inferenceTaskService.loadScenario(roomId, scenarioId);
return ret ? R.success(retMap) : R.error(retMap);
}
@GetMapping("/api/startScenario")
public String startTask(@RequestParam(value = "roomId") String roomId, @RequestParam(value = "scenarioId") String scenarioId) {
// 启动后台任务
inferenceTaskService.executeTask();
return "任务已启动";
}
}