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