燕山石化溯源三维电子沙盘-【后端】-服务
13693261870
2023-06-09 498718ad129e8a9010e6f2af2fde2f9d4508fd32
src/main/java/com/yssh/scheduled/ReadCsvTask.java
@@ -10,9 +10,8 @@
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;
@@ -28,21 +27,21 @@
@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<>();
@@ -65,7 +64,7 @@
         File file = new File(filePath);
         if (!file.exists()) {
            logger.error(file.getAbsolutePath() + " is not exist !");
            logger.info(file.getAbsolutePath() + " is not exist !");
            continue;
         }
@@ -81,9 +80,10 @@
         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);
         }
      }
   }
@@ -105,7 +105,7 @@
         File file = new File(filePath);
         if (!file.exists()) {
            logger.error(file.getAbsolutePath() + " is not exist !");
            logger.info(file.getAbsolutePath() + " is not exist !");
            continue;
         }
@@ -118,11 +118,13 @@
         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();
@@ -150,7 +152,7 @@
      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;
      }
      //创建表