|
|
@@ -8,9 +8,7 @@ import cc.smtweb.framework.core.db.vo.ModelField; |
|
|
|
import cc.smtweb.framework.core.db.vo.ModelTable; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
/** |
|
|
|
* Created by Akmm at 2022/4/18 14:20 |
|
|
@@ -52,6 +50,9 @@ public class PageDataset { |
|
|
|
private Map<String, PageDatasetField> mapFieldId; |
|
|
|
private Map<String, PageDatasetFilter> mapFilterId; |
|
|
|
|
|
|
|
//依赖的数据集 |
|
|
|
private Set<String> linkDs = new HashSet<>(); |
|
|
|
|
|
|
|
public PageDatasetField findFieldByName(String name) { |
|
|
|
if (mapFieldName == null) resetFields(); |
|
|
|
return mapFieldName.get(name); |
|
|
@@ -78,21 +79,23 @@ public class PageDataset { |
|
|
|
public void resetFields() { |
|
|
|
mapFieldName = new HashMap<>(); |
|
|
|
mapFieldId = new HashMap<>(); |
|
|
|
resetFields(mapFieldName, mapFieldId, fields); |
|
|
|
linkDs.clear(); |
|
|
|
resetFields(mapFieldName, mapFieldId, fields, false); |
|
|
|
mapFilterName = new HashMap<>(); |
|
|
|
mapFilterId = new HashMap<>(); |
|
|
|
resetFields(mapFilterName, mapFilterId, filters); |
|
|
|
for (PageDatasetFilter filter: filters) { |
|
|
|
resetFields(mapFilterName, mapFilterId, filters, true); |
|
|
|
|
|
|
|
for (PageDatasetFilter filter : filters) { |
|
|
|
if (StringUtils.isEmpty(filter.sqlName)) { |
|
|
|
filter.sqlName = filter.field; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private <T extends PageDatasetField> void resetFields(Map<String, T> mapName, Map<String, T> mapId, List<T> list) { |
|
|
|
private <T extends PageDatasetField> void resetFields(Map<String, T> mapName, Map<String, T> mapId, List<T> list, boolean isFilter) { |
|
|
|
ModelTableCache cache = ModelTableCache.getInstance(); |
|
|
|
ModelTable table = null; |
|
|
|
for (T field: list) { |
|
|
|
for (T field : list) { |
|
|
|
mapName.put(field.name, field); |
|
|
|
mapId.put(field.id, field); |
|
|
|
if (field.table <= 0 || StringUtils.isEmpty(field.field)) continue; |
|
|
@@ -111,15 +114,24 @@ public class PageDataset { |
|
|
|
if (StringUtils.isEmpty(field.dataType)) field.dataType = mf.getDataType(); |
|
|
|
if (StringUtils.isEmpty(field.remark)) field.remark = mf.getRemark(); |
|
|
|
if (StringUtils.isEmpty(field.editor)) field.editor = mf.getEditor(); |
|
|
|
//过滤条件,需要建立依赖关系 |
|
|
|
if (isFilter) { |
|
|
|
PageDatasetFilter filter = (PageDatasetFilter) field; |
|
|
|
if (StringUtils.isNotEmpty(filter.linkDb)) linkDs.add(filter.linkDb); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public PageDatasetFilter findFilterByDs(String dsName) { |
|
|
|
for (PageDatasetFilter filter: filters) { |
|
|
|
for (PageDatasetFilter filter : filters) { |
|
|
|
if (SwEnum.FilterType.LINK.value.equals(filter.type) && dsName.equals(filter.linkDb)) { |
|
|
|
return filter; |
|
|
|
} |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
public boolean hasDepends(String dsName) { |
|
|
|
return linkDs.contains(dsName); |
|
|
|
} |
|
|
|
} |