瀏覽代碼

数据集按依赖关系排序

master
郑根木 2 年之前
父節點
當前提交
672c8cd676
共有 2 個檔案被更改,包括 28 行新增13 行删除
  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 查看文件

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

+ 7
- 4
smtweb-framework/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDatasets.java 查看文件

@@ -3,10 +3,7 @@ package cc.smtweb.system.bpm.web.design.form.define;
import cc.smtweb.framework.core.db.cache.ModelTableCache;
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
@@ -31,6 +28,12 @@ public class PageDatasets {
ds.masterTable_text = ModelTableCache.getInstance().getTableName(ds.masterTable);
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() {


Loading…
取消
儲存