From a5eba18449f6871931ff2ad8897287f42149a8a6 Mon Sep 17 00:00:00 2001 From: Mzaxd Date: Thu, 18 May 2023 17:20:37 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=85=A8=E9=87=8F=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/schedule/SyncIAMScheduleJob.java | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 adc-da-sys/src/main/java/com/adc/da/sync/service/schedule/SyncIAMScheduleJob.java diff --git a/adc-da-sys/src/main/java/com/adc/da/sync/service/schedule/SyncIAMScheduleJob.java b/adc-da-sys/src/main/java/com/adc/da/sync/service/schedule/SyncIAMScheduleJob.java new file mode 100644 index 0000000..74668ca --- /dev/null +++ b/adc-da-sys/src/main/java/com/adc/da/sync/service/schedule/SyncIAMScheduleJob.java @@ -0,0 +1,61 @@ +package com.adc.da.sync.service.schedule; + +import com.adc.da.sync.service.SyncIAMTimer; +import com.adc.da.sys.vo.iam.CmpOrgResult; +import com.adc.da.sys.vo.iam.CmpUserResult; +import lombok.extern.slf4j.Slf4j; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; + +/** + * @author: CaiHaohan + * @Date: 2023/5/17 16:54 + * @Description: + */ +@Component +@EnableScheduling +@Slf4j +public class SyncIAMScheduleJob { + + @Resource + private SyncIAMTimer syncIAMTimer; + + /** + * 同步部门 + */ + @Scheduled(cron = "0 0 4 ? * ?") + public void syncOrgData() { + int pageIndex = 1; + int pageSize = 1000; + + CmpOrgResult cmpOrgResult = this.syncIAMTimer.syncOrgIncrData(pageIndex, pageSize); + if (cmpOrgResult != null) { + int totalPages = cmpOrgResult.getData().getPages(); + for (int i = pageIndex + 1; i <= totalPages; i++) { + this.syncIAMTimer.syncOrgIncrData(i, pageSize); + } + } + } + + /** + * 同步用户 + */ + @Scheduled(cron = "0 0 5 ? * ?") + public void syncUserData() { + int pageIndex = 1; + int pageSize = 1000; + + CmpUserResult cmpUserResult = this.syncIAMTimer.syncUserIncrData(pageIndex, pageSize, null); + if (cmpUserResult != null) { + int totalPages = cmpUserResult.getData().getPages(); + for (int i = pageIndex + 1; i <= totalPages; i++) { + this.syncIAMTimer.syncUserIncrData(i, pageSize, null); + } + } + } + + +}