From a83b6807d41a04e2452e07448cfa53b53f76b48d Mon Sep 17 00:00:00 2001 From: wangshaoping Date: Thu, 9 Jan 2025 18:17:54 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E6=9B=B4=E6=96=B0=E5=89=8D=E7=AB=AF=208.2?= =?UTF-8?q?.28=202.=20=E8=A7=84=E5=88=99=E5=BC=95=E6=93=8E=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E6=9E=9A=E4=B8=BE=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/shared/AutoCompletionManager.ts | 115 +++++-- .../AutoCompletionWebController.java | 32 -- .../ParameterAndValueTypeWebController.java | 2 - .../common/service/AutoCompletionService.java | 11 - .../impl/AutoCompletionServiceImpl.java | 323 ------------------ .../ParameterAndValueTypeServiceImpl.java | 10 +- .../common/service/support/Parameter.java | 2 +- .../common/service/support/Property.java | 2 +- 8 files changed, 88 insertions(+), 409 deletions(-) delete mode 100644 io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/common/controller/AutoCompletionWebController.java delete mode 100644 io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/common/service/AutoCompletionService.java delete mode 100644 io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/common/service/impl/AutoCompletionServiceImpl.java diff --git a/io.sc.engine.rule.frontend/src/views/shared/AutoCompletionManager.ts b/io.sc.engine.rule.frontend/src/views/shared/AutoCompletionManager.ts index bf9ceba1..df59ad56 100644 --- a/io.sc.engine.rule.frontend/src/views/shared/AutoCompletionManager.ts +++ b/io.sc.engine.rule.frontend/src/views/shared/AutoCompletionManager.ts @@ -1,5 +1,67 @@ import { axios, Tools } from 'platform-core'; +class ParameterMapping { + /** + * 显示顺序映射 + */ + static #Boost = { + //指标类型 + INTERFACE: 100, //接口 + INDICATOR: 100 - 1, //指标 + + // 参数类型 + CONSTANT: 100, //常量 + IN: 100 - 1, //输入 + IN_OPTION: 100 - 1, //输入(选项) + IN_SUB_OUT: 100 - 1, //输入(子模型输出) + INTERMEDIATE: 100 - 2, //中间值 + OUT: 100 - 2, //输出 + + // 元数据类型 + ENUM: 0, //枚举 + UD_JAVA_CLASS: 200 - 1, //自定义Java类 + }; + + /** + * 获取变量替换符前缀 + * @param type 类型 + * @returns 变量替换符前缀 + */ + public static getPlaceholderPrefix(type: string) { + if (type === 'ENUM') { + return '#'; + } else { + return '$'; + } + } + + /** + * 获取自动完成项的优先级, 数值越大越优先 + * @param type 类型 + * @returns 自动完成项的优先级 + */ + public static getBoost(type: string) { + return ParameterMapping.#Boost[type]; + } + + /** + * 获取自动完成项的类型 + * @param type 类型 + * @returns 自动完成项的类型 + */ + public static getAutoCompletionType(type: string) { + if (type === 'ENUM') { + return 'enum'; + } else if (type === 'CONSTANT') { + return 'constant'; + } else if (type === 'INDICATOR' || type === 'INTERMEDIATE' || type === 'OUT') { + return 'variable'; + } else { + return 'interface'; + } + } +} + class AutoCompletionManager { parameters: any; valueTypes: any; @@ -101,13 +163,20 @@ class AutoCompletionManager { } public getParameterOptions(): any { + const cache = {}; const options: any[] = []; Object.values(this.parameters).forEach((parameter: any) => { const option = this.getOptionItem(parameter); if (option) { - options.push(option); + if (!cache[option.label]) { + cache[option.label] = option; + options.push(option); + } } }); + for (const option of options) { + option.boost = ParameterMapping.getBoost(option.category); + } return options; } @@ -116,15 +185,13 @@ class AutoCompletionManager { if (!Tools.isNill(valueType)) { const version = valueType.version ? valueType.name + '(V' + valueType.version + ')' : valueType.name; const info = parameter.valueTypeIsList ? 'List<' + version + '>' : version; - if (parameter.type === 'parameter') { - if (parameter.valueTypeIsList) { - return { label: parameter.name, type: 'variable', apply: '${' + parameter.name + '}[0]', info: info }; - } else { - return { label: parameter.name, type: 'variable', apply: '${' + parameter.name + '}', info: info }; - } - } else if (parameter.type === 'enum') { - return { label: parameter.name, type: 'enum', apply: '#{' + parameter.name + '}', info: info }; - } + return { + category: parameter.type, + type: ParameterMapping.getAutoCompletionType(parameter.type), + label: parameter.name, + apply: ParameterMapping.getPlaceholderPrefix(parameter.type) + '{' + parameter.name + '}' + (parameter.valueTypeIsList ? '[0]' : ''), + info: info, + }; } return null; } @@ -151,32 +218,6 @@ class AutoCompletionManager { if (Tools.isUndefinedOrNull(parameterName)) { return null; } - - /* - const enumRegReverse = /(\.(\](.+?)\[)?\}(.+?)\{#)+/g; //匹配 '.]n[}xxx{#' 模式 - // -- -- --- -- -- --- ---- - // . ] n [ } xxx {# - let matcheds: any = matchedTextReverse.match(enumRegReverse); - if (Tools.isUndefinedOrNull(matcheds) || matcheds.length <= 0) { - const regReverse = /(\.(\](.+?)\[)?\}(.+?)\{\$)+/g; //匹配 '.]n[}xxx{$' 模式 - // -- -- --- -- -- --- ---- - // . ] n [ } xxx {$ - matcheds = matchedTextReverse.match(regReverse); - if (Tools.isUndefinedOrNull(matcheds) || matcheds.length <= 0) { - return null; - } - } - const matched = Tools.reverseString(matcheds[0]); - let parameterName = matched.replace(/#\{(.+?)\}(\[(.+?)\])?/g, '$1'); - // ---- --- -- -- --- -- - // $ { xxx } [ n ] - if (Tools.isUndefinedOrNull(parameterName)) { - parameterName = matched.replace(/\$\{(.+?)\}(\[(.+?)\])?/g, '$1'); - if (Tools.isUndefinedOrNull(parameterName)) { - return null; - } - } - */ const options = this.getOptions(parameterName); if (Tools.isUndefinedOrNull(options)) { return null; @@ -206,7 +247,7 @@ class AutoCompletionManager { } public load(url: string) { - axios.get(url).then((response) => { + axios.get(url).then((response: any) => { this.setParameters(response.data?.parameters); this.setValueTypes(response.data?.valueTypes); }); diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/common/controller/AutoCompletionWebController.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/common/controller/AutoCompletionWebController.java deleted file mode 100644 index 4065bd53..00000000 --- a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/common/controller/AutoCompletionWebController.java +++ /dev/null @@ -1,32 +0,0 @@ -package io.sc.engine.rule.server.common.controller; - -import io.sc.engine.rule.server.common.service.AutoCompletionService; -import io.sc.engine.rule.server.common.service.support.AutoCompletion; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.Locale; - -@RestController("io.sc.engine.rule.server.common.controller.AutoCompletionWebController") -@RequestMapping("/api/re/common") -public class AutoCompletionWebController { - @Autowired private AutoCompletionService service; - - @GetMapping("autoCompletionByParameterId/{parameterId}") - public AutoCompletion autoCompletionByParameterId(@PathVariable(name="parameterId",required=true)String parameterId, Locale locale) throws Exception{ - return service.autoCompletionByParameterId(parameterId,locale); - } - - @GetMapping("autoCompletionByIndicatorId/{indicatorId}") - public AutoCompletion autoCompletionByIndicatorId(@PathVariable(name="indicatorId",required=true)String indicatorId, Locale locale) throws Exception{ - return service.autoCompletionByIndicatorId(indicatorId,locale); - } - - @GetMapping("autoCompletionByDictionaryId/{dictionaryId}") - public AutoCompletion autoCompletionByDictionaryId(@PathVariable(name="dictionaryId",required=true)String dictionaryId, Locale locale) throws Exception{ - return service.autoCompletionByDictionaryId(dictionaryId,locale); - } -} diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/common/controller/ParameterAndValueTypeWebController.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/common/controller/ParameterAndValueTypeWebController.java index e6f4cc37..4961f3bd 100644 --- a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/common/controller/ParameterAndValueTypeWebController.java +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/common/controller/ParameterAndValueTypeWebController.java @@ -1,8 +1,6 @@ package io.sc.engine.rule.server.common.controller; -import io.sc.engine.rule.server.common.service.AutoCompletionService; import io.sc.engine.rule.server.common.service.ParameterAndValueTypeService; -import io.sc.engine.rule.server.common.service.support.AutoCompletion; import io.sc.engine.rule.server.common.service.support.ParameterAndValueType; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/common/service/AutoCompletionService.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/common/service/AutoCompletionService.java deleted file mode 100644 index 16fa0785..00000000 --- a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/common/service/AutoCompletionService.java +++ /dev/null @@ -1,11 +0,0 @@ -package io.sc.engine.rule.server.common.service; - -import io.sc.engine.rule.server.common.service.support.AutoCompletion; - -import java.util.Locale; - -public interface AutoCompletionService { - public AutoCompletion autoCompletionByParameterId(String parameterId, Locale locale) throws Exception; - public AutoCompletion autoCompletionByIndicatorId(String indicatorId, Locale locale) throws Exception; - public AutoCompletion autoCompletionByDictionaryId(String dictionaryId, Locale locale) throws Exception; -} diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/common/service/impl/AutoCompletionServiceImpl.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/common/service/impl/AutoCompletionServiceImpl.java deleted file mode 100644 index 786374c9..00000000 --- a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/common/service/impl/AutoCompletionServiceImpl.java +++ /dev/null @@ -1,323 +0,0 @@ -package io.sc.engine.rule.server.common.service.impl; - -import io.sc.engine.rule.core.enums.DictionaryType; -import io.sc.engine.rule.core.enums.EnumDictionaryItemValueType; -import io.sc.engine.rule.core.util.IdReplacer; -import io.sc.engine.rule.core.util.ValueTypeUtil; -import io.sc.engine.rule.server.common.service.AutoCompletionService; -import io.sc.engine.rule.server.common.service.DictionaryItemPluginsService; -import io.sc.engine.rule.server.common.service.support.*; -import io.sc.engine.rule.server.dictionary.entity.*; -import io.sc.engine.rule.server.dictionary.service.DictionaryService; -import io.sc.engine.rule.server.lib.entity.IndicatorEntity; -import io.sc.engine.rule.server.lib.entity.IndicatorLibEntity; -import io.sc.engine.rule.server.lib.service.IndicatorService; -import io.sc.engine.rule.server.lib.service.LibService; -import io.sc.engine.rule.server.model.entity.ModelEntity; -import io.sc.engine.rule.server.model.entity.ParameterEntity; -import io.sc.engine.rule.server.model.entity.parameter.OutParameterEntity; -import io.sc.engine.rule.server.model.service.ParameterProcessorService; -import io.sc.engine.rule.server.model.service.ParameterService; -import io.sc.engine.rule.server.common.plugins.item.DictionaryItem; -import io.sc.platform.util.CollectionUtil; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.MessageSource; -import org.springframework.stereotype.Service; -import org.springframework.util.StringUtils; - -import java.lang.reflect.Field; -import java.util.List; -import java.util.Locale; - -@Service("io.sc.engine.rule.server.common.service.impl.AutoCompletionServiceImpl") -public class AutoCompletionServiceImpl implements AutoCompletionService { - @Autowired private ParameterProcessorService parameterProcessorService; - @Autowired private ParameterService parameterService; - @Autowired private LibService libService; - @Autowired private IndicatorService indicatorService; - @Autowired private DictionaryService dictionaryService; - @Autowired private MessageSource messageSource; - @Autowired private DictionaryItemPluginsService dictionaryItemPluginsService; - - @Override - public AutoCompletion autoCompletionByParameterId(String parameterId, Locale locale) throws Exception { - if(!StringUtils.hasText(parameterId)){ - return null; - } - ParameterEntity parameterEntity =parameterService.findById(parameterId); - if(parameterEntity==null){ - return null; - } - ModelEntity modelEntity =parameterEntity.getModel(); - if(modelEntity==null){ - return null; - } - AutoCompletion autoCompletion =new AutoCompletion(); - buildEnumParameters(autoCompletion); - buildEnumValueTypes(autoCompletion); - buildAutoCompletion(autoCompletion,modelEntity,locale); - return autoCompletion; - } - - @Override - public AutoCompletion autoCompletionByIndicatorId(String indicatorId, Locale locale) throws Exception { - if(!StringUtils.hasText(indicatorId)){ - return null; - } - IndicatorLibEntity indicatorLibEntity =libService.findByIndicatorId(indicatorId); - if(indicatorLibEntity==null){ - return null; - } - AutoCompletion autoCompletion =new AutoCompletion(); - buildEnumParameters(autoCompletion); - buildEnumValueTypes(autoCompletion); - buildAutoCompletion(autoCompletion,indicatorLibEntity,locale); - return autoCompletion; - } - - @Override - public AutoCompletion autoCompletionByDictionaryId(String dictionaryId, Locale locale) throws Exception { - if(!StringUtils.hasText(dictionaryId)){ - return null; - } - UserDefinedJavaClassDictionaryEntity dictionaryEntity =dictionaryService.getRepository().findUserDefinedJavaClassDictionaryEntityById(dictionaryId); - if(dictionaryEntity==null){ - return null; - } - AutoCompletion autoCompletion =new AutoCompletion(); - buildEnumParameters(autoCompletion); - buildEnumValueTypes(autoCompletion); - buildAutoCompletion(autoCompletion,dictionaryEntity,locale); - return autoCompletion; - } - - private void buildAutoCompletion(AutoCompletion autoCompletion,ModelEntity modelEntity, Locale locale) throws Exception{ - //子模型结果值参数作为本模型输入值参数 - List subModelOutParameters =parameterService.findOutParameterEntitiesOfSubModels(modelEntity.getId()); - if(subModelOutParameters!=null && subModelOutParameters.size()>0) { - for(OutParameterEntity entity : subModelOutParameters) { - Parameter parameter =new Parameter(); - parameter.setCode(entity.getCode()); - parameter.setName(entity.getName()); - parameter.setValueType(entity.getValueType()); - parameter.setValueTypeVersion(entity.getValueTypeVersion()); - parameter.setValueTypeIsList(entity.getValueTypeIsList()); - autoCompletion.addParameter(parameter); - buildValueType(autoCompletion,entity.getValueType(),entity.getValueTypeVersion(),locale); - } - } - //本模型其他参数 - List parameterEntities =modelEntity.getParameters(); - if(parameterEntities!=null && parameterEntities.size()>0) { - for(ParameterEntity entity : parameterEntities) { - Parameter parameter =new Parameter(); - parameter.setCode(entity.getCode()); - parameter.setName(entity.getName()); - parameter.setValueType(entity.getValueType()); - parameter.setValueTypeVersion(entity.getValueTypeVersion()); - parameter.setValueTypeIsList(entity.getValueTypeIsList()); - autoCompletion.addParameter(parameter); - buildValueType(autoCompletion,entity.getValueType(),entity.getValueTypeVersion(),locale); - } - } - //父模型参数 - ModelEntity parentModelEntity =modelEntity.getParent(); - while(parentModelEntity!=null){ - List parentParameterEntities =parentModelEntity.getParameters(); - if(CollectionUtil.hasElements(parentParameterEntities)){ - for(ParameterEntity entity : parentParameterEntities) { - switch(entity.getType()) { - case CONSTANT: - case IN_OPTION: - case IN: - case INDICATOR: - Parameter parameter =new Parameter(); - parameter.setCode(entity.getCode()); - parameter.setName(entity.getName()); - parameter.setValueType(entity.getValueType()); - parameter.setValueTypeVersion(entity.getValueTypeVersion()); - parameter.setValueTypeIsList(entity.getValueTypeIsList()); - autoCompletion.addParameter(parameter); - buildValueType(autoCompletion,entity.getValueType(),entity.getValueTypeVersion(),locale); - break; - default: - } - } - } - parentModelEntity =parentModelEntity.getParent(); - } - } - - private void buildAutoCompletion(AutoCompletion autoCompletion,IndicatorLibEntity indicatorLibEntity, Locale locale) throws Exception{ - if(indicatorLibEntity==null){ - return; - } - List indicators =indicatorLibEntity.getIndicators(); - if(indicators==null || indicators.isEmpty()){ - return; - } - for(IndicatorEntity entity : indicators) { - Parameter parameter =new Parameter(); - parameter.setCode(entity.getCode()); - parameter.setName(entity.getName()); - parameter.setValueType(entity.getValueType()); - parameter.setValueTypeVersion(entity.getValueTypeVersion()); - parameter.setValueTypeIsList(entity.getValueTypeIsList()); - autoCompletion.addParameter(parameter); - buildValueType(autoCompletion,entity.getValueType(),entity.getValueTypeVersion(),locale); - } - } - - private void buildAutoCompletion(AutoCompletion autoCompletion,UserDefinedJavaClassDictionaryEntity dictionaryEntity, Locale locale) throws Exception{ - if(dictionaryEntity==null){ - return; - } - List fields =dictionaryEntity.getFields(); - if(fields==null || fields.isEmpty()){ - return; - } - for(UserDefinedJavaClassFieldEntity entity : fields) { - Parameter parameter =new Parameter(); - parameter.setCode(entity.getCode()); - parameter.setName(entity.getName()); - parameter.setValueType(entity.getValueType()); - parameter.setValueTypeVersion(entity.getValueTypeVersion()); - parameter.setValueTypeIsList(entity.getValueTypeIsList()); - autoCompletion.addParameter(parameter); - buildValueType(autoCompletion,entity.getValueType(),entity.getValueTypeVersion(),locale); - } - } - - private void buildValueType(AutoCompletion autoCompletion,String valueTypeCode, Integer valueTypeVersion, Locale locale) throws Exception{ - if(dictionaryItemPluginsService.contains(valueTypeCode)){ - // 引擎内置类型 - DictionaryItem item =dictionaryItemPluginsService.getByCode(valueTypeCode); - if(DictionaryType.JAVA_CLASS.equals(item.getType())){ - buildJavaClassValueTypes(autoCompletion,item.getCode(),item.getCode(),messageSource.getMessage(item.getCode(),null,locale),item.getVersion(),locale); - } - }else{ - // 用户自定义结构体 - DictionaryEntity dictionaryEntity =dictionaryService.findDictionaryByCodeAndVersion(valueTypeCode,valueTypeVersion); - if(dictionaryEntity!=null && dictionaryEntity instanceof UserDefinedJavaClassDictionaryEntity){ - UserDefinedJavaClassDictionaryEntity userDefinedJavaClassDictionaryEntity =(UserDefinedJavaClassDictionaryEntity)dictionaryEntity; - ValueType valueType =new ValueType(); - valueType.setCode(userDefinedJavaClassDictionaryEntity.getCode()); - valueType.setName(userDefinedJavaClassDictionaryEntity.getName()); - valueType.setVersion(userDefinedJavaClassDictionaryEntity.getVersion()); - List fieldEntities =userDefinedJavaClassDictionaryEntity.getFields(); - if(CollectionUtil.hasElements(fieldEntities)){ - for(UserDefinedJavaClassFieldEntity fieldEntity : fieldEntities){ - Property property =new Property(); - property.setCode(fieldEntity.getCode()); - property.setName(fieldEntity.getName()); - property.setValueType(fieldEntity.getValueType()); - property.setValueTypeVersion(fieldEntity.getValueTypeVersion()); - valueType.addProperty(property); - buildValueType(autoCompletion, property.getValueType(), property.getValueTypeVersion(), locale); - } - } - autoCompletion.addValueType(valueType); - } - } - } - - private void buildEnumParameters(AutoCompletion autoCompletion){ - List enumDictionaryEntities =dictionaryService.getRepository().findAllEnumDictionaryEntities(); - if(CollectionUtil.hasElements(enumDictionaryEntities)){ - for(EnumDictionaryEntity enumDictionary : enumDictionaryEntities){ - Parameter parameter =new Parameter(); - parameter.setCode(IdReplacer.className(enumDictionary.getCode(),enumDictionary.getVersion())); - parameter.setName(enumDictionary.getName()); - parameter.setType("enum"); - parameter.setValueType(enumDictionary.getCode()); - parameter.setValueTypeVersion(enumDictionary.getVersion()); - parameter.setValueTypeIsList(false); - autoCompletion.addParameter(parameter); - } - } - } - - private void buildEnumValueTypes(AutoCompletion autoCompletion){ - List enumDictionaryEntities =dictionaryService.getRepository().findAllEnumDictionaryEntities(); - if(CollectionUtil.hasElements(enumDictionaryEntities)){ - for(EnumDictionaryEntity enumDictionary : enumDictionaryEntities){ - ValueType valueType =new ValueType(); - valueType.setCode(enumDictionary.getCode()); - valueType.setName(enumDictionary.getName()); - valueType.setVersion(enumDictionary.getVersion()); - List items =enumDictionary.getItems(); - if(CollectionUtil.hasElements(items)){ - for(EnumItemEntity item : items){ - Property property =new Property(); - property.setCode(item.getCode()); - property.setName(item.getName()); - property.setType("enum"); - if(EnumDictionaryItemValueType.STRING.equals(item.getValueType())){ - property.setValueType("java.lang.String"); - }else if(EnumDictionaryItemValueType.INTEGER.equals(item.getValueType())){ - property.setValueType("java.lang.Long"); - }else if(EnumDictionaryItemValueType.DECIMAL.equals(item.getValueType())){ - property.setValueType("java.math.BigDecimal"); - } - valueType.addProperty(property); - } - } - autoCompletion.addValueType(valueType); - } - } - } - - private void buildJavaClassValueTypes(AutoCompletion autoCompletion,String className,String valueTypeCode, String valueTypeName,Integer valueTypeVersion,Locale locale) throws Exception { - Class clazz =Class.forName(className); - buildJavaClassValueTypes(autoCompletion,clazz,valueTypeCode,valueTypeName,valueTypeVersion,locale); - } - - private void buildJavaClassValueTypes(AutoCompletion autoCompletion,Class clazz,String valueTypeCode, String valueTypeName,Integer valueTypeVersion,Locale locale) throws Exception { - if(ValueTypeUtil.isBase(clazz) || ValueTypeUtil.isEnum(clazz)) { - ValueType valueType =new ValueType(); - valueType.setCode(clazz.getName()); - valueType.setName(messageSource.getMessage(clazz.getName(),null,locale)); - valueType.setVersion(null); - autoCompletion.addValueType(valueType); - return; - } - ValueType valueType =new ValueType(); - valueType.setCode(StringUtils.hasText(valueTypeCode)?valueTypeCode:clazz.getName()); - valueType.setName(StringUtils.hasText(valueTypeName)?valueTypeName:messageSource.getMessage(clazz.getName(), new Object[]{}, clazz.getName(), locale)); - valueType.setVersion(valueTypeVersion); - autoCompletion.addValueType(valueType); - - Field[] fields =clazz.getDeclaredFields(); - for(Field field : fields){ - Class fieldTypeClass =field.getType(); - Property property = new Property(); - if(ValueTypeUtil.isBase(fieldTypeClass)) { - property.setCode(field.getName()); - String nameI18nKey =clazz.getPackage().getName() + "." + clazz.getSimpleName() + "." + field.getName(); - String name=messageSource.getMessage(nameI18nKey, new Object[]{}, nameI18nKey, locale); - property.setName(name); - property.setValueType(fieldTypeClass.getName()); - property.setValueTypeVersion(null); - }else if(ValueTypeUtil.isList(fieldTypeClass)){ - Class elementClass =CollectionUtil.getListElementJavaType(field.getGenericType()); - property.setCode(field.getName()); - String nameI18nKey =clazz.getPackage().getName() + "." + elementClass.getSimpleName(); - String name=messageSource.getMessage(nameI18nKey, new Object[]{}, nameI18nKey, locale); - property.setName(name); - property.setValueType(elementClass.getName()); - property.setValueTypeVersion(valueTypeVersion); - property.setValueTypeIsList(true); - buildJavaClassValueTypes(autoCompletion,elementClass,null,null,valueTypeVersion,locale); - }else{ - property.setCode(field.getName()); - String nameI18nKey =fieldTypeClass.getPackage().getName() + "." + fieldTypeClass.getSimpleName(); - String name=messageSource.getMessage(nameI18nKey, new Object[]{}, nameI18nKey, locale); - property.setName(name); - property.setValueType(fieldTypeClass.getName()); - property.setValueTypeVersion(valueTypeVersion); - } - valueType.addProperty(property); - buildJavaClassValueTypes(autoCompletion,fieldTypeClass,null,null,valueTypeVersion,locale); - } - } -} diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/common/service/impl/ParameterAndValueTypeServiceImpl.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/common/service/impl/ParameterAndValueTypeServiceImpl.java index 3c194f1f..bc56a769 100644 --- a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/common/service/impl/ParameterAndValueTypeServiceImpl.java +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/common/service/impl/ParameterAndValueTypeServiceImpl.java @@ -2,6 +2,7 @@ package io.sc.engine.rule.server.common.service.impl; import io.sc.engine.rule.core.enums.DictionaryType; import io.sc.engine.rule.core.enums.EnumDictionaryItemValueType; +import io.sc.engine.rule.core.enums.ParameterType; import io.sc.engine.rule.core.util.IdReplacer; import io.sc.engine.rule.core.util.ValueTypeUtil; import io.sc.engine.rule.server.common.plugins.item.DictionaryItem; @@ -110,6 +111,7 @@ public class ParameterAndValueTypeServiceImpl implements ParameterAndValueTypeSe Parameter parameter =new Parameter(); parameter.setCode(entity.getCode()); parameter.setName(entity.getName()); + parameter.setType(ParameterType.IN_SUB_OUT.toString()); parameter.setValueType(entity.getValueType()); parameter.setValueTypeVersion(entity.getValueTypeVersion()); parameter.setValueTypeIsList(entity.getValueTypeIsList()); @@ -125,6 +127,7 @@ public class ParameterAndValueTypeServiceImpl implements ParameterAndValueTypeSe Parameter parameter =new Parameter(); parameter.setCode(entity.getCode()); parameter.setName(entity.getName()); + parameter.setType(entity.getType().toString()); parameter.setValueType(entity.getValueType()); parameter.setValueTypeVersion(entity.getValueTypeVersion()); parameter.setValueTypeIsList(entity.getValueTypeIsList()); @@ -146,6 +149,7 @@ public class ParameterAndValueTypeServiceImpl implements ParameterAndValueTypeSe Parameter parameter =new Parameter(); parameter.setCode(entity.getCode()); parameter.setName(entity.getName()); + parameter.setType(entity.getType().toString()); parameter.setValueType(entity.getValueType()); parameter.setValueTypeVersion(entity.getValueTypeVersion()); parameter.setValueTypeIsList(entity.getValueTypeIsList()); @@ -172,6 +176,7 @@ public class ParameterAndValueTypeServiceImpl implements ParameterAndValueTypeSe Parameter parameter =new Parameter(); parameter.setCode(entity.getCode()); parameter.setName(entity.getName()); + parameter.setType(entity.getType().toString()); parameter.setValueType(entity.getValueType()); parameter.setValueTypeVersion(entity.getValueTypeVersion()); parameter.setValueTypeIsList(entity.getValueTypeIsList()); @@ -188,6 +193,7 @@ public class ParameterAndValueTypeServiceImpl implements ParameterAndValueTypeSe Parameter parameter =new Parameter(); parameter.setCode(entity.getCode()); parameter.setName(entity.getName()); + parameter.setType(DictionaryType.UD_JAVA_CLASS.toString()); parameter.setValueType(entity.getValueType()); parameter.setValueTypeVersion(entity.getValueTypeVersion()); parameter.setValueTypeIsList(entity.getValueTypeIsList()); @@ -205,7 +211,7 @@ public class ParameterAndValueTypeServiceImpl implements ParameterAndValueTypeSe Parameter parameter =new Parameter(); parameter.setCode(IdReplacer.className(enumDictionary.getCode(),enumDictionary.getVersion())); parameter.setName(enumDictionary.getName()); - parameter.setType("enum"); + parameter.setType(DictionaryType.ENUM.toString()); parameter.setValueType(enumDictionary.getCode()); parameter.setValueTypeVersion(enumDictionary.getVersion()); parameter.setValueTypeIsList(false); @@ -224,7 +230,7 @@ public class ParameterAndValueTypeServiceImpl implements ParameterAndValueTypeSe Property property =new Property(); property.setCode(item.getCode()); property.setName(item.getName()); - property.setType("enum"); + property.setType("ENUM"); if(EnumDictionaryItemValueType.STRING.equals(item.getValueType())){ property.setValueType("java.lang.String"); }else if(EnumDictionaryItemValueType.INTEGER.equals(item.getValueType())){ diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/common/service/support/Parameter.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/common/service/support/Parameter.java index f10e138f..a48c0ba1 100644 --- a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/common/service/support/Parameter.java +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/common/service/support/Parameter.java @@ -3,7 +3,7 @@ package io.sc.engine.rule.server.common.service.support; public class Parameter { private String code; private String name; - private String type ="parameter"; + private String type ="variable"; private String valueType; private Integer valueTypeVersion; private Boolean valueTypeIsList =false; diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/common/service/support/Property.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/common/service/support/Property.java index 6c725417..0c02fcdc 100644 --- a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/common/service/support/Property.java +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/common/service/support/Property.java @@ -3,7 +3,7 @@ package io.sc.engine.rule.server.common.service.support; public class Property { private String code; private String name; - private String type ="parameter"; + private String type; private String valueType; private Integer valueTypeVersion; private Boolean valueTypeIsList =false;