Commit 67a1ce83 authored by whlviolin's avatar whlviolin

增加算法分析接口

parent 0f04cd92
package cn.ac.iscas.server; package cn.ac.iscas.server;
import org.apache.catalina.connector.Connector;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient; import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;
@SpringBootApplication @SpringBootApplication
@EnableEurekaClient @EnableEurekaClient
...@@ -12,4 +17,15 @@ public class ServerApplication { ...@@ -12,4 +17,15 @@ public class ServerApplication {
SpringApplication.run(ServerApplication.class, args); SpringApplication.run(ServerApplication.class, args);
} }
@Bean
public ConfigurableServletWebServerFactory webServerFactory() {
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
@Override
public void customize(Connector connector) {
connector.setProperty("relaxedQueryChars", "|{}[]");
}
});
return factory;
}
} }
...@@ -11,29 +11,36 @@ import java.util.List; ...@@ -11,29 +11,36 @@ import java.util.List;
@CrossOrigin @CrossOrigin
@RestController @RestController
@RequestMapping("/api/algo/") @RequestMapping("/algo/")
public class AlgoController { public class AlgoController {
@Autowired @Autowired
AlgorithmService algorithmService; AlgorithmService algorithmService;
@RequestMapping(value = "/run", method = RequestMethod.GET) @RequestMapping(value = "/run", method = RequestMethod.GET)
public boolean insertFileList( public Result insertFileList(
@RequestParam("name")String name,
@RequestParam("fId")String fId, @RequestParam("fId")String fId,
@RequestParam("algo")String algo, @RequestParam("algo")String algo,
@RequestParam("ar")String ar, @RequestParam("ar")String ar
@RequestParam("name")List name
) throws Exception{ ) throws Exception{
String data = algorithmService.run(fId, algo, ar, name); String data = algorithmService.run(name, fId,algo, ar);
return false; if (data != null) {
return new Result(200, "success", data);
} else {
return new Result(HttpStatus.INTERNAL_SERVER_ERROR.value(), "failed",null);
}
} }
@RequestMapping(value = "/runDEA", method = RequestMethod.GET) @RequestMapping(value = "/runDEA", method = RequestMethod.GET)
public ResponseEntity<List<FileList>> runDEA( public ResponseEntity<List<FileList>> runDEA(
@RequestParam("name")String name,
@RequestParam("fId")String fId,
@RequestParam("args_x")String args_x,
@RequestParam("args_y")String args_y
) throws Exception{ ) throws Exception{
List<FileList> data = null; List data = algorithmService.runDEA(name, fId, args_x, args_y);
if (data != null) { if (data != null) {
return ResponseEntity.ok(data); return ResponseEntity.ok(data);
} else { } else {
......
...@@ -4,5 +4,7 @@ import java.util.List; ...@@ -4,5 +4,7 @@ import java.util.List;
public interface AlgorithmService { public interface AlgorithmService {
public String run(String name, String fId, String algo, List args)throws Exception; public String run(String name, String fId, String algo, String args)throws Exception;
public List runDEA(String name, String fId, String algo, String args)throws Exception;
} }
...@@ -15,7 +15,7 @@ public class AlgorithmServiceImpl implements AlgorithmService { ...@@ -15,7 +15,7 @@ public class AlgorithmServiceImpl implements AlgorithmService {
private String baseFile; private String baseFile;
@Override @Override
public String run(String name, String fId, String algo, List args) throws Exception{ public String run(String name, String fId, String algo, String args) throws Exception{
// 查找文件扩展名的位置 // 查找文件扩展名的位置
int dotIndex = name.lastIndexOf('.'); int dotIndex = name.lastIndexOf('.');
String fileType=""; String fileType="";
...@@ -27,9 +27,15 @@ public class AlgorithmServiceImpl implements AlgorithmService { ...@@ -27,9 +27,15 @@ public class AlgorithmServiceImpl implements AlgorithmService {
CSVTableData csvTableData = new ReadFileUtil().read_csv(filePath, name); CSVTableData csvTableData = new ReadFileUtil().read_csv(filePath, name);
List algoRes = csvTableData.getData(); List algoRes = csvTableData.getData();
for(Object arg : args) { // for(Object arg : args) {
//
// }
return null;
} }
public List runDEA(String name, String fId, String algo, String args) throws Exception{
Object result = new Object();
CSVTableData csvTableData = new ReadFileUtil().read_csv(baseFile + fId, name);
return null; return null;
} }
} }
\ No newline at end of file
...@@ -68,4 +68,18 @@ public class ReadFileUtil { ...@@ -68,4 +68,18 @@ public class ReadFileUtil {
return tableData; return tableData;
} }
public String getFullPath(String baseFile, String fId, String name){
// 查找文件扩展名的位置
int dotIndex = name.lastIndexOf('.');
String fileType="";
if (dotIndex != -1 && dotIndex < name.length() - 1) {
// 提取文件扩展名
fileType = name.substring(dotIndex + 1);
}
String filePath = baseFile + fId + fileType;
return filePath;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment