Sfoglia il codice sorgente

项目依赖修正

master
郑根木 2 anni fa
parent
commit
66dc1ae2a9
4 ha cambiato i file con 51 aggiunte e 13 eliminazioni
  1. +9
    -5
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/db/ModelCatalogTreeHandler.java
  2. +10
    -6
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/db/ModelCatalogTreeHelper.java
  3. +26
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/db/ModelProjectCache.java
  4. +6
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/db/ModelTableComboHandler.java

+ 9
- 5
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/db/ModelCatalogTreeHandler.java Vedi File

@@ -56,15 +56,19 @@ public class ModelCatalogTreeHandler extends AbstractTreeHandler<DefaultEntity>

@Override
protected List<DefaultEntity> filterData() {
Set<Long> setId = ModelProjectCache.getInstance().getDependsPrjIds(prj_id);
if (setId.isEmpty()) return new ArrayList<>();
String sqlPrjId = CommUtil.getSqlInIds(setId);

EntityDao<ModelCatalog> dao = DbEngine.getInstance().findDao(ModelCatalog.ENTITY_NAME);
String text = "%" + params.readString("text") + "%";
List<ModelCatalog> list = dao.queryWhere(" mc_prj_id=? and (mc_name like ? or mc_code like ?) order by mc_name", prj_id, text, text);
List<ModelCatalog> list = dao.queryWhere(" mc_prj_id in (" + sqlPrjId + ") and (mc_name like ? or mc_code like ?) order by mc_name", text, text);
List<DefaultEntity> listRet = new ArrayList<>(list);

switch (type) {
case TYPE_TABLE:
EntityDao<ModelTable> tabledao = DbEngine.getInstance().findDao(ModelTable.class);
List<ModelTable> l = tabledao.queryWhere(" tb_prj_id=? and (tb_name like ? or tb_title like ?) order by tb_name", prj_id, text, text);
List<ModelTable> l = tabledao.queryWhere(" tb_prj_id in (" + sqlPrjId + ") and (tb_name like ? or tb_title like ?) order by tb_name", text, text);
listRet.addAll(l);
break;
case TYPE_PAGE:
@@ -74,13 +78,13 @@ public class ModelCatalogTreeHandler extends AbstractTreeHandler<DefaultEntity>
List<ModelForm> lf;
switch (type) {
case TYPE_PAGE:
lf = formdao.queryWhere(" mf_prj_id=? and mf_type<>? and (mf_name like ? or mf_title like ?) order by tb_name", prj_id, SwEnum.FormType.WIDGET.value, text, text);
lf = formdao.queryWhere(" mf_prj_id in (" + sqlPrjId + ") and mf_type<>? and (mf_name like ? or mf_title like ?) order by tb_name", SwEnum.FormType.WIDGET.value, text, text);
break;
case TYPE_WIDGET:
lf = formdao.queryWhere(" mf_prj_id=? and mf_type=? and (mf_name like ? or mf_title like ?) order by tb_name", prj_id, SwEnum.FormType.WIDGET.value, text, text);
lf = formdao.queryWhere(" mf_prj_id in (" + sqlPrjId + ") and mf_type=? and (mf_name like ? or mf_title like ?) order by tb_name", SwEnum.FormType.WIDGET.value, text, text);
break;
default:
lf = formdao.queryWhere(" mf_prj_id=? and (mf_name like ? or mf_title like ?) order by tb_name", prj_id, text, text);
lf = formdao.queryWhere(" mf_prj_id in (" + sqlPrjId + ") and (mf_name like ? or mf_title like ?) order by tb_name", text, text);
}
listRet.addAll(lf);
}


+ 10
- 6
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/db/ModelCatalogTreeHelper.java Vedi File

@@ -4,10 +4,7 @@ import cc.smtweb.framework.core.common.SwConsts;
import cc.smtweb.framework.core.db.vo.ModelCatalog;
import cc.smtweb.framework.core.mvc.service.TreeHelper;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.*;

/**
* Created by Akmm at 2022/3/25 10:47
@@ -24,9 +21,16 @@ public class ModelCatalogTreeHelper extends TreeHelper<ModelCatalog> {
if (id > 0) {
return getChildren(id, comparator);
}
Collection<ModelCatalog> set = cache.getListByKey(CACHE_KEY, prj_id + SwConsts.SPLIT_CHAR + SwConsts.DEF_ROOT_ID);
Set<Long> setId = ModelProjectCache.getInstance().getDependsPrjIds(prj_id);
if (setId.isEmpty()) return new ArrayList<>();
Set<ModelCatalog> set = new HashSet<>();

List<ModelCatalog> list = set == null ? new ArrayList<>() : new ArrayList<>(set);
for (long prjId: setId) {
Collection<ModelCatalog> st = cache.getListByKey(CACHE_KEY, prjId + SwConsts.SPLIT_CHAR + SwConsts.DEF_ROOT_ID);
if (st != null) set.addAll(st);
}

List<ModelCatalog> list = new ArrayList<>(set);
if (comparator != null)
list.sort(comparator);
return list;


+ 26
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/db/ModelProjectCache.java Vedi File

@@ -6,8 +6,12 @@ import cc.smtweb.framework.core.cache.CacheManager;
import cc.smtweb.framework.core.db.DbEngine;
import cc.smtweb.framework.core.db.EntityDao;
import cc.smtweb.framework.core.db.vo.ModelProject;
import cc.smtweb.framework.core.util.NumberUtil;
import org.apache.commons.lang3.StringUtils;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
* Created by Akmm at 2022/1/12 18:34
@@ -45,4 +49,26 @@ public class ModelProjectCache extends AbstractCache<ModelProject> {
ModelProject bean = getByModule(module);
return bean !=null ? String.valueOf(bean.getId()): "";
}

//找当前项目及其依赖项目的id集合,递归
public Set<Long> getDependsPrjIds(long id) {
Set<Long> set = new HashSet<>();
addPrjId(set, id);
return set;
}

//递归增加
private void addPrjId(Set<Long> set, long id) {
if (set.contains(id)) return;
ModelProject bean = get(id);
if (bean == null) return;
set.add(id);
if (StringUtils.isEmpty(bean.getDepends())) return;
String[] dps = bean.getDepends().split(",");
for (String s: dps) {
s = s.trim();
if (StringUtils.isEmpty(s)) return;
addPrjId(set, NumberUtil.getLongIgnoreErr(s));
}
}
}

+ 6
- 2
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/db/ModelTableComboHandler.java Vedi File

@@ -2,8 +2,10 @@ package cc.smtweb.system.bpm.web.design.db;

import cc.smtweb.framework.core.db.vo.ModelTable;
import cc.smtweb.framework.core.mvc.service.DefaultComboHandler;
import cc.smtweb.framework.core.util.CommUtil;

import java.util.List;
import java.util.Set;

/**
* Created by Akmm at 2022/3/22 19:25
@@ -18,8 +20,10 @@ public class ModelTableComboHandler extends DefaultComboHandler<ModelTable> {
super.buildCondition(sql, args);
long prj_id = params.readLong("prj_id");
if (prj_id > 0) {
sql.append(" and tb_prj_id=?");
args.add(prj_id);
Set<Long> setId = ModelProjectCache.getInstance().getDependsPrjIds(prj_id);
if (!setId.isEmpty()) {
sql.append(" and tb_prj_id in (").append(CommUtil.getSqlInIds(setId)).append(")");
}
}

long db_id = params.readLong("db_id");


Caricamento…
Annulla
Salva