From 9f4828565c45341aea69fb7aa7e434d972bc100c Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期四, 15 六月 2023 16:55:47 +0800
Subject: [PATCH] 修改voc和csv入库程序

---
 src/main/java/com/yssh/scheduled/ReadCsvTask.java |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/src/main/java/com/yssh/scheduled/ReadCsvTask.java b/src/main/java/com/yssh/scheduled/ReadCsvTask.java
index cd06d1c..41d62c8 100644
--- a/src/main/java/com/yssh/scheduled/ReadCsvTask.java
+++ b/src/main/java/com/yssh/scheduled/ReadCsvTask.java
@@ -12,6 +12,7 @@
 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;
 
@@ -44,6 +45,12 @@
 	@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");
@@ -57,7 +64,7 @@
 	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";
@@ -80,8 +87,9 @@
 			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);
 			}
@@ -98,7 +106,7 @@
 	@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";
@@ -119,7 +127,7 @@
 			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 {

--
Gitblit v1.9.3