update - 流程转换"批量操作","审批同意手写签名" 配置

This commit is contained in:
yangqicheng 2024-04-22 17:44:21 +08:00
parent 98e3292257
commit c723d5907a
8 changed files with 102 additions and 37 deletions

View File

@ -55,10 +55,13 @@ public interface BpmnConstants {
String FLOW_SERVER_VERSION_121 = "1.2.1";
String FLOW_SERVER_VERSION_130 = "1.3.0";
String CONFIG_NOTICE = "noticeConfig";
String CONFIG_APPROVE = "approveConfig";
String TEMPLATE_NOTICE_MESSAGE_ID = "noticeMessageId";
String TEMPLATE_PENDING_MESSAGE_ID = "pendingMessageId";
String TEMPLATE_CARBON_COPY_MESSAGE_ID = "carbonCopyMessageId";
String TEMPLATE_SMS_MESSAGE_ID = "smsMessageId";
String APPROVE_SUPPORT_BATCH_OPERATION = "supportBatchOperation";
String APPROVE_USER_AGREE_SIGNATURE = "userAgreeSignature";
String CONFIG_BUTTON = "buttonConfig";
String CONFIG_CARBON_COPIES = "carbonCopyConfigs";
String CONFIG_CARBON_COPY = "carbonCopyConfig";

View File

@ -0,0 +1,30 @@
package cn.axzo.workflow.common.model.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import javax.validation.Valid;
@ApiModel("JSON 版本的 BPMN 协议模型中流程配置管理")
@Data
@NoArgsConstructor
@Accessors(chain = true)
public class BpmnApproveConf {
/**
* 是否支持批量审批
*/
@ApiModelProperty(value = "是否支持批量审批")
@Valid
private Boolean supportBatchOperation;
/**
* 审批同意录入手写签名
*/
@ApiModelProperty(value = "审批同意录入手写签名")
@Valid
private Boolean userAgreeSignature;
}

View File

@ -1,5 +1,6 @@
package cn.axzo.workflow.common.model.request.bpmn;
import cn.axzo.workflow.common.model.request.BpmnApproveConf;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -48,9 +49,9 @@ public class BpmnJsonModel implements Serializable {
private List<BpmnFieldConf> fieldConf;
/**
* 是否支持批量审批
* 审批相关高级配置
*/
@ApiModelProperty(value = "是否支持批量审批")
@ApiModelProperty(value = "审批相关高级配置")
@Valid
private Boolean supportBatchOperation;
private BpmnApproveConf approveConf;
}

View File

@ -142,6 +142,7 @@ public final class BpmnJsonConverterUtil {
BpmnJsonNode bpmnJsonNode = JSON.parseObject(mainProcess.getAttributeValue(null, FLOW_NODE_JSON),
BpmnJsonNode.class);
model.setNode(bpmnJsonNode);
getProcessApproveConf(mainProcess).ifPresent(model::setApproveConf);
getNoticeConfig(mainProcess).ifPresent(model::setNoticeConf);
getButtonConfig(mainProcess).ifPresent(model::setButtonConf);
getFieldConfig(mainProcess).ifPresent(model::setFieldConf);
@ -152,13 +153,16 @@ public final class BpmnJsonConverterUtil {
* json 格式数据转的 BpmnJsonNode 对象,转换成 Flowable 标准的模型 {@link BpmnModel}
*
* @param bpmnJsonNode json 格式对象,可以直接解析
* @param approveConf 流程高审批相关高级配置
* @param noticeConf
* @param buttonConf
* @param fieldConf
* @return {@link BpmnModel}
*/
public static BpmnModel convertToBpmn(BpmnJsonNode bpmnJsonNode, String id, String name, String documentation,
BpmnNoticeConf noticeConf, BpmnButtonConf buttonConf,
BpmnApproveConf approveConf,
BpmnNoticeConf noticeConf,
BpmnButtonConf buttonConf,
List<BpmnFieldConf> fieldConf,
String serverVersionStr) {
if (Objects.isNull(bpmnJsonNode)) {
@ -182,6 +186,8 @@ public final class BpmnJsonConverterUtil {
mainProcess.addAttribute(serverVersion);
mainProcess.addAttribute(jsonMetaValue);
//设置流程审批相关高级配置
setProcessApproveConfigs(approveConf, mainProcess);
// 设置流程的通知管理配置
setProcessNoticeConfig(noticeConf, mainProcess);
// 设置流程的默认的按钮配置
@ -387,6 +393,35 @@ public final class BpmnJsonConverterUtil {
mainProcess.addExtensionElement(noticeConfigElement);
}
private static void setProcessApproveConfigs(BpmnApproveConf approveConf, Process mainProcess) {
if (Objects.isNull(approveConf)) {
return;
}
ExtensionElement approveConfigElement = new ExtensionElement();
approveConfigElement.setName(CONFIG_APPROVE);
mainProcess.addExtensionElement(approveConfigElement);
// 审批相关配置
if (Objects.nonNull(approveConf.getSupportBatchOperation())) {
ExtensionElement config = new ExtensionElement();
config.setName(APPROVE_SUPPORT_BATCH_OPERATION);
ExtensionAttribute configAttribute = new ExtensionAttribute();
configAttribute.setName(ELEMENT_ATTRIBUTE_VALUE);
configAttribute.setValue(Boolean.toString(approveConf.getSupportBatchOperation()));
config.addAttribute(configAttribute);
approveConfigElement.addChildElement(config);
}
if (Objects.nonNull(approveConf.getUserAgreeSignature())) {
ExtensionElement config = new ExtensionElement();
config.setName(APPROVE_USER_AGREE_SIGNATURE);
ExtensionAttribute configAttribute = new ExtensionAttribute();
configAttribute.setName(ELEMENT_ATTRIBUTE_VALUE);
configAttribute.setValue(Boolean.toString(approveConf.getUserAgreeSignature()));
config.addAttribute(configAttribute);
approveConfigElement.addChildElement(config);
}
}
public static byte[] transformBytes(BpmnModel bpmnModel) {
return new BpmnXMLConverter().convertToXML(bpmnModel);
@ -614,11 +649,12 @@ public final class BpmnJsonConverterUtil {
BpmnModelCreateDTO model = JSON.parseObject(content, BpmnModelCreateDTO.class);
BpmnModel bpmnModel = convertToBpmn(model.getJsonModel().getNode(), "id", "测试", "remark",
model.getJsonModel().getApproveConf(),
model.getJsonModel().getNoticeConf(),
model.getJsonModel().getButtonConf(), model.getJsonModel().getFieldConf(),
"1.3.1-SNAPSHOT");
convertToJson(bpmnModel);
BpmnJsonModel bpmnJsonModel = convertToJson(bpmnModel);
// ServiceTask serviceTask = (ServiceTask) bpmnModel.getFlowElement("node_946990365785");
// Optional<List<BpmnCarbonCopyConf>> carbonCopyConfigs = BpmnMetaParserHelper.getCarbonCopyConfigs

View File

@ -6,6 +6,7 @@ import cn.axzo.workflow.common.enums.ApproverScopeEnum;
import cn.axzo.workflow.common.enums.ApproverSpecifyEnum;
import cn.axzo.workflow.common.enums.BpmnFlowNodeType;
import cn.axzo.workflow.common.enums.CarbonCopyObjectType;
import cn.axzo.workflow.common.model.request.BpmnApproveConf;
import cn.axzo.workflow.common.model.request.bpmn.BpmnButtonConf;
import cn.axzo.workflow.common.model.request.bpmn.BpmnButtonMetaInfo;
import cn.axzo.workflow.common.model.request.bpmn.BpmnCarbonCopyConf;
@ -35,38 +36,7 @@ import java.util.List;
import java.util.Objects;
import java.util.Optional;
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_APPROVAL_METHOD;
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_APPROVER_EMPTY_HANDLE_TYPE;
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_APPROVER_SCOPE;
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_APPROVER_SPECIFY;
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_BUTTON;
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_BUTTON_META;
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_BUTTON_TYPE_CARBON_COPY;
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_BUTTON_TYPE_CURRENT;
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_BUTTON_TYPE_HISTORY;
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_BUTTON_TYPE_INITIATOR;
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_CARBON_COPIES;
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_CARBON_COPY;
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_CARBON_COPY_OBJECT;
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_CARBON_COPY_SPECIFY;
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_FIELD;
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_FIELD_META;
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_FIELD_OPTION;
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_NODE_TYPE;
import static cn.axzo.workflow.common.constant.BpmnConstants.CONFIG_NOTICE;
import static cn.axzo.workflow.common.constant.BpmnConstants.ELEMENT_ATTRIBUTE_CHECKED;
import static cn.axzo.workflow.common.constant.BpmnConstants.ELEMENT_ATTRIBUTE_CODE;
import static cn.axzo.workflow.common.constant.BpmnConstants.ELEMENT_ATTRIBUTE_DISABLED;
import static cn.axzo.workflow.common.constant.BpmnConstants.ELEMENT_ATTRIBUTE_KEY;
import static cn.axzo.workflow.common.constant.BpmnConstants.ELEMENT_ATTRIBUTE_NAME;
import static cn.axzo.workflow.common.constant.BpmnConstants.ELEMENT_ATTRIBUTE_ORDER;
import static cn.axzo.workflow.common.constant.BpmnConstants.ELEMENT_ATTRIBUTE_TYPE;
import static cn.axzo.workflow.common.constant.BpmnConstants.ELEMENT_ATTRIBUTE_VALUE;
import static cn.axzo.workflow.common.constant.BpmnConstants.FLOW_SERVER_VERSION;
import static cn.axzo.workflow.common.constant.BpmnConstants.TEMPLATE_CARBON_COPY_MESSAGE_ID;
import static cn.axzo.workflow.common.constant.BpmnConstants.TEMPLATE_NOTICE_MESSAGE_ID;
import static cn.axzo.workflow.common.constant.BpmnConstants.TEMPLATE_PENDING_MESSAGE_ID;
import static cn.axzo.workflow.common.constant.BpmnConstants.TEMPLATE_SMS_MESSAGE_ID;
import static cn.axzo.workflow.common.constant.BpmnConstants.*;
/**
* 协助解析 BPMN 文件中的自定义扩展字段和属性
@ -82,6 +52,24 @@ public final class BpmnMetaParserHelper {
return Optional.ofNullable(process.getAttributeValue(null, FLOW_SERVER_VERSION));
}
public static Optional<BpmnApproveConf> getProcessApproveConf(Process process) {
List<ExtensionElement> elements = process.getExtensionElements().getOrDefault(CONFIG_APPROVE,
Collections.emptyList());
if (CollectionUtils.isEmpty(elements)) {
return Optional.empty();
}
BpmnApproveConf conf = new BpmnApproveConf();
elements.get(0).getChildElements().forEach((k, v) -> {
if (APPROVE_SUPPORT_BATCH_OPERATION.equals(k)) {
String value = v.get(0).getAttributeValue(null, ELEMENT_ATTRIBUTE_VALUE);
conf.setSupportBatchOperation(Boolean.valueOf(value));
} else if (APPROVE_USER_AGREE_SIGNATURE.equals(k)) {
String value = v.get(0).getAttributeValue(null, ELEMENT_ATTRIBUTE_VALUE);
conf.setUserAgreeSignature(Boolean.valueOf(value));
}});
return Optional.of(conf);
}
/**
* 获取流程模型全局兜底的消息模板相关配置
*

View File

@ -124,6 +124,7 @@ public class BpmnProcessDefinitionServiceImpl implements BpmnProcessDefinitionSe
StringUtils.hasLength(dto.getKey()) ? dto.getKey() : dto.getCategory(),
dto.getName(),
dto.getDescription(),
dto.getJsonModel().getApproveConf(),
dto.getJsonModel().getNoticeConf(),
dto.getJsonModel().getButtonConf(),
dto.getJsonModel().getFieldConf(),

View File

@ -234,6 +234,7 @@ public class BpmnProcessModelServiceImpl implements BpmnProcessModelService {
StringUtils.hasLength(dto.getKey()) ? dto.getKey() : dto.getCategory(),
dto.getName(),
dto.getDescription(),
dto.getJsonModel().getApproveConf(),
dto.getJsonModel().getNoticeConf(),
dto.getJsonModel().getButtonConf(),
dto.getJsonModel().getFieldConf(),
@ -322,6 +323,7 @@ public class BpmnProcessModelServiceImpl implements BpmnProcessModelService {
StringUtils.hasLength(dto.getKey()) ? dto.getKey() : dto.getCategory(),
dto.getName(),
dto.getDescription(),
dto.getJsonModel().getApproveConf(),
dto.getJsonModel().getNoticeConf(),
dto.getJsonModel().getButtonConf(),
dto.getJsonModel().getFieldConf(),

View File

@ -10917,6 +10917,10 @@
"branches": null,
"property": null
},
"approveConf": {
"supportBatchOperation": true,
"userAgreeSignature": true
},
"noticeConf": {
"notice": {
"noticeMessageId": "",