燕山石化溯源三维电子沙盘-【后端】-服务
13693261870
2023-06-15 9f4828565c45341aea69fb7aa7e434d972bc100c
修改voc和csv入库程序
已修改4个文件
28 ■■■■■ 文件已修改
src/main/java/com/yssh/run/InitDataRunner.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/scheduled/ReadCsvTask.java 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application-file.yml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application-scheduled.yml 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/run/InitDataRunner.java
@@ -51,7 +51,7 @@
    }
    private void test() {
        //task.corpReserveDataSync();
        task.corpReserveDataSync();
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.MONTH, 5);
@@ -61,6 +61,6 @@
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        warningAnalyseService.warningOperationStorage(calendar.getTime());
        //warningAnalyseService.warningOperationStorage(calendar.getTime());
    }
}
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 {
src/main/resources/application-file.yml
@@ -5,4 +5,4 @@
#csv配置路径
csv:
  filePath: 'D:\2022\yssh'
  vocPath: 'D:\2022\voc'
  vocPath: 'D:\2022\voc_all'
src/main/resources/application-scheduled.yml
@@ -1,3 +1,5 @@
csv: 
  cron: '0 1 * * * ? '
  voc: '0 31 12 * * ? '
  voc: '0 41 * * * ? '
  cron_max: 384
  voc_max: 360