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); + } + } + } + + +}