| | |
| | | import com.yssh.utils.*; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | |
| | | @Resource |
| | | private IWarningAnalyseService warningAnalyseService; |
| | | |
| | | @Value("${csv.cron_max}") |
| | | private int cronMax = 48; |
| | | |
| | | @Value("${csv.voc_max}") |
| | | private int vocMax = 192; |
| | | |
| | | private final static List<String> md5List = new ArrayList<>(); |
| | | |
| | | private final static SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHH"); |
| | |
| | | private void loadVocSync() { |
| | | vocValsService.deleteLastYear(); |
| | | Calendar calendar = getCalendar(96); |
| | | for (int i = 0; i < 192; i++) { |
| | | for (int i = 0; i < cronMax; i++) { |
| | | calendar.add(Calendar.HOUR, -1); |
| | | String time = format.format(calendar.getTime()); |
| | | String filePath = csvFilePathConfig.getVocPath() + File.separator + time + ".csv"; |
| | |
| | | addFileMd5(md5); |
| | | |
| | | try { |
| | | logger.info("loadVocSync:" + filePath); |
| | | EasyCsv.read(filePath, VocVals.class, new VocParser(vocValsService, calendar.getTime())).doRead(); |
| | | logger.info("loadVocSync: " + filePath); |
| | | Date date = (Date)calendar.getTime().clone(); |
| | | EasyCsv.read(filePath, VocVals.class, new VocParser(vocValsService, date)).doRead(); |
| | | } catch (Exception e) { |
| | | logger.error(e.getMessage(), e); |
| | | } |
| | |
| | | @Scheduled(cron = "${csv.cron}") |
| | | private void loadCsvSync() { |
| | | Calendar calendar = getCalendar(1); |
| | | for (int i = 0; i < 49; i++) { |
| | | for (int i = 0; i < vocMax; i++) { |
| | | calendar.add(Calendar.HOUR, -1); |
| | | String time = format.format(calendar.getTime()); |
| | | String filePath = csvFilePathConfig.getFilePath() + File.separator + time + ".csv"; |
| | |
| | | suYuanService.createNewTable(newTableName); |
| | | dictRecordService.insertDictRecord(new DictRecord(1L, newTableName, Long.parseLong(time), "")); |
| | | |
| | | logger.info("loadCsvSync:" + filePath); |
| | | logger.info("loadCsvSync: " + filePath); |
| | | EasyCsv.read(filePath, SuYuan.class, new CsvParser(suYuanService, time)).doRead(); |
| | | |
| | | try { |