|
@@ -1,5 +1,7 @@
|
|
|
package com.fdkankan.sale.service.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.fdkankan.sale.entity.Dict;
|
|
|
import com.fdkankan.sale.entity.Fault;
|
|
|
import com.fdkankan.sale.mapper.IFaultMapper;
|
|
|
import com.fdkankan.sale.service.IFaultService;
|
|
@@ -7,6 +9,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -23,4 +26,31 @@ public class FaultServiceImpl extends ServiceImpl<IFaultMapper, Fault> implement
|
|
|
public List<Fault> getByRepairId(String repairId) {
|
|
|
return this.getBaseMapper().getByRepairId(repairId);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object getTree() {
|
|
|
+ LambdaQueryWrapper<Fault> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(Fault::getVersion,"2.0");
|
|
|
+ List<Fault> list = this.list(wrapper);
|
|
|
+ if(list.isEmpty()){
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+ List<Fault> parent = list.stream().filter(e -> e.getParentId() == null).collect(Collectors.toList());
|
|
|
+ if(list.size() == parent.size()){
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ return getVoList(parent,list);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<Fault> getVoList (List<Fault> oneList,List<Fault> allList){
|
|
|
+ for (Fault dict : oneList) {
|
|
|
+ List<Fault> twoList = allList.stream().filter(e -> e.getParentId() !=null && e.getParentId().equals(dict.getFaultId())).collect(Collectors.toList());
|
|
|
+ if(!twoList.isEmpty()){
|
|
|
+ dict.setChildren(getVoList(twoList,allList));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return oneList;
|
|
|
+ }
|
|
|
}
|