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();
|
}
|
|
}
|
|
}
|