燕山石化溯源三维电子沙盘-【后端】-服务
1
13693261870
2024-11-01 2b75d84cabc3416d903f425239c713b65a98503f
1
已修改5个文件
42 ■■■■■ 文件已修改
src/main/java/com/yssh/config/InitConfig.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/config/ScheduleConfig.java 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/utils/CsvParser.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application-scheduled.yml 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application-test.yml 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/config/InitConfig.java
@@ -28,8 +28,8 @@
    @Resource
    WarningAnalyseService warningAnalyseService;
    //@Resource
    //ScheduleConfig task;
    @Resource
    ScheduleConfig task;
    @Resource
    XlsReportService xlsReportService;
@@ -52,7 +52,6 @@
        //task.createMonthReport();
        //task.corpReserveDataSync();
        //task.corpReserveDataSync();
        //warningAnalyseService.warningOperationStorage(cal.getTime());
        /*Calendar cal1 = Calendar.getInstance();
src/main/java/com/yssh/config/ScheduleConfig.java
@@ -58,23 +58,34 @@
    @Value("${email.enable}")
    private Boolean enableEmail;
    private static boolean flag = false;
    private static final Object OBJ = new Object();
    private final static List<String> md5List = new ArrayList<>();
    private final static SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHH");
    public void corpReserveDataSync() {
        loadVocSync();
        //loadVocSync();
        loadCsvSync();
    }
    @Scheduled(cron = "${csv.cron}")
    private void loadCsvSync() {
        synchronized (OBJ) {
            if (flag) return;
            flag = true;
        }
        logger.info("***************** 开始执行CSV入库 *****************" + "\n");
        Calendar calendar = getCalendar(1);
        calendar.add(Calendar.HOUR, -cronMax);
        for (int i = 0; i < cronMax; i++) {
            try {
                calendar.add(Calendar.HOUR, -1);
                calendar.add(Calendar.HOUR, 1);
                String time = format.format(calendar.getTime());
                System.out.println(time);
                String filePath = csvFilePathConfig.getFilePath() + File.separator + time + ".csv";
                File file = new File(filePath);
@@ -102,6 +113,7 @@
            }
        }
        logger.info("***************** CSV入库执行完成 *****************" + "\n");
        flag = false;
    }
    public Calendar getCalendar(int start) {
src/main/java/com/yssh/utils/CsvParser.java
@@ -56,8 +56,13 @@
        /*if ("0_0_0".equals(t.getId())) {
            return; // 解决主键重复
        }*/
        if (t.getZ() > 0 && t.getC() < jcyj) {
        /*if (t.getZ() > 0 && t.getC() < jcyj) {
            return; // 只入第0层数据+Voc值大于1
        }*/
        // 只入值 > =0.05
        if (t.getC() < 0.1) {
            return;
        }
        cachedData.add(t);
src/main/resources/application-scheduled.yml
@@ -1,7 +1,7 @@
csv:
  # 221Mb CSV入库时间
  cron: '0 35 * * * ?'
  cron_max: 720
  # 221Mb CSV入库时间,35,720
  cron: '0/5 * * * * ?'
  cron_max: 5200
  # 112Kb CSV入库时间
  voc: '0 40 * * * ?'
src/main/resources/application-test.yml
@@ -21,11 +21,11 @@
    datasource:
        type: com.alibaba.druid.pool.DruidDataSource
        driverClassName: com.mysql.cj.jdbc.Driver
        #url: jdbc:mysql://127.0.0.1:3306/yssh?useUnicode=true&rewriteBatchedStatements=true&characterEncoding=utf-8&useSSL=true&serverTimezone=GMT%2B8
        url: jdbc:mysql://192.168.11.206:3306/yssh?useUnicode=true&rewriteBatchedStatements=true&characterEncoding=utf-8&useSSL=true&serverTimezone=GMT%2B8
        url: jdbc:mysql://127.0.0.1:3306/yssh?useUnicode=true&rewriteBatchedStatements=true&characterEncoding=utf-8&useSSL=true&serverTimezone=GMT%2B8
        #url: jdbc:mysql://192.168.11.206:3306/yssh?useUnicode=true&rewriteBatchedStatements=true&characterEncoding=utf-8&useSSL=true&serverTimezone=GMT%2B8
        username: root
        #password: mysql
        password: 123456
        password: mysql
        #password: 123456
        # 初始连接数
        initialSize: 10
        # 最小连接池数量