Merge remote-tracking branch 'origin/v4' into v4
This commit is contained in:
commit
f497872d51
|
|
@ -7,6 +7,8 @@ import (
|
||||||
"ai_scheduler/internal/data/constants"
|
"ai_scheduler/internal/data/constants"
|
||||||
"ai_scheduler/internal/data/impl"
|
"ai_scheduler/internal/data/impl"
|
||||||
"ai_scheduler/internal/data/model"
|
"ai_scheduler/internal/data/model"
|
||||||
|
"ai_scheduler/internal/domain/workflow/recharge"
|
||||||
|
"ai_scheduler/internal/domain/workflow/runtime"
|
||||||
"ai_scheduler/internal/entitys"
|
"ai_scheduler/internal/entitys"
|
||||||
"ai_scheduler/internal/pkg/l_request"
|
"ai_scheduler/internal/pkg/l_request"
|
||||||
"ai_scheduler/internal/pkg/utils_oss"
|
"ai_scheduler/internal/pkg/utils_oss"
|
||||||
|
|
@ -35,19 +37,20 @@ import (
|
||||||
|
|
||||||
// AiRouterBiz 智能路由服务
|
// AiRouterBiz 智能路由服务
|
||||||
type DingTalkBotBiz struct {
|
type DingTalkBotBiz struct {
|
||||||
do *do.Do
|
do *do.Do
|
||||||
handle *do.Handle
|
handle *do.Handle
|
||||||
botConfigImpl *impl.BotConfigImpl
|
botConfigImpl *impl.BotConfigImpl
|
||||||
replier *chatbot.ChatbotReplier
|
replier *chatbot.ChatbotReplier
|
||||||
log log.Logger
|
log log.Logger
|
||||||
dingTalkUser *dingtalk.User
|
dingTalkUser *dingtalk.User
|
||||||
botTools []model.AiBotTool
|
botTools []model.AiBotTool
|
||||||
botGroupImpl *impl.BotGroupImpl
|
botGroupImpl *impl.BotGroupImpl
|
||||||
toolManager *tools.Manager
|
toolManager *tools.Manager
|
||||||
chatHis *impl.BotChatHisImpl
|
chatHis *impl.BotChatHisImpl
|
||||||
conf *config.Config
|
conf *config.Config
|
||||||
cardSend *dingtalk.SendCardClient
|
cardSend *dingtalk.SendCardClient
|
||||||
ossClient *utils_oss.Client
|
ossClient *utils_oss.Client
|
||||||
|
workflowManager *runtime.Registry
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDingTalkBotBiz
|
// NewDingTalkBotBiz
|
||||||
|
|
@ -63,20 +66,22 @@ func NewDingTalkBotBiz(
|
||||||
conf *config.Config,
|
conf *config.Config,
|
||||||
cardSend *dingtalk.SendCardClient,
|
cardSend *dingtalk.SendCardClient,
|
||||||
ossClient *utils_oss.Client,
|
ossClient *utils_oss.Client,
|
||||||
|
workflowManager *runtime.Registry,
|
||||||
) *DingTalkBotBiz {
|
) *DingTalkBotBiz {
|
||||||
return &DingTalkBotBiz{
|
return &DingTalkBotBiz{
|
||||||
do: do,
|
do: do,
|
||||||
handle: handle,
|
handle: handle,
|
||||||
botConfigImpl: botConfigImpl,
|
botConfigImpl: botConfigImpl,
|
||||||
replier: chatbot.NewChatbotReplier(),
|
replier: chatbot.NewChatbotReplier(),
|
||||||
dingTalkUser: dingTalkUser,
|
dingTalkUser: dingTalkUser,
|
||||||
botTools: tools.BootTools,
|
botTools: tools.BootTools,
|
||||||
botGroupImpl: botGroupImpl,
|
botGroupImpl: botGroupImpl,
|
||||||
toolManager: toolManager,
|
toolManager: toolManager,
|
||||||
chatHis: chatHis,
|
chatHis: chatHis,
|
||||||
conf: conf,
|
conf: conf,
|
||||||
cardSend: cardSend,
|
cardSend: cardSend,
|
||||||
ossClient: ossClient,
|
ossClient: ossClient,
|
||||||
|
workflowManager: workflowManager,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -623,6 +628,38 @@ func (d *DingTalkBotBiz) GetReportLists(ctx context.Context, group *model.AiBotG
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 追加电商充值系统统计 - 返回统一使用 []*bbxt.ReportRes
|
||||||
|
rechargeReports, err := d.rechargeDailyReport(ctx, time.Now(), []string{"官方-爱奇艺-星钻季卡", "官方-爱奇艺-星钻半年卡", "官方--腾讯-年卡", "官方--爱奇艺-月卡"}, d.ossClient)
|
||||||
|
reports = append(reports, rechargeReports...)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// rechargeDailyReport 获取电商充值系统统计报告
|
||||||
|
func (d *DingTalkBotBiz) rechargeDailyReport(ctx context.Context, now time.Time, productNames []string, ossClient *utils_oss.Client) (reports []*bbxt.ReportRes, err error) {
|
||||||
|
workflowId := recharge.WorkflowIDStatisticsOursProduct
|
||||||
|
args := &runtime.WorkflowArgs{
|
||||||
|
Args: map[string]any{
|
||||||
|
"product_names": productNames,
|
||||||
|
"now": now,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
res, err := d.workflowManager.Invoke(ctx, workflowId, args)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
reports = []*bbxt.ReportRes{
|
||||||
|
{
|
||||||
|
ReportName: "我们的商品统计(电商充值系统)",
|
||||||
|
Title: fmt.Sprintf("%s 电商充值系统我们的商品统计", now.Format("2006-01-02")),
|
||||||
|
Path: res["path"].(string),
|
||||||
|
Url: res["url"].(string),
|
||||||
|
Data: res["data"].([][]string),
|
||||||
|
Desc: res["desc"].(string),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -396,7 +396,7 @@ func (r *Handle) handleEinoWorkflow(ctx context.Context, rec *entitys.Recognize,
|
||||||
|
|
||||||
// 工作流内部输出
|
// 工作流内部输出
|
||||||
workflowId := task.Index
|
workflowId := task.Index
|
||||||
_, err = r.workflowManager.Invoke(ctx, workflowId, rec)
|
_, err = r.workflowManager.Invoke(ctx, workflowId, &runtime.WorkflowArgs{Recognize: rec})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ func New(cfg config.ToolConfig) *Client {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call 将 Excel 文件转换为图片
|
// Call 将 Excel 文件转换为图片
|
||||||
func (c *Client) Call(filename string, fileBytes []byte) ([]byte, error) {
|
func (c *Client) Call(filename string, fileBytes []byte, scale int) ([]byte, error) {
|
||||||
body := &bytes.Buffer{}
|
body := &bytes.Buffer{}
|
||||||
writer := multipart.NewWriter(body)
|
writer := multipart.NewWriter(body)
|
||||||
|
|
||||||
|
|
@ -33,6 +33,14 @@ func (c *Client) Call(filename string, fileBytes []byte) ([]byte, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 添加 scale 参数
|
||||||
|
if scale <= 0 {
|
||||||
|
scale = 2
|
||||||
|
}
|
||||||
|
if err = writer.WriteField("scale", fmt.Sprintf("%d", scale)); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
if err = writer.Close(); err != nil {
|
if err = writer.Close(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ import (
|
||||||
"ai_scheduler/internal/domain/tools/hyt/goods_category_add"
|
"ai_scheduler/internal/domain/tools/hyt/goods_category_add"
|
||||||
"ai_scheduler/internal/domain/tools/hyt/goods_media_add"
|
"ai_scheduler/internal/domain/tools/hyt/goods_media_add"
|
||||||
"ai_scheduler/internal/domain/workflow/runtime"
|
"ai_scheduler/internal/domain/workflow/runtime"
|
||||||
"ai_scheduler/internal/entitys"
|
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
@ -42,7 +41,7 @@ type GoodsAddWorkflowInput struct {
|
||||||
|
|
||||||
func (o *goodsAdd) ID() string { return WorkflowIDGoodsAdd }
|
func (o *goodsAdd) ID() string { return WorkflowIDGoodsAdd }
|
||||||
|
|
||||||
func (o *goodsAdd) Invoke(ctx context.Context, rec *entitys.Recognize) (map[string]any, error) {
|
func (o *goodsAdd) Invoke(ctx context.Context, rec *runtime.WorkflowArgs) (map[string]any, error) {
|
||||||
// 构建工作流
|
// 构建工作流
|
||||||
runnable, err := o.buildWorkflow(ctx)
|
runnable, err := o.buildWorkflow(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import (
|
||||||
toolManager "ai_scheduler/internal/domain/tools"
|
toolManager "ai_scheduler/internal/domain/tools"
|
||||||
toolPu "ai_scheduler/internal/domain/tools/hyt/product_upload"
|
toolPu "ai_scheduler/internal/domain/tools/hyt/product_upload"
|
||||||
"ai_scheduler/internal/domain/workflow/runtime"
|
"ai_scheduler/internal/domain/workflow/runtime"
|
||||||
"ai_scheduler/internal/entitys"
|
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
@ -39,7 +38,7 @@ type ProductUploadWorkflowInput struct {
|
||||||
|
|
||||||
func (o *productUpload) ID() string { return WorkflowIDProductUpload }
|
func (o *productUpload) ID() string { return WorkflowIDProductUpload }
|
||||||
|
|
||||||
func (o *productUpload) Invoke(ctx context.Context, rec *entitys.Recognize) (map[string]any, error) {
|
func (o *productUpload) Invoke(ctx context.Context, rec *runtime.WorkflowArgs) (map[string]any, error) {
|
||||||
// 构建工作流
|
// 构建工作流
|
||||||
runnable, err := o.buildWorkflow(ctx)
|
runnable, err := o.buildWorkflow(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import (
|
||||||
toolManager "ai_scheduler/internal/domain/tools"
|
toolManager "ai_scheduler/internal/domain/tools"
|
||||||
"ai_scheduler/internal/domain/tools/recharge/statistics_ours_product"
|
"ai_scheduler/internal/domain/tools/recharge/statistics_ours_product"
|
||||||
"ai_scheduler/internal/domain/workflow/runtime"
|
"ai_scheduler/internal/domain/workflow/runtime"
|
||||||
"ai_scheduler/internal/entitys"
|
|
||||||
"ai_scheduler/internal/pkg/utils_oss"
|
"ai_scheduler/internal/pkg/utils_oss"
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
@ -37,28 +36,31 @@ type StatisticsOursProductWorkflowInput struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type StatisticsOursProductWorkflowOutput struct {
|
type StatisticsOursProductWorkflowOutput struct {
|
||||||
ImgUrl string `json:"img_url"`
|
Path string `json:"path"`
|
||||||
|
Url string `json:"url"`
|
||||||
|
Data [][]string `json:"data"`
|
||||||
|
Desc string `json:"desc"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *statisticsOursProduct) ID() string { return WorkflowIDStatisticsOursProduct }
|
func (w *statisticsOursProduct) ID() string { return WorkflowIDStatisticsOursProduct }
|
||||||
|
|
||||||
func (w *statisticsOursProduct) Invoke(ctx context.Context, rec *entitys.Recognize) (map[string]any, error) {
|
func (w *statisticsOursProduct) Invoke(ctx context.Context, args *runtime.WorkflowArgs) (map[string]any, error) {
|
||||||
// 构建工作流
|
// 构建工作流
|
||||||
runnable, err := w.buildWorkflow(ctx)
|
runnable, err := w.buildWorkflow(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 解析参数 (假设参数在 rec.Match.Parameters 中,或者根据实际情况解析)
|
// 获取参数时间
|
||||||
// 这里简化处理,假设需要解析参数
|
now := args.Args["now"].(time.Time)
|
||||||
// 实际上这里应该根据 LLM 解析的结果来填充 Input
|
|
||||||
// 暂时假设 ParameterResult 是 JSON 字符串
|
|
||||||
input := &StatisticsOursProductWorkflowInput{
|
input := &StatisticsOursProductWorkflowInput{
|
||||||
// 默认值,具体应从 rec 解析
|
// 默认值,具体应从 rec 解析
|
||||||
StartTime: time.Now().Format("2006010200"),
|
StartTime: now.Format("2006010200"),
|
||||||
EndTime: time.Now().Format("2006010223"),
|
EndTime: now.Format("2006010215"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input.StartTime = "2025122300"
|
||||||
|
|
||||||
// 工作流过程调用
|
// 工作流过程调用
|
||||||
output, err := runnable.Invoke(ctx, input)
|
output, err := runnable.Invoke(ctx, input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -70,11 +72,11 @@ func (w *statisticsOursProduct) Invoke(ctx context.Context, rec *entitys.Recogni
|
||||||
return nil, errorcode.WorkflowErr(errStr)
|
return nil, errorcode.WorkflowErr(errStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
return map[string]any{"img_url": output.ImgUrl}, nil
|
return output, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *statisticsOursProduct) buildWorkflow(ctx context.Context) (compose.Runnable[*StatisticsOursProductWorkflowInput, *StatisticsOursProductWorkflowOutput], error) {
|
func (w *statisticsOursProduct) buildWorkflow(ctx context.Context) (compose.Runnable[*StatisticsOursProductWorkflowInput, map[string]any], error) {
|
||||||
c := compose.NewChain[*StatisticsOursProductWorkflowInput, *StatisticsOursProductWorkflowOutput]()
|
c := compose.NewChain[*StatisticsOursProductWorkflowInput, map[string]any]()
|
||||||
|
|
||||||
// 1. 调用工具统计我们的商品
|
// 1. 调用工具统计我们的商品
|
||||||
c.AppendLambda(compose.InvokableLambda(w.callStatisticsTool))
|
c.AppendLambda(compose.InvokableLambda(w.callStatisticsTool))
|
||||||
|
|
@ -82,6 +84,9 @@ func (w *statisticsOursProduct) buildWorkflow(ctx context.Context) (compose.Runn
|
||||||
// 2. 生成 Excel 并转图片上传
|
// 2. 生成 Excel 并转图片上传
|
||||||
c.AppendLambda(compose.InvokableLambda(w.generateExcelAndUpload))
|
c.AppendLambda(compose.InvokableLambda(w.generateExcelAndUpload))
|
||||||
|
|
||||||
|
// 3. 转map输出
|
||||||
|
c.AppendLambda(compose.InvokableLambda(w.convertToMap))
|
||||||
|
|
||||||
return c.Compile(ctx)
|
return c.Compile(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -98,20 +103,20 @@ func (w *statisticsOursProduct) callStatisticsTool(ctx context.Context, input *S
|
||||||
func (w *statisticsOursProduct) generateExcelAndUpload(ctx context.Context, data []statistics_ours_product.StatisticsOursProductItem) (*StatisticsOursProductWorkflowOutput, error) {
|
func (w *statisticsOursProduct) generateExcelAndUpload(ctx context.Context, data []statistics_ours_product.StatisticsOursProductItem) (*StatisticsOursProductWorkflowOutput, error) {
|
||||||
// 2. 获取模板路径 (假设在项目根目录的 assets/templates 下)
|
// 2. 获取模板路径 (假设在项目根目录的 assets/templates 下)
|
||||||
cwd, _ := filepath.Abs(".")
|
cwd, _ := filepath.Abs(".")
|
||||||
templatePath := filepath.Join(cwd, "assets", "templates", "statistics_ours_product.xlsx")
|
templatePath := filepath.Join(cwd, "tmpl", "excel_temp", "recharge_statistics_ours_product.xlsx")
|
||||||
fileName := fmt.Sprintf("statistics_ours_product_%d", time.Now().Unix())
|
fileName := fmt.Sprintf("statistics_ours_product_%d", time.Now().Unix())
|
||||||
|
|
||||||
// 3. 转换数据为 [][]string
|
// 3. 转换数据为 [][]string
|
||||||
excelData := w.convertDataToExcelFormat(data)
|
excelData := w.convertDataToExcelFormat(data)
|
||||||
|
|
||||||
// 4. 生成 Excel
|
// 4. 生成 Excel
|
||||||
excelBytes, err := w.toolManager.Common.ExcelGenerator.Call(templatePath, excelData, 2, 2)
|
excelBytes, err := w.toolManager.Common.ExcelGenerator.Call(templatePath, excelData, 4, 3)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("生成 Excel 失败: %v", err)
|
return nil, fmt.Errorf("生成 Excel 失败: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. Excel 转图片
|
// 5. Excel 转图片
|
||||||
picBytes, err := w.toolManager.Common.ImageConverter.Call(fileName+".xlsx", excelBytes)
|
picBytes, err := w.toolManager.Common.ImageConverter.Call(fileName+".xlsx", excelBytes, 2)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Excel 转图片失败: %v", err)
|
return nil, fmt.Errorf("Excel 转图片失败: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -122,7 +127,14 @@ func (w *statisticsOursProduct) generateExcelAndUpload(ctx context.Context, data
|
||||||
return nil, fmt.Errorf("上传 OSS 失败: %v", err)
|
return nil, fmt.Errorf("上传 OSS 失败: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &StatisticsOursProductWorkflowOutput{ImgUrl: url}, nil
|
res := &StatisticsOursProductWorkflowOutput{
|
||||||
|
Path: "",
|
||||||
|
Url: url,
|
||||||
|
Data: excelData,
|
||||||
|
Desc: "",
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// convertDataToExcelFormat 将业务数据转换为 Excel 生成器需要的二维字符串数组
|
// convertDataToExcelFormat 将业务数据转换为 Excel 生成器需要的二维字符串数组
|
||||||
|
|
@ -131,16 +143,26 @@ func (w *statisticsOursProduct) convertDataToExcelFormat(data []statistics_ours_
|
||||||
for _, item := range data {
|
for _, item := range data {
|
||||||
row := []string{
|
row := []string{
|
||||||
item.OursProductName,
|
item.OursProductName,
|
||||||
fmt.Sprintf("%d", item.OursProductId),
|
// fmt.Sprintf("%d", item.OursProductId),
|
||||||
item.Count,
|
item.Count,
|
||||||
item.TotalPrice,
|
// item.TotalPrice,
|
||||||
item.SuccessCount,
|
// item.SuccessCount,
|
||||||
item.SuccessPrice,
|
item.SuccessPrice,
|
||||||
item.FailCount,
|
// item.FailCount,
|
||||||
item.FailPrice,
|
// item.FailPrice,
|
||||||
item.Profit,
|
item.Profit,
|
||||||
}
|
}
|
||||||
|
|
||||||
result = append(result, row)
|
result = append(result, row)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *statisticsOursProduct) convertToMap(ctx context.Context, output *StatisticsOursProductWorkflowOutput) (map[string]any, error) {
|
||||||
|
return map[string]any{
|
||||||
|
"path": output.Path,
|
||||||
|
"url": output.Url,
|
||||||
|
"data": output.Data,
|
||||||
|
"desc": output.Desc,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ import (
|
||||||
type Workflow interface {
|
type Workflow interface {
|
||||||
ID() string
|
ID() string
|
||||||
// Schema() map[string]any
|
// Schema() map[string]any
|
||||||
Invoke(ctx context.Context, requireData *entitys.Recognize) (map[string]any, error)
|
Invoke(ctx context.Context, requireData *WorkflowArgs) (map[string]any, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Deps struct {
|
type Deps struct {
|
||||||
|
|
@ -28,6 +28,11 @@ type Deps struct {
|
||||||
|
|
||||||
type Factory func(deps *Deps) (Workflow, error)
|
type Factory func(deps *Deps) (Workflow, error)
|
||||||
|
|
||||||
|
type WorkflowArgs struct {
|
||||||
|
*entitys.Recognize
|
||||||
|
Args map[string]any
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
regMu sync.RWMutex
|
regMu sync.RWMutex
|
||||||
factories = map[string]Factory{}
|
factories = map[string]Factory{}
|
||||||
|
|
@ -69,7 +74,7 @@ func Default() *Registry {
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Registry) Invoke(ctx context.Context, id string, rec *entitys.Recognize) (map[string]any, error) {
|
func (r *Registry) Invoke(ctx context.Context, id string, rec *WorkflowArgs) (map[string]any, error) {
|
||||||
regMu.RLock()
|
regMu.RLock()
|
||||||
f, ok := factories[id]
|
f, ok := factories[id]
|
||||||
regMu.RUnlock()
|
regMu.RUnlock()
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ func (w *bugOptimizationSubmitBak) ID() string {
|
||||||
|
|
||||||
type BugOptimizationSubmitBakInput struct {
|
type BugOptimizationSubmitBakInput struct {
|
||||||
Ch chan entitys.Response
|
Ch chan entitys.Response
|
||||||
RequireData *entitys.Recognize
|
RequireData *runtime.WorkflowArgs
|
||||||
}
|
}
|
||||||
|
|
||||||
type BugOptimizationSubmitBakOutput struct {
|
type BugOptimizationSubmitBakOutput struct {
|
||||||
|
|
@ -54,7 +54,7 @@ type contextWithTaskBak struct {
|
||||||
TaskID string
|
TaskID string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *bugOptimizationSubmitBak) Invoke(ctx context.Context, recognize *entitys.Recognize) (map[string]any, error) {
|
func (w *bugOptimizationSubmitBak) Invoke(ctx context.Context, recognize *runtime.WorkflowArgs) (map[string]any, error) {
|
||||||
chain, err := w.buildWorkflow(ctx)
|
chain, err := w.buildWorkflow(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ func (w *bugOptimizationSubmit) ID() string {
|
||||||
|
|
||||||
type BugOptimizationSubmitInput struct {
|
type BugOptimizationSubmitInput struct {
|
||||||
Ch chan entitys.Response
|
Ch chan entitys.Response
|
||||||
RequireData *entitys.Recognize
|
RequireData *runtime.WorkflowArgs
|
||||||
}
|
}
|
||||||
|
|
||||||
type BugOptimizationSubmitOutput struct {
|
type BugOptimizationSubmitOutput struct {
|
||||||
|
|
@ -54,7 +54,7 @@ type contextWithTask struct {
|
||||||
TaskID string
|
TaskID string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *bugOptimizationSubmit) Invoke(ctx context.Context, recognize *entitys.Recognize) (map[string]any, error) {
|
func (w *bugOptimizationSubmit) Invoke(ctx context.Context, recognize *runtime.WorkflowArgs) (map[string]any, error) {
|
||||||
chain, err := w.buildWorkflow(ctx)
|
chain, err := w.buildWorkflow(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ type OrderAfterSaleResellerBatchData struct {
|
||||||
func (o *orderAfterSaleResellerBatch) ID() string { return "zltx.orderAfterSaleResellerBatch" }
|
func (o *orderAfterSaleResellerBatch) ID() string { return "zltx.orderAfterSaleResellerBatch" }
|
||||||
|
|
||||||
// Invoke 调用原有编排工作流并规范化输出
|
// Invoke 调用原有编排工作流并规范化输出
|
||||||
func (o *orderAfterSaleResellerBatch) Invoke(ctx context.Context, rec *entitys.Recognize) (map[string]any, error) {
|
func (o *orderAfterSaleResellerBatch) Invoke(ctx context.Context, rec *runtime.WorkflowArgs) (map[string]any, error) {
|
||||||
// 构建工作流
|
// 构建工作流
|
||||||
chain, err := o.buildWorkflow(ctx)
|
chain, err := o.buildWorkflow(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -198,7 +198,7 @@ func (s *CapabilityService) ProductIngestConfirm(c *fiber.Ctx) error {
|
||||||
|
|
||||||
// 调用eino工作流,实现商品上传到目标系统
|
// 调用eino工作流,实现商品上传到目标系统
|
||||||
rec := &entitys.Recognize{UserContent: &entitys.RecognizeUserContent{Text: req.Confirmed}}
|
rec := &entitys.Recognize{UserContent: &entitys.RecognizeUserContent{Text: req.Confirmed}}
|
||||||
res, err := s.workflowManager.Invoke(ctx, workflowId, rec)
|
res, err := s.workflowManager.Invoke(ctx, workflowId, &runtime.WorkflowArgs{Recognize: rec})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"ai_scheduler/internal/domain/component/callback"
|
"ai_scheduler/internal/domain/component/callback"
|
||||||
"ai_scheduler/internal/domain/repo"
|
"ai_scheduler/internal/domain/repo"
|
||||||
"ai_scheduler/internal/domain/workflow"
|
"ai_scheduler/internal/domain/workflow"
|
||||||
|
"ai_scheduler/internal/domain/workflow/runtime"
|
||||||
"ai_scheduler/internal/pkg"
|
"ai_scheduler/internal/pkg"
|
||||||
"ai_scheduler/internal/pkg/dingtalk"
|
"ai_scheduler/internal/pkg/dingtalk"
|
||||||
"ai_scheduler/internal/pkg/utils_ollama"
|
"ai_scheduler/internal/pkg/utils_ollama"
|
||||||
|
|
@ -102,7 +103,9 @@ func run() {
|
||||||
handle := do.NewHandle(ollamaService, manager, configConfig, sessionImpl, registry, oldClient, contactClient, notableClient)
|
handle := do.NewHandle(ollamaService, manager, configConfig, sessionImpl, registry, oldClient, contactClient, notableClient)
|
||||||
// 初始化钉钉机器人业务逻辑
|
// 初始化钉钉机器人业务逻辑
|
||||||
utils_ossClient, _ := utils_oss.NewClient(configConfig)
|
utils_ossClient, _ := utils_oss.NewClient(configConfig)
|
||||||
dingTalkBotBiz := biz.NewDingTalkBotBiz(doDo, handle, botConfigImpl, botGroupImpl, user, toolRegis, botChatHisImpl, manager, configConfig, sendCardClient, utils_ossClient)
|
// 初始化工作流管理器
|
||||||
|
workflowManager := runtime.NewRegistry()
|
||||||
|
dingTalkBotBiz := biz.NewDingTalkBotBiz(doDo, handle, botConfigImpl, botGroupImpl, user, toolRegis, botChatHisImpl, manager, configConfig, sendCardClient, utils_ossClient, workflowManager)
|
||||||
// 初始化钉钉机器人服务
|
// 初始化钉钉机器人服务
|
||||||
cronService = NewCronService(configConfig, dingTalkBotBiz)
|
cronService = NewCronService(configConfig, dingTalkBotBiz)
|
||||||
dingBotService = NewDingBotService(configConfig, dingTalkBotBiz)
|
dingBotService = NewDingBotService(configConfig, dingTalkBotBiz)
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ func (u *Uploader) Run(report *ReportRes) (err error) {
|
||||||
return fmt.Errorf("write to bytes failed: %v", err)
|
return fmt.Errorf("write to bytes failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
picBytes, err := u.excel2picPy(report.Path, excelBytes.Bytes())
|
picBytes, err := u.excel2picPy(report.Path, excelBytes.Bytes(), 2)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("excel2picPy failed: %v", err)
|
return fmt.Errorf("excel2picPy failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -62,7 +62,7 @@ func (u *Uploader) Run(report *ReportRes) (err error) {
|
||||||
// --header 'Content-Type: multipart/form-data; boundary=--------------------------952147881043913664015069' \
|
// --header 'Content-Type: multipart/form-data; boundary=--------------------------952147881043913664015069' \
|
||||||
// --form 'file=@"C:\\Users\\Administrator\\Downloads\\销售同比分析2025-12-29 0-12点.xlsx"' \
|
// --form 'file=@"C:\\Users\\Administrator\\Downloads\\销售同比分析2025-12-29 0-12点.xlsx"' \
|
||||||
// --form 'sheet_name="销售同比分析"'
|
// --form 'sheet_name="销售同比分析"'
|
||||||
func (u *Uploader) excel2picPy(templatePath string, excelBytes []byte) ([]byte, error) {
|
func (u *Uploader) excel2picPy(templatePath string, excelBytes []byte, scale int) ([]byte, error) {
|
||||||
// 1. 获取 Sheet Name
|
// 1. 获取 Sheet Name
|
||||||
// 尝试从 excelBytes 解析,如果失败则使用默认值 "Sheet1"
|
// 尝试从 excelBytes 解析,如果失败则使用默认值 "Sheet1"
|
||||||
sheetName := "Sheet1"
|
sheetName := "Sheet1"
|
||||||
|
|
@ -99,6 +99,14 @@ func (u *Uploader) excel2picPy(templatePath string, excelBytes []byte) ([]byte,
|
||||||
return nil, fmt.Errorf("write field sheet_name failed: %v", err)
|
return nil, fmt.Errorf("write field sheet_name failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 添加 scale 字段
|
||||||
|
if scale <= 0 {
|
||||||
|
scale = 2
|
||||||
|
}
|
||||||
|
if err = writer.WriteField("scale", fmt.Sprintf("%d", scale)); err != nil {
|
||||||
|
return nil, fmt.Errorf("write field scale failed: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
if err = writer.Close(); err != nil {
|
if err = writer.Close(); err != nil {
|
||||||
return nil, fmt.Errorf("close writer failed: %v", err)
|
return nil, fmt.Errorf("close writer failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue