| | |
| | | |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | |
| | | @Autowired |
| | | private IWarningAnalyseService warningAnalyseService; |
| | | |
| | | private final SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHH"); |
| | | |
| | | @Scheduled(cron = "${csv.cron}") |
| | | public void corpReserveDataSync() { |
| | | /*Date date = DateUtils.getNowDate(); |
| | | String time = DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, date); |
| | | String filePath = csvFilePathConfig.getFilePath() + "\\\\" + time + ".csv"; |
| | | File file = new File(filePath); |
| | | if (!file.exists()) { |
| | | logger.error(file.getAbsolutePath() + " is not exist ï¼"); |
| | | return; |
| | | } |
| | | //å建表 |
| | | String newTableName = TableStrategy.getTableStrategy(time); |
| | | suYuanService.createNewTable(newTableName); |
| | | dictRecordService.insertDictRecord(new DictRecord(1L, newTableName, Long.parseLong(time), "")); |
| | | EasyCsv.read(filePath, SuYuan.class, new CsvParser(suYuanService, time)).doRead(); |
| | | //计ç®é¢è¦/æ¥è¦,å¹¶ä¸è¿è¡å
¥åºæä½ |
| | | try { |
| | | Thread.sleep(1000 * 60 * 1); |
| | | } catch (InterruptedException e) { |
| | | logger.error("ç¡ç ä¸åéåæ§è¡é¢è¦/æ¥è¦è®¡ç®,å¹¶ä¸è¿è¡å
¥åºæä½åºç°å¼å¸¸ï¼å¼å¸¸åå æ¯ï¼", e); |
| | | e.printStackTrace(); |
| | | loadVoc(); |
| | | loadCsv(); |
| | | } |
| | | |
| | | private void loadVoc() { |
| | | Calendar calendar = getCalendar(96); |
| | | for (int i = 0; i < 192; i++) { |
| | | calendar.add(Calendar.HOUR, -1); |
| | | String time = format.format(calendar.getTime()); |
| | | String filePath = csvFilePathConfig.getVocPath() + File.separator + time + ".csv"; |
| | | |
| | | File file = new File(filePath); |
| | | if (!file.exists()) { |
| | | logger.error(file.getAbsolutePath() + " is not exist ï¼"); |
| | | continue; |
| | | } |
| | | |
| | | |
| | | } |
| | | warningAnalyseService.warningOperationStorage(date);*/ |
| | | } |
| | | |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHH"); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(new Date()); |
| | | calendar.add(Calendar.HOUR, 1); |
| | | |
| | | // æµè¯ -> 2023-04-23 19:00 |
| | | //calendar.set(Calendar.MONTH, 3); |
| | | //calendar.set(Calendar.DAY_OF_MONTH, 23); |
| | | //calendar.set(Calendar.HOUR_OF_DAY, 20); |
| | | |
| | | private void loadCsv() { |
| | | Calendar calendar = getCalendar(1); |
| | | for (int i = 0; i < 25; i++) { |
| | | calendar.add(Calendar.HOUR, -1); |
| | | String time = dateFormat.format(calendar.getTime()); |
| | | String time = format.format(calendar.getTime()); |
| | | String filePath = csvFilePathConfig.getFilePath() + "\\\\" + time + ".csv"; |
| | | |
| | | File file = new File(filePath); |
| | |
| | | warningAnalyseService.warningOperationStorage(calendar.getTime()); |
| | | } |
| | | } |
| | | |
| | | private Calendar getCalendar(int start) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(new Date()); |
| | | calendar.add(Calendar.HOUR, start); |
| | | |
| | | // æµè¯ -> 2023-04-23 19:00 |
| | | //calendar.set(Calendar.MONTH, 3); |
| | | //calendar.set(Calendar.DAY_OF_MONTH, 23); |
| | | //calendar.set(Calendar.HOUR_OF_DAY, 20); |
| | | |
| | | return calendar; |
| | | } |
| | | |
| | | private void loadCsv_old() { |
| | | Date date = DateUtils.getNowDate(); |
| | | String time = DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, date); |
| | | String filePath = csvFilePathConfig.getFilePath() + "\\\\" + time + ".csv"; |
| | | File file = new File(filePath); |
| | | if (!file.exists()) { |
| | | logger.error(file.getAbsolutePath() + " is not exist ï¼"); |
| | | return; |
| | | } |
| | | //å建表 |
| | | String newTableName = TableStrategy.getTableStrategy(time); |
| | | suYuanService.createNewTable(newTableName); |
| | | dictRecordService.insertDictRecord(new DictRecord(1L, newTableName, Long.parseLong(time), "")); |
| | | EasyCsv.read(filePath, SuYuan.class, new CsvParser(suYuanService, time)).doRead(); |
| | | //计ç®é¢è¦/æ¥è¦,å¹¶ä¸è¿è¡å
¥åºæä½ |
| | | try { |
| | | Thread.sleep(1000 * 60 * 1); |
| | | } catch (InterruptedException e) { |
| | | logger.error("ç¡ç ä¸åéåæ§è¡é¢è¦/æ¥è¦è®¡ç®,å¹¶ä¸è¿è¡å
¥åºæä½åºç°å¼å¸¸ï¼å¼å¸¸åå æ¯ï¼", e); |
| | | e.printStackTrace(); |
| | | } |
| | | warningAnalyseService.warningOperationStorage(date); |
| | | } |
| | | } |