feat: 添加工作流取消与临时文件管理功能

- 新增临时文件(FileTemp)的实体、DAO和DTO,支持文件临时存储与批量操作
- 实现工作流执行取消功能,使用sync.Map管理context.CancelFunc,支持按会话取消运行中的流程
- 将流程执行状态"暂停"变更为"取消",并处理取消导致的错误
- 引入IsDialogue标识区分对话模式,调整判断/文案/图片节点的表单数据组装逻辑
- 重构ComposeMessagesReq,使用BuildType替代IsBuild和ModelTypeId
- 优化HTML内容提取逻辑,修复文案纯文本与图片URL的标签过滤及标签命名
- 在结果汇总节点中使用事务更新执行状态并批量保存输出文件记录
This commit is contained in:
2026-05-15 09:37:23 +08:00
parent 2c3cbab11d
commit b1ee117f6c
18 changed files with 730 additions and 336 deletions

View File

@@ -17,6 +17,7 @@ type NodeExecutionInput struct {
// FlowExecutionInput 工作流执行入参(全程不变)
type FlowExecutionInput struct {
IsDialogue bool `json:"isDialogue"`
ExecutionId int64 `json:"executionId"`
ConfigMap map[string]*entity.FlowNode `json:"configMap"`
SessionId string `json:"sessionId" dc:"会话ID"`
@@ -27,15 +28,15 @@ type FlowExecutionInput struct {
}
type ComposeMessagesReq struct {
ModelTypeId int `json:"modelTypeId"`
ModelName string `json:"modelName"`
SkillName string `json:"skillName"`
Form map[string]any `json:"form"`
UserForm map[string]any `json:"userForm"`
UserFiles []string `json:"userFiles"`
SessionId string `json:"sessionId" dc:"会话ID"`
IsBuild bool `json:"isBuild"`
Cause string `json:"cause"`
BuildType int `json:"buildType"`
ModelName string `json:"modelName"`
SkillName string `json:"skillName"`
Form map[string]any `json:"form"`
UserForm map[string]any `json:"userForm"`
UserFiles []string `json:"userFiles"`
SessionId string `json:"sessionId" dc:"会话ID"`
IsBuild bool `json:"isBuild"`
Cause string `json:"cause"`
}
type ComposeMessagesRes struct {
@@ -143,9 +144,9 @@ type ExecuteRes struct {
}
type CancelReq struct {
g.Meta `path:"/cancel" method:"get" tags:"任务管理" summary:"取消任务" dc:"取消任务"`
g.Meta `path:"/cancel" method:"post" tags:"任务管理" summary:"取消任务" dc:"取消任务"`
FlowId int64 `json:"flowId" dc:"用户流程ID"`
SessionId string `json:"sessionId" dc:"会话ID"`
}
type CreateFlowExecutionReq struct {
@@ -195,19 +196,21 @@ type ListFlowExecutionRes struct {
}
type VOFlowExecution struct {
Id int64 `json:"id,string" dc:"id"`
FlowUserId int64 `json:"flowUserId,string" description:"流程ID"`
FlowName string `json:"flowName"`
TriggerType flow.FlowExecutionTriggerType `json:"triggerType" description:"触发类型"`
DurationMs int64 `json:"durationMs" description:"执行时长(毫秒)"`
Status flow.FlowExecutionStatus `json:"status" description:"状态:1-运行中,2-成功,3-失败"`
FlowContent *entity.FlowInfo `json:"flowContent" description:"流程内容"`
NodeInputParams []*entity.FlowNode `json:"nodeInputParams" description:"节点输入参数"`
OutputParams []map[string]interface{} `json:"outputParams" description:"输出参数"`
ErrorMessage string `json:"errorMessage" description:"错误信息"`
TraceId string `json:"traceId" description:"跟踪ID"`
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
UpdatedAt *gtime.Time `json:"updatedAt" dc:"更新时间"`
Id int64 `json:"id,string" dc:"id"`
FlowUserId int64 `json:"flowUserId,string" description:"流程ID"`
FlowName string `json:"flowName"`
TriggerType flow.FlowExecutionTriggerType `json:"triggerType" description:"触发类型"`
DurationMs int64 `json:"durationMs" description:"执行时长(毫秒)"`
Status flow.FlowExecutionStatus `json:"status" description:"状态:1-运行中,2-成功,3-失败"`
FlowContent *entity.FlowInfo `json:"flowContent" description:"流程内容"`
NodeInputParams []*entity.FlowNode `json:"nodeInputParams" description:"节点输入参数"`
OutputParams []map[string]interface{} `json:"outputParams" description:"输出参数"`
ErrorMessage string `json:"errorMessage" description:"错误信息"`
TraceId string `json:"traceId" description:"跟踪ID"`
SessionId string `json:"sessionId" dc:"会话ID"`
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
UpdatedAt *gtime.Time `json:"updatedAt" dc:"更新时间"`
ImgAddressPrefix string `json:"imgAddressPrefix"`
}
// ========== 核心:构建树状结构 ==========