|
@@ -21,6 +21,7 @@ import com.fdkankan.contro.constant.ModelingControlRespCode;
|
|
|
import com.fdkankan.contro.entity.*;
|
|
import com.fdkankan.contro.entity.*;
|
|
|
import com.fdkankan.contro.mq.service.IBuildLogService;
|
|
import com.fdkankan.contro.mq.service.IBuildLogService;
|
|
|
import com.fdkankan.contro.service.*;
|
|
import com.fdkankan.contro.service.*;
|
|
|
|
|
+import com.fdkankan.contro.util.LogUtil;
|
|
|
import com.fdkankan.contro.util.SceneSourceUtil;
|
|
import com.fdkankan.contro.util.SceneSourceUtil;
|
|
|
import com.fdkankan.contro.vo.SendCallAlgorithmParam;
|
|
import com.fdkankan.contro.vo.SendCallAlgorithmParam;
|
|
|
import com.fdkankan.contro.vo.UploadSceneOrigParamVo;
|
|
import com.fdkankan.contro.vo.UploadSceneOrigParamVo;
|
|
@@ -37,8 +38,13 @@ import java.io.File;
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.nio.file.Files;
|
|
import java.nio.file.Files;
|
|
|
|
|
+import java.nio.file.Path;
|
|
|
import java.nio.file.Paths;
|
|
import java.nio.file.Paths;
|
|
|
|
|
+import java.time.LocalDate;
|
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
+import java.util.regex.Matcher;
|
|
|
|
|
+import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
|
@@ -483,33 +489,15 @@ public class JmgaServiceImpl implements IJmgaService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 递归收集文件列表
|
|
|
|
|
- private static void collectFiles(File dir, List<File> fileList) {
|
|
|
|
|
- File[] files = dir.listFiles();
|
|
|
|
|
- if (files == null) return;
|
|
|
|
|
-
|
|
|
|
|
- for (File file : files) {
|
|
|
|
|
- if (file.isDirectory()) {
|
|
|
|
|
- collectFiles(file, fileList);
|
|
|
|
|
- } else {
|
|
|
|
|
- fileList.add(file);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
private void copyLog(String serverPath, String tmpPath, String... levels) throws IOException {
|
|
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);
|
|
|
|
|
- if(CollUtil.isEmpty(fileList)){
|
|
|
|
|
|
|
+ for (String level : levels) {
|
|
|
|
|
+ String levelPath = serverPath + File.separator + level + File.separator;
|
|
|
|
|
+ List<Path> latestDaysLogs = LogUtil.getLatestDaysLogs(Paths.get(levelPath), level, 7);
|
|
|
|
|
+ if(CollUtil.isEmpty(latestDaysLogs)){
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
- CollUtil.reverse(fileList);
|
|
|
|
|
- for (File file : fileList) {
|
|
|
|
|
- int i = fileList.indexOf(file);
|
|
|
|
|
- if(i > 7){
|
|
|
|
|
- continue level;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ for (Path path : latestDaysLogs) {
|
|
|
|
|
+ File file = path.toFile();
|
|
|
String targetPath = file.getAbsolutePath().replace(FileUtil.getParent(serverPath, 1) + File.separator, tmpPath);
|
|
String targetPath = file.getAbsolutePath().replace(FileUtil.getParent(serverPath, 1) + File.separator, tmpPath);
|
|
|
File targetLog = new File(targetPath);
|
|
File targetLog = new File(targetPath);
|
|
|
// targetLog.createNewFile();
|
|
// targetLog.createNewFile();
|
|
@@ -524,44 +512,8 @@ public class JmgaServiceImpl implements IJmgaService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public static void main(String[] args) throws IOException {
|
|
public static void main(String[] args) throws IOException {
|
|
|
- String logBasePath = "D:\\Downloads\\";
|
|
|
|
|
- File baseDir = new File(logBasePath);
|
|
|
|
|
- File[] modelingDirs = baseDir.listFiles(f ->
|
|
|
|
|
- f.isDirectory() && f.getName().startsWith("modeling-control")
|
|
|
|
|
- );
|
|
|
|
|
- if (modelingDirs != null) {
|
|
|
|
|
- for (File dir : modelingDirs) {
|
|
|
|
|
- String serverPath = dir.getAbsolutePath();
|
|
|
|
|
- String tmpPath = "D:\\Downloads\\temp\\";
|
|
|
|
|
- String[] levels = {"info","error","sql"};
|
|
|
|
|
- level: for (String level : levels) {
|
|
|
|
|
- String infoPath = serverPath + File.separator + level + File.separator;
|
|
|
|
|
- List<File> fileList = FileUtil.loopFiles(infoPath);
|
|
|
|
|
- if(CollUtil.isEmpty(fileList)){
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- CollUtil.reverse(fileList);
|
|
|
|
|
- for (File file : fileList) {
|
|
|
|
|
- int i = fileList.indexOf(file);
|
|
|
|
|
- if(i > 7){
|
|
|
|
|
- continue level;
|
|
|
|
|
- }
|
|
|
|
|
- String targetPath = file.getAbsolutePath().replace(FileUtil.getParent(serverPath, 1) + File.separator, tmpPath);
|
|
|
|
|
- File targetLog = new File(targetPath);
|
|
|
|
|
-// targetLog.createNewFile();
|
|
|
|
|
- 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();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|