a
554325746@qq.com
2019-12-25 84e391f79e4c298e31b990667a54d991d645949f
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
package com.basic.security.manager;
 
import com.basic.security.model.ModelAdapter;
 
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
 
public class RebootManager extends BaseManager {
 
    static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH");
 
    static Set<String> systemRebooted = new HashSet<>();
 
    public static boolean needReboot() {
        if (!BaseSettingManager.rebootHourEnable()) {
            return false;
        }
        String timeNow = sdf.format(new Date());
        if (systemRebooted.contains(timeNow)) {
            return false;
        }
        String rebootTime = BaseSettingManager.getRebootTime();
        if (rebootTime.equals(timeNow)) {
            ModelAdapter log = LogManager.findByMessage("reboot:" + timeNow);
            if (log == null) {
                systemRebooted.add(timeNow);
                LogManager.saveLog("reboot:" + rebootTime);
                return true;
            }
        }
 
        return false;
    }
}