Merge remote-tracking branch 'origin/feature/REQ-5369' into release-20251022
This commit is contained in:
commit
224bbd5473
@ -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<List<FormDataVO>> getFormData(@Validated @RequestBody FromDataSearchDTO dto);
|
||||
|
||||
/**
|
||||
* 获取 WPS 文档中所有可配置的流程相关变量
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/api/form/admin/wps/file/config/variables")
|
||||
@InvokeMode(SYNC)
|
||||
CommonResponse<List<PrintFieldDTO>> getWpsFileConfigVariables(@Validated @RequestBody WpsFileConfigVariableDTO dto);
|
||||
}
|
||||
|
||||
@ -72,5 +72,6 @@ public interface PrintAdminApi {
|
||||
@GetMapping("/api/print/admin/field/variables")
|
||||
@Manageable
|
||||
@InvokeMode(SYNC)
|
||||
CommonResponse<Map<String, Object>> getPrintFieldVariables(@NotBlank(message = "流程实例不能为空") @RequestParam String processInstanceId);
|
||||
CommonResponse<Map<String, Object>> getPrintFieldVariables(@NotBlank(message = "流程实例不能为空") @RequestParam String processInstanceId,
|
||||
@RequestParam(required = false, defaultValue = "true") Boolean throwException);
|
||||
}
|
||||
|
||||
@ -1,11 +1,18 @@
|
||||
package cn.axzo.workflow.common.enums;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonEnumDefaultValue;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 打印字段的类型枚举
|
||||
*
|
||||
* @author wangli
|
||||
* @since 2025-01-16 18:19
|
||||
*/
|
||||
@Getter
|
||||
public enum PrintFieldCategoryEnum {
|
||||
|
||||
// 表单变量
|
||||
@ -15,5 +22,21 @@ public enum PrintFieldCategoryEnum {
|
||||
// 电子签名变量
|
||||
signature,
|
||||
// 签署业务自定义变量
|
||||
sign
|
||||
sign,
|
||||
// 审批业务的变量
|
||||
biz_variable,
|
||||
@JsonEnumDefaultValue
|
||||
unknown,
|
||||
;
|
||||
|
||||
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
|
||||
public static PrintFieldCategoryEnum fromValue(String value) {
|
||||
if (value == null) {
|
||||
return unknown;
|
||||
}
|
||||
return Arrays.stream(values())
|
||||
.filter(e -> e.name().equalsIgnoreCase(value))
|
||||
.findFirst()
|
||||
.orElse(unknown);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
@ -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<List<FormDataVO>> getFormData(@Validated @RequestBody FromDataSearchDTO dto) {
|
||||
return success(formCoreService.getFormData(dto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 WPS 文档中所有可配置的流程相关变量
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/wps/file/config/variables")
|
||||
@Override
|
||||
public CommonResponse<List<PrintFieldDTO>> getWpsFileConfigVariables(@Validated @RequestBody WpsFileConfigVariableDTO dto) {
|
||||
CommonResponse<List<PrintFieldDTO>> printFieldResponse = printAdminController.getPrintFields(PrintFieldQueryDTO.builder()
|
||||
.processDefinitionKey(dto.getProcessDefinitionKey())
|
||||
.tenantId(dto.getTenantId())
|
||||
.throwException(dto.getThrowException())
|
||||
.build());
|
||||
List<PrintFieldDTO> result = printFieldResponse.getData();
|
||||
|
||||
List<CategoryGroupVarItemVo> 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<FieldAttributeDTO> 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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -322,10 +322,11 @@ public class PrintAdminController implements PrintAdminApi {
|
||||
@Operation(summary = "获取指定流程下用于替换打印的相关变量")
|
||||
@GetMapping("/field/variables")
|
||||
@Override
|
||||
public CommonResponse<Map<String, Object>> getPrintFieldVariables(@NotBlank(message = "流程实例不能为空") @RequestParam String processInstanceId) {
|
||||
public CommonResponse<Map<String, Object>> getPrintFieldVariables(@NotBlank(message = "流程实例不能为空") @RequestParam String processInstanceId,
|
||||
@RequestParam(required = false, defaultValue = "true") Boolean throwException) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor();
|
||||
byte[] formInstanceValue = commandExecutor.execute(new CustomGetFormInstanceLatestValuesCmd(processInstanceId));
|
||||
byte[] formInstanceValue = commandExecutor.execute(new CustomGetFormInstanceLatestValuesCmd(processInstanceId, throwException));
|
||||
if (!ObjectUtils.isEmpty(formInstanceValue)) {
|
||||
JSONObject treeNode = JSON.parseObject(new String(formInstanceValue));
|
||||
result.putAll(treeNode.getJSONObject("values").getInnerMap());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user