| | |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springblade.mdm.basesetting.machine.service.MachineService; |
| | | import org.springblade.mdm.basesetting.machine.entity.Machine; |
| | | import org.springblade.mdm.commons.service.MachineDirTranslator; |
| | | import org.springblade.mdm.commons.service.ParamService; |
| | | import org.springblade.mdm.flow.service.TaskDispatchService; |
| | | import org.springblade.mdm.machinefile.entity.MachineFile; |
| | |
| | | private final ProgramAnnotationService annotationService; |
| | | private final MachineFileScanService machineFileScanService; |
| | | private final TaskDispatchService taskDispatchService; |
| | | |
| | | //@Value("${task.file_scan_on_start:true}") |
| | | //@Value("${task.fileScanOnStart:true}") |
| | | //public boolean fileScanOnStart; |
| | | private final MachineDirTranslator dirTranslator; |
| | | private final TaskPropertieBean taskPropertieBean; |
| | | @PostConstruct |
| | | public void init() { |
| | |
| | | log.info("工控网启动文件监控"); |
| | | initMachineDirMonitor(); |
| | | }else{ |
| | | |
| | | //涉密网 |
| | | taskDispatchService.resetDrawingNos(); |
| | | } |
| | |
| | | machineList.forEach(m -> { |
| | | addToWatchDirList(monitorInfoList,m); |
| | | }); |
| | | |
| | | for (WatchInfo info : monitorInfoList) { |
| | | try { |
| | | Path dirPath = Paths.get(info.getPath()); |
| | |
| | | String dir; |
| | | //加入send文件夹 |
| | | if (StringUtils.isNotEmpty(machine.getProgSendDir())) { |
| | | dir = StringUtils.removeEnd(StringUtils.removeEnd(machine.getProgSendDir(), "/"), "\\"); |
| | | //dir = dirTranslator.trans(StringUtils.removeEnd(StringUtils.removeEnd(machine.getProgSendDir(), "/"), "\\")); |
| | | dir = fixMachineDir(machine.getProgSendDir()); |
| | | WatchInfo watchInfo = new WatchInfo(); |
| | | watchInfo.setMachine(machine); |
| | | watchInfo.setDirType(MachineFile.DIR_TYPE_SEND); |
| | |
| | | |
| | | //加入rec文件夹 |
| | | if (StringUtils.isNotEmpty(machine.getProgReceiveDir())) { |
| | | dir = StringUtils.removeEnd(StringUtils.removeEnd(machine.getProgReceiveDir(), "/"), "\\"); |
| | | //dir = StringUtils.removeEnd(StringUtils.removeEnd(machine.getProgReceiveDir(), "/"), "\\"); |
| | | dir = fixMachineDir(machine.getProgReceiveDir()); |
| | | WatchInfo watchInfo = new WatchInfo(); |
| | | watchInfo.setMachine(machine); |
| | | watchInfo.setDirType(MachineFile.DIR_TYPE_REC); |
| | |
| | | |
| | | //加入temp文件夹 |
| | | if (StringUtils.isNotEmpty(machine.getProgTempDir())) { |
| | | dir = StringUtils.removeEnd(StringUtils.removeEnd(machine.getProgTempDir(), "/"), "\\"); |
| | | //dir = StringUtils.removeEnd(StringUtils.removeEnd(machine.getProgTempDir(), "/"), "\\"); |
| | | dir = fixMachineDir(machine.getProgTempDir()); |
| | | WatchInfo watchInfo = new WatchInfo(); |
| | | watchInfo.setMachine(machine); |
| | | watchInfo.setDirType(MachineFile.DIR_TYPE_TEMP); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 翻译共享文件夹路径到 标准网络路径,去掉末尾路径分割不 |
| | | * @param dirpath 原始路径 |
| | | * @return 转换后的路径 |
| | | */ |
| | | String fixMachineDir(String dirpath){ |
| | | return dirTranslator.trans(StringUtils.removeEnd(StringUtils.removeEnd(dirpath, "/"), "\\")); |
| | | } |
| | | |
| | | FileWatcherService.FileChangeListener getListener(WatchInfo info) { |
| | | return new MachineFileChangeListener(machineFileService,annotationService,info); |
| | | } |