路泰机电科技体检——数据平台后端
zhaowenxuan
2024-07-01 6cf4b661abe31a8502d7e686f1a8eb849c00c1e7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.example.scheudleds;
 
import com.example.utils.DictionaryUtil;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
 
import java.io.FileWriter;
import java.io.IOException;
 
@Slf4j
@Component
@EnableScheduling
public class DictSync {
    @Autowired
    private DictionaryUtil dictionaryUtil;
 
    /**
     * 字典同步
     */
    @Scheduled(cron = "0 0 22 * * ? ")
    public void execDict(){
        FileWriter fileWriter = null;
        try {
            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();
        }
    }
}