| | |
| | | package org.jeecg.modules.dnc.listener; |
| | | import org.apache.commons.io.monitor.FileAlterationListener; |
| | | import org.apache.commons.io.monitor.FileAlterationObserver; |
| | | import org.jeecg.common.util.FileUtil; |
| | | import org.jeecg.modules.dnc.service.IDocInfoService; |
| | | import org.jeecg.modules.dnc.utils.file.FileUtilS; |
| | | import org.jeecg.modules.message.enums.DeployEnum; |
| | | import org.jeecg.modules.dnc.dto.TransferPackage; |
| | | import org.jeecg.modules.dnc.service.impl.DataImportService; |
| | | import org.jeecg.modules.dnc.service.impl.FileFerryService; |
| | | 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 { |
| | | private static final Logger log = LoggerFactory.getLogger(FileListener.class); |
| | | |
| | | @Autowired |
| | | private IDocInfoService docInfoService; // 文档服务 |
| | | private FileFerryService fileFerryService; |
| | | |
| | | @Autowired |
| | | private DataImportService dataImportService; |
| | | |
| | | |
| | | @Override |
| | | public void onStart(FileAlterationObserver observer) { |
| | |
| | | public void onFileCreate(File file) { |
| | | String filePath = file.getAbsolutePath(); |
| | | log.info("[新建]: {}", filePath); |
| | | // 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) { |