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<CommonCascade> loadCascadePlus(List<Site> siteList, List<Area> areaList,
|
List<ProductionLine> productionLineList) {
|
if (siteList == null || siteList.isEmpty() || areaList == null || areaList.isEmpty()
|
|| productionLineList == null || productionLineList.isEmpty())
|
return Collections.emptyList();
|
List<CommonCascade> list = new ArrayList<>();
|
Map<String, CommonCascade> siteMap = new HashMap<>();
|
Map<String, CommonCascade> 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<CommonCascade> secondList = new ArrayList<>();
|
for (CommonCascade c : list) {
|
if (c.hasChildren()) {
|
secondList.add(c);
|
}
|
}
|
List<CommonCascade> middleList = new ArrayList<>();
|
for (CommonCascade c : secondList) {
|
if (c.hasChildren()) {
|
middleList.add(c);
|
}
|
}
|
List<CommonCascade> result = new ArrayList<>();
|
for (CommonCascade c : middleList) {
|
if (c.hasChildren()) {
|
result.add(c);
|
}
|
}
|
return middleList;
|
}
|
|
}
|