whycxzp
2024-12-31 44fad38cf4808c535c6d15f5366aa7cd09bfc3ee
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
package com.whyc.schedule;
 
import com.whyc.factory.ThreadPoolExecutorFactory;
import com.whyc.service.VideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
 
@EnableScheduling
@Component
public class VideoScheduleService {
 
    @Autowired
    private VideoService service;
 
    /**凌晨0点执行一次,录制视频流*/
    @Scheduled(cron = "0 0 0 * * ? ")
    public void getAndSaveB247(){
        ThreadPoolExecutorFactory.getPoolExecutor().execute(()->{
            //service.getAndSaveB247();
        });
    }
 
    /**凌晨0点0分2秒执行一次,停止上次的录制视频流*/
    @Scheduled(cron = "2 0 0 * * ? ")
    public void getAndSaveA250(){
        ThreadPoolExecutorFactory.getPoolExecutor().execute(()->{
            //service.getAndSaveA250();
        });
    }
 
}