自动化立体仓库 - WMS系统
#
zjj
2024-08-31 1f1c652c027fd86407d33640e2ac5e91d6a776b6
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
package com.zy.common.task;
 
import com.core.common.AesUtils;
import com.core.common.Cools;
import com.core.common.DateUtils;
import com.zy.common.properties.OSinfo;
import com.zy.common.properties.SystemProperties;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
 
import javax.annotation.PostConstruct;
import java.util.Date;
 
/**
 * 系统激活任务
 */
@Component
public class ActivateScheduler {
 
//    @Scheduled(cron = "0/1 * 8 * * ? ") // 每天8点
//    @Scheduled(cron = "* 0/1 * * * ? ") // 每分钟
//    @PostConstruct
    private void execute(){
        // 获取激活码
        String activationCode = SystemProperties.getActivationCode(OSinfo.getOSname().getActivationCodePath());
        if (!Cools.isEmpty(activationCode)) {
            // 获取有效期
            String timeStr = AesUtils.decrypt(activationCode, SystemProperties.SALT);
            if (null == timeStr) {
                SystemProperties.SYSTEM_ACTIVATION = Boolean.FALSE;
                return;
            }
            Date exprTime = DateUtils.convert(timeStr, DateUtils.yyyyMMddHHmmss);
            if (new Date().getTime() < exprTime.getTime()) {
                SystemProperties.SYSTEM_ACTIVATION = Boolean.TRUE;
            } else {
                SystemProperties.SYSTEM_ACTIVATION = Boolean.FALSE;
            }
        } else {
            SystemProperties.SYSTEM_ACTIVATION = Boolean.FALSE;
        }
    }
 
}