mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-02-03 12:14:57 +08:00
【代码优化】模型的 JSON 统一返回 string
This commit is contained in:
parent
f0103448b1
commit
9ccdd30643
@ -170,10 +170,10 @@ public class BpmModelServiceImpl implements BpmModelService {
|
|||||||
// 1.4 校验任务分配规则已配置
|
// 1.4 校验任务分配规则已配置
|
||||||
taskCandidateInvoker.validateBpmnConfig(bpmnBytes);
|
taskCandidateInvoker.validateBpmnConfig(bpmnBytes);
|
||||||
// 1.5 获取仿钉钉流程设计器模型数据
|
// 1.5 获取仿钉钉流程设计器模型数据
|
||||||
byte[] simpleBytes = getModelSimpleJson(model.getId());
|
String simpleJson = getModelSimpleJson(model.getId());
|
||||||
|
|
||||||
// 2.1 创建流程定义
|
// 2.1 创建流程定义
|
||||||
String definitionId = processDefinitionService.createProcessDefinition(model, metaInfo, bpmnBytes, simpleBytes, form);
|
String definitionId = processDefinitionService.createProcessDefinition(model, metaInfo, bpmnBytes, simpleJson, form);
|
||||||
|
|
||||||
// 2.2 将老的流程定义进行挂起。也就是说,只有最新部署的流程定义,才可以发起任务。
|
// 2.2 将老的流程定义进行挂起。也就是说,只有最新部署的流程定义,才可以发起任务。
|
||||||
updateProcessDefinitionSuspended(model.getDeploymentId());
|
updateProcessDefinitionSuspended(model.getDeploymentId());
|
||||||
@ -238,8 +238,8 @@ public class BpmModelServiceImpl implements BpmModelService {
|
|||||||
public BpmSimpleModelNodeVO getSimpleModel(String modelId) {
|
public BpmSimpleModelNodeVO getSimpleModel(String modelId) {
|
||||||
Model model = validateModelExists(modelId);
|
Model model = validateModelExists(modelId);
|
||||||
// 通过 ACT_RE_MODEL 表 EDITOR_SOURCE_EXTRA_VALUE_ID_ ,获取仿钉钉快搭模型的 JSON 数据
|
// 通过 ACT_RE_MODEL 表 EDITOR_SOURCE_EXTRA_VALUE_ID_ ,获取仿钉钉快搭模型的 JSON 数据
|
||||||
byte[] jsonBytes = getModelSimpleJson(model.getId());
|
String json = getModelSimpleJson(model.getId());
|
||||||
return JsonUtils.parseObject(jsonBytes, BpmSimpleModelNodeVO.class);
|
return JsonUtils.parseObject(json, BpmSimpleModelNodeVO.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -252,7 +252,7 @@ public class BpmModelServiceImpl implements BpmModelService {
|
|||||||
// 2.2 保存 Bpmn XML
|
// 2.2 保存 Bpmn XML
|
||||||
updateModelBpmnXml(model.getId(), BpmnModelUtils.getBpmnXml(bpmnModel));
|
updateModelBpmnXml(model.getId(), BpmnModelUtils.getBpmnXml(bpmnModel));
|
||||||
// 2.3 保存 JSON 数据
|
// 2.3 保存 JSON 数据
|
||||||
saveModelSimpleJson(model.getId(), JsonUtils.toJsonByte(reqVO.getSimpleModel()));
|
updateModelSimpleJson(model.getId(), reqVO.getSimpleModel());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -291,15 +291,21 @@ public class BpmModelServiceImpl implements BpmModelService {
|
|||||||
repositoryService.addModelEditorSource(id, StrUtil.utf8Bytes(bpmnXml));
|
repositoryService.addModelEditorSource(id, StrUtil.utf8Bytes(bpmnXml));
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] getModelSimpleJson(String id) {
|
@SuppressWarnings("JavaExistingMethodCanBeUsed")
|
||||||
return repositoryService.getModelEditorSourceExtra(id);
|
private String getModelSimpleJson(String id) {
|
||||||
|
byte[] bytes = repositoryService.getModelEditorSourceExtra(id);
|
||||||
|
if (ArrayUtil.isEmpty(bytes)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return StrUtil.utf8Str(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveModelSimpleJson(String id, byte[] jsonBytes) {
|
private void updateModelSimpleJson(String id, BpmSimpleModelNodeVO node) {
|
||||||
if (ArrayUtil.isEmpty(jsonBytes)) {
|
if (node == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
repositoryService.addModelEditorSourceExtra(id, jsonBytes);
|
byte[] bytes = JsonUtils.toJsonByte(node);
|
||||||
|
repositoryService.addModelEditorSourceExtra(id, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,12 +48,12 @@ public interface BpmProcessDefinitionService {
|
|||||||
* @param model 流程模型
|
* @param model 流程模型
|
||||||
* @param modelMetaInfo 流程模型元信息
|
* @param modelMetaInfo 流程模型元信息
|
||||||
* @param bpmnBytes BPMN XML 字节数组
|
* @param bpmnBytes BPMN XML 字节数组
|
||||||
* @param simpleBytes SIMPLE Model JSON 字节数组
|
* @param simpleJson SIMPLE Model JSON
|
||||||
* @param form 表单
|
* @param form 表单
|
||||||
* @return 流程编号
|
* @return 流程编号
|
||||||
*/
|
*/
|
||||||
String createProcessDefinition(Model model, BpmModelMetaInfoVO modelMetaInfo,
|
String createProcessDefinition(Model model, BpmModelMetaInfoVO modelMetaInfo,
|
||||||
byte[] bpmnBytes, byte[] simpleBytes, BpmFormDO form);
|
byte[] bpmnBytes, String simpleJson, BpmFormDO form);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新流程定义状态
|
* 更新流程定义状态
|
||||||
|
@ -24,7 +24,6 @@ import org.flowable.engine.repository.ProcessDefinitionQuery;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
@ -120,7 +119,7 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String createProcessDefinition(Model model, BpmModelMetaInfoVO modelMetaInfo,
|
public String createProcessDefinition(Model model, BpmModelMetaInfoVO modelMetaInfo,
|
||||||
byte[] bpmnBytes, byte[] simpleBytes, BpmFormDO form) {
|
byte[] bpmnBytes, String simpleJson, BpmFormDO form) {
|
||||||
// 创建 Deployment 部署
|
// 创建 Deployment 部署
|
||||||
Deployment deploy = repositoryService.createDeployment()
|
Deployment deploy = repositoryService.createDeployment()
|
||||||
.key(model.getKey()).name(model.getName()).category(model.getCategory())
|
.key(model.getKey()).name(model.getName()).category(model.getCategory())
|
||||||
@ -145,8 +144,8 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ
|
|||||||
|
|
||||||
// 插入拓展表
|
// 插入拓展表
|
||||||
BpmProcessDefinitionInfoDO definitionDO = BeanUtils.toBean(modelMetaInfo, BpmProcessDefinitionInfoDO.class)
|
BpmProcessDefinitionInfoDO definitionDO = BeanUtils.toBean(modelMetaInfo, BpmProcessDefinitionInfoDO.class)
|
||||||
.setModelId(model.getId()).setProcessDefinitionId(definition.getId()).setModelType(modelMetaInfo.getType())
|
.setModelId(model.getId()).setProcessDefinitionId(definition.getId())
|
||||||
.setSimpleModel(StrUtil.str(simpleBytes, StandardCharsets.UTF_8));
|
.setModelType(modelMetaInfo.getType()).setSimpleModel(simpleJson);
|
||||||
|
|
||||||
if (form != null) {
|
if (form != null) {
|
||||||
definitionDO.setFormFields(form.getFields()).setFormConf(form.getConf());
|
definitionDO.setFormFields(form.getFields()).setFormConf(form.getConf());
|
||||||
|
Loading…
Reference in New Issue
Block a user