diff --git a/workflow-engine-api/src/main/java/cn/axzo/workflow/client/feign/manage/FormAdminApi.java b/workflow-engine-api/src/main/java/cn/axzo/workflow/client/feign/manage/FormAdminApi.java index 2590dd4a4..525720f53 100644 --- a/workflow-engine-api/src/main/java/cn/axzo/workflow/client/feign/manage/FormAdminApi.java +++ b/workflow-engine-api/src/main/java/cn/axzo/workflow/client/feign/manage/FormAdminApi.java @@ -3,16 +3,17 @@ package cn.axzo.workflow.client.feign.manage; import cn.axzo.workflow.client.annotation.WorkflowEngineFeignClient; import cn.axzo.workflow.common.annotation.InvokeMode; import cn.axzo.workflow.common.annotation.Manageable; +import cn.axzo.workflow.common.model.dto.print.PrintFieldDTO; import cn.axzo.workflow.common.model.request.form.definition.StartFormSearchDTO; import cn.axzo.workflow.common.model.request.form.instance.FormDetailDTO; import cn.axzo.workflow.common.model.request.form.instance.FormSearchDTO; import cn.axzo.workflow.common.model.request.form.instance.FromDataSearchDTO; +import cn.axzo.workflow.common.model.request.form.model.WpsFileConfigVariableDTO; import cn.axzo.workflow.common.model.response.form.FormVO; import cn.axzo.workflow.common.model.response.form.definition.FormDefinitionVO; import cn.axzo.workflow.common.model.response.form.instance.FormDataVO; import cn.axzo.workflow.common.model.response.form.instance.FormInstanceVO; import cn.azxo.framework.common.model.CommonResponse; -import io.swagger.v3.oas.annotations.Operation; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -69,4 +70,14 @@ public interface FormAdminApi { @PostMapping("/api/form/admin/instance/form/data") @InvokeMode(SYNC) CommonResponse> getFormData(@Validated @RequestBody FromDataSearchDTO dto); + + /** + * 获取 WPS 文档中所有可配置的流程相关变量 + * + * @param dto + * @return + */ + @PostMapping("/api/form/admin/wps/file/config/variables") + @InvokeMode(SYNC) + CommonResponse> getWpsFileConfigVariables(@Validated @RequestBody WpsFileConfigVariableDTO dto); } diff --git a/workflow-engine-common/src/main/java/cn/axzo/workflow/common/enums/PrintFieldCategoryEnum.java b/workflow-engine-common/src/main/java/cn/axzo/workflow/common/enums/PrintFieldCategoryEnum.java index 305e63223..4d210e173 100644 --- a/workflow-engine-common/src/main/java/cn/axzo/workflow/common/enums/PrintFieldCategoryEnum.java +++ b/workflow-engine-common/src/main/java/cn/axzo/workflow/common/enums/PrintFieldCategoryEnum.java @@ -23,6 +23,8 @@ public enum PrintFieldCategoryEnum { signature, // 签署业务自定义变量 sign, + // 审批业务的变量 + biz_variable, @JsonEnumDefaultValue unknown, ; diff --git a/workflow-engine-common/src/main/java/cn/axzo/workflow/common/model/request/form/model/WpsFileConfigVariableDTO.java b/workflow-engine-common/src/main/java/cn/axzo/workflow/common/model/request/form/model/WpsFileConfigVariableDTO.java new file mode 100644 index 000000000..338e12117 --- /dev/null +++ b/workflow-engine-common/src/main/java/cn/axzo/workflow/common/model/request/form/model/WpsFileConfigVariableDTO.java @@ -0,0 +1,39 @@ +package cn.axzo.workflow.common.model.request.form.model; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * 查询用于 WPS 左侧变量列表的集合 + * + * @author wangli + * @since 2025-09-15 10:07 + */ +@ApiModel("查询用于 WPS 左侧变量列表的集合") +@Data +@Builder +public class WpsFileConfigVariableDTO { + /** + * 模板定义 KEY + */ + @ApiModelProperty(value = "流程模板 KEY") + @NotBlank(message = "流程模板 KEY 不能为空") + private String processDefinitionKey; + + /** + * 租户 ID + */ + @ApiModelProperty(value = "租户 ID") + private String tenantId; + + /** + * 是否抛出内部异常 + */ + @ApiModelProperty(value = "是否报错内部异常") + @Builder.Default + private Boolean throwException = true; +} diff --git a/workflow-engine-server/src/main/java/cn/axzo/workflow/server/controller/web/form/FormAdminController.java b/workflow-engine-server/src/main/java/cn/axzo/workflow/server/controller/web/form/FormAdminController.java index 35c7c3d9e..ae80e6fa2 100644 --- a/workflow-engine-server/src/main/java/cn/axzo/workflow/server/controller/web/form/FormAdminController.java +++ b/workflow-engine-server/src/main/java/cn/axzo/workflow/server/controller/web/form/FormAdminController.java @@ -1,20 +1,30 @@ package cn.axzo.workflow.server.controller.web.form; import cn.axzo.workflow.client.feign.manage.FormAdminApi; +import cn.axzo.workflow.common.enums.PrintFieldCategoryEnum; import cn.axzo.workflow.common.model.dto.BpmnFormRelationSearchDTO; +import cn.axzo.workflow.common.model.dto.print.FieldAttributeDTO; +import cn.axzo.workflow.common.model.dto.print.PrintFieldDTO; +import cn.axzo.workflow.common.model.request.bpmn.print.PrintFieldQueryDTO; +import cn.axzo.workflow.common.model.request.category.CategoryGroupVarSearchDto; import cn.axzo.workflow.common.model.request.form.definition.StartFormSearchDTO; import cn.axzo.workflow.common.model.request.form.instance.FormDetailDTO; import cn.axzo.workflow.common.model.request.form.instance.FormSearchDTO; import cn.axzo.workflow.common.model.request.form.instance.FromDataSearchDTO; +import cn.axzo.workflow.common.model.request.form.model.WpsFileConfigVariableDTO; +import cn.axzo.workflow.common.model.response.category.CategoryGroupVarItemVo; import cn.axzo.workflow.common.model.response.form.FormVO; import cn.axzo.workflow.common.model.response.form.definition.FormDefinitionVO; import cn.axzo.workflow.common.model.response.form.instance.FormDataVO; import cn.axzo.workflow.common.model.response.form.instance.FormInstanceVO; +import cn.axzo.workflow.core.service.CategoryGroupService; import cn.axzo.workflow.core.service.FormCoreService; import cn.axzo.workflow.server.common.annotation.ErrorReporter; +import cn.axzo.workflow.server.controller.web.manage.PrintAdminController; import cn.azxo.framework.common.model.CommonResponse; import io.swagger.v3.oas.annotations.Operation; import lombok.extern.slf4j.Slf4j; +import org.springframework.util.CollectionUtils; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -22,6 +32,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; +import java.util.ArrayList; import java.util.List; import static cn.azxo.framework.common.model.CommonResponse.success; @@ -41,6 +52,10 @@ public class FormAdminController implements FormAdminApi { @Resource private FormCoreService formCoreService; + @Resource + private PrintAdminController printAdminController; + @Resource + private CategoryGroupService categoryGroupService; @Operation(summary = "表单列表") @PostMapping("/form/page") @@ -68,4 +83,48 @@ public class FormAdminController implements FormAdminApi { public CommonResponse> getFormData(@Validated @RequestBody FromDataSearchDTO dto) { return success(formCoreService.getFormData(dto)); } + + /** + * 获取 WPS 文档中所有可配置的流程相关变量 + * + * @param dto + * @return + */ + @PostMapping("/wps/file/config/variables") + @Override + public CommonResponse> getWpsFileConfigVariables(@Validated @RequestBody WpsFileConfigVariableDTO dto) { + CommonResponse> printFieldResponse = printAdminController.getPrintFields(PrintFieldQueryDTO.builder() + .processDefinitionKey(dto.getProcessDefinitionKey()) + .tenantId(dto.getTenantId()) + .throwException(dto.getThrowException()) + .build()); + List result = printFieldResponse.getData(); + + List categoryGroupVarItemVos = categoryGroupService.searchGroupAndVarList(CategoryGroupVarSearchDto.builder() + .category(dto.getProcessDefinitionKey()) + .build()); + + if (CollectionUtils.isEmpty(categoryGroupVarItemVos)) { + return printFieldResponse; + } + + categoryGroupVarItemVos.forEach(i -> { + PrintFieldDTO field = new PrintFieldDTO(); + field.setName(i.getGroupName()); + field.setFieldCategoryType(PrintFieldCategoryEnum.biz_variable); + field.setCode(""); + field.setFieldFormType(""); + List attributes = new ArrayList<>(); + i.getVars().forEach(e -> { + FieldAttributeDTO attribute = new FieldAttributeDTO(); + attribute.setCode(e.getCode()); + attribute.setName(e.getName()); + attribute.setFieldFormType(e.getType().getType()); + attributes.add(attribute); + }); + field.setAttributes(attributes); + result.add(field); + }); + return success(result); + } }