//package com.consum.base.util;
//
//import com.consum.model.po.PTempProjectStageNode;
//import com.walker.infrastructure.utils.CollectionUtils;
//
//import java.util.*;
//
///**
// * @ClassName RangeMergeUtil
// * @Author cy
// * @Date 2023/9/25
// * @Description
// * @Version 1.0
// **/
//public class RangeMergeUtil {
//
// /**
// * 根据节点中节点开始时间、持续时间,将节点转为link
// *
// * @param tempProjectStageNodes
// * @return
// */
// public static ArrayList tempNode2Link(List tempProjectStageNodes) {
// ArrayList links = new ArrayList<>();
// tempProjectStageNodes.forEach(item -> {
// Integer nodeTimeStart = item.getNodeTimeStart();
// Integer nodeTimeDays = item.getNodeTimeDays();
// if (nodeTimeStart != null && nodeTimeDays != null) {
// Link link = new Link(nodeTimeStart, nodeTimeStart + nodeTimeDays - 1);
// links.add(link);
// }
// });
// return links;
// }
//
// /**
// * 对给定区间进行合并
// *
// * @param info_dict
// * @return
// */
// public static ArrayList merge(ArrayList info_dict) {
// //首先对info_dict进行排序,排序规则为根据Link的left排序,如果left相等,根据right排序
// Collections.sort(info_dict, (o1, o2) -> {
// int a = o1.getLeft() - o2.getLeft();
// return a == 0 ? o1.getRight() - o2.getRight() : a;
// });
//
// //创建一个用于接受合并后结果的dict,同时设置一个类似滑动窗口一样的start和end
// ArrayList result_dict = new ArrayList<>();
// double start = -2e9, end = -2e9;
// for (Link i : info_dict) {
// //判断两种情况
// //第一种是当end小于i.getLeft()时,说明我们遇到了一个新的没有交集的区间
// //那么就将start和end移动过来,并且将它添加到result_dict中
// if (end + 1 < i.getLeft()) {
// if (start != -2e9) {
// result_dict.add(new Link((int) start, (int) end));
// }
// start = i.getLeft();
// end = i.getRight();
// }
// //第二种情况是当有交集时,如果在当前滑动区间内,不变,如果其right大于当前end,将滑动区间的end设置为right
// else {
// end = Math.max(end, i.getRight());
// }
// }
//
// //排空滑动区间
// if (start != -2e9) {
// result_dict.add(new Link((int) start, (int) end));
// }
// //返回result_dict中区间的个数
// return result_dict;
// }
//
// /**
// * 获取节点元素中的最值信息
// *
// * @param mergeList
// * @return
// */
// public static Map getMergeMaxMinInfo(ArrayList mergeList) {
// if (CollectionUtils.isEmpty(mergeList)) {
// return null;
// }
// int maxLeft = Integer.MIN_VALUE;
// int minLeft = Integer.MAX_VALUE;
// int maxRight = Integer.MIN_VALUE;
// int minRight = Integer.MAX_VALUE;
//
// for (Link link : mergeList) {
// int left = link.getLeft();
// int right = link.getRight();
// maxLeft = Math.max(maxLeft, left);
// minLeft = Math.min(minLeft, left);
// maxRight = Math.max(maxRight, right);
// minRight = Math.min(minRight, right);
// }
// HashMap rtnInfo = new HashMap<>();
// rtnInfo.put("maxLeft", maxLeft);
// rtnInfo.put("minLeft", minLeft);
// rtnInfo.put("maxRight", maxRight);
// rtnInfo.put("minRight", minRight);
// return rtnInfo;
// }
//
// /**
// * 校验是否有日期空档并返回区间最值信息
// * @param tempProjectStageNodes
// * @return
// */
// public static Map checkDateGap(List tempProjectStageNodes) {
// ArrayList info_dict = tempNode2Link(tempProjectStageNodes);
// ArrayList mergeList = merge(info_dict);
// if (mergeList.size() > 1) {
// return null;
// }
// return getMergeMaxMinInfo(mergeList);
// }
//
// /**
// * 校验是否有重叠
// * @param list
// * @return
// */
// public static Boolean checkOverlap(List