diff --git a/src/main/java/neatlogic/module/autoexec/api/job/AutoexecJobRunTimeParamGetApi.java b/src/main/java/neatlogic/module/autoexec/api/job/AutoexecJobRunTimeParamGetApi.java index 55d0f249b214bb77b9697b8043d18ee8d7cdb9fc..0afe82a623a2dee10396a91f43cd5837f75bf541 100644 --- a/src/main/java/neatlogic/module/autoexec/api/job/AutoexecJobRunTimeParamGetApi.java +++ b/src/main/java/neatlogic/module/autoexec/api/job/AutoexecJobRunTimeParamGetApi.java @@ -78,15 +78,16 @@ public class AutoexecJobRunTimeParamGetApi extends PrivateApiComponentBase { JSONArray runTimeParam = JSONObject.parseArray(paramContentVo.getContent()); //集成数据特殊处理,截取text for (int i = 0; i < runTimeParam.size(); i++) { - String value = runTimeParam.getJSONObject(i).getString("value"); - String defaultValue = runTimeParam.getJSONObject(i).getString("defaultValue"); + Object value = runTimeParam.getJSONObject(i).get("value"); + Object defaultValue = runTimeParam.getJSONObject(i).get("defaultValue"); String type = runTimeParam.getJSONObject(i).getString("type"); - if (StringUtils.isNotBlank(type) && StringUtils.isNotBlank(value)) { + if (StringUtils.isNotBlank(type) && value != null) { IScriptParamType paramType = ScriptParamTypeFactory.getHandler(type); if (paramType != null) { - runTimeParam.getJSONObject(i).put("value", paramType.getTextByValue(value)); - if (StringUtils.isNotBlank(defaultValue)) { - runTimeParam.getJSONObject(i).put("defaultValue", paramType.getTextByValue(defaultValue)); + JSONObject config = runTimeParam.getJSONObject(i).getJSONObject("config"); + runTimeParam.getJSONObject(i).put("value", paramType.getTextByValue(value, config)); + if (defaultValue != null) { + runTimeParam.getJSONObject(i).put("defaultValue", paramType.getTextByValue(defaultValue, config)); } } } diff --git a/src/main/java/neatlogic/module/autoexec/api/service/CreateAutoexecServiceJobApi.java b/src/main/java/neatlogic/module/autoexec/api/service/CreateAutoexecServiceJobApi.java index 8df2195339952a565fd2024dcfc73e09a1bbe7d7..23489676095508652c5acecb836c476d894558d5 100644 --- a/src/main/java/neatlogic/module/autoexec/api/service/CreateAutoexecServiceJobApi.java +++ b/src/main/java/neatlogic/module/autoexec/api/service/CreateAutoexecServiceJobApi.java @@ -36,13 +36,16 @@ import neatlogic.framework.autoexec.exception.AutoexecJobParamNotExistException; import neatlogic.framework.autoexec.exception.AutoexecServiceConfigExpiredException; import neatlogic.framework.autoexec.exception.AutoexecServiceNotFoundException; import neatlogic.framework.common.constvalue.ApiParamType; +import neatlogic.framework.crossover.CrossoverServiceFactory; import neatlogic.framework.dto.AuthenticationInfoVo; import neatlogic.framework.exception.type.ParamNotExistsException; import neatlogic.framework.exception.type.PermissionDeniedException; +import neatlogic.framework.form.constvalue.FormHandler; import neatlogic.framework.form.dao.mapper.FormMapper; import neatlogic.framework.form.dto.FormAttributeVo; import neatlogic.framework.form.dto.FormVersionVo; import neatlogic.framework.form.exception.FormAttributeRequiredException; +import neatlogic.framework.form.service.IFormCrossoverService; import neatlogic.framework.restful.annotation.*; import neatlogic.framework.restful.constvalue.OperationTypeEnum; import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; @@ -190,10 +193,12 @@ public class CreateAutoexecServiceJobApi extends PrivateApiComponentBase { } formAttributeDataMap.put(attributeUuid, dataList); } + Map attributeUuid2HandlerMap = new HashMap<>(); FormVersionVo formVersionVo = formMapper.getActionFormVersionByFormUuid(formUuid); List formAttributeVoList = formVersionVo.getFormAttributeList(); for (FormAttributeVo formAttributeVo : formAttributeVoList) { String uuid = formAttributeVo.getUuid(); + attributeUuid2HandlerMap.put(uuid, formAttributeVo.getHandler()); if (formAttributeVo.isRequired()) { if (hidecomponentList.contains(uuid)) { continue; @@ -204,6 +209,10 @@ public class CreateAutoexecServiceJobApi extends PrivateApiComponentBase { throw new FormAttributeRequiredException(formAttributeVo.getLabel()); } } + List formSelectAttributeList = new ArrayList<>(); + formSelectAttributeList.add(FormHandler.FORMSELECT.getHandler()); + formSelectAttributeList.add(FormHandler.FORMCHECKBOX.getHandler()); + formSelectAttributeList.add(FormHandler.FORMRADIO.getHandler()); if (config != null) { ParamMappingVo roundCountParamMappingVo = config.getRoundCount(); if (needRoundCount && roundCountParamMappingVo != null) { @@ -277,7 +286,13 @@ public class CreateAutoexecServiceJobApi extends PrivateApiComponentBase { } else if (Objects.equals(paramMappingVo.getMappingMode(), ServiceParamMappingMode.FORMATTR.getValue())) { Object formAttrValue = formAttributeDataMap.get(value); if (formAttrValue != null) { - param.put(key, formAttrValue); + if (formSelectAttributeList.contains(attributeUuid2HandlerMap.get(value))) { + IFormCrossoverService formCrossoverService = CrossoverServiceFactory.getApi(IFormCrossoverService.class); + Object valueObject = formCrossoverService.getFormSelectAttributeValueByOriginalValue(formAttrValue); + param.put(key, valueObject); + } else { + param.put(key, formAttrValue); + } } } } diff --git a/src/main/java/neatlogic/module/autoexec/api/tool/ExportAutoexecToolParamApi.java b/src/main/java/neatlogic/module/autoexec/api/tool/ExportAutoexecToolParamApi.java index a2af45a65ac1f93fb1fd289851aa6b25c619de87..6fb90a3ce7a6fd72134e103f5ae8a505a73bae6f 100644 --- a/src/main/java/neatlogic/module/autoexec/api/tool/ExportAutoexecToolParamApi.java +++ b/src/main/java/neatlogic/module/autoexec/api/tool/ExportAutoexecToolParamApi.java @@ -15,9 +15,10 @@ */ package neatlogic.module.autoexec.api.tool; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import neatlogic.framework.auth.core.AuthAction; import neatlogic.framework.autoexec.auth.AUTOEXEC_BASE; -import neatlogic.framework.autoexec.constvalue.ParamDataSource; import neatlogic.framework.autoexec.constvalue.ParamType; import neatlogic.framework.autoexec.dao.mapper.AutoexecToolMapper; import neatlogic.framework.autoexec.dto.AutoexecParamConfigVo; @@ -27,17 +28,15 @@ import neatlogic.framework.autoexec.dto.profile.AutoexecProfileParamVo; import neatlogic.framework.autoexec.dto.profile.AutoexecProfileVo; import neatlogic.framework.autoexec.exception.AutoexecToolExportNotFoundToolException; import neatlogic.framework.autoexec.exception.AutoexecToolNotFoundException; +import neatlogic.framework.autoexec.script.paramtype.IScriptParamType; +import neatlogic.framework.autoexec.script.paramtype.ScriptParamTypeFactory; import neatlogic.framework.cmdb.crossover.IResourceAccountCrossoverMapper; import neatlogic.framework.cmdb.dto.resourcecenter.AccountVo; import neatlogic.framework.cmdb.dto.resourcecenter.ResourceVo; import neatlogic.framework.common.constvalue.ApiParamType; -import neatlogic.framework.common.dto.ValueTextVo; import neatlogic.framework.crossover.CrossoverServiceFactory; import neatlogic.framework.exception.type.ParamNotExistsException; import neatlogic.framework.file.dto.FileVo; -import neatlogic.framework.matrix.core.MatrixPrivateDataSourceHandlerFactory; -import neatlogic.framework.matrix.dao.mapper.MatrixMapper; -import neatlogic.framework.matrix.dto.MatrixVo; import neatlogic.framework.restful.annotation.Description; import neatlogic.framework.restful.annotation.Input; import neatlogic.framework.restful.annotation.OperationType; @@ -50,8 +49,6 @@ import neatlogic.framework.util.word.enums.FontFamily; import neatlogic.framework.util.word.enums.TableColor; import neatlogic.framework.util.word.enums.TitleType; import neatlogic.module.autoexec.dao.mapper.AutoexecProfileMapper; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; @@ -83,9 +80,6 @@ public class ExportAutoexecToolParamApi extends PrivateBinaryStreamApiComponentB @Resource private AutoexecProfileMapper autoexecProfileMapper; - @Resource - private MatrixMapper matrixMapper; - @Override public String getName() { return "导出工具库工具参数"; @@ -234,85 +228,36 @@ public class ExportAutoexecToolParamApi extends PrivateBinaryStreamApiComponentB if (config == null) { return returnDefaultValue; } - String dataSource = config.getDataSource(); - //静态数据源 - if (StringUtils.equals(ParamDataSource.STATIC.getValue(), dataSource)) { - if (paramDefaultValue != null && !Objects.equals(paramDefaultValue.toString(), "")) { - JSONArray dataArray = config.getDataList(); - if (CollectionUtils.isNotEmpty(dataArray)) { - List valueTextVoList = dataArray.toJavaList(ValueTextVo.class); - Map valueTextMap = valueTextVoList.stream().collect(Collectors.toMap(ValueTextVo::getValue, ValueTextVo::getText)); - returnDefaultValue.append(" ").append(valueTextMap.get(paramDefaultValue)); - } - } - //矩阵数据源 - } else if (StringUtils.equals(ParamDataSource.MATRIX.getValue(), dataSource)) { - String matrixUuid = config.getMatrixUuid(); - if (StringUtils.isNotBlank(matrixUuid)) { - MatrixVo matrixVo = matrixMapper.getMatrixByUuid(matrixUuid); - if (matrixVo == null) { - matrixVo = MatrixPrivateDataSourceHandlerFactory.getMatrixVo(matrixUuid); - } - if (matrixVo != null) { - returnDefaultValue = new StringBuilder(matrixVo.getName()); - if (paramDefaultValue != null) { - String valueString = String.valueOf(paramDefaultValue); - returnDefaultValue.append(" ").append(valueString.substring(valueString.substring(0, valueString.indexOf("&=&")).length() + 3)); - } - } + IScriptParamType paramType = ScriptParamTypeFactory.getHandler(paramVo.getType()); + if (paramType != null) { + Object text = paramType.getTextByValue(paramDefaultValue, JSONObject.parseObject(JSONObject.toJSONString(config))).toString(); + if (text != null) { + returnDefaultValue.append(" ").append(text); } } - //复选、多选下拉 } else if (StringUtils.equals(ParamType.CHECKBOX.getValue(), paramVo.getType()) || StringUtils.equals(ParamType.MULTISELECT.getValue(), paramVo.getType())) { AutoexecParamConfigVo config = paramVo.getConfig(); if (config == null) { return returnDefaultValue; } - String dataSource = config.getDataSource(); - //静态数据源 - if (StringUtils.equals(ParamDataSource.STATIC.getValue(), dataSource)) { - if (paramDefaultValue != null) { - List valueList = (List) paramDefaultValue; - JSONArray dataArray = config.getDataList(); - if (CollectionUtils.isNotEmpty(dataArray)) { - List valueTextVoList = dataArray.toJavaList(ValueTextVo.class); - Map valueTextMap = valueTextVoList.stream().collect(Collectors.toMap(ValueTextVo::getValue, ValueTextVo::getText)); - for (int i = 0; i < valueList.size(); i++) { - Object object = valueList.get(i); - returnDefaultValue.append(" ").append(valueTextMap.get(object)); - if (i < valueList.size() - 1) { + IScriptParamType paramType = ScriptParamTypeFactory.getHandler(paramVo.getType()); + if (paramType != null) { + Object text = paramType.getTextByValue(paramDefaultValue, JSONObject.parseObject(JSONObject.toJSONString(config))).toString(); + if (text != null) { + if (text instanceof List) { + List textList = (List) text; + returnDefaultValue.append(" "); + for (int i = 0; i < textList.size(); i++) { + Object textStr = textList.get(i); + returnDefaultValue.append(textStr); + if (i < textList.size() - 1) { returnDefaultValue.append("|"); } } } } - - //矩阵数据源 - } else if (StringUtils.equals(ParamDataSource.MATRIX.getValue(), dataSource)) { - String matrixUuid = config.getMatrixUuid(); - if (StringUtils.isNotBlank(matrixUuid)) { - MatrixVo matrixVo = matrixMapper.getMatrixByUuid(matrixUuid); - if (matrixVo == null) { - matrixVo = MatrixPrivateDataSourceHandlerFactory.getMatrixVo(matrixUuid); - } - if (matrixVo != null) { - returnDefaultValue = new StringBuilder(matrixVo.getName()); - if (paramDefaultValue != null) { - List valueList = (List) paramDefaultValue; - returnDefaultValue.append(" "); - for (int i = 0; i < valueList.size(); i++) { - String valueString = (String) valueList.get(i); - returnDefaultValue.append(valueString.substring(valueString.substring(0, valueString.indexOf("&=&")).length() + 3)); - if (i < valueList.size() - 1) { - returnDefaultValue.append("|"); - } - } - } - } - } } - //文件 } else if (StringUtils.equals(ParamType.FILE.getValue(), paramVo.getType())) { if (paramDefaultValue != null) { diff --git a/src/main/java/neatlogic/module/autoexec/dependency/AutoexecGlobalParam2CombopPhaseOperationArgumentParamDependencyHandler.java b/src/main/java/neatlogic/module/autoexec/dependency/AutoexecGlobalParam2CombopPhaseOperationArgumentParamDependencyHandler.java index b4b3adf94f75ffa48629eac24c3c6d978233c7ba..3368c0e1f962098ee515d9c52b6addf8a4f08baf 100644 --- a/src/main/java/neatlogic/module/autoexec/dependency/AutoexecGlobalParam2CombopPhaseOperationArgumentParamDependencyHandler.java +++ b/src/main/java/neatlogic/module/autoexec/dependency/AutoexecGlobalParam2CombopPhaseOperationArgumentParamDependencyHandler.java @@ -107,6 +107,9 @@ public class AutoexecGlobalParam2CombopPhaseOperationArgumentParamDependencyHand } if (Objects.equals(paramMappingVo.getValue(), dependencyVo.getFrom())) { AutoexecCombopVo autoexecCombopVo = autoexecCombopMapper.getAutoexecCombopById(autoexecCombopVersionVo.getCombopId()); + if (autoexecCombopVo == null) { + return null; + } String operationName = phaseOperationVo.getOperationName(); String phaseName = combopPhaseVo.getName(); String combopName = autoexecCombopVo.getName(); diff --git a/src/main/java/neatlogic/module/autoexec/dependency/AutoexecGlobalParam2CombopPhaseOperationInputParamDependencyHandler.java b/src/main/java/neatlogic/module/autoexec/dependency/AutoexecGlobalParam2CombopPhaseOperationInputParamDependencyHandler.java index 89158371c67e3da1927bab7bb7453913a24301f5..269ee83d6437af381d488c262a3c497ed44c33d1 100644 --- a/src/main/java/neatlogic/module/autoexec/dependency/AutoexecGlobalParam2CombopPhaseOperationInputParamDependencyHandler.java +++ b/src/main/java/neatlogic/module/autoexec/dependency/AutoexecGlobalParam2CombopPhaseOperationInputParamDependencyHandler.java @@ -107,6 +107,9 @@ public class AutoexecGlobalParam2CombopPhaseOperationInputParamDependencyHandler } if (Objects.equals(paramMappingVo.getValue(), dependencyVo.getFrom())) { AutoexecCombopVo autoexecCombopVo = autoexecCombopMapper.getAutoexecCombopById(autoexecCombopVersionVo.getCombopId()); + if (autoexecCombopVo == null) { + return null; + } String operationName = phaseOperationVo.getOperationName(); String phaseName = combopPhaseVo.getName(); String combopName = autoexecCombopVo.getName(); diff --git a/src/main/java/neatlogic/module/autoexec/dependency/AutoexecProfile2CombopPhaseOperationDependencyHandler.java b/src/main/java/neatlogic/module/autoexec/dependency/AutoexecProfile2CombopPhaseOperationDependencyHandler.java index c99127c7bd9bc7c174ec2acac7d6d1229c6ab298..f91d1d4c7b78ab74ece4a279908c78417dc1ca4a 100644 --- a/src/main/java/neatlogic/module/autoexec/dependency/AutoexecProfile2CombopPhaseOperationDependencyHandler.java +++ b/src/main/java/neatlogic/module/autoexec/dependency/AutoexecProfile2CombopPhaseOperationDependencyHandler.java @@ -97,6 +97,9 @@ public class AutoexecProfile2CombopPhaseOperationDependencyHandler extends Fixed return null; } AutoexecCombopVo autoexecCombopVo = autoexecCombopMapper.getAutoexecCombopById(autoexecCombopVersionVo.getCombopId()); + if (autoexecCombopVo == null) { + return null; + } String operationName = phaseOperationVo.getOperationName(); String phaseName = combopPhaseVo.getName(); String combopName = autoexecCombopVo.getName(); diff --git a/src/main/java/neatlogic/module/autoexec/dependency/AutoexecScenarioCombopDependencyHandler.java b/src/main/java/neatlogic/module/autoexec/dependency/AutoexecScenarioCombopDependencyHandler.java index a4ad79b7fcbf31cc2d2ee2ec5886818fa04d3ea9..086afcffb88f53edb67b29246b14cc377be7d954 100644 --- a/src/main/java/neatlogic/module/autoexec/dependency/AutoexecScenarioCombopDependencyHandler.java +++ b/src/main/java/neatlogic/module/autoexec/dependency/AutoexecScenarioCombopDependencyHandler.java @@ -60,7 +60,9 @@ public class AutoexecScenarioCombopDependencyHandler extends FixedTableDependenc } Long combopId = autoexecCombopVersionVo.getCombopId(); AutoexecCombopVo autoexecCombopVo = autoexecCombopMapper.getAutoexecCombopById(combopId); - + if (autoexecCombopVo == null) { + return null; + } JSONObject dependencyInfoConfig = new JSONObject(); dependencyInfoConfig.put("combopId", combopId); dependencyInfoConfig.put("versionId", versionId); diff --git a/src/main/java/neatlogic/module/autoexec/dependency/AutoexecScript2CombopPhaseOperationDependencyHandler.java b/src/main/java/neatlogic/module/autoexec/dependency/AutoexecScript2CombopPhaseOperationDependencyHandler.java index 148a3e85691de898e495e60ee533349b0413de47..56fbcc3867654e90b85cc7789fb9b88cde6afb8c 100644 --- a/src/main/java/neatlogic/module/autoexec/dependency/AutoexecScript2CombopPhaseOperationDependencyHandler.java +++ b/src/main/java/neatlogic/module/autoexec/dependency/AutoexecScript2CombopPhaseOperationDependencyHandler.java @@ -95,6 +95,9 @@ public class AutoexecScript2CombopPhaseOperationDependencyHandler extends FixedT return null; } AutoexecCombopVo autoexecCombopVo = autoexecCombopMapper.getAutoexecCombopById(autoexecCombopVersionVo.getCombopId()); + if (autoexecCombopVo == null) { + return null; + } String operationName = phaseOperationVo.getOperationName(); String phaseName = combopPhaseVo.getName(); String combopName = autoexecCombopVo.getName(); diff --git a/src/main/java/neatlogic/module/autoexec/dependency/AutoexecTool2CombopPhaseOperationDependencyHandler.java b/src/main/java/neatlogic/module/autoexec/dependency/AutoexecTool2CombopPhaseOperationDependencyHandler.java index 968b6f05a80694d70722a332dcf3f04d48689c3b..d85f75fdd7ef887fe814a3f39b028d021cabcb2b 100644 --- a/src/main/java/neatlogic/module/autoexec/dependency/AutoexecTool2CombopPhaseOperationDependencyHandler.java +++ b/src/main/java/neatlogic/module/autoexec/dependency/AutoexecTool2CombopPhaseOperationDependencyHandler.java @@ -95,6 +95,9 @@ public class AutoexecTool2CombopPhaseOperationDependencyHandler extends FixedTab return null; } AutoexecCombopVo autoexecCombopVo = autoexecCombopMapper.getAutoexecCombopById(autoexecCombopVersionVo.getCombopId()); + if (autoexecCombopVo == null) { + return null; + } String operationName = phaseOperationVo.getOperationName(); String phaseName = combopPhaseVo.getName(); String combopName = autoexecCombopVo.getName(); diff --git a/src/main/java/neatlogic/module/autoexec/dependency/Matrix2AutoexecCombopVersionParamDependencyHandler.java b/src/main/java/neatlogic/module/autoexec/dependency/Matrix2AutoexecCombopVersionParamDependencyHandler.java index 98e210e2e484063909bf652d84dd150ae4e885b4..f36683c8e6ce23daa17b5f35246aa27259d6517b 100644 --- a/src/main/java/neatlogic/module/autoexec/dependency/Matrix2AutoexecCombopVersionParamDependencyHandler.java +++ b/src/main/java/neatlogic/module/autoexec/dependency/Matrix2AutoexecCombopVersionParamDependencyHandler.java @@ -71,6 +71,9 @@ public class Matrix2AutoexecCombopVersionParamDependencyHandler extends FixedTab for (AutoexecParamVo autoexecParamVo : runtimeParamList) { if (Objects.equals(dependencyVo.getTo(), autoexecParamVo.getId().toString())) { AutoexecCombopVo autoexecCombopVo = autoexecCombopMapper.getAutoexecCombopById(autoexecCombopVersionVo.getCombopId()); + if (autoexecCombopVo == null) { + return null; + } JSONObject dependencyInfoConfig = new JSONObject(); dependencyInfoConfig.put("combopId", autoexecCombopVo.getId()); dependencyInfoConfig.put("versionId", autoexecCombopVersionVo.getId()); diff --git a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeAccount.java b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeAccount.java index 8b7989f041d2edfd84f327aa0758216b4821e4ae..b800c3a14b7926409831a7e7d4b86c918629dc76 100644 --- a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeAccount.java +++ b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeAccount.java @@ -122,7 +122,7 @@ public class ScriptParamTypeAccount extends ScriptParamTypeBase { } @Override - protected Object getMyTextByValue(Object value) { + protected Object getMyTextByValue(Object value, JSONObject config) { String valueStr = value.toString(); if (StringUtils.isNotBlank(valueStr)) { IResourceAccountCrossoverMapper resourceAccountCrossoverMapper = CrossoverServiceFactory.getApi(IResourceAccountCrossoverMapper.class); diff --git a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeCheckbox.java b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeCheckbox.java index 4465983c2577212ca81b433a450769ec44e3527e..4ecf8bd8c117fffa11d766d0e656f870166f4698 100644 --- a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeCheckbox.java +++ b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeCheckbox.java @@ -16,10 +16,14 @@ limitations under the License. package neatlogic.module.autoexec.script.paramtype; -import neatlogic.framework.autoexec.constvalue.ParamType; -import neatlogic.framework.autoexec.script.paramtype.ScriptParamTypeBase; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.autoexec.constvalue.ParamType; +import neatlogic.framework.autoexec.script.paramtype.ScriptParamTypeBase; +import neatlogic.framework.crossover.CrossoverServiceFactory; +import neatlogic.framework.form.dto.AttributeDataVo; +import neatlogic.framework.form.service.IFormCrossoverService; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Service; /** @@ -79,8 +83,6 @@ public class ScriptParamTypeCheckbox extends ScriptParamTypeBase { { this.put("type", "checkbox"); this.put("placeholder", "请选择"); - this.put("url", "/api/rest/matrix/column/data/search/forselect/new"); - this.put("rootName", "tbodyList"); } }; } @@ -91,20 +93,15 @@ public class ScriptParamTypeCheckbox extends ScriptParamTypeBase { } @Override - public Object getMyTextByValue(Object value) { - JSONArray values = JSONArray.parseArray(value.toString()); - for (int i = 0; i < values.size(); i++) { - String valueStr = values.getString(i); - int tmpIndex = valueStr.indexOf("&=&"); - if (tmpIndex > -1) { - values.set(i,valueStr.substring(tmpIndex + 3)); - } + public Object getMyTextByValue(Object value, JSONObject config) { + IFormCrossoverService formCrossoverService = CrossoverServiceFactory.getApi(IFormCrossoverService.class); + AttributeDataVo attributeDataVo = new AttributeDataVo(); + attributeDataVo.setDataObj(value); + JSONObject resultObj = formCrossoverService.getMyDetailedDataForSelectHandler(attributeDataVo, config); + JSONArray textList = resultObj.getJSONArray("textList"); + if (CollectionUtils.isNotEmpty(textList)) { + return textList; } - return values; - } - - @Override - public Object getMyAutoexecParamByValue(Object value){ - return getMyTextByValue(value); + return value; } } diff --git a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeFile.java b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeFile.java index 902c60959798125a11546e2fd03e1f2bf923f357..9b19c7957a7a4f51536c3630233ca8bba28c368c 100644 --- a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeFile.java +++ b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeFile.java @@ -87,7 +87,7 @@ public class ScriptParamTypeFile extends ScriptParamTypeBase { } @Override - protected Object getMyTextByValue(Object value) { + protected Object getMyTextByValue(Object value, JSONObject config) { return JSONObject.parseObject(value.toString()); } diff --git a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeMultiSelect.java b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeMultiSelect.java index 86ca086515cccad440a65d6725d0d5c861b1050c..440d09c9af6a052cb72a6fd828bb17f84eaffb56 100644 --- a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeMultiSelect.java +++ b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeMultiSelect.java @@ -16,10 +16,14 @@ limitations under the License. package neatlogic.module.autoexec.script.paramtype; -import neatlogic.framework.autoexec.constvalue.ParamType; -import neatlogic.framework.autoexec.script.paramtype.ScriptParamTypeBase; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.autoexec.constvalue.ParamType; +import neatlogic.framework.autoexec.script.paramtype.ScriptParamTypeBase; +import neatlogic.framework.crossover.CrossoverServiceFactory; +import neatlogic.framework.form.dto.AttributeDataVo; +import neatlogic.framework.form.service.IFormCrossoverService; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Service; /** @@ -79,8 +83,6 @@ public class ScriptParamTypeMultiSelect extends ScriptParamTypeBase { { this.put("type", "select"); this.put("placeholder", "请选择"); - this.put("dynamicUrl", "/api/rest/matrix/column/data/search/forselect/new"); - this.put("rootName", "tbodyList"); this.put("multiple", true); } }; @@ -92,20 +94,15 @@ public class ScriptParamTypeMultiSelect extends ScriptParamTypeBase { } @Override - public Object getMyTextByValue(Object value) { - JSONArray values = JSONArray.parseArray(value.toString()); - for (int i = 0; i < values.size(); i++) { - String valueStr = values.getString(i); - int tmpIndex = valueStr.indexOf("&=&"); - if (tmpIndex > -1) { - values.set(i,valueStr.substring(tmpIndex + 3)); - } + public Object getMyTextByValue(Object value, JSONObject config) { + IFormCrossoverService formCrossoverService = CrossoverServiceFactory.getApi(IFormCrossoverService.class); + AttributeDataVo attributeDataVo = new AttributeDataVo(); + attributeDataVo.setDataObj(value); + JSONObject resultObj = formCrossoverService.getMyDetailedDataForSelectHandler(attributeDataVo, config); + JSONArray textList = resultObj.getJSONArray("textList"); + if (CollectionUtils.isNotEmpty(textList)) { + return textList; } - return values; - } - - @Override - public Object getMyAutoexecParamByValue(Object value){ - return getMyTextByValue(value); + return value; } } diff --git a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeNode.java b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeNode.java index 90ef6368575eb8f98dc65d97a5abdb55caa0f067..36c509c11778e407a9e0547196fff47fe649feb0 100644 --- a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeNode.java +++ b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeNode.java @@ -84,7 +84,7 @@ public class ScriptParamTypeNode extends ScriptParamTypeBase { } @Override - protected Object getMyTextByValue(Object value) { + protected Object getMyTextByValue(Object value, JSONObject config) { JSONArray nodeJsonArray = JSONObject.parseArray(value.toString()); for (Object node : nodeJsonArray) { JSONObject nodeJson = (JSONObject) node; @@ -92,9 +92,4 @@ public class ScriptParamTypeNode extends ScriptParamTypeBase { } return nodeJsonArray; } - - @Override - public Object getMyAutoexecParamByValue(Object value){ - return value; - } } diff --git a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypePassword.java b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypePassword.java index fdb87bc6400e7925ee51abf8768baa72db5b6647..79a3caef40ce75041e5f7d469610e40cb51074b7 100644 --- a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypePassword.java +++ b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypePassword.java @@ -86,13 +86,13 @@ public class ScriptParamTypePassword extends ScriptParamTypeBase { } @Override - protected Object getMyTextByValue(Object value) { + protected Object getMyTextByValue(Object value, JSONObject config) { String valueStr = value.toString(); return RC4Util.encrypt(valueStr); } @Override public Object getMyAutoexecParamByValue(Object value){ - return getMyTextByValue(value); + return getMyTextByValue(value, null); } } diff --git a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypePhase.java b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypePhase.java index 7a3c5dc774adf49579eb3a4ec0fa449be22da967..5d63c72222f0b1086a9affa4c669d619a85e1edb 100644 --- a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypePhase.java +++ b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypePhase.java @@ -87,14 +87,4 @@ public class ScriptParamTypePhase extends ScriptParamTypeBase { public Boolean myNeedDataSource() { return false; } - - @Override - public Object getMyTextByValue(Object value) { - return value; - } - - @Override - public Object getMyAutoexecParamByValue(Object value){ - return getMyTextByValue(value); - } } diff --git a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeRadio.java b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeRadio.java index a00c8add8fb9435837ad20c923b867d242bce707..79c31294d570f01e5c7216bed84744a9118ac431 100644 --- a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeRadio.java +++ b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeRadio.java @@ -16,9 +16,14 @@ limitations under the License. package neatlogic.module.autoexec.script.paramtype; +import com.alibaba.fastjson.JSONArray; import neatlogic.framework.autoexec.constvalue.ParamType; import neatlogic.framework.autoexec.script.paramtype.ScriptParamTypeBase; import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.crossover.CrossoverServiceFactory; +import neatlogic.framework.form.dto.AttributeDataVo; +import neatlogic.framework.form.service.IFormCrossoverService; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Service; /** @@ -78,8 +83,6 @@ public class ScriptParamTypeRadio extends ScriptParamTypeBase { { this.put("type", "radio"); this.put("placeholder", "请选择"); - this.put("url", "/api/rest/matrix/column/data/search/forselect/new"); - this.put("rootName", "tbodyList"); } }; } @@ -90,17 +93,15 @@ public class ScriptParamTypeRadio extends ScriptParamTypeBase { } @Override - public Object getMyTextByValue(Object value) { - String valueStr = value.toString(); - int tmpIndex = valueStr.indexOf("&=&"); - if (tmpIndex > -1) { - return valueStr.substring(tmpIndex + 3); + public Object getMyTextByValue(Object value, JSONObject config) { + IFormCrossoverService formCrossoverService = CrossoverServiceFactory.getApi(IFormCrossoverService.class); + AttributeDataVo attributeDataVo = new AttributeDataVo(); + attributeDataVo.setDataObj(value); + JSONObject resultObj = formCrossoverService.getMyDetailedDataForSelectHandler(attributeDataVo, config); + JSONArray textList = resultObj.getJSONArray("textList"); + if (CollectionUtils.isNotEmpty(textList)) { + return textList.get(0); } return value; } - - @Override - public Object getMyAutoexecParamByValue(Object value){ - return getMyTextByValue(value); - } } diff --git a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeSelect.java b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeSelect.java index 048e1fdac3e7097a315a7b7f477324e1bc20d4bb..9fa015fba1db8e00fa3dff2ff2d989e91fe2277d 100644 --- a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeSelect.java +++ b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeSelect.java @@ -16,9 +16,14 @@ limitations under the License. package neatlogic.module.autoexec.script.paramtype; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import neatlogic.framework.autoexec.constvalue.ParamType; import neatlogic.framework.autoexec.script.paramtype.ScriptParamTypeBase; -import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.crossover.CrossoverServiceFactory; +import neatlogic.framework.form.dto.AttributeDataVo; +import neatlogic.framework.form.service.IFormCrossoverService; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Service; /** @@ -78,8 +83,6 @@ public class ScriptParamTypeSelect extends ScriptParamTypeBase { { this.put("type", "select"); this.put("placeholder", "请选择"); - this.put("dynamicUrl", "/api/rest/matrix/column/data/search/forselect/new"); - this.put("rootName", "tbodyList"); this.put("multiple", false); } }; @@ -91,17 +94,15 @@ public class ScriptParamTypeSelect extends ScriptParamTypeBase { } @Override - public Object getMyTextByValue(Object value) { - String valueStr = value.toString(); - int tmpIndex = valueStr.indexOf("&=&"); - if (tmpIndex > -1) { - return valueStr.substring(tmpIndex + 3); + public Object getMyTextByValue(Object value, JSONObject config) { + IFormCrossoverService formCrossoverService = CrossoverServiceFactory.getApi(IFormCrossoverService.class); + AttributeDataVo attributeDataVo = new AttributeDataVo(); + attributeDataVo.setDataObj(value); + JSONObject resultObj = formCrossoverService.getMyDetailedDataForSelectHandler(attributeDataVo, config); + JSONArray textList = resultObj.getJSONArray("textList"); + if (CollectionUtils.isNotEmpty(textList)) { + return textList.get(0); } return value; } - - @Override - public Object getMyAutoexecParamByValue(Object value){ - return getMyTextByValue(value); - } } diff --git a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeSwitch.java b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeSwitch.java index 07f0e3379f810ca459b467cb603caf5712657470..ee1636a07cd98cc4b8e600db5f0b9d65782cd3c6 100644 --- a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeSwitch.java +++ b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeSwitch.java @@ -85,14 +85,4 @@ public class ScriptParamTypeSwitch extends ScriptParamTypeBase { public Boolean myNeedDataSource() { return false; } - - @Override - public Object getMyTextByValue(Object value) { - return value; - } - - @Override - public Object getMyAutoexecParamByValue(Object value) { - return getMyTextByValue(value); - } } diff --git a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeUserSelect.java b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeUserSelect.java index 1b5696f48606df5a7ab898e33e44fd8baa9b7f69..472b57782bba0fac5b110a30e21f1a82bb8a29c2 100644 --- a/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeUserSelect.java +++ b/src/main/java/neatlogic/module/autoexec/script/paramtype/ScriptParamTypeUserSelect.java @@ -100,7 +100,7 @@ public class ScriptParamTypeUserSelect extends ScriptParamTypeBase { } @Override - public Object getMyTextByValue(Object value) { + public Object getMyTextByValue(Object value, JSONObject config) { String valueString = value.toString(); if (valueString.startsWith("[") && valueString.endsWith("]")) { return JSONObject.parseArray(valueString); diff --git a/src/main/java/neatlogic/module/autoexec/stephandler/component/AutoexecProcessComponent.java b/src/main/java/neatlogic/module/autoexec/stephandler/component/AutoexecProcessComponent.java index 591be70a86f2c5c665c5ef1ed784de561ca7d4de..4ba08856112068202574c2fdb04d3a918a8bcc08 100644 --- a/src/main/java/neatlogic/module/autoexec/stephandler/component/AutoexecProcessComponent.java +++ b/src/main/java/neatlogic/module/autoexec/stephandler/component/AutoexecProcessComponent.java @@ -16,7 +16,10 @@ limitations under the License. package neatlogic.module.autoexec.stephandler.component; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONException; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.JSONPath; import neatlogic.framework.asynchronization.threadlocal.UserContext; import neatlogic.framework.autoexec.constvalue.CombopOperationType; import neatlogic.framework.autoexec.constvalue.JobStatus; @@ -34,6 +37,7 @@ import neatlogic.framework.common.constvalue.SystemUser; import neatlogic.framework.crossover.CrossoverServiceFactory; import neatlogic.framework.form.dto.FormAttributeVo; import neatlogic.framework.form.dto.FormVersionVo; +import neatlogic.framework.form.service.IFormCrossoverService; import neatlogic.framework.process.constvalue.*; import neatlogic.framework.process.crossover.IProcessTaskCrossoverService; import neatlogic.framework.process.dao.mapper.ProcessTaskStepDataMapper; @@ -46,9 +50,6 @@ import neatlogic.framework.process.stephandler.core.ProcessStepHandlerFactory; import neatlogic.framework.process.stephandler.core.ProcessStepThread; import neatlogic.module.autoexec.constvalue.FailPolicy; import neatlogic.module.autoexec.service.AutoexecJobActionService; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.alibaba.fastjson.JSONPath; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -576,6 +577,14 @@ public class AutoexecProcessComponent extends ProcessStepHandlerBase { JSONObject tbodyObj, Map formAttributeMap, Map processTaskFormAttributeDataMap) { + List formSelectAttributeList = new ArrayList<>(); + formSelectAttributeList.add(neatlogic.framework.form.constvalue.FormHandler.FORMSELECT.getHandler()); + formSelectAttributeList.add(neatlogic.framework.form.constvalue.FormHandler.FORMCHECKBOX.getHandler()); + formSelectAttributeList.add(neatlogic.framework.form.constvalue.FormHandler.FORMRADIO.getHandler()); + List formTextAttributeList = new ArrayList<>(); + formTextAttributeList.add(neatlogic.framework.form.constvalue.FormHandler.FORMTEXT.getHandler()); + formTextAttributeList.add(neatlogic.framework.form.constvalue.FormHandler.FORMTEXTAREA.getHandler()); + JSONObject param = new JSONObject(); for (int i = 0; i < runtimeParamList.size(); i++) { JSONObject runtimeParamObj = runtimeParamList.getJSONObject(i); @@ -608,9 +617,13 @@ public class AutoexecProcessComponent extends ProcessStepHandlerBase { } else if (Objects.equals(mappingMode, "formCommonComponent")) { ProcessTaskFormAttributeDataVo attributeDataVo = processTaskFormAttributeDataMap.get(value); if (attributeDataVo != null) { - if (Objects.equals(attributeDataVo.getType(), "formtext") || Objects.equals(attributeDataVo.getType(), "formtextarea")) { + if (formTextAttributeList.contains(attributeDataVo.getType())) { String type = runtimeParamObj.getString("type"); param.put(key, convertDateType(type, (String) attributeDataVo.getDataObj())); + } else if (formSelectAttributeList.contains(attributeDataVo.getType())) { + IFormCrossoverService formCrossoverService = CrossoverServiceFactory.getApi(IFormCrossoverService.class); + Object valueObject = formCrossoverService.getFormSelectAttributeValueByOriginalValue(attributeDataVo.getDataObj()); + param.put(key, valueObject); } else { param.put(key, attributeDataVo.getDataObj()); } @@ -634,6 +647,9 @@ public class AutoexecProcessComponent extends ProcessStepHandlerBase { JSONObject tbodyObj, Map formAttributeMap, Map processTaskFormAttributeDataMap) { + List formTextAttributeList = new ArrayList<>(); + formTextAttributeList.add(neatlogic.framework.form.constvalue.FormHandler.FORMTEXT.getHandler()); + formTextAttributeList.add(neatlogic.framework.form.constvalue.FormHandler.FORMTEXTAREA.getHandler()); JSONObject executeConfig = new JSONObject(); for (int i = 0; i < executeParamList.size(); i++) { JSONObject executeParamObj = executeParamList.getJSONObject(i); @@ -695,7 +711,7 @@ public class AutoexecProcessComponent extends ProcessStepHandlerBase { if (Objects.equals(attributeDataVo.getType(), FormHandler.FORMRESOURECES.getHandler())) { // 映射的表单组件是执行目标 executeNodeConfigVo = ((JSONObject) dataObj).toJavaObject(AutoexecCombopExecuteNodeConfigVo.class); - } else if (Objects.equals(attributeDataVo.getType(), "formtext") || Objects.equals(attributeDataVo.getType(), "formtextarea")) { + } else if (formTextAttributeList.contains(attributeDataVo.getType())) { // 映射的表单组件是文本框 String dataStr = dataObj.toString(); try {