湘潭大学质量分析

manual-analysis
youys 3 weeks ago
parent 1e30e94a99
commit d8e7045581

@ -14,7 +14,7 @@ public class ThreadPoolConfig {
@Primary
public ExecutorService sonarScannerPool() {
ThreadFactory sonarScannerPool = new CustomizableThreadFactory("sonarScanner-pool-");
return new ThreadPoolExecutor(10, 10, 0,
return new ThreadPoolExecutor(4, 4, 0,
TimeUnit.SECONDS, new ArrayBlockingQueue<>(10000), sonarScannerPool,
new ThreadPoolExecutor.AbortPolicy());
}

@ -258,7 +258,7 @@ public class SonarService {
*/
public void scanExcel(String excelPath) {
int homeworkId = 202405181;
int homeworkId = 202505142;
try {
List<Person> personList = ExcelUtil.readExcel(excelPath);

@ -57,10 +57,10 @@ public class ReadExcelRunnable implements Runnable{
// }
// }
String key = String.format("%d-%s", homeworkId, uid);
// if(new File(path + "/.scannerwork/").exists()){
// System.out.println(path+ "----exist");
// return;
// }
if(new File(path + "/.scannerwork/").exists()){
System.out.println(path+ "----exist");
return;
}
log.info("开始调用sonar:{}",key);
sonarService.sonar(path,key);
}
@ -68,7 +68,7 @@ public class ReadExcelRunnable implements Runnable{
private void download(String zipUrl, String zipPath) throws IOException {
log.info("下载文件: {}-{}", zipUrl, zipPath);
String cookie = "_educoder_session=1f4bf34409fec2180b99aa1cbf0b7586";
String cookie = "_educoder_session=0bea28f7a6db39cefb2fc3cbe715d840;";
URL url = new URL(zipUrl);
URLConnection conn = url.openConnection();
conn.setRequestProperty("Cookie", cookie);

@ -7,6 +7,8 @@ import cn.hutool.core.util.ZipUtil;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
/**
* @Author: youys
@ -27,19 +29,22 @@ public class RarUtil {
}
public static void main(String[] args) {
public static void main(String[] args) throws Exception{
// unrar("/tmp/20230301/201905962222/20230519153409_wuiol3vn.rar", "/Users/youyongsheng/Desktop/aa");
// un7Z("/tmp/20230301/201905962241/20230519153506_i39sv5p2.7z", "/Users/youyongsheng/Desktop/aa");
String path = "/tmp/202505142";
// unzip();
// valid("/tmp/202405181");
// removeFullCode("/tmp/202405181");
// valid(path);
// removeFullCode(path);
removeDirectory(Paths.get(path));
}
public static void unzip(){
String sourceDir = "/tmp/20240518";
String targetDir = "/tmp/202405181";
String sourceDir = "/tmp/202505141";
String targetDir = "/tmp/202505142";
File directory = new File(sourceDir);
File[] studentDirs = directory.listFiles();
@ -160,4 +165,39 @@ public class RarUtil {
}
}
}
private static void removeDirectory(Path rootPath) throws IOException {
Files.walkFileTree(rootPath, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
String folderName = dir.getFileName().toString();
if (folderName.equals("node_modules") || folderName.equals("target") || folderName.equals("dist")) {
System.out.println("Deleting directory: " + dir.toAbsolutePath());
deleteDirectoryRecursively(dir);
return FileVisitResult.SKIP_SUBTREE; // 不再进入已删除目录
}
return FileVisitResult.CONTINUE;
}
});
}
// 递归删除目录
private static void deleteDirectoryRecursively(Path path) throws IOException {
Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
Files.deleteIfExists(file);
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
Files.deleteIfExists(dir);
return FileVisitResult.CONTINUE;
}
});
}
}

@ -6,9 +6,9 @@
spring.datasource.initSize=20
#spring.datasource.master.url=jdbc:postgresql://127.0.0.1:5432/sonar
spring.datasource.master.url=jdbc:postgresql://121.40.224.66:45432/sonar
spring.datasource.master.username=postgres
spring.datasource.master.password=Edu_postgresql
spring.datasource.master.url=jdbc:postgresql://106.75.25.158:5432/sonar
spring.datasource.master.username=sonar
spring.datasource.master.password=sonar
spring.datasource.master.driverClassName=org.postgresql.Driver
@ -44,7 +44,7 @@ zip.save.path=/tmp/
excel.template.path=template.xlsx
#sonar.url=http://127.0.0.1:9000
sonar.url=http://121.40.224.66:49000
sonar.url=http://106.75.25.158:9000
# token令牌
sonar.token=0253a518e824a976ea2f11aec17938cb0f8c0495

@ -67,8 +67,8 @@ public class EcsonarApplicationTests {
public void scanExcel(){
CountDownLatch countDownLatch = new CountDownLatch(1);
// String excelPath = "/Users/youyongsheng/Desktop/ZQ/质量分析/2023-05-16/data.xlsx";
String excelPath = "/Users/youyongsheng/Desktop/湘潭大学计算机科学与工程系2024届.xlsx";
String excelPath = "/Users/youyongsheng/Desktop/ZQ/质量分析/2025-05-14/湘潭大学毕业设计检测数据.xlsx";
// String excelPath = "/Users/youyongsheng/Desktop/湘潭大学计算机科学与工程系2024届.xlsx";
sonarService.scanExcel(excelPath);
try {
@ -81,13 +81,13 @@ public class EcsonarApplicationTests {
@Test
public void writeExcel() throws Exception {
int homeworkId = 202405181;
String directory = "/tmp/202405181/";
int homeworkId = 202505142;
String directory = "/tmp/202505142/";
File file = new File(directory);
File[] files = file.listFiles();
System.out.println("学生数:" + files.length);
List<Person> personList = ExcelUtil.readExcel("/Users/youyongsheng/Desktop/湘潭大学计算机科学与工程系2024届.xlsx");
List<Person> personList = ExcelUtil.readExcel("/Users/youyongsheng/Desktop/ZQ/质量分析/2025-05-14/湘潭大学毕业设计检测数据.xlsx");
Map<String, List<Person>> collect = personList.stream().collect(Collectors.groupingBy(Person::getUid));
@ -100,7 +100,7 @@ public class EcsonarApplicationTests {
Metrics metrics = reportService.getMetrics(projectName);
String templatePath = this.getClass().getClassLoader().getResource("template1.xlsx").getPath();
String outPath = "/Users/youyongsheng/Desktop/fffff333.xlsx";
String outPath = "/Users/youyongsheng/Desktop/bbbb.xlsx";
System.out.println("第"+(i++)+"个学生," + uid);
if (CollectionUtils.isEmpty(collect.get(uid))) {

Loading…
Cancel
Save