|
@@ -1011,20 +1011,41 @@ public class TimingTask {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //每个月1号和2号早上6点同步上个月的企业微信考勤打卡记录
|
|
|
- @Scheduled(cron = "0 0 6 1,2 * ?")
|
|
|
+ //每个月第一个和第二个工作日早上6点同步上个月的企业微信考勤打卡记录
|
|
|
+ @Scheduled(cron = "0 0 6 ? * *")
|
|
|
private void synMonthCorpWXCardTime() {
|
|
|
if (isDev) return;
|
|
|
- LocalDateTime lastMonth = LocalDateTime.now().minusMonths(1);
|
|
|
- LocalDateTime start = lastMonth.withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0).withNano(0);
|
|
|
- LocalDateTime now = LocalDateTime.now().withDayOfMonth(1);
|
|
|
- LocalDateTime end = now.minusDays(1).withHour(0).withMinute(0).withSecond(0).withNano(0);
|
|
|
- System.out.println("开始同步上个月的考勤记录");
|
|
|
- List<TimeType> typeList = timeTypeMapper.selectList(new QueryWrapper<TimeType>().eq("sync_corpwx_time", 1));
|
|
|
- for (TimeType type : typeList) {
|
|
|
- Integer companyId = type.getCompanyId();
|
|
|
- wxCorpInfoService.getUserCheckInDayData(companyId, null, start, end, false);
|
|
|
+ LocalDateTime current = LocalDateTime.now();
|
|
|
+ LocalDate localDate = current.toLocalDate();
|
|
|
+ LocalDate firstDay = localDate.withDayOfMonth(1);
|
|
|
+ boolean todayIsFirstOrSecWorkDay = false;
|
|
|
+ int workDayCount = 0;
|
|
|
+ for (int i=0;i<10;i++) {
|
|
|
+ LocalDate targetDay = firstDay.plusDays(i);
|
|
|
+ if (WorkDayCalculateUtils.isWorkDay(targetDay)) {
|
|
|
+ workDayCount++;
|
|
|
+ if (targetDay.isEqual(localDate)) {
|
|
|
+ todayIsFirstOrSecWorkDay = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (workDayCount >= 2) break;
|
|
|
+ }
|
|
|
+ if (todayIsFirstOrSecWorkDay) {
|
|
|
+ LocalDateTime lastMonth = LocalDateTime.now().minusMonths(1);
|
|
|
+ LocalDateTime start = lastMonth.withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0).withNano(0);
|
|
|
+ LocalDateTime now = LocalDateTime.now().withDayOfMonth(1);
|
|
|
+ LocalDateTime end = now.minusDays(1).withHour(0).withMinute(0).withSecond(0).withNano(0);
|
|
|
+ System.out.println("开始同步上个月的考勤记录");
|
|
|
+ List<TimeType> typeList = timeTypeMapper.selectList(new QueryWrapper<TimeType>().eq("sync_corpwx_time", 1));
|
|
|
+ for (TimeType type : typeList) {
|
|
|
+ Integer companyId = type.getCompanyId();
|
|
|
+ wxCorpInfoService.getUserCheckInDayData(companyId, null, start, end, false);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ System.out.println("今天不是本月前两个工作日,不同步上月考勤");
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
//每半个小时推送一次token到每个公司
|
|
|
@Scheduled(fixedRate = 1800 * 1000)
|