Fixiaobai
2023-11-17 2fb28b36f15de26249ae34160e1accf118c011c7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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;
    }
 
 
}