路泰机电科技体检——数据平台后端
zhaowenxuan
2024-12-18 9449b5f71bd0c20ed9aefd025ee87c69bcdfbd40
src/main/java/com/example/scheudleds/DictSync.java
@@ -1,6 +1,7 @@
package com.example.scheudleds;
import com.example.utils.DictionaryUtil;
import com.example.utils.DictionaryUtilNew;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -9,6 +10,7 @@
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.io.FileWriter;
import java.io.IOException;
@Slf4j
@@ -17,17 +19,26 @@
public class DictSync {
    @Autowired
    private DictionaryUtil dictionaryUtil;
    @Autowired
    private DictionaryUtilNew dictionaryUtilNew;
    /**
     * 字典同步
     */
    @Scheduled(cron = "0 0 22 * * ? ")
    public void execDict(){
        FileWriter fileWriter = null;
        try {
            dictionaryUtil.exec1();
        } catch (IOException e) {
            log.error("定时任务异常");
            e.printStackTrace();
        }
            fileWriter = new FileWriter("src/main/resources/log.log");
            fileWriter.write("");
            fileWriter.close();
        } catch (IOException ignored) {}
//        try {
//            dictionaryUtil.exec1();
//        } catch (IOException e) {
//            log.error("定时任务异常");
//            e.printStackTrace();
//        }
        dictionaryUtilNew.exec1();
    }
}