update - 模型转换中的版本动态化

This commit is contained in:
wangli 2024-03-26 13:57:53 +08:00
parent c89bf404eb
commit 0b7c0ebe07
4 changed files with 21 additions and 12 deletions

View File

@ -81,7 +81,6 @@ import static cn.axzo.workflow.common.constant.BpmnConstants.ELEMENT_ATTRIBUTE_V
import static cn.axzo.workflow.common.constant.BpmnConstants.END_EVENT_ID;
import static cn.axzo.workflow.common.constant.BpmnConstants.FLOW_NODE_JSON;
import static cn.axzo.workflow.common.constant.BpmnConstants.FLOW_SERVER_VERSION;
import static cn.axzo.workflow.common.constant.BpmnConstants.FLOW_SERVER_VERSION_130;
import static cn.axzo.workflow.common.constant.BpmnConstants.SEQUENCE_FLOW_ID;
import static cn.axzo.workflow.common.constant.BpmnConstants.START_EVENT_ID;
import static cn.axzo.workflow.common.constant.BpmnConstants.TEMPLATE_CARBON_COPY_MESSAGE_ID;
@ -151,7 +150,8 @@ public final class BpmnJsonConverterUtil {
*/
public static BpmnModel convertToBpmn(BpmnJsonNode bpmnJsonNode, String id, String name, String documentation,
BpmnNoticeConf noticeConf, BpmnButtonConf buttonConf,
List<BpmnFieldConf> fieldConf) {
List<BpmnFieldConf> fieldConf,
String serverVersionStr) {
if (Objects.isNull(bpmnJsonNode)) {
throw new WorkflowEngineException(CONVERTOR_COMMON_ERROR, "JSON 数据为空");
}
@ -160,8 +160,8 @@ public final class BpmnJsonConverterUtil {
ExtensionAttribute serverVersion = new ExtensionAttribute();
serverVersion.setName(FLOW_SERVER_VERSION);
//FIXME: 尽量在每次版本迭代时, 都修改这里的版本号, 用于以后特殊场景下消息流程相关数据时, 能区别不同时期的处理办法
serverVersion.setValue(FLOW_SERVER_VERSION_130);
//FIXME: 尽量在每次版本迭代时, 都修改这里的版本号, 用于以后特殊场景下消息流程相关数据时, 能区别不同时期的处理办法,还需要动态起来
serverVersion.setValue(serverVersionStr);
ExtensionAttribute jsonMetaValue = new ExtensionAttribute();
jsonMetaValue.setName(FLOW_NODE_JSON);
jsonMetaValue.setValue(JSON.toJSONString(bpmnJsonNode));
@ -570,7 +570,8 @@ public final class BpmnJsonConverterUtil {
BpmnModelCreateDTO model = JSON.parseObject(content, BpmnModelCreateDTO.class);
BpmnModel bpmnModel = convertToBpmn(model.getJsonModel().getNode(), "id", "测试", "remark",
model.getJsonModel().getNoticeConf(),
model.getJsonModel().getButtonConf(), model.getJsonModel().getFieldConf());
model.getJsonModel().getButtonConf(), model.getJsonModel().getFieldConf(),
"1.3.1-SNAPSHOT");
System.out.println("bpmnModel = " + bpmnModel);
convertToJson(bpmnModel);

View File

@ -56,6 +56,8 @@ public class BpmnProcessDefinitionServiceImpl implements BpmnProcessDefinitionSe
private ExtAxReProcDefService extAxReProcDefService;
@Resource
private BpmnProcessDefinitionConverter processDefinitionConverter;
@Resource
private String serviceVersion;
@Override
public String createProcessDefinition(Model model, byte[] bpmnBytes) {
@ -123,7 +125,8 @@ public class BpmnProcessDefinitionServiceImpl implements BpmnProcessDefinitionSe
dto.getDescription(),
dto.getJsonModel().getNoticeConf(),
dto.getJsonModel().getButtonConf(),
dto.getJsonModel().getFieldConf());
dto.getJsonModel().getFieldConf(),
serviceVersion);
byte[] bpmn = BpmnJsonConverterUtil.transformBytes(bpmnModel);
updateProcessDefinition(model.getId(), bpmn);
}

View File

@ -89,7 +89,6 @@ import static cn.axzo.workflow.common.constant.BpmnConstants.AND_SIGN_EXPRESSION
import static cn.axzo.workflow.common.constant.BpmnConstants.BIZ_ORG_RELATION;
import static cn.axzo.workflow.common.constant.BpmnConstants.BPM_MODEL_CATEGORY;
import static cn.axzo.workflow.common.constant.BpmnConstants.FLOW_SERVER_VERSION_121;
import static cn.axzo.workflow.common.constant.BpmnConstants.FLOW_SERVER_VERSION_130;
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_INITIATOR;
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_PROCESS_AGENT;
import static cn.axzo.workflow.common.constant.BpmnConstants.OLD_INTERNAL_INITIATOR;
@ -275,7 +274,7 @@ public class BpmnProcessInstanceServiceImpl implements BpmnProcessInstanceServic
dto.getVariables().put(INTERNAL_INITIATOR, dto.getInitiator());
dto.getVariables().put(BIZ_ORG_RELATION, dto.getCooperationOrg());
dto.getVariables().put(WORKFLOW_ENGINE_VERSION, FLOW_SERVER_VERSION_130);
dto.getVariables().put(WORKFLOW_ENGINE_VERSION, serviceVersion);
dto.getVariables().put(PENDING_TEMPLATE_VARIABLE, dto.getPendingVariables());
dto.getVariables().put(INTERNAL_PROCESS_AGENT,
!Objects.isNull(definition) && StringUtils.isNotBlank(definition.getTenantId()));
@ -356,7 +355,7 @@ public class BpmnProcessInstanceServiceImpl implements BpmnProcessInstanceServic
@Override
public Boolean carbonCopyProcessInstance(BpmnProcessInstanceCarbonCopyDTO dto) {
// TODO 开发抄送功能, 还是通过事件, senna 去发送
// TODO 暴露给二方 API 的抄送功能, 需求被砍
CommandExecutor commandExecutor = springProcessEngineConfiguration.getCommandExecutor();
// commandExecutor.execute(new );
return null;

View File

@ -73,6 +73,8 @@ public class BpmnProcessModelServiceImpl implements BpmnProcessModelService {
private ExtAxReModelService extAxReModelService;
@Resource
private BpmnModelConverter bpmnModelConverter;
@Resource
private String serviceVersion;
@Override
public BpmPageResult<BpmnModelDetailVO> getModelPage(BpmnModelSearchDTO dto) {
@ -231,7 +233,8 @@ public class BpmnProcessModelServiceImpl implements BpmnProcessModelService {
dto.getDescription(),
dto.getJsonModel().getNoticeConf(),
dto.getJsonModel().getButtonConf(),
dto.getJsonModel().getFieldConf());
dto.getJsonModel().getFieldConf(),
serviceVersion);
BpmnJsonConverterUtil.setCategory(bpmnModel, dto.getCategory());
byte[] bpmn = BpmnJsonConverterUtil.transformBytes(bpmnModel);
processDefinitionService.updateProcessDefinition(model.getId(), bpmn);
@ -315,8 +318,11 @@ public class BpmnProcessModelServiceImpl implements BpmnProcessModelService {
BpmnModel bpmnModel = BpmnJsonConverterUtil.convertToBpmn(dto.getJsonModel().getNode(),
StringUtils.hasLength(dto.getKey()) ? dto.getKey() : dto.getCategory(),
dto.getName(),
dto.getDescription(), dto.getJsonModel().getNoticeConf(), dto.getJsonModel().getButtonConf(),
dto.getJsonModel().getFieldConf());
dto.getDescription(),
dto.getJsonModel().getNoticeConf(),
dto.getJsonModel().getButtonConf(),
dto.getJsonModel().getFieldConf(),
serviceVersion);
BpmnJsonConverterUtil.setCategory(bpmnModel, dto.getCategory());
byte[] bpmn = BpmnJsonConverterUtil.transformBytes(bpmnModel);
processDefinitionService.updateProcessDefinition(originModel.getId(), bpmn);