Merge branch 'master' into test
This commit is contained in:
commit
b7d042ff20
|
|
@ -28,7 +28,10 @@ func main() {
|
|||
}()
|
||||
//钉钉机器人
|
||||
app.DingBotServer.Run(ctx, *onBot)
|
||||
//定时任务
|
||||
// app.Cron.Run(ctx)
|
||||
//定时任务 - 测试环境不启用
|
||||
if configPath != nil && *configPath == "./config/config.yaml" {
|
||||
app.Cron.Run(ctx)
|
||||
}
|
||||
|
||||
log.Fatal(app.HttpServer.Listen(fmt.Sprintf(":%d", bc.Server.Port)))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,19 @@ vllm:
|
|||
|
||||
coze:
|
||||
base_url: "https://api.coze.cn"
|
||||
api_secret: "sat_AqvFcdNgesP8megy1ItTscWFXRcsHRzmM4NJ1KNavfcdT0EPwYuCPkDqGhItpx13"
|
||||
|
||||
redis:
|
||||
host: 47.97.27.195:6379
|
||||
type: node
|
||||
pass:
|
||||
lansexiongdi@666i_secret: "sat_AqvFcdNgesP8megy1ItTscWFXRcsHRzmM4NJ1KNavfcdT0EPwYuCPkDqGhItpx13"
|
||||
|
||||
lsxd:
|
||||
# 统一登录
|
||||
login_url: "https://api.user.1688sup.com/v1/login/phone"
|
||||
phone: "ORlviZN7N06W2+WKLe76xg=="
|
||||
password: "V5Uh8C4bamEM6UQZh4TCeQ=="
|
||||
check_token_url: "https://api.user.1688sup.com/v1/user/welcome"
|
||||
|
||||
|
||||
sys:
|
||||
|
|
@ -30,10 +42,6 @@ sys:
|
|||
channel_pool_size: 32
|
||||
llm_pool_len: 5
|
||||
heartbeat_interval: 30
|
||||
redis:
|
||||
host: 47.97.27.195:6379
|
||||
type: node
|
||||
pass: lansexiongdi@666
|
||||
key: report-api
|
||||
pollSize: 5 #连接池大小,不配置,或配置为0表示不启用连接池
|
||||
minIdleConns: 2 #最小空闲连接数
|
||||
|
|
@ -128,7 +136,8 @@ eino_tools:
|
|||
# 我们的商品统计
|
||||
rechargeStatisticsOursProduct:
|
||||
base_url: "http://admin.lanseds.cn/admin/statistics/oursProduct"
|
||||
api_key: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ1c2VyQ2VudGVyIiwiZXhwIjoxNzY3MTc5ODgzLCJuYmYiOjE3NjcxNjkwODMsImp0aSI6IjEiLCJQaG9uZSI6IjE4MjAwMTYwMTQzIiwiVXNlck5hbWUiOiJsc3hkIiwiUmVhbE5hbWUiOiLotoXnuqfnrqHnkIblkZgiLCJBY2NvdW50VHlwZSI6MiwiR3JvdXBDb2RlcyI6IkxTWEREU19TWVNURU0sU1RBVElTVElDQUxTWVNURU1fQURNSU4sUEhZU0lDQUxHT09EU19BRE1JTiIsIkRpbmdVc2VySWQiOiIifQ.ELNF1Iv6yEwA12nCbXGKwXCw-F5Gq4GI2t2nqo1PlSkFdQ5Oz5s5NwV0RUXA66LxCggI-9IjBtFI1MvBHpvTHq9QRlm-HKzVTMcOBkEtKEfCCI6SPKVTAZyntTJlWPKG3u-CJUotT5YW0j2rU1VcpA7uGEiY7gs5VPUOZ80R1uGJ7HBSqVI2DRqar6STa1xryygdCjK7qamUM2d6aJ6r9VPTBt-JO6dkDdw3KHs3wl-PGM3wcbXHZ2aC18WFd_PxLmtjqErpxTEkdUBCnUHOSKDePG0henDJq71Nh3yRdRmY9VvszHMyIxJA2BVGPIPUT_Y5aewaaEMQVEjhiBnn-Q"
|
||||
# == 通用工具 ==
|
||||
# 表格转图片
|
||||
excel2pic:
|
||||
base_url: "http://192.168.6.109:8010/api/v1/convert"
|
||||
|
||||
|
|
@ -139,6 +148,9 @@ dingtalk:
|
|||
url: "https://alidocs.dingtalk.com/i/nodes/2Amq4vjg89RnYx9DTp66m2orW3kdP0wQ"
|
||||
base_id: "2Amq4vjg89RnYx9DTp66m2orW3kdP0wQ"
|
||||
sheet_id_or_name: "数据表"
|
||||
# 机器人群组
|
||||
bot_group_id:
|
||||
bbxt: 28
|
||||
|
||||
default_prompt:
|
||||
img_recognize:
|
||||
|
|
|
|||
|
|
@ -25,10 +25,10 @@ coze:
|
|||
|
||||
lsxd:
|
||||
# 统一登录
|
||||
login_url: "http://api.test.user.1688sup.com/v1/login/phone"
|
||||
phone: "0zmINhJBwsDJYTmeaxXK4A=="
|
||||
password: "LSSGoWhc63NpZc1rq3LT8g=="
|
||||
check_token_url: "http://api.test.user.1688sup.com/v1/user/welcome"
|
||||
login_url: "https://api.user.1688sup.com/v1/login/phone"
|
||||
phone: "ORlviZN7N06W2+WKLe76xg=="
|
||||
password: "V5Uh8C4bamEM6UQZh4TCeQ=="
|
||||
check_token_url: "https://api.user.1688sup.com/v1/user/welcome"
|
||||
|
||||
|
||||
sys:
|
||||
|
|
@ -131,8 +131,9 @@ eino_tools:
|
|||
# == 电商充值系统 ==
|
||||
# 我们的商品统计
|
||||
rechargeStatisticsOursProduct:
|
||||
base_url: "http://admin.1688sup.cn:8001/admin/statistics/oursProduct"
|
||||
api_key: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ1c2VyQ2VudGVyIiwiZXhwIjoxNzY3MDc3NzcwLCJuYmYiOjE3NjcwNzU5NzAsImp0aSI6IjEiLCJQaG9uZSI6IjE4MDAwMDAwMDAwIiwiVXNlck5hbWUiOiJsc3hkIiwiUmVhbE5hbWUiOiLotoXnuqfnrqHnkIblkZgiLCJBY2NvdW50VHlwZSI6MSwiR3JvdXBDb2RlcyI6IlZDTF9DQVNISUVSLFZDTF9PUEVSQVRFLFZDTF9BRE1JTixWQ0xfQUFBLFZDTF9WQ0xfT1BFUkFULFZDTF9JTlZPSUNFLENSTV9BRE1JTixMSUFOTElBTl9BRE1JTixNQVJLRVRNQUcyX0FETUlOLFBIT05FQklMTF9BRE1JTixRSUFOWkhVX1NVUFBFUl9BRE0sTUFSS0VUSU5HU0FBU19TVVBFUkFETUlOLENBUkRfQ09ERSxDQVJEX1BST0NVUkVNRU5ULE1BUktFVElOR1NZU1RFTV9TVVBFUixTVEFUSVNUSUNBTFNZU1RFTV9BRE1JTixaTFRYX0FETUlOLFpMVFhfT1BFUkFURSIsIkRpbmdVc2VySWQiOiIxNjIwMjYxMjMwMjg5MzM4MzQifQ.Nuw_aR6iSPmhhh9E5rhyTxHBsgWtaTZvbnc7SFTnUBJXTQvYahnk0LyZaVpsVw6FB3cU0F5xOdX3rmGyWyaiszWO6yi-o1oxGMXwhf39fMiWT2xUI6pAn9Ync8DmZ4tOMCNUTdEk4CaQFzrTwJs0c-VR4yW6LgoPmNPvUVZ-KwmusUpnPz5j9RsJItzIWE3bpGGsfB54e2UERcZdbo9BXxCZIBbpAYKBKdl73KuI8SNaXgKvGTrJ6hEN4ESpnbisJVwT5pp_kuChJlcfjHTHFsEf4RJDjN9gTrtDbBWZyY3OmO2ukqYAM7tZPs6TXJwvQGJQsFRVZUBGxS1nD_6DzQ"
|
||||
base_url: "http://admin.lanseds.cn/admin/statistics/oursProduct"
|
||||
# == 通用工具 ==
|
||||
# 表格转图片
|
||||
excel2pic:
|
||||
base_url: "http://192.168.6.109:8010/api/v1/convert"
|
||||
|
||||
|
|
@ -143,6 +144,9 @@ dingtalk:
|
|||
url: "https://alidocs.dingtalk.com/i/nodes/YQBnd5ExVE6qAbnOiANQg2KKJyeZqMmz"
|
||||
base_id: "YQBnd5ExVE6qAbnOiANQg2KKJyeZqMmz"
|
||||
sheet_id_or_name: "数据表"
|
||||
# 机器人群组
|
||||
bot_group_id:
|
||||
bbxt: 23
|
||||
|
||||
|
||||
default_prompt:
|
||||
|
|
|
|||
|
|
@ -24,6 +24,13 @@ coze:
|
|||
api_secret: "sat_AqvFcdNgesP8megy1ItTscWFXRcsHRzmM4NJ1KNavfcdT0EPwYuCPkDqGhItpx13"
|
||||
|
||||
|
||||
lsxd:
|
||||
# 统一登录
|
||||
login_url: "https://api.user.1688sup.com/v1/login/phone"
|
||||
phone: "ORlviZN7N06W2+WKLe76xg=="
|
||||
password: "V5Uh8C4bamEM6UQZh4TCeQ=="
|
||||
check_token_url: "https://api.user.1688sup.com/v1/user/welcome"
|
||||
|
||||
sys:
|
||||
session_len: 6
|
||||
channel_pool_len: 100
|
||||
|
|
@ -128,7 +135,8 @@ eino_tools:
|
|||
# 我们的商品统计
|
||||
rechargeStatisticsOursProduct:
|
||||
base_url: "http://admin.lanseds.cn/admin/statistics/oursProduct"
|
||||
api_key: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ1c2VyQ2VudGVyIiwiZXhwIjoxNzY3MTc5ODgzLCJuYmYiOjE3NjcxNjkwODMsImp0aSI6IjEiLCJQaG9uZSI6IjE4MjAwMTYwMTQzIiwiVXNlck5hbWUiOiJsc3hkIiwiUmVhbE5hbWUiOiLotoXnuqfnrqHnkIblkZgiLCJBY2NvdW50VHlwZSI6MiwiR3JvdXBDb2RlcyI6IkxTWEREU19TWVNURU0sU1RBVElTVElDQUxTWVNURU1fQURNSU4sUEhZU0lDQUxHT09EU19BRE1JTiIsIkRpbmdVc2VySWQiOiIifQ.ELNF1Iv6yEwA12nCbXGKwXCw-F5Gq4GI2t2nqo1PlSkFdQ5Oz5s5NwV0RUXA66LxCggI-9IjBtFI1MvBHpvTHq9QRlm-HKzVTMcOBkEtKEfCCI6SPKVTAZyntTJlWPKG3u-CJUotT5YW0j2rU1VcpA7uGEiY7gs5VPUOZ80R1uGJ7HBSqVI2DRqar6STa1xryygdCjK7qamUM2d6aJ6r9VPTBt-JO6dkDdw3KHs3wl-PGM3wcbXHZ2aC18WFd_PxLmtjqErpxTEkdUBCnUHOSKDePG0henDJq71Nh3yRdRmY9VvszHMyIxJA2BVGPIPUT_Y5aewaaEMQVEjhiBnn-Q"
|
||||
# == 通用工具 ==
|
||||
# 表格转图片
|
||||
excel2pic:
|
||||
base_url: "http://192.168.6.109:8010/api/v1/convert"
|
||||
|
||||
|
|
@ -139,6 +147,9 @@ dingtalk:
|
|||
url: "https://alidocs.dingtalk.com/i/nodes/YQBnd5ExVE6qAbnOiANQg2KKJyeZqMmz"
|
||||
base_id: "YQBnd5ExVE6qAbnOiANQg2KKJyeZqMmz"
|
||||
sheet_id_or_name: "数据表"
|
||||
# 机器人群组
|
||||
bot_group_id:
|
||||
bbxt: 23
|
||||
|
||||
default_prompt:
|
||||
img_recognize:
|
||||
|
|
|
|||
|
|
@ -633,27 +633,28 @@ func (d *DingTalkBotBiz) HandleStreamRes(ctx context.Context, data *chatbot.BotC
|
|||
|
||||
func (d *DingTalkBotBiz) GetReportLists(ctx context.Context, group *model.AiBotGroup) (reports []*bbxt.ReportRes, err error) {
|
||||
|
||||
reportList, err := bbxt.NewBbxtTools()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
var product []string
|
||||
if group.ProductName != "" {
|
||||
product = strings.Split(group.ProductName, ",")
|
||||
}
|
||||
//[]string{"官方-爱奇艺-星钻季卡", "官方-爱奇艺-星钻半年卡", "官方--腾讯-年卡", "官方--爱奇艺-月卡"}
|
||||
reports, err = reportList.DailyReport(time.Now(), bbxt.DownWardValue, product, bbxt.SumFilter, d.ossClient)
|
||||
|
||||
reportList, err := bbxt.NewBbxtTools()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
reports, err = reportList.DailyReport(time.Now(), bbxt.DownWardValue, product, bbxt.SumFilter, d.ossClient)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
//product = []string{"优酷周卡", "优酷季卡", "优酷年卡", "爱奇艺黄金会员天卡"}
|
||||
//追加电商充值系统统计 - 返回统一使用[]*bbxt.ReportRes
|
||||
//rechargeReports, err := d.rechargeDailyReport(ctx, time.Now(), product, d.ossClient)
|
||||
//if err != nil || len(rechargeReports) == 0 {
|
||||
// return
|
||||
//}
|
||||
//
|
||||
//reports = append(reports, rechargeReports...)
|
||||
rechargeReports, err := d.rechargeDailyReport(ctx, time.Now(), nil, d.ossClient)
|
||||
if err != nil || len(rechargeReports) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
reports = append(reports, rechargeReports...)
|
||||
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ type DingtalkConfig struct {
|
|||
ApiKey string `mapstructure:"api_key"`
|
||||
ApiSecret string `mapstructure:"api_secret"`
|
||||
TableDemand AITableConfig `mapstructure:"table_demand"`
|
||||
BotGroupID map[string]int `mapstructure:"bot_group_id"` // 机器人群组
|
||||
}
|
||||
|
||||
// TableDemandConfig 需求表配置
|
||||
|
|
|
|||
|
|
@ -2,14 +2,17 @@ package component
|
|||
|
||||
import (
|
||||
"ai_scheduler/internal/domain/component/callback"
|
||||
"ai_scheduler/internal/pkg/lsxd"
|
||||
)
|
||||
|
||||
type Components struct {
|
||||
Callback callback.Manager
|
||||
LSXDLogin *lsxd.Login
|
||||
}
|
||||
|
||||
func NewComponents(callbackManager callback.Manager) *Components {
|
||||
func NewComponents(callbackManager callback.Manager, lsxdLogin *lsxd.Login) *Components {
|
||||
return &Components{
|
||||
Callback: callbackManager,
|
||||
LSXDLogin: lsxdLogin,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,18 +4,21 @@ import (
|
|||
"ai_scheduler/internal/config"
|
||||
"ai_scheduler/internal/data/impl"
|
||||
"ai_scheduler/internal/pkg/utils_oss"
|
||||
"ai_scheduler/utils"
|
||||
)
|
||||
|
||||
// Repos 聚合所有 Repository
|
||||
type Repos struct {
|
||||
Session SessionRepo
|
||||
OssClient *utils_oss.Client
|
||||
Rdb *utils.Rdb
|
||||
}
|
||||
|
||||
func NewRepos(sessionImpl *impl.SessionImpl, cfg *config.Config) *Repos {
|
||||
func NewRepos(sessionImpl *impl.SessionImpl, cfg *config.Config, rdb *utils.Rdb) *Repos {
|
||||
ossClient, _ := utils_oss.NewClient(cfg)
|
||||
return &Repos{
|
||||
Session: NewSessionAdapter(sessionImpl),
|
||||
OssClient: ossClient,
|
||||
Rdb: rdb,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,9 +44,8 @@ func (c *Client) Call(ctx context.Context, req StatisticsOursProductRequest) ([]
|
|||
|
||||
queryString := strings.Join(queryParams, "&")
|
||||
fullURL := fmt.Sprintf("%s?%s", c.cfg.BaseURL, queryString)
|
||||
|
||||
headers := map[string]string{
|
||||
"Authorization": fmt.Sprintf("Bearer %s", c.cfg.APIKey),
|
||||
"Authorization": fmt.Sprintf("Bearer %s", req.Token),
|
||||
}
|
||||
|
||||
reqObj := l_request.Request{
|
||||
|
|
|
|||
|
|
@ -7,12 +7,14 @@ import (
|
|||
)
|
||||
|
||||
func TestClient_Call(t *testing.T) {
|
||||
cfg := config.ToolConfig{
|
||||
BaseURL: "http://admin.1688sup.cn:8001/admin/statistics/oursProduct",
|
||||
APIKey: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ1c2VyQ2VudGVyIiwiZXhwIjoxNzY3MDc3NzcwLCJuYmYiOjE3NjcwNzU5NzAsImp0aSI6IjEiLCJQaG9uZSI6IjE4MDAwMDAwMDAwIiwiVXNlck5hbWUiOiJsc3hkIiwiUmVhbE5hbWUiOiLotoXnuqfnrqHnkIblkZgiLCJBY2NvdW50VHlwZSI6MSwiR3JvdXBDb2RlcyI6IlZDTF9DQVNISUVSLFZDTF9PUEVSQVRFLFZDTF9BRE1JTixWQ0xfQUFBLFZDTF9WQ0xfT1BFUkFULFZDTF9JTlZPSUNFLENSTV9BRE1JTixMSUFOTElBTl9BRE1JTixNQVJLRVRNQUcyX0FETUlOLFBIT05FQklMTF9BRE1JTixRSUFOWkhVX1NVUFBFUl9BRE0sTUFSS0VUSU5HU0FBU19TVVBFUkFETUlOLENBUkRfQ09ERSxDQVJEX1BST0NVUkVNRU5ULE1BUktFVElOR1NZU1RFTV9TVVBFUixTVEFUSVNUSUNBTFNZU1RFTV9BRE1JTixaTFRYX0FETUlOLFpMVFhfT1BFUkFURSIsIkRpbmdVc2VySWQiOiIxNjIwMjYxMjMwMjg5MzM4MzQifQ.Nuw_aR6iSPmhhh9E5rhyTxHBsgWtaTZvbnc7SFTnUBJXTQvYahnk0LyZaVpsVw6FB3cU0F5xOdX3rmGyWyaiszWO6yi-o1oxGMXwhf39fMiWT2xUI6pAn9Ync8DmZ4tOMCNUTdEk4CaQFzrTwJs0c-VR4yW6LgoPmNPvUVZ-KwmusUpnPz5j9RsJItzIWE3bpGGsfB54e2UERcZdbo9BXxCZIBbpAYKBKdl73KuI8SNaXgKvGTrJ6hEN4ESpnbisJVwT5pp_kuChJlcfjHTHFsEf4RJDjN9gTrtDbBWZyY3OmO2ukqYAM7tZPs6TXJwvQGJQsFRVZUBGxS1nD_6DzQ",
|
||||
|
||||
configEino := config.ToolConfig{
|
||||
BaseURL: "http://admin.lanseds.cn/admin/statistics/oursProduct",
|
||||
APIKey: "OFJ8UpqOlI7+w3Qklf36ZA==",
|
||||
APISecret: "tEbFegH/DRRh6LutFb7o3g==",
|
||||
}
|
||||
|
||||
client := New(cfg)
|
||||
client := New(configEino)
|
||||
|
||||
req := StatisticsOursProductRequest{
|
||||
Page: 1,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package statistics_ours_product
|
|||
|
||||
// StatisticsOursProductRequest 我们的商品统计请求参数
|
||||
type StatisticsOursProductRequest struct {
|
||||
Token string `json:"token"` // 登录token
|
||||
Page int `json:"page"` // 页码
|
||||
Limit int `json:"limit"` // 每页条数
|
||||
Serial []string `json:"serial"` // 流水号范围 (通常是日期格式,如 YYYYMMDDHH)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,9 @@ import (
|
|||
"ai_scheduler/internal/domain/tools/common/excel_generator"
|
||||
"ai_scheduler/internal/domain/tools/recharge/statistics_ours_product"
|
||||
"ai_scheduler/internal/domain/workflow/runtime"
|
||||
"ai_scheduler/internal/pkg/lsxd"
|
||||
"ai_scheduler/internal/pkg/utils_oss"
|
||||
"ai_scheduler/utils"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
|
@ -24,7 +26,13 @@ const WorkflowIDStatisticsOursProduct = "recharge.statisticsOursProduct"
|
|||
|
||||
func init() {
|
||||
runtime.Register(WorkflowIDStatisticsOursProduct, func(d *runtime.Deps) (runtime.Workflow, error) {
|
||||
return &statisticsOursProduct{cfg: d.Conf, toolManager: d.ToolManager, ossClient: d.Repos.OssClient}, nil
|
||||
return &statisticsOursProduct{
|
||||
cfg: d.Conf,
|
||||
toolManager: d.ToolManager,
|
||||
ossClient: d.Repos.OssClient,
|
||||
rdb: d.Repos.Rdb,
|
||||
lsxdLogin: d.Component.LSXDLogin,
|
||||
}, nil
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -32,6 +40,8 @@ type statisticsOursProduct struct {
|
|||
cfg *config.Config
|
||||
toolManager *toolManager.Manager
|
||||
ossClient *utils_oss.Client
|
||||
rdb *utils.Rdb
|
||||
lsxdLogin *lsxd.Login
|
||||
}
|
||||
|
||||
type StatisticsOursProductWorkflowInput struct {
|
||||
|
|
@ -104,6 +114,7 @@ func (w *statisticsOursProduct) buildWorkflow(ctx context.Context) (compose.Runn
|
|||
// formatContext 整理上下文参数
|
||||
func (w *statisticsOursProduct) formatContext(ctx context.Context, input *StatisticsOursProductWorkflowInput) (*StatisticsOursProductContext, error) {
|
||||
startTime := input.Time.Format("2006010200")
|
||||
// startTime := "2025010500"
|
||||
endTime := input.Time.Format("2006010215")
|
||||
endTimeStr := input.Time.Format("1.2号15点")
|
||||
|
||||
|
|
@ -116,7 +127,14 @@ func (w *statisticsOursProduct) formatContext(ctx context.Context, input *Statis
|
|||
}
|
||||
|
||||
func (w *statisticsOursProduct) callStatisticsTool(ctx context.Context, state *StatisticsOursProductContext) (*StatisticsOursProductContext, error) {
|
||||
// 前置获取登录token
|
||||
token := w.lsxdLogin.GetToken(ctx)
|
||||
if token == "" {
|
||||
return nil, fmt.Errorf("登录token为空")
|
||||
}
|
||||
|
||||
req := statistics_ours_product.StatisticsOursProductRequest{
|
||||
Token: token,
|
||||
Page: 1,
|
||||
Limit: 100, // 仅取前100条
|
||||
Serial: []string{state.StartTime, state.EndTime},
|
||||
|
|
@ -138,6 +156,7 @@ func (w *statisticsOursProduct) callStatisticsTool(ctx context.Context, state *S
|
|||
|
||||
func (w *statisticsOursProduct) generateExcelAndUpload(ctx context.Context, state *StatisticsOursProductContext) (*StatisticsOursProductContext, error) {
|
||||
// 1. 获取模板路径
|
||||
// cwd, _ := filepath.Abs("../../") // 单元测试用
|
||||
cwd, _ := filepath.Abs(".")
|
||||
templatePath := filepath.Join(cwd, "tmpl", "excel_temp", "recharge_statistics_ours_product.xlsx")
|
||||
fileName := fmt.Sprintf("statistics_ours_product_%d%d", time.Now().Unix(), rand.Intn(1000))
|
||||
|
|
@ -149,7 +168,7 @@ func (w *statisticsOursProduct) generateExcelAndUpload(ctx context.Context, stat
|
|||
req := &excel_generator.ExcelGeneratorRequest{
|
||||
TemplatePath: templatePath,
|
||||
ExcelData: excelData,
|
||||
StartRow: 4,
|
||||
StartRow: 3,
|
||||
StyleRow: 3,
|
||||
Title: state.Title,
|
||||
}
|
||||
|
|
@ -190,16 +209,18 @@ func (w *statisticsOursProduct) convertDataToExcelFormat(data []statistics_ours_
|
|||
if val, err := strconv.ParseFloat(v, 64); err == nil {
|
||||
profitVal = val
|
||||
} else {
|
||||
// 解析失败默认为0,或者记录错误
|
||||
// 解析失败默认为0,或者记录错误日志
|
||||
log.Errorf("解析 Profit 字段失败: %v", v)
|
||||
profitVal = 0
|
||||
}
|
||||
default:
|
||||
// 其他类型视为0
|
||||
// 其他类型视为0,或者记录错误日志
|
||||
log.Errorf("未知 Profit 类型: %T", v)
|
||||
profitVal = 0
|
||||
}
|
||||
|
||||
// 过滤利润小于 -100 的记录
|
||||
if profitVal < -100 {
|
||||
if profitVal > -100 {
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,9 +31,9 @@ func NewLogin(config *config.Config, rdb *utils.Rdb) *Login {
|
|||
}
|
||||
}
|
||||
|
||||
func (l *Login) GetToken() string {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
||||
defer cancel()
|
||||
func (l *Login) GetToken(ctx context.Context) string {
|
||||
// ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
||||
// defer cancel()
|
||||
|
||||
token, err := l.getCachedToken(ctx)
|
||||
if err != nil {
|
||||
|
|
@ -111,7 +111,7 @@ func (l *Login) login(ctx context.Context) (string, error) {
|
|||
reqBody := map[string]any{
|
||||
"phone": phone,
|
||||
"password": password,
|
||||
"code": "123456",
|
||||
"code": "456789",
|
||||
}
|
||||
bodyBytes, err := json.Marshal(reqBody)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package lsxd
|
|||
import (
|
||||
"ai_scheduler/internal/config"
|
||||
"ai_scheduler/utils"
|
||||
"context"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
|
@ -18,13 +19,13 @@ func TestGetToken(t *testing.T) {
|
|||
|
||||
login := NewLogin(&config.Config{
|
||||
LSXD: config.LSXDConfig{
|
||||
LoginURL: "http://api.test.user.1688sup.com/v1/login/phone",
|
||||
Phone: "0zmINhJBwsDJYTmeaxXK4A==",
|
||||
Password: "LSSGoWhc63NpZc1rq3LT8g==",
|
||||
CheckTokenURL: "http://api.test.user.1688sup.com/v1/user/welcome",
|
||||
LoginURL: "https://api.user.1688sup.com/v1/login/phone",
|
||||
Phone: "ORlviZN7N06W2+WKLe76xg==",
|
||||
Password: "V5Uh8C4bamEM6UQZh4TCeQ==",
|
||||
CheckTokenURL: "https://api.user.1688sup.com/v1/user/welcome",
|
||||
},
|
||||
}, rdb)
|
||||
token := login.GetToken()
|
||||
token := login.GetToken(context.Background())
|
||||
if token == "" {
|
||||
t.Errorf("token is empty")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package pkg
|
|||
|
||||
import (
|
||||
"ai_scheduler/internal/pkg/dingtalk"
|
||||
"ai_scheduler/internal/pkg/lsxd"
|
||||
"ai_scheduler/internal/pkg/utils_langchain"
|
||||
"ai_scheduler/internal/pkg/utils_ollama"
|
||||
"ai_scheduler/internal/pkg/utils_oss"
|
||||
|
|
@ -22,4 +23,5 @@ var ProviderSetClient = wire.NewSet(
|
|||
dingtalk.NewNotableClient,
|
||||
|
||||
utils_oss.NewClient,
|
||||
lsxd.NewLogin,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -66,13 +66,13 @@ func (c *CronServer) Run(ctx context.Context) {
|
|||
}
|
||||
c.log.Infof("任务[%d]:%s执行结束", jobID, job.Name)
|
||||
}()
|
||||
|
||||
c.log.Infof("任务[%d]:%s执ddd", jobID, job.Name)
|
||||
// 为每次执行创建新的上下文
|
||||
ctx := context.Background()
|
||||
err := job.Func(ctx)
|
||||
if err != nil {
|
||||
c.log.Errorf("任务[%d]:%s执行失败: %s", jobID, job.Name, err.Error())
|
||||
}
|
||||
//ctx := context.Background()
|
||||
//err := job.Func(ctx)
|
||||
//if err != nil {
|
||||
// c.log.Errorf("任务[%d]:%s执行失败: %s", jobID, job.Name, err.Error())
|
||||
//}
|
||||
})
|
||||
if err != nil {
|
||||
c.log.Errorf("添加任务失败:%s", err.Error())
|
||||
|
|
|
|||
|
|
@ -21,8 +21,7 @@ func NewCronService(config *config.Config, dingTalkBotBiz *biz.DingTalkBotBiz) *
|
|||
}
|
||||
|
||||
func (d *CronService) CronReportSend(ctx context.Context) error {
|
||||
|
||||
groupId := 29
|
||||
groupId := d.config.Dingtalk.BotGroupID["bbxt"]
|
||||
groupInfo, err := d.dingTalkBotBiz.GetGroupInfo(ctx, groupId)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import (
|
|||
"ai_scheduler/internal/domain/workflow/runtime"
|
||||
"ai_scheduler/internal/pkg"
|
||||
"ai_scheduler/internal/pkg/dingtalk"
|
||||
"ai_scheduler/internal/pkg/lsxd"
|
||||
"ai_scheduler/internal/pkg/utils_ollama"
|
||||
"ai_scheduler/internal/pkg/utils_oss"
|
||||
"ai_scheduler/internal/pkg/utils_vllm"
|
||||
|
|
@ -63,7 +64,7 @@ func run() {
|
|||
// 初始化Redis数据库连接
|
||||
rdb := utils.NewRdb(configConfig)
|
||||
// 初始化仓库层
|
||||
repos := repo.NewRepos(sessionImpl, configConfig)
|
||||
repos := repo.NewRepos(sessionImpl, configConfig, rdb)
|
||||
// 初始化包级别的Redis连接
|
||||
pkgRdb := pkg.NewRdb(configConfig)
|
||||
|
||||
|
|
@ -73,8 +74,10 @@ func run() {
|
|||
botDeptImpl := impl.NewBotDeptImpl(db)
|
||||
// 初始化Redis管理器
|
||||
redisManager := callback.NewRedisManager(pkgRdb)
|
||||
// 初始化登录组件
|
||||
lsxdLogin := lsxd.NewLogin(configConfig, rdb)
|
||||
// 初始化组件
|
||||
components := component.NewComponents(redisManager)
|
||||
components := component.NewComponents(redisManager, lsxdLogin)
|
||||
// 初始化工作流注册表
|
||||
registry := workflow.NewRegistry(configConfig, client, repos, components)
|
||||
// 初始化钉钉旧版客户端
|
||||
|
|
|
|||
Loading…
Reference in New Issue