Merge branch 'feature/RDMP-3845' into dev
This commit is contained in:
commit
d9c1b037d0
@ -23,6 +23,8 @@ public enum FormInstanceRespCode implements IModuleRespCode {
|
|||||||
FORM_DATA_PARSE_ERROR_BY_IMAGE("008", "表单图片组件的数据解析异常"),
|
FORM_DATA_PARSE_ERROR_BY_IMAGE("008", "表单图片组件的数据解析异常"),
|
||||||
FORM_DATA_PARSE_ERROR_BY_CUSTOM_COMPONENT("009", "表单自定义组件的数据解析异常"),
|
FORM_DATA_PARSE_ERROR_BY_CUSTOM_COMPONENT("009", "表单自定义组件的数据解析异常"),
|
||||||
FORM_DATA_PARSE_ERROR_BY_AMOUNT("010", "表单金额组件的数据解析异常"),
|
FORM_DATA_PARSE_ERROR_BY_AMOUNT("010", "表单金额组件的数据解析异常"),
|
||||||
|
FORM_DATA_PARSE_ERROR_BY_CHECKBOX("011", "表单复选框组件的数据解析异常"),
|
||||||
|
FORM_DATA_PARSE_ERROR_BY_RADIO("012", "表单单选框组件的数据解析异常"),
|
||||||
;
|
;
|
||||||
|
|
||||||
private final String code;
|
private final String code;
|
||||||
|
|||||||
@ -46,6 +46,10 @@ public enum FormFieldTypeEnum {
|
|||||||
}),
|
}),
|
||||||
decimal("decimal", "小数", new TypeReference<Map<String, Object>>() {
|
decimal("decimal", "小数", new TypeReference<Map<String, Object>>() {
|
||||||
}),
|
}),
|
||||||
|
checkbox("checkbox", "复选框", new TypeReference<List<String>>() {
|
||||||
|
}),
|
||||||
|
radio("radio", "单选框", new TypeReference<String>() {
|
||||||
|
})
|
||||||
;
|
;
|
||||||
|
|
||||||
private final String type;
|
private final String type;
|
||||||
|
|||||||
@ -22,7 +22,7 @@ import java.util.Map;
|
|||||||
public class FormFieldDTO {
|
public class FormFieldDTO {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字段类型, 如果是分组:FormContainer,其他表单组件:FormField
|
* 字段类型, 如果是分组:FormContainer,单选复选组件:OptionFormField,其他表单组件:FormField,
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "表单字段类型")
|
@ApiModelProperty(value = "表单字段类型")
|
||||||
@NotBlank(message = "字段类型不能为空")
|
@NotBlank(message = "字段类型不能为空")
|
||||||
@ -41,6 +41,9 @@ public class FormFieldDTO {
|
|||||||
* { label: "变洽签单", value: "changeSignatureOrder" },
|
* { label: "变洽签单", value: "changeSignatureOrder" },
|
||||||
* { label: "通讯录", value: "contacts" },
|
* { label: "通讯录", value: "contacts" },
|
||||||
* { label: "金额", value: "amount" },
|
* { label: "金额", value: "amount" },
|
||||||
|
* { label: "复选", value: "checkbox" },
|
||||||
|
* { label: "单选", value: "radio" },
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "前端的组件类型")
|
@ApiModelProperty(value = "前端的组件类型")
|
||||||
private String type;
|
private String type;
|
||||||
@ -76,6 +79,14 @@ public class FormFieldDTO {
|
|||||||
@ApiModelProperty(value = "该表单字段的其他扩展属性,期望 JSON 格式")
|
@ApiModelProperty(value = "该表单字段的其他扩展属性,期望 JSON 格式")
|
||||||
private Map<String, Object> params;
|
private Map<String, Object> params;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单选复选框的选项
|
||||||
|
* <p>
|
||||||
|
* {@see org.flowable.form.model.OptionFormField}
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "单选复选框的选项,配合 fieldType=OptionFormField 使用")
|
||||||
|
private List<OptionDTO> options;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当 fieldType=FormContainer 时,这里的代表内部的集合
|
* 当 fieldType=FormContainer 时,这里的代表内部的集合
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -0,0 +1,24 @@
|
|||||||
|
package cn.axzo.workflow.common.model.request.form.definition;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单选复选框的选项入参模型
|
||||||
|
*
|
||||||
|
* @author wangli
|
||||||
|
* @since 2025-11-20 10:57
|
||||||
|
*/
|
||||||
|
@ApiModel("单选复选框的选项入参模型")
|
||||||
|
@Data
|
||||||
|
public class OptionDTO {
|
||||||
|
/**
|
||||||
|
* 选项 ID
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 选项名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
}
|
||||||
@ -0,0 +1,46 @@
|
|||||||
|
package cn.axzo.workflow.core.engine.cmd;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import org.flowable.common.engine.impl.interceptor.CommandContext;
|
||||||
|
import org.flowable.engine.impl.util.CommandContextUtil;
|
||||||
|
import org.flowable.form.api.FormEngineConfigurationApi;
|
||||||
|
import org.flowable.form.api.FormInfo;
|
||||||
|
import org.flowable.form.api.FormInstance;
|
||||||
|
import org.flowable.form.api.FormRepositoryService;
|
||||||
|
import org.flowable.form.api.FormService;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过审批实例 ID 获取对应的表单定义实体的自定义命令
|
||||||
|
*
|
||||||
|
* @author wangli
|
||||||
|
* @since 2025-11-20 10:18
|
||||||
|
*/
|
||||||
|
public class CustomGetFormModelByProcessInstanceIdCmd extends AbstractCommand<FormInfo> implements Serializable {
|
||||||
|
private final String processInstanceId;
|
||||||
|
|
||||||
|
public CustomGetFormModelByProcessInstanceIdCmd(String processInstanceId) {
|
||||||
|
this.processInstanceId = processInstanceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String paramToJsonString() {
|
||||||
|
Map<String, Object> params = new HashMap<>();
|
||||||
|
params.put("processInstanceId", processInstanceId);
|
||||||
|
return JSON.toJSONString(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FormInfo executeInternal(CommandContext commandContext) {
|
||||||
|
FormEngineConfigurationApi formEngineConfiguration = CommandContextUtil.getFormEngineConfiguration(commandContext);
|
||||||
|
FormService formService = formEngineConfiguration.getFormService();
|
||||||
|
|
||||||
|
FormInstance formInstance = formService.createFormInstanceQuery().processInstanceId(processInstanceId).singleResult();
|
||||||
|
String formDefinitionId = formInstance.getFormDefinitionId();
|
||||||
|
FormRepositoryService formRepositoryService = formEngineConfiguration.getFormRepositoryService();
|
||||||
|
return formRepositoryService.getFormModelById(formDefinitionId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -27,6 +27,8 @@ import org.flowable.form.api.FormService;
|
|||||||
import org.flowable.form.model.FormContainer;
|
import org.flowable.form.model.FormContainer;
|
||||||
import org.flowable.form.model.FormField;
|
import org.flowable.form.model.FormField;
|
||||||
import org.flowable.form.model.FormFieldTypes;
|
import org.flowable.form.model.FormFieldTypes;
|
||||||
|
import org.flowable.form.model.Option;
|
||||||
|
import org.flowable.form.model.OptionFormField;
|
||||||
import org.flowable.form.model.SimpleFormModel;
|
import org.flowable.form.model.SimpleFormModel;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
@ -42,6 +44,8 @@ import java.util.Map;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static cn.axzo.workflow.common.code.FormInstanceRespCode.FORM_DATA_PARSE_ERROR_BY_CHECKBOX;
|
||||||
|
import static cn.axzo.workflow.common.code.FormInstanceRespCode.FORM_DATA_PARSE_ERROR_BY_RADIO;
|
||||||
import static cn.axzo.workflow.common.code.FormModelRespCode.FORM_MODEL_NOT_EXISTS;
|
import static cn.axzo.workflow.common.code.FormModelRespCode.FORM_MODEL_NOT_EXISTS;
|
||||||
import static cn.axzo.workflow.common.constant.BpmnConstants.BPM_MODEL_CATEGORY;
|
import static cn.axzo.workflow.common.constant.BpmnConstants.BPM_MODEL_CATEGORY;
|
||||||
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_INITIATOR;
|
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_INITIATOR;
|
||||||
@ -75,7 +79,7 @@ public class CustomGetProcessInstanceVariablesToObjectCmd extends AbstractComman
|
|||||||
|
|
||||||
private final String processInstanceId;
|
private final String processInstanceId;
|
||||||
private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
|
private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
|
||||||
private static final List<String> SUPPORTED_FORM_TYPES = Lists.newArrayList("input", "date", "textarea", "image", "contacts", "amount", "decimal");
|
private static final List<String> SUPPORTED_FORM_TYPES = Lists.newArrayList("input", "date", "textarea", "image", "contacts", "amount", "decimal", "checkbox", "radio");
|
||||||
|
|
||||||
public CustomGetProcessInstanceVariablesToObjectCmd(String processInstanceId) {
|
public CustomGetProcessInstanceVariablesToObjectCmd(String processInstanceId) {
|
||||||
this.processInstanceId = processInstanceId;
|
this.processInstanceId = processInstanceId;
|
||||||
@ -219,6 +223,39 @@ public class CustomGetProcessInstanceVariablesToObjectCmd extends AbstractComman
|
|||||||
.type(convert(field.getType()))
|
.type(convert(field.getType()))
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
} else if (Objects.equals(field.getType(), "checkbox")) {
|
||||||
|
if (field instanceof OptionFormField) {
|
||||||
|
OptionFormField optionField = (OptionFormField) field;
|
||||||
|
if (StringUtils.hasText(fieldValue.toString())
|
||||||
|
&& fieldValue.toString().startsWith("[")
|
||||||
|
&& fieldValue.toString().endsWith("]")) {
|
||||||
|
List<String> selectedOptions = JSON.parseArray((String) fieldValue, String.class);
|
||||||
|
List<String> optionNames = optionField.getOptions().stream().filter(i -> selectedOptions.contains(i.getId())).map(Option::getName).collect(Collectors.toList());
|
||||||
|
variables.add(VariableObjectDTO.builder()
|
||||||
|
.key(field.getId())
|
||||||
|
.desc(field.getName())
|
||||||
|
.value(StringUtils.collectionToCommaDelimitedString(optionNames))
|
||||||
|
.type(convert(field.getType()))
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new WorkflowEngineException(FORM_DATA_PARSE_ERROR_BY_CHECKBOX);
|
||||||
|
}
|
||||||
|
} else if (Objects.equals(field.getType(), "radio")) {
|
||||||
|
if (field instanceof OptionFormField) {
|
||||||
|
OptionFormField optionField = (OptionFormField) field;
|
||||||
|
if (StringUtils.hasText(fieldValue.toString())) {
|
||||||
|
List<String> optionNames = optionField.getOptions().stream().filter(i -> Objects.equals(fieldValue, i.getId())).map(Option::getName).collect(Collectors.toList());
|
||||||
|
variables.add(VariableObjectDTO.builder()
|
||||||
|
.key(field.getId())
|
||||||
|
.desc(field.getName())
|
||||||
|
.value(StringUtils.collectionToCommaDelimitedString(optionNames))
|
||||||
|
.type(convert(field.getType()))
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new WorkflowEngineException(FORM_DATA_PARSE_ERROR_BY_RADIO);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
variables.add(VariableObjectDTO.builder()
|
variables.add(VariableObjectDTO.builder()
|
||||||
.key(field.getId())
|
.key(field.getId())
|
||||||
|
|||||||
@ -39,6 +39,7 @@ import cn.axzo.workflow.common.model.response.print.ProcessLogPdfResultDTO;
|
|||||||
import cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper;
|
import cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper;
|
||||||
import cn.axzo.workflow.core.conf.SupportRefreshProperties;
|
import cn.axzo.workflow.core.conf.SupportRefreshProperties;
|
||||||
import cn.axzo.workflow.core.engine.cmd.CustomGetFormInstanceLatestValuesCmd;
|
import cn.axzo.workflow.core.engine.cmd.CustomGetFormInstanceLatestValuesCmd;
|
||||||
|
import cn.axzo.workflow.core.engine.cmd.CustomGetFormModelByProcessInstanceIdCmd;
|
||||||
import cn.axzo.workflow.core.engine.cmd.CustomGetProcessInstanceVariablesCmd;
|
import cn.axzo.workflow.core.engine.cmd.CustomGetProcessInstanceVariablesCmd;
|
||||||
import cn.axzo.workflow.core.repository.entity.ExtAxProcessLog;
|
import cn.axzo.workflow.core.repository.entity.ExtAxProcessLog;
|
||||||
import cn.axzo.workflow.core.service.BpmnProcessDefinitionService;
|
import cn.axzo.workflow.core.service.BpmnProcessDefinitionService;
|
||||||
@ -406,16 +407,17 @@ public class PrintAdminController implements PrintAdminApi {
|
|||||||
// 生成系统字段的变量
|
// 生成系统字段的变量
|
||||||
generateSystemFieldVariables(processInstanceId, result);
|
generateSystemFieldVariables(processInstanceId, result);
|
||||||
|
|
||||||
|
FormInfo formInfo = commandExecutor.execute(new CustomGetFormModelByProcessInstanceIdCmd(processInstanceId));
|
||||||
// 将所有变量都转换成 JSON 对象返回
|
// 将所有变量都转换成 JSON 对象返回
|
||||||
convertValueToObject(result);
|
convertValueToObject(result, formInfo);
|
||||||
return success(result);
|
return success(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void convertValueToObject(Map<String, Object> result) {
|
private void convertValueToObject(Map<String, Object> result, FormInfo formInfo) {
|
||||||
if (CollectionUtils.isEmpty(result)) {
|
if (CollectionUtils.isEmpty(result)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Map<String, FormField> stringFormFieldMap = ((SimpleFormModel) formInfo.getFormModel()).allFieldsAsMap();
|
||||||
result.forEach((key, value) -> {
|
result.forEach((key, value) -> {
|
||||||
if (!(value instanceof String)) {
|
if (!(value instanceof String)) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user