Explorar o código

Merge remote-tracking branch 'upstream/master'

zhangcl hai 4 meses
pai
achega
1dbcd34edb
Modificáronse 62 ficheiros con 3241 adicións e 153 borrados
  1. 12 12
      yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/query/MPJLambdaWrapperX.java
  2. 1 1
      yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/type/EncryptTypeHandler.java
  3. 4 0
      yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/ErrorCodeConstants.java
  4. 77 0
      yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/workflow/AiWorkflowController.java
  5. 32 0
      yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/workflow/vo/AiWorkflowPageReqVO.java
  6. 33 0
      yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/workflow/vo/AiWorkflowRespVO.java
  7. 34 0
      yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/workflow/vo/AiWorkflowSaveReqVO.java
  8. 20 0
      yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/workflow/vo/AiWorkflowTestReqVO.java
  9. 51 0
      yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/dataobject/workflow/AiWorkflowDO.java
  10. 30 0
      yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/mysql/workflow/AiWorkflowMapper.java
  11. 7 1
      yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageServiceImpl.java
  12. 62 0
      yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/workflow/AiWorkflowService.java
  13. 150 0
      yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/workflow/AiWorkflowServiceImpl.java
  14. 8 0
      yudao-module-ai/yudao-spring-boot-starter-ai/pom.xml
  15. 31 2
      yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/config/YudaoAiAutoConfiguration.java
  16. 19 0
      yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/config/YudaoAiProperties.java
  17. 1 0
      yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/enums/AiPlatformEnum.java
  18. 34 0
      yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/factory/AiModelFactoryImpl.java
  19. 45 0
      yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/model/baichuan/BaiChuanChatModel.java
  20. 34 0
      yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/model/siliconflow/SiliconFlowApiConstants.java
  21. 0 4
      yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/model/siliconflow/SiliconFlowChatModel.java
  22. 115 0
      yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/model/siliconflow/SiliconFlowImageApi.java
  23. 159 0
      yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/model/siliconflow/SiliconFlowImageModel.java
  24. 105 0
      yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/model/siliconflow/SiliconFlowImageOptions.java
  25. 385 0
      yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/model/wenduoduo/api/WddPptApi.java
  26. 759 0
      yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/model/xinghuo/api/XunfeiPptApi.java
  27. 1 0
      yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/util/AiUtils.java
  28. 68 0
      yudao-module-ai/yudao-spring-boot-starter-ai/src/test/java/cn/iocoder/yudao/framework/ai/chat/BaiChuanChatModelTests.java
  29. 3 2
      yudao-module-ai/yudao-spring-boot-starter-ai/src/test/java/cn/iocoder/yudao/framework/ai/chat/SiliconFlowChatModelTests.java
  30. 35 0
      yudao-module-ai/yudao-spring-boot-starter-ai/src/test/java/cn/iocoder/yudao/framework/ai/image/SiliconFlowImageModelTests.java
  31. 314 0
      yudao-module-ai/yudao-spring-boot-starter-ai/src/test/java/cn/iocoder/yudao/framework/ai/ppt/wdd/WddPptApiTests.java
  32. 318 0
      yudao-module-ai/yudao-spring-boot-starter-ai/src/test/java/cn/iocoder/yudao/framework/ai/ppt/xunfei/XunfeiPptApiTests.java
  33. 1 0
      yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/ErrorCodeConstants.java
  34. 1 0
      yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmReasonEnum.java
  35. 15 0
      yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/base/dept/DeptSimpleBaseVO.java
  36. 11 2
      yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmModelController.java
  37. 9 0
      yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelMetaInfoVO.java
  38. 4 0
      yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelRespVO.java
  39. 2 2
      yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/simple/BpmSimpleModelNodeVO.java
  40. 0 1
      yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java
  41. 3 0
      yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmApprovalDetailRespVO.java
  42. 11 6
      yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmModelConvert.java
  43. 20 0
      yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmProcessDefinitionInfoDO.java
  44. 6 1
      yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmTaskEventListener.java
  45. 9 6
      yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/SimpleModelUtils.java
  46. 20 5
      yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionServiceImpl.java
  47. 53 36
      yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java
  48. 7 0
      yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskService.java
  49. 63 17
      yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java
  50. 1 4
      yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/listener/BpmUserTaskListener.java
  51. 1 4
      yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/trigger/http/BpmHttpCallbackTrigger.java
  52. 1 4
      yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/trigger/http/BpmSyncHttpRequestTrigger.java
  53. 1 1
      yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java
  54. 2 7
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/framework/job/core/IotSchedulerManager.java
  55. 11 11
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/product/IotProductCategoryServiceImpl.java
  56. 2 2
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/MenuController.java
  57. 17 5
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/TenantController.java
  58. 0 16
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/vo/tenant/TenantSimpleRespVO.java
  59. 4 0
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/tenant/TenantMapper.java
  60. 9 1
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantService.java
  61. 5 0
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImpl.java
  62. 5 0
      yudao-server/src/main/resources/application.yaml

+ 12 - 12
yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/query/MPJLambdaWrapperX.java

@@ -20,7 +20,7 @@ import java.util.function.Consumer;
  */
 public class MPJLambdaWrapperX<T> extends MPJLambdaWrapper<T> {
 
-    public MPJLambdaWrapperX<T> likeIfPresent(SFunction<T, ?> column, String val) {
+    public <R> MPJLambdaWrapperX<T> likeIfPresent(SFunction<R, ?> column, String val) {
         MPJWrappers.lambdaJoin().like(column, val);
         if (StringUtils.hasText(val)) {
             return (MPJLambdaWrapperX<T>) super.like(column, val);
@@ -28,63 +28,63 @@ public class MPJLambdaWrapperX<T> extends MPJLambdaWrapper<T> {
         return this;
     }
 
-    public MPJLambdaWrapperX<T> inIfPresent(SFunction<T, ?> column, Collection<?> values) {
+    public <R> MPJLambdaWrapperX<T> inIfPresent(SFunction<R, ?> column, Collection<?> values) {
         if (ObjectUtil.isAllNotEmpty(values) && !ArrayUtil.isEmpty(values)) {
             return (MPJLambdaWrapperX<T>) super.in(column, values);
         }
         return this;
     }
 
-    public MPJLambdaWrapperX<T> inIfPresent(SFunction<T, ?> column, Object... values) {
+    public <R> MPJLambdaWrapperX<T> inIfPresent(SFunction<R, ?> column, Object... values) {
         if (ObjectUtil.isAllNotEmpty(values) && !ArrayUtil.isEmpty(values)) {
             return (MPJLambdaWrapperX<T>) super.in(column, values);
         }
         return this;
     }
 
-    public MPJLambdaWrapperX<T> eqIfPresent(SFunction<T, ?> column, Object val) {
+    public <R> MPJLambdaWrapperX<T> eqIfPresent(SFunction<R, ?> column, Object val) {
         if (ObjectUtil.isNotEmpty(val)) {
             return (MPJLambdaWrapperX<T>) super.eq(column, val);
         }
         return this;
     }
 
-    public MPJLambdaWrapperX<T> neIfPresent(SFunction<T, ?> column, Object val) {
+    public <R> MPJLambdaWrapperX<T> neIfPresent(SFunction<R, ?> column, Object val) {
         if (ObjectUtil.isNotEmpty(val)) {
             return (MPJLambdaWrapperX<T>) super.ne(column, val);
         }
         return this;
     }
 
-    public MPJLambdaWrapperX<T> gtIfPresent(SFunction<T, ?> column, Object val) {
+    public <R> MPJLambdaWrapperX<T> gtIfPresent(SFunction<R, ?> column, Object val) {
         if (val != null) {
             return (MPJLambdaWrapperX<T>) super.gt(column, val);
         }
         return this;
     }
 
-    public MPJLambdaWrapperX<T> geIfPresent(SFunction<T, ?> column, Object val) {
+    public <R> MPJLambdaWrapperX<T> geIfPresent(SFunction<R, ?> column, Object val) {
         if (val != null) {
             return (MPJLambdaWrapperX<T>) super.ge(column, val);
         }
         return this;
     }
 
-    public MPJLambdaWrapperX<T> ltIfPresent(SFunction<T, ?> column, Object val) {
+    public <R> MPJLambdaWrapperX<T> ltIfPresent(SFunction<R, ?> column, Object val) {
         if (val != null) {
             return (MPJLambdaWrapperX<T>) super.lt(column, val);
         }
         return this;
     }
 
-    public MPJLambdaWrapperX<T> leIfPresent(SFunction<T, ?> column, Object val) {
+    public <R> MPJLambdaWrapperX<T> leIfPresent(SFunction<R, ?> column, Object val) {
         if (val != null) {
             return (MPJLambdaWrapperX<T>) super.le(column, val);
         }
         return this;
     }
 
-    public MPJLambdaWrapperX<T> betweenIfPresent(SFunction<T, ?> column, Object val1, Object val2) {
+    public <R> MPJLambdaWrapperX<T> betweenIfPresent(SFunction<R, ?> column, Object val1, Object val2) {
         if (val1 != null && val2 != null) {
             return (MPJLambdaWrapperX<T>) super.between(column, val1, val2);
         }
@@ -97,7 +97,7 @@ public class MPJLambdaWrapperX<T> extends MPJLambdaWrapper<T> {
         return this;
     }
 
-    public MPJLambdaWrapperX<T> betweenIfPresent(SFunction<T, ?> column, Object[] values) {
+    public <R> MPJLambdaWrapperX<T> betweenIfPresent(SFunction<R, ?> column, Object[] values) {
         Object val1 = ArrayUtils.get(values, 0);
         Object val2 = ArrayUtils.get(values, 1);
         return betweenIfPresent(column, val1, val2);
@@ -310,4 +310,4 @@ public class MPJLambdaWrapperX<T> extends MPJLambdaWrapper<T> {
         return this;
     }
 
-}
+}

+ 1 - 1
yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/type/EncryptTypeHandler.java

@@ -13,7 +13,7 @@ import java.sql.ResultSet;
 import java.sql.SQLException;
 
 /**
- * 字段字段的 TypeHandler 实现类,基于 {@link cn.hutool.crypto.symmetric.AES} 实现
+ * 字段字段的 TypeHandler 实现类,基于 {@link AES} 实现
  * 可通过 jasypt.encryptor.password 配置项,设置密钥
  *
  * @author 芋道源码

+ 4 - 0
yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/ErrorCodeConstants.java

@@ -61,4 +61,8 @@ public interface ErrorCodeConstants {
     ErrorCode TOOL_NOT_EXISTS = new ErrorCode(1_040_010_000, "工具不存在");
     ErrorCode TOOL_NAME_NOT_EXISTS = new ErrorCode(1_040_010_001, "工具({})找不到 Bean");
 
+    // ========== AI 工作流 1-040-011-000 ==========
+    ErrorCode WORKFLOW_NOT_EXISTS = new ErrorCode(1_040_011_000, "工作流不存在");
+    ErrorCode WORKFLOW_CODE_EXISTS = new ErrorCode(1_040_011_001, "工作流标识已存在");
+
 }

+ 77 - 0
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/workflow/AiWorkflowController.java

@@ -0,0 +1,77 @@
+package cn.iocoder.yudao.module.ai.controller.admin.workflow;
+
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import cn.iocoder.yudao.module.ai.controller.admin.workflow.vo.*;
+import cn.iocoder.yudao.module.ai.dal.dataobject.workflow.AiWorkflowDO;
+import cn.iocoder.yudao.module.ai.service.workflow.AiWorkflowService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.annotation.Resource;
+import jakarta.validation.Valid;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+
+@Tag(name = "管理后台 - AI 工作流")
+@RestController
+@RequestMapping("/ai/workflow")
+@Slf4j
+public class AiWorkflowController {
+
+    @Resource
+    private AiWorkflowService workflowService;
+
+    @PostMapping("/create")
+    @Operation(summary = "创建 AI 工作流")
+    @PreAuthorize("@ss.hasPermission('ai:workflow:create')")
+    public CommonResult<Long> createWorkflow(@Valid @RequestBody AiWorkflowSaveReqVO createReqVO) {
+        return success(workflowService.createWorkflow(createReqVO));
+    }
+
+    @PutMapping("/update")
+    @Operation(summary = "更新 AI 工作流")
+    @PreAuthorize("@ss.hasPermission('ai:workflow:update')")
+    public CommonResult<Boolean> updateWorkflow(@Valid @RequestBody AiWorkflowSaveReqVO updateReqVO) {
+        workflowService.updateWorkflow(updateReqVO);
+        return success(true);
+    }
+
+    @DeleteMapping("/delete")
+    @Operation(summary = "删除 AI 工作流")
+    @Parameter(name = "id", description = "编号", required = true)
+    @PreAuthorize("@ss.hasPermission('ai:workflow:delete')")
+    public CommonResult<Boolean> deleteWorkflow(@RequestParam("id") Long id) {
+        workflowService.deleteWorkflow(id);
+        return success(true);
+    }
+
+    @GetMapping("/get")
+    @Operation(summary = "获得 AI 工作流")
+    @Parameter(name = "id", description = "编号", required = true, example = "1024")
+    @PreAuthorize("@ss.hasPermission('ai:workflow:query')")
+    public CommonResult<AiWorkflowRespVO> getWorkflow(@RequestParam("id") Long id) {
+        AiWorkflowDO workflow = workflowService.getWorkflow(id);
+        return success(BeanUtils.toBean(workflow, AiWorkflowRespVO.class));
+    }
+
+    @GetMapping("/page")
+    @Operation(summary = "获得 AI 工作流分页")
+    @PreAuthorize("@ss.hasPermission('ai:workflow:query')")
+    public CommonResult<PageResult<AiWorkflowRespVO>> getWorkflowPage(@Valid AiWorkflowPageReqVO pageReqVO) {
+        PageResult<AiWorkflowDO> pageResult = workflowService.getWorkflowPage(pageReqVO);
+        return success(BeanUtils.toBean(pageResult, AiWorkflowRespVO.class));
+    }
+
+    @PostMapping("/test")
+    @Operation(summary = "测试 AI 工作流")
+    @PreAuthorize("@ss.hasPermission('ai:workflow:test')")
+    public CommonResult<Object> testWorkflow(@Valid @RequestBody AiWorkflowTestReqVO testReqVO) {
+        return success(workflowService.testWorkflow(testReqVO));
+    }
+
+}

+ 32 - 0
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/workflow/vo/AiWorkflowPageReqVO.java

@@ -0,0 +1,32 @@
+package cn.iocoder.yudao.module.ai.controller.admin.workflow.vo;
+
+import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import cn.iocoder.yudao.framework.common.validation.InEnum;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.time.LocalDateTime;
+
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@Schema(description = "管理后台 - AI 工作流分页 Request VO")
+@Data
+public class AiWorkflowPageReqVO extends PageParam {
+
+    @Schema(description = "名称", example = "工作流")
+    private String name;
+
+    @Schema(description = "标识", example = "FLOW")
+    private String code;
+
+    @Schema(description = "状态", example = "1")
+    @InEnum(CommonStatusEnum.class)
+    private Integer status;
+
+    @Schema(description = "创建时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] createTime;
+
+}

+ 33 - 0
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/workflow/vo/AiWorkflowRespVO.java

@@ -0,0 +1,33 @@
+package cn.iocoder.yudao.module.ai.controller.admin.workflow.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+@Schema(description = "管理后台 - AI 工作流 Response VO")
+@Data
+public class AiWorkflowRespVO {
+
+    @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
+    private Long id;
+
+    @Schema(description = "工作流标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "FLOW")
+    private String code;
+
+    @Schema(description = "工作流名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "工作流")
+    private String name;
+
+    @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "工作流")
+    private String remark;
+
+    @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
+    private Integer status;
+
+    @Schema(description = "工作流模型 JSON", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}")
+    private String graph;
+
+    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "时间戳格式")
+    private LocalDateTime createTime;
+
+}

+ 34 - 0
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/workflow/vo/AiWorkflowSaveReqVO.java

@@ -0,0 +1,34 @@
+package cn.iocoder.yudao.module.ai.controller.admin.workflow.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotEmpty;
+import jakarta.validation.constraints.NotNull;
+import lombok.Data;
+
+@Schema(description = "管理后台 - AI 工作流新增/修改 Request VO")
+@Data
+public class AiWorkflowSaveReqVO {
+
+    @Schema(description = "编号", example = "1")
+    private Long id;
+
+    @Schema(description = "工作流标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "FLOW")
+    @NotEmpty(message = "工作流标识不能为空")
+    private String code;
+
+    @Schema(description = "工作流名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "工作流")
+    @NotEmpty(message = "工作流名称不能为空")
+    private String name;
+
+    @Schema(description = "备注", example = "FLOW")
+    private String remark;
+
+    @Schema(description = "工作流模型", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}")
+    @NotEmpty(message = "工作流模型不能为空")
+    private String graph;
+
+    @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "FLOW")
+    @NotNull(message = "状态不能为空")
+    private Integer status;
+
+}

+ 20 - 0
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/workflow/vo/AiWorkflowTestReqVO.java

@@ -0,0 +1,20 @@
+package cn.iocoder.yudao.module.ai.controller.admin.workflow.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotEmpty;
+import lombok.Data;
+
+import java.util.Map;
+
+@Schema(description = "管理后台 - AI 工作流测试 Request VO")
+@Data
+public class AiWorkflowTestReqVO {
+
+    @Schema(description = "工作流模型", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}")
+    @NotEmpty(message = "工作流模型不能为空")
+    private String graph;
+
+    @Schema(description = "参数", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}")
+    private Map<String, Object> params;
+
+}

+ 51 - 0
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/dataobject/workflow/AiWorkflowDO.java

@@ -0,0 +1,51 @@
+package cn.iocoder.yudao.module.ai.dal.dataobject.workflow;
+
+import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
+import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+import com.baomidou.mybatisplus.annotation.KeySequence;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+/**
+ * AI 工作流 DO
+ *
+ * @author lesan
+ */
+@TableName(value = "ai_workflow", autoResultMap = true)
+@KeySequence("ai_workflow") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
+@Data
+public class AiWorkflowDO extends BaseDO {
+
+    /**
+     * 编号
+     */
+    @TableId
+    private Long id;
+    /**
+     * 工作流名称
+     */
+    private String name;
+    /**
+     * 工作流标识
+     */
+    private String code;
+
+    /**
+     * 工作流模型 JSON 数据
+     */
+    private String graph;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    /**
+     * 状态
+     *
+     * 枚举 {@link CommonStatusEnum}
+     */
+    private Integer status;
+
+}

+ 30 - 0
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/mysql/workflow/AiWorkflowMapper.java

@@ -0,0 +1,30 @@
+package cn.iocoder.yudao.module.ai.dal.mysql.workflow;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.module.ai.controller.admin.workflow.vo.AiWorkflowPageReqVO;
+import cn.iocoder.yudao.module.ai.dal.dataobject.workflow.AiWorkflowDO;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * AI 工作流 Mapper
+ *
+ * @author lesan
+ */
+@Mapper
+public interface AiWorkflowMapper extends BaseMapperX<AiWorkflowDO> {
+
+    default AiWorkflowDO selectByCode(String code) {
+        return selectOne(AiWorkflowDO::getCode, code);
+    }
+
+    default PageResult<AiWorkflowDO> selectPage(AiWorkflowPageReqVO pageReqVO) {
+        return selectPage(pageReqVO, new LambdaQueryWrapperX<AiWorkflowDO>()
+                .eqIfPresent(AiWorkflowDO::getStatus, pageReqVO.getStatus())
+                .likeIfPresent(AiWorkflowDO::getName, pageReqVO.getName())
+                .likeIfPresent(AiWorkflowDO::getCode, pageReqVO.getCode())
+                .betweenIfPresent(AiWorkflowDO::getCreateTime, pageReqVO.getCreateTime()));
+    }
+
+}

+ 7 - 1
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/image/AiImageServiceImpl.java

@@ -11,6 +11,7 @@ import cn.hutool.extra.spring.SpringUtil;
 import cn.hutool.http.HttpUtil;
 import cn.iocoder.yudao.framework.ai.core.enums.AiPlatformEnum;
 import cn.iocoder.yudao.framework.ai.core.model.midjourney.api.MidjourneyApi;
+import cn.iocoder.yudao.framework.ai.core.model.siliconflow.SiliconFlowImageOptions;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
 import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImageDrawReqVO;
@@ -144,7 +145,12 @@ public class AiImageServiceImpl implements AiImageService {
                     .withStyle(MapUtil.getStr(draw.getOptions(), "style")) // 风格
                     .withResponseFormat("b64_json")
                     .build();
-        } else if (ObjUtil.equal(model.getPlatform(), AiPlatformEnum.STABLE_DIFFUSION.getPlatform())) {
+        } else if (ObjUtil.equal(model.getPlatform(), AiPlatformEnum.SILICON_FLOW.getPlatform())) {
+            // https://docs.siliconflow.cn/cn/api-reference/images/images-generations
+            return SiliconFlowImageOptions.builder().model(model.getModel())
+                    .height(draw.getHeight()).width(draw.getWidth())
+                    .build();
+        }  else if (ObjUtil.equal(model.getPlatform(), AiPlatformEnum.STABLE_DIFFUSION.getPlatform())) {
             // https://platform.stability.ai/docs/api-reference#tag/SDXL-and-SD1.6/operation/textToImage
             // https://platform.stability.ai/docs/api-reference#tag/Text-to-Image/operation/textToImage
             return StabilityAiImageOptions.builder().model(model.getModel())

+ 62 - 0
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/workflow/AiWorkflowService.java

@@ -0,0 +1,62 @@
+package cn.iocoder.yudao.module.ai.service.workflow;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.ai.controller.admin.workflow.vo.AiWorkflowPageReqVO;
+import cn.iocoder.yudao.module.ai.controller.admin.workflow.vo.AiWorkflowSaveReqVO;
+import cn.iocoder.yudao.module.ai.controller.admin.workflow.vo.AiWorkflowTestReqVO;
+import cn.iocoder.yudao.module.ai.dal.dataobject.workflow.AiWorkflowDO;
+import jakarta.validation.Valid;
+
+/**
+ * AI 工作流 Service 接口
+ *
+ * @author lesan
+ */
+public interface AiWorkflowService {
+
+    /**
+     * 创建 AI 工作流
+     *
+     * @param createReqVO 创建信息
+     * @return 编号
+     */
+    Long createWorkflow(@Valid AiWorkflowSaveReqVO createReqVO);
+
+    /**
+     * 更新 AI 工作流
+     *
+     * @param updateReqVO 更新信息
+     */
+    void updateWorkflow(@Valid AiWorkflowSaveReqVO updateReqVO);
+
+    /**
+     * 删除 AI 工作流
+     *
+     * @param id 编号
+     */
+    void deleteWorkflow(Long id);
+
+    /**
+     * 获得 AI 工作流
+     *
+     * @param id 编号
+     * @return AI 工作流
+     */
+    AiWorkflowDO getWorkflow(Long id);
+
+    /**
+     * 获得 AI 工作流分页
+     *
+     * @param pageReqVO 分页查询
+     * @return AI 工作流分页
+     */
+    PageResult<AiWorkflowDO> getWorkflowPage(AiWorkflowPageReqVO pageReqVO);
+
+    /**
+     * 测试 AI 工作流
+     *
+     * @param testReqVO 测试数据
+     */
+    Object testWorkflow(AiWorkflowTestReqVO testReqVO);
+
+}

+ 150 - 0
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/workflow/AiWorkflowServiceImpl.java

@@ -0,0 +1,150 @@
+package cn.iocoder.yudao.module.ai.service.workflow;
+
+import cn.hutool.core.util.ObjUtil;
+import cn.hutool.core.util.StrUtil;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import cn.iocoder.yudao.module.ai.controller.admin.workflow.vo.AiWorkflowPageReqVO;
+import cn.iocoder.yudao.module.ai.controller.admin.workflow.vo.AiWorkflowSaveReqVO;
+import cn.iocoder.yudao.module.ai.controller.admin.workflow.vo.AiWorkflowTestReqVO;
+import cn.iocoder.yudao.module.ai.dal.dataobject.model.AiApiKeyDO;
+import cn.iocoder.yudao.module.ai.dal.dataobject.workflow.AiWorkflowDO;
+import cn.iocoder.yudao.module.ai.dal.mysql.workflow.AiWorkflowMapper;
+import cn.iocoder.yudao.module.ai.service.model.AiApiKeyService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import dev.tinyflow.core.Tinyflow;
+import jakarta.annotation.Resource;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import java.util.Map;
+
+import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.iocoder.yudao.module.ai.enums.ErrorCodeConstants.WORKFLOW_CODE_EXISTS;
+import static cn.iocoder.yudao.module.ai.enums.ErrorCodeConstants.WORKFLOW_NOT_EXISTS;
+
+/**
+ * AI 工作流 Service 实现类
+ *
+ * @author lesan
+ */
+@Service
+@Slf4j
+public class AiWorkflowServiceImpl implements AiWorkflowService {
+
+    @Resource
+    private AiWorkflowMapper workflowMapper;
+
+    @Resource
+    private AiApiKeyService apiKeyService;
+
+    @Override
+    public Long createWorkflow(AiWorkflowSaveReqVO createReqVO) {
+        validateWorkflowForCreateOrUpdate(null, createReqVO.getCode());
+        AiWorkflowDO workflow = BeanUtils.toBean(createReqVO, AiWorkflowDO.class);
+        workflowMapper.insert(workflow);
+        return workflow.getId();
+    }
+
+    @Override
+    public void updateWorkflow(AiWorkflowSaveReqVO updateReqVO) {
+        validateWorkflowForCreateOrUpdate(updateReqVO.getId(), updateReqVO.getCode());
+        AiWorkflowDO workflow = BeanUtils.toBean(updateReqVO, AiWorkflowDO.class);
+        workflowMapper.updateById(workflow);
+    }
+
+    @Override
+    public void deleteWorkflow(Long id) {
+        validateWorkflowExists(id);
+        workflowMapper.deleteById(id);
+    }
+
+    @Override
+    public AiWorkflowDO getWorkflow(Long id) {
+        return workflowMapper.selectById(id);
+    }
+
+    @Override
+    public PageResult<AiWorkflowDO> getWorkflowPage(AiWorkflowPageReqVO pageReqVO) {
+        return workflowMapper.selectPage(pageReqVO);
+    }
+
+    @Override
+    public Object testWorkflow(AiWorkflowTestReqVO testReqVO) {
+        Map<String, Object> variables = testReqVO.getParams();
+        Tinyflow tinyflow = parseFlowParam(testReqVO.getGraph());
+        return tinyflow.toChain().executeForResult(variables);
+    }
+
+    private void validateWorkflowForCreateOrUpdate(Long id, String code) {
+        validateWorkflowExists(id);
+        validateCodeUnique(id, code);
+    }
+
+    private void validateWorkflowExists(Long id) {
+        if (ObjUtil.isNull(id)) {
+            return;
+        }
+        AiWorkflowDO workflow = workflowMapper.selectById(id);
+        if (ObjUtil.isNull(workflow)) {
+            throw exception(WORKFLOW_NOT_EXISTS);
+        }
+    }
+
+    private void validateCodeUnique(Long id, String code) {
+        if (StrUtil.isBlank(code)) {
+            return;
+        }
+        AiWorkflowDO workflow = workflowMapper.selectByCode(code);
+        if (ObjUtil.isNull(workflow)) {
+            return;
+        }
+        if (ObjUtil.isNull(id)) {
+            throw exception(WORKFLOW_CODE_EXISTS);
+        }
+        if (ObjUtil.notEqual(workflow.getId(), id)) {
+            throw exception(WORKFLOW_CODE_EXISTS);
+        }
+    }
+
+    private Tinyflow parseFlowParam(String graph) {
+        // TODO @lesan:可以使用 jackson 哇?
+        JSONObject json = JSONObject.parseObject(graph);
+        JSONArray nodeArr = json.getJSONArray("nodes");
+        Tinyflow tinyflow = new Tinyflow(json.toJSONString());
+        for (int i = 0; i < nodeArr.size(); i++) {
+            JSONObject node = nodeArr.getJSONObject(i);
+            switch (node.getString("type")) {
+                case "llmNode":
+                    JSONObject data = node.getJSONObject("data");
+                    AiApiKeyDO apiKey = apiKeyService.getApiKey(data.getLong("llmId"));
+                    switch (apiKey.getPlatform()) {
+                        // TODO @lesan 需要讨论一下这里怎么弄
+                        // TODO @lesan llmId 对应 model 的编号如何?这样的话,就是 apiModelService 提供一个获取 LLM 的方法。然后,创建的方法,也在 AiModelFactory 提供。可以先接个 deepseek 先。deepseek yyds!
+                        case "OpenAI":
+                            break;
+                        case "Ollama":
+                            break;
+                        case "YiYan":
+                            break;
+                        case "XingHuo":
+                            break;
+                        case "TongYi":
+                            break;
+                        case "DeepSeek":
+                            break;
+                        case "ZhiPu":
+                            break;
+                    }
+                    break;
+                case "internalNode":
+                    break;
+                default:
+                    break;
+            }
+        }
+        return tinyflow;
+    }
+
+}

+ 8 - 0
yudao-module-ai/yudao-spring-boot-starter-ai/pom.xml

@@ -15,6 +15,7 @@
     <description>AI 大模型拓展,接入国内外大模型</description>
     <properties>
         <spring-ai.version>1.0.0-M6</spring-ai.version>
+        <tinyflow.version>1.0.0-rc.3</tinyflow.version>
     </properties>
 
     <dependencies>
@@ -117,6 +118,13 @@
             </exclusions>
         </dependency>
 
+        <!-- TinyFlow:AI 工作流 -->
+        <dependency>
+            <groupId>dev.tinyflow</groupId>
+            <artifactId>tinyflow-java-core</artifactId>
+            <version>${tinyflow.version}</version>
+        </dependency>
+
         <!-- Test 测试相关 -->
         <dependency>
             <groupId>org.springframework.boot</groupId>

+ 31 - 2
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/config/YudaoAiAutoConfiguration.java

@@ -4,10 +4,12 @@ import cn.hutool.core.util.StrUtil;
 import cn.hutool.extra.spring.SpringUtil;
 import cn.iocoder.yudao.framework.ai.core.factory.AiModelFactory;
 import cn.iocoder.yudao.framework.ai.core.factory.AiModelFactoryImpl;
+import cn.iocoder.yudao.framework.ai.core.model.baichuan.BaiChuanChatModel;
 import cn.iocoder.yudao.framework.ai.core.model.deepseek.DeepSeekChatModel;
 import cn.iocoder.yudao.framework.ai.core.model.doubao.DouBaoChatModel;
 import cn.iocoder.yudao.framework.ai.core.model.hunyuan.HunYuanChatModel;
 import cn.iocoder.yudao.framework.ai.core.model.midjourney.api.MidjourneyApi;
+import cn.iocoder.yudao.framework.ai.core.model.siliconflow.SiliconFlowApiConstants;
 import cn.iocoder.yudao.framework.ai.core.model.siliconflow.SiliconFlowChatModel;
 import cn.iocoder.yudao.framework.ai.core.model.suno.api.SunoApi;
 import cn.iocoder.yudao.framework.ai.core.model.xinghuo.XingHuoChatModel;
@@ -113,11 +115,11 @@ public class YudaoAiAutoConfiguration {
 
     public SiliconFlowChatModel buildSiliconFlowChatClient(YudaoAiProperties.SiliconFlowProperties properties) {
         if (StrUtil.isEmpty(properties.getModel())) {
-            properties.setModel(SiliconFlowChatModel.MODEL_DEFAULT);
+            properties.setModel(SiliconFlowApiConstants.MODEL_DEFAULT);
         }
         OpenAiChatModel openAiChatModel = OpenAiChatModel.builder()
                 .openAiApi(OpenAiApi.builder()
-                        .baseUrl(SiliconFlowChatModel.BASE_URL)
+                        .baseUrl(SiliconFlowApiConstants.DEFAULT_BASE_URL)
                         .apiKey(properties.getApiKey())
                         .build())
                 .defaultOptions(OpenAiChatOptions.builder()
@@ -192,6 +194,33 @@ public class YudaoAiAutoConfiguration {
         return new XingHuoChatModel(openAiChatModel);
     }
 
+    @Bean
+    @ConditionalOnProperty(value = "yudao.ai.baichuan.enable", havingValue = "true")
+    public BaiChuanChatModel baiChuanChatClient(YudaoAiProperties yudaoAiProperties) {
+        YudaoAiProperties.BaiChuanProperties properties = yudaoAiProperties.getBaichuan();
+        return buildBaiChuanChatClient(properties);
+    }
+
+    public BaiChuanChatModel buildBaiChuanChatClient(YudaoAiProperties.BaiChuanProperties properties) {
+        if (StrUtil.isEmpty(properties.getModel())) {
+            properties.setModel(BaiChuanChatModel.MODEL_DEFAULT);
+        }
+        OpenAiChatModel openAiChatModel = OpenAiChatModel.builder()
+                .openAiApi(OpenAiApi.builder()
+                        .baseUrl(BaiChuanChatModel.BASE_URL)
+                        .apiKey(properties.getApiKey())
+                        .build())
+                .defaultOptions(OpenAiChatOptions.builder()
+                        .model(properties.getModel())
+                        .temperature(properties.getTemperature())
+                        .maxTokens(properties.getMaxTokens())
+                        .topP(properties.getTopP())
+                        .build())
+                .toolCallingManager(getToolCallingManager())
+                .build();
+        return new BaiChuanChatModel(openAiChatModel);
+    }
+
     @Bean
     @ConditionalOnProperty(value = "yudao.ai.midjourney.enable", havingValue = "true")
     public MidjourneyApi midjourneyApi(YudaoAiProperties yudaoAiProperties) {

+ 19 - 0
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/config/YudaoAiProperties.java

@@ -43,6 +43,12 @@ public class YudaoAiProperties {
     @SuppressWarnings("SpellCheckingInspection")
     private XingHuoProperties xinghuo;
 
+    /**
+     * 百川
+     */
+    @SuppressWarnings("SpellCheckingInspection")
+    private BaiChuanProperties baichuan;
+
     /**
      * Midjourney 绘图
      */
@@ -122,6 +128,19 @@ public class YudaoAiProperties {
 
     }
 
+    @Data
+    public static class  BaiChuanProperties {
+
+        private String enable;
+        private String apiKey;
+
+        private String model;
+        private Double temperature;
+        private Integer maxTokens;
+        private Double topP;
+
+    }
+
     @Data
     public static class MidjourneyProperties {
 

+ 1 - 0
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/enums/AiPlatformEnum.java

@@ -27,6 +27,7 @@ public enum AiPlatformEnum implements ArrayValuable<String> {
     SILICON_FLOW("SiliconFlow", "硅基流动"), // 硅基流动
     MINI_MAX("MiniMax", "MiniMax"), // 稀宇科技
     MOONSHOT("Moonshot", "月之暗灭"), // KIMI
+    BAI_CHUAN("BaiChuan", "百川智能"), // 百川智能
 
     // ========== 国外平台 ==========
 

+ 34 - 0
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/factory/AiModelFactoryImpl.java

@@ -11,11 +11,15 @@ import cn.hutool.extra.spring.SpringUtil;
 import cn.iocoder.yudao.framework.ai.config.YudaoAiAutoConfiguration;
 import cn.iocoder.yudao.framework.ai.config.YudaoAiProperties;
 import cn.iocoder.yudao.framework.ai.core.enums.AiPlatformEnum;
+import cn.iocoder.yudao.framework.ai.core.model.baichuan.BaiChuanChatModel;
 import cn.iocoder.yudao.framework.ai.core.model.deepseek.DeepSeekChatModel;
 import cn.iocoder.yudao.framework.ai.core.model.doubao.DouBaoChatModel;
 import cn.iocoder.yudao.framework.ai.core.model.hunyuan.HunYuanChatModel;
 import cn.iocoder.yudao.framework.ai.core.model.midjourney.api.MidjourneyApi;
+import cn.iocoder.yudao.framework.ai.core.model.siliconflow.SiliconFlowApiConstants;
 import cn.iocoder.yudao.framework.ai.core.model.siliconflow.SiliconFlowChatModel;
+import cn.iocoder.yudao.framework.ai.core.model.siliconflow.SiliconFlowImageApi;
+import cn.iocoder.yudao.framework.ai.core.model.siliconflow.SiliconFlowImageModel;
 import cn.iocoder.yudao.framework.ai.core.model.suno.api.SunoApi;
 import cn.iocoder.yudao.framework.ai.core.model.xinghuo.XingHuoChatModel;
 import cn.iocoder.yudao.framework.common.util.spring.SpringUtils;
@@ -42,6 +46,7 @@ import org.springframework.ai.autoconfigure.moonshot.MoonshotAutoConfiguration;
 import org.springframework.ai.autoconfigure.ollama.OllamaAutoConfiguration;
 import org.springframework.ai.autoconfigure.openai.OpenAiAutoConfiguration;
 import org.springframework.ai.autoconfigure.qianfan.QianFanAutoConfiguration;
+import org.springframework.ai.autoconfigure.stabilityai.StabilityAiImageAutoConfiguration;
 import org.springframework.ai.autoconfigure.vectorstore.milvus.MilvusServiceClientConnectionDetails;
 import org.springframework.ai.autoconfigure.vectorstore.milvus.MilvusServiceClientProperties;
 import org.springframework.ai.autoconfigure.vectorstore.milvus.MilvusVectorStoreAutoConfiguration;
@@ -146,6 +151,8 @@ public class AiModelFactoryImpl implements AiModelFactory {
                     return buildMoonshotChatModel(apiKey, url);
                 case XING_HUO:
                     return buildXingHuoChatModel(apiKey);
+                case BAI_CHUAN:
+                    return buildBaiChuanChatModel(apiKey);
                 case OPENAI:
                     return buildOpenAiChatModel(apiKey, url);
                 case AZURE_OPENAI:
@@ -182,6 +189,8 @@ public class AiModelFactoryImpl implements AiModelFactory {
                 return SpringUtil.getBean(MoonshotChatModel.class);
             case XING_HUO:
                 return SpringUtil.getBean(XingHuoChatModel.class);
+            case BAI_CHUAN:
+                return SpringUtil.getBean(AzureOpenAiChatModel.class);
             case OPENAI:
                 return SpringUtil.getBean(OpenAiChatModel.class);
             case AZURE_OPENAI:
@@ -203,6 +212,8 @@ public class AiModelFactoryImpl implements AiModelFactory {
                 return SpringUtil.getBean(QianFanImageModel.class);
             case ZHI_PU:
                 return SpringUtil.getBean(ZhiPuAiImageModel.class);
+            case SILICON_FLOW:
+                return SpringUtil.getBean(SiliconFlowImageModel.class);
             case OPENAI:
                 return SpringUtil.getBean(OpenAiImageModel.class);
             case STABLE_DIFFUSION:
@@ -224,6 +235,8 @@ public class AiModelFactoryImpl implements AiModelFactory {
                 return buildZhiPuAiImageModel(apiKey, url);
             case OPENAI:
                 return buildOpenAiImageModel(apiKey, url);
+            case SILICON_FLOW:
+                return buildSiliconFlowImageModel(apiKey,url);
             case STABLE_DIFFUSION:
                 return buildStabilityAiImageModel(apiKey, url);
             default:
@@ -433,6 +446,15 @@ public class AiModelFactoryImpl implements AiModelFactory {
         return new YudaoAiAutoConfiguration().buildXingHuoChatClient(properties);
     }
 
+    /**
+     * 可参考 {@link YudaoAiAutoConfiguration#baiChuanChatClient(YudaoAiProperties)}
+     */
+    private BaiChuanChatModel buildBaiChuanChatModel(String apiKey) {
+        YudaoAiProperties.BaiChuanProperties properties = new YudaoAiProperties.BaiChuanProperties()
+                .setApiKey(apiKey);
+        return new YudaoAiAutoConfiguration().buildBaiChuanChatClient(properties);
+    }
+
     /**
      * 可参考 {@link OpenAiAutoConfiguration} 的 openAiChatModel 方法
      */
@@ -468,6 +490,15 @@ public class AiModelFactoryImpl implements AiModelFactory {
         return new OpenAiImageModel(openAiApi);
     }
 
+    /**
+     * 创建 SiliconFlowImageModel 对象
+     */
+    private SiliconFlowImageModel buildSiliconFlowImageModel(String apiToken, String url) {
+        url = StrUtil.blankToDefault(url, SiliconFlowApiConstants.DEFAULT_BASE_URL);
+        SiliconFlowImageApi openAiApi = new SiliconFlowImageApi(url, apiToken);
+        return new SiliconFlowImageModel(openAiApi);
+    }
+
     /**
      * 可参考 {@link OllamaAutoConfiguration} 的 ollamaApi 方法
      */
@@ -476,6 +507,9 @@ public class AiModelFactoryImpl implements AiModelFactory {
         return OllamaChatModel.builder().ollamaApi(ollamaApi).toolCallingManager(getToolCallingManager()).build();
     }
 
+    /**
+     * 可参考 {@link StabilityAiImageAutoConfiguration} 的 stabilityAiImageModel 方法
+     */
     private StabilityAiImageModel buildStabilityAiImageModel(String apiKey, String url) {
         url = StrUtil.blankToDefault(url, StabilityAiApi.DEFAULT_BASE_URL);
         StabilityAiApi stabilityAiApi = new StabilityAiApi(apiKey, StabilityAiApi.DEFAULT_IMAGE_MODEL, url);

+ 45 - 0
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/model/baichuan/BaiChuanChatModel.java

@@ -0,0 +1,45 @@
+package cn.iocoder.yudao.framework.ai.core.model.baichuan;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.ai.chat.model.ChatModel;
+import org.springframework.ai.chat.model.ChatResponse;
+import org.springframework.ai.chat.prompt.ChatOptions;
+import org.springframework.ai.chat.prompt.Prompt;
+import org.springframework.ai.openai.OpenAiChatModel;
+import reactor.core.publisher.Flux;
+
+/**
+ * 百川 {@link ChatModel} 实现类
+ *
+ * @author 芋道源码
+ */
+@Slf4j
+@RequiredArgsConstructor
+public class BaiChuanChatModel implements ChatModel {
+
+    public static final String BASE_URL = "https://api.baichuan-ai.com";
+
+    public static final String MODEL_DEFAULT = "Baichuan4-Turbo";
+
+    /**
+     * 兼容 OpenAI 接口,进行复用
+     */
+    private final OpenAiChatModel openAiChatModel;
+
+    @Override
+    public ChatResponse call(Prompt prompt) {
+        return openAiChatModel.call(prompt);
+    }
+
+    @Override
+    public Flux<ChatResponse> stream(Prompt prompt) {
+        return openAiChatModel.stream(prompt);
+    }
+
+    @Override
+    public ChatOptions getDefaultOptions() {
+        return openAiChatModel.getDefaultOptions();
+    }
+
+}

+ 34 - 0
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/model/siliconflow/SiliconFlowApiConstants.java

@@ -0,0 +1,34 @@
+/*
+ * Copyright 2023-2024 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package cn.iocoder.yudao.framework.ai.core.model.siliconflow;
+
+/**
+ * SiliconFlow API 枚举类
+ *
+ * @author zzt
+ */
+public final class SiliconFlowApiConstants {
+
+	public static final String DEFAULT_BASE_URL = "https://api.siliconflow.cn";
+
+	public static final String MODEL_DEFAULT = "deepseek-ai/DeepSeek-R1-Distill-Qwen-7B";
+
+    public static final String DEFAULT_IMAGE_MODEL = "Kwai-Kolors/Kolors";
+
+	public static final String PROVIDER_NAME = "Siiconflow";
+
+}

+ 0 - 4
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/model/siliconflow/SiliconFlowChatModel.java

@@ -20,10 +20,6 @@ import reactor.core.publisher.Flux;
 @RequiredArgsConstructor
 public class SiliconFlowChatModel implements ChatModel {
 
-    public static final String BASE_URL = "https://api.siliconflow.cn";
-
-    public static final String MODEL_DEFAULT = "deepseek-ai/DeepSeek-R1-Distill-Qwen-7B";
-
     /**
      * 兼容 OpenAI 接口,进行复用
      */

+ 115 - 0
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/model/siliconflow/SiliconFlowImageApi.java

@@ -0,0 +1,115 @@
+/*
+ * Copyright 2023-2024 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package cn.iocoder.yudao.framework.ai.core.model.siliconflow;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.springframework.ai.model.ApiKey;
+import org.springframework.ai.model.NoopApiKey;
+import org.springframework.ai.model.SimpleApiKey;
+import org.springframework.ai.openai.api.OpenAiImageApi;
+import org.springframework.ai.retry.RetryUtils;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.util.Assert;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.client.ResponseErrorHandler;
+import org.springframework.web.client.RestClient;
+
+import java.util.Map;
+
+/**
+ * 硅基流动 Image API
+ *
+ * @see <a href= "https://docs.siliconflow.cn/cn/api-reference/images/images-generations">Images</a>
+ *
+ * @author zzt
+ */
+public class SiliconFlowImageApi {
+
+	private final RestClient restClient;
+
+	public SiliconFlowImageApi(String aiToken) {
+		this(SiliconFlowApiConstants.DEFAULT_BASE_URL, aiToken, RestClient.builder());
+	}
+
+    public SiliconFlowImageApi(String baseUrl, String openAiToken) {
+        this(baseUrl, openAiToken, RestClient.builder());
+    }
+
+	public SiliconFlowImageApi(String baseUrl, String openAiToken, RestClient.Builder restClientBuilder) {
+		this(baseUrl, openAiToken, restClientBuilder, RetryUtils.DEFAULT_RESPONSE_ERROR_HANDLER);
+	}
+
+	public SiliconFlowImageApi(String baseUrl, String apiKey, RestClient.Builder restClientBuilder,
+                               ResponseErrorHandler responseErrorHandler) {
+		this(baseUrl, apiKey, CollectionUtils.toMultiValueMap(Map.of()), restClientBuilder, responseErrorHandler);
+	}
+
+	public SiliconFlowImageApi(String baseUrl, String apiKey, MultiValueMap<String, String> headers,
+                               RestClient.Builder restClientBuilder, ResponseErrorHandler responseErrorHandler) {
+		this(baseUrl, new SimpleApiKey(apiKey), headers, restClientBuilder, responseErrorHandler);
+	}
+
+	public SiliconFlowImageApi(String baseUrl, ApiKey apiKey, MultiValueMap<String, String> headers,
+                               RestClient.Builder restClientBuilder, ResponseErrorHandler responseErrorHandler) {
+
+		// @formatter:off
+		this.restClient = restClientBuilder.baseUrl(baseUrl)
+			.defaultHeaders(h -> {
+				if(!(apiKey instanceof NoopApiKey)) {
+					h.setBearerAuth(apiKey.getValue());
+				}
+				h.setContentType(MediaType.APPLICATION_JSON);
+				h.addAll(headers);
+			})
+			.defaultStatusHandler(responseErrorHandler)
+			.build();
+		// @formatter:on
+	}
+
+	public ResponseEntity<OpenAiImageApi.OpenAiImageResponse> createImage(SiliconflowImageRequest siliconflowImageRequest) {
+		Assert.notNull(siliconflowImageRequest, "Image request cannot be null.");
+		Assert.hasLength(siliconflowImageRequest.prompt(), "Prompt cannot be empty.");
+
+		return this.restClient.post()
+			.uri("v1/images/generations")
+			.body(siliconflowImageRequest)
+			.retrieve()
+			.toEntity(OpenAiImageApi.OpenAiImageResponse.class);
+	}
+
+
+	// @formatter:off
+	@JsonInclude(JsonInclude.Include.NON_NULL)
+	public record SiliconflowImageRequest (
+			@JsonProperty("prompt") String prompt,
+			@JsonProperty("model") String model,
+			@JsonProperty("batch_size") Integer batchSize,
+			@JsonProperty("negative_prompt") String negativePrompt,
+			@JsonProperty("seed") Integer seed,
+			@JsonProperty("num_inference_steps") Integer numInferenceSteps,
+			@JsonProperty("guidance_scale") Float guidanceScale,
+			@JsonProperty("image") String image) {
+
+		public SiliconflowImageRequest(String prompt, String model) {
+			this(prompt, model, null, null, null, null, null, null);
+		}
+	}
+
+}

+ 159 - 0
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/model/siliconflow/SiliconFlowImageModel.java

@@ -0,0 +1,159 @@
+/*
+ * Copyright 2023-2024 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package cn.iocoder.yudao.framework.ai.core.model.siliconflow;
+
+import io.micrometer.observation.ObservationRegistry;
+import lombok.Setter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.ai.image.*;
+import org.springframework.ai.image.observation.DefaultImageModelObservationConvention;
+import org.springframework.ai.image.observation.ImageModelObservationContext;
+import org.springframework.ai.image.observation.ImageModelObservationConvention;
+import org.springframework.ai.image.observation.ImageModelObservationDocumentation;
+import org.springframework.ai.model.ModelOptionsUtils;
+import org.springframework.ai.openai.OpenAiImageModel;
+import org.springframework.ai.openai.api.OpenAiImageApi;
+import org.springframework.ai.openai.metadata.OpenAiImageGenerationMetadata;
+import org.springframework.ai.retry.RetryUtils;
+import org.springframework.http.ResponseEntity;
+import org.springframework.lang.Nullable;
+import org.springframework.retry.support.RetryTemplate;
+import org.springframework.util.Assert;
+
+import java.util.List;
+
+/**
+ * 硅基流动 {@link ImageModel} 实现类
+ *
+ * 参考 {@link OpenAiImageModel} 实现
+ *
+ * @author zzt
+ */
+public class SiliconFlowImageModel implements ImageModel {
+
+	private static final Logger logger = LoggerFactory.getLogger(SiliconFlowImageModel.class);
+
+	private static final ImageModelObservationConvention DEFAULT_OBSERVATION_CONVENTION = new DefaultImageModelObservationConvention();
+
+	private final SiliconFlowImageOptions defaultOptions;
+
+	private final RetryTemplate retryTemplate;
+
+	private final SiliconFlowImageApi siliconFlowImageApi;
+
+	private final ObservationRegistry observationRegistry;
+
+    @Setter
+	private ImageModelObservationConvention observationConvention = DEFAULT_OBSERVATION_CONVENTION;
+
+	public SiliconFlowImageModel(SiliconFlowImageApi siliconFlowImageApi) {
+		this(siliconFlowImageApi, SiliconFlowImageOptions.builder().build(), RetryUtils.DEFAULT_RETRY_TEMPLATE);
+	}
+
+	public SiliconFlowImageModel(SiliconFlowImageApi siliconFlowImageApi, SiliconFlowImageOptions options, RetryTemplate retryTemplate) {
+		this(siliconFlowImageApi, options, retryTemplate, ObservationRegistry.NOOP);
+	}
+
+	public SiliconFlowImageModel(SiliconFlowImageApi siliconFlowImageApi, SiliconFlowImageOptions options, RetryTemplate retryTemplate,
+                                 ObservationRegistry observationRegistry) {
+		Assert.notNull(siliconFlowImageApi, "OpenAiImageApi must not be null");
+		Assert.notNull(options, "options must not be null");
+		Assert.notNull(retryTemplate, "retryTemplate must not be null");
+		Assert.notNull(observationRegistry, "observationRegistry must not be null");
+		this.siliconFlowImageApi = siliconFlowImageApi;
+		this.defaultOptions = options;
+		this.retryTemplate = retryTemplate;
+		this.observationRegistry = observationRegistry;
+	}
+
+	@Override
+	public ImageResponse call(ImagePrompt imagePrompt) {
+        SiliconFlowImageOptions requestImageOptions = mergeOptions(imagePrompt.getOptions(), this.defaultOptions);
+        SiliconFlowImageApi.SiliconflowImageRequest imageRequest = createRequest(imagePrompt, requestImageOptions);
+
+		var observationContext = ImageModelObservationContext.builder()
+			.imagePrompt(imagePrompt)
+			.provider(SiliconFlowApiConstants.PROVIDER_NAME)
+			.requestOptions(imagePrompt.getOptions())
+			.build();
+
+		return ImageModelObservationDocumentation.IMAGE_MODEL_OPERATION
+			.observation(this.observationConvention, DEFAULT_OBSERVATION_CONVENTION, () -> observationContext,
+					this.observationRegistry)
+			.observe(() -> {
+				ResponseEntity<OpenAiImageApi.OpenAiImageResponse> imageResponseEntity = this.retryTemplate
+					.execute(ctx -> this.siliconFlowImageApi.createImage(imageRequest));
+
+				ImageResponse imageResponse = convertResponse(imageResponseEntity, imageRequest);
+
+				observationContext.setResponse(imageResponse);
+
+				return imageResponse;
+			});
+	}
+
+	private SiliconFlowImageApi.SiliconflowImageRequest createRequest(ImagePrompt imagePrompt,
+                                                                      SiliconFlowImageOptions requestImageOptions) {
+		String instructions = imagePrompt.getInstructions().get(0).getText();
+
+		SiliconFlowImageApi.SiliconflowImageRequest imageRequest = new SiliconFlowImageApi.SiliconflowImageRequest(instructions,
+                SiliconFlowApiConstants.DEFAULT_IMAGE_MODEL);
+
+		return ModelOptionsUtils.merge(requestImageOptions, imageRequest, SiliconFlowImageApi.SiliconflowImageRequest.class);
+	}
+
+	private ImageResponse convertResponse(ResponseEntity<OpenAiImageApi.OpenAiImageResponse> imageResponseEntity,
+										  SiliconFlowImageApi.SiliconflowImageRequest siliconflowImageRequest) {
+		OpenAiImageApi.OpenAiImageResponse imageApiResponse = imageResponseEntity.getBody();
+		if (imageApiResponse == null) {
+			logger.warn("No image response returned for request: {}", siliconflowImageRequest);
+			return new ImageResponse(List.of());
+		}
+
+		List<ImageGeneration> imageGenerationList = imageApiResponse.data()
+			.stream()
+			.map(entry -> new ImageGeneration(new Image(entry.url(), entry.b64Json()),
+					new OpenAiImageGenerationMetadata(entry.revisedPrompt())))
+			.toList();
+
+		ImageResponseMetadata openAiImageResponseMetadata = new ImageResponseMetadata(imageApiResponse.created());
+		return new ImageResponse(imageGenerationList, openAiImageResponseMetadata);
+	}
+
+    private SiliconFlowImageOptions mergeOptions(@Nullable ImageOptions runtimeOptions, SiliconFlowImageOptions defaultOptions) {
+        var runtimeOptionsForProvider = ModelOptionsUtils.copyToTarget(runtimeOptions, ImageOptions.class,
+                SiliconFlowImageOptions.class);
+
+        if (runtimeOptionsForProvider == null) {
+            return defaultOptions;
+        }
+
+        return SiliconFlowImageOptions.builder()
+                // Handle portable image options
+                .model(ModelOptionsUtils.mergeOption(runtimeOptionsForProvider.getModel(), defaultOptions.getModel()))
+                .batchSize(ModelOptionsUtils.mergeOption(runtimeOptionsForProvider.getN(), defaultOptions.getN()))
+                .width(ModelOptionsUtils.mergeOption(runtimeOptionsForProvider.getWidth(), defaultOptions.getWidth()))
+                .height(ModelOptionsUtils.mergeOption(runtimeOptionsForProvider.getHeight(), defaultOptions.getHeight()))
+                // Handle SiliconFlow specific image options
+                .negativePrompt(ModelOptionsUtils.mergeOption(runtimeOptionsForProvider.getNegativePrompt(), defaultOptions.getNegativePrompt()))
+                .numInferenceSteps(ModelOptionsUtils.mergeOption(runtimeOptionsForProvider.getNumInferenceSteps(), defaultOptions.getNumInferenceSteps()))
+                .guidanceScale(ModelOptionsUtils.mergeOption(runtimeOptionsForProvider.getGuidanceScale(), defaultOptions.getGuidanceScale()))
+                .seed(ModelOptionsUtils.mergeOption(runtimeOptionsForProvider.getSeed(), defaultOptions.getSeed()))
+                .build();
+    }
+}

+ 105 - 0
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/model/siliconflow/SiliconFlowImageOptions.java

@@ -0,0 +1,105 @@
+package cn.iocoder.yudao.framework.ai.core.model.siliconflow;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.ai.image.ImageOptions;
+
+/**
+ * 硅基流动 {@link ImageOptions}
+ *
+ * @author zzt
+ */
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class SiliconFlowImageOptions implements ImageOptions {
+
+    @JsonProperty("model")
+    private String model;
+
+    @JsonProperty("negative_prompt")
+    private String negativePrompt;
+
+    /**
+     * The number of images to generate. Must be between 1 and 4.
+     */
+    @JsonProperty("image_size")
+    private String imageSize;
+
+    /**
+     * The number of images to generate. Must be between 1 and 4.
+     */
+    @JsonProperty("batch_size")
+    private Integer batchSize = 1;
+
+    /**
+     * number of inference steps
+     */
+    @JsonProperty("num_inference_steps")
+    private Integer numInferenceSteps = 25;
+
+    /**
+     * This value is used to control the degree of match between the generated image and the given prompt. The higher the value, the more the generated image will tend to strictly match the text prompt. The lower the value, the more creative and diverse the generated image will be, potentially containing more unexpected elements.
+     *
+     * Required range: 0 <= x <= 20
+     */
+    @JsonProperty("guidance_scale")
+    private Float guidanceScale = 0.75F;
+
+    /**
+     * 如果想要每次都生成固定的图片,可以把 seed 设置为固定值
+     *
+     */
+    @JsonProperty("seed")
+    private Integer seed =  (int)(Math.random() * 1_000_000_000);
+
+    /**
+     * The image that needs to be uploaded should be converted into base64 format.
+     */
+    @JsonProperty("image")
+    private String image;
+
+    /**
+     * 宽
+     */
+    private Integer width;
+
+    /**
+     * 高
+     */
+    private Integer height;
+
+    public void setHeight(Integer height) {
+        this.height = height;
+        if (this.width != null && this.height != null) {
+            this.imageSize = this.width + "x" + this.height;
+        }
+    }
+
+    public void setWidth(Integer width) {
+        this.width = width;
+        if (this.width != null && this.height != null) {
+            this.imageSize = this.width + "x" + this.height;
+        }
+    }
+
+    @Override
+    public Integer getN() {
+        return batchSize;
+    }
+
+    @Override
+    public String getResponseFormat() {
+        return "url";
+    }
+
+    @Override
+    public String getStyle() {
+        return null;
+    }
+
+}

+ 385 - 0
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/model/wenduoduo/api/WddPptApi.java

@@ -0,0 +1,385 @@
+package cn.iocoder.yudao.framework.ai.core.model.wenduoduo.api;
+
+import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.core.ParameterizedTypeReference;
+import org.springframework.http.HttpRequest;
+import org.springframework.http.HttpStatusCode;
+import org.springframework.http.MediaType;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.reactive.function.BodyInserters;
+import org.springframework.web.reactive.function.client.ClientResponse;
+import org.springframework.web.reactive.function.client.WebClient;
+import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
+
+import java.time.LocalDateTime;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.function.Function;
+import java.util.function.Predicate;
+
+// TODO @新:要不改成 WenDuoDuoPptApi
+/**
+ * 文多多 API
+ *
+ * @see <a href="https://docmee.cn/open-platform/api">PPT 生成 API</a>
+ *
+ * @author xiaoxin
+ */
+@Slf4j
+public class WddPptApi {
+
+    public static final String BASE_URL = "https://docmee.cn";
+
+    private final WebClient webClient;
+
+    private final Predicate<HttpStatusCode> STATUS_PREDICATE = status -> !status.is2xxSuccessful();
+
+    private final Function<Object, Function<ClientResponse, Mono<? extends Throwable>>> EXCEPTION_FUNCTION =
+            reqParam -> response -> response.bodyToMono(String.class).handle((responseBody, sink) -> {
+                HttpRequest request = response.request();
+                log.error("[wdd-api] 调用失败!请求方式:[{}],请求地址:[{}],请求参数:[{}],响应数据: [{}]",
+                        request.getMethod(), request.getURI(), reqParam, responseBody);
+                sink.error(new IllegalStateException("[wdd-api] 调用失败!"));
+            });
+
+    // TODO @新:是不是不用 baseUrl 哈
+    public WddPptApi(String baseUrl) {
+        this.webClient = WebClient.builder()
+                .baseUrl(baseUrl)
+                // TODO @新:建议,token 作为 defaultHeader
+                .defaultHeaders((headers) -> headers.setContentType(MediaType.APPLICATION_JSON))
+                .build();
+    }
+
+    /**
+     * 创建 token
+     *
+     * @param request 请求信息
+     * @return token
+     */
+    public String createApiToken(CreateTokenRequest request) {
+        return this.webClient.post()
+                .uri("/api/user/createApiToken")
+                .header("Api-Key", request.apiKey)
+                .body(Mono.just(request), CreateTokenRequest.class)
+                .retrieve()
+                .onStatus(STATUS_PREDICATE, EXCEPTION_FUNCTION.apply(request))
+                .bodyToMono(ApiResponse.class)
+                .<String>handle((response, sink) -> {
+                    if (response.code != 0) {
+                        sink.error(new IllegalStateException("创建 token 异常," + response.message));
+                        return;
+                    }
+                    sink.next(response.data.get("token").toString());
+                })
+                .block();
+    }
+
+    // TODO @xin:是不是给个 API 连接,这样 type、content、files 都不用写注释太细了
+    /**
+     * 创建任务
+     *
+     * @param type    类型
+     *                1.智能生成(主题、要求)
+     *                2.上传文件生成
+     *                3.上传思维导图生成
+     *                4.通过word精准转ppt
+     *                5.通过网页链接生成
+     *                6.粘贴文本内容生成
+     *                7.Markdown大纲生成
+     * @param content 内容
+     *                type=1 用户输入主题或要求(不超过1000字符)
+     *                type=2、4 不传
+     *                type=3 幕布等分享链接
+     *                type=5 网页链接地址(http/https)
+     *                type=6 粘贴文本内容(不超过20000字符)
+     *                type=7 大纲内容(markdown)
+     * @param files   文件列表
+     *                文件列表(文件数不超过5个,总大小不超过50M):
+     *                type=1 上传参考文件(非必传,支持多个)
+     *                type=2 上传文件(支持多个)
+     *                type=3 上传思维导图(xmind/mm/md)(仅支持一个)
+     *                type=4 上传word文件(仅支持一个)
+     *                type=5、6、7 不传
+     *                <p>
+     *                支持格式:doc/docx/pdf/ppt/pptx/txt/md/xls/xlsx/csv/html/epub/mobi/xmind/mm
+     * @return 任务ID
+     */
+    public ApiResponse createTask(String token, Integer type, String content, List<MultipartFile> files) {
+        MultiValueMap<String, Object> formData = new LinkedMultiValueMap<>();
+        formData.add("type", type);
+        if (content != null) {
+            formData.add("content", content);
+        }
+        if (files != null) {
+            for (MultipartFile file : files) {
+                formData.add("file", file.getResource());
+            }
+        }
+        return this.webClient.post()
+                .uri("/api/ppt/v2/createTask")
+                .header("token", token)
+                .contentType(MediaType.MULTIPART_FORM_DATA)
+                .body(BodyInserters.fromMultipartData(formData))
+                .retrieve()
+                .onStatus(STATUS_PREDICATE, EXCEPTION_FUNCTION.apply(formData))
+                .bodyToMono(ApiResponse.class)
+                .block();
+    }
+
+    /**
+     * 获取生成选项
+     *
+     * @param lang 语种
+     * @return 生成选项
+     */
+    public Map<String, Object> getOptions(String lang) {
+        String uri = "/api/ppt/v2/options";
+        if (lang != null) {
+            uri += "?lang=" + lang;
+        }
+        return this.webClient.get()
+                .uri(uri)
+                .retrieve()
+                .onStatus(STATUS_PREDICATE, EXCEPTION_FUNCTION.apply(lang))
+                .bodyToMono(new ParameterizedTypeReference<ApiResponse>() {
+                })
+                .<Map<String, Object>>handle((response, sink) -> {
+                    if (response.code != 0) {
+                        sink.error(new IllegalStateException("获取生成选项异常," + response.message));
+                        return;
+                    }
+                    sink.next(response.data);
+                })
+                .block();
+    }
+
+    /**
+     * 分页查询 PPT 模板
+     *
+     * @param token   令牌
+     * @param request 请求体
+     * @return 模板列表
+     */
+    public PagePptTemplateInfo getTemplatePage(String token, TemplateQueryRequest request) {
+        return this.webClient.post()
+                .uri("/api/ppt/templates")
+                .header("token", token)
+                .bodyValue(request)
+                .retrieve()
+                .onStatus(STATUS_PREDICATE, EXCEPTION_FUNCTION.apply(request))
+                .bodyToMono(new ParameterizedTypeReference<PagePptTemplateInfo>() {
+                })
+                .block();
+    }
+
+    /**
+     * 生成大纲内容
+     *
+     * @return 大纲内容流
+     */
+    public Flux<Map<String, Object>> createOutline(String token, CreateOutlineRequest request) {
+        return this.webClient.post()
+                .uri("/api/ppt/v2/generateContent")
+                .header("token", token)
+                .body(Mono.just(request), CreateOutlineRequest.class)
+                .retrieve()
+                .onStatus(STATUS_PREDICATE, EXCEPTION_FUNCTION.apply(request))
+                .bodyToFlux(new ParameterizedTypeReference<>() {
+                });
+    }
+
+    /**
+     * 修改大纲内容
+     *
+     * @param request 请求体
+     * @return 大纲内容流
+     */
+    public Flux<Map<String, Object>> updateOutline(String token, UpdateOutlineRequest request) {
+        return this.webClient.post()
+                .uri("/api/ppt/v2/updateContent")
+                .header("token", token)
+                .body(Mono.just(request), UpdateOutlineRequest.class)
+                .retrieve()
+                .onStatus(STATUS_PREDICATE, EXCEPTION_FUNCTION.apply(request))
+                .bodyToFlux(new ParameterizedTypeReference<>() {
+                });
+    }
+
+    /**
+     * 生成 PPT
+     *
+     * @return PPT信息
+     */
+    public PptInfo create(String token, CreatePptRequest request) {
+        return this.webClient.post()
+                .uri("/api/ppt/v2/generatePptx")
+                .header("token", token)
+                .body(Mono.just(request), CreatePptRequest.class)
+                .retrieve()
+                .onStatus(STATUS_PREDICATE, EXCEPTION_FUNCTION.apply(request))
+                .bodyToMono(ApiResponse.class)
+                .<PptInfo>handle((response, sink) -> {
+                    if (response.code != 0) {
+                        sink.error(new IllegalStateException("生成 PPT 异常," + response.message));
+                        return;
+                    }
+                    sink.next(Objects.requireNonNull(JsonUtils.parseObject(JsonUtils.toJsonString(response.data.get("pptInfo")), PptInfo.class)));
+                })
+                .block();
+    }
+
+
+    @JsonInclude(value = JsonInclude.Include.NON_NULL)
+    public record CreateTokenRequest(
+            String apiKey,
+            String uid,
+            Integer limit
+    ) {
+
+        public CreateTokenRequest(String apiKey) {
+            this(apiKey, null, null);
+        }
+
+    }
+
+    /**
+     * API 通用响应
+     */
+    @JsonInclude(value = JsonInclude.Include.NON_NULL)
+    public record ApiResponse(
+            Integer code,
+            String message,
+            Map<String, Object> data
+    ) { }
+
+    /**
+     * 创建任务
+     */
+    @JsonInclude(value = JsonInclude.Include.NON_NULL)
+    public record CreateTaskRequest(
+            Integer type,
+            String content,
+            List<MultipartFile> files
+    ) { }
+
+    /**
+     * 生成大纲内容请求
+     */
+    @JsonInclude(value = JsonInclude.Include.NON_NULL)
+    public record CreateOutlineRequest(
+            String id,
+            String length,
+            String scene,
+            String audience,
+            String lang,
+            String prompt
+    ) { }
+
+    /**
+     * 修改大纲内容请求
+     */
+    @JsonInclude(value = JsonInclude.Include.NON_NULL)
+    public record UpdateOutlineRequest(
+            String id,
+            String markdown,
+            String question
+    ) { }
+
+    /**
+     * 生成 PPT 请求
+     */
+    // TODO @新:要不按照 PptCreateRequest 这样的风格
+    @JsonInclude(value = JsonInclude.Include.NON_NULL)
+    public record CreatePptRequest(
+            String id,
+            String templateId,
+            String markdown
+    ) { }
+
+    // TODO @新:要不写下类注释
+    @JsonInclude(value = JsonInclude.Include.NON_NULL)
+    public record PptInfo(
+            String id,
+            String name,
+            String subject,
+            String coverUrl,
+            String fileUrl,
+            String templateId,
+            String pptxProperty,
+            String userId,
+            String userName,
+            int companyId,
+            @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+            LocalDateTime updateTime,
+            @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+            LocalDateTime createTime,
+            String createUser,
+            String updateUser
+    ) { }
+
+    // TODO @新:要不写下类注释
+    @JsonInclude(value = JsonInclude.Include.NON_NULL)
+    public record TemplateQueryRequest(
+            int page,
+            int size,
+            Filter filters
+    ) {
+
+        @JsonInclude(value = JsonInclude.Include.NON_NULL)
+        public record Filter(
+                int type,
+                String category,
+                String style,
+                String themeColor
+        ) { }
+
+    }
+
+    // TODO @新:要不写下类注释
+    @JsonInclude(value = JsonInclude.Include.NON_NULL)
+    public record PagePptTemplateInfo(
+            List<PptTemplateInfo> data,
+            String total
+    ) {}
+
+
+    // TODO @新:要不写下类注释
+    @JsonInclude(value = JsonInclude.Include.NON_NULL)
+    public record PptTemplateInfo(
+            String id,
+            int type,
+            Integer subType,
+            String layout,
+            String category,
+            String style,
+            String themeColor,
+            String lang,
+            boolean animation,
+            String subject,
+            String coverUrl,
+            String fileUrl,
+            List<String> pageCoverUrls,
+            String pptxProperty,
+            int sort,
+            int num,
+            Integer imgNum,
+            int isDeleted,
+            String userId,
+            int companyId,
+            @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+            LocalDateTime updateTime,
+            @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+            LocalDateTime createTime,
+            String createUser,
+            String updateUser
+    ) { }
+
+}

+ 759 - 0
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/model/xinghuo/api/XunfeiPptApi.java

@@ -0,0 +1,759 @@
+package cn.iocoder.yudao.framework.ai.core.model.xinghuo.api;
+
+import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.core.io.ByteArrayResource;
+import org.springframework.http.HttpStatusCode;
+import org.springframework.http.MediaType;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.reactive.function.BodyInserters;
+import org.springframework.web.reactive.function.client.ClientResponse;
+import org.springframework.web.reactive.function.client.WebClient;
+import reactor.core.publisher.Mono;
+
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.security.InvalidKeyException;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Base64;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.function.Predicate;
+
+// TODO @新:要不改成 XunFeiPptApi
+/**
+ * 讯飞智能 PPT 生成 API
+ *
+ * @see <a href="https://www.xfyun.cn/doc/spark/PPTv2.html">智能 PPT 生成 API</a>
+ *
+ * @author xiaoxin
+ */
+@Slf4j
+public class XunfeiPptApi {
+
+    public static final String BASE_URL = "https://zwapi.xfyun.cn/api/ppt/v2";
+
+    private final WebClient webClient;
+    private final String appId;
+    private final String apiSecret;
+
+    private final Predicate<HttpStatusCode> STATUS_PREDICATE = status -> !status.is2xxSuccessful();
+
+    private final Function<Object, Function<ClientResponse, Mono<? extends Throwable>>> EXCEPTION_FUNCTION =
+            reqParam -> response -> response.bodyToMono(String.class).handle((responseBody, sink) -> {
+                log.error("[xunfei-ppt-api] 调用失败!请求参数:[{}],响应数据: [{}]", reqParam, responseBody);
+                sink.error(new IllegalStateException("[xunfei-ppt-api] 调用失败!"));
+            });
+
+    // TODO @新:是不是不用 baseUrl 哈
+    public XunfeiPptApi(String baseUrl, String appId, String apiSecret) {
+        // TODO @新:建议,增加 defaultheaders,例如说 appid 之类的;或者每个请求,通过 headers customer 处理。
+        this.webClient = WebClient.builder()
+                .baseUrl(baseUrl)
+                .build();
+        this.appId = appId;
+        this.apiSecret = apiSecret;
+    }
+
+    /**
+     * 获取签名
+     *
+     * @return 签名信息
+     */
+    private SignatureInfo getSignature() {
+        long timestamp = System.currentTimeMillis() / 1000;
+        String ts = String.valueOf(timestamp);
+        String signature = generateSignature(appId, apiSecret, timestamp);
+        return new SignatureInfo(appId, ts, signature);
+    }
+
+    /**
+     * 生成签名
+     *
+     * @param appId     应用ID
+     * @param apiSecret 应用密钥
+     * @param timestamp 时间戳(秒)
+     * @return 签名
+     */
+    private String generateSignature(String appId, String apiSecret, long timestamp) {
+        try {
+            // TODO @新:使用 hutool 简化
+            String auth = md5(appId + timestamp);
+            return hmacSHA1Encrypt(auth, apiSecret);
+        } catch (NoSuchAlgorithmException | InvalidKeyException e) {
+            log.error("[xunfei-ppt-api] 生成签名失败", e);
+            throw new IllegalStateException("[xunfei-ppt-api] 生成签名失败");
+        }
+    }
+
+    /**
+     * HMAC SHA1 加密
+     */
+    private String hmacSHA1Encrypt(String encryptText, String encryptKey)
+            throws NoSuchAlgorithmException, InvalidKeyException {
+        SecretKeySpec keySpec = new SecretKeySpec(
+                encryptKey.getBytes(StandardCharsets.UTF_8), "HmacSHA1");
+
+        Mac mac = Mac.getInstance("HmacSHA1");
+        mac.init(keySpec);
+        byte[] result = mac.doFinal(encryptText.getBytes(StandardCharsets.UTF_8));
+
+        return Base64.getEncoder().encodeToString(result);
+    }
+
+    /**
+     * MD5 哈希
+     */
+    private String md5(String text) throws NoSuchAlgorithmException {
+        MessageDigest md = MessageDigest.getInstance("MD5");
+        byte[] digest = md.digest(text.getBytes(StandardCharsets.UTF_8));
+
+        StringBuilder sb = new StringBuilder();
+        for (byte b : digest) {
+            sb.append(String.format("%02x", b));
+        }
+        return sb.toString();
+    }
+
+    /**
+     * 获取 PPT 模板列表
+     *
+     * @param style    风格,如"商务"
+     * @param pageSize 每页数量
+     * @return 模板列表
+     */
+    public TemplatePageResponse getTemplatePage(String style, Integer pageSize) {
+        SignatureInfo signInfo = getSignature();
+        Map<String, Object> requestBody = new HashMap<>();
+        requestBody.put("style", style);
+        // TODO @新:可以使用 ObjUtil.defaultIfNull
+        requestBody.put("pageSize", pageSize != null ? pageSize : 10);
+        return this.webClient.post()
+                .uri("/template/list")
+                .header("appId", signInfo.appId)
+                .header("timestamp", signInfo.timestamp)
+                .header("signature", signInfo.signature)
+                .contentType(MediaType.APPLICATION_JSON)
+                .bodyValue(requestBody)
+                .retrieve()
+                .onStatus(STATUS_PREDICATE, EXCEPTION_FUNCTION.apply(requestBody))
+                .bodyToMono(TemplatePageResponse.class)
+                .block();
+    }
+
+    /**
+     * 创建大纲(通过文本)
+     *
+     * @param query 查询文本
+     * @return 大纲创建响应
+     */
+    public CreateResponse createOutline(String query) {
+        SignatureInfo signInfo = getSignature();
+        MultiValueMap<String, Object> formData = new LinkedMultiValueMap<>();
+        formData.add("query", query);
+        return this.webClient.post()
+                .uri("/createOutline")
+                .header("appId", signInfo.appId)
+                .header("timestamp", signInfo.timestamp)
+                .header("signature", signInfo.signature)
+                .contentType(MediaType.MULTIPART_FORM_DATA)
+                .body(BodyInserters.fromMultipartData(formData))
+                .retrieve()
+                .onStatus(STATUS_PREDICATE, EXCEPTION_FUNCTION.apply(formData))
+                .bodyToMono(CreateResponse.class)
+                .block();
+    }
+
+
+    /**
+     * 直接创建 PPT(简化版 - 通过文本)
+     *
+     * @param query 查询文本
+     * @return 创建响应
+     */
+    public CreateResponse create(String query) {
+        CreatePptRequest request = CreatePptRequest.builder()
+                .query(query)
+                .build();
+        return create(request);
+    }
+
+    /**
+     * 直接创建 PPT(简化版 - 通过文件)
+     *
+     * @param file     文件
+     * @param fileName 文件名
+     * @return 创建响应
+     */
+    public CreateResponse create(MultipartFile file, String fileName) {
+        CreatePptRequest request = CreatePptRequest.builder()
+                .file(file).fileName(fileName).build();
+        return create(request);
+    }
+
+    /**
+     * 直接创建 PPT(完整版)
+     *
+     * @param request 请求参数
+     * @return 创建响应
+     */
+    public CreateResponse create(CreatePptRequest request) {
+        SignatureInfo signInfo = getSignature();
+        MultiValueMap<String, Object> formData = buildCreateFormData(request);
+        return this.webClient.post()
+                .uri("/create")
+                .header("appId", signInfo.appId)
+                .header("timestamp", signInfo.timestamp)
+                .header("signature", signInfo.signature)
+                .contentType(MediaType.MULTIPART_FORM_DATA)
+                .body(BodyInserters.fromMultipartData(formData))
+                .retrieve()
+                .onStatus(STATUS_PREDICATE, EXCEPTION_FUNCTION.apply(formData))
+                .bodyToMono(CreateResponse.class)
+                .block();
+    }
+
+
+    /**
+     * 通过大纲创建 PPT(简化版)
+     *
+     * @param outline 大纲内容
+     * @param query   查询文本
+     * @return 创建响应
+     */
+    public CreateResponse createPptByOutline(OutlineData outline, String query) {
+        CreatePptByOutlineRequest request = CreatePptByOutlineRequest.builder()
+                .outline(outline)
+                .query(query)
+                .build();
+        return createPptByOutline(request);
+    }
+
+    /**
+     * 通过大纲创建 PPT(完整版)
+     *
+     * @param request 请求参数
+     * @return 创建响应
+     */
+    public CreateResponse createPptByOutline(CreatePptByOutlineRequest request) {
+        SignatureInfo signInfo = getSignature();
+        return this.webClient.post()
+                .uri("/createPptByOutline")
+                .header("appId", signInfo.appId)
+                .header("timestamp", signInfo.timestamp)
+                .header("signature", signInfo.signature)
+                .contentType(MediaType.APPLICATION_JSON)
+                .bodyValue(request)
+                .retrieve()
+                .onStatus(STATUS_PREDICATE, EXCEPTION_FUNCTION.apply(request))
+                .bodyToMono(CreateResponse.class)
+                .block();
+    }
+
+    /**
+     * 检查 PPT 生成进度
+     *
+     * @param sid 任务 ID
+     * @return 进度响应
+     */
+    public ProgressResponse checkProgress(String sid) {
+        SignatureInfo signInfo = getSignature();
+        return this.webClient.get()
+                .uri(uriBuilder -> uriBuilder
+                        .path("/progress")
+                        .queryParam("sid", sid)
+                        .build())
+                .header("appId", signInfo.appId)
+                .header("timestamp", signInfo.timestamp)
+                .header("signature", signInfo.signature)
+                .retrieve()
+                .onStatus(STATUS_PREDICATE, EXCEPTION_FUNCTION.apply(sid))
+                .bodyToMono(ProgressResponse.class)
+                .block();
+    }
+
+    /**
+     * 签名信息
+     */
+    @JsonInclude(value = JsonInclude.Include.NON_NULL)
+    private record SignatureInfo(
+            String appId,
+            String timestamp,
+            String signature
+    ) { }
+
+    /**
+     * 模板列表响应
+     */
+    @JsonInclude(value = JsonInclude.Include.NON_NULL)
+    public record TemplatePageResponse(
+            boolean flag,
+            int code,
+            String desc,
+            Integer count,
+            TemplatePageData data
+    ) { }
+
+    /**
+     * 模板列表数据
+     */
+    @JsonInclude(value = JsonInclude.Include.NON_NULL)
+    public record TemplatePageData(
+            String total,
+            List<TemplateInfo> records,
+            Integer pageNum
+    ) { }
+
+    /**
+     * 模板信息
+     */
+    @JsonInclude(value = JsonInclude.Include.NON_NULL)
+    public record TemplateInfo(
+            String templateIndexId,
+            Integer pageCount,
+            String type,
+            String color,
+            String industry,
+            String style,
+            String detailImage
+    ) { }
+
+    /**
+     * 创建响应
+     */
+    @JsonInclude(value = JsonInclude.Include.NON_NULL)
+    public record CreateResponse(
+            boolean flag,
+            int code,
+            String desc,
+            Integer count,
+            CreateResponseData data
+    ) { }
+
+    /**
+     * 创建响应数据
+     */
+    @JsonInclude(value = JsonInclude.Include.NON_NULL)
+    public record CreateResponseData(
+            String sid,
+            String coverImgSrc,
+            String title,
+            String subTitle,
+            OutlineData outline
+    ) { }
+
+    /**
+     * 大纲数据结构
+     */
+    @JsonInclude(value = JsonInclude.Include.NON_NULL)
+    public record OutlineData(
+            String title,
+            String subTitle,
+            List<Chapter> chapters
+    ) {
+
+        /**
+         * 章节结构
+         */
+        @JsonInclude(value = JsonInclude.Include.NON_NULL)
+        public record Chapter(
+                String chapterTitle,
+                List<ChapterContent> chapterContents
+        ) {
+
+            /**
+             * 章节内容
+             */
+            @JsonInclude(value = JsonInclude.Include.NON_NULL)
+            public record ChapterContent(
+                    String chapterTitle
+            ) { }
+
+        }
+
+        /**
+         * 将大纲对象转换为JSON字符串
+         *
+         * @return 大纲JSON字符串
+         */
+        public String toJsonString() {
+            return JsonUtils.toJsonString(this);
+        }
+    }
+
+    /**
+     * 进度响应
+     */
+    @JsonInclude(value = JsonInclude.Include.NON_NULL)
+    public record ProgressResponse(
+            int code,
+            String desc,
+            ProgressResponseData data
+    ) { }
+
+    /**
+     * 进度响应数据
+     */
+    @JsonInclude(value = JsonInclude.Include.NON_NULL)
+    public record ProgressResponseData(
+            int process,
+            String pptId,
+            String pptUrl,
+            // TODO @新:字段注释,去掉
+            String pptStatus,         // PPT构建状态:building(构建中),done(已完成),build_failed(生成失败)
+            String aiImageStatus,     // ai配图状态:building(构建中),done(已完成)
+            String cardNoteStatus,    // 演讲备注状态:building(构建中),done(已完成)
+            String errMsg,            // 生成PPT的失败信息
+            Integer totalPages,       // 生成PPT的总页数
+            Integer donePages         // 生成PPT的完成页数
+    ) {
+
+        /**
+         * 是否全部完成
+         *
+         * @return 是否全部完成
+         */
+        public boolean isAllDone() {
+            return "done".equals(pptStatus)
+                    && ("done".equals(aiImageStatus) || aiImageStatus == null)
+                    && ("done".equals(cardNoteStatus) || cardNoteStatus == null);
+        }
+
+        /**
+         * 是否失败
+         *
+         * @return 是否失败
+         */
+        public boolean isFailed() {
+            return "build_failed".equals(pptStatus);
+        }
+
+        /**
+         * 获取进度百分比
+         *
+         * @return 进度百分比
+         */
+        public int getProgressPercent() {
+            if (totalPages == null || totalPages == 0 || donePages == null) {
+                return process; // 兼容旧版返回
+            }
+            return (int) (donePages * 100.0 / totalPages);
+        }
+
+    }
+
+    /**
+     * 通过大纲创建 PPT 请求参数
+     */
+    @JsonInclude(value = JsonInclude.Include.NON_NULL)
+    public record CreatePptByOutlineRequest(
+            String query,                // 用户生成PPT要求(最多8000字)
+            String outlineSid,           // 已生成大纲后,响应返回的请求大纲唯一id
+            OutlineData outline,         // 大纲内容
+            String templateId,           // 模板ID
+            String businessId,           // 业务ID(非必传)
+            String author,               // PPT作者名
+            Boolean isCardNote,          // 是否生成PPT演讲备注
+            Boolean search,              // 是否联网搜索
+            String language,             // 语种
+            String fileUrl,              // 文件地址
+            String fileName,             // 文件名(带文件名后缀)
+            Boolean isFigure,            // 是否自动配图
+            String aiImage               // ai配图类型:normal、advanced
+    ) {
+
+        /**
+         * 创建构建器
+         *
+         * @return 构建器
+         */
+        public static Builder builder() {
+            return new Builder();
+        }
+
+        // TODO @新:这个可以用 lombok 简化么?
+        /**
+         * 构建器类
+         */
+        public static class Builder {
+
+            private String query;
+            private String outlineSid;
+            private OutlineData outline;
+            private String templateId;
+            private String businessId;
+            private String author;
+            private Boolean isCardNote;
+            private Boolean search;
+            private String language;
+            private String fileUrl;
+            private String fileName;
+            private Boolean isFigure;
+            private String aiImage;
+
+            public Builder query(String query) {
+                this.query = query;
+                return this;
+            }
+
+            public Builder outlineSid(String outlineSid) {
+                this.outlineSid = outlineSid;
+                return this;
+            }
+
+            public Builder outline(OutlineData outline) {
+                this.outline = outline;
+                return this;
+            }
+
+            public Builder templateId(String templateId) {
+                this.templateId = templateId;
+                return this;
+            }
+
+            public Builder businessId(String businessId) {
+                this.businessId = businessId;
+                return this;
+            }
+
+            public Builder author(String author) {
+                this.author = author;
+                return this;
+            }
+
+            public Builder isCardNote(Boolean isCardNote) {
+                this.isCardNote = isCardNote;
+                return this;
+            }
+
+            public Builder search(Boolean search) {
+                this.search = search;
+                return this;
+            }
+
+            public Builder language(String language) {
+                this.language = language;
+                return this;
+            }
+
+            public Builder fileUrl(String fileUrl) {
+                this.fileUrl = fileUrl;
+                return this;
+            }
+
+            public Builder fileName(String fileName) {
+                this.fileName = fileName;
+                return this;
+            }
+
+            public Builder isFigure(Boolean isFigure) {
+                this.isFigure = isFigure;
+                return this;
+            }
+
+            public Builder aiImage(String aiImage) {
+                this.aiImage = aiImage;
+                return this;
+            }
+
+            public CreatePptByOutlineRequest build() {
+                return new CreatePptByOutlineRequest(
+                        query, outlineSid, outline, templateId, businessId, author,
+                        isCardNote, search, language, fileUrl, fileName, isFigure, aiImage
+                );
+            }
+        }
+    }
+
+    /**
+     * 构建创建 PPT 的表单数据
+     *
+     * @param request 请求参数
+     * @return 表单数据
+     */
+    private MultiValueMap<String, Object> buildCreateFormData(CreatePptRequest request) {
+        MultiValueMap<String, Object> formData = new LinkedMultiValueMap<>();
+        // 添加请求参数
+        if (request.query() != null) {
+            formData.add("query", request.query());
+        }
+        if (request.file() != null) {
+            try {
+                formData.add("file", new ByteArrayResource(request.file().getBytes()) {
+                    @Override
+                    public String getFilename() {
+                        return request.file().getOriginalFilename();
+                    }
+                });
+            } catch (IOException e) {
+                log.error("[xunfei-ppt-api] 文件处理失败", e);
+                throw new IllegalStateException("[xunfei-ppt-api] 文件处理失败", e);
+            }
+        }
+        // TODO @新:要不搞个 MapUtil.addIfPresent 方法?
+        if (request.fileUrl() != null) {
+            formData.add("fileUrl", request.fileUrl());
+        }
+        if (request.fileName() != null) {
+            formData.add("fileName", request.fileName());
+        }
+        if (request.templateId() != null) {
+            formData.add("templateId", request.templateId());
+        }
+        if (request.businessId() != null) {
+            formData.add("businessId", request.businessId());
+        }
+        if (request.author() != null) {
+            formData.add("author", request.author());
+        }
+        if (request.isCardNote() != null) {
+            formData.add("isCardNote", request.isCardNote().toString());
+        }
+        if (request.search() != null) {
+            formData.add("search", request.search().toString());
+        }
+        if (request.language() != null) {
+            formData.add("language", request.language());
+        }
+        if (request.isFigure() != null) {
+            formData.add("isFigure", request.isFigure().toString());
+        }
+        if (request.aiImage() != null) {
+            formData.add("aiImage", request.aiImage());
+        }
+        return formData;
+    }
+
+    /**
+     * 直接生成PPT请求参数
+     */
+    @JsonInclude(value = JsonInclude.Include.NON_NULL)
+    public record CreatePptRequest(
+            String query,                // 用户生成PPT要求(最多8000字)
+            MultipartFile file,          // 上传文件
+            String fileUrl,              // 文件地址
+            String fileName,             // 文件名(带文件名后缀)
+            String templateId,           // 模板ID
+            String businessId,           // 业务ID(非必传)
+            String author,               // PPT作者名
+            Boolean isCardNote,          // 是否生成PPT演讲备注
+            Boolean search,              // 是否联网搜索
+            String language,             // 语种
+            Boolean isFigure,            // 是否自动配图
+            String aiImage               // ai配图类型:normal、advanced
+    ) {
+
+        /**
+         * 创建构建器
+         *
+         * @return 构建器
+         */
+        public static Builder builder() {
+            return new Builder();
+        }
+
+        /**
+         * 构建器类
+         */
+        public static class Builder {
+
+            private String query;
+            private MultipartFile file;
+            private String fileUrl;
+            private String fileName;
+            private String templateId;
+            private String businessId;
+            private String author;
+            private Boolean isCardNote;
+            private Boolean search;
+            private String language;
+            private Boolean isFigure;
+            private String aiImage;
+
+            // TODO @新:这个可以用 lombok 简化么?
+
+            public Builder query(String query) {
+                this.query = query;
+                return this;
+            }
+
+            public Builder file(MultipartFile file) {
+                this.file = file;
+                return this;
+            }
+
+            public Builder fileUrl(String fileUrl) {
+                this.fileUrl = fileUrl;
+                return this;
+            }
+
+            public Builder fileName(String fileName) {
+                this.fileName = fileName;
+                return this;
+            }
+
+            public Builder templateId(String templateId) {
+                this.templateId = templateId;
+                return this;
+            }
+
+            public Builder businessId(String businessId) {
+                this.businessId = businessId;
+                return this;
+            }
+
+            public Builder author(String author) {
+                this.author = author;
+                return this;
+            }
+
+            public Builder isCardNote(Boolean isCardNote) {
+                this.isCardNote = isCardNote;
+                return this;
+            }
+
+            public Builder search(Boolean search) {
+                this.search = search;
+                return this;
+            }
+
+            public Builder language(String language) {
+                this.language = language;
+                return this;
+            }
+
+            public Builder isFigure(Boolean isFigure) {
+                this.isFigure = isFigure;
+                return this;
+            }
+
+            public Builder aiImage(String aiImage) {
+                this.aiImage = aiImage;
+                return this;
+            }
+
+            public CreatePptRequest build() {
+                // 验证参数
+                if (query == null && file == null && fileUrl == null) {
+                    throw new IllegalArgumentException("query、file、fileUrl必填其一");
+                }
+                if ((file != null || fileUrl != null) && fileName == null) {
+                    throw new IllegalArgumentException("如果传file或者fileUrl,fileName必填");
+                }
+                return new CreatePptRequest(
+                        query, file, fileUrl, fileName, templateId, businessId, author,
+                        isCardNote, search, language, isFigure, aiImage
+                );
+            }
+        }
+    }
+
+}

+ 1 - 0
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/util/AiUtils.java

@@ -53,6 +53,7 @@ public class AiUtils {
             case HUN_YUAN: // 复用 OpenAI 客户端
             case XING_HUO: // 复用 OpenAI 客户端
             case SILICON_FLOW: // 复用 OpenAI 客户端
+            case BAI_CHUAN: // 复用 OpenAI 客户端
                 return OpenAiChatOptions.builder().model(model).temperature(temperature).maxTokens(maxTokens)
                         .toolNames(toolNames).build();
             case AZURE_OPENAI:

+ 68 - 0
yudao-module-ai/yudao-spring-boot-starter-ai/src/test/java/cn/iocoder/yudao/framework/ai/chat/BaiChuanChatModelTests.java

@@ -0,0 +1,68 @@
+package cn.iocoder.yudao.framework.ai.chat;
+
+import cn.iocoder.yudao.framework.ai.core.model.baichuan.BaiChuanChatModel;
+import cn.iocoder.yudao.framework.ai.core.model.deepseek.DeepSeekChatModel;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.springframework.ai.chat.messages.Message;
+import org.springframework.ai.chat.messages.SystemMessage;
+import org.springframework.ai.chat.messages.UserMessage;
+import org.springframework.ai.chat.model.ChatResponse;
+import org.springframework.ai.chat.prompt.Prompt;
+import org.springframework.ai.openai.OpenAiChatModel;
+import org.springframework.ai.openai.OpenAiChatOptions;
+import org.springframework.ai.openai.api.OpenAiApi;
+import reactor.core.publisher.Flux;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * {@link BaiChuanChatModel} 集成测试
+ *
+ * @author 芋道源码
+ */
+public class BaiChuanChatModelTests {
+
+    private final OpenAiChatModel openAiChatModel = OpenAiChatModel.builder()
+            .openAiApi(OpenAiApi.builder()
+                    .baseUrl(BaiChuanChatModel.BASE_URL)
+                    .apiKey("sk-61b6766a94c70786ed02673f5e16af3c") // apiKey
+                    .build())
+            .defaultOptions(OpenAiChatOptions.builder()
+                    .model("Baichuan4-Turbo") // 模型(https://platform.baichuan-ai.com/docs/api)
+                    .temperature(0.7)
+                    .build())
+            .build();
+
+    private final DeepSeekChatModel chatModel = new DeepSeekChatModel(openAiChatModel);
+
+    @Test
+    @Disabled
+    public void testCall() {
+        // 准备参数
+        List<Message> messages = new ArrayList<>();
+        messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。"));
+        messages.add(new UserMessage("1 + 1 = ?"));
+
+        // 调用
+        ChatResponse response = chatModel.call(new Prompt(messages));
+        // 打印结果
+        System.out.println(response);
+    }
+
+    @Test
+    @Disabled
+    public void testStream() {
+        // 准备参数
+        List<Message> messages = new ArrayList<>();
+        messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。"));
+        messages.add(new UserMessage("1 + 1 = ?"));
+
+        // 调用
+        Flux<ChatResponse> flux = chatModel.stream(new Prompt(messages));
+        // 打印结果
+        flux.doOnNext(System.out::println).then().block();
+    }
+
+}

+ 3 - 2
yudao-module-ai/yudao-spring-boot-starter-ai/src/test/java/cn/iocoder/yudao/framework/ai/chat/SiliconFlowChatModelTests.java

@@ -1,5 +1,6 @@
 package cn.iocoder.yudao.framework.ai.chat;
 
+import cn.iocoder.yudao.framework.ai.core.model.siliconflow.SiliconFlowApiConstants;
 import cn.iocoder.yudao.framework.ai.core.model.siliconflow.SiliconFlowChatModel;
 import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
@@ -25,11 +26,11 @@ public class SiliconFlowChatModelTests {
 
     private final OpenAiChatModel openAiChatModel = OpenAiChatModel.builder()
             .openAiApi(OpenAiApi.builder()
-                    .baseUrl(SiliconFlowChatModel.BASE_URL)
+                    .baseUrl(SiliconFlowApiConstants.DEFAULT_BASE_URL)
                     .apiKey("sk-epsakfenqnyzoxhmbucsxlhkdqlcbnimslqoivkshalvdozz") // apiKey
                     .build())
             .defaultOptions(OpenAiChatOptions.builder()
-                    .model(SiliconFlowChatModel.MODEL_DEFAULT) // 模型
+                    .model(SiliconFlowApiConstants.MODEL_DEFAULT) // 模型
 //                    .model("deepseek-ai/DeepSeek-R1") // 模型(deepseek-ai/DeepSeek-R1)可用赠费
 //                    .model("Pro/deepseek-ai/DeepSeek-R1") // 模型(Pro/deepseek-ai/DeepSeek-R1)需要付费
                     .temperature(0.7)

+ 35 - 0
yudao-module-ai/yudao-spring-boot-starter-ai/src/test/java/cn/iocoder/yudao/framework/ai/image/SiliconFlowImageModelTests.java

@@ -0,0 +1,35 @@
+package cn.iocoder.yudao.framework.ai.image;
+
+import cn.iocoder.yudao.framework.ai.core.model.siliconflow.SiliconFlowImageApi;
+import cn.iocoder.yudao.framework.ai.core.model.siliconflow.SiliconFlowImageModel;
+import cn.iocoder.yudao.framework.ai.core.model.siliconflow.SiliconFlowImageOptions;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.springframework.ai.image.ImagePrompt;
+import org.springframework.ai.image.ImageResponse;
+
+/**
+ * {@link SiliconFlowImageModel} 集成测试
+ */
+public class SiliconFlowImageModelTests {
+
+    private final SiliconFlowImageModel imageModel = new SiliconFlowImageModel(
+            new SiliconFlowImageApi("sk-epsakfenqnyzoxhmbucsxlhkdqlcbnimslqoivkshalvdozz") // 密钥
+    );
+
+    @Test
+    @Disabled
+    public void testCall() {
+        // 准备参数
+        SiliconFlowImageOptions imageOptions = SiliconFlowImageOptions.builder()
+                .model("Kwai-Kolors/Kolors")
+                .build();
+        ImagePrompt prompt = new ImagePrompt("万里长城", imageOptions);
+
+        // 方法调用
+        ImageResponse response = imageModel.call(prompt);
+        // 打印结果
+        System.out.println(response);
+    }
+
+}

+ 314 - 0
yudao-module-ai/yudao-spring-boot-starter-ai/src/test/java/cn/iocoder/yudao/framework/ai/ppt/wdd/WddPptApiTests.java

@@ -0,0 +1,314 @@
+package cn.iocoder.yudao.framework.ai.ppt.wdd;
+
+import cn.iocoder.yudao.framework.ai.core.model.wenduoduo.api.WddPptApi;
+import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import reactor.core.publisher.Flux;
+
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * {@link WddPptApi} 集成测试
+ *
+ * @author xiaoxin
+ */
+public class WddPptApiTests {
+
+    private final WddPptApi wddPptApi = new WddPptApi("https://docmee.cn");
+
+    private final String token = ""; // API Token
+
+    @Test
+    @Disabled
+    public void testCreateApiToken() {
+        // 准备参数
+        String apiKey = "";
+        WddPptApi.CreateTokenRequest request = new WddPptApi.CreateTokenRequest(apiKey);
+        // 调用方法
+        String token = wddPptApi.createApiToken(request);
+        // 打印结果
+        System.out.println(token);
+    }
+
+    /**
+     * 创建任务
+     */
+    @Test
+    @Disabled
+    public void testCreateTask() {
+        WddPptApi.ApiResponse apiResponse = wddPptApi.createTask(token, 1, "dify 介绍", null);
+        System.out.println(apiResponse);
+    }
+
+
+    @Test // 创建大纲
+    @Disabled
+    public void testGenerateOutlineRequest() {
+        WddPptApi.CreateOutlineRequest request = new WddPptApi.CreateOutlineRequest(
+                "1901539019628613632", "medium", null, null, null, null);
+        // 调用
+        Flux<Map<String, Object>> flux = wddPptApi.createOutline(token, request);
+        StringBuffer contentBuffer = new StringBuffer();
+        flux.doOnNext(chunk -> {
+            contentBuffer.append(chunk.get("text"));
+            if (Objects.equals(Integer.parseInt(String.valueOf(chunk.get("status"))), 4)) {
+                // status 为 4,最终 markdown 结构树
+                System.out.println(JsonUtils.toJsonString(chunk.get("result")));
+                System.out.println(" ########################################################################");
+            }
+        }).then().block();
+        // 打印结果
+        System.out.println(contentBuffer);
+    }
+
+    /**
+     * 修改大纲
+     */
+    @Test
+    @Disabled
+    public void testUpdateOutlineRequest() {
+        WddPptApi.UpdateOutlineRequest request = new WddPptApi.UpdateOutlineRequest(
+                "1901539019628613632", TEST_OUT_LINE_CONTENT, "精简一点,三个章节即可");
+        // 调用
+        Flux<Map<String, Object>> flux = wddPptApi.updateOutline(token, request);
+        StringBuffer contentBuffer = new StringBuffer();
+        flux.doOnNext(chunk -> {
+            contentBuffer.append(chunk.get("text"));
+            if (Objects.equals(Integer.parseInt(String.valueOf(chunk.get("status"))), 4)) {
+                // status 为 4,最终 markdown 结构树
+                System.out.println(JsonUtils.toJsonString(chunk.get("result")));
+                System.out.println(" ########################################################################");
+            }
+        }).then().block();
+        // 打印结果
+        System.out.println(contentBuffer);
+
+    }
+
+    /**
+     * 获取 PPT 模版分页
+     */
+    @Test
+    @Disabled
+    public void testGetPptTemplatePage() {
+        // 准备参数
+        WddPptApi.TemplateQueryRequest.Filter filter = new WddPptApi.TemplateQueryRequest.Filter(
+                1, null, null, null);
+        WddPptApi.TemplateQueryRequest request = new WddPptApi.TemplateQueryRequest(1, 10, filter);
+        // 调用
+        WddPptApi.PagePptTemplateInfo pptTemplatePage = wddPptApi.getTemplatePage(token, request);
+        // 打印结果
+        System.out.println(pptTemplatePage);
+    }
+
+    /**
+     * 生成 PPT
+     */
+    @Test
+    @Disabled
+    public void testGeneratePptx() {
+        // 准备参数
+        WddPptApi.CreatePptRequest request = new WddPptApi.CreatePptRequest("1901539019628613632", "1805081814809960448", TEST_OUT_LINE_CONTENT);
+        // 调用
+        WddPptApi.PptInfo pptInfo = wddPptApi.create(token, request);
+        // 打印结果
+        System.out.println(pptInfo);
+    }
+
+    private final String TEST_OUT_LINE_CONTENT = """
+            # Dify:新一代AI应用开发平台
+            
+            ## 1 什么是Dify
+            ### 1.1 Dify定义:AI应用开发平台
+            #### 1.1.1 低代码开发
+            Dify是一个低代码AI应用开发平台,旨在简化AI应用的构建过程,让开发者无需编写大量代码即可快速创建各种智能应用。
+            #### 1.1.2 核心功能
+            Dify的核心功能包括数据集成、模型选择、流程编排和应用部署,提供一站式解决方案,加速AI应用的落地和迭代。
+            #### 1.1.3 开源与商业
+            Dify提供开源版本和商业版本,满足不同用户的需求,开源版本适合个人开发者和小型团队,商业版本则提供更强大的功能和技术支持。
+            
+            ### 1.2 Dify解决的问题:AI开发痛点
+            #### 1.2.1 开发周期长
+            传统AI应用开发周期长,需要大量的人力和时间投入,Dify通过可视化界面和预置组件,大幅缩短开发周期。
+            #### 1.2.2 技术门槛高
+            AI技术门槛高,需要专业的知识和技能,Dify降低技术门槛,让更多开发者能够参与到AI应用的开发中来。
+            #### 1.2.3 部署和维护复杂
+            AI应用的部署和维护复杂,需要专业的运维团队,Dify提供自动化的部署和维护工具,简化流程,降低成本。
+            
+            ### 1.3 Dify发展历程
+            #### 1.3.1 早期探索
+            Dify的早期版本主要关注于自然语言处理领域的应用,通过集成各种NLP模型,提供文本分类、情感分析等功能。
+            #### 1.3.2 功能扩展
+            随着用户需求的不断增长,Dify的功能逐渐扩展到图像识别、语音识别等领域,支持更多类型的AI应用。
+            #### 1.3.3 生态建设
+            Dify积极建设开发者生态,提供丰富的文档、教程和案例,帮助开发者更好地使用Dify平台,共同推动AI技术的发展。
+            
+            ## 2 Dify的核心功能
+            ### 2.1 数据集成:连接各种数据源
+            #### 2.1.1 支持多种数据源
+            Dify支持连接各种数据源,包括关系型数据库、NoSQL数据库、文件系统、云存储等,满足不同场景的数据需求。
+            #### 2.1.2 数据转换和清洗
+            Dify提供数据转换和清洗功能,可以将不同格式的数据转换为统一的格式,并去除无效数据,提高数据质量。
+            #### 2.1.3 数据安全
+            Dify注重数据安全,采用各种安全措施保护用户的数据,包括数据加密、访问控制、权限管理等。
+            
+            ### 2.2 模型选择:丰富的AI模型库
+            #### 2.2.1 预置模型
+            Dify预置了丰富的AI模型,包括自然语言处理、图像识别、语音识别等领域的模型,开发者可以直接使用这些模型,无需自行训练,极大的简化了开发流程。
+            #### 2.2.2 自定义模型
+            Dify支持开发者上传自定义模型,满足个性化的需求。开发者可以将自己训练的模型部署到Dify平台上,与其他开发者共享。
+            #### 2.2.3 模型评估
+            Dify提供模型评估功能,可以对不同模型进行评估,选择最优的模型,提高应用性能。
+            
+            ### 2.3 流程编排:可视化流程设计器
+            #### 2.3.1 可视化界面
+            Dify提供可视化的流程设计器,开发者可以通过拖拽组件的方式,设计AI应用的流程,无需编写代码,简单高效。
+            #### 2.3.2 灵活的流程控制
+            Dify支持灵活的流程控制,可以根据不同的条件执行不同的分支,实现复杂的业务逻辑。
+            #### 2.3.3 实时调试
+            Dify提供实时调试功能,可以在设计流程的过程中,实时查看流程的执行结果,及时发现和解决问题。
+            
+            ### 2.4 应用部署:一键部署和管理
+            #### 2.4.1 快速部署
+            Dify提供一键部署功能,可以将AI应用快速部署到各种环境,包括本地环境、云环境、容器环境等。
+            #### 2.4.2 自动伸缩
+            Dify支持自动伸缩,可以根据应用的负载自动调整资源,保证应用的稳定性和性能。
+            #### 2.4.3 监控和告警
+            Dify提供监控和告警功能,可以实时监控应用的状态,并在出现问题时及时告警,方便运维人员进行处理。
+            
+            ## 3 Dify的特点和优势
+            ### 3.1 低代码:降低开发门槛
+            #### 3.1.1 可视化开发
+            Dify采用可视化开发模式,开发者无需编写大量代码,只需通过拖拽组件即可完成AI应用的开发,降低了开发门槛。
+            #### 3.1.2 预置组件
+            Dify预置了丰富的组件,包括数据源组件、模型组件、流程控制组件等,开发者可以直接使用这些组件,提高开发效率。
+            #### 3.1.3 减少代码量
+            Dify可以显著减少代码量,降低开发难度,让更多开发者能够参与到AI应用的开发中来。
+            
+            ### 3.2 灵活:满足不同场景需求
+            #### 3.2.1 支持多种数据源
+            Dify支持多种数据源,可以连接各种数据源,满足不同场景的数据需求。
+            #### 3.2.2 支持自定义模型
+            Dify支持自定义模型,开发者可以将自己训练的模型部署到Dify平台上,满足个性化的需求。
+            #### 3.2.3 灵活的流程控制
+            Dify支持灵活的流程控制,可以根据不同的条件执行不同的分支,实现复杂的业务逻辑。
+            
+            ### 3.3 高效:加速应用落地
+            #### 3.3.1 快速开发
+            Dify通过可视化界面和预置组件,大幅缩短开发周期,加速AI应用的落地。
+            #### 3.3.2 快速部署
+            Dify提供一键部署功能,可以将AI应用快速部署到各种环境,提高部署效率。
+            #### 3.3.3 自动化运维
+            Dify提供自动化的运维工具,简化运维流程,降低运维成本。
+            
+            ### 3.4 开放:构建繁荣生态
+            #### 3.4.1 开源社区
+            Dify拥有活跃的开源社区,开发者可以在社区中交流经验、分享资源、共同推动Dify的发展。
+            #### 3.4.2 丰富的文档
+            Dify提供丰富的文档、教程和案例,帮助开发者更好地使用Dify平台。
+            #### 3.4.3 API支持
+            Dify提供API支持,开发者可以通过API将Dify集成到自己的系统中,扩展Dify的功能。
+            
+            ## 4 Dify的使用场景
+            ### 4.1 智能客服:提升客户服务质量
+            #### 4.1.1 自动回复
+            Dify可以用于构建智能客服系统,实现自动回复客户的常见问题,提高客户服务效率。
+            #### 4.1.2 情感分析
+            Dify可以对客户的语音或文本进行情感分析,判断客户的情绪,并根据情绪提供个性化的服务。
+            #### 4.1.3 知识库问答
+            Dify可以构建知识库问答系统,让客户通过提问的方式获取所需的信息,提高客户满意度。
+            
+            ### 4.2 金融风控:提高风险识别能力
+            #### 4.2.1 欺诈检测
+            Dify可以用于构建金融风控系统,实现欺诈检测,识别可疑交易,降低风险。
+            #### 4.2.2 信用评估
+            Dify可以对用户的信用进行评估,并根据评估结果提供不同的金融服务。
+            #### 4.2.3 反洗钱
+            Dify可以用于反洗钱,识别可疑资金流动,防止犯罪行为。
+            
+            ### 4.3 智慧医疗:提升医疗服务水平
+            #### 4.3.1 疾病诊断
+            Dify可以用于辅助疾病诊断,提高诊断准确率,缩短诊断时间。
+            #### 4.3.2 药物研发
+            Dify可以用于药物研发,加速新药的发现和开发。
+            #### 4.3.3 智能健康管理
+            Dify可以构建智能健康管理系统,为用户提供个性化的健康建议和服务。
+            
+            ### 4.4 智慧城市:提升城市管理效率
+            #### 4.4.1 交通优化
+            Dify可以用于交通优化,提高交通效率,缓解交通拥堵。
+            #### 4.4.2 环境监测
+            Dify可以用于环境监测,实时监测空气质量、水质等环境指标,及时发现和解决环境问题。
+            #### 4.4.3 智能安防
+            Dify可以用于智能安防,提高城市安全水平,预防犯罪行为。
+            
+            ## 5 Dify的成功案例
+            ### 5.1 Case 1:某电商平台的智能客服
+            #### 5.1.1 项目背景
+            该电商平台客户服务压力大,人工客服成本高,需要一种智能化的解决方案。
+            #### 5.1.2 解决方案
+            使用Dify构建智能客服系统,实现自动回复客户的常见问题,并根据客户的情绪提供个性化的服务。
+            #### 5.1.3 效果
+            客户服务效率提高50%,客户满意度提高20%,人工客服成本降低30%。
+            
+            ### 5.2 Case 2:某银行的金融风控系统
+            #### 5.2.1 项目背景
+            该银行面临日益增长的金融风险,需要一种更有效的风险识别和控制手段。
+            #### 5.2.2 解决方案
+            使用Dify构建金融风控系统,实现欺诈检测、信用评估和反洗钱等功能,提高风险识别能力。
+            #### 5.2.3 效果
+            欺诈交易识别率提高40%,信用评估准确率提高30%,洗钱风险降低25%。
+            
+            ### 5.3 Case 3:某医院的辅助疾病诊断系统
+            #### 5.3.1 项目背景
+            该医院医生工作压力大,疾病诊断准确率有待提高,需要一种辅助诊断工具。
+            #### 5.3.2 解决方案
+            使用Dify构建辅助疾病诊断系统,根据患者的病历和症状,提供诊断建议,提高诊断准确率。
+            #### 5.3.3 效果
+            疾病诊断准确率提高20%,诊断时间缩短15%,医生工作效率提高10%。
+            
+            ## 6 Dify的未来展望
+            ### 6.1 技术升级
+            #### 6.1.1 模型优化
+            Dify将不断优化预置模型,提高模型性能,并支持更多类型的AI模型。
+            #### 6.1.2 流程引擎升级
+            Dify将升级流程引擎,提高流程的灵活性和可扩展性,支持更复杂的业务逻辑。
+            #### 6.1.3 平台性能优化
+            Dify将不断优化平台性能,提高平台的稳定性和可靠性,满足大规模应用的需求。
+            
+            ### 6.2 生态建设
+            #### 6.2.1 社区建设
+            Dify将继续加强开源社区建设,吸引更多开发者参与,共同推动Dify的发展。
+            #### 6.2.2 合作伙伴拓展
+            Dify将拓展合作伙伴,与更多的企业和机构合作,共同推动AI技术的应用。
+            #### 6.2.3 应用商店
+            Dify将构建应用商店,让开发者可以分享自己的应用,用户可以购买和使用这些应用,构建繁荣的生态系统。
+            
+            ### 6.3 应用领域拓展
+            #### 6.3.1 智能制造
+            Dify将拓展到智能制造领域,为企业提供智能化的生产管理和质量控制解决方案。
+            #### 6.3.2 智慧农业
+            Dify将拓展到智慧农业领域,为农民提供智能化的种植和养殖管理解决方案。
+            #### 6.3.3 更多领域
+            Dify将拓展到更多领域,为各行各业提供智能化的解决方案,推动社会发展。
+            
+            ## 7 总结
+            ### 7.1 Dify的价值
+            #### 7.1.1 降低AI开发门槛
+            Dify通过低代码的方式,让更多开发者能够参与到AI应用的开发中来。
+            #### 7.1.2 加速AI应用落地
+            Dify提供一站式解决方案,加速AI应用的落地和迭代。
+            #### 7.1.3 构建繁荣的AI生态
+            Dify通过开源社区和应用商店,构建繁荣的AI生态系统。
+            
+            ### 7.2 共同发展
+            #### 7.2.1 欢迎加入Dify社区
+            欢迎更多开发者加入Dify社区,共同推动Dify的发展。
+            #### 7.2.2 合作共赢
+            期待与更多的企业和机构合作,共同推动AI技术的应用。
+            #### 7.2.3 共创未来
+            让我们一起用AI技术改变世界,共创美好未来。""";
+
+}

+ 318 - 0
yudao-module-ai/yudao-spring-boot-starter-ai/src/test/java/cn/iocoder/yudao/framework/ai/ppt/xunfei/XunfeiPptApiTests.java

@@ -0,0 +1,318 @@
+package cn.iocoder.yudao.framework.ai.ppt.xunfei;
+
+import cn.hutool.core.io.FileUtil;
+import cn.iocoder.yudao.framework.ai.core.model.xinghuo.api.XunfeiPptApi;
+import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.springframework.mock.web.MockMultipartFile;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.File;
+
+/**
+ * {@link XunfeiPptApi} 集成测试
+ *
+ * @author xiaoxin
+ */
+public class XunfeiPptApiTests {
+
+    // 讯飞 API 配置信息,实际使用时请替换为您的应用信息
+    private static final String APP_ID = "";
+    private static final String API_SECRET = "";
+
+    private final XunfeiPptApi xunfeiPptApi = new XunfeiPptApi(XunfeiPptApi.BASE_URL, APP_ID, API_SECRET);
+
+    /**
+     * 获取 PPT 模板列表
+     */
+    @Test
+    @Disabled
+    public void testGetTemplatePage() {
+        // 调用方法
+        XunfeiPptApi.TemplatePageResponse response = xunfeiPptApi.getTemplatePage("商务", 10);
+        // 打印结果
+        System.out.println("模板列表响应:" + JsonUtils.toJsonString(response));
+
+        if (response != null && response.data() != null && response.data().records() != null) {
+            System.out.println("模板总数:" + response.data().total());
+            System.out.println("当前页码:" + response.data().pageNum());
+            System.out.println("模板数量:" + response.data().records().size());
+
+            // 打印第一个模板的信息(如果存在)
+            if (!response.data().records().isEmpty()) {
+                XunfeiPptApi.TemplateInfo firstTemplate = response.data().records().get(0);
+                System.out.println("模板ID:" + firstTemplate.templateIndexId());
+                System.out.println("模板风格:" + firstTemplate.style());
+                System.out.println("模板颜色:" + firstTemplate.color());
+                System.out.println("模板行业:" + firstTemplate.industry());
+            }
+        }
+    }
+
+    /**
+     * 创建大纲(通过文本)
+     */
+    @Test
+    @Disabled
+    public void testCreateOutline() {
+        XunfeiPptApi.CreateResponse response = getCreateResponse();
+        // 打印结果
+        System.out.println("创建大纲响应:" + JsonUtils.toJsonString(response));
+
+        // 保存 sid 和 outline 用于后续测试
+        if (response != null && response.data() != null) {
+            System.out.println("sid: " + response.data().sid());
+            if (response.data().outline() != null) {
+                // 使用 OutlineData 的 toJsonString 方法
+                System.out.println("outline: " + response.data().outline().toJsonString());
+                // 将 outline 对象转换为 JSON 字符串,用于后续 createPptByOutline 测试
+                String outlineJson = response.data().outline().toJsonString();
+                System.out.println("可用于 createPptByOutline 的 outline 字符串: " + outlineJson);
+            }
+        }
+    }
+
+    /**
+     * 创建大纲(通过文本)
+     * @return 创建大纲响应
+     */
+    private XunfeiPptApi.CreateResponse getCreateResponse() {
+        String param = "智能体平台 Dify 介绍";
+        return xunfeiPptApi.createOutline(param);
+    }
+
+    /**
+     * 通过大纲创建 PPT(完整参数)
+     */
+    @Test
+    @Disabled
+    public void testCreatePptByOutlineWithFullParams() {
+        // 创建大纲对象
+        XunfeiPptApi.CreateResponse createResponse = getCreateResponse();
+        // 调用方法
+        XunfeiPptApi.CreateResponse response = xunfeiPptApi.createPptByOutline(createResponse.data().outline(), "精简一些,不要超过6个章节");
+        // 打印结果
+        System.out.println("通过大纲创建 PPT 响应:" + JsonUtils.toJsonString(response));
+
+        // 保存sid用于后续进度查询
+        if (response != null && response.data() != null) {
+            System.out.println("sid: " + response.data().sid());
+            if (response.data().coverImgSrc() != null) {
+                System.out.println("封面图片: " + response.data().coverImgSrc());
+            }
+        }
+    }
+
+    /**
+     * 检查 PPT 生成进度
+     */
+    @Test
+    @Disabled
+    public void testCheckProgress() {
+        // 准备参数 - 使用之前创建 PPT 时返回的 sid
+        String sid = "e96dac09f2ec4ee289f029a5fb874ecd"; // 替换为实际的sid
+
+        // 调用方法
+        XunfeiPptApi.ProgressResponse response = xunfeiPptApi.checkProgress(sid);
+        // 打印结果
+        System.out.println("检查进度响应:" + JsonUtils.toJsonString(response));
+
+        // 安全地访问响应数据
+        if (response != null && response.data() != null) {
+            XunfeiPptApi.ProgressResponseData data = response.data();
+
+            // 打印PPT生成状态
+            System.out.println("PPT 构建状态: " + data.pptStatus());
+            System.out.println("AI 配图状态: " + data.aiImageStatus());
+            System.out.println("演讲备注状态: " + data.cardNoteStatus());
+
+            // 打印进度信息
+            if (data.totalPages() != null && data.donePages() != null) {
+                System.out.println("总页数: " + data.totalPages());
+                System.out.println("已完成页数: " + data.donePages());
+                System.out.println("完成进度: " + data.getProgressPercent() + "%");
+            } else {
+                System.out.println("进度: " + data.process() + "%");
+            }
+
+            // 检查是否完成
+            if (data.isAllDone()) {
+                System.out.println("PPT 生成已完成!");
+                System.out.println("PPT 下载链接: " + data.pptUrl());
+            }
+            // 检查是否失败
+            else if (data.isFailed()) {
+                System.out.println("PPT 生成失败!");
+                System.out.println("错误信息: " + data.errMsg());
+            }
+            // 正在进行中
+            else {
+                System.out.println("PPT 生成中,请稍后再查询...");
+            }
+        }
+    }
+
+    /**
+     * 轮询检查 PPT 生成进度直到完成
+     */
+    @Test
+    @Disabled
+    public void testPollCheckProgress() throws InterruptedException {
+        // 准备参数 - 使用之前创建 PP T时返回的 sid
+        String sid = "fa36e926f2ed434987fcb4c1f0776ffb"; // 替换为实际的sid
+
+        // 最大轮询次数
+        int maxPolls = 20;
+        // 轮询间隔(毫秒)- 讯飞 API 限流为 3 秒一次
+        long pollInterval = 3500;
+
+        for (int i = 0; i < maxPolls; i++) {
+            System.out.println("第" + (i + 1) + "次查询进度...");
+
+            // 调用方法
+            XunfeiPptApi.ProgressResponse response = xunfeiPptApi.checkProgress(sid);
+
+            // 安全地访问响应数据
+            if (response != null && response.data() != null) {
+                XunfeiPptApi.ProgressResponseData data = response.data();
+
+                // 打印进度信息
+                System.out.println("PPT 构建状态: " + data.pptStatus());
+                if (data.totalPages() != null && data.donePages() != null) {
+                    System.out.println("完成进度: " + data.donePages() + "/" + data.totalPages()
+                            + " (" + data.getProgressPercent() + "%)");
+                }
+
+                // 检查是否完成
+                if (data.isAllDone()) {
+                    System.out.println("PPT 生成已完成!");
+                    System.out.println("PPT 下载链接: " + data.pptUrl());
+                    break;
+                }
+                // 检查是否失败
+                else if (data.isFailed()) {
+                    System.out.println("PPT 生成失败!");
+                    System.out.println("错误信息: " + data.errMsg());
+                    break;
+                }
+                // 正在进行中,继续轮询
+                else {
+                    System.out.println("PPT 生成中,等待" + (pollInterval / 1000) + "秒后继续查询...");
+                    Thread.sleep(pollInterval);
+                }
+            } else {
+                System.out.println("查询失败,等待" + (pollInterval / 1000) + "秒后重试...");
+                Thread.sleep(pollInterval);
+            }
+        }
+    }
+
+    /**
+     * 直接创建 PPT(通过文本)
+     */
+    @Test
+    @Disabled
+    public void testCreatePptByText() {
+        // 准备参数
+        String query = "合肥天气趋势分析,包括近5年的气温变化、降水量变化、极端天气事件,以及对城市生活的影响";
+
+        // 调用方法
+        XunfeiPptApi.CreateResponse response = xunfeiPptApi.create(query);
+        // 打印结果
+        System.out.println("直接创建 PPT 响应:" + JsonUtils.toJsonString(response));
+
+        // 保存 sid 用于后续进度查询
+        if (response != null && response.data() != null) {
+            System.out.println("sid: " + response.data().sid());
+            if (response.data().coverImgSrc() != null) {
+                System.out.println("封面图片: " + response.data().coverImgSrc());
+            }
+            System.out.println("标题: " + response.data().title());
+            System.out.println("副标题: " + response.data().subTitle());
+        }
+    }
+
+    /**
+     * 直接创建 PPT(通过文件)
+     */
+    @Test
+    @Disabled
+    public void testCreatePptByFile() {
+        // 准备参数
+        File file = new File("src/test/resources/test.txt"); // 请确保此文件存在
+        MultipartFile multipartFile = convertFileToMultipartFile(file);
+
+        // 调用方法
+        XunfeiPptApi.CreateResponse response = xunfeiPptApi.create(multipartFile, file.getName());
+        // 打印结果
+        System.out.println("通过文件创建PPT响应:" + JsonUtils.toJsonString(response));
+
+        // 保存 sid 用于后续进度查询
+        if (response != null && response.data() != null) {
+            System.out.println("sid: " + response.data().sid());
+            if (response.data().coverImgSrc() != null) {
+                System.out.println("封面图片: " + response.data().coverImgSrc());
+            }
+            System.out.println("标题: " + response.data().title());
+            System.out.println("副标题: " + response.data().subTitle());
+        }
+    }
+
+    /**
+     * 直接创建 PPT(完整参数)
+     */
+    @Test
+    @Disabled
+    public void testCreatePptWithFullParams() {
+        // 准备参数
+        String query = "合肥天气趋势分析,包括近 5 年的气温变化、降水量变化、极端天气事件,以及对城市生活的影响";
+
+        // 创建请求对象
+        XunfeiPptApi.CreatePptRequest request = XunfeiPptApi.CreatePptRequest.builder()
+                .query(query)
+                .language("cn")
+                .isCardNote(true)
+                .search(true)
+                .isFigure(true)
+                .aiImage("advanced")
+                .author("测试用户")
+                .build();
+
+        // 调用方法
+        XunfeiPptApi.CreateResponse response = xunfeiPptApi.create(request);
+        // 打印结果
+        System.out.println("使用完整参数创建 PPT 响应:" + JsonUtils.toJsonString(response));
+
+        // 保存 sid 用于后续进度查询
+        if (response != null && response.data() != null) {
+            String sid = response.data().sid();
+            System.out.println("sid: " + sid);
+            if (response.data().coverImgSrc() != null) {
+                System.out.println("封面图片: " + response.data().coverImgSrc());
+            }
+            System.out.println("标题: " + response.data().title());
+            System.out.println("副标题: " + response.data().subTitle());
+
+            // 立即查询一次进度
+            System.out.println("立即查询进度...");
+            XunfeiPptApi.ProgressResponse progressResponse = xunfeiPptApi.checkProgress(sid);
+            if (progressResponse != null && progressResponse.data() != null) {
+                XunfeiPptApi.ProgressResponseData progressData = progressResponse.data();
+                System.out.println("PPT 构建状态: " + progressData.pptStatus());
+                if (progressData.totalPages() != null && progressData.donePages() != null) {
+                    System.out.println("完成进度: " + progressData.donePages() + "/" + progressData.totalPages()
+                            + " (" + progressData.getProgressPercent() + "%)");
+                }
+            }
+        }
+    }
+
+    /**
+     * 将 File 转换为 MultipartFile
+     */
+    private MultipartFile convertFileToMultipartFile(File file) {
+        return new MockMultipartFile("file", file.getName(), "text/plain", FileUtil.readBytes(file));
+    }
+
+}

+ 1 - 0
yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/ErrorCodeConstants.java

@@ -42,6 +42,7 @@ public interface ErrorCodeConstants {
     ErrorCode PROCESS_INSTANCE_CANCEL_FAIL_NOT_ALLOW = new ErrorCode(1_009_004_005, "流程取消失败,该流程不允许取消");
     ErrorCode PROCESS_INSTANCE_HTTP_TRIGGER_CALL_ERROR = new ErrorCode(1_009_004_006, "流程 Http 触发器请求调用失败");
     ErrorCode PROCESS_INSTANCE_APPROVE_USER_SELECT_ASSIGNEES_NOT_CONFIG = new ErrorCode(1_009_004_007, "下一个任务({})的审批人未配置");
+    ErrorCode PROCESS_INSTANCE_CANCEL_CHILD_FAIL_NOT_ALLOW = new ErrorCode(1_009_004_008, "子流程取消失败,子流程不允许取消");
 
     // ========== 流程任务 1-009-005-000 ==========
     ErrorCode TASK_OPERATE_FAIL_ASSIGN_NOT_SELF = new ErrorCode(1_009_005_001, "操作失败,原因:该任务的审批人不是你");

+ 1 - 0
yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmReasonEnum.java

@@ -18,6 +18,7 @@ public enum BpmReasonEnum {
     REJECT_TASK("审批不通过任务,原因:{}"), // 场景:用户审批不通过任务。修改文案时,需要注意 isRejectReason 方法
     CANCEL_PROCESS_INSTANCE_BY_START_USER("用户主动取消流程,原因:{}"), // 场景:用户主动取消流程
     CANCEL_PROCESS_INSTANCE_BY_ADMIN("管理员【{}】取消流程,原因:{}"), // 场景:管理员取消流程
+    CANCEL_CHILD_PROCESS_INSTANCE_BY_MAIN_PROCESS("子流程自动取消,原因:主流程已取消"),
 
     // ========== 流程任务的独有原因 ==========
 

+ 15 - 0
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/base/dept/DeptSimpleBaseVO.java

@@ -0,0 +1,15 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.base.dept;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+@Schema(description = "部门精简信息 VO")
+@Data
+public class DeptSimpleBaseVO {
+
+    @Schema(description = "部门编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
+    private Long id;
+    @Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "技术部")
+    private String name;
+
+}

+ 11 - 2
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmModelController.java

@@ -12,6 +12,8 @@ import cn.iocoder.yudao.module.bpm.service.definition.BpmCategoryService;
 import cn.iocoder.yudao.module.bpm.service.definition.BpmFormService;
 import cn.iocoder.yudao.module.bpm.service.definition.BpmModelService;
 import cn.iocoder.yudao.module.bpm.service.definition.BpmProcessDefinitionService;
+import cn.iocoder.yudao.module.system.api.dept.DeptApi;
+import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
 import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
 import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
 import io.swagger.v3.oas.annotations.Operation;
@@ -53,6 +55,8 @@ public class BpmModelController {
 
     @Resource
     private AdminUserApi adminUserApi;
+    @Resource
+    private DeptApi deptApi;
 
     @GetMapping("/list")
     @Operation(summary = "获得模型分页")
@@ -79,14 +83,19 @@ public class BpmModelController {
         List<ProcessDefinition> processDefinitions = processDefinitionService.getProcessDefinitionListByDeploymentIds(
                 deploymentMap.keySet());
         Map<String, ProcessDefinition> processDefinitionMap = convertMap(processDefinitions, ProcessDefinition::getDeploymentId);
-        // 获得 User Map
+        // 获得 User Map、Dept Map
         Set<Long> userIds = convertSetByFlatMap(list, model -> {
             BpmModelMetaInfoVO metaInfo = BpmModelConvert.INSTANCE.parseMetaInfo(model);
             return metaInfo != null ? metaInfo.getStartUserIds().stream() : Stream.empty();
         });
         Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userIds);
+        Set<Long> deptIds = convertSetByFlatMap(list, model -> {
+            BpmModelMetaInfoVO metaInfo = BpmModelConvert.INSTANCE.parseMetaInfo(model);
+            return metaInfo != null && metaInfo.getStartDeptIds() != null ? metaInfo.getStartDeptIds().stream() : Stream.empty();
+        });
+        Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(deptIds);
         return success(BpmModelConvert.INSTANCE.buildModelList(list,
-                formMap, categoryMap, deploymentMap, processDefinitionMap, userMap));
+                formMap, categoryMap, deploymentMap, processDefinitionMap, userMap, deptMap));
     }
 
     @GetMapping("/get")

+ 9 - 0
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelMetaInfoVO.java

@@ -59,6 +59,9 @@ public class BpmModelMetaInfoVO {
     @Schema(description = "可发起用户编号数组", example = "[1,2,3]")
     private List<Long> startUserIds;
 
+    @Schema(description = "可发起部门编号数组", example = "[2,4,6]")
+    private List<Long> startDeptIds;
+
     @Schema(description = "可管理用户编号数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "[2,4,6]")
     @NotEmpty(message = "可管理用户编号数组不能为空")
     private List<Long> managerUserIds;
@@ -88,6 +91,12 @@ public class BpmModelMetaInfoVO {
     @Schema(description = "流程后置通知设置", example = "{}")
     private HttpRequestSetting processAfterTriggerSetting;
 
+    @Schema(description = "任务前置通知设置", example = "{}")
+    private HttpRequestSetting taskBeforeTriggerSetting;
+
+    @Schema(description = "任务后置通知设置", example = "{}")
+    private HttpRequestSetting taskAfterTriggerSetting;
+
     @Schema(description = "流程 ID 规则")
     @Data
     @Valid

+ 4 - 0
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelRespVO.java

@@ -1,5 +1,6 @@
 package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model;
 
+import cn.iocoder.yudao.module.bpm.controller.admin.base.dept.DeptSimpleBaseVO;
 import cn.iocoder.yudao.module.bpm.controller.admin.base.user.UserSimpleBaseVO;
 import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO;
 import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionRespVO;
@@ -39,6 +40,9 @@ public class BpmModelRespVO extends BpmModelMetaInfoVO {
     @Schema(description = "可发起的用户数组")
     private List<UserSimpleBaseVO> startUsers;
 
+    @Schema(description = "可发起的部门数组")
+    private List<DeptSimpleBaseVO> startDepts;
+
     @Schema(description = "BPMN XML")
     private String bpmnXml;
 

+ 2 - 2
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/simple/BpmSimpleModelNodeVO.java

@@ -112,7 +112,7 @@ public class BpmSimpleModelNodeVO {
     /**
      * 条件节点设置
      */
-    private ConditionSetting conditionSetting; // 仅用于条件节点 BpmSimpleModelNodeType.CONDITION_NODE
+    private ConditionSetting conditionSetting; // 仅用于条件节点 BpmSimpleModelNodeTypeEnum.CONDITION_NODE
 
     @Schema(description = "路由分支组", example = "[]")
     private List<RouterSetting> routerGroups;
@@ -241,7 +241,7 @@ public class BpmSimpleModelNodeVO {
     @Schema(description = "条件设置")
     @Data
     @Valid
-    // 仅用于条件节点 BpmSimpleModelNodeType.CONDITION_NODE
+    // 仅用于条件节点 BpmSimpleModelNodeTypeEnum.CONDITION_NODE
     public static class ConditionSetting {
 
         @Schema(description = "条件类型", example = "1")

+ 0 - 1
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java

@@ -148,7 +148,6 @@ public class BpmProcessInstanceController {
                 processDefinition, processDefinitionInfo, startUser, dept));
     }
 
-    // TODO @lesan:【子流程】子流程如果取消,主流程应该是通过、还是不通过哈?还是禁用掉子流程的取消?
     @DeleteMapping("/cancel-by-start-user")
     @Operation(summary = "用户取消流程实例", description = "取消发起的流程")
     @PreAuthorize("@ss.hasPermission('bpm:process-instance:cancel')")

+ 3 - 0
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmApprovalDetailRespVO.java

@@ -72,6 +72,9 @@ public class BpmApprovalDetailRespVO {
         @Schema(description = "候选人用户列表")
         private List<UserSimpleBaseVO> candidateUsers; // 只包含未生成 ApprovalTaskInfo 的用户列表
 
+        @Schema(description = "流程编号", example = "8761d8e0-0922-11f0-bd37-00ff1db677bf")
+        private String processInstanceId; // 当且仅当,该节点是子流程节点时,才会有值(CallActivity 的 processInstanceId 字段)
+
     }
 
     @Schema(description = "活动节点的任务信息")

+ 11 - 6
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmModelConvert.java

@@ -4,6 +4,7 @@ import cn.hutool.core.util.ArrayUtil;
 import cn.iocoder.yudao.framework.common.util.date.DateUtils;
 import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import cn.iocoder.yudao.module.bpm.controller.admin.base.dept.DeptSimpleBaseVO;
 import cn.iocoder.yudao.module.bpm.controller.admin.base.user.UserSimpleBaseVO;
 import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelMetaInfoVO;
 import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelRespVO;
@@ -13,6 +14,7 @@ import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmPro
 import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO;
 import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO;
 import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils;
+import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
 import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
 import org.flowable.common.engine.impl.db.SuspensionState;
 import org.flowable.engine.repository.Deployment;
@@ -43,7 +45,8 @@ public interface BpmModelConvert {
                                                 Map<String, BpmCategoryDO> categoryMap,
                                                 Map<String, Deployment> deploymentMap,
                                                 Map<String, ProcessDefinition> processDefinitionMap,
-                                                Map<Long, AdminUserRespDTO> userMap) {
+                                                Map<Long, AdminUserRespDTO> userMap,
+                                                Map<Long, DeptRespDTO> deptMap) {
         List<BpmModelRespVO> result = convertList(list, model -> {
             BpmModelMetaInfoVO metaInfo = parseMetaInfo(model);
             BpmFormDO form = metaInfo != null ? formMap.get(metaInfo.getFormId()) : null;
@@ -52,7 +55,8 @@ public interface BpmModelConvert {
             ProcessDefinition processDefinition = model.getDeploymentId() != null ?
                     processDefinitionMap.get(model.getDeploymentId()) : null;
             List<AdminUserRespDTO> startUsers = metaInfo != null ? convertList(metaInfo.getStartUserIds(), userMap::get) : null;
-            return buildModel0(model, metaInfo, form, category, deployment, processDefinition, startUsers);
+            List<DeptRespDTO> startDepts = metaInfo != null ? convertList(metaInfo.getStartDeptIds(), deptMap::get) : null;
+            return buildModel0(model, metaInfo, form, category, deployment, processDefinition, startUsers, startDepts);
         });
         // 排序
         result.sort(Comparator.comparing(BpmModelMetaInfoVO::getSort));
@@ -61,7 +65,7 @@ public interface BpmModelConvert {
 
     default BpmModelRespVO buildModel(Model model, byte[] bpmnBytes, BpmSimpleModelNodeVO simpleModel) {
         BpmModelMetaInfoVO metaInfo = parseMetaInfo(model);
-        BpmModelRespVO modelVO = buildModel0(model, metaInfo, null, null, null, null, null);
+        BpmModelRespVO modelVO = buildModel0(model, metaInfo, null, null, null, null, null, null);
         if (ArrayUtil.isNotEmpty(bpmnBytes)) {
             modelVO.setBpmnXml(BpmnModelUtils.getBpmnXml(bpmnBytes));
         }
@@ -72,7 +76,7 @@ public interface BpmModelConvert {
     default BpmModelRespVO buildModel0(Model model,
                                        BpmModelMetaInfoVO metaInfo, BpmFormDO form, BpmCategoryDO category,
                                        Deployment deployment, ProcessDefinition processDefinition,
-                                       List<AdminUserRespDTO> startUsers) {
+                                       List<AdminUserRespDTO> startUsers, List<DeptRespDTO> startDepts) {
         BpmModelRespVO modelRespVO = new BpmModelRespVO().setId(model.getId()).setName(model.getName())
                 .setKey(model.getKey()).setCategory(model.getCategory())
                 .setCreateTime(DateUtils.of(model.getCreateTime()));
@@ -94,8 +98,9 @@ public interface BpmModelConvert {
                 modelRespVO.getProcessDefinition().setDeploymentTime(DateUtils.of(deployment.getDeploymentTime()));
             }
         }
-        // User
-        modelRespVO.setStartUsers(BeanUtils.toBean(startUsers, UserSimpleBaseVO.class));
+        // User、Dept
+        modelRespVO.setStartUsers(BeanUtils.toBean(startUsers, UserSimpleBaseVO.class))
+                .setStartDepts(BeanUtils.toBean(startDepts, DeptSimpleBaseVO.class));
         return modelRespVO;
     }
 

+ 20 - 0
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmProcessDefinitionInfoDO.java

@@ -151,6 +151,14 @@ public class BpmProcessDefinitionInfoDO extends BaseDO {
     @TableField(typeHandler = LongListTypeHandler.class) // 为了可以使用 find_in_set 进行过滤
     private List<Long> startUserIds;
 
+    /**
+     * 可发起部门编号数组
+     *
+     * 关联 {@link AdminUserRespDTO#getDeptId()} 字段的数组
+     */
+    @TableField(typeHandler = LongListTypeHandler.class)
+    private List<Long> startDeptIds;
+
     /**
      * 可管理用户编号数组
      *
@@ -199,4 +207,16 @@ public class BpmProcessDefinitionInfoDO extends BaseDO {
     @TableField(typeHandler = JacksonTypeHandler.class)
     private BpmModelMetaInfoVO.HttpRequestSetting processAfterTriggerSetting;
 
+    /**
+     * 任务前置通知设置
+     */
+    @TableField(typeHandler = JacksonTypeHandler.class)
+    private BpmModelMetaInfoVO.HttpRequestSetting taskBeforeTriggerSetting;
+
+    /**
+     * 任务后置通知设置
+     */
+    @TableField(typeHandler = JacksonTypeHandler.class)
+    private BpmModelMetaInfoVO.HttpRequestSetting taskAfterTriggerSetting;
+
 }

+ 6 - 1
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmTaskEventListener.java

@@ -47,7 +47,7 @@ public class BpmTaskEventListener extends AbstractFlowableEngineEventListener {
     public static final Set<FlowableEngineEventType> TASK_EVENTS = ImmutableSet.<FlowableEngineEventType>builder()
             .add(FlowableEngineEventType.TASK_CREATED)
             .add(FlowableEngineEventType.TASK_ASSIGNED)
-//            .add(FlowableEngineEventType.TASK_COMPLETED) // 由于审批通过时,已经记录了 task 的 status 为通过,所以不需要监听了
+            .add(FlowableEngineEventType.TASK_COMPLETED) // 由于审批通过时,已经记录了 task 的 status 为通过,这里仅处理任务后置通知
             .add(FlowableEngineEventType.ACTIVITY_CANCELLED)
             .add(FlowableEngineEventType.TIMER_FIRED) // 监听审批超时
             .build();
@@ -66,6 +66,11 @@ public class BpmTaskEventListener extends AbstractFlowableEngineEventListener {
         taskService.processTaskAssigned((Task) event.getEntity());
     }
 
+    @Override
+    protected void taskCompleted(FlowableEngineEntityEvent event) {
+        taskService.processTaskCompleted((Task) event.getEntity());
+    }
+
     @Override
     protected void activityCancelled(FlowableActivityCancelledEvent event) {
         List<HistoricActivityInstance> activityList = taskService.getHistoricActivityListByExecutionId(event.getExecutionId());

+ 9 - 6
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/SimpleModelUtils.java

@@ -187,7 +187,7 @@ public class SimpleModelUtils {
     /**
      * 构建有附加节点的连线
      *
-     * @param nodeId 当前节点 ID
+     * @param nodeId       当前节点 ID
      * @param attachNodeId 附属节点 ID
      * @param targetNodeId 目标节点 ID
      */
@@ -662,6 +662,10 @@ public class SimpleModelUtils {
      * 构造条件表达式
      */
     public static String buildConditionExpression(BpmSimpleModelNodeVO.ConditionSetting conditionSetting) {
+        // 并行网关不需要设置条件
+        if (conditionSetting == null) {
+            return null;
+        }
         return buildConditionExpression(conditionSetting.getConditionType(), conditionSetting.getConditionExpression(),
                 conditionSetting.getConditionGroups());
     }
@@ -813,7 +817,6 @@ public class SimpleModelUtils {
             callActivity.setCalledElementType("key");
             // 1. 是否异步
             if (node.getChildProcessSetting().getAsync()) {
-                // TODO @lesan: 这里目前测试没有跳过执行call activity 后面的节点
                 callActivity.setAsynchronous(true);
             }
 
@@ -959,8 +962,8 @@ public class SimpleModelUtils {
         if (nodeType == BpmSimpleModelNodeTypeEnum.CONDITION_BRANCH_NODE) {
             // 查找满足条件的 BpmSimpleModelNodeVO 节点
             BpmSimpleModelNodeVO matchConditionNode = CollUtil.findOne(currentNode.getConditionNodes(),
-                        conditionNode -> !BooleanUtil.isTrue(conditionNode.getConditionSetting().getDefaultFlow())
-                                && evalConditionExpress(variables, conditionNode.getConditionSetting()));
+                    conditionNode -> !BooleanUtil.isTrue(conditionNode.getConditionSetting().getDefaultFlow())
+                            && evalConditionExpress(variables, conditionNode.getConditionSetting()));
             if (matchConditionNode == null) {
                 matchConditionNode = CollUtil.findOne(currentNode.getConditionNodes(),
                         conditionNode -> BooleanUtil.isTrue(conditionNode.getConditionSetting().getDefaultFlow()));
@@ -974,8 +977,8 @@ public class SimpleModelUtils {
         if (nodeType == BpmSimpleModelNodeTypeEnum.INCLUSIVE_BRANCH_NODE) {
             // 查找满足条件的 BpmSimpleModelNodeVO 节点
             Collection<BpmSimpleModelNodeVO> matchConditionNodes = CollUtil.filterNew(currentNode.getConditionNodes(),
-                        conditionNode -> !BooleanUtil.isTrue(conditionNode.getConditionSetting().getDefaultFlow())
-                                && evalConditionExpress(variables, conditionNode.getConditionSetting()));
+                    conditionNode -> !BooleanUtil.isTrue(conditionNode.getConditionSetting().getDefaultFlow())
+                            && evalConditionExpress(variables, conditionNode.getConditionSetting()));
             if (CollUtil.isEmpty(matchConditionNodes)) {
                 matchConditionNodes = CollUtil.filterNew(currentNode.getConditionNodes(),
                         conditionNode -> BooleanUtil.isTrue(conditionNode.getConditionSetting().getDefaultFlow()));

+ 20 - 5
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionServiceImpl.java

@@ -12,6 +12,8 @@ import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitio
 import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmProcessDefinitionInfoMapper;
 import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants;
 import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils;
+import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
+import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
 import lombok.extern.slf4j.Slf4j;
 import org.flowable.bpmn.model.BpmnModel;
 import org.flowable.common.engine.impl.db.SuspensionState;
@@ -50,6 +52,9 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ
     @Resource
     private BpmProcessDefinitionInfoMapper processDefinitionMapper;
 
+    @Resource
+    private AdminUserApi adminUserApi;
+
     @Override
     public ProcessDefinition getProcessDefinition(String id) {
         return repositoryService.getProcessDefinition(id);
@@ -88,12 +93,22 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ
         if (processDefinition == null) {
             return false;
         }
-        // 为空,则所有人都可以发起
-        if (CollUtil.isEmpty(processDefinition.getStartUserIds())) {
-            return true;
+
+        // 校验用户是否在允许发起的用户列表中
+        if (CollUtil.isNotEmpty(processDefinition.getStartUserIds())) {
+            return processDefinition.getStartUserIds().contains(userId);
+        }
+
+        // 校验用户是否在允许发起的部门列表中
+        if (CollUtil.isNotEmpty(processDefinition.getStartDeptIds())) {
+            AdminUserRespDTO user = adminUserApi.getUser(userId);
+            return user != null
+                    && user.getDeptId() != null
+                    && processDefinition.getStartDeptIds().contains(user.getDeptId());
         }
-        // 不为空,则需要存在里面
-        return processDefinition.getStartUserIds().contains(userId);
+
+        // 都为空,则所有人都可以发起
+        return true;
     }
 
     @Override

+ 53 - 36
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java

@@ -14,7 +14,6 @@ import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
 import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
 import cn.iocoder.yudao.framework.common.util.object.PageUtils;
 import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
-import cn.iocoder.yudao.module.bpm.controller.admin.base.user.UserSimpleBaseVO;
 import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelMetaInfoVO;
 import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO;
 import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.*;
@@ -262,30 +261,31 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
             processVariables.putAll(reqVO.getProcessVariables());
         }
 
-        // 3 获取当前任务节点的信息
-        // 3.1 获取下一个将要执行的节点集合
+        // 3. 获取下一个将要执行的节点集合
         FlowElement flowElement = bpmnModel.getFlowElement(task.getTaskDefinitionKey());
         List<FlowNode> nextFlowNodes = BpmnModelUtils.getNextFlowNodes(flowElement, bpmnModel, processVariables);
-        return convertList(nextFlowNodes, node -> {
-            List<Long> candidateUserIds = getTaskCandidateUserList(bpmnModel, node.getId(),
-                    loginUserId, historicProcessInstance.getProcessDefinitionId(), processVariables);
-            // 3.2 获取节点的审批人信息
-            Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(candidateUserIds);
-            // 3.3 获取节点的审批人部门信息
-            Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId));
-            // 3.4 存在一个节点多人审批的情况,组装审批人信息
-            List<UserSimpleBaseVO> candidateUsers = new ArrayList<>();
-            userMap.forEach((key, value) -> candidateUsers.add(BpmProcessInstanceConvert.INSTANCE.buildUser(key, userMap, deptMap)));
-            return new ActivityNode().setNodeType(BpmSimpleModelNodeTypeEnum.APPROVE_NODE.getType())
-                    .setId(node.getId())
-                    .setName(node.getName())
-                    .setStatus(BpmTaskStatusEnum.RUNNING.getStatus())
-                    .setCandidateStrategy(BpmnModelUtils.parseCandidateStrategy(node))
-                    // TODO @小北:先把 candidateUserIds 设置完,然后最后拼接 candidateUsers 信息。这样,如果有多个节点,就不用重复查询啦;类似 buildApprovalDetail 思路;
-                    // TODO 先拼接处 List ActivityNode
-                    // TODO 接着,再起一段,处理 adminUserApi.getUserMap(candidateUserIds)、deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId))
-                    .setCandidateUsers(candidateUsers);
-        });
+        List<ActivityNode> nextActivityNodes = convertList(nextFlowNodes, node -> new ActivityNode().setId(node.getId())
+                .setName(node.getName()).setNodeType(BpmSimpleModelNodeTypeEnum.APPROVE_NODE.getType())
+                .setStatus(BpmTaskStatusEnum.RUNNING.getStatus())
+                .setCandidateStrategy(BpmnModelUtils.parseCandidateStrategy(node))
+                .setCandidateUserIds(getTaskCandidateUserList(bpmnModel, node.getId(),
+                        loginUserId, historicProcessInstance.getProcessDefinitionId(), processVariables)));
+        if (CollUtil.isNotEmpty(nextActivityNodes)) {
+            return nextActivityNodes;
+        }
+
+        // 4. 拼接基础信息
+        Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(
+                convertSetByFlatMap(nextActivityNodes, ActivityNode::getCandidateUserIds, Collection::stream));
+        Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId));
+        nextActivityNodes.forEach(node -> node.setCandidateUsers(convertList(node.getCandidateUserIds(), userId -> {
+            AdminUserRespDTO user = userMap.get(userId);
+            if (user != null) {
+                return BpmProcessInstanceConvert.INSTANCE.buildUser(userId, userMap, deptMap);
+            }
+            return null;
+        })));
+        return nextActivityNodes;
     }
 
     @Override
@@ -387,8 +387,6 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
                                                       List<HistoricActivityInstance> activities, List<HistoricTaskInstance> tasks) {
         // 遍历 tasks 列表,只处理已结束的 UserTask
         // 为什么不通过 activities 呢?因为,加签场景下,它只存在于 tasks,没有 activities,导致如果遍历 activities 的话,它无法成为一个节点
-        // TODO @芋艿:子流程只有activity,这里获取不到已结束的子流程;
-        // TODO @lesan:【子流程】基于 activities 查询出 usertask、callactivity,然后拼接?如果是子流程,就是可以点击过去?
         List<HistoricTaskInstance> endTasks = filterList(tasks, task -> task.getEndTime() != null);
         List<ActivityNode> approvalNodes = convertList(endTasks, task -> {
             FlowElement flowNode = BpmnModelUtils.getFlowElementById(bpmnModel, task.getTaskDefinitionKey());
@@ -410,7 +408,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
 
         // 遍历 activities,只处理已结束的 StartEvent、EndEvent
         List<HistoricActivityInstance> endActivities = filterList(activities, activity -> activity.getEndTime() != null
-                && (StrUtil.equalsAny(activity.getActivityType(), ELEMENT_EVENT_START, ELEMENT_EVENT_END)));
+                && (StrUtil.equalsAny(activity.getActivityType(), ELEMENT_EVENT_START, ELEMENT_CALL_ACTIVITY, ELEMENT_EVENT_END)));
         endActivities.forEach(activity -> {
             // StartEvent:只处理 BPMN 的场景。因为,SIMPLE 情况下,已经有 START_USER_NODE 节点
             if (ELEMENT_EVENT_START.equals(activity.getActivityType())
@@ -444,7 +442,20 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
                 }
                 approvalNodes.add(endNode);
             }
+            // CallActivity
+            if (ELEMENT_CALL_ACTIVITY.equals(activity.getActivityType())) {
+                ActivityNode callActivity = new ActivityNode().setId(activity.getId())
+                        .setName(BpmSimpleModelNodeTypeEnum.CHILD_PROCESS.getName())
+                        .setNodeType(BpmSimpleModelNodeTypeEnum.CHILD_PROCESS.getType()).setStatus(processInstanceStatus)
+                        .setStartTime(DateUtils.of(activity.getStartTime()))
+                        .setEndTime(DateUtils.of(activity.getEndTime()))
+                        .setProcessInstanceId(activity.getProcessInstanceId());
+                approvalNodes.add(callActivity);
+            }
         });
+
+        // 按照时间排序
+        approvalNodes.sort(Comparator.comparing(ActivityNode::getStartTime));
         return approvalNodes;
     }
 
@@ -464,7 +475,6 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
                 HistoricActivityInstance::getActivityId);
 
         // 按照 activityId 分组,构建 ApprovalNodeInfo 节点
-        // TODO @lesan:【子流程】在子流程进行审批的时候,HistoricActivityInstance 里面可以拿到 runActivities.get(0).getCalledProcessInstanceId()。要不要支持跳转???
         Map<String, HistoricTaskInstance> taskMap = convertMap(tasks, HistoricTaskInstance::getId);
         return convertList(runningTaskMap.entrySet(), entry -> {
             String activityId = entry.getKey();
@@ -510,6 +520,9 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
                                 approvalTaskInfo.getAssignee())); // 委派或者向前加签情况,需要先比较 owner
                 activityNode.setCandidateUserIds(CollUtil.sub(candidateUserIds, index + 1, candidateUserIds.size()));
             }
+            if (BpmSimpleModelNodeTypeEnum.CHILD_PROCESS.getType().equals(activityNode.getNodeType())) {
+                activityNode.setProcessInstanceId(firstActivity.getProcessInstanceId());
+            }
             return activityNode;
         });
     }
@@ -823,6 +836,10 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
                 && Boolean.FALSE.equals(processDefinitionInfo.getAllowCancelRunningProcess())) {
             throw exception(PROCESS_INSTANCE_CANCEL_FAIL_NOT_ALLOW);
         }
+        // 1.4 子流程不允许取消
+        if (StrUtil.isNotBlank(instance.getSuperExecutionId())) {
+            throw exception(PROCESS_INSTANCE_CANCEL_CHILD_FAIL_NOT_ALLOW);
+        }
 
         // 2. 取消流程
         updateProcessInstanceCancel(cancelReqVO.getId(),
@@ -849,7 +866,13 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
                 BpmProcessInstanceStatusEnum.CANCEL.getStatus());
         runtimeService.setVariable(id, BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_REASON, reason);
 
-        // 2. 结束流程
+        // 2. 取消所有子流程
+        List<ProcessInstance> childProcessInstances = runtimeService.createProcessInstanceQuery()
+                .superProcessInstanceId(id).list();
+        childProcessInstances.forEach(processInstance -> updateProcessInstanceCancel(
+                processInstance.getProcessInstanceId(), BpmReasonEnum.CANCEL_CHILD_PROCESS_INSTANCE_BY_MAIN_PROCESS.getReason()));
+
+        // 3. 结束流程
         taskService.moveTaskToEnd(id, reason);
     }
 
@@ -914,10 +937,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
                     BpmModelMetaInfoVO.HttpRequestSetting setting = processDefinitionInfo.getProcessAfterTriggerSetting();
 
                     BpmHttpRequestUtils.executeBpmHttpRequest(instance,
-                            setting.getUrl(),
-                            setting.getHeader(),
-                            setting.getBody(),
-                            true, setting.getResponse());
+                            setting.getUrl(), setting.getHeader(), setting.getBody(), true, setting.getResponse());
                 }
             }
         });
@@ -936,10 +956,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
             }
             BpmModelMetaInfoVO.HttpRequestSetting setting = processDefinitionInfo.getProcessBeforeTriggerSetting();
             BpmHttpRequestUtils.executeBpmHttpRequest(instance,
-                    setting.getUrl(),
-                    setting.getHeader(),
-                    setting.getBody(),
-                    true, setting.getResponse());
+                    setting.getUrl(), setting.getHeader(), setting.getBody(), true, setting.getResponse());
         });
     }
 

+ 7 - 0
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskService.java

@@ -278,6 +278,13 @@ public interface BpmTaskService {
      */
     void processTaskAssigned(Task task);
 
+    /**
+     * 处理 Task 完成事件,目前是发送任务后置通知
+     *
+     * @param task 任务实体
+     */
+    void processTaskCompleted(Task task);
+
     /**
      * 处理 Task 审批超时事件,可能会处理多个当前审批中的任务
      *

+ 63 - 17
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java

@@ -6,12 +6,14 @@ import cn.hutool.core.lang.Assert;
 import cn.hutool.core.util.*;
 import cn.hutool.extra.spring.SpringUtil;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
 import cn.iocoder.yudao.framework.common.util.date.DateUtils;
 import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
 import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
 import cn.iocoder.yudao.framework.common.util.object.PageUtils;
 import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
 import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelMetaInfoVO;
 import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*;
 import cn.iocoder.yudao.module.bpm.convert.task.BpmTaskConvert;
 import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO;
@@ -23,6 +25,7 @@ import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskSignTypeEnum;
 import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskStatusEnum;
 import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum;
 import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnVariableConstants;
+import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmHttpRequestUtils;
 import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils;
 import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils;
 import cn.iocoder.yudao.module.bpm.service.definition.BpmFormService;
@@ -597,47 +600,54 @@ public class BpmTaskServiceImpl implements BpmTaskService {
      */
     private Map<String, Object> validateAndSetNextAssignees(String taskDefinitionKey, Map<String, Object> variables, BpmnModel bpmnModel,
                                                             Map<String, List<Long>> nextAssignees, ProcessInstance processInstance) {
+        // simple 设计器第一个节点默认为发起人节点,不校验是否存在审批人
+        if (Objects.equals(taskDefinitionKey, START_USER_NODE_ID)) {
+            return variables;
+        }
         // 1. 获取下一个将要执行的节点集合
         FlowElement flowElement = bpmnModel.getFlowElement(taskDefinitionKey);
         List<FlowNode> nextFlowNodes = getNextFlowNodes(flowElement, bpmnModel, variables);
 
         // 2. 校验选择的下一个节点的审批人,是否合法
-        Map<String, List<Long>> processVariables;
         for (FlowNode nextFlowNode : nextFlowNodes) {
             Integer candidateStrategy = parseCandidateStrategy(nextFlowNode);
             // 2.1 情况一:如果节点中的审批人策略为 发起人自选
             if (ObjUtil.equals(candidateStrategy, BpmTaskCandidateStrategyEnum.START_USER_SELECT.getStrategy())) {
+                // 特殊:如果当前节点已经存在审批人,则不允许覆盖
+                Map<String, List<Long>> startUserSelectAssignees = FlowableUtils.getStartUserSelectAssignees(processInstance.getProcessVariables());
+                if (startUserSelectAssignees != null && CollUtil.isNotEmpty(startUserSelectAssignees.get(nextFlowNode.getId()))) {
+                    continue;
+                }
                 // 如果节点存在,但未配置审批人
                 List<Long> assignees = nextAssignees != null ? nextAssignees.get(nextFlowNode.getId()) : null;
                 if (CollUtil.isEmpty(assignees)) {
                     throw exception(PROCESS_INSTANCE_START_USER_SELECT_ASSIGNEES_NOT_CONFIG, nextFlowNode.getName());
                 }
-                processVariables = FlowableUtils.getStartUserSelectAssignees(processInstance.getProcessVariables());
-                // 特殊:如果当前节点已经存在审批人,则不允许覆盖
-                if (processVariables != null && CollUtil.isNotEmpty(processVariables.get(nextFlowNode.getId()))) {
-                    continue;
-                }
+
                 // 设置 PROCESS_INSTANCE_VARIABLE_START_USER_SELECT_ASSIGNEES
-                if (processVariables == null) {
-                    processVariables = new HashMap<>();
+                if (startUserSelectAssignees == null) {
+                    startUserSelectAssignees = new HashMap<>();
                 }
-                processVariables.put(nextFlowNode.getId(), assignees);
-                variables.put(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_START_USER_SELECT_ASSIGNEES, processVariables);
+                startUserSelectAssignees.put(nextFlowNode.getId(), assignees);
+                variables.put(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_START_USER_SELECT_ASSIGNEES, startUserSelectAssignees);
+                continue;
             }
+
             // 2.2 情况二:如果节点中的审批人策略为 审批人,在审批时选择下一个节点的审批人,并且该节点的审批人为空
             if (ObjUtil.equals(candidateStrategy, BpmTaskCandidateStrategyEnum.APPROVE_USER_SELECT.getStrategy())) {
                 // 如果节点存在,但未配置审批人
+                Map<String, List<Long>> approveUserSelectAssignees = FlowableUtils.getApproveUserSelectAssignees(processInstance.getProcessVariables());
                 List<Long> assignees = nextAssignees != null ? nextAssignees.get(nextFlowNode.getId()) : null;
                 if (CollUtil.isEmpty(assignees)) {
                     throw exception(PROCESS_INSTANCE_APPROVE_USER_SELECT_ASSIGNEES_NOT_CONFIG, nextFlowNode.getName());
                 }
-                processVariables = FlowableUtils.getApproveUserSelectAssignees(processInstance.getProcessVariables());
-                if (processVariables == null) {
-                    processVariables = new HashMap<>();
-                }
+
                 // 设置 PROCESS_INSTANCE_VARIABLE_APPROVE_USER_SELECT_ASSIGNEES
-                processVariables.put(nextFlowNode.getId(), assignees);
-                variables.put(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_APPROVE_USER_SELECT_ASSIGNEES, processVariables);
+                if (approveUserSelectAssignees == null) {
+                    approveUserSelectAssignees = new HashMap<>();
+                }
+                approveUserSelectAssignees.put(nextFlowNode.getId(), assignees);
+                variables.put(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_APPROVE_USER_SELECT_ASSIGNEES, approveUserSelectAssignees);
             }
         }
         return variables;
@@ -1174,12 +1184,26 @@ public class BpmTaskServiceImpl implements BpmTaskService {
         }
         updateTaskStatus(task.getId(), BpmTaskStatusEnum.RUNNING.getStatus());
 
-        // 2. 处理自动通过的情况,例如说:1)无审批人时,是否自动通过、不通过;2)非【人工审核】时,是否自动通过、不通过
         ProcessInstance processInstance = processInstanceService.getProcessInstance(task.getProcessInstanceId());
         if (processInstance == null) {
             log.error("[processTaskCreated][taskId({}) 没有找到流程实例]", task.getId());
             return;
         }
+        BpmProcessDefinitionInfoDO processDefinitionInfo = bpmProcessDefinitionService.
+                getProcessDefinitionInfo(processInstance.getProcessDefinitionId());
+        if (processDefinitionInfo == null) {
+            log.error("[processTaskCreated][processDefinitionId({}) 没有找到流程定义]", processInstance.getProcessDefinitionId());
+            return;
+        }
+
+        // 2. 任务前置通知
+        if (ObjUtil.isNotNull(processDefinitionInfo.getTaskBeforeTriggerSetting())){
+            BpmModelMetaInfoVO.HttpRequestSetting setting = processDefinitionInfo.getTaskBeforeTriggerSetting();
+            BpmHttpRequestUtils.executeBpmHttpRequest(processInstance,
+                    setting.getUrl(), setting.getHeader(), setting.getBody(), true, setting.getResponse());
+        }
+
+        // 3. 处理自动通过的情况,例如说:1)无审批人时,是否自动通过、不通过;2)非【人工审核】时,是否自动通过、不通过
         BpmnModel bpmnModel = modelService.getBpmnModelByDefinitionId(processInstance.getProcessDefinitionId());
         FlowElement userTaskElement = BpmnModelUtils.getFlowElementById(bpmnModel, task.getTaskDefinitionKey());
         Integer approveType = BpmnModelUtils.parseApproveType(userTaskElement);
@@ -1391,6 +1415,28 @@ public class BpmTaskServiceImpl implements BpmTaskService {
         });
     }
 
+    @Override
+    public void processTaskCompleted(Task task) {
+        ProcessInstance processInstance = processInstanceService.getProcessInstance(task.getProcessInstanceId());
+        if (processInstance == null) {
+            log.error("[processTaskCompleted][taskId({}) 没有找到流程实例]", task.getId());
+            return;
+        }
+        BpmProcessDefinitionInfoDO processDefinitionInfo = bpmProcessDefinitionService.
+                getProcessDefinitionInfo(processInstance.getProcessDefinitionId());
+        if (processDefinitionInfo == null) {
+            log.error("[processTaskCompleted][processDefinitionId({}) 没有找到流程定义]", processInstance.getProcessDefinitionId());
+            return;
+        }
+
+        // 任务后置通知
+        if (ObjUtil.isNotNull(processDefinitionInfo.getTaskAfterTriggerSetting())){
+            BpmModelMetaInfoVO.HttpRequestSetting setting = processDefinitionInfo.getTaskAfterTriggerSetting();
+            BpmHttpRequestUtils.executeBpmHttpRequest(processInstance,
+                    setting.getUrl(), setting.getHeader(), setting.getBody(), true, setting.getResponse());
+        }
+    }
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void processTaskTimeout(String processInstanceId, String taskDefineKey, Integer handlerType) {

+ 1 - 4
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/listener/BpmUserTaskListener.java

@@ -54,10 +54,7 @@ public class BpmUserTaskListener implements TaskListener {
         listenerHandler.getBody().add(new BpmSimpleModelNodeVO.HttpRequestParam().setKey("taskId")
                 .setType(BpmHttpRequestParamTypeEnum.FIXED_VALUE.getType()).setValue(delegateTask.getId()));
         BpmHttpRequestUtils.executeBpmHttpRequest(processInstance,
-                listenerHandler.getPath(),
-                listenerHandler.getHeader(),
-                listenerHandler.getBody(),
-                false, null);
+                listenerHandler.getPath(), listenerHandler.getHeader(), listenerHandler.getBody(), false, null);
 
         // 3. 是否需要后续操作?TODO 芋艿:待定!
     }

+ 1 - 4
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/trigger/http/BpmHttpCallbackTrigger.java

@@ -46,10 +46,7 @@ public class BpmHttpCallbackTrigger extends BpmAbstractHttpRequestTrigger {
                 .setKey("taskDefineKey") // 重要:回调请求 taskDefineKey 需要传给被调用方,用于回调执行
                 .setType(BpmHttpRequestParamTypeEnum.FIXED_VALUE.getType()).setValue(setting.getCallbackTaskDefineKey()));
         BpmHttpRequestUtils.executeBpmHttpRequest(processInstance,
-                setting.getUrl(),
-                setting.getHeader(),
-                setting.getBody(),
-                false, null);
+                setting.getUrl(), setting.getHeader(), setting.getBody(), false, null);
     }
 
 }

+ 1 - 4
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/trigger/http/BpmSyncHttpRequestTrigger.java

@@ -41,10 +41,7 @@ public class BpmSyncHttpRequestTrigger extends BpmAbstractHttpRequestTrigger {
         // 2. 发起请求
         ProcessInstance processInstance = processInstanceService.getProcessInstance(processInstanceId);
         BpmHttpRequestUtils.executeBpmHttpRequest(processInstance,
-                setting.getUrl(),
-                setting.getHeader(),
-                setting.getBody(),
-                true, setting.getResponse());
+                setting.getUrl(), setting.getHeader(), setting.getBody(), true, setting.getResponse());
     }
 
 }

+ 1 - 1
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java

@@ -223,7 +223,7 @@ public class CrmContactServiceImpl implements CrmContactService {
     }
 
     @Override
-    @LogRecord(type = CRM_CONTACT_TYPE, subType = CRM_CONTACT_FOLLOW_UP_SUB_TYPE, bizNo = "{{#id}",
+    @LogRecord(type = CRM_CONTACT_TYPE, subType = CRM_CONTACT_FOLLOW_UP_SUB_TYPE, bizNo = "{{#id}}",
             success = CRM_CONTACT_FOLLOW_UP_SUCCESS)
     @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#id", level = CrmPermissionLevelEnum.WRITE)
     public void updateContactFollowUp(Long id, LocalDateTime contactNextTime, String contactLastContent) {

+ 2 - 7
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/framework/job/core/IotSchedulerManager.java

@@ -1,6 +1,5 @@
 package cn.iocoder.yudao.module.iot.framework.job.core;
 
-import cn.iocoder.yudao.framework.quartz.core.enums.JobDataKeyEnum;
 import lombok.extern.slf4j.Slf4j;
 import org.quartz.*;
 import org.springframework.context.ApplicationContext;
@@ -173,12 +172,8 @@ public class IotSchedulerManager {
      * @param jobName 任务名
      * @throws SchedulerException 触发异常
      */
-    public void triggerJob(String jobName)
-            throws SchedulerException {
-        // 触发任务
-        JobDataMap data = new JobDataMap();
-        data.put(JobDataKeyEnum.JOB_HANDLER_NAME.name(), jobName);
-        scheduler.triggerJob(new JobKey(jobName), data);
+    public void triggerJob(String jobName) throws SchedulerException {
+        scheduler.triggerJob(new JobKey(jobName));
     }
 
     private Trigger buildTrigger(String jobName, String cronExpression) {

+ 11 - 11
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/product/IotProductCategoryServiceImpl.java

@@ -29,7 +29,7 @@ import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.PRODUCT_CATEG
 public class IotProductCategoryServiceImpl implements IotProductCategoryService {
 
     @Resource
-    private IotProductCategoryMapper productCategoryMapper;
+    private IotProductCategoryMapper iotProductCategoryMapper;
 
     @Resource
     private IotProductService productService;
@@ -40,7 +40,7 @@ public class IotProductCategoryServiceImpl implements IotProductCategoryService
     public Long createProductCategory(IotProductCategorySaveReqVO createReqVO) {
         // 插入
         IotProductCategoryDO productCategory = BeanUtils.toBean(createReqVO, IotProductCategoryDO.class);
-        productCategoryMapper.insert(productCategory);
+        iotProductCategoryMapper.insert(productCategory);
         // 返回
         return productCategory.getId();
     }
@@ -51,7 +51,7 @@ public class IotProductCategoryServiceImpl implements IotProductCategoryService
         validateProductCategoryExists(updateReqVO.getId());
         // 更新
         IotProductCategoryDO updateObj = BeanUtils.toBean(updateReqVO, IotProductCategoryDO.class);
-        productCategoryMapper.updateById(updateObj);
+        iotProductCategoryMapper.updateById(updateObj);
     }
 
     @Override
@@ -59,18 +59,18 @@ public class IotProductCategoryServiceImpl implements IotProductCategoryService
         // 校验存在
         validateProductCategoryExists(id);
         // 删除
-        productCategoryMapper.deleteById(id);
+        iotProductCategoryMapper.deleteById(id);
     }
 
     private void validateProductCategoryExists(Long id) {
-        if (productCategoryMapper.selectById(id) == null) {
+        if (iotProductCategoryMapper.selectById(id) == null) {
             throw exception(PRODUCT_CATEGORY_NOT_EXISTS);
         }
     }
 
     @Override
     public IotProductCategoryDO getProductCategory(Long id) {
-        return productCategoryMapper.selectById(id);
+        return iotProductCategoryMapper.selectById(id);
     }
 
     @Override
@@ -78,28 +78,28 @@ public class IotProductCategoryServiceImpl implements IotProductCategoryService
         if (CollUtil.isEmpty(ids)) {
             return CollUtil.newArrayList();
         }
-        return productCategoryMapper.selectBatchIds(ids);
+        return iotProductCategoryMapper.selectBatchIds(ids);
     }
 
     @Override
     public PageResult<IotProductCategoryDO> getProductCategoryPage(IotProductCategoryPageReqVO pageReqVO) {
-        return productCategoryMapper.selectPage(pageReqVO);
+        return iotProductCategoryMapper.selectPage(pageReqVO);
     }
 
     @Override
     public List<IotProductCategoryDO> getProductCategoryListByStatus(Integer status) {
-        return productCategoryMapper.selectListByStatus(status);
+        return iotProductCategoryMapper.selectListByStatus(status);
     }
 
     @Override
     public Long getProductCategoryCount(LocalDateTime createTime) {
-        return productCategoryMapper.selectCountByCreateTime(createTime);
+        return iotProductCategoryMapper.selectCountByCreateTime(createTime);
     }
 
     @Override
     public Map<String, Integer> getProductCategoryDeviceCountMap() {
         // 1. 获取所有数据
-        List<IotProductCategoryDO> categoryList = productCategoryMapper.selectList();
+        List<IotProductCategoryDO> categoryList = iotProductCategoryMapper.selectList();
         List<IotProductDO> productList = productService.getProductList();
         // TODO @super:不要 list 查询,返回内存,而是查询一个 Map<productId, count>
         Map<Long, Integer> deviceCountMapByProductId = deviceService.getDeviceCountMapByProductId();

+ 2 - 2
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/MenuController.java

@@ -67,8 +67,8 @@ public class MenuController {
     }
 
     @GetMapping({"/list-all-simple", "simple-list"})
-    @Operation(summary = "获取菜单精简信息列表", description = "只包含被开启的菜单,用于【角色分配菜单】功能的选项。" +
-            "在多租户的场景下,会只返回租户所在套餐有的菜单")
+    @Operation(summary = "获取菜单精简信息列表",
+            description = "只包含被开启的菜单,用于【角色分配菜单】功能的选项。在多租户的场景下,会只返回租户所在套餐有的菜单")
     public CommonResult<List<MenuSimpleRespVO>> getSimpleMenuList() {
         List<MenuDO> list = menuService.getMenuListByTenant(
                 new MenuListReqVO().setStatus(CommonStatusEnum.ENABLE.getStatus()));

+ 17 - 5
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/TenantController.java

@@ -1,6 +1,7 @@
 package cn.iocoder.yudao.module.system.controller.admin.tenant;
 
 import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
+import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
 import cn.iocoder.yudao.framework.common.pojo.PageParam;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
@@ -9,7 +10,6 @@ import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
 import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantPageReqVO;
 import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantRespVO;
 import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantSaveReqVO;
-import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantSimpleRespVO;
 import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantDO;
 import cn.iocoder.yudao.module.system.service.tenant.TenantService;
 import io.swagger.v3.oas.annotations.Operation;
@@ -27,6 +27,7 @@ import java.util.List;
 
 import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
 
 @Tag(name = "管理后台 - 租户")
 @RestController
@@ -45,13 +46,25 @@ public class TenantController {
         return success(tenant != null ? tenant.getId() : null);
     }
 
+    @GetMapping({ "simple-list" })
+    @PermitAll
+    @Operation(summary = "获取租户精简信息列表", description = "只包含被开启的租户,用于【首页】功能的选择租户选项")
+    public CommonResult<List<TenantRespVO>> getTenantSimpleList() {
+        List<TenantDO> list = tenantService.getTenantListByStatus(CommonStatusEnum.ENABLE.getStatus());
+        return success(convertList(list, tenantDO ->
+                new TenantRespVO().setId(tenantDO.getId()).setName(tenantDO.getName())));
+    }
+
     @GetMapping("/get-by-website")
     @PermitAll
     @Operation(summary = "使用域名,获得租户信息", description = "登录界面,根据用户的域名,获得租户信息")
     @Parameter(name = "website", description = "域名", required = true, example = "www.iocoder.cn")
-    public CommonResult<TenantSimpleRespVO> getTenantByWebsite(@RequestParam("website") String website) {
+    public CommonResult<TenantRespVO> getTenantByWebsite(@RequestParam("website") String website) {
         TenantDO tenant = tenantService.getTenantByWebsite(website);
-        return success(BeanUtils.toBean(tenant, TenantSimpleRespVO.class));
+        if (tenant == null || CommonStatusEnum.isDisable(tenant.getStatus())) {
+            return success(null);
+        }
+        return success(new TenantRespVO().setId(tenant.getId()).setName(tenant.getName()));
     }
 
     @PostMapping("/create")
@@ -99,8 +112,7 @@ public class TenantController {
     @Operation(summary = "导出租户 Excel")
     @PreAuthorize("@ss.hasPermission('system:tenant:export')")
     @ApiAccessLog(operateType = EXPORT)
-    public void exportTenantExcel(@Valid TenantPageReqVO exportReqVO,
-                                  HttpServletResponse response) throws IOException {
+    public void exportTenantExcel(@Valid TenantPageReqVO exportReqVO, HttpServletResponse response) throws IOException {
         exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
         List<TenantDO> list = tenantService.getTenantPage(exportReqVO).getList();
         // 导出 Excel

+ 0 - 16
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/vo/tenant/TenantSimpleRespVO.java

@@ -1,16 +0,0 @@
-package cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant;
-
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.Data;
-
-@Schema(description = "管理后台 - 租户精简 Response VO")
-@Data
-public class TenantSimpleRespVO {
-
-    @Schema(description = "租户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
-    private Long id;
-
-    @Schema(description = "租户名", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
-    private String name;
-
-}

+ 4 - 0
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/tenant/TenantMapper.java

@@ -43,4 +43,8 @@ public interface TenantMapper extends BaseMapperX<TenantDO> {
         return selectList(TenantDO::getPackageId, packageId);
     }
 
+    default List<TenantDO> selectListByStatus(Integer status) {
+        return selectList(TenantDO::getStatus, status);
+    }
+
 }

+ 9 - 1
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantService.java

@@ -38,7 +38,7 @@ public interface TenantService {
      * 更新租户的角色菜单
      *
      * @param tenantId 租户编号
-     * @param menuIds 菜单编号数组
+     * @param menuIds  菜单编号数组
      */
     void updateTenantRoleMenu(Long tenantId, Set<Long> menuIds);
 
@@ -97,6 +97,14 @@ public interface TenantService {
      */
     List<TenantDO> getTenantListByPackageId(Long packageId);
 
+    /**
+     * 获得指定状态的租户列表
+     *
+     * @param status 状态
+     * @return 租户列表
+     */
+    List<TenantDO> getTenantListByStatus(Integer status);
+
     /**
      * 进行租户的信息处理逻辑
      * 其中,租户编号从 {@link TenantContextHolder} 上下文中获取

+ 5 - 0
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImpl.java

@@ -265,6 +265,11 @@ public class TenantServiceImpl implements TenantService {
         return tenantMapper.selectListByPackageId(packageId);
     }
 
+    @Override
+    public List<TenantDO> getTenantListByStatus(Integer status) {
+        return tenantMapper.selectListByStatus(status);
+    }
+
     @Override
     public void handleTenantInfo(TenantInfoHandler handler) {
         // 如果禁用,则不执行逻辑

+ 5 - 0
yudao-server/src/main/resources/application.yaml

@@ -212,6 +212,10 @@ yudao:
       appKey: 75b161ed2aef4719b275d6e7f2a4d4cd
       secretKey: YWYxYWI2MTA4ODI2NGZlYTQyNjAzZTcz
       model: generalv3.5
+    baichuan: # 百川智能
+      enable: true
+      api-key: sk-abc
+      model: Baichuan4-Turbo
     midjourney:
       enable: true
   #    base-url: https://api.holdai.top/mj-relax/mj
@@ -271,6 +275,7 @@ yudao:
     ignore-urls:
       - /admin-api/system/tenant/get-id-by-name # 基于名字获取租户,不许带租户编号
       - /admin-api/system/tenant/get-by-website # 基于域名获取租户,不许带租户编号
+      - /admin-api/system/tenant/simple-list # 获取租户列表,不许带租户编号
       - /admin-api/system/captcha/get # 获取图片验证码,和租户无关
       - /admin-api/system/captcha/check # 校验图片验证码,和租户无关
       - /admin-api/infra/file/*/get/** # 获取图片,和租户无关