fix: 1.解决日报发送时间间隔极长问题 2.调整协程超时时长 1000s -> 100s 3.修改部分无关配置、单元测试

This commit is contained in:
fuzhongyun 2026-02-08 15:56:36 +08:00
parent 21585e731f
commit b41e68fd09
5 changed files with 52 additions and 10 deletions

View File

@ -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:

View File

@ -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()

View File

@ -20,7 +20,7 @@ import (
)
const DefaultInterval = 100 * time.Millisecond
const HeardBeatX = 1000
const HeardBeatX = 100
type SendCardClient struct {
Auth *Auth

View File

@ -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
}

View File

@ -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)
}