Browse Source

数据集按依赖关系排序

master
郑根木 2 years ago
parent
commit
672c8cd676
2 changed files with 28 additions and 13 deletions
  1. +21
    -9
      smtweb-framework/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDataset.java
  2. +7
    -4
      smtweb-framework/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDatasets.java

+ 21
- 9
smtweb-framework/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDataset.java View File

@@ -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);
}
} }

+ 7
- 4
smtweb-framework/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDatasets.java View File

@@ -3,10 +3,7 @@ package cc.smtweb.system.bpm.web.design.form.define;
import cc.smtweb.framework.core.db.cache.ModelTableCache; import cc.smtweb.framework.core.db.cache.ModelTableCache;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;


/** /**
* Created by Akmm at 2022/5/25 15:53 * Created by Akmm at 2022/5/25 15:53
@@ -31,6 +28,12 @@ public class PageDatasets {
ds.masterTable_text = ModelTableCache.getInstance().getTableName(ds.masterTable); ds.masterTable_text = ModelTableCache.getInstance().getTableName(ds.masterTable);
ds.resetFields(); ds.resetFields();
} }
//按依赖关系排序
this.list.sort((o1, o2) -> {
if (o1.hasDepends(o2.name)) return 1;
if (o2.hasDepends(o1.name)) return -1;
return 0;
});
} }


public PageDataset findMasterDataset() { public PageDataset findMasterDataset() {


Loading…
Cancel
Save