|
@@ -5,7 +5,9 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.Update;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.google.common.collect.Lists;
|
|
@@ -43,6 +45,7 @@ import org.springblade.manager.mapper.WbsTreeContractMapper;
|
|
|
import org.springblade.manager.mapper.WbsTreePrivateMapper;
|
|
|
import org.springblade.manager.service.ITableFileService;
|
|
|
import org.springblade.manager.service.IWbsTreeContractService;
|
|
|
+import org.springblade.manager.utils.CompositeKey;
|
|
|
import org.springblade.manager.vo.*;
|
|
|
import org.springblade.system.cache.ParamCache;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -1113,6 +1116,13 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
return baseMapper.getContractAllNode(contractId);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 递归获取隐蔽工程节点的所有父级节点
|
|
|
*
|
|
@@ -2590,4 +2600,62 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
}
|
|
|
System.out.println("66666666666");
|
|
|
}
|
|
|
+ public void diGuiWbs(int i) {
|
|
|
+ QueryWrapper<WbsTreeContract> wbsTreeContractQueryWrapper = new QueryWrapper<>();
|
|
|
+ wbsTreeContractQueryWrapper.select("p_key_id","id","p_id","wbs_id","contract_id","parent_id","ancestors");
|
|
|
+ wbsTreeContractQueryWrapper.eq("parent_id",0);
|
|
|
+ wbsTreeContractQueryWrapper.eq("is_deleted",0);
|
|
|
+ wbsTreeContractQueryWrapper.isNotNull("contract_id");
|
|
|
+ wbsTreeContractQueryWrapper.isNotNull("wbs_id");
|
|
|
+ List<WbsTreeContract> list = this.list(wbsTreeContractQueryWrapper);
|
|
|
+ if(!list.isEmpty()){
|
|
|
+ WbsTreeContract wbsTreeContract = list.get(i);
|
|
|
+ //通过parentID,contractID,wbsId分组,映射map
|
|
|
+ Map<CompositeKey, List<WbsTreeContract>> map = findAllContract(wbsTreeContract).stream()
|
|
|
+ .collect(Collectors.groupingBy(
|
|
|
+ item -> new CompositeKey(item.getParentId(),item.getContractId(),item.getWbsId())
|
|
|
+ ));
|
|
|
+ List<WbsTreeContract>updateList=new ArrayList<>();
|
|
|
+
|
|
|
+ //递归设置pid和ancestors
|
|
|
+ setPidAndAncestors(map,wbsTreeContract,updateList);
|
|
|
+ System.out.println("第"+i+"次递归:"+updateList.size());
|
|
|
+ for (WbsTreeContract contract : updateList) {
|
|
|
+ UpdateWrapper wrapper=new UpdateWrapper();
|
|
|
+ wrapper.set("p_id",contract.getPId());
|
|
|
+ wrapper.set("ancestors",contract.getAncestors());
|
|
|
+ wrapper.eq("p_key_id",contract.getPKeyId());
|
|
|
+ this.update(wrapper);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.out.println("第"+i+"次递归完成");
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ public List<WbsTreeContract> findAllContract(WbsTreeContract wbsTreeContract){
|
|
|
+ QueryWrapper<WbsTreeContract> wbsTreeContractQueryWrapper = new QueryWrapper<>();
|
|
|
+ wbsTreeContractQueryWrapper.select("p_key_id","id","p_id","wbs_id","contract_id","parent_id","ancestors");
|
|
|
+ wbsTreeContractQueryWrapper.eq("contract_id",wbsTreeContract.getContractId());
|
|
|
+ wbsTreeContractQueryWrapper.eq("wbs_id",wbsTreeContract.getWbsId());
|
|
|
+ return this.list(wbsTreeContractQueryWrapper);
|
|
|
+ }
|
|
|
+ public void setPidAndAncestors(Map<CompositeKey, List<WbsTreeContract>> map,WbsTreeContract wbsTreeContract,List<WbsTreeContract>updateList){
|
|
|
+ CompositeKey key = new CompositeKey(wbsTreeContract.getId(),wbsTreeContract.getContractId(),wbsTreeContract.getWbsId());
|
|
|
+ //拿到当前节点的子节点
|
|
|
+ List<WbsTreeContract> childrens = map.get(key);
|
|
|
+ if(ObjectUtil.isNotEmpty(childrens)){
|
|
|
+ for (WbsTreeContract children : childrens) {
|
|
|
+ if(children.getParentId().equals(wbsTreeContract.getId())){
|
|
|
+ //设置祖级节点和pid
|
|
|
+ String ancestors=wbsTreeContract.getAncestors()+",";
|
|
|
+ ancestors=ancestors+wbsTreeContract.getPKeyId();
|
|
|
+ children.setAncestors(ancestors);
|
|
|
+ children.setPId(wbsTreeContract.getPKeyId());
|
|
|
+ updateList.add(children);
|
|
|
+ //递归调用自己继续将一个合同段的子节点设置完
|
|
|
+ setPidAndAncestors(map,children,updateList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|