From 48d5e398e71aea00aeb336299bfd54ebbabcae70 Mon Sep 17 00:00:00 2001 From: linbangquan <1437892690@qq.com> Date: Fri, 17 Nov 2023 18:04:59 +0800 Subject: [PATCH 01/14] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E5=90=8E=E7=AB=AF?= =?UTF-8?q?-=E4=B8=8B=E6=8B=89=E6=A1=86=E3=80=81=E5=8D=95=E9=80=89?= =?UTF-8?q?=E3=80=81=E5=A4=8D=E9=80=89=E7=BB=84=E4=BB=B6=E9=80=89=E4=B8=AD?= =?UTF-8?q?=E5=80=BC=E7=94=B1xxx&=3D&yyy=E6=94=B9=E6=88=90{value:xxx,text:?= =?UTF-8?q?yyy}?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1025915604140032]后端-下拉框、单选、复选组件选中值由xxx&=&yyy改成{value:xxx,text:yyy} http://192.168.0.96:8090/demo/rdm.html#/task-detail/939050947543040/939050947543050/1025915604140032 --- .../handler/CustomDataSourceHandler.java | 193 ++---------------- .../handler/ExternalDataSourceHandler.java | 118 +---------- .../handler/PrivateDataSourceHandler.java | 106 +--------- .../matrix/handler/ViewDataSourceHandler.java | 98 +-------- 4 files changed, 26 insertions(+), 489 deletions(-) diff --git a/src/main/java/neatlogic/module/framework/matrix/handler/CustomDataSourceHandler.java b/src/main/java/neatlogic/module/framework/matrix/handler/CustomDataSourceHandler.java index 420951443..a6467dcfd 100644 --- a/src/main/java/neatlogic/module/framework/matrix/handler/CustomDataSourceHandler.java +++ b/src/main/java/neatlogic/module/framework/matrix/handler/CustomDataSourceHandler.java @@ -16,7 +16,8 @@ limitations under the License. package neatlogic.module.framework.matrix.handler; -import neatlogic.framework.common.constvalue.Expression; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import neatlogic.framework.common.constvalue.GroupSearch; import neatlogic.framework.common.dto.ValueTextVo; import neatlogic.framework.common.util.PageUtil; @@ -38,8 +39,6 @@ import neatlogic.framework.util.ExcelUtil; import neatlogic.framework.util.TableResultUtil; import neatlogic.framework.util.TimeUtil; import neatlogic.framework.util.UuidUtil; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -476,168 +475,6 @@ public class CustomDataSourceHandler extends MatrixDataSourceHandlerBase { return returnObj; } - @Override - protected List> myTableColumnDataSearch(MatrixDataVo dataVo) { - List> resultList = new ArrayList<>(); - List attributeList = attributeMapper.getMatrixAttributeByMatrixUuid(dataVo.getMatrixUuid()); - if (CollectionUtils.isNotEmpty(attributeList)) { - Map matrixAttributeMap = new HashMap<>(); - for (MatrixAttributeVo matrixAttributeVo : attributeList) { - matrixAttributeMap.put(matrixAttributeVo.getUuid(), matrixAttributeVo); - } - List columnList = dataVo.getColumnList(); - for (String column : columnList) { - if (!matrixAttributeMap.containsKey(column)) { - throw new MatrixAttributeNotFoundException(dataVo.getMatrixUuid(), column); - } - } - JSONArray defaultValue = dataVo.getDefaultValue(); - if (CollectionUtils.isNotEmpty(defaultValue)) { - for (String value : defaultValue.toJavaList(String.class)) { - if (value.contains(SELECT_COMPOSE_JOINER)) { - List sourceColumnList = new ArrayList<>(); - String[] split = value.split(SELECT_COMPOSE_JOINER); - if (StringUtils.isNotBlank(columnList.get(0))) { - MatrixColumnVo matrixColumnVo = new MatrixColumnVo(columnList.get(0), split[0]); - matrixColumnVo.setExpression(Expression.EQUAL.getExpression()); - sourceColumnList.add(matrixColumnVo); - } - String keywordColumn = null; - if (columnList.size() >= 2) { - keywordColumn = columnList.get(1); - } else { - keywordColumn = columnList.get(0); - } - MatrixAttributeVo matrixAttribute = matrixAttributeMap.get(keywordColumn); - if (matrixAttribute == null) { - throw new MatrixAttributeNotFoundException(dataVo.getMatrixUuid(), keywordColumn); - } - String keyword = split[1]; - if (MatrixAttributeType.SELECT.getValue().equals(matrixAttribute.getType())) { - JSONObject config = matrixAttribute.getConfig(); - if (MapUtils.isNotEmpty(config)) { - JSONArray dataArray = config.getJSONArray("dataList"); - if (CollectionUtils.isNotEmpty(dataArray)) { - List valueList = new ArrayList<>(); - List dataList = dataArray.toJavaList(ValueTextVo.class); - for (ValueTextVo e : dataList) { - String text = e.getText(); - if (StringUtils.isNotBlank(text)) { - if (Objects.equals(e.getText(), keyword)) { - valueList.add((String)e.getValue()); - } - } - } - if (CollectionUtils.isNotEmpty(valueList)) { - MatrixColumnVo matrixColumnVo = new MatrixColumnVo(keywordColumn, valueList); - matrixColumnVo.setExpression(Expression.INCLUDE.getExpression()); - sourceColumnList.add(matrixColumnVo); - } else { - return resultList; - } - } - } - dataVo.setKeyword(null); - } else { - dataVo.setKeyword(keyword); - dataVo.setKeywordColumn(keywordColumn); - dataVo.setAttrType(matrixAttribute.getType()); - dataVo.setKeywordExpression(Expression.EQUAL.getExpression()); - } - dataVo.setSourceColumnList(sourceColumnList); - List> dataMapList = matrixDataMapper.getDynamicTableDataForSelect(dataVo); - if (CollectionUtils.isNotEmpty(dataMapList)) { - //对dataMapList去重 - List> distinctList = new ArrayList<>(); - for (Map dataMap : dataMapList) { - if(distinctList.contains(dataMap)){ - continue; - } - distinctList.add(dataMap); - Map resultMap = new HashMap<>(dataMap.size()); - for (Map.Entry entry : dataMap.entrySet()) { - String attributeUuid = entry.getKey(); - resultMap.put(attributeUuid, matrixAttributeValueHandle(matrixAttributeMap.get(attributeUuid), entry.getValue())); - } - resultList.add(resultMap); - } - } - } - } - } else { - if (!mergeFilterListAndSourceColumnList(dataVo)) { - return resultList; - } - String keywordColumn = dataVo.getKeywordColumn(); - String keyword = dataVo.getKeyword(); - if (StringUtils.isNotBlank(keywordColumn) && StringUtils.isNotBlank(keyword)) { - MatrixAttributeVo matrixAttribute = matrixAttributeMap.get(keywordColumn); - if (matrixAttribute == null) { - throw new MatrixAttributeNotFoundException(dataVo.getMatrixUuid(), keywordColumn); - } - if (MatrixAttributeType.SELECT.getValue().equals(matrixAttribute.getType())) { - JSONObject config = matrixAttribute.getConfig(); - if (MapUtils.isNotEmpty(config)) { - JSONArray dataArray = config.getJSONArray("dataList"); - if (CollectionUtils.isNotEmpty(dataArray)) { - List valueList = new ArrayList<>(); - List dataList = dataArray.toJavaList(ValueTextVo.class); - for (ValueTextVo e : dataList) { - String text = e.getText(); - if (StringUtils.isNotBlank(text)) { - if (text.contains(keyword)) { - valueList.add((String)e.getValue()); - } - } - } - if (CollectionUtils.isNotEmpty(valueList)) { - List sourceColumnList = dataVo.getSourceColumnList(); - MatrixColumnVo matrixColumnVo = new MatrixColumnVo(keywordColumn, valueList); - matrixColumnVo.setExpression(Expression.INCLUDE.getExpression()); - sourceColumnList.add(matrixColumnVo); - dataVo.setSourceColumnList(sourceColumnList); - } else { - return resultList; - } - } - } - dataVo.setKeyword(null); - } else { - dataVo.setAttrType(matrixAttribute.getType()); - dataVo.setKeywordExpression(Expression.LIKE.getExpression()); - } - } - //下面逻辑适用于下拉框滚动加载,也可以搜索,但是一页返回的数据量可能会小于pageSize,因为做了去重处理 - int rowNum = matrixDataMapper.getDynamicTableDataCountForSelect(dataVo); - if (rowNum == 0) { - return resultList; - } - dataVo.setRowNum(rowNum); - if (dataVo.getCurrentPage() > dataVo.getPageCount()) { - return resultList; - } - List> dataMapList = matrixDataMapper.getDynamicTableDataForSelect(dataVo); - if (CollectionUtils.isEmpty(dataMapList)) { - return resultList; - } - List> distinctList = new ArrayList<>(100); - for (Map dataMap : dataMapList) { - if(distinctList.contains(dataMap)){ - continue; - } - distinctList.add(dataMap); - Map resultMap = new HashMap<>(dataMap.size()); - for (Map.Entry entry : dataMap.entrySet()) { - String attributeUuid = entry.getKey(); - resultMap.put(attributeUuid, matrixAttributeValueHandle(matrixAttributeMap.get(attributeUuid), entry.getValue())); - } - resultList.add(resultMap); - } - } - } - return resultList; - } - @Override protected List> mySearchTableDataNew(MatrixDataVo dataVo) { List> resultList = new ArrayList<>(); @@ -656,20 +493,22 @@ public class CustomDataSourceHandler extends MatrixDataSourceHandlerBase { MatrixKeywordFilterVo valueFieldFilter = defaultValueFilterVo.getValueFieldFilter(); filterList.add(new MatrixFilterVo(valueFieldFilter.getUuid(), valueFieldFilter.getExpression(), Arrays.asList(valueFieldFilter.getValue()))); MatrixKeywordFilterVo textFieldFilter = defaultValueFilterVo.getTextFieldFilter(); - MatrixAttributeVo attributeVo = matrixAttributeMap.get(textFieldFilter.getUuid()); - if (MatrixAttributeType.SELECT.getValue().equals(attributeVo.getType())) { - List valueList = getSelectTypeValueList(attributeVo, textFieldFilter.getValue(), SearchExpression.EQ); - if (CollectionUtils.isNotEmpty(valueList)) { - filterList.add(new MatrixFilterVo(textFieldFilter.getUuid(), SearchExpression.LI.getExpression(), valueList)); + if (textFieldFilter != null) { + MatrixAttributeVo attributeVo = matrixAttributeMap.get(textFieldFilter.getUuid()); + if (MatrixAttributeType.SELECT.getValue().equals(attributeVo.getType())) { + List valueList = getSelectTypeValueList(attributeVo, textFieldFilter.getValue(), SearchExpression.EQ); + if (CollectionUtils.isNotEmpty(valueList)) { + filterList.add(new MatrixFilterVo(textFieldFilter.getUuid(), SearchExpression.LI.getExpression(), valueList)); + } else { + return resultList; + } + dataVo.setKeyword(null); } else { - return resultList; + dataVo.setKeyword(textFieldFilter.getValue()); + dataVo.setKeywordColumn(textFieldFilter.getUuid()); + dataVo.setAttrType(attributeVo.getType()); + dataVo.setKeywordExpression(SearchExpression.EQ.getExpression()); } - dataVo.setKeyword(null); - } else { - dataVo.setKeyword(textFieldFilter.getValue()); - dataVo.setKeywordColumn(textFieldFilter.getUuid()); - dataVo.setAttrType(attributeVo.getType()); - dataVo.setKeywordExpression(SearchExpression.EQ.getExpression()); } dataVo.setFilterList(filterList); List> list = matrixDataMapper.getDynamicTableDataList(dataVo); diff --git a/src/main/java/neatlogic/module/framework/matrix/handler/ExternalDataSourceHandler.java b/src/main/java/neatlogic/module/framework/matrix/handler/ExternalDataSourceHandler.java index fb5db459b..9ddef9680 100644 --- a/src/main/java/neatlogic/module/framework/matrix/handler/ExternalDataSourceHandler.java +++ b/src/main/java/neatlogic/module/framework/matrix/handler/ExternalDataSourceHandler.java @@ -16,7 +16,9 @@ limitations under the License. package neatlogic.module.framework.matrix.handler; -import neatlogic.framework.common.constvalue.Expression; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import neatlogic.framework.common.dto.ValueTextVo; import neatlogic.framework.exception.core.ApiRuntimeException; import neatlogic.framework.exception.integration.IntegrationHandlerNotFoundException; @@ -33,15 +35,11 @@ import neatlogic.framework.matrix.constvalue.MatrixType; import neatlogic.framework.matrix.constvalue.SearchExpression; import neatlogic.framework.matrix.core.MatrixDataSourceHandlerBase; import neatlogic.framework.matrix.dto.*; -import neatlogic.framework.matrix.exception.MatrixAttributeNotFoundException; import neatlogic.framework.matrix.exception.MatrixExternalAccessException; import neatlogic.framework.matrix.exception.MatrixExternalNotFoundException; import neatlogic.framework.util.ExcelUtil; import neatlogic.framework.util.javascript.JavascriptUtil; import neatlogic.module.framework.integration.handler.FrameworkRequestFrom; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -356,114 +354,6 @@ public class ExternalDataSourceHandler extends MatrixDataSourceHandlerBase { return returnObj; } - @Override - protected List> myTableColumnDataSearch(MatrixDataVo dataVo) { - MatrixExternalVo externalVo = matrixMapper.getMatrixExternalByMatrixUuid(dataVo.getMatrixUuid()); - if (externalVo == null) { - throw new MatrixExternalNotFoundException(dataVo.getMatrixUuid()); - } - IntegrationVo integrationVo = integrationMapper.getIntegrationByUuid(externalVo.getIntegrationUuid()); - IIntegrationHandler handler = IntegrationHandlerFactory.getHandler(integrationVo.getHandler()); - if (handler == null) { - throw new IntegrationHandlerNotFoundException(integrationVo.getHandler()); - } - - List> resultList = new ArrayList<>(); - List matrixAttributeList = getExternalMatrixAttributeList(dataVo.getMatrixUuid(), integrationVo); - if (CollectionUtils.isNotEmpty(matrixAttributeList)) { - List attributeList = matrixAttributeList.stream().map(MatrixAttributeVo::getUuid).collect(Collectors.toList()); - List columnList = dataVo.getColumnList(); - for (String column : columnList) { - if (!attributeList.contains(column)) { - throw new MatrixAttributeNotFoundException(dataVo.getMatrixUuid(), column); - } - } - JSONObject paramObj = integrationVo.getParamObj(); - - JSONArray defaultValue = dataVo.getDefaultValue(); - if (CollectionUtils.isNotEmpty(defaultValue)) { - for (String value : defaultValue.toJavaList(String.class)) { - if (value.contains(SELECT_COMPOSE_JOINER)) { - String[] split = value.split(SELECT_COMPOSE_JOINER); - //当下拉框配置的值和显示文字列为同一列时,value值是这样的20210101&=&20210101,split数组第一和第二个元素相同,这时需要去重 - List splitList = new ArrayList<>(); - for (String str : split) { - if (!splitList.contains(str)) { - splitList.add(str); - } - } - List sourceColumnList = new ArrayList<>(); - int min = Math.min(splitList.size(), columnList.size()); - for (int i = 0; i < min; i++) { - String column = columnList.get(i); - if (StringUtils.isNotBlank(column)) { - MatrixColumnVo matrixColumnVo = new MatrixColumnVo(column, splitList.get(i)); - matrixColumnVo.setExpression(Expression.EQUAL.getExpression()); - sourceColumnList.add(matrixColumnVo); - } - } - paramObj.put("sourceColumnList", sourceColumnList); - IntegrationResultVo resultVo = handler.sendRequest(integrationVo, RequestFrom.MATRIX); - if (StringUtils.isNotBlank(resultVo.getError())) { - logger.error(resultVo.getError()); - throw new MatrixExternalAccessException(integrationVo.getName()); - } - JSONObject transformedResult = JSONObject.parseObject(resultVo.getTransformedResult()); - if (MapUtils.isNotEmpty(transformedResult)) { - Integer rowNum = transformedResult.getInteger("rowNum"); - dataVo.setRowNum(rowNum); - JSONArray tbodyArray = transformedResult.getJSONArray("tbodyList"); - resultList.addAll(getExternalDataTbodyList(matrixAttributeList, tbodyArray, columnList)); - } - } - } - deduplicateData(columnList, resultList); - } else { - List exsited = new ArrayList<>(); - if (!mergeFilterListAndSourceColumnList(dataVo)) { - return resultList; - } - List sourceColumnList = dataVo.getSourceColumnList(); - String keywordColumn = dataVo.getKeywordColumn(); - if (StringUtils.isNotBlank(keywordColumn) && StringUtils.isNotBlank(dataVo.getKeyword())) { - paramObj.put("keyword", dataVo.getKeyword()); - if (!attributeList.contains(keywordColumn)) { - throw new MatrixAttributeNotFoundException(dataVo.getMatrixUuid(), keywordColumn); - } - MatrixColumnVo matrixColumnVo = new MatrixColumnVo(); - matrixColumnVo.setColumn(keywordColumn); - matrixColumnVo.setExpression(Expression.LIKE.getExpression()); - List valueList = new ArrayList<>(); - valueList.add(dataVo.getKeyword()); - matrixColumnVo.setValueList(valueList); - sourceColumnList.add(matrixColumnVo); - } - //下面逻辑适用于下拉框滚动加载,也可以搜索,但是一页返回的数据量可能会小于pageSize,因为做了去重处理 - paramObj.put("currentPage", dataVo.getCurrentPage()); - paramObj.put("pageSize", dataVo.getPageSize()); - paramObj.put("sourceColumnList", sourceColumnList); - IntegrationResultVo resultVo = handler.sendRequest(integrationVo, RequestFrom.MATRIX); - if (StringUtils.isNotBlank(resultVo.getError())) { - logger.error(resultVo.getError()); - throw new MatrixExternalAccessException(integrationVo.getName()); - } - JSONObject transformedResult = JSONObject.parseObject(resultVo.getTransformedResult()); - if (MapUtils.isNotEmpty(transformedResult)) { - Integer rowNum = transformedResult.getInteger("rowNum"); - dataVo.setRowNum(rowNum); - JSONArray tbodyArray = transformedResult.getJSONArray("tbodyList"); - List> list = getExternalDataTbodyList(matrixAttributeList, tbodyArray, columnList); - if (CollectionUtils.isEmpty(list)) { - return resultList; - } - deduplicateData(columnList, exsited, list); - resultList.addAll(list); - } - } - } - return resultList; - } - @Override protected List> mySearchTableDataNew(MatrixDataVo dataVo) { MatrixExternalVo externalVo = matrixMapper.getMatrixExternalByMatrixUuid(dataVo.getMatrixUuid()); @@ -502,7 +392,7 @@ public class ExternalDataSourceHandler extends MatrixDataSourceHandlerBase { MatrixKeywordFilterVo valueFieldFilter = defaultValueFilterVo.getValueFieldFilter(); filterList.add(new MatrixFilterVo(valueFieldFilter.getUuid(), valueFieldFilter.getExpression(), Arrays.asList(valueFieldFilter.getValue()))); MatrixKeywordFilterVo textFieldFilter = defaultValueFilterVo.getTextFieldFilter(); - if (!Objects.equals(valueFieldFilter.getUuid(), textFieldFilter.getUuid())) { + if (textFieldFilter != null && !Objects.equals(valueFieldFilter.getUuid(), textFieldFilter.getUuid())) { filterList.add(new MatrixFilterVo(textFieldFilter.getUuid(), textFieldFilter.getExpression(), Arrays.asList(textFieldFilter.getValue()))); } // dataVo.setFilterList(filterList); diff --git a/src/main/java/neatlogic/module/framework/matrix/handler/PrivateDataSourceHandler.java b/src/main/java/neatlogic/module/framework/matrix/handler/PrivateDataSourceHandler.java index 6f5418bc3..7ee96c2d7 100644 --- a/src/main/java/neatlogic/module/framework/matrix/handler/PrivateDataSourceHandler.java +++ b/src/main/java/neatlogic/module/framework/matrix/handler/PrivateDataSourceHandler.java @@ -16,7 +16,8 @@ limitations under the License. package neatlogic.module.framework.matrix.handler; -import neatlogic.framework.common.constvalue.Expression; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import neatlogic.framework.dao.mapper.RoleMapper; import neatlogic.framework.dao.mapper.TeamMapper; import neatlogic.framework.dao.mapper.UserMapper; @@ -30,10 +31,7 @@ import neatlogic.framework.matrix.core.IMatrixPrivateDataSourceHandler; import neatlogic.framework.matrix.core.MatrixDataSourceHandlerBase; import neatlogic.framework.matrix.core.MatrixPrivateDataSourceHandlerFactory; import neatlogic.framework.matrix.dto.*; -import neatlogic.framework.matrix.exception.MatrixAttributeNotFoundException; import neatlogic.framework.util.TableResultUtil; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -135,104 +133,6 @@ public class PrivateDataSourceHandler extends MatrixDataSourceHandlerBase { return TableResultUtil.getResult(theadList, tbodyList, dataVo); } - @Override - protected List> myTableColumnDataSearch(MatrixDataVo dataVo) { - List> resultList = new ArrayList<>(); - IMatrixPrivateDataSourceHandler matrixPrivateDataSourceHandler = MatrixPrivateDataSourceHandlerFactory.getHandler(dataVo.getMatrixUuid()); - List attributeList = matrixPrivateDataSourceHandler.getAttributeList(); - if (CollectionUtils.isEmpty(attributeList)) { - return resultList; - } - Map matrixAttributeMap = new HashMap<>(); - for (MatrixAttributeVo matrixAttributeVo : attributeList) { - matrixAttributeMap.put(matrixAttributeVo.getUuid(), matrixAttributeVo); - } - List columnList = dataVo.getColumnList(); - for (String column : columnList) { - if (!matrixAttributeMap.containsKey(column)) { - throw new MatrixAttributeNotFoundException(dataVo.getMatrixUuid(), column); - } - } - JSONArray defaultValue = dataVo.getDefaultValue(); - if (CollectionUtils.isNotEmpty(defaultValue)) { - for (String value : defaultValue.toJavaList(String.class)) { - if (value.contains(SELECT_COMPOSE_JOINER)) { - List sourceColumnList = new ArrayList<>(); - String[] split = value.split(SELECT_COMPOSE_JOINER); - if (StringUtils.isNotBlank(columnList.get(0))) { - MatrixColumnVo matrixColumnVo = new MatrixColumnVo(columnList.get(0), split[0]); - matrixColumnVo.setExpression(Expression.EQUAL.getExpression()); - sourceColumnList.add(matrixColumnVo); - } - String keywordColumn = null; - if (columnList.size() >= 2) { - keywordColumn = columnList.get(1); - } else { - keywordColumn = columnList.get(0); - } - MatrixAttributeVo matrixAttribute = matrixAttributeMap.get(keywordColumn); - if (matrixAttribute == null) { - throw new MatrixAttributeNotFoundException(dataVo.getMatrixUuid(), keywordColumn); - } - MatrixColumnVo matrixColumnVo = new MatrixColumnVo(keywordColumn, split[1]); - matrixColumnVo.setExpression(Expression.EQUAL.getExpression()); - sourceColumnList.add(matrixColumnVo); - dataVo.setSourceColumnList(sourceColumnList); - List> dataMapList = matrixPrivateDataSourceHandler.searchTableData(dataVo); - if (CollectionUtils.isNotEmpty(dataMapList)) { - //对dataMapList去重 - List> distinctList = new ArrayList<>(); - for (Map dataMap : dataMapList) { - if(distinctList.contains(dataMap)){ - continue; - } - distinctList.add(dataMap); - Map resultMap = new HashMap<>(dataMap.size()); - for (Map.Entry entry : dataMap.entrySet()) { - String attributeUuid = entry.getKey(); - resultMap.put(attributeUuid, matrixAttributeValueHandle(matrixAttributeMap.get(attributeUuid), entry.getValue())); - } - resultList.add(resultMap); - } - } - } - } - } else { - if (!mergeFilterListAndSourceColumnList(dataVo)) { - return resultList; - } - String keywordColumn = dataVo.getKeywordColumn(); - String keyword = dataVo.getKeyword(); - if (StringUtils.isNotBlank(keywordColumn) && StringUtils.isNotBlank(keyword)) { - MatrixAttributeVo matrixAttribute = matrixAttributeMap.get(keywordColumn); - if (matrixAttribute == null) { - throw new MatrixAttributeNotFoundException(dataVo.getMatrixUuid(), keywordColumn); - } - dataVo.setAttrType(matrixAttribute.getType()); - dataVo.setKeywordExpression(Expression.LIKE.getExpression()); - } - //下面逻辑适用于下拉框滚动加载,也可以搜索,但是一页返回的数据量可能会小于pageSize,因为做了去重处理 - List> dataMapList = matrixPrivateDataSourceHandler.searchTableData(dataVo); - if (CollectionUtils.isEmpty(dataMapList)) { - return resultList; - } - List> distinctList = new ArrayList<>(100); - for (Map dataMap : dataMapList) { - if(distinctList.contains(dataMap)){ - continue; - } - distinctList.add(dataMap); - Map resultMap = new HashMap<>(dataMap.size()); - for (Map.Entry entry : dataMap.entrySet()) { - String attributeUuid = entry.getKey(); - resultMap.put(attributeUuid, matrixAttributeValueHandle(matrixAttributeMap.get(attributeUuid), entry.getValue())); - } - resultList.add(resultMap); - } - } - return resultList; - } - @Override protected List> mySearchTableDataNew(MatrixDataVo dataVo) { List> resultList = new ArrayList<>(); @@ -249,7 +149,7 @@ public class PrivateDataSourceHandler extends MatrixDataSourceHandlerBase { MatrixKeywordFilterVo valueFieldFilter = defaultValueFilterVo.getValueFieldFilter(); filterList.add(new MatrixFilterVo(valueFieldFilter.getUuid(), valueFieldFilter.getExpression(), Arrays.asList(valueFieldFilter.getValue()))); MatrixKeywordFilterVo textFieldFilter = defaultValueFilterVo.getTextFieldFilter(); - if (!Objects.equals(valueFieldFilter.getUuid(), textFieldFilter.getUuid())) { + if (textFieldFilter != null && !Objects.equals(valueFieldFilter.getUuid(), textFieldFilter.getUuid())) { filterList.add(new MatrixFilterVo(textFieldFilter.getUuid(), textFieldFilter.getExpression(), Arrays.asList(textFieldFilter.getValue()))); } dataVo.setFilterList(filterList); diff --git a/src/main/java/neatlogic/module/framework/matrix/handler/ViewDataSourceHandler.java b/src/main/java/neatlogic/module/framework/matrix/handler/ViewDataSourceHandler.java index 49c930675..819636267 100644 --- a/src/main/java/neatlogic/module/framework/matrix/handler/ViewDataSourceHandler.java +++ b/src/main/java/neatlogic/module/framework/matrix/handler/ViewDataSourceHandler.java @@ -303,100 +303,6 @@ public class ViewDataSourceHandler extends MatrixDataSourceHandlerBase { return returnObj; } - @Override - protected List> myTableColumnDataSearch(MatrixDataVo dataVo) { - List> resultList = new ArrayList<>(); - MatrixViewVo matrixViewVo = matrixMapper.getMatrixViewByMatrixUuid(dataVo.getMatrixUuid()); - if (matrixViewVo == null) { - throw new MatrixViewNotFoundException(dataVo.getMatrixUuid()); - } - JSONArray attributeArray = (JSONArray) JSONPath.read(matrixViewVo.getConfig(), "attributeList"); - if (CollectionUtils.isNotEmpty(attributeArray)) { - List attributeList = attributeArray.toJavaList(MatrixAttributeVo.class); - Map matrixAttributeMap = new HashMap<>(); - for (MatrixAttributeVo matrixAttributeVo : attributeList) { - matrixAttributeMap.put(matrixAttributeVo.getUuid(), matrixAttributeVo); - } - List columnList = dataVo.getColumnList(); - for (String column : columnList) { - if (!matrixAttributeMap.containsKey(column)) { - throw new MatrixAttributeNotFoundException(dataVo.getMatrixUuid(), column); - } - } - JSONArray defaultValue = dataVo.getDefaultValue(); - if (CollectionUtils.isNotEmpty(defaultValue)) { - for (String value : defaultValue.toJavaList(String.class)) { - if (value.contains(SELECT_COMPOSE_JOINER)) { - List sourceColumnList = new ArrayList<>(); - String[] split = value.split(SELECT_COMPOSE_JOINER); - if (StringUtils.isNotBlank(columnList.get(0))) { - MatrixColumnVo matrixColumnVo = new MatrixColumnVo(columnList.get(0), split[0]); - matrixColumnVo.setExpression(Expression.EQUAL.getExpression()); - sourceColumnList.add(matrixColumnVo); - } - if (columnList.size() >= 2) { - String keywordColumn = columnList.get(1); - MatrixAttributeVo matrixAttribute = matrixAttributeMap.get(keywordColumn); - if (matrixAttribute == null) { - throw new MatrixAttributeNotFoundException(dataVo.getMatrixUuid(), keywordColumn); - } - MatrixColumnVo matrixColumnVo = new MatrixColumnVo(keywordColumn, split[1]); - matrixColumnVo.setExpression(Expression.EQUAL.getExpression()); - sourceColumnList.add(matrixColumnVo); - } - dataVo.setSourceColumnList(sourceColumnList); - List> dataMapList = matrixViewDataMapper.getDynamicTableDataForSelect(dataVo); - resultList.addAll(matrixTableDataValueHandle(dataMapList)); - } - } - } else { - if (!mergeFilterListAndSourceColumnList(dataVo)) { - return resultList; - } - String keywordColumn = dataVo.getKeywordColumn(); - String keyword = dataVo.getKeyword(); - if (StringUtils.isNotBlank(keywordColumn) && StringUtils.isNotBlank(keyword)) { - MatrixAttributeVo matrixAttribute = matrixAttributeMap.get(keywordColumn); - if (matrixAttribute == null) { - throw new MatrixAttributeNotFoundException(dataVo.getMatrixUuid(), keywordColumn); - } - List sourceColumnList = new ArrayList<>(); - MatrixColumnVo matrixColumnVo = new MatrixColumnVo(keywordColumn, keyword); - matrixColumnVo.setExpression(Expression.LIKE.getExpression()); - sourceColumnList.add(matrixColumnVo); - dataVo.setSourceColumnList(sourceColumnList); - } - //下面逻辑适用于下拉框滚动加载,也可以搜索,但是一页返回的数据量可能会小于pageSize,因为做了去重处理 - int rowNum = matrixViewDataMapper.getDynamicTableDataCountForSelect(dataVo); - if (rowNum == 0) { - return resultList; - } - dataVo.setRowNum(rowNum); - if (dataVo.getCurrentPage() > dataVo.getPageCount()) { - return resultList; - } - List> dataMapList = matrixViewDataMapper.getDynamicTableDataForSelect(dataVo); - if (CollectionUtils.isEmpty(dataMapList)) { - return resultList; - } - List> distinctDataMapList = new ArrayList<>(); - List> distinctList = new ArrayList<>(100); - for (Map dataMap : dataMapList) { - if(distinctList.contains(dataMap)){ - continue; - } - distinctDataMapList.add(dataMap); - distinctList.add(dataMap); - if (distinctList.size() >= dataVo.getPageSize()) { - break; - } - } - resultList.addAll(matrixTableDataValueHandle(distinctDataMapList)); - } - } - return resultList; - } - @Override protected List> mySearchTableDataNew(MatrixDataVo dataVo) { List> resultList = new ArrayList<>(); @@ -421,7 +327,9 @@ public class ViewDataSourceHandler extends MatrixDataSourceHandlerBase { MatrixKeywordFilterVo valueFieldFilter = defaultValueFilterVo.getValueFieldFilter(); filterList.add(new MatrixFilterVo(valueFieldFilter.getUuid(), valueFieldFilter.getExpression(), Arrays.asList(valueFieldFilter.getValue()))); MatrixKeywordFilterVo textFieldFilter = defaultValueFilterVo.getTextFieldFilter(); - filterList.add(new MatrixFilterVo(textFieldFilter.getUuid(), textFieldFilter.getExpression(), Arrays.asList(textFieldFilter.getValue()))); + if (textFieldFilter != null) { + filterList.add(new MatrixFilterVo(textFieldFilter.getUuid(), textFieldFilter.getExpression(), Arrays.asList(textFieldFilter.getValue()))); + } dataVo.setFilterList(filterList); List> list = matrixViewDataMapper.getDynamicTableDataList(dataVo); if (CollectionUtils.isNotEmpty(list)) { -- Gitee From 78f2b306d115fa58b1a9fa47eded20e0eed0eada Mon Sep 17 00:00:00 2001 From: linbangquan <1437892690@qq.com> Date: Fri, 17 Nov 2023 18:07:32 +0800 Subject: [PATCH 02/14] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E5=90=8E=E7=AB=AF?= =?UTF-8?q?-=E4=B8=8B=E6=8B=89=E6=A1=86=E3=80=81=E5=8D=95=E9=80=89?= =?UTF-8?q?=E3=80=81=E5=A4=8D=E9=80=89=E7=BB=84=E4=BB=B6=E9=80=89=E4=B8=AD?= =?UTF-8?q?=E5=80=BC=E7=94=B1xxx&=3D&yyy=E6=94=B9=E6=88=90{value:xxx,text:?= =?UTF-8?q?yyy}?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1025915604140032]后端-下拉框、单选、复选组件选中值由xxx&=&yyy改成{value:xxx,text:yyy} http://192.168.0.96:8090/demo/rdm.html#/task-detail/939050947543040/939050947543050/1025915604140032 --- .../matrix/core/IMatrixDataSourceHandler.java | 8 -- .../core/MatrixDataSourceHandlerBase.java | 88 +------------------ .../dto/MatrixDefaultValueFilterVo.java | 6 +- 3 files changed, 7 insertions(+), 95 deletions(-) diff --git a/src/main/java/neatlogic/framework/matrix/core/IMatrixDataSourceHandler.java b/src/main/java/neatlogic/framework/matrix/core/IMatrixDataSourceHandler.java index dd0972993..ae4c8a1b1 100644 --- a/src/main/java/neatlogic/framework/matrix/core/IMatrixDataSourceHandler.java +++ b/src/main/java/neatlogic/framework/matrix/core/IMatrixDataSourceHandler.java @@ -148,14 +148,6 @@ public interface IMatrixDataSourceHandler { */ JSONObject searchTableData(MatrixDataVo dataVo); - /** - * 查询矩阵表格某列数据 - * - * @param dataVo - * @return - */ - List> searchTableColumnData(MatrixDataVo dataVo); - /** * 查询矩阵表格某列数据 * diff --git a/src/main/java/neatlogic/framework/matrix/core/MatrixDataSourceHandlerBase.java b/src/main/java/neatlogic/framework/matrix/core/MatrixDataSourceHandlerBase.java index d4a216445..6ec5fb56f 100644 --- a/src/main/java/neatlogic/framework/matrix/core/MatrixDataSourceHandlerBase.java +++ b/src/main/java/neatlogic/framework/matrix/core/MatrixDataSourceHandlerBase.java @@ -16,19 +16,18 @@ limitations under the License. package neatlogic.framework.matrix.core; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import neatlogic.framework.asynchronization.threadlocal.UserContext; import neatlogic.framework.common.constvalue.ExportFileType; import neatlogic.framework.common.constvalue.Expression; import neatlogic.framework.dependency.constvalue.FrameworkFromType; import neatlogic.framework.dependency.core.DependencyManager; import neatlogic.framework.exception.file.FileTypeNotSupportToExportException; -import neatlogic.framework.exception.type.ParamIrregularException; import neatlogic.framework.matrix.dao.mapper.MatrixMapper; import neatlogic.framework.matrix.dto.*; import neatlogic.framework.matrix.exception.MatrixAttributeNotFoundException; import neatlogic.framework.matrix.exception.MatrixReferencedCannotBeDeletedException; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.poi.ss.usermodel.Workbook; @@ -45,10 +44,6 @@ import java.util.stream.Collectors; * @since 2021/11/5 10:26 **/ public abstract class MatrixDataSourceHandlerBase implements IMatrixDataSourceHandler { - /** - * 下拉列表value和text列的组合连接符 - **/ - protected final static String SELECT_COMPOSE_JOINER = "&=&"; protected static MatrixMapper matrixMapper; @@ -180,45 +175,6 @@ public abstract class MatrixDataSourceHandlerBase implements IMatrixDataSourceHa protected abstract JSONObject myTableDataSearch(MatrixDataVo dataVo); - @Override - public List> searchTableColumnData(MatrixDataVo dataVo) { - List columnList = dataVo.getColumnList(); - if (CollectionUtils.isEmpty(columnList)) { - throw new ParamIrregularException("columnList"); - } - /** 属性集合去重 **/ - List distinctColumList = new ArrayList<>(); - for (String column : columnList) { - if (!distinctColumList.contains(column)) { - distinctColumList.add(column); - } - } - columnList = distinctColumList; - dataVo.setColumnList(distinctColumList); - List> resultList = myTableColumnDataSearch(dataVo); - if (columnList.size() >= 2) { - for (Map resultObj : resultList) { - JSONObject firstObj = resultObj.get(columnList.get(0)); - String firstValue = firstObj.getString("value"); - String firstText = firstObj.getString("text"); - JSONObject secondObj = resultObj.get(columnList.get(1)); - String secondText = secondObj.getString("text"); - secondObj.put("compose", secondText + "(" + firstText + ")"); - firstObj.put("compose", firstValue + SELECT_COMPOSE_JOINER + secondText); - } - } else if (columnList.size() == 1) { - for (Map resultObj : resultList) { - JSONObject firstObj = resultObj.get(columnList.get(0)); - String firstValue = firstObj.getString("value"); - String firstText = firstObj.getString("text"); - firstObj.put("compose", firstValue + SELECT_COMPOSE_JOINER + firstText); - } - } - return resultList; - } - - protected abstract List> myTableColumnDataSearch(MatrixDataVo dataVo); - @Override public List> searchTableDataNew(MatrixDataVo dataVo) { /** 属性集合去重 **/ @@ -355,44 +311,4 @@ public abstract class MatrixDataSourceHandlerBase implements IMatrixDataSourceHa } return true; } - - /** - * 删除重复数据 - * @param columnList - * @param resultList - * @return - */ - protected void deduplicateData(List columnList, List> resultList) { - List exsited = new ArrayList<>(); - deduplicateData(columnList, exsited, resultList); - } - - /** - * 删除重复数据 - * @param columnList - * @param exsited - * @param resultList - * @return - */ - protected void deduplicateData(List columnList, List exsited, List> resultList) { - String firstColumn = columnList.get(0); - String secondColumn = columnList.get(0); - if (columnList.size() >= 2) { - secondColumn = columnList.get(1); - } - Iterator> iterator = resultList.iterator(); - while (iterator.hasNext()) { - Map resultObj = iterator.next(); - JSONObject firstObj = resultObj.get(firstColumn); - JSONObject secondObj = resultObj.get(secondColumn); - String firstValue = firstObj.getString("value"); - String secondText = secondObj.getString("text"); - String compose = firstValue + SELECT_COMPOSE_JOINER + secondText; - if (exsited.contains(compose)) { - iterator.remove(); - } else { - exsited.add(compose); - } - } - } } diff --git a/src/main/java/neatlogic/framework/matrix/dto/MatrixDefaultValueFilterVo.java b/src/main/java/neatlogic/framework/matrix/dto/MatrixDefaultValueFilterVo.java index 006278190..c7a62f183 100644 --- a/src/main/java/neatlogic/framework/matrix/dto/MatrixDefaultValueFilterVo.java +++ b/src/main/java/neatlogic/framework/matrix/dto/MatrixDefaultValueFilterVo.java @@ -2,7 +2,11 @@ package neatlogic.framework.matrix.dto; public class MatrixDefaultValueFilterVo { private final MatrixKeywordFilterVo valueFieldFilter; - private final MatrixKeywordFilterVo textFieldFilter; + private MatrixKeywordFilterVo textFieldFilter; + + public MatrixDefaultValueFilterVo(MatrixKeywordFilterVo valueFieldFilter) { + this.valueFieldFilter = valueFieldFilter; + } public MatrixDefaultValueFilterVo(MatrixKeywordFilterVo valueFieldFilter, MatrixKeywordFilterVo textFieldFilter) { this.valueFieldFilter = valueFieldFilter; -- Gitee From 4c16aeb9f7c90877dd6bbfb07d6e5f936a12fd0c Mon Sep 17 00:00:00 2001 From: linbangquan <1437892690@qq.com> Date: Fri, 17 Nov 2023 19:27:35 +0800 Subject: [PATCH 03/14] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E5=90=8E=E7=AB=AF?= =?UTF-8?q?-=E4=B8=8B=E6=8B=89=E6=A1=86=E3=80=81=E5=8D=95=E9=80=89?= =?UTF-8?q?=E3=80=81=E5=A4=8D=E9=80=89=E7=BB=84=E4=BB=B6=E9=80=89=E4=B8=AD?= =?UTF-8?q?=E5=80=BC=E7=94=B1xxx&=3D&yyy=E6=94=B9=E6=88=90{value:xxx,text:?= =?UTF-8?q?yyy}?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1025915604140032]后端-下拉框、单选、复选组件选中值由xxx&=&yyy改成{value:xxx,text:yyy} http://192.168.0.96:8090/demo/rdm.html#/task-detail/939050947543040/939050947543050/1025915604140032 --- .../attribute/core/IFormAttributeHandler.java | 4 - .../attribute/handler/CascadeHandler.java | 137 +----------------- 2 files changed, 2 insertions(+), 139 deletions(-) diff --git a/src/main/java/neatlogic/framework/form/attribute/core/IFormAttributeHandler.java b/src/main/java/neatlogic/framework/form/attribute/core/IFormAttributeHandler.java index c69e50933..9f5c59ba1 100644 --- a/src/main/java/neatlogic/framework/form/attribute/core/IFormAttributeHandler.java +++ b/src/main/java/neatlogic/framework/form/attribute/core/IFormAttributeHandler.java @@ -32,10 +32,6 @@ import java.util.List; * @Description: 表单组件接口,新增表单组件必须实现此接口 */ public interface IFormAttributeHandler { - /** - * 下拉列表value和text列的组合连接符 - **/ - String SELECT_COMPOSE_JOINER = "&=&"; /** * @param @return diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/CascadeHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/CascadeHandler.java index bdf351e57..5a112d0da 100644 --- a/src/main/java/neatlogic/module/framework/form/attribute/handler/CascadeHandler.java +++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/CascadeHandler.java @@ -16,25 +16,15 @@ limitations under the License. package neatlogic.module.framework.form.attribute.handler; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import neatlogic.framework.common.constvalue.ParamType; -import neatlogic.framework.common.dto.ValueTextVo; import neatlogic.framework.form.attribute.core.FormHandlerBase; -import neatlogic.framework.form.attribute.core.IFormAttributeHandler; import neatlogic.framework.form.constvalue.FormConditionModel; import neatlogic.framework.form.constvalue.FormHandler; import neatlogic.framework.form.dto.AttributeDataVo; import neatlogic.framework.form.dto.FormAttributeVo; import neatlogic.framework.form.exception.AttributeValidException; -import neatlogic.framework.matrix.core.IMatrixDataSourceHandler; -import neatlogic.framework.matrix.core.MatrixDataSourceHandlerFactory; -import neatlogic.framework.matrix.dto.MatrixColumnVo; -import neatlogic.framework.matrix.dto.MatrixDataVo; -import neatlogic.framework.matrix.dto.MatrixVo; -import neatlogic.framework.matrix.exception.MatrixDataSourceHandlerNotFoundException; -import neatlogic.framework.matrix.exception.MatrixNotFoundException; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -106,131 +96,8 @@ public class CascadeHandler extends FormHandlerBase { @Override public Object textConversionValue(Object text, JSONObject config) { return text; -// Object result = null; -// if (CollectionUtils.isNotEmpty(values)) { -// result = getTextOrValue(config, values, ConversionType.TOVALUE.getValue()); -// } -// return result; - } - - private Object getTextOrValue(JSONObject configObj, List valueList, String conversionType) { - List result = new ArrayList<>(); - String dataSource = configObj.getString("dataSource"); - if ("static".equals(dataSource)) { - JSONArray dataList = configObj.getJSONArray("dataList"); - for (String value : valueList) { - for (int i = 0; i < dataList.size(); i++) { - JSONObject dataObject = dataList.getJSONObject(i); - if (ConversionType.TOTEXT.getValue().equals(conversionType) && Objects.equals(dataObject.getString("value"), value)) { - result.add(dataObject.getString("text")); - dataList = dataObject.getJSONArray("children"); - break; - } else if (ConversionType.TOVALUE.getValue().equals(conversionType) && Objects.equals(dataObject.getString("text"), value)) { - result.add(dataObject.getString("value")); - dataList = dataObject.getJSONArray("children"); - break; - } - } - } - } else if ("matrix".equals(dataSource)) {// 其他,如动态数据源 - String matrixUuid = configObj.getString("matrixUuid"); - List mappingList = - JSON.parseArray(JSON.toJSONString(configObj.getJSONArray("mapping")), ValueTextVo.class); - if (StringUtils.isNotBlank(matrixUuid) && CollectionUtils.isNotEmpty(valueList) - && CollectionUtils.isNotEmpty(mappingList)) { - if (valueList.size() > 0 && mappingList.size() > 0) { - if (ConversionType.TOTEXT.getValue().equals(conversionType)) { - List sourceColumnList = new ArrayList<>(); - result.add(getText(matrixUuid, mappingList.get(0), valueList.get(0), sourceColumnList)); - if (valueList.size() > 1 && mappingList.size() > 1) { - result.add(getText(matrixUuid, mappingList.get(1), valueList.get(1), sourceColumnList)); - if (valueList.size() > 2 && mappingList.size() > 2) { - result.add(getText(matrixUuid, mappingList.get(2), valueList.get(2), sourceColumnList)); - } - } - } else if (ConversionType.TOVALUE.getValue().equals(conversionType)) { - result.add(getValueForCascade(matrixUuid, mappingList.get(0), valueList.get(0))); - if (valueList.size() > 1 && mappingList.size() > 1) { - result.add(getValueForCascade(matrixUuid, mappingList.get(1), valueList.get(1))); - if (valueList.size() > 2 && mappingList.size() > 2) { - result.add(getValueForCascade(matrixUuid, mappingList.get(2), valueList.get(2))); - } - } - } - } - } - } - return result; - } - - private String getText(String matrixUuid, ValueTextVo mapping, String value, List sourceColumnList) { - if (StringUtils.isBlank(value)) { - return value; - } - String[] split = value.split(IFormAttributeHandler.SELECT_COMPOSE_JOINER); - try { - MatrixVo matrixVo = matrixMapper.getMatrixByUuid(matrixUuid); - if (matrixVo == null) { - throw new MatrixNotFoundException(matrixUuid); - } - IMatrixDataSourceHandler matrixDataSourceHandler = MatrixDataSourceHandlerFactory.getHandler(matrixVo.getType()); - if (matrixDataSourceHandler == null) { - throw new MatrixDataSourceHandlerNotFoundException(matrixVo.getType()); - } - MatrixDataVo dataVo = new MatrixDataVo(); - dataVo.setMatrixUuid(matrixUuid); - List columnList = new ArrayList<>(); - columnList.add((String) mapping.getValue()); - columnList.add(mapping.getText()); - dataVo.setColumnList(columnList); - sourceColumnList.add(new MatrixColumnVo((String) mapping.getValue(), split[0])); - sourceColumnList.add(new MatrixColumnVo(mapping.getText(), split[1])); - dataVo.setSourceColumnList(sourceColumnList); - List> tbodyList = matrixDataSourceHandler.searchTableColumnData(dataVo); - for (Map firstObj : tbodyList) { - JSONObject textObj = firstObj.get(mapping.getText()); - if (Objects.equals(textObj.getString("value"), split[1])) { - return textObj.getString("text"); - } - } - } catch (Exception e) { - e.printStackTrace(); - } - return split[1]; } - private String getValueForCascade(String matrixUuid, ValueTextVo mapping, String value) { - if (StringUtils.isBlank(value)) { - return value; - } - try { - MatrixVo matrixVo = matrixMapper.getMatrixByUuid(matrixUuid); - if (matrixVo == null) { - throw new MatrixNotFoundException(matrixUuid); - } - IMatrixDataSourceHandler matrixDataSourceHandler = MatrixDataSourceHandlerFactory.getHandler(matrixVo.getType()); - if (matrixDataSourceHandler == null) { - throw new MatrixDataSourceHandlerNotFoundException(matrixVo.getType()); - } - MatrixDataVo dataVo = new MatrixDataVo(); - dataVo.setMatrixUuid(matrixUuid); - List columnList = new ArrayList<>(); - columnList.add((String) mapping.getValue()); - columnList.add(mapping.getText()); - dataVo.setColumnList(columnList); - List> tbodyList = matrixDataSourceHandler.searchTableColumnData(dataVo); - for (Map firstObj : tbodyList) { - JSONObject valueObj = firstObj.get(mapping.getValue()); - if (valueObj.getString("compose").contains(value)) { - JSONObject textObj = firstObj.get(mapping.getText()); - return valueObj.getString("value") + IFormAttributeHandler.SELECT_COMPOSE_JOINER + textObj.getString("value"); - } - } - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } @Override public String getIcon() { -- Gitee From 52dd2fa70fe935be456db625cdbed909d5140a86 Mon Sep 17 00:00:00 2001 From: linbangquan <1437892690@qq.com> Date: Fri, 17 Nov 2023 19:29:29 +0800 Subject: [PATCH 04/14] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E5=90=8E=E7=AB=AF?= =?UTF-8?q?-=E4=B8=8B=E6=8B=89=E6=A1=86=E3=80=81=E5=8D=95=E9=80=89?= =?UTF-8?q?=E3=80=81=E5=A4=8D=E9=80=89=E7=BB=84=E4=BB=B6=E9=80=89=E4=B8=AD?= =?UTF-8?q?=E5=80=BC=E7=94=B1xxx&=3D&yyy=E6=94=B9=E6=88=90{value:xxx,text:?= =?UTF-8?q?yyy}?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1025915604140032]后端-下拉框、单选、复选组件选中值由xxx&=&yyy改成{value:xxx,text:yyy} http://192.168.0.96:8090/demo/rdm.html#/task-detail/939050947543040/939050947543050/1025915604140032 --- .../form/attribute/core/FormHandlerBase.java | 72 +------------------ 1 file changed, 2 insertions(+), 70 deletions(-) diff --git a/src/main/java/neatlogic/framework/form/attribute/core/FormHandlerBase.java b/src/main/java/neatlogic/framework/form/attribute/core/FormHandlerBase.java index 1d3a7b01e..6cd37413a 100644 --- a/src/main/java/neatlogic/framework/form/attribute/core/FormHandlerBase.java +++ b/src/main/java/neatlogic/framework/form/attribute/core/FormHandlerBase.java @@ -18,23 +18,16 @@ package neatlogic.framework.form.attribute.core; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; -import neatlogic.framework.common.dto.ValueTextVo; import neatlogic.framework.form.dto.AttributeDataVo; import neatlogic.framework.form.exception.AttributeValidException; -import neatlogic.framework.matrix.core.IMatrixDataSourceHandler; -import neatlogic.framework.matrix.core.MatrixDataSourceHandlerFactory; import neatlogic.framework.matrix.dao.mapper.MatrixMapper; -import neatlogic.framework.matrix.dto.MatrixDataVo; -import neatlogic.framework.matrix.dto.MatrixVo; -import neatlogic.framework.matrix.exception.MatrixDataSourceHandlerNotFoundException; -import neatlogic.framework.matrix.exception.MatrixNotFoundException; import neatlogic.framework.util.$; import neatlogic.framework.util.I18n; import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.lang3.StringUtils; import javax.annotation.Resource; -import java.util.*; +import java.util.Collections; +import java.util.List; public abstract class FormHandlerBase implements IFormAttributeHandler, IFormAttributeDataConversionHandler { @@ -72,67 +65,6 @@ public abstract class FormHandlerBase implements IFormAttributeHandler, IFormAtt return "form"; } - protected String getValue(String matrixUuid, ValueTextVo mapping, String value) { - if (StringUtils.isBlank(value)) { - return value; - } - try { - MatrixVo matrixVo = matrixMapper.getMatrixByUuid(matrixUuid); - if (matrixVo == null) { - throw new MatrixNotFoundException(matrixUuid); - } - IMatrixDataSourceHandler matrixDataSourceHandler = MatrixDataSourceHandlerFactory.getHandler(matrixVo.getType()); - if (matrixDataSourceHandler == null) { - throw new MatrixDataSourceHandlerNotFoundException(matrixVo.getType()); - } - String valueField = (String) mapping.getValue(); - String textField = mapping.getText(); - MatrixDataVo dataVo = new MatrixDataVo(); - dataVo.setMatrixUuid(matrixUuid); - List columnList = new ArrayList<>(); - columnList.add((String) mapping.getValue()); - columnList.add(mapping.getText()); - dataVo.setColumnList(columnList); - dataVo.setKeyword(value); - dataVo.setKeywordColumn(textField); - for (int i = 0; i < 10; i++) { - List> tbodyList = matrixDataSourceHandler.searchTableDataNew(dataVo); - for (Map tbody : tbodyList) { - JSONObject textObj = tbody.get(textField); - if (Objects.equals(value, textObj.getString("text"))) { - JSONObject valueObj = tbody.get(valueField); - return valueObj.getString("value") + IFormAttributeHandler.SELECT_COMPOSE_JOINER + value; - } - } - if (dataVo.getCurrentPage() >= dataVo.getPageCount()) { - break; - } - dataVo.setCurrentPage(dataVo.getCurrentPage() + 1); - } -// List> tbodyList = matrixDataSourceHandler.searchTableColumnData(dataVo); -// for (Map firstObj : tbodyList) { -// JSONObject valueObj = firstObj.get(mapping.getValue()); -// /** 当text与value字段相同时,不同类型的矩阵字段,拼接value的逻辑不同,下拉、用户、组、角色,按uuid&=&text拼接,其余按value&=&value拼接 **/ -// if (mapping.getValue().equals(mapping.getText()) -// && (GroupSearch.USER.getValue().equals(valueObj.getString("type")) -// || GroupSearch.ROLE.getValue().equals(valueObj.getString("type")) -// || GroupSearch.TEAM.getValue().equals(valueObj.getString("type")) -// || FormHandlerType.SELECT.toString().equals(valueObj.getString("type"))) -// && value.equals(valueObj.getString("text"))) { -// return valueObj.getString("value") + IFormAttributeHandler.SELECT_COMPOSE_JOINER + valueObj.getString("text"); -// } else if (mapping.getValue().equals(mapping.getText()) && value.equals(valueObj.getString("text"))) { -// return valueObj.getString("value") + IFormAttributeHandler.SELECT_COMPOSE_JOINER + valueObj.getString("value"); -// } -// if (valueObj.getString("compose").contains(value)) { -// return valueObj.getString("compose"); -// } -// } - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - @Override public List indexFieldContentList(String data) { List contentList = myIndexFieldContentList(data); -- Gitee From 2a6c12e20a4ac4ce20a77b86b96e68ae7608498e Mon Sep 17 00:00:00 2001 From: linbangquan <1437892690@qq.com> Date: Fri, 17 Nov 2023 19:33:19 +0800 Subject: [PATCH 05/14] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E5=90=8E=E7=AB=AF?= =?UTF-8?q?-=E4=B8=8B=E6=8B=89=E6=A1=86=E3=80=81=E5=8D=95=E9=80=89?= =?UTF-8?q?=E3=80=81=E5=A4=8D=E9=80=89=E7=BB=84=E4=BB=B6=E9=80=89=E4=B8=AD?= =?UTF-8?q?=E5=80=BC=E7=94=B1xxx&=3D&yyy=E6=94=B9=E6=88=90{value:xxx,text:?= =?UTF-8?q?yyy}?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1025915604140032]后端-下拉框、单选、复选组件选中值由xxx&=&yyy改成{value:xxx,text:yyy} http://192.168.0.96:8090/demo/rdm.html#/task-detail/939050947543040/939050947543050/1025915604140032 --- .../attribute/handler/CheckboxHandler.java | 70 +------------------ 1 file changed, 3 insertions(+), 67 deletions(-) diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/CheckboxHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/CheckboxHandler.java index aaa22d7ff..216c807aa 100644 --- a/src/main/java/neatlogic/module/framework/form/attribute/handler/CheckboxHandler.java +++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/CheckboxHandler.java @@ -16,18 +16,15 @@ limitations under the License. package neatlogic.module.framework.form.attribute.handler; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import neatlogic.framework.common.constvalue.ParamType; -import neatlogic.framework.common.dto.ValueTextVo; +import neatlogic.framework.form.attribute.core.FormHandlerBase; import neatlogic.framework.form.constvalue.FormConditionModel; import neatlogic.framework.form.constvalue.FormHandler; import neatlogic.framework.form.dto.AttributeDataVo; import neatlogic.framework.form.dto.FormAttributeVo; import neatlogic.framework.form.exception.AttributeValidException; -import neatlogic.framework.form.attribute.core.FormHandlerBase; -import neatlogic.framework.form.attribute.core.IFormAttributeHandler; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; import neatlogic.module.framework.form.service.FormService; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; @@ -36,7 +33,6 @@ import org.springframework.stereotype.Component; import javax.annotation.Resource; import java.util.*; -import java.util.stream.Collectors; @Component public class CheckboxHandler extends FormHandlerBase { @@ -74,12 +70,6 @@ public class CheckboxHandler extends FormHandlerBase { @Override public Object valueConversionText(AttributeDataVo attributeDataVo, JSONObject configObj) { -// List valueList = JSON.parseArray(JSON.toJSONString(attributeDataVo.getDataObj()), String.class); -// if (CollectionUtils.isNotEmpty(valueList)) { -// return getTextOrValue(configObj, valueList, ConversionType.TOTEXT.getValue()); -// } else { -// return valueList; -// } JSONObject resultObj = getMyDetailedData(attributeDataVo, configObj); JSONArray textArray = resultObj.getJSONArray("textList"); if (CollectionUtils.isNotEmpty(textArray)) { @@ -111,60 +101,6 @@ public class CheckboxHandler extends FormHandlerBase { List list = new ArrayList<>(); list.add(value); return list; -// Object result = null; -// if (CollectionUtils.isNotEmpty(values)) { -// result = getTextOrValue(config, values, ConversionType.TOVALUE.getValue()); -// } -// return result; - } - - private Object getTextOrValue(JSONObject configObj, List valueList, String conversionType) { - List result = new ArrayList<>(); - String dataSource = configObj.getString("dataSource"); - if ("static".equals(dataSource)) { - Map valueTextMap = new HashMap<>(); - List dataList = - JSON.parseArray(JSON.toJSONString(configObj.getJSONArray("dataList")), ValueTextVo.class); - if (CollectionUtils.isNotEmpty(dataList)) { - for (ValueTextVo data : dataList) { - valueTextMap.put(data.getValue(), data.getText()); - } - } - if (ConversionType.TOTEXT.getValue().equals(conversionType)) { - for (String value : valueList) { - String text = valueTextMap.get(value); - if (text != null) { - result.add(text); - } else { - result.add(value); - } - } - } else if (ConversionType.TOVALUE.getValue().equals(conversionType)) { - for (String value : valueList) { - result.add(valueTextMap.get(value)); - } - } - } else if ("matrix".equals(dataSource)) {// 其他,如动态数据源 - if (ConversionType.TOTEXT.getValue().equals(conversionType)) { - for (String value : valueList) { - if (value.contains(IFormAttributeHandler.SELECT_COMPOSE_JOINER)) { - result.add(value.split(IFormAttributeHandler.SELECT_COMPOSE_JOINER)[1]); - } else { - result.add(value); - } - } - } else if (ConversionType.TOVALUE.getValue().equals(conversionType)) { - String matrixUuid = configObj.getString("matrixUuid"); - ValueTextVo mapping = JSON.toJavaObject(configObj.getJSONObject("mapping"), ValueTextVo.class); - if (StringUtils.isNotBlank(matrixUuid) && CollectionUtils.isNotEmpty(valueList) - && mapping != null) { - for (String value : valueList) { - result.add(getValue(matrixUuid, mapping, value)); - } - } - } - } - return result; } @Override -- Gitee From 7839e6da9ea223e0ecd636433e7896444c66f4d5 Mon Sep 17 00:00:00 2001 From: linbangquan <1437892690@qq.com> Date: Fri, 17 Nov 2023 19:36:29 +0800 Subject: [PATCH 06/14] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E5=90=8E=E7=AB=AF?= =?UTF-8?q?-=E4=B8=8B=E6=8B=89=E6=A1=86=E3=80=81=E5=8D=95=E9=80=89?= =?UTF-8?q?=E3=80=81=E5=A4=8D=E9=80=89=E7=BB=84=E4=BB=B6=E9=80=89=E4=B8=AD?= =?UTF-8?q?=E5=80=BC=E7=94=B1xxx&=3D&yyy=E6=94=B9=E6=88=90{value:xxx,text:?= =?UTF-8?q?yyy}?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1025915604140032]后端-下拉框、单选、复选组件选中值由xxx&=&yyy改成{value:xxx,text:yyy} http://192.168.0.96:8090/demo/rdm.html#/task-detail/939050947543040/939050947543050/1025915604140032 --- .../form/attribute/handler/RadioHandler.java | 69 ++++++------------- 1 file changed, 21 insertions(+), 48 deletions(-) diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/RadioHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/RadioHandler.java index 5bd61a59e..ed8137f82 100644 --- a/src/main/java/neatlogic/module/framework/form/attribute/handler/RadioHandler.java +++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/RadioHandler.java @@ -16,18 +16,15 @@ limitations under the License. package neatlogic.module.framework.form.attribute.handler; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import neatlogic.framework.common.constvalue.ParamType; -import neatlogic.framework.common.dto.ValueTextVo; +import neatlogic.framework.form.attribute.core.FormHandlerBase; import neatlogic.framework.form.constvalue.FormConditionModel; import neatlogic.framework.form.constvalue.FormHandler; import neatlogic.framework.form.dto.AttributeDataVo; import neatlogic.framework.form.dto.FormAttributeVo; import neatlogic.framework.form.exception.AttributeValidException; -import neatlogic.framework.form.attribute.core.FormHandlerBase; -import neatlogic.framework.form.attribute.core.IFormAttributeHandler; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; import neatlogic.module.framework.form.service.FormService; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; @@ -55,7 +52,24 @@ public class RadioHandler extends FormHandlerBase { @Override public Object conversionDataType(Object source, String attributeLabel) { - return convertToString(source, attributeLabel); + if (source == null) { + return null; + } + if (source instanceof JSONObject) { + return source; + } else if (source instanceof String) { + String sourceStr = (String) source; + if (sourceStr.startsWith("{") && sourceStr.endsWith("}")) { + try { + return JSONObject.parseObject(sourceStr); + } catch (Exception e) { + throw new AttributeValidException(attributeLabel); + } + } else { + return source; + } + } + throw new AttributeValidException(attributeLabel); } @Override @@ -73,11 +87,6 @@ public class RadioHandler extends FormHandlerBase { @Override public Object valueConversionText(AttributeDataVo attributeDataVo, JSONObject configObj) { -// String value = (String) attributeDataVo.getDataObj(); -// if (StringUtils.isNotBlank(value)) { -// return getTextOrValue(value, configObj, ConversionType.TOTEXT.getValue()); -// } -// return value; JSONObject resultObj = getMyDetailedData(attributeDataVo, configObj); JSONArray textArray = resultObj.getJSONArray("textList"); if (CollectionUtils.isNotEmpty(textArray)) { @@ -100,42 +109,6 @@ public class RadioHandler extends FormHandlerBase { @Override public Object textConversionValue(Object text, JSONObject config) { return formService.textConversionValueForSelectHandler(text, config); -// Object result = null; -// if (CollectionUtils.isNotEmpty(values)) { -// result = getTextOrValue(values.get(0), config, ConversionType.TOVALUE.getValue()); -// } -// return result; - } - - private Object getTextOrValue(String value, JSONObject configObj, String conversionType) { - Object result = null; - String dataSource = configObj.getString("dataSource"); - if ("static".equals(dataSource)) { - List dataList = JSON.parseArray(configObj.getString("dataList"), ValueTextVo.class); - if (CollectionUtils.isNotEmpty(dataList)) { - for (ValueTextVo data : dataList) { - if (ConversionType.TOTEXT.getValue().equals(conversionType) && value.equals(data.getValue())) { - result = data.getText(); - break; - } else if (ConversionType.TOVALUE.getValue().equals(conversionType) && value.equals(data.getText())) { - result = data.getValue(); - break; - } - } - } - } else if ("matrix".equals(dataSource)) {// 其他,如动态数据源 - if (ConversionType.TOTEXT.getValue().equals(conversionType) && value.contains(IFormAttributeHandler.SELECT_COMPOSE_JOINER)) { - result = value.split(IFormAttributeHandler.SELECT_COMPOSE_JOINER)[1]; - } else if (ConversionType.TOVALUE.getValue().equals(conversionType)) { - String matrixUuid = configObj.getString("matrixUuid"); - ValueTextVo mapping = JSON.toJavaObject(configObj.getJSONObject("mapping"), ValueTextVo.class); - if (StringUtils.isNotBlank(matrixUuid) && StringUtils.isNotBlank(value) - && mapping != null) { - result = getValue(matrixUuid, mapping, value); - } - } - } - return result; } @Override -- Gitee From e37a3af5d1930d30e81a3efbd2f3ee01d46742a1 Mon Sep 17 00:00:00 2001 From: linbangquan <1437892690@qq.com> Date: Fri, 17 Nov 2023 19:39:10 +0800 Subject: [PATCH 07/14] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E5=90=8E=E7=AB=AF?= =?UTF-8?q?-=E4=B8=8B=E6=8B=89=E6=A1=86=E3=80=81=E5=8D=95=E9=80=89?= =?UTF-8?q?=E3=80=81=E5=A4=8D=E9=80=89=E7=BB=84=E4=BB=B6=E9=80=89=E4=B8=AD?= =?UTF-8?q?=E5=80=BC=E7=94=B1xxx&=3D&yyy=E6=94=B9=E6=88=90{value:xxx,text:?= =?UTF-8?q?yyy}?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1025915604140032]后端-下拉框、单选、复选组件选中值由xxx&=&yyy改成{value:xxx,text:yyy} http://192.168.0.96:8090/demo/rdm.html#/task-detail/939050947543040/939050947543050/1025915604140032 --- .../form/attribute/handler/SelectHandler.java | 52 +++++++++++++------ 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/SelectHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/SelectHandler.java index 86ac25025..45c687fdc 100644 --- a/src/main/java/neatlogic/module/framework/form/attribute/handler/SelectHandler.java +++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/SelectHandler.java @@ -16,18 +16,15 @@ package neatlogic.module.framework.form.attribute.handler; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import neatlogic.framework.common.constvalue.ParamType; -import neatlogic.framework.common.dto.ValueTextVo; +import neatlogic.framework.form.attribute.core.FormHandlerBase; import neatlogic.framework.form.constvalue.FormConditionModel; import neatlogic.framework.form.constvalue.FormHandler; import neatlogic.framework.form.dto.AttributeDataVo; import neatlogic.framework.form.dto.FormAttributeVo; import neatlogic.framework.form.exception.AttributeValidException; -import neatlogic.framework.form.attribute.core.FormHandlerBase; -import neatlogic.framework.form.attribute.core.IFormAttributeHandler; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; import neatlogic.module.framework.form.service.FormService; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; @@ -36,7 +33,6 @@ import org.springframework.stereotype.Component; import javax.annotation.Resource; import java.util.*; -import java.util.stream.Collectors; @Component public class SelectHandler extends FormHandlerBase { @@ -74,19 +70,27 @@ public class SelectHandler extends FormHandlerBase { if (source == null) { return null; } - if (source instanceof String) { + if (source instanceof JSONObject) { + return source; + } else if (source instanceof JSONArray) { + return source; + } else if (source instanceof String) { String sourceStr = (String) source; - if (sourceStr.startsWith("[") && sourceStr.endsWith("]")) { + if (sourceStr.startsWith("{") && sourceStr.endsWith("}")) { try { - return JSONObject.parseArray((String) source); + return JSONObject.parseObject(sourceStr); + } catch (Exception e) { + throw new AttributeValidException(attributeLabel); + } + } else if (sourceStr.startsWith("[") && sourceStr.endsWith("]")) { + try { + return JSONObject.parseArray(sourceStr); } catch (Exception e) { throw new AttributeValidException(attributeLabel); } } else { return source; } - } else if (source instanceof JSONArray) { - return source; } throw new AttributeValidException(attributeLabel); } @@ -313,16 +317,34 @@ public class SelectHandler extends FormHandlerBase { @Override protected List myIndexFieldContentList(String data) { List contentList = new ArrayList<>(); - if (data.startsWith("[") && data.endsWith("]")) { + if (data.startsWith("{") && data.endsWith("}")) { + JSONObject jsonObj = JSONObject.parseObject(data); + String value = jsonObj.getString("value"); + contentList.add(value); + String text = jsonObj.getString("text"); + if (StringUtils.isNotBlank(text)) { + contentList.add(text); + } + } else if (data.startsWith("[") && data.endsWith("]")) { JSONArray jsonArray = JSONArray.parseArray(data); for (Object obj : jsonArray) { if (obj != null) { - contentList.addAll(Arrays.asList(obj.toString().split("&=&"))); + if (obj instanceof JSONObject) { + JSONObject jsonObj = (JSONObject) obj; + String value = jsonObj.getString("value"); + contentList.add(value); + String text = jsonObj.getString("text"); + if (StringUtils.isNotBlank(text)) { + contentList.add(text); + } + } else { + contentList.add(obj.toString()); + } } } return JSONObject.parseArray(jsonArray.toJSONString(), String.class); } else { - contentList.addAll(Arrays.asList(data.split("&=&"))); + contentList.add(data); } return contentList; } -- Gitee From 9c92384f769eedf1e5c259cdb31a20337a297175 Mon Sep 17 00:00:00 2001 From: linbangquan <1437892690@qq.com> Date: Sat, 18 Nov 2023 11:37:41 +0800 Subject: [PATCH 08/14] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E5=90=8E=E7=AB=AF?= =?UTF-8?q?-=E4=B8=8B=E6=8B=89=E6=A1=86=E3=80=81=E5=8D=95=E9=80=89?= =?UTF-8?q?=E3=80=81=E5=A4=8D=E9=80=89=E7=BB=84=E4=BB=B6=E9=80=89=E4=B8=AD?= =?UTF-8?q?=E5=80=BC=E7=94=B1xxx&=3D&yyy=E6=94=B9=E6=88=90{value:xxx,text:?= =?UTF-8?q?yyy}?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1025915604140032]后端-下拉框、单选、复选组件选中值由xxx&=&yyy改成{value:xxx,text:yyy} http://192.168.0.96:8090/demo/rdm.html#/task-detail/939050947543040/939050947543050/1025915604140032 --- .../attribute/handler/CheckboxHandler.java | 10 +- .../form/attribute/handler/RadioHandler.java | 7 +- .../form/attribute/handler/SelectHandler.java | 12 +- .../framework/form/service/FormService.java | 3 +- .../form/service/FormServiceImpl.java | 134 ++++++++++++------ 5 files changed, 109 insertions(+), 57 deletions(-) diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/CheckboxHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/CheckboxHandler.java index 216c807aa..b8b2bb94b 100644 --- a/src/main/java/neatlogic/module/framework/form/attribute/handler/CheckboxHandler.java +++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/CheckboxHandler.java @@ -19,6 +19,7 @@ package neatlogic.module.framework.form.attribute.handler; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import neatlogic.framework.common.constvalue.ParamType; +import neatlogic.framework.common.dto.ValueTextVo; import neatlogic.framework.form.attribute.core.FormHandlerBase; import neatlogic.framework.form.constvalue.FormConditionModel; import neatlogic.framework.form.constvalue.FormHandler; @@ -91,15 +92,10 @@ public class CheckboxHandler extends FormHandlerBase { @Override public Object textConversionValue(Object text, JSONObject config) { - Object value = formService.textConversionValueForSelectHandler(text, config); - if (value == null) { + List list = formService.textConversionValueForSelectHandler(text, config); + if (CollectionUtils.isEmpty(list)) { return null; } - if (value instanceof List) { - return value; - } - List list = new ArrayList<>(); - list.add(value); return list; } diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/RadioHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/RadioHandler.java index ed8137f82..f5db49074 100644 --- a/src/main/java/neatlogic/module/framework/form/attribute/handler/RadioHandler.java +++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/RadioHandler.java @@ -19,6 +19,7 @@ package neatlogic.module.framework.form.attribute.handler; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import neatlogic.framework.common.constvalue.ParamType; +import neatlogic.framework.common.dto.ValueTextVo; import neatlogic.framework.form.attribute.core.FormHandlerBase; import neatlogic.framework.form.constvalue.FormConditionModel; import neatlogic.framework.form.constvalue.FormHandler; @@ -108,7 +109,11 @@ public class RadioHandler extends FormHandlerBase { @Override public Object textConversionValue(Object text, JSONObject config) { - return formService.textConversionValueForSelectHandler(text, config); + List list = formService.textConversionValueForSelectHandler(text, config); + if (CollectionUtils.isNotEmpty(list)) { + return list.get(0); + } + return null; } @Override diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/SelectHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/SelectHandler.java index 45c687fdc..a04abdf67 100644 --- a/src/main/java/neatlogic/module/framework/form/attribute/handler/SelectHandler.java +++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/SelectHandler.java @@ -19,6 +19,7 @@ package neatlogic.module.framework.form.attribute.handler; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import neatlogic.framework.common.constvalue.ParamType; +import neatlogic.framework.common.dto.ValueTextVo; import neatlogic.framework.form.attribute.core.FormHandlerBase; import neatlogic.framework.form.constvalue.FormConditionModel; import neatlogic.framework.form.constvalue.FormHandler; @@ -202,20 +203,15 @@ public class SelectHandler extends FormHandlerBase { @Override public Object textConversionValue(Object text, JSONObject config) { - Object value = formService.textConversionValueForSelectHandler(text, config); - if (value == null) { + List list = formService.textConversionValueForSelectHandler(text, config); + if (CollectionUtils.isEmpty(list)) { return null; } - if (value instanceof List) { - return value; - } boolean isMultiple = config.getBooleanValue("isMultiple"); if (isMultiple) { - List list = new ArrayList<>(); - list.add(value); return list; } - return value; + return list.get(0); // Object result = null; // if (CollectionUtils.isNotEmpty(values)) { // boolean isMultiple = config.getBooleanValue("isMultiple"); diff --git a/src/main/java/neatlogic/module/framework/form/service/FormService.java b/src/main/java/neatlogic/module/framework/form/service/FormService.java index fc09e51fb..a15ae4eba 100644 --- a/src/main/java/neatlogic/module/framework/form/service/FormService.java +++ b/src/main/java/neatlogic/module/framework/form/service/FormService.java @@ -17,6 +17,7 @@ limitations under the License. package neatlogic.module.framework.form.service; import com.alibaba.fastjson.JSONArray; +import neatlogic.framework.common.dto.ValueTextVo; import neatlogic.framework.form.dto.AttributeDataVo; import neatlogic.framework.form.dto.FormAttributeVo; import com.alibaba.fastjson.JSONObject; @@ -38,7 +39,7 @@ public interface FormService { */ JSONArray staticListPasswordEncrypt(JSONArray data, JSONObject config); - Object textConversionValueForSelectHandler(Object text, JSONObject config); + List textConversionValueForSelectHandler(Object text, JSONObject config); /** * 校验表单数据有效性,并针对特殊组件数据进行相应处理,如密码类型组件对数据进行加密处理 diff --git a/src/main/java/neatlogic/module/framework/form/service/FormServiceImpl.java b/src/main/java/neatlogic/module/framework/form/service/FormServiceImpl.java index 46c7b70d1..4351f031b 100644 --- a/src/main/java/neatlogic/module/framework/form/service/FormServiceImpl.java +++ b/src/main/java/neatlogic/module/framework/form/service/FormServiceImpl.java @@ -16,20 +16,18 @@ limitations under the License. package neatlogic.module.framework.form.service; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import neatlogic.framework.common.dto.ValueTextVo; -import neatlogic.framework.common.util.RC4Util; -import neatlogic.framework.crossover.CrossoverServiceFactory; import neatlogic.framework.dependency.core.DependencyManager; import neatlogic.framework.form.attribute.core.FormAttributeHandlerFactory; import neatlogic.framework.form.attribute.core.IFormAttributeHandler; -import neatlogic.framework.form.constvalue.FormHandler; import neatlogic.framework.form.dao.mapper.FormMapper; import neatlogic.framework.form.dto.AttributeDataVo; import neatlogic.framework.form.dto.FormAttributeMatrixVo; import neatlogic.framework.form.dto.FormAttributeVo; import neatlogic.framework.form.dto.FormVersionVo; import neatlogic.framework.form.exception.AttributeValidException; -import neatlogic.framework.form.exception.FormAttributeHandlerNotFoundException; import neatlogic.framework.form.service.IFormCrossoverService; import neatlogic.framework.matrix.core.IMatrixDataSourceHandler; import neatlogic.framework.matrix.core.MatrixDataSourceHandlerFactory; @@ -40,8 +38,6 @@ import neatlogic.framework.matrix.exception.MatrixDataSourceHandlerNotFoundExcep import neatlogic.framework.matrix.exception.MatrixNotFoundException; import neatlogic.module.framework.dependency.handler.Integration2FormAttrDependencyHandler; import neatlogic.module.framework.dependency.handler.MatrixAttr2FormAttrDependencyHandler; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -232,9 +228,10 @@ public class FormServiceImpl implements FormService, IFormCrossoverService { } @Override - public Object textConversionValueForSelectHandler(Object text, JSONObject config) { + public List textConversionValueForSelectHandler(Object text, JSONObject config) { + List valueList = new ArrayList<>(); if (text == null) { - return null; + return valueList; } String dataSource = config.getString("dataSource"); if ("static".equals(dataSource)) { @@ -247,17 +244,19 @@ public class FormServiceImpl implements FormService, IFormCrossoverService { if (text instanceof String) { String textStr = (String) text; Object value = valueTextMap.get(textStr); - return value; + if (value != null) { + valueList.add(new ValueTextVo(value, textStr)); + } + return valueList; } else if (text instanceof List) { List textList = (List) text; if (CollectionUtils.isEmpty(textList)) { - return textList; + return valueList; } - List valueList = new ArrayList<>(); for (String textStr : textList) { Object value = valueTextMap.get(textStr); if (value != null) { - valueList.add(value); + valueList.add(new ValueTextVo(value, textStr)); } } return valueList; @@ -265,32 +264,38 @@ public class FormServiceImpl implements FormService, IFormCrossoverService { } else if ("matrix".equals(dataSource)) { String matrixUuid = config.getString("matrixUuid"); if (StringUtils.isBlank(matrixUuid)) { - return null; + return valueList; } JSONObject mappingObj = config.getJSONObject("mapping"); if (MapUtils.isEmpty(mappingObj)) { - return null; + return valueList; } ValueTextVo mapping = mappingObj.toJavaObject(ValueTextVo.class); + System.out.println("13"); if (text instanceof String) { String textStr = (String) text; if (Objects.equals(mapping.getText(), mapping.getValue())) { - return textStr + IFormAttributeHandler.SELECT_COMPOSE_JOINER + textStr; + valueList.add(new ValueTextVo(textStr, textStr)); + return valueList; } - return getValue(matrixUuid, mapping, textStr); + String value = getValue(matrixUuid, mapping, textStr); + if (value != null) { + valueList.add(new ValueTextVo(value, textStr)); + } + return valueList; } else if (text instanceof List) { List textList = (List) text; if (CollectionUtils.isEmpty(textList)) { - return textList; + return valueList; } - List valueList = new ArrayList<>(); for (String textStr : textList) { if (Objects.equals(mapping.getText(), mapping.getValue())) { - valueList.add(textStr + IFormAttributeHandler.SELECT_COMPOSE_JOINER + textStr); - } - Object value = getValue(matrixUuid, mapping, textStr); - if (value != null) { - valueList.add(value); + valueList.add(new ValueTextVo(textStr, textStr)); + } else { + String value = getValue(matrixUuid, mapping, textStr); + if (value != null) { + valueList.add(new ValueTextVo(value, textStr)); + } } } return valueList; @@ -353,16 +358,46 @@ public class FormServiceImpl implements FormService, IFormCrossoverService { if (dataObj instanceof JSONArray) { JSONArray valueArray = (JSONArray) dataObj; if (CollectionUtils.isNotEmpty(valueArray)) { - valueList = valueArray.toJavaList(String.class); - for (String value : valueList) { - String text = valueTextMap.get(value); - if (text != null) { - textList.add(text); +// valueList = valueArray.toJavaList(String.class); + for (Object valueObj : valueArray) { + if (valueObj instanceof JSONObject) { + JSONObject jsonObj = (JSONObject) valueObj; + String value = jsonObj.getString("value"); + if (value != null) { + valueList.add(value); + } + String text = jsonObj.getString("text"); + if (text != null) { + textList.add(text); + } else { + if (value != null) { + textList.add(value); + } + } } else { - textList.add(value); + String text = valueTextMap.get(valueObj); + if (text != null) { + textList.add(text); + } else { + textList.add(valueObj.toString()); + } } } } + } else if (dataObj instanceof JSONObject) { + JSONObject jsonObj = (JSONObject) dataObj; + String value = jsonObj.getString("value"); + if (value != null) { + valueList.add(value); + } + String text = jsonObj.getString("text"); + if (text != null) { + textList.add(text); + } else { + if (value != null) { + textList.add(value); + } + } } else { String value = dataObj.toString(); valueList.add(value); @@ -374,25 +409,43 @@ public class FormServiceImpl implements FormService, IFormCrossoverService { } } } else {// 其他,如动态数据源 + System.out.println("14"); if (dataObj instanceof JSONArray) { JSONArray valueArray = (JSONArray) dataObj; if (CollectionUtils.isNotEmpty(valueArray)) { - valueList = valueArray.toJavaList(String.class); - for (String key : valueList) { - if (key.contains(IFormAttributeHandler.SELECT_COMPOSE_JOINER)) { - textList.add(key.split(IFormAttributeHandler.SELECT_COMPOSE_JOINER)[1]); + for (int i = 0; i < valueArray.size(); i++) { + Object obj = valueArray.get(i); + if (obj instanceof JSONObject) { + JSONObject jsonObj = (JSONObject) obj; + String value = jsonObj.getString("value"); + if (value != null) { + valueList.add(value); + } + String text = jsonObj.getString("text"); + if (text != null) { + textList.add(text); + } } else { - textList.add(key); + String value = obj.toString(); + valueList.add(value); + textList.add(value); } } } + } else if (dataObj instanceof JSONObject) { + JSONObject jsonObj = (JSONObject) dataObj; + String value = jsonObj.getString("value"); + if (value != null) { + valueList.add(value); + } + String text = jsonObj.getString("text"); + if (text != null) { + textList.add(text); + } } else { String value = dataObj.toString(); - if (value.contains(IFormAttributeHandler.SELECT_COMPOSE_JOINER)) { - textList.add(value.split(IFormAttributeHandler.SELECT_COMPOSE_JOINER)[1]); - } else { - textList.add(value); - } + valueList.add(value); + textList.add(value); } } resultObj.put("valueList", valueList); @@ -458,7 +511,8 @@ public class FormServiceImpl implements FormService, IFormCrossoverService { JSONObject textObj = tbody.get(textField); if (Objects.equals(text, textObj.getString("text"))) { JSONObject valueObj = tbody.get(valueField); - return valueObj.getString("value") + IFormAttributeHandler.SELECT_COMPOSE_JOINER + text; + System.out.println("15"); + return valueObj.getString("value"); } } if (dataVo.getCurrentPage() >= dataVo.getPageCount()) { -- Gitee From e1fb8c200c813f1fdb1a7e87449b7d7ac1e6c94d Mon Sep 17 00:00:00 2001 From: linbangquan <1437892690@qq.com> Date: Mon, 20 Nov 2023 17:35:11 +0800 Subject: [PATCH 09/14] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E8=A7=86=E5=9B=BE?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE-=E5=A2=9E=E5=8A=A0=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E8=A7=86=E5=9B=BE=E6=95=B0=E6=8D=AE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1023682900623360]视图设置-增加显示视图数据功能 http://192.168.0.96:8090/demo/rdm.html#/story-detail/939050947543040/939050947543042/1023682900623360 --- .../form/service/IFormCrossoverService.java | 2 + .../matrix/core/IMatrixDataSourceHandler.java | 8 -- .../core/MatrixDataSourceHandlerBase.java | 7 -- .../form/service/FormServiceImpl.java | 85 +++++++++++++++++-- .../handler/CustomDataSourceHandler.java | 18 ---- .../handler/ExternalDataSourceHandler.java | 53 ------------ .../handler/PrivateDataSourceHandler.java | 10 --- .../matrix/handler/ViewDataSourceHandler.java | 23 ----- .../matrix/service/MatrixService.java | 8 ++ .../matrix/service/MatrixServiceImpl.java | 36 ++++++++ 10 files changed, 122 insertions(+), 128 deletions(-) create mode 100644 src/main/java/neatlogic/module/framework/matrix/service/MatrixService.java create mode 100644 src/main/java/neatlogic/module/framework/matrix/service/MatrixServiceImpl.java diff --git a/src/main/java/neatlogic/framework/form/service/IFormCrossoverService.java b/src/main/java/neatlogic/framework/form/service/IFormCrossoverService.java index b174d8b7c..40efe0cf5 100644 --- a/src/main/java/neatlogic/framework/form/service/IFormCrossoverService.java +++ b/src/main/java/neatlogic/framework/form/service/IFormCrossoverService.java @@ -48,6 +48,8 @@ public interface IFormCrossoverService extends ICrossoverService { */ void formAttributeValueValid(FormVersionVo formVersionVo, JSONArray formAttributeDataList) throws AttributeValidException; + JSONObject getMyDetailedDataForSelectHandler(AttributeDataVo attributeDataVo, JSONObject configObj); + /** * 判断是否修改了表单数据 * @param formAttributeList 表单属性列表 diff --git a/src/main/java/neatlogic/framework/matrix/core/IMatrixDataSourceHandler.java b/src/main/java/neatlogic/framework/matrix/core/IMatrixDataSourceHandler.java index ae4c8a1b1..17d122e91 100644 --- a/src/main/java/neatlogic/framework/matrix/core/IMatrixDataSourceHandler.java +++ b/src/main/java/neatlogic/framework/matrix/core/IMatrixDataSourceHandler.java @@ -132,14 +132,6 @@ public interface IMatrixDataSourceHandler { */ JSONObject exportAttribute(MatrixVo matrixVo); - /** - * 查询矩阵表格数据 - * - * @param dataVo - * @return - */ - JSONObject getTableData(MatrixDataVo dataVo); - /** * 查询矩阵表格数据 * diff --git a/src/main/java/neatlogic/framework/matrix/core/MatrixDataSourceHandlerBase.java b/src/main/java/neatlogic/framework/matrix/core/MatrixDataSourceHandlerBase.java index 6ec5fb56f..4485921bd 100644 --- a/src/main/java/neatlogic/framework/matrix/core/MatrixDataSourceHandlerBase.java +++ b/src/main/java/neatlogic/framework/matrix/core/MatrixDataSourceHandlerBase.java @@ -161,13 +161,6 @@ public abstract class MatrixDataSourceHandlerBase implements IMatrixDataSourceHa protected abstract JSONObject myExportAttribute(MatrixVo matrixVo); - @Override - public JSONObject getTableData(MatrixDataVo dataVo) { - return myGetTableData(dataVo); - } - - protected abstract JSONObject myGetTableData(MatrixDataVo dataVo); - @Override public JSONObject searchTableData(MatrixDataVo dataVo) { return myTableDataSearch(dataVo); diff --git a/src/main/java/neatlogic/module/framework/form/service/FormServiceImpl.java b/src/main/java/neatlogic/module/framework/form/service/FormServiceImpl.java index 4351f031b..085afc7a9 100644 --- a/src/main/java/neatlogic/module/framework/form/service/FormServiceImpl.java +++ b/src/main/java/neatlogic/module/framework/form/service/FormServiceImpl.java @@ -29,15 +29,17 @@ import neatlogic.framework.form.dto.FormAttributeVo; import neatlogic.framework.form.dto.FormVersionVo; import neatlogic.framework.form.exception.AttributeValidException; import neatlogic.framework.form.service.IFormCrossoverService; +import neatlogic.framework.matrix.constvalue.SearchExpression; import neatlogic.framework.matrix.core.IMatrixDataSourceHandler; import neatlogic.framework.matrix.core.MatrixDataSourceHandlerFactory; -import neatlogic.framework.matrix.dao.mapper.MatrixMapper; import neatlogic.framework.matrix.dto.MatrixDataVo; +import neatlogic.framework.matrix.dto.MatrixDefaultValueFilterVo; +import neatlogic.framework.matrix.dto.MatrixKeywordFilterVo; import neatlogic.framework.matrix.dto.MatrixVo; import neatlogic.framework.matrix.exception.MatrixDataSourceHandlerNotFoundException; -import neatlogic.framework.matrix.exception.MatrixNotFoundException; import neatlogic.module.framework.dependency.handler.Integration2FormAttrDependencyHandler; import neatlogic.module.framework.dependency.handler.MatrixAttr2FormAttrDependencyHandler; +import neatlogic.module.framework.matrix.service.MatrixService; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -54,7 +56,7 @@ public class FormServiceImpl implements FormService, IFormCrossoverService { private FormMapper formMapper; @Resource - private MatrixMapper matrixMapper; + private MatrixService matrixService; /** * 保存表单属性与其他功能的引用关系 @@ -410,6 +412,15 @@ public class FormServiceImpl implements FormService, IFormCrossoverService { } } else {// 其他,如动态数据源 System.out.println("14"); + String matrixUuid = configObj.getString("matrixUuid"); + if (StringUtils.isBlank(matrixUuid)) { + return resultObj; + } + JSONObject mappingObj = configObj.getJSONObject("mapping"); + if (MapUtils.isEmpty(mappingObj)) { + return resultObj; + } + ValueTextVo mapping = mappingObj.toJavaObject(ValueTextVo.class); if (dataObj instanceof JSONArray) { JSONArray valueArray = (JSONArray) dataObj; if (CollectionUtils.isNotEmpty(valueArray)) { @@ -424,11 +435,18 @@ public class FormServiceImpl implements FormService, IFormCrossoverService { String text = jsonObj.getString("text"); if (text != null) { textList.add(text); + } else { + textList.add(value); } } else { String value = obj.toString(); valueList.add(value); - textList.add(value); + String text = getText(matrixUuid, mapping, value); + if (text != null) { + textList.add(text); + } else { + textList.add(value); + } } } } @@ -441,11 +459,18 @@ public class FormServiceImpl implements FormService, IFormCrossoverService { String text = jsonObj.getString("text"); if (text != null) { textList.add(text); + } else { + textList.add(value); } } else { String value = dataObj.toString(); valueList.add(value); - textList.add(value); + String text = getText(matrixUuid, mapping, value); + if (text != null) { + textList.add(text); + } else { + textList.add(value); + } } } resultObj.put("valueList", valueList); @@ -487,10 +512,7 @@ public class FormServiceImpl implements FormService, IFormCrossoverService { return text; } try { - MatrixVo matrixVo = matrixMapper.getMatrixByUuid(matrixUuid); - if (matrixVo == null) { - throw new MatrixNotFoundException(matrixUuid); - } + MatrixVo matrixVo = matrixService.getMatrixByUuid(matrixUuid); IMatrixDataSourceHandler matrixDataSourceHandler = MatrixDataSourceHandlerFactory.getHandler(matrixVo.getType()); if (matrixDataSourceHandler == null) { throw new MatrixDataSourceHandlerNotFoundException(matrixVo.getType()); @@ -525,4 +547,49 @@ public class FormServiceImpl implements FormService, IFormCrossoverService { } return null; } + + private String getText(String matrixUuid, ValueTextVo mapping, String value) { + if (StringUtils.isBlank(value)) { + return value; + } + try { + MatrixVo matrixVo = matrixService.getMatrixByUuid(matrixUuid); + IMatrixDataSourceHandler matrixDataSourceHandler = MatrixDataSourceHandlerFactory.getHandler(matrixVo.getType()); + if (matrixDataSourceHandler == null) { + throw new MatrixDataSourceHandlerNotFoundException(matrixVo.getType()); + } + String valueField = (String) mapping.getValue(); + String textField = mapping.getText(); + MatrixDataVo dataVo = new MatrixDataVo(); + dataVo.setMatrixUuid(matrixUuid); + List columnList = new ArrayList<>(); + columnList.add((String) mapping.getValue()); + columnList.add(mapping.getText()); + dataVo.setColumnList(columnList); + List defaultValueFilterList = new ArrayList<>(); + MatrixDefaultValueFilterVo matrixDefaultValueFilterVo = new MatrixDefaultValueFilterVo( + new MatrixKeywordFilterVo(valueField, SearchExpression.EQ.getExpression(), value) + ); + defaultValueFilterList.add(matrixDefaultValueFilterVo); + dataVo.setDefaultValueFilterList(defaultValueFilterList); + for (int i = 0; i < 10; i++) { + List> tbodyList = matrixDataSourceHandler.searchTableDataNew(dataVo); + for (Map tbody : tbodyList) { + JSONObject valueObj = tbody.get(valueField); + if (Objects.equals(value, valueObj.getString("value"))) { + JSONObject textObj = tbody.get(textField); + System.out.println("15"); + return textObj.getString("text"); + } + } + if (dataVo.getCurrentPage() >= dataVo.getPageCount()) { + break; + } + dataVo.setCurrentPage(dataVo.getCurrentPage() + 1); + } + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } } diff --git a/src/main/java/neatlogic/module/framework/matrix/handler/CustomDataSourceHandler.java b/src/main/java/neatlogic/module/framework/matrix/handler/CustomDataSourceHandler.java index a6467dcfd..f7b75e9ce 100644 --- a/src/main/java/neatlogic/module/framework/matrix/handler/CustomDataSourceHandler.java +++ b/src/main/java/neatlogic/module/framework/matrix/handler/CustomDataSourceHandler.java @@ -431,24 +431,6 @@ public class CustomDataSourceHandler extends MatrixDataSourceHandlerBase { return resultObj; } - @Override - protected JSONObject myGetTableData(MatrixDataVo dataVo) { - List attributeVoList = attributeMapper.getMatrixAttributeByMatrixUuid(dataVo.getMatrixUuid()); - if (CollectionUtils.isNotEmpty(attributeVoList)) { - List columnList = attributeVoList.stream().map(MatrixAttributeVo::getUuid).collect(Collectors.toList()); - dataVo.setColumnList(columnList); - if (dataVo.getNeedPage()) { - int rowNum = matrixDataMapper.getDynamicTableDataCount(dataVo); - dataVo.setRowNum(rowNum); - } - List> dataList = matrixDataMapper.searchDynamicTableData(dataVo); - List> tbodyList = matrixTableDataValueHandle(attributeVoList, dataList); - JSONArray theadList = getTheadList(attributeVoList); - return TableResultUtil.getResult(theadList, tbodyList, dataVo); - } - return new JSONObject(); - } - @Override protected JSONObject myTableDataSearch(MatrixDataVo dataVo) { JSONObject returnObj = new JSONObject(); diff --git a/src/main/java/neatlogic/module/framework/matrix/handler/ExternalDataSourceHandler.java b/src/main/java/neatlogic/module/framework/matrix/handler/ExternalDataSourceHandler.java index 9ddef9680..ed55d4526 100644 --- a/src/main/java/neatlogic/module/framework/matrix/handler/ExternalDataSourceHandler.java +++ b/src/main/java/neatlogic/module/framework/matrix/handler/ExternalDataSourceHandler.java @@ -53,7 +53,6 @@ import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import java.io.IOException; import java.util.*; -import java.util.stream.Collectors; /** * @author linbq @@ -190,58 +189,6 @@ public class ExternalDataSourceHandler extends MatrixDataSourceHandlerBase { return null; } - @Override - protected JSONObject myGetTableData(MatrixDataVo dataVo) { - - MatrixExternalVo externalVo = matrixMapper.getMatrixExternalByMatrixUuid(dataVo.getMatrixUuid()); - if (externalVo == null) { - throw new MatrixExternalNotFoundException(dataVo.getMatrixUuid()); - } - IntegrationVo integrationVo = integrationMapper.getIntegrationByUuid(externalVo.getIntegrationUuid()); - if (integrationVo == null) { - throw new IntegrationNotFoundException(externalVo.getIntegrationUuid()); - } - IIntegrationHandler handler = IntegrationHandlerFactory.getHandler(integrationVo.getHandler()); - if (handler == null) { - throw new IntegrationHandlerNotFoundException(integrationVo.getHandler()); - } - - JSONObject paramObj = integrationVo.getParamObj(); - paramObj.put("keyword", dataVo.getKeyword()); - paramObj.put("currentPage", dataVo.getCurrentPage()); - paramObj.put("pageSize", dataVo.getPageSize()); - IntegrationResultVo resultVo = handler.sendRequest(integrationVo, RequestFrom.MATRIX); - if (StringUtils.isNotBlank(resultVo.getError())) { - logger.error(resultVo.getError()); - throw new MatrixExternalAccessException(integrationVo.getName()); - } - handler.validate(resultVo); - JSONObject returnObj = new JSONObject(); - JSONObject transformedResult = JSONObject.parseObject(resultVo.getTransformedResult()); - Integer rowNum = transformedResult.getInteger("rowNum"); - dataVo.setRowNum(rowNum); - returnObj.put("currentPage", transformedResult.get("currentPage")); - returnObj.put("pageSize", transformedResult.get("pageSize")); - returnObj.put("pageCount", transformedResult.get("pageCount")); - returnObj.put("rowNum", rowNum); - - List matrixAttributeList = getExternalMatrixAttributeList(dataVo.getMatrixUuid(), integrationVo); - List columnList = matrixAttributeList.stream().map(MatrixAttributeVo::getUuid).collect(Collectors.toList()); - JSONArray theadList = getTheadList(dataVo.getMatrixUuid(), matrixAttributeList, columnList); -// JSONArray theadList = transformedResult.getJSONArray("theadList"); - returnObj.put("theadList", theadList); -// for (int i = 0; i < theadList.size(); i++) { -// JSONObject theadObj = theadList.getJSONObject(i); -// String key = theadObj.getString("key"); -// if (StringUtils.isNotBlank(key)) { -// columnList.add(key); -// } -// } - JSONArray tbodyArray = transformedResult.getJSONArray("tbodyList"); - returnObj.put("tbodyList", getExternalDataTbodyList(matrixAttributeList, tbodyArray, columnList)); - return returnObj; - } - @Override protected JSONObject myTableDataSearch(MatrixDataVo dataVo) { JSONObject returnObj = new JSONObject(); diff --git a/src/main/java/neatlogic/module/framework/matrix/handler/PrivateDataSourceHandler.java b/src/main/java/neatlogic/module/framework/matrix/handler/PrivateDataSourceHandler.java index 7ee96c2d7..055905303 100644 --- a/src/main/java/neatlogic/module/framework/matrix/handler/PrivateDataSourceHandler.java +++ b/src/main/java/neatlogic/module/framework/matrix/handler/PrivateDataSourceHandler.java @@ -110,16 +110,6 @@ public class PrivateDataSourceHandler extends MatrixDataSourceHandlerBase { return null; } - @Override - protected JSONObject myGetTableData(MatrixDataVo dataVo) { - IMatrixPrivateDataSourceHandler matrixPrivateDataSourceHandler = MatrixPrivateDataSourceHandlerFactory.getHandler(dataVo.getMatrixUuid()); - List attributeVoList = matrixPrivateDataSourceHandler.getAttributeList(); - List> dataList = matrixPrivateDataSourceHandler.searchTableData(dataVo); - List> tbodyList = matrixTableDataValueHandle(attributeVoList, dataList); - JSONArray theadList = getTheadList(attributeVoList); - return TableResultUtil.getResult(theadList, tbodyList, dataVo); - } - @Override protected JSONObject myTableDataSearch(MatrixDataVo dataVo) { IMatrixPrivateDataSourceHandler matrixPrivateDataSourceHandler = MatrixPrivateDataSourceHandlerFactory.getHandler(dataVo.getMatrixUuid()); diff --git a/src/main/java/neatlogic/module/framework/matrix/handler/ViewDataSourceHandler.java b/src/main/java/neatlogic/module/framework/matrix/handler/ViewDataSourceHandler.java index 819636267..ac1f0e642 100644 --- a/src/main/java/neatlogic/module/framework/matrix/handler/ViewDataSourceHandler.java +++ b/src/main/java/neatlogic/module/framework/matrix/handler/ViewDataSourceHandler.java @@ -248,29 +248,6 @@ public class ViewDataSourceHandler extends MatrixDataSourceHandlerBase { return null; } - @Override - protected JSONObject myGetTableData(MatrixDataVo dataVo) { - MatrixViewVo matrixViewVo = matrixMapper.getMatrixViewByMatrixUuid(dataVo.getMatrixUuid()); - if (matrixViewVo == null) { - throw new MatrixViewNotFoundException(dataVo.getMatrixUuid()); - } - JSONArray attributeList = (JSONArray) JSONPath.read(matrixViewVo.getConfig(), "attributeList"); - if (CollectionUtils.isNotEmpty(attributeList)) { - List attributeVoList = attributeList.toJavaList(MatrixAttributeVo.class); - List columnList = attributeVoList.stream().map(MatrixAttributeVo::getUuid).collect(Collectors.toList()); - dataVo.setColumnList(columnList); - if (dataVo.getNeedPage()) { - int rowNum = matrixViewDataMapper.getDynamicTableDataCount(dataVo); - dataVo.setRowNum(rowNum); - } - List> dataList = matrixViewDataMapper.searchDynamicTableData(dataVo); - List> tbodyList = matrixTableDataValueHandle(dataList); - JSONArray theadList = getTheadList(attributeVoList); - return TableResultUtil.getResult(theadList, tbodyList, dataVo); - } - return new JSONObject(); - } - @Override protected JSONObject myTableDataSearch(MatrixDataVo dataVo) { JSONObject returnObj = new JSONObject(); diff --git a/src/main/java/neatlogic/module/framework/matrix/service/MatrixService.java b/src/main/java/neatlogic/module/framework/matrix/service/MatrixService.java new file mode 100644 index 000000000..db68e9476 --- /dev/null +++ b/src/main/java/neatlogic/module/framework/matrix/service/MatrixService.java @@ -0,0 +1,8 @@ +package neatlogic.module.framework.matrix.service; + +import neatlogic.framework.matrix.dto.MatrixVo; + +public interface MatrixService { + + MatrixVo getMatrixByUuid(String uuid); +} diff --git a/src/main/java/neatlogic/module/framework/matrix/service/MatrixServiceImpl.java b/src/main/java/neatlogic/module/framework/matrix/service/MatrixServiceImpl.java new file mode 100644 index 000000000..b1e3507a2 --- /dev/null +++ b/src/main/java/neatlogic/module/framework/matrix/service/MatrixServiceImpl.java @@ -0,0 +1,36 @@ +package neatlogic.module.framework.matrix.service; + +import neatlogic.framework.matrix.constvalue.MatrixType; +import neatlogic.framework.matrix.core.IMatrixPrivateDataSourceHandler; +import neatlogic.framework.matrix.core.MatrixPrivateDataSourceHandlerFactory; +import neatlogic.framework.matrix.dao.mapper.MatrixMapper; +import neatlogic.framework.matrix.dto.MatrixVo; +import neatlogic.framework.matrix.exception.MatrixNotFoundException; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +@Service +public class MatrixServiceImpl implements MatrixService { + + @Resource + private MatrixMapper matrixMapper; + + @Override + public MatrixVo getMatrixByUuid(String uuid) { + MatrixVo matrixVo = matrixMapper.getMatrixByUuid(uuid); + if (matrixVo != null) { + return matrixVo; + } + IMatrixPrivateDataSourceHandler matrixPrivateDataSourceHandler = MatrixPrivateDataSourceHandlerFactory.getHandler(uuid); + if (matrixPrivateDataSourceHandler != null) { + matrixVo = new MatrixVo(); + matrixVo.setUuid(uuid); + matrixVo.setName(matrixPrivateDataSourceHandler.getName()); + matrixVo.setLabel(matrixPrivateDataSourceHandler.getLabel()); + matrixVo.setType(MatrixType.PRIVATE.getValue()); + return matrixVo; + } + throw new MatrixNotFoundException(uuid); + } +} -- Gitee From 2372d70689107be9514c548e7a082db143aebd34 Mon Sep 17 00:00:00 2001 From: linbangquan <1437892690@qq.com> Date: Mon, 20 Nov 2023 18:00:42 +0800 Subject: [PATCH 10/14] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E8=A7=86=E5=9B=BE?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE-=E5=A2=9E=E5=8A=A0=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E8=A7=86=E5=9B=BE=E6=95=B0=E6=8D=AE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1023682900623360]视图设置-增加显示视图数据功能 http://192.168.0.96:8090/demo/rdm.html#/story-detail/939050947543040/939050947543042/1023682900623360 --- .../form/attribute/handler/TableInputerHandler.java | 12 ++++++------ .../form/attribute/handler/TableSelectorHandler.java | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/TableInputerHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/TableInputerHandler.java index 7964e38ac..6dba8ce90 100644 --- a/src/main/java/neatlogic/module/framework/form/attribute/handler/TableInputerHandler.java +++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/TableInputerHandler.java @@ -420,7 +420,7 @@ public class TableInputerHandler extends FormHandlerBase { "value": [ { "266abb12741f49218c6d6a6d1e89e131": "1", - "c2090bb8472d482eb8eaece9864c08f6": "6&=&许*航", + "c2090bb8472d482eb8eaece9864c08f6": {"value": "6", "text": "许*航"}, "3805bbf114414604b6a514c6287b51f0": "3", "3c33ca77c2f148f4af50bf7f98715a38": "2023-03-02", "cad032ca2175424eb815586694a8f17d": "文本1", @@ -428,10 +428,10 @@ public class TableInputerHandler extends FormHandlerBase { "bbc47193be544403a79f31e5529a93f4": "文本域1", "_selected": false, "75ed2187390d4c4ea37dab180f6fee00": [ - "6&=&金融同业部-同业业务中心" + {"value": "6", "text": "金融同业部-同业业务中心"} ], "516fdf5d27e54fc2a8b7cf66bd02c8b9": [ - "3333&=&薛*源" + {"value": "3333", "text": "薛*源"} ], "d2e965358f264cee926fe00b5caec36c": [ { @@ -448,7 +448,7 @@ public class TableInputerHandler extends FormHandlerBase { }, { "266abb12741f49218c6d6a6d1e89e131": "1", - "c2090bb8472d482eb8eaece9864c08f6": "6&=&许*航", + "c2090bb8472d482eb8eaece9864c08f6": {"value": "6", "text": "许*航"}, "3805bbf114414604b6a514c6287b51f0": "3", "3c33ca77c2f148f4af50bf7f98715a38": "2023-03-02", "cad032ca2175424eb815586694a8f17d": "文本1", @@ -456,10 +456,10 @@ public class TableInputerHandler extends FormHandlerBase { "bbc47193be544403a79f31e5529a93f4": "文本域1", "_selected": false, "75ed2187390d4c4ea37dab180f6fee00": [ - "6&=&金融同业部-同业业务中心" + {"value": "6", "text": "金融同业部-同业业务中心"} ], "516fdf5d27e54fc2a8b7cf66bd02c8b9": [ - "3333&=&薛*源" + {"value": "3333", "text": "薛*源"} ], "d2e965358f264cee926fe00b5caec36c": [ { diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/TableSelectorHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/TableSelectorHandler.java index a2387b8a5..095fd1ea1 100644 --- a/src/main/java/neatlogic/module/framework/form/attribute/handler/TableSelectorHandler.java +++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/TableSelectorHandler.java @@ -297,7 +297,7 @@ public class TableSelectorHandler extends FormHandlerBase { "b67e647f6fd049e59cc903fb678c7291": "2022-09-24 00:00:00", "147321ac250d48ed9cff09516f47bd8f": "扩展属性_1_3", "688dfb6ec05147098cf8e34a1141ad58": [ - "6&=&许*航" + {"value": "6", "text": "许*航"} ], "uuid": "1b0661a40da3478c9be344c99db2ffb0" }, @@ -312,7 +312,7 @@ public class TableSelectorHandler extends FormHandlerBase { "b67e647f6fd049e59cc903fb678c7291": "2022-12-13 00:00:00", "147321ac250d48ed9cff09516f47bd8f": "扩展属性_1_2", "688dfb6ec05147098cf8e34a1141ad58": [ - "3333&=&薛*源" + {"value": "3333", "text": "薛*源"} ], "uuid": "8eed18cdbcb34691b379d1b5fc1e3b0f" }, @@ -327,8 +327,8 @@ public class TableSelectorHandler extends FormHandlerBase { "b67e647f6fd049e59cc903fb678c7291": "2023-02-10 00:00:00", "147321ac250d48ed9cff09516f47bd8f": "扩展属性_1_1", "688dfb6ec05147098cf8e34a1141ad58": [ - "3&=&冉ss", - "6&=&许*航" + {"value": "3", "text": "冉ss"}, + {"value": "6", "text": "许*航"} ], "uuid": "c8bc60ca9ec740d7a8808753ab504bab" } @@ -342,7 +342,7 @@ public class TableSelectorHandler extends FormHandlerBase { "e00fc42fca5d4f5e831d296ed68b3ff1": "0093a20ff182675fee7b6f821b874488", "14a67eabc2584d4da19c561c26ed0f3a": "金融市场总部", "c95435c411884f149e8e22a6e67ab1ec": [ - "6&=&许*航" + {"value": "6", "text": "许*航"} ], "a22002af151b4da589bc390f3ad164f5": "2", "579c9de2986d48738cc0ecafab2f43d3": "a2", @@ -357,7 +357,7 @@ public class TableSelectorHandler extends FormHandlerBase { "e00fc42fca5d4f5e831d296ed68b3ff1": "薛*源", "14a67eabc2584d4da19c561c26ed0f3a": "纪律监督室", "c95435c411884f149e8e22a6e67ab1ec": [ - "3&=&冉ss" + {"value": "3", "text": "冉ss"} ], "a22002af151b4da589bc390f3ad164f5": "3333", "579c9de2986d48738cc0ecafab2f43d3": "a2", -- Gitee From 41b15746369e80f5d8c1d497b854f8670dfda7bf Mon Sep 17 00:00:00 2001 From: linbangquan <1437892690@qq.com> Date: Tue, 21 Nov 2023 11:37:43 +0800 Subject: [PATCH 11/14] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E8=A7=86=E5=9B=BE?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE-=E5=A2=9E=E5=8A=A0=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E8=A7=86=E5=9B=BE=E6=95=B0=E6=8D=AE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1023682900623360]视图设置-增加显示视图数据功能 http://192.168.0.96:8090/demo/rdm.html#/story-detail/939050947543040/939050947543042/1023682900623360 --- .../form/service/IFormCrossoverService.java | 2 ++ .../form/service/FormServiceImpl.java | 28 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/main/java/neatlogic/framework/form/service/IFormCrossoverService.java b/src/main/java/neatlogic/framework/form/service/IFormCrossoverService.java index 40efe0cf5..7bc3d9595 100644 --- a/src/main/java/neatlogic/framework/form/service/IFormCrossoverService.java +++ b/src/main/java/neatlogic/framework/form/service/IFormCrossoverService.java @@ -60,4 +60,6 @@ public interface IFormCrossoverService extends ICrossoverService { boolean isModifiedFormData(List formAttributeList, List newFormAttributeDataList, List oldFormAttributeDataList); + + Object getFormSelectAttributeValueByOriginalValue(Object originalValue); } diff --git a/src/main/java/neatlogic/module/framework/form/service/FormServiceImpl.java b/src/main/java/neatlogic/module/framework/form/service/FormServiceImpl.java index 085afc7a9..0acc65052 100644 --- a/src/main/java/neatlogic/module/framework/form/service/FormServiceImpl.java +++ b/src/main/java/neatlogic/module/framework/form/service/FormServiceImpl.java @@ -507,6 +507,34 @@ public class FormServiceImpl implements FormService, IFormCrossoverService { return isModified; } + @Override + public Object getFormSelectAttributeValueByOriginalValue(Object originalValue) { + if (originalValue == null) { + return null; + } + if (originalValue instanceof JSONArray) { + JSONArray valueList = new JSONArray(); + JSONArray originalValueArray = (JSONArray) originalValue; + for (int i = 0; i < originalValueArray.size(); i++) { + Object originalValueObject = originalValueArray.get(i); + if (originalValueObject instanceof JSONObject) { + JSONObject originalValueObj = (JSONObject) originalValueObject; + Object value = originalValueObj.get("value"); + if (value != null) { + valueList.add(value); + } + } else { + valueList.add(originalValueObject); + } + } + return valueList; + } else if (originalValue instanceof JSONObject) { + JSONObject originalValueObj = (JSONObject) originalValue; + return originalValueObj.get("value"); + } + return originalValue; + } + private String getValue(String matrixUuid, ValueTextVo mapping, String text) { if (StringUtils.isBlank(text)) { return text; -- Gitee From ad8f07f8f4bf266a9efbf1edc6458308c0665122 Mon Sep 17 00:00:00 2001 From: linbangquan <1437892690@qq.com> Date: Tue, 21 Nov 2023 14:42:26 +0800 Subject: [PATCH 12/14] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E5=90=8E=E7=AB=AF?= =?UTF-8?q?-=E4=B8=8B=E6=8B=89=E6=A1=86=E3=80=81=E5=8D=95=E9=80=89?= =?UTF-8?q?=E3=80=81=E5=A4=8D=E9=80=89=E7=BB=84=E4=BB=B6=E9=80=89=E4=B8=AD?= =?UTF-8?q?=E5=80=BC=E7=94=B1xxx&=3D&yyy=E6=94=B9=E6=88=90{value:xxx,text:?= =?UTF-8?q?yyy}?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1025915604140032]后端-下拉框、单选、复选组件选中值由xxx&=&yyy改成{value:xxx,text:yyy} http://192.168.0.96:8090/demo/rdm.html#/task-detail/939050947543040/939050947543050/1025915604140032 --- .../framework/matrix/service/MatrixServiceImpl.java | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/main/java/neatlogic/module/framework/matrix/service/MatrixServiceImpl.java b/src/main/java/neatlogic/module/framework/matrix/service/MatrixServiceImpl.java index b1e3507a2..6a4025fdd 100644 --- a/src/main/java/neatlogic/module/framework/matrix/service/MatrixServiceImpl.java +++ b/src/main/java/neatlogic/module/framework/matrix/service/MatrixServiceImpl.java @@ -1,7 +1,5 @@ package neatlogic.module.framework.matrix.service; -import neatlogic.framework.matrix.constvalue.MatrixType; -import neatlogic.framework.matrix.core.IMatrixPrivateDataSourceHandler; import neatlogic.framework.matrix.core.MatrixPrivateDataSourceHandlerFactory; import neatlogic.framework.matrix.dao.mapper.MatrixMapper; import neatlogic.framework.matrix.dto.MatrixVo; @@ -22,13 +20,8 @@ public class MatrixServiceImpl implements MatrixService { if (matrixVo != null) { return matrixVo; } - IMatrixPrivateDataSourceHandler matrixPrivateDataSourceHandler = MatrixPrivateDataSourceHandlerFactory.getHandler(uuid); - if (matrixPrivateDataSourceHandler != null) { - matrixVo = new MatrixVo(); - matrixVo.setUuid(uuid); - matrixVo.setName(matrixPrivateDataSourceHandler.getName()); - matrixVo.setLabel(matrixPrivateDataSourceHandler.getLabel()); - matrixVo.setType(MatrixType.PRIVATE.getValue()); + matrixVo = MatrixPrivateDataSourceHandlerFactory.getMatrixVo(uuid); + if (matrixVo != null) { return matrixVo; } throw new MatrixNotFoundException(uuid); -- Gitee From 80e4b32c575a7132bd406874c265cea075bf1a02 Mon Sep 17 00:00:00 2001 From: linbangquan <1437892690@qq.com> Date: Tue, 21 Nov 2023 16:52:53 +0800 Subject: [PATCH 13/14] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E5=90=8E=E7=AB=AF?= =?UTF-8?q?-=E4=B8=8B=E6=8B=89=E6=A1=86=E3=80=81=E5=8D=95=E9=80=89?= =?UTF-8?q?=E3=80=81=E5=A4=8D=E9=80=89=E7=BB=84=E4=BB=B6=E9=80=89=E4=B8=AD?= =?UTF-8?q?=E5=80=BC=E7=94=B1xxx&=3D&yyy=E6=94=B9=E6=88=90{value:xxx,text:?= =?UTF-8?q?yyy}?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1025915604140032]后端-下拉框、单选、复选组件选中值由xxx&=&yyy改成{value:xxx,text:yyy} http://192.168.0.96:8090/demo/rdm.html#/task-detail/939050947543040/939050947543050/1025915604140032 --- .../framework/matrix/dto/MatrixDefaultValueFilterVo.java | 6 +----- .../module/framework/form/service/FormServiceImpl.java | 3 ++- .../framework/matrix/handler/CustomDataSourceHandler.java | 6 ++++-- .../framework/matrix/handler/ExternalDataSourceHandler.java | 4 +++- .../framework/matrix/handler/PrivateDataSourceHandler.java | 4 +++- .../framework/matrix/handler/ViewDataSourceHandler.java | 4 +++- 6 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/main/java/neatlogic/framework/matrix/dto/MatrixDefaultValueFilterVo.java b/src/main/java/neatlogic/framework/matrix/dto/MatrixDefaultValueFilterVo.java index c7a62f183..006278190 100644 --- a/src/main/java/neatlogic/framework/matrix/dto/MatrixDefaultValueFilterVo.java +++ b/src/main/java/neatlogic/framework/matrix/dto/MatrixDefaultValueFilterVo.java @@ -2,11 +2,7 @@ package neatlogic.framework.matrix.dto; public class MatrixDefaultValueFilterVo { private final MatrixKeywordFilterVo valueFieldFilter; - private MatrixKeywordFilterVo textFieldFilter; - - public MatrixDefaultValueFilterVo(MatrixKeywordFilterVo valueFieldFilter) { - this.valueFieldFilter = valueFieldFilter; - } + private final MatrixKeywordFilterVo textFieldFilter; public MatrixDefaultValueFilterVo(MatrixKeywordFilterVo valueFieldFilter, MatrixKeywordFilterVo textFieldFilter) { this.valueFieldFilter = valueFieldFilter; diff --git a/src/main/java/neatlogic/module/framework/form/service/FormServiceImpl.java b/src/main/java/neatlogic/module/framework/form/service/FormServiceImpl.java index 0acc65052..e1ce1c4ff 100644 --- a/src/main/java/neatlogic/module/framework/form/service/FormServiceImpl.java +++ b/src/main/java/neatlogic/module/framework/form/service/FormServiceImpl.java @@ -596,7 +596,8 @@ public class FormServiceImpl implements FormService, IFormCrossoverService { dataVo.setColumnList(columnList); List defaultValueFilterList = new ArrayList<>(); MatrixDefaultValueFilterVo matrixDefaultValueFilterVo = new MatrixDefaultValueFilterVo( - new MatrixKeywordFilterVo(valueField, SearchExpression.EQ.getExpression(), value) + new MatrixKeywordFilterVo(valueField, SearchExpression.EQ.getExpression(), value), + null ); defaultValueFilterList.add(matrixDefaultValueFilterVo); dataVo.setDefaultValueFilterList(defaultValueFilterList); diff --git a/src/main/java/neatlogic/module/framework/matrix/handler/CustomDataSourceHandler.java b/src/main/java/neatlogic/module/framework/matrix/handler/CustomDataSourceHandler.java index f7b75e9ce..5a9fc401b 100644 --- a/src/main/java/neatlogic/module/framework/matrix/handler/CustomDataSourceHandler.java +++ b/src/main/java/neatlogic/module/framework/matrix/handler/CustomDataSourceHandler.java @@ -473,14 +473,16 @@ public class CustomDataSourceHandler extends MatrixDataSourceHandlerBase { for (MatrixDefaultValueFilterVo defaultValueFilterVo : dataVo.getDefaultValueFilterList()) { List filterList = new ArrayList<>(); MatrixKeywordFilterVo valueFieldFilter = defaultValueFilterVo.getValueFieldFilter(); - filterList.add(new MatrixFilterVo(valueFieldFilter.getUuid(), valueFieldFilter.getExpression(), Arrays.asList(valueFieldFilter.getValue()))); + if (valueFieldFilter != null) { + filterList.add(new MatrixFilterVo(valueFieldFilter.getUuid(), valueFieldFilter.getExpression(), Arrays.asList(valueFieldFilter.getValue()))); + } MatrixKeywordFilterVo textFieldFilter = defaultValueFilterVo.getTextFieldFilter(); if (textFieldFilter != null) { MatrixAttributeVo attributeVo = matrixAttributeMap.get(textFieldFilter.getUuid()); if (MatrixAttributeType.SELECT.getValue().equals(attributeVo.getType())) { List valueList = getSelectTypeValueList(attributeVo, textFieldFilter.getValue(), SearchExpression.EQ); if (CollectionUtils.isNotEmpty(valueList)) { - filterList.add(new MatrixFilterVo(textFieldFilter.getUuid(), SearchExpression.LI.getExpression(), valueList)); + filterList.add(new MatrixFilterVo(textFieldFilter.getUuid(), SearchExpression.EQ.getExpression(), valueList)); } else { return resultList; } diff --git a/src/main/java/neatlogic/module/framework/matrix/handler/ExternalDataSourceHandler.java b/src/main/java/neatlogic/module/framework/matrix/handler/ExternalDataSourceHandler.java index ed55d4526..97a8a7301 100644 --- a/src/main/java/neatlogic/module/framework/matrix/handler/ExternalDataSourceHandler.java +++ b/src/main/java/neatlogic/module/framework/matrix/handler/ExternalDataSourceHandler.java @@ -337,7 +337,9 @@ public class ExternalDataSourceHandler extends MatrixDataSourceHandlerBase { for (MatrixDefaultValueFilterVo defaultValueFilterVo : dataVo.getDefaultValueFilterList()) { List filterList = new ArrayList<>(); MatrixKeywordFilterVo valueFieldFilter = defaultValueFilterVo.getValueFieldFilter(); - filterList.add(new MatrixFilterVo(valueFieldFilter.getUuid(), valueFieldFilter.getExpression(), Arrays.asList(valueFieldFilter.getValue()))); + if (valueFieldFilter != null) { + filterList.add(new MatrixFilterVo(valueFieldFilter.getUuid(), valueFieldFilter.getExpression(), Arrays.asList(valueFieldFilter.getValue()))); + } MatrixKeywordFilterVo textFieldFilter = defaultValueFilterVo.getTextFieldFilter(); if (textFieldFilter != null && !Objects.equals(valueFieldFilter.getUuid(), textFieldFilter.getUuid())) { filterList.add(new MatrixFilterVo(textFieldFilter.getUuid(), textFieldFilter.getExpression(), Arrays.asList(textFieldFilter.getValue()))); diff --git a/src/main/java/neatlogic/module/framework/matrix/handler/PrivateDataSourceHandler.java b/src/main/java/neatlogic/module/framework/matrix/handler/PrivateDataSourceHandler.java index 055905303..e29805a32 100644 --- a/src/main/java/neatlogic/module/framework/matrix/handler/PrivateDataSourceHandler.java +++ b/src/main/java/neatlogic/module/framework/matrix/handler/PrivateDataSourceHandler.java @@ -137,7 +137,9 @@ public class PrivateDataSourceHandler extends MatrixDataSourceHandlerBase { for (MatrixDefaultValueFilterVo defaultValueFilterVo : dataVo.getDefaultValueFilterList()) { List filterList = new ArrayList<>(); MatrixKeywordFilterVo valueFieldFilter = defaultValueFilterVo.getValueFieldFilter(); - filterList.add(new MatrixFilterVo(valueFieldFilter.getUuid(), valueFieldFilter.getExpression(), Arrays.asList(valueFieldFilter.getValue()))); + if (valueFieldFilter != null) { + filterList.add(new MatrixFilterVo(valueFieldFilter.getUuid(), valueFieldFilter.getExpression(), Arrays.asList(valueFieldFilter.getValue()))); + } MatrixKeywordFilterVo textFieldFilter = defaultValueFilterVo.getTextFieldFilter(); if (textFieldFilter != null && !Objects.equals(valueFieldFilter.getUuid(), textFieldFilter.getUuid())) { filterList.add(new MatrixFilterVo(textFieldFilter.getUuid(), textFieldFilter.getExpression(), Arrays.asList(textFieldFilter.getValue()))); diff --git a/src/main/java/neatlogic/module/framework/matrix/handler/ViewDataSourceHandler.java b/src/main/java/neatlogic/module/framework/matrix/handler/ViewDataSourceHandler.java index ac1f0e642..7ed972b47 100644 --- a/src/main/java/neatlogic/module/framework/matrix/handler/ViewDataSourceHandler.java +++ b/src/main/java/neatlogic/module/framework/matrix/handler/ViewDataSourceHandler.java @@ -302,7 +302,9 @@ public class ViewDataSourceHandler extends MatrixDataSourceHandlerBase { for (MatrixDefaultValueFilterVo defaultValueFilterVo : dataVo.getDefaultValueFilterList()) { List filterList = new ArrayList<>(); MatrixKeywordFilterVo valueFieldFilter = defaultValueFilterVo.getValueFieldFilter(); - filterList.add(new MatrixFilterVo(valueFieldFilter.getUuid(), valueFieldFilter.getExpression(), Arrays.asList(valueFieldFilter.getValue()))); + if (valueFieldFilter != null) { + filterList.add(new MatrixFilterVo(valueFieldFilter.getUuid(), valueFieldFilter.getExpression(), Arrays.asList(valueFieldFilter.getValue()))); + } MatrixKeywordFilterVo textFieldFilter = defaultValueFilterVo.getTextFieldFilter(); if (textFieldFilter != null) { filterList.add(new MatrixFilterVo(textFieldFilter.getUuid(), textFieldFilter.getExpression(), Arrays.asList(textFieldFilter.getValue()))); -- Gitee From c246e9eec9834079bb202b4fbb98e1a2e3a3b3ae Mon Sep 17 00:00:00 2001 From: linbangquan <1437892690@qq.com> Date: Tue, 21 Nov 2023 18:15:19 +0800 Subject: [PATCH 14/14] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E5=90=8E=E7=AB=AF?= =?UTF-8?q?-=E4=B8=8B=E6=8B=89=E6=A1=86=E3=80=81=E5=8D=95=E9=80=89?= =?UTF-8?q?=E3=80=81=E5=A4=8D=E9=80=89=E7=BB=84=E4=BB=B6=E9=80=89=E4=B8=AD?= =?UTF-8?q?=E5=80=BC=E7=94=B1xxx&=3D&yyy=E6=94=B9=E6=88=90{value:xxx,text:?= =?UTF-8?q?yyy}?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1025915604140032]后端-下拉框、单选、复选组件选中值由xxx&=&yyy改成{value:xxx,text:yyy} http://192.168.0.96:8090/demo/rdm.html#/task-detail/939050947543040/939050947543050/1025915604140032 --- .../form/service/FormServiceImpl.java | 26 ++++++++++++----- .../matrix/service/MatrixService.java | 8 ----- .../matrix/service/MatrixServiceImpl.java | 29 ------------------- 3 files changed, 18 insertions(+), 45 deletions(-) delete mode 100644 src/main/java/neatlogic/module/framework/matrix/service/MatrixService.java delete mode 100644 src/main/java/neatlogic/module/framework/matrix/service/MatrixServiceImpl.java diff --git a/src/main/java/neatlogic/module/framework/form/service/FormServiceImpl.java b/src/main/java/neatlogic/module/framework/form/service/FormServiceImpl.java index e1ce1c4ff..eef966da7 100644 --- a/src/main/java/neatlogic/module/framework/form/service/FormServiceImpl.java +++ b/src/main/java/neatlogic/module/framework/form/service/FormServiceImpl.java @@ -32,14 +32,16 @@ import neatlogic.framework.form.service.IFormCrossoverService; import neatlogic.framework.matrix.constvalue.SearchExpression; import neatlogic.framework.matrix.core.IMatrixDataSourceHandler; import neatlogic.framework.matrix.core.MatrixDataSourceHandlerFactory; +import neatlogic.framework.matrix.core.MatrixPrivateDataSourceHandlerFactory; +import neatlogic.framework.matrix.dao.mapper.MatrixMapper; import neatlogic.framework.matrix.dto.MatrixDataVo; import neatlogic.framework.matrix.dto.MatrixDefaultValueFilterVo; import neatlogic.framework.matrix.dto.MatrixKeywordFilterVo; import neatlogic.framework.matrix.dto.MatrixVo; import neatlogic.framework.matrix.exception.MatrixDataSourceHandlerNotFoundException; +import neatlogic.framework.matrix.exception.MatrixNotFoundException; import neatlogic.module.framework.dependency.handler.Integration2FormAttrDependencyHandler; import neatlogic.module.framework.dependency.handler.MatrixAttr2FormAttrDependencyHandler; -import neatlogic.module.framework.matrix.service.MatrixService; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -56,7 +58,7 @@ public class FormServiceImpl implements FormService, IFormCrossoverService { private FormMapper formMapper; @Resource - private MatrixService matrixService; + private MatrixMapper matrixMapper; /** * 保存表单属性与其他功能的引用关系 @@ -273,7 +275,6 @@ public class FormServiceImpl implements FormService, IFormCrossoverService { return valueList; } ValueTextVo mapping = mappingObj.toJavaObject(ValueTextVo.class); - System.out.println("13"); if (text instanceof String) { String textStr = (String) text; if (Objects.equals(mapping.getText(), mapping.getValue())) { @@ -411,7 +412,6 @@ public class FormServiceImpl implements FormService, IFormCrossoverService { } } } else {// 其他,如动态数据源 - System.out.println("14"); String matrixUuid = configObj.getString("matrixUuid"); if (StringUtils.isBlank(matrixUuid)) { return resultObj; @@ -540,7 +540,13 @@ public class FormServiceImpl implements FormService, IFormCrossoverService { return text; } try { - MatrixVo matrixVo = matrixService.getMatrixByUuid(matrixUuid); + MatrixVo matrixVo = MatrixPrivateDataSourceHandlerFactory.getMatrixVo(matrixUuid); + if (matrixVo == null) { + matrixVo = matrixMapper.getMatrixByUuid(matrixUuid); + if (matrixVo == null) { + throw new MatrixNotFoundException(matrixUuid); + } + } IMatrixDataSourceHandler matrixDataSourceHandler = MatrixDataSourceHandlerFactory.getHandler(matrixVo.getType()); if (matrixDataSourceHandler == null) { throw new MatrixDataSourceHandlerNotFoundException(matrixVo.getType()); @@ -561,7 +567,6 @@ public class FormServiceImpl implements FormService, IFormCrossoverService { JSONObject textObj = tbody.get(textField); if (Objects.equals(text, textObj.getString("text"))) { JSONObject valueObj = tbody.get(valueField); - System.out.println("15"); return valueObj.getString("value"); } } @@ -581,7 +586,13 @@ public class FormServiceImpl implements FormService, IFormCrossoverService { return value; } try { - MatrixVo matrixVo = matrixService.getMatrixByUuid(matrixUuid); + MatrixVo matrixVo = MatrixPrivateDataSourceHandlerFactory.getMatrixVo(matrixUuid); + if (matrixVo == null) { + matrixVo = matrixMapper.getMatrixByUuid(matrixUuid); + if (matrixVo == null) { + throw new MatrixNotFoundException(matrixUuid); + } + } IMatrixDataSourceHandler matrixDataSourceHandler = MatrixDataSourceHandlerFactory.getHandler(matrixVo.getType()); if (matrixDataSourceHandler == null) { throw new MatrixDataSourceHandlerNotFoundException(matrixVo.getType()); @@ -607,7 +618,6 @@ public class FormServiceImpl implements FormService, IFormCrossoverService { JSONObject valueObj = tbody.get(valueField); if (Objects.equals(value, valueObj.getString("value"))) { JSONObject textObj = tbody.get(textField); - System.out.println("15"); return textObj.getString("text"); } } diff --git a/src/main/java/neatlogic/module/framework/matrix/service/MatrixService.java b/src/main/java/neatlogic/module/framework/matrix/service/MatrixService.java deleted file mode 100644 index db68e9476..000000000 --- a/src/main/java/neatlogic/module/framework/matrix/service/MatrixService.java +++ /dev/null @@ -1,8 +0,0 @@ -package neatlogic.module.framework.matrix.service; - -import neatlogic.framework.matrix.dto.MatrixVo; - -public interface MatrixService { - - MatrixVo getMatrixByUuid(String uuid); -} diff --git a/src/main/java/neatlogic/module/framework/matrix/service/MatrixServiceImpl.java b/src/main/java/neatlogic/module/framework/matrix/service/MatrixServiceImpl.java deleted file mode 100644 index 6a4025fdd..000000000 --- a/src/main/java/neatlogic/module/framework/matrix/service/MatrixServiceImpl.java +++ /dev/null @@ -1,29 +0,0 @@ -package neatlogic.module.framework.matrix.service; - -import neatlogic.framework.matrix.core.MatrixPrivateDataSourceHandlerFactory; -import neatlogic.framework.matrix.dao.mapper.MatrixMapper; -import neatlogic.framework.matrix.dto.MatrixVo; -import neatlogic.framework.matrix.exception.MatrixNotFoundException; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; - -@Service -public class MatrixServiceImpl implements MatrixService { - - @Resource - private MatrixMapper matrixMapper; - - @Override - public MatrixVo getMatrixByUuid(String uuid) { - MatrixVo matrixVo = matrixMapper.getMatrixByUuid(uuid); - if (matrixVo != null) { - return matrixVo; - } - matrixVo = MatrixPrivateDataSourceHandlerFactory.getMatrixVo(uuid); - if (matrixVo != null) { - return matrixVo; - } - throw new MatrixNotFoundException(uuid); - } -} -- Gitee