package org.jeecg.modules.eam.wrapper;
|
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
import org.jeecg.common.api.vo.CommonGenericTree;
|
import org.jeecg.common.util.StrUtils;
|
import org.jeecg.modules.eam.entity.Area;
|
import org.jeecg.modules.eam.entity.ProductionLine;
|
import org.jeecg.modules.eam.entity.Site;
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
@SuppressWarnings("rawtypes")
|
public class SiteAreaLineTreeWrapper {
|
|
/**
|
* 工厂/车间树
|
*/
|
public static List<CommonGenericTree> loadTree(List<Site> siteList, List<Area> areaList) {
|
//return loadTree(siteList, areaList, Collections.emptyList());
|
return null;
|
}
|
|
/**
|
* 工厂/车间/产线树
|
*/
|
@SuppressWarnings("unchecked")
|
public static List<CommonGenericTree> loadTree(String title,List<Site> siteList, List<Area> areaList,
|
List<ProductionLine> productionLineList) {
|
List<CommonGenericTree> list = new ArrayList<>();
|
Map<String, CommonGenericTree> siteMap = new HashMap<>();
|
Map<String, CommonGenericTree> areaMap = new HashMap<>();
|
CommonGenericTree<Site> root = new CommonGenericTree<>();
|
root.setKey("-1");
|
root.setTitle("中国航发");
|
root.setType(0);
|
list.add(root);
|
if (CollectionUtils.isNotEmpty(siteList)) {
|
CommonGenericTree<Site> siteNode;
|
CommonGenericTree<Area> areaNode;
|
CommonGenericTree<ProductionLine> lineNode;
|
for (Site site : siteList) {
|
siteNode = new CommonGenericTree<>();
|
siteNode.setKey(site.getId());
|
siteNode.setTitle(site.getName());
|
siteNode.setParentId(root.getKey());
|
siteNode.setIcon("");
|
siteNode.setType(1);
|
siteNode.setEntity(site);
|
root.addChildren(siteNode);
|
siteMap.put(site.getId(), siteNode);
|
}
|
for (Area area : areaList) {
|
if (siteMap.containsKey(area.getSiteId())) {
|
siteNode = siteMap.get(area.getSiteId());
|
areaNode = new CommonGenericTree<>();
|
areaNode.setKey(area.getId());
|
areaNode.setTitle(area.getName());
|
areaNode.setParentId(area.getSiteId());
|
areaNode.setIcon("");
|
areaNode.setType(2);
|
areaNode.setEntity(area);
|
siteNode.addChildren(areaNode);
|
areaMap.put(area.getId(), areaNode);
|
}
|
}
|
for (ProductionLine line : productionLineList) {
|
if (areaMap.containsKey(line.getAreaId())) {
|
areaNode = areaMap.get(line.getAreaId());
|
lineNode = new CommonGenericTree<>();
|
lineNode.setKey(line.getId());
|
lineNode.setTitle(line.getName());
|
lineNode.setParentId(line.getAreaId());
|
lineNode.setIcon("");
|
lineNode.setType(3);
|
lineNode.setEntity(line);
|
lineNode.setDisabled(true);
|
areaNode.addChildren(lineNode);
|
}
|
}
|
}
|
return list;
|
}
|
|
}
|