|
@@ -105,6 +105,13 @@ public class WrapperUtil {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * 检查对象是否有值
|
|
|
|
+ */
|
|
|
|
+ public static <T> void checkObj(T obj, String errMsg) {
|
|
|
|
+ Optional.ofNullable(obj).orElseThrow(() -> new BizException(errMsg));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
* 全部有值则为true
|
|
* 全部有值则为true
|
|
*
|
|
*
|
|
* @param obj 多个对象
|
|
* @param obj 多个对象
|
|
@@ -187,4 +194,45 @@ public class WrapperUtil {
|
|
.orElse(new HashMap<String, Object>());
|
|
.orElse(new HashMap<String, Object>());
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 判断2个时间段是否有交集-默认允许结束时间和开始时间相等
|
|
|
|
+ *
|
|
|
|
+ * @param startDateOne 第一个时间段的开始时间
|
|
|
|
+ * @param endDateOne 第一个时间段的结束时间
|
|
|
|
+ * @param startDateTwo 第二个时间段的开始时间
|
|
|
|
+ * @param endDateTwo 第二个时间段的结束时间
|
|
|
|
+ * @return 有交集 true 无交集 false
|
|
|
|
+ */
|
|
|
|
+ public static Boolean inInterSection(Date startDateOne, Date endDateOne, Date startDateTwo, Date endDateTwo) {
|
|
|
|
+ return inInterSection(startDateOne, endDateOne, startDateTwo, endDateTwo, true);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 判断2个时间段是否有交集
|
|
|
|
+ *
|
|
|
|
+ * @param startDateOne 第一个时间段的开始时间
|
|
|
|
+ * @param endDateOne 第一个时间段的结束时间
|
|
|
|
+ * @param startDateTwo 第二个时间段的开始时间
|
|
|
|
+ * @param endDateTwo 第二个时间段的结束时间
|
|
|
|
+ * @param eq 是否允许结束时间和开始时间相等 true 允许
|
|
|
|
+ * @return 有交集 true 无交集 false
|
|
|
|
+ */
|
|
|
|
+ public static Boolean inInterSection(Date startDateOne, Date endDateOne, Date startDateTwo, Date endDateTwo, boolean eq) {
|
|
|
|
+ Date maxStartDate = startDateOne;
|
|
|
|
+ if (maxStartDate.before(startDateTwo)) {
|
|
|
|
+ maxStartDate = startDateTwo;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Date minEndDate = endDateOne;
|
|
|
|
+ if (endDateTwo.before(minEndDate)) {
|
|
|
|
+ minEndDate = endDateTwo;
|
|
|
|
+ }
|
|
|
|
+ //是否允许结束时间和开始时间相等 true 允许
|
|
|
|
+ if (eq) {
|
|
|
|
+ return maxStartDate.before(minEndDate);
|
|
|
|
+ } else {
|
|
|
|
+ return maxStartDate.before(minEndDate) || (maxStartDate.getTime() == minEndDate.getTime());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|