From b41e68fd098dfeec41bc4ad7489c3b596bdd16e3 Mon Sep 17 00:00:00 2001 From: fuzhongyun <15339891972@163.com> Date: Sun, 8 Feb 2026 15:56:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=201.=E8=A7=A3=E5=86=B3=E6=97=A5=E6=8A=A5?= =?UTF-8?q?=E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4=E9=97=B4=E9=9A=94=E6=9E=81?= =?UTF-8?q?=E9=95=BF=E9=97=AE=E9=A2=98=202.=E8=B0=83=E6=95=B4=E5=8D=8F?= =?UTF-8?q?=E7=A8=8B=E8=B6=85=E6=97=B6=E6=97=B6=E9=95=BF=201000s=20->=2010?= =?UTF-8?q?0s=203.=E4=BF=AE=E6=94=B9=E9=83=A8=E5=88=86=E6=97=A0=E5=85=B3?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E3=80=81=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/config_env.yaml | 2 ++ internal/biz/ding_talk_bot.go | 32 +++++++++++++++++++++++ internal/biz/handle/dingtalk/send_card.go | 2 +- internal/services/cron.go | 18 ++++++++----- internal/services/dtalk_bot_test.go | 8 +++--- 5 files changed, 52 insertions(+), 10 deletions(-) diff --git a/config/config_env.yaml b/config/config_env.yaml index 1b1a8bd..532191a 100644 --- a/config/config_env.yaml +++ b/config/config_env.yaml @@ -88,6 +88,8 @@ tools: zltxOrderAfterSaleResellerBatch: enabled: true base_url: "https://gateway.dev.cdlsxd.cn/zltx_api/admin/afterSales/reseller_pre_ai" + zltxResellerAuthProductToManagerAndDefaultLossReason: + base_url: "https://revcl.1688sup.com/api/admin/reseller/resellerAuthProduct/getManagerAndDefaultLossReason" # eino tool 配置 eino_tools: diff --git a/internal/biz/ding_talk_bot.go b/internal/biz/ding_talk_bot.go index 6773353..8aaa4cd 100644 --- a/internal/biz/ding_talk_bot.go +++ b/internal/biz/ding_talk_bot.go @@ -312,6 +312,38 @@ func (d *DingTalkBotBiz) SendReport(ctx context.Context, groupInfo *model.AiBotG return } +// SendReports 发送多个报告 +func (d *DingTalkBotBiz) SendReports(ctx context.Context, groupInfo *model.AiBotGroup, reports []*bbxt.ReportRes) (err error) { + if len(reports) == 0 { + return errors.New("report is empty") + } + + title := fmt.Sprintf("截止%s日报", time.Now().Format("1月2日15点")) + reportChan := make(chan string, len(reports)*2) + writeCount := 0 + for _, v := range reports { + if v == nil { + continue + } + reportChan <- fmt.Sprintf("**%s**", v.Title) + reportChan <- fmt.Sprintf("![图片](%s)", v.Url) + writeCount += 2 + } + close(reportChan) + if writeCount == 0 { + return errors.New("report is empty") + } + err = d.HandleStreamRes(ctx, &chatbot.BotCallbackDataModel{ + RobotCode: groupInfo.RobotCode, + ConversationType: constants.ConversationTypeGroup, + ConversationId: groupInfo.ConversationID, + Text: chatbot.BotCallbackDataTextModel{ + Content: title, + }, + }, reportChan) + return +} + func (d *DingTalkBotBiz) GetGroupInfo(ctx context.Context, groupId int) (group model.AiBotGroup, err error) { cond := builder.NewCond() diff --git a/internal/biz/handle/dingtalk/send_card.go b/internal/biz/handle/dingtalk/send_card.go index 4660f33..d2e5cb7 100644 --- a/internal/biz/handle/dingtalk/send_card.go +++ b/internal/biz/handle/dingtalk/send_card.go @@ -20,7 +20,7 @@ import ( ) const DefaultInterval = 100 * time.Millisecond -const HeardBeatX = 1000 +const HeardBeatX = 100 type SendCardClient struct { Auth *Auth diff --git a/internal/services/cron.go b/internal/services/cron.go index e3c5604..b1f1023 100644 --- a/internal/services/cron.go +++ b/internal/services/cron.go @@ -50,12 +50,18 @@ func (d *CronService) CronReportSendDingTalk(ctx context.Context) error { return err } - for _, report := range reports { - err = d.dingTalkBotBiz.SendReport(ctx, &groupInfo, report) - if err != nil { - log.Error(err) - continue - } + // for _, report := range reports { + // err = d.dingTalkBotBiz.SendReport(ctx, &groupInfo, report) + // if err != nil { + // log.Error(err) + // continue + // } + // } + + err = d.dingTalkBotBiz.SendReports(ctx, &groupInfo, reports) + if err != nil { + log.Error(err) + return err } return nil } diff --git a/internal/services/dtalk_bot_test.go b/internal/services/dtalk_bot_test.go index 37c206e..8e9e477 100644 --- a/internal/services/dtalk_bot_test.go +++ b/internal/services/dtalk_bot_test.go @@ -92,7 +92,7 @@ func run() { // 初始化Ollama服务 ollamaService := llm_service.NewOllamaGenerate(client, utils_vllmClient, configConfig, chatHisImpl) // 初始化工具管理器 - manager := tools.NewManager(configConfig, client) + manager := tools.NewManager(configConfig, client, rdb) // 初始化钉钉联系人客户端 contactClient, _ := dingtalk.NewContactClient(configConfig) // 初始化钉钉记事本客户端 @@ -120,8 +120,10 @@ func run() { group := qywx.NewGroup(botGroupQywxImpl, qywxAuth) other := qywx.NewOther(qywxAuth) qywxAppBiz := biz.NewQywxAppBiz(configConfig, botGroupQywxImpl, group, other) - groupConfigBiz := biz.NewGroupConfigBiz(toolRegis, utils_ossClient, botGroupConfigImpl, registry, configConfig, impl.NewReportDailyCacheImpl(db), rdb) - dingTalkBotBiz := biz.NewDingTalkBotBiz(doDo, handle, botConfigImpl, botGroupImpl, user, botChatHisImpl, impl.NewReportDailyCacheImpl(db), manager, configConfig, sendCardClient, groupConfigBiz) + reportDailyCacheImpl := impl.NewReportDailyCacheImpl(db) + macro := do.NewMacro(botGroupImpl, reportDailyCacheImpl, configConfig, rdb) + groupConfigBiz := biz.NewGroupConfigBiz(toolRegis, utils_ossClient, botGroupConfigImpl, registry, configConfig, impl.NewReportDailyCacheImpl(db), rdb, macro, manager, handle) + dingTalkBotBiz := biz.NewDingTalkBotBiz(doDo, handle, botConfigImpl, botGroupImpl, user, botChatHisImpl, reportDailyCacheImpl, manager, configConfig, sendCardClient, groupConfigBiz, macro) // 初始化钉钉机器人服务 cronService = NewCronService(configConfig, dingTalkBotBiz, qywxAppBiz, groupConfigBiz) }