diff --git a/internal/domain/tools/common/image_converter/client.go b/internal/domain/tools/common/image_converter/client.go index 5eba199..2de57d2 100644 --- a/internal/domain/tools/common/image_converter/client.go +++ b/internal/domain/tools/common/image_converter/client.go @@ -21,7 +21,7 @@ func New(cfg config.ToolConfig) *Client { } // Call 将 Excel 文件转换为图片 -func (c *Client) Call(filename string, fileBytes []byte) ([]byte, error) { +func (c *Client) Call(filename string, fileBytes []byte, scale int) ([]byte, error) { body := &bytes.Buffer{} writer := multipart.NewWriter(body) @@ -33,6 +33,14 @@ func (c *Client) Call(filename string, fileBytes []byte) ([]byte, error) { return nil, err } + // 添加 scale 参数 + if scale <= 0 { + scale = 2 + } + if err = writer.WriteField("scale", fmt.Sprintf("%d", scale)); err != nil { + return nil, err + } + if err = writer.Close(); err != nil { return nil, err } diff --git a/internal/domain/workflow/recharge/statistics_ours_product.go b/internal/domain/workflow/recharge/statistics_ours_product.go index cb89347..ebc33a9 100644 --- a/internal/domain/workflow/recharge/statistics_ours_product.go +++ b/internal/domain/workflow/recharge/statistics_ours_product.go @@ -110,13 +110,13 @@ func (w *statisticsOursProduct) generateExcelAndUpload(ctx context.Context, data excelData := w.convertDataToExcelFormat(data) // 4. 生成 Excel - excelBytes, err := w.toolManager.Common.ExcelGenerator.Call(templatePath, excelData, 2, 2) + excelBytes, err := w.toolManager.Common.ExcelGenerator.Call(templatePath, excelData, 4, 3) if err != nil { return nil, fmt.Errorf("生成 Excel 失败: %v", err) } // 5. Excel 转图片 - picBytes, err := w.toolManager.Common.ImageConverter.Call(fileName+".xlsx", excelBytes) + picBytes, err := w.toolManager.Common.ImageConverter.Call(fileName+".xlsx", excelBytes, 2) if err != nil { return nil, fmt.Errorf("Excel 转图片失败: %v", err) } @@ -143,15 +143,16 @@ func (w *statisticsOursProduct) convertDataToExcelFormat(data []statistics_ours_ for _, item := range data { row := []string{ item.OursProductName, - fmt.Sprintf("%d", item.OursProductId), + // fmt.Sprintf("%d", item.OursProductId), item.Count, - item.TotalPrice, - item.SuccessCount, + // item.TotalPrice, + // item.SuccessCount, item.SuccessPrice, - item.FailCount, - item.FailPrice, + // item.FailCount, + // item.FailPrice, item.Profit, } + result = append(result, row) } return result diff --git a/internal/server/http.go b/internal/server/http.go index 3d0b180..53446c8 100644 --- a/internal/server/http.go +++ b/internal/server/http.go @@ -18,7 +18,6 @@ type HTTPServer struct { callback *services.CallbackService chatHis *services.HistoryService capabilityService *services.CapabilityService - cronService *services.CronService } func NewHTTPServer( @@ -29,11 +28,10 @@ func NewHTTPServer( callback *services.CallbackService, chatHis *services.HistoryService, capabilityService *services.CapabilityService, - cronService *services.CronService, ) *fiber.App { //构建 server app := initRoute() - router.SetupRoutes(app, service, session, task, gateway, callback, chatHis, capabilityService, cronService) + router.SetupRoutes(app, service, session, task, gateway, callback, chatHis, capabilityService) return app } diff --git a/internal/server/router/router.go b/internal/server/router/router.go index 3c33b42..091c85f 100644 --- a/internal/server/router/router.go +++ b/internal/server/router/router.go @@ -21,13 +21,12 @@ type RouterServer struct { gateway *gateway.Gateway chatHist *services.HistoryService capabilityService *services.CapabilityService - cronService *services.CronService } // SetupRoutes 设置路由 func SetupRoutes(app *fiber.App, ChatService *services.ChatService, sessionService *services.SessionService, task *services.TaskService, gateway *gateway.Gateway, callbackService *services.CallbackService, chatHist *services.HistoryService, - capabilityService *services.CapabilityService, cronService *services.CronService, + capabilityService *services.CapabilityService, ) { app.Use(func(c *fiber.Ctx) error { // 设置 CORS 头 @@ -95,11 +94,6 @@ func SetupRoutes(app *fiber.App, ChatService *services.ChatService, sessionServi // 能力 r.Post("/capability/product/ingest", capabilityService.ProductIngest) // 商品数据提取 r.Post("/capability/product/ingest/:thread_id/confirm", capabilityService.ProductIngestConfirm) // 商品数据提取确认 - - // 测试任务 - r.Post("/test/cron", func(c *fiber.Ctx) error { - return cronService.CronReportSend(c.Context()) - }) } func routerSocket(app *fiber.App, chatService *services.ChatService) { diff --git a/internal/tools/bbxt/upload.go b/internal/tools/bbxt/upload.go index a5d0886..c5b6c80 100644 --- a/internal/tools/bbxt/upload.go +++ b/internal/tools/bbxt/upload.go @@ -42,7 +42,7 @@ func (u *Uploader) Run(report *ReportRes) (err error) { return fmt.Errorf("write to bytes failed: %v", err) } - picBytes, err := u.excel2picPy(report.Path, excelBytes.Bytes()) + picBytes, err := u.excel2picPy(report.Path, excelBytes.Bytes(), 2) if err != nil { return fmt.Errorf("excel2picPy failed: %v", err) } @@ -62,7 +62,7 @@ func (u *Uploader) Run(report *ReportRes) (err error) { // --header 'Content-Type: multipart/form-data; boundary=--------------------------952147881043913664015069' \ // --form 'file=@"C:\\Users\\Administrator\\Downloads\\销售同比分析2025-12-29 0-12点.xlsx"' \ // --form 'sheet_name="销售同比分析"' -func (u *Uploader) excel2picPy(templatePath string, excelBytes []byte) ([]byte, error) { +func (u *Uploader) excel2picPy(templatePath string, excelBytes []byte, scale int) ([]byte, error) { // 1. 获取 Sheet Name // 尝试从 excelBytes 解析,如果失败则使用默认值 "Sheet1" sheetName := "Sheet1" @@ -99,6 +99,14 @@ func (u *Uploader) excel2picPy(templatePath string, excelBytes []byte) ([]byte, return nil, fmt.Errorf("write field sheet_name failed: %v", err) } + // 添加 scale 字段 + if scale <= 0 { + scale = 2 + } + if err = writer.WriteField("scale", fmt.Sprintf("%d", scale)); err != nil { + return nil, fmt.Errorf("write field scale failed: %v", err) + } + if err = writer.Close(); err != nil { return nil, fmt.Errorf("close writer failed: %v", err) } diff --git a/tmpl/excel_temp/kshj_gt.xlsx b/tmpl/excel_temp/kshj_gt.xlsx index 2b27bfa..957d183 100755 Binary files a/tmpl/excel_temp/kshj_gt.xlsx and b/tmpl/excel_temp/kshj_gt.xlsx differ diff --git a/tmpl/excel_temp/kshj_total.xlsx b/tmpl/excel_temp/kshj_total.xlsx index b29ae47..369dfe9 100755 Binary files a/tmpl/excel_temp/kshj_total.xlsx and b/tmpl/excel_temp/kshj_total.xlsx differ diff --git a/tmpl/excel_temp/recharge_statistics_ours_product.xlsx b/tmpl/excel_temp/recharge_statistics_ours_product.xlsx index 8d5b5a3..347e886 100755 Binary files a/tmpl/excel_temp/recharge_statistics_ours_product.xlsx and b/tmpl/excel_temp/recharge_statistics_ours_product.xlsx differ