@@ -31,7 +31,7 @@ public class ModelCatalogTreeHandler extends AbstractTreeHandler<DefaultEntity> | |||||
private long prj_id;//所属项目 | private long prj_id;//所属项目 | ||||
private int type;//查询类型:0-目录;1-表定义;2-页面定义 | private int type;//查询类型:0-目录;1-表定义;2-页面定义 | ||||
private boolean exc_empty;//排除空目录,type非目录时有效 | private boolean exc_empty;//排除空目录,type非目录时有效 | ||||
private boolean exc_depend;//排除依赖项目的目录 | |||||
private ModelCatalogTreeHelper mcTreeHelper = null; | private ModelCatalogTreeHelper mcTreeHelper = null; | ||||
//模块子页面,暂存 | //模块子页面,暂存 | ||||
@@ -43,6 +43,7 @@ public class ModelCatalogTreeHandler extends AbstractTreeHandler<DefaultEntity> | |||||
type = params.readInt("type"); | type = params.readInt("type"); | ||||
prj_id = params.readLong("prj_id"); | prj_id = params.readLong("prj_id"); | ||||
exc_empty = params.readBool("exc_empty"); | exc_empty = params.readBool("exc_empty"); | ||||
exc_depend = params.readBool("exc_depend"); | |||||
mcTreeHelper = (ModelCatalogTreeHelper) TreeHelper.getTreeHelper(ModelCatalog.ENTITY_NAME, ModelCatalogTreeHelper.class); | mcTreeHelper = (ModelCatalogTreeHelper) TreeHelper.getTreeHelper(ModelCatalog.ENTITY_NAME, ModelCatalogTreeHelper.class); | ||||
} | } | ||||
@@ -56,7 +57,7 @@ public class ModelCatalogTreeHandler extends AbstractTreeHandler<DefaultEntity> | |||||
@Override | @Override | ||||
protected List<DefaultEntity> filterData() { | protected List<DefaultEntity> filterData() { | ||||
Set<Long> setId = ModelProjectCache.getInstance().getDependsPrjIds(prj_id); | |||||
Set<Long> setId =exc_depend ? new HashSet<>(Arrays.asList(prj_id)) : ModelProjectCache.getInstance().getDependsPrjIds(prj_id); | |||||
if (setId.isEmpty()) return new ArrayList<>(); | if (setId.isEmpty()) return new ArrayList<>(); | ||||
String sqlPrjId = CommUtil.getSqlInIds(setId); | String sqlPrjId = CommUtil.getSqlInIds(setId); | ||||
@@ -93,7 +94,7 @@ public class ModelCatalogTreeHandler extends AbstractTreeHandler<DefaultEntity> | |||||
@Override | @Override | ||||
protected List<DefaultEntity> getChildren(long id) { | protected List<DefaultEntity> getChildren(long id) { | ||||
List<ModelCatalog> list = mcTreeHelper.getChildren(id, prj_id, (o1, o2) -> CommUtil.chineseCompare(o1.getName(), o2.getName())); | |||||
List<ModelCatalog> list = mcTreeHelper.getChildren(id, prj_id,exc_depend, (o1, o2) -> CommUtil.chineseCompare(o1.getName(), o2.getName())); | |||||
List<DefaultEntity> listRet; | List<DefaultEntity> listRet; | ||||
if (type != TYPE_CATALOG && exc_empty) {//排除空目录 | if (type != TYPE_CATALOG && exc_empty) {//排除空目录 | ||||
listRet = cleanEmpty(list); | listRet = cleanEmpty(list); | ||||
@@ -141,7 +142,7 @@ public class ModelCatalogTreeHandler extends AbstractTreeHandler<DefaultEntity> | |||||
addPageChildren(listRet, mc.getId(), type); | addPageChildren(listRet, mc.getId(), type); | ||||
} | } | ||||
if (!listRet.isEmpty()) return true; | if (!listRet.isEmpty()) return true; | ||||
List<ModelCatalog> list = mcTreeHelper.getChildren(mc.getId(), prj_id, null); | |||||
List<ModelCatalog> list = mcTreeHelper.getChildren(mc.getId(), prj_id,exc_depend,null); | |||||
if (list == null || list.isEmpty()) return false; | if (list == null || list.isEmpty()) return false; | ||||
for (ModelCatalog c : list) { | for (ModelCatalog c : list) { | ||||
if (hasChildren(c)) return true; | if (hasChildren(c)) return true; | ||||
@@ -223,6 +224,8 @@ public class ModelCatalogTreeHandler extends AbstractTreeHandler<DefaultEntity> | |||||
} else if (bean instanceof ModelForm) { | } else if (bean instanceof ModelForm) { | ||||
final ModelForm form = (ModelForm) bean; | final ModelForm form = (ModelForm) bean; | ||||
node.put("type", form.getType() + 2); | node.put("type", form.getType() + 2); | ||||
// 返回页面名称 | |||||
bean.put("pageName",ModelProjectCache.getInstance().getModule(((ModelForm) bean).getPrjId())+"."+((ModelForm) bean).getName()); | |||||
//是模块,需要加子页面 | //是模块,需要加子页面 | ||||
if (form.getType() == SwEnum.FormType.MODULE.value) { | if (form.getType() == SwEnum.FormType.MODULE.value) { | ||||
List<DefaultEntity> lf = mapFormChild.get(form.getEntityId()); | List<DefaultEntity> lf = mapFormChild.get(form.getEntityId()); | ||||
@@ -17,11 +17,11 @@ public class ModelCatalogTreeHelper extends TreeHelper<ModelCatalog> { | |||||
super(ModelCatalog.ENTITY_NAME); | super(ModelCatalog.ENTITY_NAME); | ||||
} | } | ||||
public List<ModelCatalog> getChildren(long id, long prj_id, Comparator<ModelCatalog> comparator) { | |||||
public List<ModelCatalog> getChildren(long id, long prj_id,boolean exc_depend, Comparator<ModelCatalog> comparator) { | |||||
if (id > 0) { | if (id > 0) { | ||||
return getChildren(id, comparator); | return getChildren(id, comparator); | ||||
} | } | ||||
Set<Long> setId = ModelProjectCache.getInstance().getDependsPrjIds(prj_id); | |||||
Set<Long> setId = exc_depend ? new HashSet<>(Arrays.asList(prj_id)) : ModelProjectCache.getInstance().getDependsPrjIds(prj_id); | |||||
if (setId.isEmpty()) return new ArrayList<>(); | if (setId.isEmpty()) return new ArrayList<>(); | ||||
Set<ModelCatalog> set = new HashSet<>(); | Set<ModelCatalog> set = new HashSet<>(); | ||||
@@ -7,6 +7,8 @@ import cc.smtweb.framework.core.cache.CacheManager; | |||||
import cc.smtweb.framework.core.common.SwConsts; | import cc.smtweb.framework.core.common.SwConsts; | ||||
import cc.smtweb.framework.core.db.DbEngine; | import cc.smtweb.framework.core.db.DbEngine; | ||||
import cc.smtweb.framework.core.db.EntityDao; | import cc.smtweb.framework.core.db.EntityDao; | ||||
import cc.smtweb.framework.core.util.PubUtil; | |||||
import cc.smtweb.system.bpm.web.design.db.ModelProjectCache; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Comparator; | import java.util.Comparator; | ||||
@@ -23,13 +25,14 @@ public class ModelFormCache extends AbstractEntityCache<ModelForm> { | |||||
private final static String mc = "c"; | private final static String mc = "c"; | ||||
private final static String mt = "t"; | private final static String mt = "t"; | ||||
private final static String ms = "s"; | private final static String ms = "s"; | ||||
private final static String mn = "mn"; | |||||
public static ModelFormCache getInstance() { | public static ModelFormCache getInstance() { | ||||
return CacheManager.getIntance().getCache(ModelFormCache.class); | return CacheManager.getIntance().getCache(ModelFormCache.class); | ||||
} | } | ||||
public ModelFormCache() { | public ModelFormCache() { | ||||
regMap(mk, k-> k.getName().toUpperCase()); | regMap(mk, k-> k.getName().toUpperCase()); | ||||
regMap(mn, k-> ModelProjectCache.getInstance().getModule(k.getPrjId())+"-"+k.getName().toUpperCase()); | |||||
regList(mp, k-> String.valueOf(k.getPrjId())); | regList(mp, k-> String.valueOf(k.getPrjId())); | ||||
regList(mc, k-> String.valueOf(k.getMcId())); | regList(mc, k-> String.valueOf(k.getMcId())); | ||||
regList(ms, k-> String.valueOf(k.getParent())); | regList(ms, k-> String.valueOf(k.getParent())); | ||||
@@ -90,4 +93,17 @@ public class ModelFormCache extends AbstractEntityCache<ModelForm> { | |||||
ModelForm form = get(id); | ModelForm form = get(id); | ||||
return form != null ? form.getTitle() : String.valueOf(id); | return form != null ? form.getTitle() : String.valueOf(id); | ||||
} | } | ||||
/** | |||||
* 根据末模块名称和页面名称获取 页面模型 | |||||
* @param module | |||||
* @param pageName | |||||
* @return ModelForm | |||||
*/ | |||||
public ModelForm getByName(String module,String pageName){ | |||||
if(PubUtil.isEmptyStr(module)||PubUtil.isEmptyStr(pageName)){ | |||||
return null; | |||||
} | |||||
return getByKey(mn,module+"-"+pageName.toUpperCase()); | |||||
} | |||||
} | } |
@@ -63,7 +63,12 @@ public class ModelFormLoadHandler extends DefaultLoadHandler<ModelForm> { | |||||
if (bean == null) throw new BizException("没有找到指定定义信息!id=" + id); | if (bean == null) throw new BizException("没有找到指定定义信息!id=" + id); | ||||
return R.success(ModelFormHelper.buildEngineModel(bean, params, us)); | return R.success(ModelFormHelper.buildEngineModel(bean, params, us)); | ||||
} | } | ||||
// 页面引擎-获取页面模型 | |||||
public R loadForm(String module, String pageName) { | |||||
ModelForm bean = ModelFormCache.getInstance().getByName(module,pageName); | |||||
if (bean == null) throw new BizException("没有找到指定定义信息!module=" + module+",pageName="+pageName); | |||||
return R.success(ModelFormHelper.buildEngineModel(bean, params, us)); | |||||
} | |||||
//获取页面使用的控件的filter信息 | //获取页面使用的控件的filter信息 | ||||
public R loadWidgetFilter() { | public R loadWidgetFilter() { | ||||
long id = params.readLong("id"); | long id = params.readLong("id"); | ||||
@@ -109,7 +109,15 @@ public class ModelFormService extends AbstractCompService { | |||||
public R model(@SwBody SwMap params, UserSession us) { | public R model(@SwBody SwMap params, UserSession us) { | ||||
try { | try { | ||||
ModelFormLoadHandler handler = (ModelFormLoadHandler) getHandler(params, us, TYPE_LOAD); | ModelFormLoadHandler handler = (ModelFormLoadHandler) getHandler(params, us, TYPE_LOAD); | ||||
return handler.loadForm(); | |||||
String page = params.readString("id",""); | |||||
String [] array = page.split("\\."); | |||||
String module = ""; | |||||
String pageName = ""; | |||||
if(array.length==2){ | |||||
module = array[0]; | |||||
pageName = array[1]; | |||||
} | |||||
return handler.loadForm(module,pageName); | |||||
} catch (Exception e) { | } catch (Exception e) { | ||||
return R.error("操作失败!", e); | return R.error("操作失败!", e); | ||||
} | } | ||||
@@ -54,7 +54,7 @@ public class PreviewMenuTreeService { | |||||
MenuVO menu = new MenuVO(); | MenuVO menu = new MenuVO(); | ||||
menu.setId(form.getId()); | menu.setId(form.getId()); | ||||
menu.setName(form.getTitle()); | menu.setName(form.getTitle()); | ||||
menu.setPath("/bpm/" + form.getId()); | |||||
menu.setPath("/bpm/" + module+"."+form.getName()); | |||||
menu.setParentId(form.getMcId()); | menu.setParentId(form.getMcId()); | ||||
setMenuChildren(map.get(form.getMcId()), menu); | setMenuChildren(map.get(form.getMcId()), menu); | ||||