diff --git a/src/main/java/neatlogic/framework/rebuilddatabaseview/core/RebuildDataBaseViewManager.java b/src/main/java/neatlogic/framework/rebuilddatabaseview/core/RebuildDataBaseViewManager.java index 10ae2f00bf8c31f66f6e407937e3360bc3544db9..1b5b7d1720cc07affabb8f044d04f742e037d613 100644 --- a/src/main/java/neatlogic/framework/rebuilddatabaseview/core/RebuildDataBaseViewManager.java +++ b/src/main/java/neatlogic/framework/rebuilddatabaseview/core/RebuildDataBaseViewManager.java @@ -17,32 +17,38 @@ package neatlogic.framework.rebuilddatabaseview.core; import neatlogic.framework.applicationlistener.core.ModuleInitializedListenerBase; +import neatlogic.framework.asynchronization.threadlocal.TenantContext; import neatlogic.framework.bootstrap.NeatLogicWebApplicationContext; import neatlogic.framework.common.RootComponent; +import neatlogic.framework.dto.module.ModuleGroupVo; +import org.apache.commons.collections4.CollectionUtils; import java.util.*; @RootComponent public class RebuildDataBaseViewManager extends ModuleInitializedListenerBase { - private final static Map map = new HashMap<>(); - - public static IRebuildDataBaseView getHandler(String handler) { - return map.get(handler); - } + private final static Map> moduleGroup2HandlerListMap = new HashMap<>(); @Override protected void onInitialized(NeatLogicWebApplicationContext context) { Map myMap = context.getBeansOfType(IRebuildDataBaseView.class); for (Map.Entry entry : myMap.entrySet()) { IRebuildDataBaseView bean = entry.getValue(); - map.put(bean.getHandler(), bean); + moduleGroup2HandlerListMap.computeIfAbsent(context.getGroup(), key -> new ArrayList<>()).add(bean); } } public static List execute() { List resultList = new ArrayList<>(); - List list = new ArrayList<>(map.values()); + List list = new ArrayList<>(); + List activeModuleGroupList = TenantContext.get().getActiveModuleGroupList(); + for (ModuleGroupVo moduleGroupVo : activeModuleGroupList) { + List handlerList = moduleGroup2HandlerListMap.get(moduleGroupVo.getGroup()); + if (CollectionUtils.isNotEmpty(handlerList)) { + list.addAll(handlerList); + } + } list.sort(Comparator.comparing(IRebuildDataBaseView::getSort)); for (IRebuildDataBaseView rebuildDataBaseView : list) { resultList.addAll(rebuildDataBaseView.execute());