package org.jeecg.modules.eam.service.impl;
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
import org.jeecg.common.api.vo.CommonGenericTree;
|
import org.jeecg.modules.eam.entity.EquipmentCategory;
|
import org.jeecg.modules.eam.entity.FaultCause;
|
import org.jeecg.modules.eam.mapper.EquipmentCategoryMapper;
|
import org.jeecg.modules.eam.service.IEquipmentCategoryService;
|
import org.springframework.stereotype.Service;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* @Description: mom_eam_equipment_category
|
* @Author: jeecg-boot
|
* @Date: 2023-03-08
|
* @Version: V1.0
|
*/
|
@Service
|
public class EquipmentCategoryServiceImpl extends ServiceImpl<EquipmentCategoryMapper, EquipmentCategory> implements IEquipmentCategoryService {
|
|
@Override
|
public List<CommonGenericTree> loadTree() {
|
List<EquipmentCategory> equipmentCategoryList = this.lambdaQuery().eq(EquipmentCategory::getDelFlag, "0").list();
|
List<CommonGenericTree> commonGenericTrees = loadTree(equipmentCategoryList);
|
return commonGenericTrees;
|
}
|
|
@SuppressWarnings("unchecked")
|
public List<CommonGenericTree> loadTree(List<EquipmentCategory> EquipmentCategory) {
|
@SuppressWarnings("unused")
|
EquipmentCategory equipmentCategory = new EquipmentCategory();
|
List<CommonGenericTree> list = new ArrayList<>();
|
Map<String, CommonGenericTree> map = new HashMap<>();
|
Map<String, CommonGenericTree> map2 = new HashMap<>();
|
Map<String, CommonGenericTree> map3 = new HashMap<>();
|
Map<String, CommonGenericTree> map4 = new HashMap<>();
|
Map<String, CommonGenericTree> map5 = new HashMap<>();
|
Map<String, CommonGenericTree> map6 = new HashMap<>();
|
Map<String, CommonGenericTree> map7 = new HashMap<>();
|
CommonGenericTree<EquipmentCategory> node = new CommonGenericTree<>();
|
node.setKey("-1");
|
node.setValue("-1");
|
node.setTitle("设备分类");
|
node.setRField1("-1");
|
node.setRField2("设备分类");
|
node.setDisabled(false);
|
node.setEntity(new EquipmentCategory());
|
list.add(node);
|
if (CollectionUtils.isNotEmpty(list)) {
|
CommonGenericTree<EquipmentCategory> pcNode;
|
for (EquipmentCategory category : EquipmentCategory) {
|
if (category.getParentId().equals("-1")) {
|
pcNode = new CommonGenericTree<>();
|
pcNode.setKey(category.getId());
|
pcNode.setTitle(category.getNum() + "/" + category.getName());
|
pcNode.setParentId(node.getKey());
|
pcNode.setIcon("");
|
pcNode.setType(0);
|
pcNode.setValue(category.getId());
|
pcNode.setDisabled(false);
|
pcNode.setRField1(category.getNum());
|
pcNode.setRField2(category.getName());
|
pcNode.setEntity(category);
|
node.addChildren(pcNode);
|
map.put(category.getId(), pcNode);
|
}
|
}
|
CommonGenericTree<EquipmentCategory> childNode;
|
for (EquipmentCategory category : EquipmentCategory) {
|
if (map.containsKey(category.getParentId())) {
|
pcNode = map.get(category.getParentId());
|
childNode = new CommonGenericTree<>();
|
childNode.setKey(category.getId());
|
childNode.setTitle(category.getNum() + "/" + category.getName());
|
childNode.setParentId(category.getParentId());
|
childNode.setIcon("");
|
childNode.setType(0);
|
childNode.setValue(category.getId());
|
childNode.setDisabled(false);
|
childNode.setRField1(category.getNum());
|
childNode.setRField2(category.getName());
|
childNode.setEntity(category);
|
pcNode.addChildren(childNode);
|
map2.put(category.getId(), childNode);
|
}
|
}
|
if(map2.size()>0){
|
CommonGenericTree<EquipmentCategory> child2Node;
|
for (EquipmentCategory category : EquipmentCategory) {
|
if (map2.containsKey(category.getParentId())) {
|
pcNode = map2.get(category.getParentId());
|
child2Node = new CommonGenericTree<>();
|
child2Node.setKey(category.getId());
|
child2Node.setTitle(category.getNum() + "/" + category.getName());
|
child2Node.setParentId(category.getParentId());
|
child2Node.setIcon("");
|
child2Node.setType(0);
|
child2Node.setValue(category.getId());
|
child2Node.setDisabled(false);
|
child2Node.setRField1(category.getNum());
|
child2Node.setRField2(category.getName());
|
child2Node.setEntity(category);
|
pcNode.addChildren(child2Node);
|
map3.put(category.getId(), child2Node);
|
}
|
}
|
if(map3.size()>0){
|
CommonGenericTree<EquipmentCategory> child3Node;
|
for (EquipmentCategory category : EquipmentCategory) {
|
if (map3.containsKey(category.getParentId())) {
|
pcNode = map3.get(category.getParentId());
|
child3Node = new CommonGenericTree<>();
|
child3Node.setKey(category.getId());
|
child3Node.setTitle(category.getNum() + "/" + category.getName());
|
child3Node.setParentId(category.getParentId());
|
child3Node.setIcon("");
|
child3Node.setType(0);
|
child3Node.setValue(category.getId());
|
child3Node.setDisabled(false);
|
child3Node.setRField1(category.getNum());
|
child3Node.setRField2(category.getName());
|
child3Node.setEntity(category);
|
pcNode.addChildren(child3Node);
|
map4.put(category.getId(), child3Node);
|
}
|
}
|
if(map4.size()>0){
|
CommonGenericTree<EquipmentCategory> child4Node;
|
for (EquipmentCategory category : EquipmentCategory) {
|
if (map4.containsKey(category.getParentId())) {
|
pcNode = map4.get(category.getParentId());
|
child4Node = new CommonGenericTree<>();
|
child4Node.setKey(category.getId());
|
child4Node.setTitle(category.getNum() + "/" + category.getName());
|
child4Node.setParentId(category.getParentId());
|
child4Node.setIcon("");
|
child4Node.setType(0);
|
child4Node.setValue(category.getId());
|
child4Node.setDisabled(false);
|
child4Node.setRField1(category.getNum());
|
child4Node.setRField2(category.getName());
|
child4Node.setEntity(category);
|
pcNode.addChildren(child4Node);
|
map5.put(category.getId(), child4Node);
|
}
|
}
|
if(map5.size()>0){
|
CommonGenericTree<EquipmentCategory> child5Node;
|
for (EquipmentCategory category : EquipmentCategory) {
|
if (map5.containsKey(category.getParentId())) {
|
pcNode = map5.get(category.getParentId());
|
child5Node = new CommonGenericTree<>();
|
child5Node.setKey(category.getId());
|
child5Node.setTitle(category.getNum() + "/" + category.getName());
|
child5Node.setParentId(category.getParentId());
|
child5Node.setIcon("");
|
child5Node.setType(0);
|
child5Node.setValue(category.getId());
|
child5Node.setDisabled(false);
|
child5Node.setRField1(category.getNum());
|
child5Node.setRField2(category.getName());
|
child5Node.setEntity(category);
|
pcNode.addChildren(child5Node);
|
map6.put(category.getId(), child5Node);
|
}
|
}
|
if(map6.size()>0){
|
CommonGenericTree<EquipmentCategory> child6Node;
|
for (EquipmentCategory category : EquipmentCategory) {
|
if (map6.containsKey(category.getParentId())) {
|
pcNode = map6.get(category.getParentId());
|
child6Node = new CommonGenericTree<>();
|
child6Node.setKey(category.getId());
|
child6Node.setTitle(category.getNum() + "/" + category.getName());
|
child6Node.setParentId(category.getParentId());
|
child6Node.setIcon("");
|
child6Node.setType(0);
|
child6Node.setValue(category.getId());
|
child6Node.setDisabled(false);
|
child6Node.setRField1(category.getNum());
|
child6Node.setRField2(category.getName());
|
child6Node.setEntity(category);
|
pcNode.addChildren(child6Node);
|
map7.put(category.getId(), child6Node);
|
}
|
}
|
if(map7.size()>0){
|
CommonGenericTree<EquipmentCategory> child7Node;
|
for (EquipmentCategory category : EquipmentCategory) {
|
if (map.containsKey(category.getParentId())) {
|
pcNode = map7.get(category.getParentId());
|
child7Node = new CommonGenericTree<>();
|
child7Node.setKey(category.getId());
|
child7Node.setTitle(category.getNum() + "/" + category.getName());
|
child7Node.setParentId(category.getParentId());
|
child7Node.setIcon("");
|
child7Node.setType(0);
|
child7Node.setValue(category.getId());
|
child7Node.setDisabled(false);
|
child7Node.setRField1(category.getNum());
|
child7Node.setRField2(category.getName());
|
child7Node.setEntity(category);
|
// pcNode.addChildren(child7Node);
|
// map7.put(cause.getId(), child7Node);
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
return list;
|
}
|
}
|