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