You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
virtual-patient/virtual-patient-rasa/src/main/java/com/supervision/rasa/controller/RasaCmdController.java

70 lines
2.2 KiB
Java

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.supervision.rasa.controller;
import cn.hutool.core.util.StrUtil;
import com.supervision.rasa.pojo.vo.RasaArgumentVo;
import com.supervision.rasa.service.RasaCmdService;
import com.supervision.exception.BusinessException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.io.*;
import java.util.concurrent.*;
@Api(tags = "rasa文件保存")
@RestController
@RequestMapping("rasaCmd")
@RequiredArgsConstructor
public class RasaCmdController {
private final RasaCmdService rasaCmdService;
@ApiOperation("执行训练shell命令")
@PostMapping("/trainExec")
public String trainExec(@RequestBody RasaArgumentVo argument) throws IOException, ExecutionException, InterruptedException, TimeoutException {
if (StrUtil.isEmpty(argument.getFixedModelName())){
throw new BusinessException("fixedModelName参数不能为空");
}
if (StrUtil.isEmpty(argument.getModelId())){
throw new BusinessException("modelId参数不能为空! ");
}
return rasaCmdService.trainExec(argument);
}
@ApiOperation("执行启动shell命令")
@PostMapping("/runExec")
public String runExec(@RequestBody RasaArgumentVo argument) throws ExecutionException, InterruptedException, TimeoutException {
if (StrUtil.isEmpty(argument.getFixedModelName())){
throw new BusinessException("fixedModelName参数不能为空");
}
if (StrUtil.isEmpty(argument.getModelId())){
throw new BusinessException("modelId参数不能为空! ");
}
String outString = rasaCmdService.runExec(argument);
if (StrUtil.isEmptyIfStr(outString) || !outString.contains("Rasa server is up and running")){
throw new BusinessException("任务执行异常。详细日志:"+outString);
}
return outString;
}
@ApiOperation("执行启动shell命令")
@PostMapping("/test")
public String test(@RequestBody RasaArgumentVo argument) throws ExecutionException, InterruptedException, TimeoutException {
rasaCmdService.test();
return " dd";
}
}