| | |
| | | package org.jeecg.modules.dnc.listener; |
| | | |
| | | import org.apache.commons.io.monitor.FileAlterationListener; |
| | | import org.apache.commons.io.monitor.FileAlterationObserver; |
| | | import org.jeecg.modules.dnc.dto.TransferPackage; |
| | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.io.File; |
| | | import java.util.Objects; |
| | | |
| | | @Component |
| | | public class FileListener implements FileAlterationListener { |
| | |
| | | |
| | | @Autowired |
| | | private DataImportService dataImportService; |
| | | |
| | | |
| | | @Override |
| | | public void onStart(FileAlterationObserver observer) { |
| | |
| | | public void onFileCreate(File file) { |
| | | String filePath = file.getAbsolutePath(); |
| | | log.info("[新建]: {}", filePath); |
| | | if (filePath.endsWith(".ferry")){ |
| | | TransferPackage data = fileFerryService.importData(filePath); |
| | | dataImportService.importTransferPackage(data); |
| | | log.info("文件导入完成"); |
| | | } |
| | | // if (filePath.startsWith(fileMonitorConfig.getPaths().get(0))){ |
| | | if (filePath.endsWith(".ferry")){ |
| | | TransferPackage data = fileFerryService.importData(filePath); |
| | | dataImportService.importTransferPackage(data); |
| | | log.info("文件导入完成"); |
| | | } |
| | | // } |
| | | } |
| | | @Override |
| | | public void onFileChange(File file) { |