|
@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
+import org.jetbrains.annotations.NotNull;
|
|
|
import org.jsoup.Jsoup;
|
|
|
import org.jsoup.nodes.Document;
|
|
|
import org.jsoup.nodes.Element;
|
|
@@ -32,13 +33,16 @@ import org.springblade.manager.dto.WbsTreeContractDTO2;
|
|
|
import org.springblade.manager.entity.*;
|
|
|
import org.springblade.manager.excel.WbsExcelBatchUtil;
|
|
|
import org.springblade.manager.excel.WbsExcelUtil;
|
|
|
+import org.springblade.manager.feign.ContractClient;
|
|
|
import org.springblade.manager.mapper.ContractInfoMapper;
|
|
|
import org.springblade.manager.mapper.WbsTreeContractMapper;
|
|
|
import org.springblade.manager.mapper.WbsTreePrivateMapper;
|
|
|
import org.springblade.manager.service.IWbsTreeContractService;
|
|
|
import org.springblade.manager.vo.*;
|
|
|
import org.springblade.system.cache.ParamCache;
|
|
|
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
+import org.springframework.jdbc.core.RowMapper;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.LinkedCaseInsensitiveMap;
|
|
@@ -49,11 +53,14 @@ import java.io.FileInputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.math.BigInteger;
|
|
|
+import java.sql.ResultSet;
|
|
|
+import java.sql.SQLException;
|
|
|
import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
@@ -64,6 +71,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
private final ContractInfoMapper contractInfoMapper;
|
|
|
private final JdbcTemplate jdbcTemplate;
|
|
|
private final InformationQueryClient informationQueryClient;
|
|
|
+ private final ContractClient contractClient;
|
|
|
|
|
|
@Override
|
|
|
public List<WbsTreeContract> selectQueryCurrentNodeByAncestors(List<String> ids, String contractId) {
|
|
@@ -548,6 +556,313 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
baseMapper.syncCurrentFormToAllContract(wbsTreePrivate);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<WbsTreeContractLazyVO> lazyQueryContractWbsTree(String id, String contractId, String contractIdRelation) {
|
|
|
+ if (ObjectUtil.isNotEmpty(contractId)) {
|
|
|
+ //获取当前合同段名称
|
|
|
+ ContractInfo contractInfo = jdbcTemplate.query("select contract_name,contract_type from m_contract_info where id = " + contractId, new BeanPropertyRowMapper<>(ContractInfo.class)).stream().findAny().orElse(null);
|
|
|
+ if (contractInfo != null) {
|
|
|
+ //施工合同段
|
|
|
+ if (new Integer(1).equals(contractInfo.getContractType())) {
|
|
|
+ //获取当前层懒加载节点
|
|
|
+ List<WbsTreeContractLazyVO> lazyNodes = jdbcTemplate.query("select a.*,CASE (SELECT count(1) FROM u_tree_contract_first AS tcf WHERE tcf.is_deleted = 0 AND tcf.wbs_node_id = a.p_key_id) WHEN 0 THEN 'false' ELSE 'true' END AS isFirst,IFNULL(if(length(trim(full_name))>0,full_name,node_name),node_name) AS title,(SELECT CASE WHEN count(1) > 0 THEN 1 ELSE 0 END FROM m_wbs_tree_contract b WHERE b.parent_id = a.id AND b.type = 1 and b.status = 1 AND b.contract_id = " + contractId + " AND b.is_deleted = 0 ) AS hasChildren from m_wbs_tree_contract a where a.type = 1 and a.status = 1 and a.is_deleted = 0 and parent_id = " + (StringUtils.isNotEmpty(id) ? id : 0) + " and contract_id = " + contractId, new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
|
|
|
+ if (lazyNodes.size() > 0) {
|
|
|
+ //所有最底层节点
|
|
|
+ List<WbsTreeContractLazyVO> lowestNodesAll = jdbcTemplate.query("select a.p_key_id,a.id,a.parent_id,(SELECT CASE WHEN count(1) > 0 THEN 1 ELSE 0 END FROM m_wbs_tree_contract b WHERE b.parent_id = a.id AND type = 1 AND b.contract_id = " + contractId + " AND b.is_deleted = 0 ) AS hasChildren from m_wbs_tree_contract a where type = 1 and status = 1 and is_deleted = 0 and contract_id = " + contractId + " HAVING hasChildren = 0", new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
|
|
|
+
|
|
|
+ //获取当前合同段所有填报资料信息
|
|
|
+ List<WbsTreeContractLazyQueryInfoVO> queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where type = 1 and contract_id = " + contractId, new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class));
|
|
|
+ Map<Long, Integer> queryInfoMaps = queryInfoList.stream().distinct().collect(Collectors.toMap(WbsTreeContractLazyQueryInfoVO::getWbsId, WbsTreeContractLazyQueryInfoVO::getStatus));
|
|
|
+ List<Long> pKeyIdList = new ArrayList<>(queryInfoMaps.keySet());
|
|
|
+
|
|
|
+ //填报过的所有最底层节点
|
|
|
+ List<WbsTreeContractLazyVO> lowestNodesTB = lowestNodesAll.stream().filter(f -> pKeyIdList.contains(f.getPKeyId())).collect(Collectors.toList());
|
|
|
+ List<Long> lowestNodeParentIdsTB = lowestNodesTB.stream().map(WbsTreeContractLazyVO::getParentId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //获取所有填报过的父级节点,处理数量
|
|
|
+ List<WbsTreeContractLazyVO> resultParentNodes = new ArrayList<>();
|
|
|
+ this.recursiveGetParentNodes(resultParentNodes, lowestNodeParentIdsTB, contractId);
|
|
|
+
|
|
|
+ //所有节点Map
|
|
|
+ List<WbsTreeContractLazyVO> distinctResultParentNodes = resultParentNodes.stream().distinct().collect(Collectors.toList());
|
|
|
+ Map<Long, WbsTreeContractLazyVO> nodeMap = new HashMap<>();
|
|
|
+ for (WbsTreeContractLazyVO node : distinctResultParentNodes) {
|
|
|
+ nodeMap.put(node.getId(), node);
|
|
|
+ }
|
|
|
+
|
|
|
+ //最底层节点Map
|
|
|
+ Map<Long, WbsTreeContractLazyVO> lowestNodesMap = lowestNodesAll.stream()
|
|
|
+ .peek(vo -> {
|
|
|
+ Integer colorStatus = queryInfoMaps.get(vo.getPKeyId());
|
|
|
+ if (colorStatus != null) {
|
|
|
+ //任务状态0=未上报=颜色2蓝色、任务状态1=待审批=颜色3橙色、任务状态2=已审批=颜色4绿色、任务状态3=已废除=颜色1黑色
|
|
|
+ vo.setColorStatus(colorStatus == 0 ? 2 : (colorStatus == 1 ? 3 : (colorStatus == 2 ? 4 : 1)));
|
|
|
+ } else {
|
|
|
+ //未填报的=颜色1黑色
|
|
|
+ vo.setColorStatus(1);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .collect(Collectors.toMap(WbsTreeContractLazyVO::getPKeyId, Function.identity(), (obj1, obj2) -> obj1));
|
|
|
+
|
|
|
+ //构造完成的所有最底层节点,处理父节点颜色
|
|
|
+ this.recursiveParentNodeColorStatus(lowestNodesAll, nodeMap);
|
|
|
+
|
|
|
+ //处理最终结果集
|
|
|
+ if (lowestNodesAll.size() > 0) {
|
|
|
+ //处理填报数量
|
|
|
+ Map<Long, Integer> countMap = new HashMap<>();
|
|
|
+ for (WbsTreeContractLazyVO node : resultParentNodes) {
|
|
|
+ Long key = node.getPKeyId();
|
|
|
+ if (countMap.containsKey(key)) {
|
|
|
+ countMap.put(key, countMap.get(key) + 1);
|
|
|
+ } else {
|
|
|
+ countMap.put(key, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //返回最终结果集
|
|
|
+ for (WbsTreeContractLazyVO lazyNodeVO : lazyNodes) {
|
|
|
+ lazyNodeVO.setNotExsitChild(!lazyNodeVO.getHasChildren().equals(1));
|
|
|
+ lazyNodeVO.setPrimaryKeyId(lazyNodeVO.getPKeyId());
|
|
|
+ if (lazyNodeVO.getParentId() == 0L) {
|
|
|
+ if (ObjectUtil.isNotEmpty(contractInfo.getContractName())) {
|
|
|
+ lazyNodeVO.setTitle(contractInfo.getContractName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ lazyNodeVO.setSubmitCounts(ObjectUtil.isNotEmpty(countMap.get(lazyNodeVO.getPKeyId())) ? countMap.get(lazyNodeVO.getPKeyId()) : (ObjectUtil.isNotEmpty(queryInfoMaps.get(lazyNodeVO.getPKeyId())) ? 1 : 0));
|
|
|
+
|
|
|
+ WbsTreeContractLazyVO vo = nodeMap.get(lazyNodeVO.getId());
|
|
|
+ if (vo != null) {
|
|
|
+ lazyNodeVO.setColorStatus(ObjectUtil.isNotEmpty(vo.getColorStatus()) ? vo.getColorStatus() : 1);
|
|
|
+ } else {
|
|
|
+ WbsTreeContractLazyVO lowestNode = lowestNodesMap.get(lazyNodeVO.getPKeyId());
|
|
|
+ lazyNodeVO.setColorStatus(ObjectUtil.isNotEmpty(lowestNode) ? lowestNode.getColorStatus() : 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return lazyNodes;
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if (new Integer("2").equals(contractInfo.getContractType()) || new Integer("3").equals(contractInfo.getContractType())) {
|
|
|
+ List<WbsTreeContractLazyVO> lazyNodesAll = new ArrayList<>();
|
|
|
+ //监理、总监办合同段
|
|
|
+ List<String> contractIds = new ArrayList<>();
|
|
|
+ if (ObjectUtil.isNotEmpty(contractIdRelation) && ObjectUtil.isNotEmpty(id)) {
|
|
|
+ //非根节点时选择加载施工合同段的树
|
|
|
+ contractIds.add(contractIdRelation);
|
|
|
+ } else {
|
|
|
+ //根节点时默认加载所有施工合同段的树
|
|
|
+ contractIds = this.contractClient.getProcessContractByJLContractId(contractId);
|
|
|
+ }
|
|
|
+ for (String sgContractId : contractIds) {
|
|
|
+ ContractInfo sgContractInfo = jdbcTemplate.query("select contract_name from m_contract_info where id = " + sgContractId, new BeanPropertyRowMapper<>(ContractInfo.class)).stream().findAny().orElse(null);
|
|
|
+ if (sgContractInfo != null) {
|
|
|
+ //获取当前层懒加载节点
|
|
|
+ List<WbsTreeContractLazyVO> lazyNodes = jdbcTemplate.query("select a.*,CASE (SELECT count(1) FROM u_tree_contract_first AS tcf WHERE tcf.is_deleted = 0 AND tcf.wbs_node_id = a.p_key_id) WHEN 0 THEN 'false' ELSE 'true' END AS isFirst,IFNULL(if(length(trim(full_name))>0,full_name,node_name),node_name) AS title,(SELECT CASE WHEN count(1) > 0 THEN 1 ELSE 0 END FROM m_wbs_tree_contract b WHERE b.parent_id = a.id AND b.type = 1 and b.status = 1 AND b.contract_id = " + sgContractId + " AND b.is_deleted = 0 ) AS hasChildren from m_wbs_tree_contract a where a.type = 1 and a.status = 1 and a.is_deleted = 0 and parent_id = " + (StringUtils.isNotEmpty(id) ? id : 0) + " and contract_id = " + sgContractId, new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
|
|
|
+
|
|
|
+ if (lazyNodes.size() > 0) {
|
|
|
+ //所有最底层节点
|
|
|
+ List<WbsTreeContractLazyVO> lowestNodesAll = jdbcTemplate.query("select a.p_key_id,a.id,a.parent_id,(SELECT CASE WHEN count(1) > 0 THEN 1 ELSE 0 END FROM m_wbs_tree_contract b WHERE b.parent_id = a.id AND type = 1 AND b.contract_id = " + sgContractId + " AND b.is_deleted = 0 ) AS hasChildren from m_wbs_tree_contract a where type = 1 and status = 1 and is_deleted = 0 and contract_id = " + sgContractId + " HAVING hasChildren = 0", new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
|
|
|
+
|
|
|
+ //获取当前合同段所有填报资料信息
|
|
|
+ List<WbsTreeContractLazyQueryInfoVO> queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where type = 1 and contract_id = " + sgContractId, new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class));
|
|
|
+ Map<Long, Integer> queryInfoMaps = queryInfoList.stream().distinct().collect(Collectors.toMap(WbsTreeContractLazyQueryInfoVO::getWbsId, WbsTreeContractLazyQueryInfoVO::getStatus));
|
|
|
+ List<Long> pKeyIdList = new ArrayList<>(queryInfoMaps.keySet());
|
|
|
+
|
|
|
+ //填报过的所有最底层节点
|
|
|
+ List<WbsTreeContractLazyVO> lowestNodesTB = lowestNodesAll.stream().filter(f -> pKeyIdList.contains(f.getPKeyId())).collect(Collectors.toList());
|
|
|
+ List<Long> lowestNodeParentIdsTB = lowestNodesTB.stream().map(WbsTreeContractLazyVO::getParentId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //获取所有填报过的父级节点,处理数量
|
|
|
+ List<WbsTreeContractLazyVO> resultParentNodes = new ArrayList<>();
|
|
|
+ this.recursiveGetParentNodes(resultParentNodes, lowestNodeParentIdsTB, sgContractId);
|
|
|
+
|
|
|
+ //所有节点Map
|
|
|
+ List<WbsTreeContractLazyVO> distinctResultParentNodes = resultParentNodes.stream().distinct().collect(Collectors.toList());
|
|
|
+ Map<Long, WbsTreeContractLazyVO> nodeMap = new HashMap<>();
|
|
|
+ for (WbsTreeContractLazyVO node : distinctResultParentNodes) {
|
|
|
+ nodeMap.put(node.getId(), node);
|
|
|
+ }
|
|
|
+
|
|
|
+ //最底层节点Map
|
|
|
+ Map<Long, WbsTreeContractLazyVO> lowestNodesMap = lowestNodesAll.stream()
|
|
|
+ .peek(vo -> {
|
|
|
+ Integer colorStatus = queryInfoMaps.get(vo.getPKeyId());
|
|
|
+ if (colorStatus != null) {
|
|
|
+ //任务状态0=未上报=颜色2蓝色、任务状态1=待审批=颜色3橙色、任务状态2=已审批=颜色4绿色、任务状态3=已废除=颜色1黑色
|
|
|
+ vo.setColorStatus(colorStatus == 0 ? 2 : (colorStatus == 1 ? 3 : (colorStatus == 2 ? 4 : 1)));
|
|
|
+ } else {
|
|
|
+ //未填报的=颜色1黑色
|
|
|
+ vo.setColorStatus(1);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .collect(Collectors.toMap(WbsTreeContractLazyVO::getPKeyId, Function.identity(), (obj1, obj2) -> obj1));
|
|
|
+
|
|
|
+ //构造完成的所有最底层节点,处理父节点颜色
|
|
|
+ this.recursiveParentNodeColorStatus(lowestNodesAll, nodeMap);
|
|
|
+
|
|
|
+ //处理最终结果集
|
|
|
+ if (lowestNodesAll.size() > 0) {
|
|
|
+ //处理填报数量
|
|
|
+ Map<Long, Integer> countMap = new HashMap<>();
|
|
|
+ for (WbsTreeContractLazyVO node : resultParentNodes) {
|
|
|
+ Long key = node.getPKeyId();
|
|
|
+ if (countMap.containsKey(key)) {
|
|
|
+ countMap.put(key, countMap.get(key) + 1);
|
|
|
+ } else {
|
|
|
+ countMap.put(key, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //返回最终结果集
|
|
|
+ for (WbsTreeContractLazyVO lazyNodeVO : lazyNodes) {
|
|
|
+ lazyNodeVO.setNotExsitChild(!lazyNodeVO.getHasChildren().equals(1));
|
|
|
+ lazyNodeVO.setPrimaryKeyId(lazyNodeVO.getPKeyId());
|
|
|
+ lazyNodeVO.setContractIdRelation(sgContractId);
|
|
|
+ if (lazyNodeVO.getParentId() == 0L) {
|
|
|
+ if (ObjectUtil.isNotEmpty(sgContractInfo.getContractName())) {
|
|
|
+ lazyNodeVO.setTitle(sgContractInfo.getContractName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ lazyNodeVO.setSubmitCounts(ObjectUtil.isNotEmpty(countMap.get(lazyNodeVO.getPKeyId())) ? countMap.get(lazyNodeVO.getPKeyId()) : (ObjectUtil.isNotEmpty(queryInfoMaps.get(lazyNodeVO.getPKeyId())) ? queryInfoMaps.get(lazyNodeVO.getPKeyId()) : 0));
|
|
|
+
|
|
|
+ WbsTreeContractLazyVO vo = nodeMap.get(lazyNodeVO.getId());
|
|
|
+ if (vo != null) {
|
|
|
+ lazyNodeVO.setColorStatus(ObjectUtil.isNotEmpty(vo.getColorStatus()) ? vo.getColorStatus() : 1);
|
|
|
+ } else {
|
|
|
+ WbsTreeContractLazyVO lowestNode = lowestNodesMap.get(lazyNodeVO.getPKeyId());
|
|
|
+ lazyNodeVO.setColorStatus(ObjectUtil.isNotEmpty(lowestNode) ? lowestNode.getColorStatus() : 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ lazyNodesAll.addAll(lazyNodes);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return lazyNodesAll;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 反向递归获取父级(父级Id=子级parentId)
|
|
|
+ *
|
|
|
+ * @param result 结果集
|
|
|
+ * @param lowestNodeParentIds 最底层节点ParentIds
|
|
|
+ * @param contractId 施工合同段id
|
|
|
+ */
|
|
|
+ private void recursiveGetParentNodes(List<WbsTreeContractLazyVO> result, List<Long> lowestNodeParentIds, String contractId) {
|
|
|
+ if (lowestNodeParentIds.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ //父级Id与出现的次数Map
|
|
|
+ Map<Long, Long> parentIdGroup = lowestNodeParentIds.stream()
|
|
|
+ .collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
|
|
|
+
|
|
|
+ List<String> keysWithValueOne = new ArrayList<>();
|
|
|
+ Map<Long, Long> keysWithValueSome = new HashMap<>();
|
|
|
+
|
|
|
+ for (Map.Entry<Long, Long> entry : parentIdGroup.entrySet()) {
|
|
|
+ if (entry.getValue() == 1L) {
|
|
|
+ keysWithValueOne.add(entry.getKey().toString());
|
|
|
+ } else {
|
|
|
+ keysWithValueSome.put(entry.getKey(), entry.getValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //批量查询单次节点
|
|
|
+ List<WbsTreeContractLazyVO> parentNodes = new ArrayList<>();
|
|
|
+ if (keysWithValueOne.size() > 0) {
|
|
|
+ parentNodes = jdbcTemplate.query("select p_key_id,id,parent_id from m_wbs_tree_contract where is_deleted = 0 and status = 1 and type = 1 and id in (" + StringUtils.join(keysWithValueOne, ",") + ") and contract_id = " + contractId, new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ //批量查询多次节点
|
|
|
+ List<WbsTreeContractLazyVO> multipleParentNodes = new ArrayList<>();
|
|
|
+ for (Map.Entry<Long, Long> entry : keysWithValueSome.entrySet()) {
|
|
|
+ Long key = entry.getKey();
|
|
|
+ Long count = entry.getValue();
|
|
|
+
|
|
|
+ List<WbsTreeContractLazyVO> nodes = jdbcTemplate.query("select p_key_id,id,parent_id from m_wbs_tree_contract where is_deleted = 0 and status = 1 and type = 1 and id = " + key + " and contract_id = " + contractId, new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
|
|
|
+ if (!nodes.isEmpty()) {
|
|
|
+ multipleParentNodes.addAll(Collections.nCopies(count.intValue(), nodes.get(0)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //结果集
|
|
|
+ List<Long> collect = Stream.concat(parentNodes.stream(), multipleParentNodes.stream())
|
|
|
+ .map(WbsTreeContractLazyVO::getParentId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ if (!collect.isEmpty()) {
|
|
|
+ result.addAll(parentNodes);
|
|
|
+ result.addAll(multipleParentNodes);
|
|
|
+ this.recursiveGetParentNodes(result, collect, contractId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 反向递归处理父节点颜色
|
|
|
+ *
|
|
|
+ * @param childNodeList 子级节点List
|
|
|
+ * @param nodeMap 所有节点Map
|
|
|
+ */
|
|
|
+ private void recursiveParentNodeColorStatus(List<WbsTreeContractLazyVO> childNodeList, Map<Long, WbsTreeContractLazyVO> nodeMap) {
|
|
|
+ if (childNodeList.size() > 0) {
|
|
|
+ List<WbsTreeContractLazyVO> parentNodeList = new ArrayList<>();
|
|
|
+ Map<Long, List<WbsTreeContractLazyVO>> lowestNodesParentGroup = childNodeList.stream().collect(Collectors.groupingBy(WbsTreeContractLazyVO::getParentId));
|
|
|
+ for (Map.Entry<Long, List<WbsTreeContractLazyVO>> oneParentGroups : lowestNodesParentGroup.entrySet()) {
|
|
|
+ Long parentId = oneParentGroups.getKey(); //父节点id
|
|
|
+ List<WbsTreeContractLazyVO> oneLevel = oneParentGroups.getValue(); //子节点分组
|
|
|
+ if (parentId != null && oneLevel.size() > 0) {
|
|
|
+ WbsTreeContractLazyVO parentNode = nodeMap.get(parentId); //获取父节点
|
|
|
+ if (parentNode != null) {
|
|
|
+ boolean allThree = true; //是否所有子节点的getColorStatus都等于3
|
|
|
+ boolean allFour = true; //是否所有子节点的getColorStatus都等于4
|
|
|
+ boolean hasTwo = false; //是否存在子节点的getColorStatus等于2
|
|
|
+ boolean hasOne = false; //是否存在子节点的getColorStatus等于1
|
|
|
+ boolean hasThreeOrFour = false; //是否存在子节点的getColorStatus等于3或4
|
|
|
+ for (WbsTreeContractLazyVO node : oneLevel) {
|
|
|
+ if (node.getColorStatus() != 3) {
|
|
|
+ allThree = false;
|
|
|
+ }
|
|
|
+ if (node.getColorStatus() != 4) {
|
|
|
+ allFour = false;
|
|
|
+ }
|
|
|
+ if (node.getColorStatus() == 2) {
|
|
|
+ hasTwo = true;
|
|
|
+ }
|
|
|
+ if (node.getColorStatus() == 1) {
|
|
|
+ hasOne = true;
|
|
|
+ }
|
|
|
+ if (node.getColorStatus() == 3 || node.getColorStatus() == 4) {
|
|
|
+ hasThreeOrFour = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (allThree) {
|
|
|
+ parentNode.setColorStatus(3);
|
|
|
+ } else if (allFour) {
|
|
|
+ parentNode.setColorStatus(4);
|
|
|
+ } else if (hasTwo || (hasOne && hasThreeOrFour)) {
|
|
|
+ parentNode.setColorStatus(2);
|
|
|
+ } else {
|
|
|
+ parentNode.setColorStatus(1);
|
|
|
+ }
|
|
|
+ parentNodeList.add(parentNode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (parentNodeList.size() > 0) { //递归处理父级颜色,当前父级作为下次循环子级
|
|
|
+ this.recursiveParentNodeColorStatus(parentNodeList, nodeMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public boolean syncTabData(String pKeyId) throws Exception {
|
|
|
WbsTreeContract node = baseMapper.selectOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId, pKeyId));
|