yangys
2025-09-17 1e2b04fabbbc4b1ae37d7951068d7ab235f5b5f9
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
package org.springblade.mdm.task;
 
import lombok.extern.slf4j.Slf4j;
import org.springblade.mdm.basesetting.machine.service.MachineService;
import org.springblade.mdm.commons.service.ParamService;
import org.springblade.mdm.machinefile.service.MachineFileScanService;
import org.springblade.mdm.machinefile.service.MachineFileService;
import org.springblade.mdm.program.service.ProgramAnnotationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.io.IOException;
 
@Slf4j
@Component
@EnableScheduling
public class MachineFileScanTask {
    @Autowired
    private MachineFileService machineFileService;
    @Autowired
    private MachineService machineService;
    @Autowired
    private ParamService paramService;
    @Autowired
    private ProgramAnnotationService programAnnotationService;
    @Autowired
    private MachineFileScanService machineFileScanService;
    // 每5秒执行一次
    //@Scheduled(fixedRate = 1000000)
    //@Scheduled(cron = "0 1 0 * * ?") // 每天上午0点1分执行
    //@Scheduled(cron = "0 */5 * * * ?")
    //@Scheduled(cron = "0 15 19 * * ?") //test
    @Scheduled(cron = "${task.cron.machine_file_scan:0 1 0 * * ?}")
    public void execute() {
        String networkType = paramService.getParamValue(ParamService.NETWORK_TYPE,ParamService.NETWORK_TYPE_SHEMI);
 
        if(!ParamService.NETWORK_TYPE_SHEMI.equals(networkType)){
            //非涉密网,才扫描目录文件
            machineFileScanService.scanMachineFile();
        }
 
    }
 
}