| | |
| | | import org.springblade.mdm.machinefile.service.MachineFileService; |
| | | import org.springblade.mdm.program.service.ProgramAnnotationService; |
| | | import org.springblade.system.feign.ISysClient; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.scheduling.annotation.EnableAsync; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.nio.file.Path; |
| | |
| | | @Slf4j |
| | | @AllArgsConstructor |
| | | @Component |
| | | @EnableAsync |
| | | public class InitBean { |
| | | private final DirectorLockService directorLockService; |
| | | private final DynamicDirectoryWatcher directoryWatcher; |
| | |
| | | private final ParamService paramService; |
| | | private final ProgramAnnotationService annotationService; |
| | | private final MachineFileScanService machineFileScanService; |
| | | private final ISysClient sysClient; |
| | | private final TaskDispatchService taskDispatchService; |
| | | @PostConstruct |
| | | public void init() { |
| | | log.info("应用启动时执行初始化操作 @PostConstruct"); |
| | | String networkType = paramService.networkType(); |
| | | if(!ParamService.NETWORK_TYPE_SHEMI.equals(networkType)) { |
| | | machineFileScanService.scanMachineFile();//启动执行一次扫描 |
| | | machineFileScanService.scanMachineFile(); |
| | | |
| | | //工控网才启动文件监控 |
| | | log.info("工控网启动文件监控"); |
| | | initMachineDirMonitor(); |
| | |
| | | addToWatchDirList(monitorInfoList,m); |
| | | }); |
| | | for (WatchInfo info : monitorInfoList) { |
| | | Path dirPath = Paths.get(info.getPath()); |
| | | try { |
| | | Path dirPath = Paths.get(info.getPath()); |
| | | if(!dirPath.toFile().exists()) { |
| | | dirPath.toFile().mkdirs(); |
| | | } |