package com.vci.web.utility;
|
|
import com.vci.corba.common.PLException;
|
import com.vci.corba.portal.data.PLPageDefination;
|
import com.vci.corba.portal.data.PLTabButton;
|
import com.vci.corba.portal.data.PLTabPage;
|
import com.vci.corba.portal.data.PLUILayout;
|
import com.vci.web.util.UITools;
|
|
import java.util.*;
|
import java.util.stream.Collectors;
|
|
/**
|
* @author ludc
|
* @date 2024/10/15 10:32
|
*/
|
public class UIDataFetcher {
|
|
//上下文map
|
private Map<String, List<PLUILayout>> contextMap = new HashMap<String, List<PLUILayout>>();
|
|
//tab页签map
|
private Map<String, List<PLTabPage>> tabMap = new HashMap<String, List<PLTabPage>>();
|
|
//组件map
|
private Map<String, List<PLPageDefination>> defMap = new HashMap<String, List<PLPageDefination>>();
|
|
//按钮map
|
private Map<String, List<PLTabButton>> buttonMap = new HashMap<String, List<PLTabButton>>();
|
|
|
|
public UIDataFetcher() {
|
initUIDefination();
|
}
|
|
public static void main(String[] args) {
|
new UIDataFetcher();
|
}
|
|
/**
|
* 初始化所有UI定义信息
|
*/
|
private void initUIDefination() {
|
try {
|
//初始化所有的上下文
|
//long s = System.currentTimeMillis();
|
PLUILayout[] allContext = UITools.getService().getAllPLUILayouts();
|
//long e = System.currentTimeMillis();
|
//System.out.println(allContext.length + " 1: " + (e - s));
|
//s = System.currentTimeMillis();
|
List<PLUILayout> contextList = null;
|
for (PLUILayout context : allContext) {
|
if (contextMap.get(context.plRelatedType) == null) {
|
contextList = new ArrayList<PLUILayout>();
|
contextMap.put(context.plRelatedType, contextList);
|
} else {
|
contextList = contextMap.get(context.plRelatedType);
|
}
|
contextList.add(context);
|
}
|
//e = System.currentTimeMillis();
|
//System.out.println("2: " + (e - s));
|
//初始化所有的页签
|
//s = System.currentTimeMillis();
|
PLTabPage[] allTabs = UITools.getService().getAllPLTabPages();
|
//e = System.currentTimeMillis();
|
//System.out.println(allTabs.length + " 3: " + (e - s));
|
//s = System.currentTimeMillis();
|
List<PLTabPage> tabList = null;
|
for (PLTabPage tab : allTabs) {
|
if (tabMap.get(tab.plContextOId) == null) {
|
tabList = new ArrayList<PLTabPage>();
|
tabMap.put(tab.plContextOId, tabList);
|
} else {
|
tabList = tabMap.get(tab.plContextOId);
|
}
|
tabList.add(tab);
|
}
|
//e = System.currentTimeMillis();
|
//System.out.println("4: " + (e - s));
|
//s = System.currentTimeMillis();
|
//初始化组建定义
|
PLPageDefination[] allDefinations = UITools.getService().getAllPLPageDefinationsWithNoConf();
|
//e = System.currentTimeMillis();
|
//System.out.println(allDefinations.length + " 5: " + (e - s));
|
//s = System.currentTimeMillis();
|
List<PLPageDefination> defList = null;
|
for (PLPageDefination def : allDefinations) {
|
if (defMap.get(def.plTabPageOId) == null) {
|
defList = new ArrayList<PLPageDefination>();
|
defMap.put(def.plTabPageOId, defList);
|
} else {
|
defList = defMap.get(def.plTabPageOId);
|
}
|
defList.add(def);
|
}
|
//e = System.currentTimeMillis();
|
//System.out.println("6: " + (e - s));
|
//初始化button
|
//s = System.currentTimeMillis();
|
PLTabButton[] allButtons = UITools.getService().getAllPLTabButtons();
|
//e = System.currentTimeMillis();
|
//System.out.println(allButtons.length + " 7: " + (e - s));
|
//s = System.currentTimeMillis();
|
List<PLTabButton> allButtonList = Arrays.stream(allButtons).filter(item -> item.show.equals("0")).collect(Collectors.toList());
|
List<PLTabButton> buttonList = null;
|
for (PLTabButton button : allButtonList) {
|
if (buttonMap.get(button.plTableOId) == null) {
|
buttonList = new ArrayList<PLTabButton>();
|
buttonMap.put(button.plTableOId, buttonList);
|
} else {
|
buttonList = buttonMap.get(button.plTableOId);
|
}
|
buttonList.add(button);
|
}
|
//e = System.currentTimeMillis();
|
//System.out.println("8: " + (e - s));
|
} catch (PLException e) {
|
e.printStackTrace();
|
}
|
}
|
|
/**
|
* 获取业务类型下的上下文信息
|
* @param btmType
|
* @return
|
*/
|
public List<PLUILayout> getContext(String btmType) {
|
return contextMap.get(btmType);
|
}
|
|
/**
|
* 获取上下文件下的tab页签信息
|
* @param contextId
|
* @return
|
*/
|
public List<PLTabPage> getTabs(String contextId) {
|
return tabMap.get(contextId);
|
}
|
|
/**
|
* 获取tab页签下的组件信息
|
* @param tabId
|
* @return
|
*/
|
public List<PLPageDefination> getComopnent(String tabId) {
|
return defMap.get(tabId);
|
}
|
|
/**
|
* 获取组件下的按钮信息
|
* @param componentId
|
* @return
|
*/
|
public List<PLTabButton> getButtons(String componentId) {
|
List<PLTabButton> buttons = this.buttonMap.get(componentId);
|
if (buttons != null) {
|
sort(buttons);
|
}
|
return buttons;
|
}
|
|
/**
|
* 按钮顺序好排序button
|
* @param buttons
|
*/
|
private void sort(List<PLTabButton> buttons) {
|
Collections.sort(buttons, new Comparator<PLTabButton>(){
|
|
@Override
|
public int compare(PLTabButton o1, PLTabButton o2) {
|
return new Integer(o1.plSeq).compareTo(new Integer(o2.plSeq));
|
}
|
});
|
}
|
|
}
|