feat: 增加日报货易通微信群组发送

This commit is contained in:
fuzhongyun 2026-01-08 15:44:59 +08:00
parent f1346a604c
commit 11e0982845
5 changed files with 74 additions and 3 deletions

View File

@ -165,7 +165,7 @@ qywx:
chat_id_len: 16 chat_id_len: 16
default_config_id: 1 default_config_id: 1
bot_group_id: bot_group_id:
bbxt: 23 bbxt: 37
default_prompt: default_prompt:
img_recognize: img_recognize:

View File

@ -148,6 +148,17 @@ dingtalk:
bot_group_id: bot_group_id:
bbxt: 23 bbxt: 23
qywx:
corp_id: "ww48151f694fb8ec67"
app_secret: "uYqtdwdtdH4Uv_P4is2AChuGzBCoB6cQDyRvpbW0Vmk"
token: "zJdukry6"
aes_key: "4VLH47qRGUogc2d3QLWuUhvJlk8Y0YuRjXzeBquBq8B"
init_account: "les.,FuZhongYun"
chat_id_len: 16
default_config_id: 1
bot_group_id:
bbxt: 36
default_prompt: default_prompt:
img_recognize: img_recognize:

View File

@ -160,7 +160,7 @@ qywx:
chat_id_len: 16 chat_id_len: 16
default_config_id: 1 default_config_id: 1
bot_group_id: bot_group_id:
bbxt: 35 bbxt: 36
default_prompt: default_prompt:
img_recognize: img_recognize:

View File

@ -3,11 +3,14 @@ package biz
import ( import (
"ai_scheduler/internal/biz/handle/qywx" "ai_scheduler/internal/biz/handle/qywx"
"ai_scheduler/internal/data/constants" "ai_scheduler/internal/data/constants"
errors "ai_scheduler/internal/data/error"
"ai_scheduler/internal/data/impl" "ai_scheduler/internal/data/impl"
"ai_scheduler/internal/data/model" "ai_scheduler/internal/data/model"
"ai_scheduler/internal/pkg" "ai_scheduler/internal/pkg"
"ai_scheduler/internal/pkg/l_request"
"ai_scheduler/internal/tools/bbxt" "ai_scheduler/internal/tools/bbxt"
"context" "context"
"log"
"strings" "strings"
"time" "time"
@ -105,3 +108,59 @@ func (q *QywxAppBiz) SendReport(ctx context.Context, groupInfo *model.AiBotGroup
} }
return return
} }
// SendReportV2 发送到货易通指定的群聊
func (q *QywxAppBiz) SendReportHYT(ctx context.Context, groupInfo *model.AiBotGroupQywx, report *bbxt.ReportRes) (err error) {
// 文本消息
err = q.sendReportHYT(groupInfo, &bbxt.ReportRes{
Title: report.Title,
})
if err != nil {
return err
}
time.Sleep(1 * time.Second) // 等待1秒避免被频控
// 图片消息
err = q.sendReportHYT(groupInfo, &bbxt.ReportRes{
ReportName: report.ReportName,
Url: report.Url,
})
if err != nil {
return err
}
time.Sleep(1 * time.Second) // 等待1秒避免被频控
return nil
}
func (q *QywxAppBiz) sendReportHYT(groupInfo *model.AiBotGroupQywx, report *bbxt.ReportRes) (err error) {
req := l_request.Request{
Method: "POST",
Url: "https://hyt.86698.cn/admin_upload/api/v1/sendWxCommon",
Headers: map[string]string{
"Content-Type": "application/json",
},
Json: map[string]interface{}{
"room_id": groupInfo.ChatID, // 群ID
"oss_url": report.Url, // 图片URL
"file_type": 2, // 文件类型2:图片
"file_name": report.ReportName, // 文件名称
"content": report.Title, // 输入文本,此处有值就走文本发送,没有就走文件发送
},
}
resp, err := req.Send()
if err != nil {
return err
}
if resp.StatusCode != 200 {
return errors.SysErrf("发送到货易通群聊失败,状态码:%d", resp.StatusCode)
}
// 记录相应结果日志
log.Printf("发送到货易通群聊成功,状态码:%d, 响应体:%s", resp.StatusCode, resp.Text)
return nil
}

View File

@ -28,5 +28,6 @@ func run() {
botGroupQywxImpl := impl.NewBotGroupQywxImpl(db) botGroupQywxImpl := impl.NewBotGroupQywxImpl(db)
qywxAuth := qywx.NewAuth(configConfig, rdb) qywxAuth := qywx.NewAuth(configConfig, rdb)
group := qywx.NewGroup(botGroupQywxImpl, qywxAuth) group := qywx.NewGroup(botGroupQywxImpl, qywxAuth)
qywxAppBiz = NewQywxAppBiz(configConfig, botGroupQywxImpl, group) other := qywx.NewOther(qywxAuth)
qywxAppBiz = NewQywxAppBiz(configConfig, botGroupQywxImpl, group, other)
} }