This commit is contained in:
2026-03-11 19:36:26 +08:00
parent 9e76fd467b
commit 869b269fb1

View File

@@ -160,20 +160,8 @@ func (h *QYGLReportHandler) GetQYGLReportPDFByID(c *gin.Context) {
} }
} }
// 先尝试从缓存中读取基于报告ID // 临时关闭企业全景报告 PDF 的读取缓存,强制每次都重新生成
if h.pdfCacheManager != nil { // 如果后续需要恢复缓存,可在此重新启用 pdfCacheManager.GetByReportID 的逻辑。
if cachedBytes, hit, _, err := h.pdfCacheManager.GetByReportID(id); err == nil && hit && len(cachedBytes) > 0 {
h.logger.Info("企业全景报告 PDF 缓存命中",
zap.String("report_id", id),
zap.Int("pdf_size", len(cachedBytes)),
)
encodedFileName := url.QueryEscape(fileName)
c.Header("Content-Type", "application/pdf")
c.Header("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", encodedFileName))
c.Data(http.StatusOK, "application/pdf", cachedBytes)
return
}
}
// 根据当前请求推断访问协议(支持通过反向代理的 X-Forwarded-Proto // 根据当前请求推断访问协议(支持通过反向代理的 X-Forwarded-Proto
scheme := "http" scheme := "http"
@@ -205,15 +193,8 @@ func (h *QYGLReportHandler) GetQYGLReportPDFByID(c *gin.Context) {
return return
} }
// 将生成结果写入缓存(忽略写入错误,不影响主流程) // 临时关闭企业全景报告 PDF 的写入缓存,只返回最新生成的 PDF。
if h.pdfCacheManager != nil { // 若后续需要重新启用缓存,可恢复对 pdfCacheManager.SetByReportID 的调用。
if err := h.pdfCacheManager.SetByReportID(id, pdfBytes); err != nil {
h.logger.Warn("保存企业全景报告 PDF 到缓存失败",
zap.String("report_id", id),
zap.Error(err),
)
}
}
encodedFileName := url.QueryEscape(fileName) encodedFileName := url.QueryEscape(fileName)
c.Header("Content-Type", "application/pdf") c.Header("Content-Type", "application/pdf")