feat(可回溯): 可回溯
调整临时文件生成
This commit is contained in:
@@ -19,6 +19,15 @@
|
||||
<spring-cloud-alibaba.version>2.2.3.RELEASE</spring-cloud-alibaba.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.wabestway.engine</groupId>
|
||||
<artifactId>afis-engine-api</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
|
||||
@@ -3,9 +3,11 @@ package com.wabestway.recall;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableDiscoveryClient
|
||||
@EnableFeignClients(basePackages = {"com.wabestway.engine"})
|
||||
public class AfisRecallApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -101,19 +101,19 @@ public class OrderController {
|
||||
return Mono.just(ResObj.ok());
|
||||
}
|
||||
|
||||
void createVideo(String dir, String jsonData) throws IOException {
|
||||
void createVideo(String orderId, String jsonData) throws IOException {
|
||||
|
||||
// 创建临时目录
|
||||
Path tempDir = null;
|
||||
try {
|
||||
tempDir = Files.createTempDirectory(dir);
|
||||
tempDir = Files.createTempDirectory("ts");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("Created temporary directory: " + tempDir);
|
||||
|
||||
try {
|
||||
File tempFile = File.createTempFile("traces", ".json", tempDir.toFile());
|
||||
File tempFile = new File(tempDir.toFile(), "traces.json");
|
||||
FileWriter fw = new FileWriter(tempFile);
|
||||
BufferedWriter bw = new BufferedWriter(fw);
|
||||
bw.write(jsonData);
|
||||
|
||||
@@ -1,12 +1,69 @@
|
||||
package com.wabestway.recall;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import javax.script.*;
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Base64;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
|
||||
public class FFmpeg {
|
||||
@Test
|
||||
public void TestMp4() {
|
||||
public void TestMp4() throws IOException {
|
||||
String jsonData = new String(Files.readAllBytes(Paths.get("C:","Users/Administrator/Desktop","traces.json")), StandardCharsets.UTF_8);
|
||||
|
||||
// 创建临时目录
|
||||
Path tempDir = null;
|
||||
try {
|
||||
tempDir = Files.createTempDirectory("example");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("Created temporary directory: " + tempDir);
|
||||
|
||||
try {
|
||||
File tempFile = File.createTempFile("traces", ".json", tempDir.toFile());
|
||||
FileWriter fw = new FileWriter(tempFile);
|
||||
BufferedWriter bw = new BufferedWriter(fw);
|
||||
bw.write(jsonData);
|
||||
bw.flush();
|
||||
bw.close();
|
||||
fw.close();
|
||||
String[] command = {"C:\\Users\\Administrator\\AppData\\Roaming\\npm\\ts-node", "E:\\Develop\\trace-transform\\src\\index.ts"};
|
||||
ProcessBuilder processBuilder = new ProcessBuilder(command);
|
||||
processBuilder.directory(tempDir.toFile());
|
||||
// 在临时目录下执行命令
|
||||
Process process = processBuilder.start();
|
||||
// 读取命令输出
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
System.out.println(line);
|
||||
}
|
||||
reader.close();
|
||||
|
||||
// 等待命令执行完成
|
||||
int exitCode = process.waitFor();
|
||||
System.out.println("Command exited with code " + exitCode);
|
||||
} catch (IOException | InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
// 删除临时目录
|
||||
Files.walk(tempDir)
|
||||
.sorted(Comparator.reverseOrder())
|
||||
.map(Path::toFile)
|
||||
.forEach(File::delete);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user