| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- package com.malk.hake.schedule;
- import com.malk.hake.service.HKClient;
- import com.malk.utils.UtilDateTime;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
- import org.springframework.context.annotation.Configuration;
- import org.springframework.scheduling.annotation.EnableScheduling;
- import org.springframework.scheduling.annotation.Scheduled;
- import java.util.Date;
- /**
- * @EnableScheduling 开启定时任务 [配置参考McScheduleTask]
- */
- @Slf4j
- @Configuration
- @EnableScheduling
- @ConditionalOnProperty(name = {"spel.scheduling"})
- public class HKScheduleTask {
- @Autowired
- private HKClient hkClient;
- /**
- * 同步通讯录: 早上6:00, 下午16:00
- */
- @Scheduled(cron = "0 0 6,16 * * ? ")
- public void timer_1() {
- try {
- hkClient.syncContact(false);
- } catch (Exception e) {
- // 记录错误信息
- e.printStackTrace();
- }
- }
- /**
- * 同步通讯录: 中午11:30, 下午19:30
- */
- @Scheduled(cron = "0 30 11,19 * * ? ")
- public void timer_2() {
- try {
- hkClient.syncContact(false);
- } catch (Exception e) {
- // 记录错误信息
- e.printStackTrace();
- }
- }
- /**
- * 同步付款: 每次凌晨1点
- */
- @Scheduled(cron = "0 0 1 * * ? ")
- public void timer_3() {
- try {
- hkClient.syncMonitor("FKSQ", null);
- } catch (Exception e) {
- // 记录错误信息
- e.printStackTrace();
- }
- }
- /**
- * 同步预付款: 每次凌晨2点
- */
- @Scheduled(cron = "0 0 2 * * ? ")
- public void timer_4() {
- try {
- hkClient.syncMonitor("YFKSQ", null);
- } catch (Exception e) {
- // 记录错误信息
- e.printStackTrace();
- }
- }
- /**
- * 清理打卡标记位: 每天早晨7点 [废弃, 通过全量同步处理]
- */
- @Scheduled(cron = "0 0 7 * * ? ")
- public void timer_5() {
- //hkClient.clearClockStatus();
- }
- /**
- * 同步前一日全量考勤数据
- */
- @Scheduled(cron = "0 50 7 * * ? ")
- public void timer_6() {
- hkClient.syncAttendance(UtilDateTime.formatDate(new Date(new Date().getTime() - 24 * 60 * 60 * 1000)), null);
- }
- }
|