Compare commits
5 Commits
94c4a8fae8
...
d3fe7ded1a
| Author | SHA1 | Date |
|---|---|---|
|
|
d3fe7ded1a | |
|
|
5d1649de96 | |
|
|
fa53d5f950 | |
|
|
2d974f2e03 | |
|
|
b7e9ab8bcf |
|
|
@ -142,7 +142,7 @@ eino_tools:
|
||||||
# == 通用工具 ==
|
# == 通用工具 ==
|
||||||
# 表格转图片
|
# 表格转图片
|
||||||
excel2pic:
|
excel2pic:
|
||||||
base_url: "http://excel2pic:8000/api/v1/convert"
|
base_url: "http://192.168.6.109:8010/api/v1/convert"
|
||||||
|
|
||||||
dingtalk:
|
dingtalk:
|
||||||
api_key: "dingsbbntrkeiyazcfdg"
|
api_key: "dingsbbntrkeiyazcfdg"
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
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)
|
reportChan := make(chan string, 10)
|
||||||
defer close(reportChan)
|
defer close(reportChan)
|
||||||
reportChan <- report.Title
|
reportChan <- report.Title
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
}
|
||||||
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"ai_scheduler/internal/pkg/l_request"
|
"ai_scheduler/internal/pkg/l_request"
|
||||||
"ai_scheduler/internal/tools/bbxt"
|
"ai_scheduler/internal/tools/bbxt"
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -111,6 +112,10 @@ func (q *QywxAppBiz) SendReport(ctx context.Context, groupInfo *model.AiBotGroup
|
||||||
|
|
||||||
// SendReportV2 发送到货易通指定的群聊
|
// SendReportV2 发送到货易通指定的群聊
|
||||||
func (q *QywxAppBiz) SendReportHYT(ctx context.Context, groupInfo *model.AiBotGroupQywx, report *bbxt.ReportRes) (err error) {
|
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{
|
err = q.sendReportHYT(groupInfo, &bbxt.ReportRes{
|
||||||
Title: report.Title,
|
Title: report.Title,
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,17 @@ package biz
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"ai_scheduler/internal/biz/handle/qywx"
|
"ai_scheduler/internal/biz/handle/qywx"
|
||||||
|
"ai_scheduler/internal/biz/tools_regis"
|
||||||
"ai_scheduler/internal/config"
|
"ai_scheduler/internal/config"
|
||||||
"ai_scheduler/internal/data/impl"
|
"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"
|
"ai_scheduler/utils"
|
||||||
"context"
|
"context"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
@ -18,6 +27,7 @@ func Test_InitGroup(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
configConfig *config.Config
|
configConfig *config.Config
|
||||||
qywxAppBiz *QywxAppBiz
|
qywxAppBiz *QywxAppBiz
|
||||||
|
groupConfigBiz *GroupConfigBiz
|
||||||
)
|
)
|
||||||
|
|
||||||
func run() {
|
func run() {
|
||||||
|
|
@ -28,6 +38,21 @@ 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)
|
||||||
|
sessionImpl := impl.NewSessionImpl(db)
|
||||||
other := qywx.NewOther(qywxAuth)
|
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)
|
qywxAppBiz = NewQywxAppBiz(configConfig, botGroupQywxImpl, group, other)
|
||||||
|
groupConfigBiz = NewGroupConfigBiz(toolRegis, utils_ossClient, botGroupConfigImpl, registry, configConfig)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"ai_scheduler/internal/data/impl"
|
"ai_scheduler/internal/data/impl"
|
||||||
"ai_scheduler/internal/data/model"
|
"ai_scheduler/internal/data/model"
|
||||||
"ai_scheduler/internal/entitys"
|
"ai_scheduler/internal/entitys"
|
||||||
|
"ai_scheduler/internal/pkg/util"
|
||||||
"context"
|
"context"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -151,9 +152,24 @@ func (s *SessionBiz) SessionList(ctx context.Context, req *entitys.SessionListRe
|
||||||
list, err = s.sessionRepo.FindAll(
|
list, err = s.sessionRepo.FindAll(
|
||||||
s.sessionRepo.WithUserId(req.UserId), // 条件:用户ID
|
s.sessionRepo.WithUserId(req.UserId), // 条件:用户ID
|
||||||
s.sessionRepo.WithSysId(req.SysId), // 条件:系统ID
|
s.sessionRepo.WithSysId(req.SysId), // 条件:系统ID
|
||||||
|
s.sessionRepo.WithDeleteAt(), // 条件:未删除
|
||||||
s.sessionRepo.PaginateScope(req.Page, req.PageSize), // 分页
|
s.sessionRepo.PaginateScope(req.Page, req.PageSize), // 分页
|
||||||
s.sessionRepo.OrderByDesc("create_at"), // 排序:按创建时间降序
|
s.sessionRepo.OrderByDesc("create_at"), // 排序:按创建时间降序
|
||||||
)
|
)
|
||||||
|
|
||||||
return
|
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
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,9 @@ import (
|
||||||
"ai_scheduler/internal/data/model"
|
"ai_scheduler/internal/data/model"
|
||||||
"ai_scheduler/tmpl/dataTemp"
|
"ai_scheduler/tmpl/dataTemp"
|
||||||
"ai_scheduler/utils"
|
"ai_scheduler/utils"
|
||||||
"gorm.io/gorm"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SessionImpl struct {
|
type SessionImpl struct {
|
||||||
|
|
@ -46,3 +47,10 @@ func (impl *SessionImpl) WithSessionId(sessionId interface{}) CondFunc {
|
||||||
return db.Where("session_id = ?", sessionId)
|
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")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,3 +28,7 @@ type UseFulRequest struct {
|
||||||
HisId int64 `json:"his_id"`
|
HisId int64 `json:"his_id"`
|
||||||
Useful int32 `json:"useful"`
|
Useful int32 `json:"useful"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SessionDeleteRequest struct {
|
||||||
|
SessionId string `json:"session_id"`
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,13 +41,13 @@ func (c *CronServer) InitJobs(ctx context.Context) {
|
||||||
c.jobs = []*cronJob{
|
c.jobs = []*cronJob{
|
||||||
{
|
{
|
||||||
Func: c.cronService.CronReportSendDingTalk,
|
Func: c.cronService.CronReportSendDingTalk,
|
||||||
Name: "直连天下报表推送",
|
Name: "直连天下报表推送(钉钉)",
|
||||||
Schedule: "0 12,18,23 * * *",
|
Schedule: "20 12,18,23 * * *",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Func: c.cronService.CronReportSendQywx,
|
Func: c.cronService.CronReportSendQywx,
|
||||||
Name: "直连天下报表推送",
|
Name: "直连天下报表推送(微信)",
|
||||||
Schedule: "0 12,18,23 * * *",
|
Schedule: "20 12,18,23 * * *",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ func SetupRoutes(app *fiber.App, ChatService *services.ChatService, sessionServi
|
||||||
r.Post("/session/new", sessionService.NewSession)
|
r.Post("/session/new", sessionService.NewSession)
|
||||||
r.Post("/session/init", sessionService.SessionInit) // 会话初始化,不存在则创建,存在则返回会话ID和默认条数会话历史
|
r.Post("/session/init", sessionService.SessionInit) // 会话初始化,不存在则创建,存在则返回会话ID和默认条数会话历史
|
||||||
r.Post("/session/list", sessionService.SessionList)
|
r.Post("/session/list", sessionService.SessionList)
|
||||||
|
r.Post("/session/delete", sessionService.DeleteSession) // 删除会话
|
||||||
|
|
||||||
r.Post("/sys/tasks", task.Tasks)
|
r.Post("/sys/tasks", task.Tasks)
|
||||||
// 评价
|
// 评价
|
||||||
|
|
|
||||||
|
|
@ -69,3 +69,21 @@ func (s *SessionService) SessionList(c *fiber.Ctx) error {
|
||||||
"session_list": sessionList,
|
"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",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,8 @@ func Test_GetStatisOfficialProductSumDecline(t *testing.T) {
|
||||||
}
|
}
|
||||||
s := "官方--腾讯-周卡,官方--腾讯-月卡,官方--腾讯-季卡,官方--腾讯-年卡,官方--优酷周卡,官方--优酷月卡,官方--优酷季卡,官方--优酷年卡,官方--爱奇艺-周卡,官方--爱奇艺-月卡,官方--爱奇艺-季卡,官方--爱奇艺-年卡,官方--芒果-PC周卡,官方--芒果-PC月卡,官方--芒果-PC季卡,官方--美团外卖红包5元,官方--美团外卖红包10元,官方--QQ音乐-绿钻月卡,官方--饿了么超级会员月卡,官方--网易云黑胶vip月卡,官方--喜马拉雅巅峰会员月卡"
|
s := "官方--腾讯-周卡,官方--腾讯-月卡,官方--腾讯-季卡,官方--腾讯-年卡,官方--优酷周卡,官方--优酷月卡,官方--优酷季卡,官方--优酷年卡,官方--爱奇艺-周卡,官方--爱奇艺-月卡,官方--爱奇艺-季卡,官方--爱奇艺-年卡,官方--芒果-PC周卡,官方--芒果-PC月卡,官方--芒果-PC季卡,官方--美团外卖红包5元,官方--美团外卖红包10元,官方--QQ音乐-绿钻月卡,官方--饿了么超级会员月卡,官方--网易云黑胶vip月卡,官方--喜马拉雅巅峰会员月卡"
|
||||||
//s := "官方--QQ音乐-绿钻月卡"
|
//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)
|
t.Log(report, err)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue