Compare commits

..

5 Commits

Author SHA1 Message Date
fuzhongyun d3fe7ded1a fix: 1. session列表移除删除记录 2. 新增删除session记录接口 2026-01-14 15:59:49 +08:00
fuzhongyun 5d1649de96 merge branch v4 2026-01-14 10:42:30 +08:00
fuzhongyun fa53d5f950 Merge branch 'v4' 2026-01-14 10:42:16 +08:00
renzhiyuan 2d974f2e03 fix: 增加报表空值检查,优化推送逻辑 2026-01-12 14:08:47 +08:00
renzhiyuan b7e9ab8bcf fix: 调整报表推送任务执行时间 2026-01-12 11:43:13 +08:00
12 changed files with 102 additions and 10 deletions

View File

@ -142,7 +142,7 @@ eino_tools:
# == 通用工具 ==
# 表格转图片
excel2pic:
base_url: "http://excel2pic:8000/api/v1/convert"
base_url: "http://192.168.6.109:8010/api/v1/convert"
dingtalk:
api_key: "dingsbbntrkeiyazcfdg"

View File

@ -378,7 +378,9 @@ func (d *DingTalkBotBiz) HandleStreamRes(ctx context.Context, data *chatbot.BotC
}
func (d *DingTalkBotBiz) SendReport(ctx context.Context, groupInfo *model.AiBotGroup, report *bbxt.ReportRes) (err error) {
if report == nil {
return errors.New("report is nil")
}
reportChan := make(chan string, 10)
defer close(reportChan)
reportChan <- report.Title

View File

@ -0,0 +1,12 @@
package biz
import (
"context"
"testing"
)
func Test_report(t *testing.T) {
run()
chatId, err := groupConfigBiz.GetReportLists(context.Background(), nil)
t.Log(chatId, err)
}

View File

@ -10,6 +10,7 @@ import (
"ai_scheduler/internal/pkg/l_request"
"ai_scheduler/internal/tools/bbxt"
"context"
"fmt"
"log"
"strings"
"time"
@ -111,6 +112,10 @@ func (q *QywxAppBiz) SendReport(ctx context.Context, groupInfo *model.AiBotGroup
// SendReportV2 发送到货易通指定的群聊
func (q *QywxAppBiz) SendReportHYT(ctx context.Context, groupInfo *model.AiBotGroupQywx, report *bbxt.ReportRes) (err error) {
if report == nil {
return fmt.Errorf("report is nil")
}
// 文本消息
err = q.sendReportHYT(groupInfo, &bbxt.ReportRes{
Title: report.Title,

View File

@ -2,8 +2,17 @@ package biz
import (
"ai_scheduler/internal/biz/handle/qywx"
"ai_scheduler/internal/biz/tools_regis"
"ai_scheduler/internal/config"
"ai_scheduler/internal/data/impl"
"ai_scheduler/internal/domain/component"
"ai_scheduler/internal/domain/component/callback"
"ai_scheduler/internal/domain/repo"
"ai_scheduler/internal/domain/workflow"
"ai_scheduler/internal/pkg"
"ai_scheduler/internal/pkg/lsxd"
"ai_scheduler/internal/pkg/utils_ollama"
"ai_scheduler/internal/pkg/utils_oss"
"ai_scheduler/utils"
"context"
"testing"
@ -18,6 +27,7 @@ func Test_InitGroup(t *testing.T) {
var (
configConfig *config.Config
qywxAppBiz *QywxAppBiz
groupConfigBiz *GroupConfigBiz
)
func run() {
@ -28,6 +38,21 @@ func run() {
botGroupQywxImpl := impl.NewBotGroupQywxImpl(db)
qywxAuth := qywx.NewAuth(configConfig, rdb)
group := qywx.NewGroup(botGroupQywxImpl, qywxAuth)
sessionImpl := impl.NewSessionImpl(db)
other := qywx.NewOther(qywxAuth)
repos := repo.NewRepos(sessionImpl, configConfig, rdb)
pkgRdb := pkg.NewRdb(configConfig)
redisManager := callback.NewRedisManager(pkgRdb)
login := lsxd.NewLogin(configConfig, rdb)
components := component.NewComponents(redisManager, login)
repos = repo.NewRepos(sessionImpl, configConfig, rdb)
botToolsImpl := impl.NewBotToolsImpl(db)
toolRegis := tools_regis.NewToolsRegis(botToolsImpl)
utils_ossClient, _ := utils_oss.NewClient(configConfig)
client, _, _ := utils_ollama.NewClient(configConfig)
registry := workflow.NewRegistry(configConfig, client, repos, components)
botGroupConfigImpl := impl.NewBotGroupConfigImpl(db)
qywxAppBiz = NewQywxAppBiz(configConfig, botGroupQywxImpl, group, other)
groupConfigBiz = NewGroupConfigBiz(toolRegis, utils_ossClient, botGroupConfigImpl, registry, configConfig)
}

View File

@ -6,6 +6,7 @@ import (
"ai_scheduler/internal/data/impl"
"ai_scheduler/internal/data/model"
"ai_scheduler/internal/entitys"
"ai_scheduler/internal/pkg/util"
"context"
"time"
@ -151,9 +152,24 @@ func (s *SessionBiz) SessionList(ctx context.Context, req *entitys.SessionListRe
list, err = s.sessionRepo.FindAll(
s.sessionRepo.WithUserId(req.UserId), // 条件用户ID
s.sessionRepo.WithSysId(req.SysId), // 条件系统ID
s.sessionRepo.WithDeleteAt(), // 条件:未删除
s.sessionRepo.PaginateScope(req.Page, req.PageSize), // 分页
s.sessionRepo.OrderByDesc("create_at"), // 排序:按创建时间降序
)
return
}
// DeleteSession 删除会话
func (s *SessionBiz) DeleteSession(ctx context.Context, req *entitys.SessionDeleteRequest) error {
err := s.sessionRepo.Update(
&model.AiSession{
DeleteAt: util.AnyToPoint(time.Now()), // 设置删除时间
},
s.sessionRepo.WithSessionId(req.SessionId), // 条件会话ID
)
if err != nil {
return err
}
return nil
}

View File

@ -4,8 +4,9 @@ import (
"ai_scheduler/internal/data/model"
"ai_scheduler/tmpl/dataTemp"
"ai_scheduler/utils"
"gorm.io/gorm"
"time"
"gorm.io/gorm"
)
type SessionImpl struct {
@ -46,3 +47,10 @@ func (impl *SessionImpl) WithSessionId(sessionId interface{}) CondFunc {
return db.Where("session_id = ?", sessionId)
}
}
// WithDeletedAt 条件:是否删除
func (impl *SessionImpl) WithDeleteAt() CondFunc {
return func(db *gorm.DB) *gorm.DB {
return db.Where("delete_at IS NULL")
}
}

View File

@ -28,3 +28,7 @@ type UseFulRequest struct {
HisId int64 `json:"his_id"`
Useful int32 `json:"useful"`
}
type SessionDeleteRequest struct {
SessionId string `json:"session_id"`
}

View File

@ -41,13 +41,13 @@ func (c *CronServer) InitJobs(ctx context.Context) {
c.jobs = []*cronJob{
{
Func: c.cronService.CronReportSendDingTalk,
Name: "直连天下报表推送",
Schedule: "0 12,18,23 * * *",
Name: "直连天下报表推送(钉钉)",
Schedule: "20 12,18,23 * * *",
},
{
Func: c.cronService.CronReportSendQywx,
Name: "直连天下报表推送",
Schedule: "0 12,18,23 * * *",
Name: "直连天下报表推送(微信)",
Schedule: "20 12,18,23 * * *",
},
}
}

View File

@ -59,6 +59,7 @@ func SetupRoutes(app *fiber.App, ChatService *services.ChatService, sessionServi
r.Post("/session/new", sessionService.NewSession)
r.Post("/session/init", sessionService.SessionInit) // 会话初始化,不存在则创建,存在则返回会话ID和默认条数会话历史
r.Post("/session/list", sessionService.SessionList)
r.Post("/session/delete", sessionService.DeleteSession) // 删除会话
r.Post("/sys/tasks", task.Tasks)
// 评价

View File

@ -69,3 +69,21 @@ func (s *SessionService) SessionList(c *fiber.Ctx) error {
"session_list": sessionList,
})
}
// DeleteSession 删除会话
func (s *SessionService) DeleteSession(c *fiber.Ctx) error {
req := &entitys.SessionDeleteRequest{}
if err := c.BodyParser(req); err != nil {
return err
}
err := s.sessionBiz.DeleteSession(c.Context(), req)
if err != nil {
return err
}
return c.JSON(fiber.Map{
"message": "success",
})
}

View File

@ -72,7 +72,8 @@ func Test_GetStatisOfficialProductSumDecline(t *testing.T) {
}
s := "官方--腾讯-周卡,官方--腾讯-月卡,官方--腾讯-季卡,官方--腾讯-年卡,官方--优酷周卡,官方--优酷月卡,官方--优酷季卡,官方--优酷年卡,官方--爱奇艺-周卡,官方--爱奇艺-月卡,官方--爱奇艺-季卡,官方--爱奇艺-年卡,官方--芒果-PC周卡,官方--芒果-PC月卡,官方--芒果-PC季卡,官方--美团外卖红包5元,官方--美团外卖红包10元,官方--QQ音乐-绿钻月卡,官方--饿了么超级会员月卡,官方--网易云黑胶vip月卡,官方--喜马拉雅巅峰会员月卡"
//s := "官方--QQ音乐-绿钻月卡"
report, err := o.GetStatisOfficialProductSumDecline(time.Now(), 1000, strings.Split(s, ","), -150)
now := time.Now()
report, err := o.GetStatisOfficialProductSumDecline(time.Date(now.Year(), now.Month(), now.Day(), 12, 0, 0, 0, now.Location()), 1000, strings.Split(s, ","), -150)
t.Log(report, err)