|
|
|
@ -14,6 +14,8 @@ import java.util.concurrent.ExecutorService;
|
|
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
|
|
|
|
|
import static Tools.Crawler.Util.Util.doRequestWithRetry;
|
|
|
|
|
|
|
|
|
|
public class KnowledgeLesson {
|
|
|
|
|
// 用于存储课程信息的线程安全列表
|
|
|
|
|
public static List<Record> lessonList = Collections.synchronizedList(new ArrayList<>());
|
|
|
|
@ -107,7 +109,7 @@ public class KnowledgeLesson {
|
|
|
|
|
argBook.put("sortType", 2);
|
|
|
|
|
argBook.put("stageCode", stageCode);
|
|
|
|
|
argBook.put("subjectCode", subjectCode);
|
|
|
|
|
String respBook = BookLesson.doRequestWithRetry(url, argBook.toString(), false, 3);
|
|
|
|
|
String respBook = doRequestWithRetry(url, argBook.toString(), false, 3);
|
|
|
|
|
|
|
|
|
|
if (respBook != null) {
|
|
|
|
|
JSONArray jsonArrSource = JSONObject.parseObject(respBook)
|
|
|
|
@ -202,7 +204,7 @@ public class KnowledgeLesson {
|
|
|
|
|
subjectCode, subjectMap.get(subjectCode));
|
|
|
|
|
String url = "https://yx.ccsjy.cn/api/business/v1/knowledge/tree";
|
|
|
|
|
|
|
|
|
|
String respBook = BookLesson.doRequestWithRetry(url, argBook.toString(), false, 3);
|
|
|
|
|
String respBook = doRequestWithRetry(url, argBook.toString(), false, 3);
|
|
|
|
|
if (respBook != null) {
|
|
|
|
|
try {
|
|
|
|
|
List<Record> allRecords = new ArrayList<>();
|
|
|
|
@ -242,13 +244,11 @@ public class KnowledgeLesson {
|
|
|
|
|
List<CompletableFuture<Void>> futures = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
for (Record record : listKnowledge) {
|
|
|
|
|
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
|
|
|
|
|
collectLesson(
|
|
|
|
|
record.getStr("node_id"),
|
|
|
|
|
record.getStr("stage_id"),
|
|
|
|
|
record.getStr("subject_id")
|
|
|
|
|
);
|
|
|
|
|
}, executorService);
|
|
|
|
|
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> collectLesson(
|
|
|
|
|
record.getStr("node_id"),
|
|
|
|
|
record.getStr("stage_id"),
|
|
|
|
|
record.getStr("subject_id")
|
|
|
|
|
), executorService);
|
|
|
|
|
futures.add(future);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|