郑根木 преди 2 години
родител
ревизия
2fe93fbd1d
променени са 3 файла, в които са добавени 117 реда и са изтрити 29 реда
  1. +66
    -0
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormCache.java
  2. +1
    -1
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormHelper.java
  3. +50
    -28
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/table/ModelCatalogTreeHandler.java

+ 66
- 0
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormCache.java Целия файл

@@ -0,0 +1,66 @@
package cc.smtweb.system.bpm.web.design.form;

import cc.smtweb.framework.core.annotation.SwCache;
import cc.smtweb.framework.core.cache.AbstractCache;
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.impl.DefaultEntity;
import cc.smtweb.framework.core.db.vo.ModelTable;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.ResultSetExtractor;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Set;

/**
* Created by Akmm at 2022/1/12 18:34
*/
@SwCache(ident = "ASP_MODEL_FORM", title = "页面定义")
public class ModelFormCache extends AbstractCache<ModelForm> {
private final static String mk = "k";
private final static String mp = "prj";
private final static String mc = "c";

public static ModelFormCache getInstance() {
return CacheManager.getIntance().getCache(ModelFormCache.class);
}

public ModelFormCache() {
regMap(mk, k-> k.getName().toUpperCase());
regList(mp, k-> String.valueOf(k.getPrjId()));
regList(mc, k-> String.valueOf(k.getMcId()));
// regList(mf, k-> k.get);
}

@Override
protected String getId(ModelForm bean) {
return String.valueOf(bean.getId());
}

@Override
protected List<ModelForm> loadAll() {
EntityDao<ModelForm> dao = DbEngine.getInstance().findDao(ModelForm.class);
return dao.query();
}

public final ModelForm getByName(String key) {
return getByKey(mk, key.toUpperCase());
}

public final Set<ModelForm> getFormsByMc(long mcId) {
return getListByKey(mc, String.valueOf(mcId));
}

public final List<ModelForm> getFormsByMc(long mcId, Comparator<ModelForm> comparator) {
Set<ModelForm> set = getListByKey(mc, String.valueOf(mcId));
if (set == null || set.isEmpty()) return null;
List<ModelForm> list = new ArrayList<>(set);
list.sort(comparator);
return list;
}
}

+ 1
- 1
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormHelper.java Целия файл

@@ -36,7 +36,7 @@ public class ModelFormHelper {
* @return
*/
public static ModelForm getFromCache(long formId) {
AbstractCache<ModelForm> cache = CacheManager.getIntance().getCache(ModelForm.ENTITY_NAME);
AbstractCache<ModelForm> cache = ModelFormCache.getInstance();
if (cache == null) return null;
return cache.get(formId);
}


+ 50
- 28
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/table/ModelCatalogTreeHandler.java Целия файл

@@ -1,5 +1,6 @@
package cc.smtweb.system.bpm.web.design.table;

import cc.smtweb.framework.core.common.SwEnum;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.db.DbEngine;
import cc.smtweb.framework.core.db.EntityDao;
@@ -11,6 +12,8 @@ import cc.smtweb.framework.core.mvc.service.AbstractTreeHandler;
import cc.smtweb.framework.core.mvc.service.TreeHelper;
import cc.smtweb.framework.core.session.UserSession;
import cc.smtweb.framework.core.util.CommUtil;
import cc.smtweb.system.bpm.web.design.form.ModelForm;
import cc.smtweb.system.bpm.web.design.form.ModelFormCache;

import java.util.ArrayList;
import java.util.Collection;
@@ -19,11 +22,13 @@ import java.util.List;
/**
* Created by Akmm at 2022/3/21 18:22
*/
public class ModelCatalogTreeHandler extends AbstractTreeHandler<Object> {
//查询类型:0-目录;1-表定义;2-页面定义
public class ModelCatalogTreeHandler extends AbstractTreeHandler<DefaultEntity> {
//查询类型:0-目录;1-表定义;2-页面;3-控件;4-页面和控件
private final static int TYPE_CATALOG = 0;
private final static int TYPE_TABLE = 1;
private final static int TYPE_PAGE = 2;
private final static int TYPE_WIDGET = 3;
private final static int TYPE_FORM = 4;

private long prj_id;//所属项目
private int type;//查询类型:0-目录;1-表定义;2-页面定义
@@ -39,7 +44,7 @@ public class ModelCatalogTreeHandler extends AbstractTreeHandler<Object> {
}

@Override
protected List<Object> getChildren(Object bean) {
protected List<DefaultEntity> getChildren(DefaultEntity bean) {
if (bean instanceof ModelCatalog) {
return super.getChildren(bean);
}
@@ -47,13 +52,12 @@ public class ModelCatalogTreeHandler extends AbstractTreeHandler<Object> {
}

@Override
protected List<Object> filterData() {
List<Object> listRet = new ArrayList<>();
protected List<DefaultEntity> filterData() {

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);
listRet.addAll(list);
List<DefaultEntity> listRet = new ArrayList<>(list);

switch (type) {
case TYPE_TABLE:
@@ -62,55 +66,73 @@ public class ModelCatalogTreeHandler extends AbstractTreeHandler<Object> {
listRet.addAll(l);
break;
case TYPE_PAGE:
;
case TYPE_WIDGET:
case TYPE_FORM:
EntityDao<ModelForm> formdao = DbEngine.getInstance().findDao(ModelForm.class);
List<ModelForm> lf;
if (type != TYPE_FORM) {
lf = formdao.queryWhere(" mf_prj_id=? and (mf_name like ? or mf_title like ?) order by tb_name", prj_id, text, text);
} else {
//数据库type 0-页面 1-控件
lf = formdao.queryWhere(" mf_prj_id=? and mf_type=? and (mf_name like ? or mf_title like ?) order by tb_name", prj_id, type - 2, text, text);
}
listRet.addAll(lf);
}
return listRet;
}

@Override
protected List<Object> getChildren(long id) {
List<Object> listRet = new ArrayList<>();
protected List<DefaultEntity> getChildren(long id) {
List<ModelCatalog> list;
list = mcTreeHelper.getChildren(id, prj_id, (o1, o2) -> CommUtil.chineseCompare(o1.getName(), o2.getName()));

listRet.addAll(list);
List<DefaultEntity> listRet = new ArrayList<>(list);

switch (type) {
case TYPE_TABLE:
addTableChildren(listRet, id);
break;
case TYPE_PAGE:
addPageChildren(listRet, id);
case TYPE_WIDGET:
case TYPE_FORM:
addPageChildren(listRet, id, type);
}
return listRet;
}

//增加表
private void addTableChildren(List<Object> listRet, long id) {
Collection<ModelTable> set = ModelTableCache.getInstance().getTablesByMc(id, (o1, o2) -> CommUtil.chineseCompare(o1.getName(), o2.getName()));
private void addTableChildren(List<DefaultEntity> listRet, long mcid) {
Collection<ModelTable> set = ModelTableCache.getInstance().getTablesByMc(mcid, (o1, o2) -> CommUtil.chineseCompare(o1.getName(), o2.getName()));
if (set == null || set.isEmpty()) return;

listRet.addAll(set);
}

//增加页面定义
private void addPageChildren(List<Object> listRet, long id) {

private void addPageChildren(List<DefaultEntity> listRet, long mcid, int type) {
List<ModelForm> set = ModelFormCache.getInstance().getFormsByMc(mcid, (o1, o2) -> {
if (o1.getType() != o2.getType()) return o1.getType() - o2.getType();
return CommUtil.chineseCompare(o1.getTitle(), o2.getTitle());
});
if (set == null || set.isEmpty()) return;
if (type != TYPE_FORM) {
for (ModelForm form: set) {
if (form.getType() == type) {
listRet.add(form);
}
}
} else {
listRet.addAll(set);
}
}

@Override
protected long getId(Object bean) {
if (bean instanceof DefaultEntity) {
return ((DefaultEntity) bean).getEntityId();
}
if (bean instanceof ModelTable) {
return ((ModelTable) bean).getId();
}
return 0;
protected long getId(DefaultEntity bean) {
return bean.getEntityId();
}

@Override
protected String getText(Object bean) {
protected String getText(DefaultEntity bean) {
if (bean instanceof ModelCatalog) {
return ((ModelCatalog) bean).getName();
}
@@ -118,14 +140,14 @@ public class ModelCatalogTreeHandler extends AbstractTreeHandler<Object> {
return ((ModelTable) bean).getTitle();
}

/*if (bean instanceof ModelTable) {
return ((ModelTable)bean).getTitle();
}*/
if (bean instanceof ModelForm) {
return ((ModelForm)bean).getTitle();
}
return null;
}

@Override
protected void buildNode(SwMap node, Object bean) {
protected void buildNode(SwMap node, DefaultEntity bean) {
super.buildNode(node, bean);
if (bean instanceof ModelCatalog) {
node.put("type", TYPE_CATALOG);


Зареждане…
Отказ
Запис