修改日志展示逻辑

This commit is contained in:
2025-06-11 18:19:40 +08:00
parent 5bc58e159a
commit 43d1b02a1c
72 changed files with 29 additions and 4132 deletions

View File

@@ -13,6 +13,7 @@ import org.springframework.util.StopWatch;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
/*
@@ -27,7 +28,6 @@ public class HostInfoServiceImpl extends ServiceImpl<NewHostsMapper, NewHosts> i
@Override
@Async("taskExecutor")
public CompletableFuture<Void> saveHostInfo(List<NewHosts> newHosts) {
try {
StopWatch stopWatch = new StopWatch();
@@ -35,11 +35,11 @@ public class HostInfoServiceImpl extends ServiceImpl<NewHostsMapper, NewHosts> i
saveBatch(newHosts);
stopWatch.stop();
long totalTimeMillis = stopWatch.getTotalTimeMillis();
log.info(" 存储花费: {}ms", totalTimeMillis);
log.info("存储花费: {}ms", totalTimeMillis);
return CompletableFuture.completedFuture(null);
} catch (Exception e) {
// 将异常包装到Future使调用方能处理
return CompletableFuture.failedFuture(e); // Java9+
return CompletableFuture.failedFuture(e);
}
}
@@ -64,6 +64,7 @@ public class HostInfoServiceImpl extends ServiceImpl<NewHostsMapper, NewHosts> i
List<CompletableFuture<Void>> futures = new ArrayList<>();
// 分片提交(避免单批次过大)
Lists.partition(hosts, 1500).forEach(batch -> {
log.info("当前存储数据量大小 {}", batch.size());
CompletableFuture<Void> future = this.saveHostInfo(batch);
futures.add(future);
});