|
@@ -4,6 +4,7 @@ import cn.hutool.core.thread.ExecutorBuilder;
|
|
|
import com.persagy.apm.common.context.poems.PoemsContext;
|
|
|
import com.persagy.apm.report.outline.model.ReportOutline;
|
|
|
import com.persagy.apm.report.outline.service.builder.IReportGenerator;
|
|
|
+import com.persagy.framework.tenant.mybatis.datasource.db.holder.SaasContext;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -61,9 +62,12 @@ public class GenerateReportThreadPool {
|
|
|
String userId = PoemsContext.getContext().getUserId();
|
|
|
String pd = PoemsContext.getContext().getPd();
|
|
|
String loginDevice = PoemsContext.getContext().getLoginDevice();
|
|
|
+ String groupCode = SaasContext.getContextGroupCode();
|
|
|
// 添加Future任务,过期时间为5分钟
|
|
|
FutureTask<String> future = new FutureTask<>(() -> {
|
|
|
+ // 将主线程中的缓存手动传递给子线程
|
|
|
PoemsContext.setContext(userId, loginDevice, pd);
|
|
|
+ SaasContext.setContextGroupCode(groupCode);
|
|
|
synchronized (reportOutline.getId().intern()) {
|
|
|
reportGenerator.generateReport(reportOutline);
|
|
|
}
|
|
@@ -76,6 +80,7 @@ public class GenerateReportThreadPool {
|
|
|
try {
|
|
|
future.get(maxGenerateMinutes, TimeUnit.MINUTES);
|
|
|
} catch (InterruptedException | ExecutionException | TimeoutException e) {
|
|
|
+ SaasContext.setContextGroupCode(groupCode);
|
|
|
log.error("生成报告发生异常", e);
|
|
|
future.cancel(true);
|
|
|
reportGenerator.updateReportOutlineInfoWhenFailure(reportOutline);
|