| | |
| | | import com.yssh.entity.VocVals; |
| | | import com.yssh.service.VocValsService; |
| | | import com.yssh.utils.*; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | |
| | | |
| | | @Component |
| | | public class ReadCsvTask { |
| | | protected final Log logger = LogFactory.getLog(this.getClass()); |
| | | protected final Logger logger = LoggerFactory.getLogger(this.getClass()); |
| | | |
| | | @Resource |
| | | private VocValsService vocValsService; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | private SuYuanServiceImpl suYuanService; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | private CsvFilePathConfig csvFilePathConfig; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | private IDictRecordService dictRecordService; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | private IWarningAnalyseService warningAnalyseService; |
| | | |
| | | private final static List<String> md5List = new ArrayList<>(); |
| | |
| | | |
| | | File file = new File(filePath); |
| | | if (!file.exists()) { |
| | | logger.error(file.getAbsolutePath() + " is not exist !"); |
| | | logger.info(file.getAbsolutePath() + " is not exist !"); |
| | | continue; |
| | | } |
| | | |
| | |
| | | addFileMd5(md5); |
| | | |
| | | try { |
| | | logger.info("loadVocSync:" + filePath); |
| | | EasyCsv.read(filePath, VocVals.class, new VocParser(vocValsService, calendar.getTime())).doRead(); |
| | | } catch (Exception e) { |
| | | logger.error(e); |
| | | logger.error(e.getMessage(), e); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | File file = new File(filePath); |
| | | if (!file.exists()) { |
| | | logger.error(file.getAbsolutePath() + " is not exist !"); |
| | | logger.info(file.getAbsolutePath() + " is not exist !"); |
| | | continue; |
| | | } |
| | | |
| | |
| | | |
| | | suYuanService.createNewTable(newTableName); |
| | | dictRecordService.insertDictRecord(new DictRecord(1L, newTableName, Long.parseLong(time), "")); |
| | | |
| | | logger.info("loadCsvSync:" + filePath); |
| | | EasyCsv.read(filePath, SuYuan.class, new CsvParser(suYuanService, time)).doRead(); |
| | | |
| | | try { |
| | | // 计算预警/报警,并且进行入库操作 |
| | | Thread.sleep(60000); |
| | | Thread.sleep(10000); // 60000 |
| | | } catch (InterruptedException e) { |
| | | logger.error("睡眠一分钟后执行预警/报警计算,并且进行入库操作出现异常,异常原因是:", e); |
| | | e.printStackTrace(); |
| | |
| | | String filePath = csvFilePathConfig.getFilePath() + "\\\\" + time + ".csv"; |
| | | File file = new File(filePath); |
| | | if (!file.exists()) { |
| | | logger.error(file.getAbsolutePath() + " is not exist !"); |
| | | logger.info(file.getAbsolutePath() + " is not exist !"); |
| | | return; |
| | | } |
| | | //创建表 |