package com.chinaztt.mes.aps.core.helper;
|
|
import com.chinaztt.mes.aps.core.domain.Task;
|
|
|
/**
|
* 约束helper
|
*
|
* @Author: zhangxy
|
* @Date: 2020-10-23 15:18
|
*/
|
public class ApsConstraintHelper {
|
|
/**
|
* 任务时间是否重合
|
*
|
* @param t1
|
* @param t2
|
* @return
|
*/
|
public static boolean taskOverlap(Task t1, Task t2) {
|
if (t1 == null || t2 == null) {
|
return false;
|
}
|
if (t1.equals(t2)) {
|
return false;
|
}
|
if (t1.getResourceBo().equals(t2.getResourceBo())) {
|
//同一资源下不能重合
|
if (t1.getPlanStartTime().compareTo(t2.getPlanEndTime()) >= 0 || t1.getPlanEndTime().compareTo(t2.getPlanStartTime()) <= 0) {
|
return false;
|
}
|
|
} else if (t1.getOrderId().equals(t2.getOrderId())) {
|
//同一订单工艺下不能重合
|
if (t1.getOperationPriority() < t2.getOperationPriority()) {
|
if (t1.getPlanEndTime().compareTo(t2.getPlanStartTime()) > 0) {
|
return true;
|
}
|
}
|
if (t2.getOperationPriority() < t1.getOperationPriority()) {
|
if (t2.getPlanEndTime().compareTo(t1.getPlanStartTime()) > 0) {
|
return true;
|
}
|
}
|
|
}
|
return false;
|
}
|
|
|
}
|