package org.jeecg.modules.eam.wrapper; import org.jeecg.modules.eam.entity.Area; import org.jeecg.modules.eam.entity.ProductionLine; import org.jeecg.modules.eam.entity.Site; import org.jeecg.modules.eam.vo.CommonCascade; import java.util.*; public class SiteAreaProductLineWrapper { public static List loadCascadePlus(List siteList, List areaList, List productionLineList) { if (siteList == null || siteList.isEmpty() || areaList == null || areaList.isEmpty() || productionLineList == null || productionLineList.isEmpty()) return Collections.emptyList(); List list = new ArrayList<>(); Map siteMap = new HashMap<>(); Map areaMap = new HashMap<>(); if (siteList == null || siteList.isEmpty()) return list; CommonCascade siteNode; CommonCascade areaNode; CommonCascade productionLineNode; for (Site site : siteList) { siteNode = new CommonCascade(); siteNode = siteNode.setValue(site.getId()).setLabel(site.getName()); list.add(siteNode); siteMap.put(site.getId(), siteNode); } for (Area area : areaList) { if (siteMap.containsKey(area.getSiteId())) { siteNode = siteMap.get(area.getSiteId()); areaNode = new CommonCascade(); areaNode = areaNode.setValue(area.getId()).setLabel(area.getName()); siteNode.addChildren(areaNode); areaMap.put(area.getId(), areaNode); } } for (ProductionLine productionLine : productionLineList) { if (areaMap.containsKey(productionLine.getAreaId())) { areaNode = areaMap.get(productionLine.getAreaId()); productionLineNode = new CommonCascade(); productionLineNode = productionLineNode.setValue(productionLine.getId()) .setLabel(productionLine.getName()); areaNode.addChildren(productionLineNode); } } List secondList = new ArrayList<>(); for (CommonCascade c : list) { if (c.hasChildren()) { secondList.add(c); } } List middleList = new ArrayList<>(); for (CommonCascade c : secondList) { if (c.hasChildren()) { middleList.add(c); } } List result = new ArrayList<>(); for (CommonCascade c : middleList) { if (c.hasChildren()) { result.add(c); } } return middleList; } }