|
|
@@ -2,6 +2,7 @@ package com.fdkankan.contro.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
+import cn.hutool.core.io.file.FileMode;
|
|
|
import cn.hutool.core.lang.UUID;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.core.util.ZipUtil;
|
|
|
@@ -38,8 +39,14 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.RandomAccessFile;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
+import java.nio.file.Files;
|
|
|
+import java.nio.file.Paths;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
@@ -388,7 +395,7 @@ public class JmgaServiceImpl implements IJmgaService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void updateSceneFailAndZipLog(String num, String failReason) {
|
|
|
+ public void updateSceneFailAndZipLog(String num, String failReason) throws IOException {
|
|
|
scenePlusService.update(new LambdaUpdateWrapper<ScenePlus>()
|
|
|
.set(ScenePlus::getSceneStatus, SceneStatus.FAILD.code())
|
|
|
.set(ScenePlus::getBuildFailReason, failReason)
|
|
|
@@ -452,7 +459,7 @@ public class JmgaServiceImpl implements IJmgaService {
|
|
|
|
|
|
}
|
|
|
|
|
|
- private void copyLog(String serverPath, String tmpPath, String... levels){
|
|
|
+ private void copyLog(String serverPath, String tmpPath, String... levels) throws IOException {
|
|
|
level: for (String level : levels) {
|
|
|
String infoPath = serverPath + File.separator + level + File.separator;
|
|
|
List<File> fileList = FileUtil.loopFiles(infoPath);
|
|
|
@@ -466,10 +473,19 @@ public class JmgaServiceImpl implements IJmgaService {
|
|
|
continue level;
|
|
|
}
|
|
|
String targetPath = file.getAbsolutePath().replace(FileUtil.getParent(serverPath, 1), tmpPath);
|
|
|
- FileUtil.copy(file.getAbsolutePath(), targetPath, true);
|
|
|
- String content = FileUtil.readUtf8String(targetPath);
|
|
|
- content = content.replace("公安", "xx").replaceAll(ipv4Pattern, "ip");
|
|
|
- FileUtil.writeUtf8String(content, targetPath);
|
|
|
+ File targetLog = new File(targetPath);
|
|
|
+ targetLog.createNewFile();
|
|
|
+// FileUtil.copy(file.getAbsolutePath(), targetPath, true);
|
|
|
+// String content = FileUtil.readUtf8String(targetPath);
|
|
|
+// content = content.replace("公安", "xx").replaceAll(ipv4Pattern, "ip");
|
|
|
+// FileUtil.writeUtf8String(content, targetPath);
|
|
|
+
|
|
|
+ try (Stream<String> lines = Files.lines(Paths.get(file.getAbsolutePath()), StandardCharsets.UTF_8)) {
|
|
|
+ lines.map(line -> line.replace("公安", "xx").replaceAll(ipv4Pattern, "ip"))
|
|
|
+ .forEach(line -> FileUtil.appendUtf8String(line, targetLog)); // 或者进行其他处理
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|